主子表subdata.html页面添加商品时间选择

This commit is contained in:
Ricky 2020-06-29 10:06:56 +08:00
parent 9627ba9e1d
commit df29372303
3 changed files with 68 additions and 1 deletions

View File

@ -30,6 +30,11 @@ public class GoodsModel
*/
private String type;
/**
* 时间
*/
private String time;
public String getName()
{
return name;
@ -70,13 +75,22 @@ public class GoodsModel
this.type = type;
}
@Override
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("name", getName())
.append("weight", getWeight())
.append("price", getPrice())
.append("type", getType())
.append("time", getTime())
.toString();
}
}

View File

@ -0,0 +1,43 @@
/**
* bootstrapTable行内编辑扩展
* 可以自行扩展其他属性如data-type="date"
*/
(function($) {
'use strict';
var BootstrapTable = $.fn.bootstrapTable.Constructor,
_initBody = BootstrapTable.prototype.initBody;
BootstrapTable.prototype.initBody = function() {
var that = this;
_initBody.apply(this, Array.prototype.slice.apply(arguments));
var data = that.getData();
var $tr = that.$body.find('tr');
$.each($tr, function(rowindex, row) {//循环行
var $td = $(row).find('td');//当前行的所有列
$.each(that.columns, function(columnindex, column) {//循环列
const $time = $($td[columnindex]).find('.time');// 查找时间控件
if($time.length > 0){
$time.each((i, element) => {//循环time控件获取element
//可以获取其他属性
layui.use('laydate', function () {
layui.laydate.render({
elem: element,
theme: 'molv',
trigger: 'click',
type: 'date',
done: function (value, d) {
//此处可以扩展callback
data[rowindex][column.field] = value;
}
});
});
});
}
});
});
};
})(jQuery);

View File

@ -82,6 +82,7 @@
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:src="@{/js/jquery.tmpl.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/editable/bootstrap-table-editable-inline.js}"></script>
<script th:inline="javascript">
$(function() {
var options = {
@ -129,6 +130,15 @@
return html;
}
},
{
field: 'time',
align: 'center',
title: '时间',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control time' type='text' name='goods[%s].time' value='%s'>", index, value);
return html;
}
},
{
field: 'type',
align: 'center',