1、列表使用日期时间选择插件,而不是使用默认的时间段选择
//js中修改为
{field: 'overtimetime', title: __('Overtimetime'),operate:"datetime",addclass:'datetimepicker',extend:"data-date-format='YYYY-MM-DD' autocomplete=off",formatter: Table.api.formatter.datetime,datetimeFormat:'YYYY-MM-DD'},
//修改 app\common\controller\Backend.php 中buildparams方法中
在case 'IS NOT NULL':
$where[] = [$k, strtolower(str_replace('IS ', '', $sym))];
break;下方添加:(一定要条加到default前面)
case 'DATETIME':
$where[] = [$k, '=', strtotime($v)];
break;
2、列表项使用selectpage搜索
var table = $("#table");
table.on('post-common-search.bs.table', function (event, table) {
var form = $("form", table.$commonsearch);
$("input[name='processinstance_id']", form).addClass("selectpage").data("source", "processinstance/index").data("primaryKey", "id").data("field", "process_code").data("orderBy", "id desc");
$("input[name='department_id']", form).addClass("selectpage").data("source", "department/index").data("primaryKey", "id").data("field", "name").data("orderBy", "id asc");
$("input[name='user_id']", form).addClass("selectpage").data("source", "user/user/index").data("primaryKey", "id").data("field", "nickname").data("orderBy", "id asc");
Form.events.cxselect(form);
Form.events.selectpage(form);
});
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'user_id', title: __('User_id')},
{field: 'user.nickname', title: __('User.nickname'),operate:false},
{field: 'department_id', title: __('Department'),visible:false},
{field: 'department.name', title: __('Department'),operate:false},
{field: 'createdate', title: __('Createdate'), operate:'RANGE', addclass:'datetimerange'},
{field: 'type', title: __('申领部门'), searchList: {0:__('月购'),"1":__('急购')}, formatter: Table.api.formatter.status},
{field: 'month', title: __('Month'), searchList: {"1":__('Month 1'),"2":__('Month 2'),"3":__('Month 3'),"4":__('Month 4'),"5":__('Month 5'),"6":__('Month 6'),"7":__('Month 7'),"8":__('Month 8'),"9":__('Month 9'),"10":__('Month 10'),"11":__('Month 11'),"12":__('Month 12')}, formatter: Table.api.formatter.normal},
{field: 'remarks', title: __('Remarks'),visible:false},
{field: 'status', title: __('申请状态'), searchList: {0:__('待审核'),"1":__('已同意'),'2':__('已拒绝'),'3':__('已撤销'),'4':'已处理'}, formatter: Table.api.formatter.status},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'processinstance_id', title: __('Processinstance.process_code'),visible:false},
{field: 'processinstance.task_action_type', title: __('Task_action_type'), searchList: {"AND":__('Task_action_type and'),"OR":__('Task_action_type or'),"NONE":__('Task_action_type none'),"ORDER":__('Task_action_type order')}, formatter: Table.api.formatter.normal},
{field: 'processinstance.user_ids', title: __('Processinstance.user_ids')},
{field: 'processinstance.cc_list', title: __('Processinstance.cc_list')},
{field: 'processinstance.cc_position', title: __('Processinstance.Cc_position'), searchList: {"START":__('Cc_position start'),"FINISH":__('Cc_position finish'),"START_FINISH":__('Cc_position start_finish')}, formatter: Table.api.formatter.normal},
{field: 'processinstance.status', title: __('Processinstance.Status'), searchList: {"NEW":__('Status new'),"RUNNING":__('Status running'),"TERMINATED":__('Status terminated'),"COMPLETED":"已完成"}, formatter: Table.api.formatter.status,custom: {NEW:'yellow', RUNNING:'info',TERMINATED:'danger',COMPLETED:'success'}},
{field: 'custom', title: __('采购单'), operate: false, formatter: Controller.api.formatter.custom},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
3、日期变更事件 datetimepicker选中日期变更事件
$('.checkweek').on('dp.change', function(e){ //dp.change
console.log($(this).val());//当前变更元素的值
console.log($("#c-startdate").val());//也可以精准获取,适用于多个值联合判断
console.log($("#c-enddate").val());
});