fastadmin使用技巧分享 日期变更事件

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());
});
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值