//今日时间 var timestartaddDate=moment().subtract('days', 0).format('YYYY/M/DD'); var fun = { init: function () { // 初始化 commSelect.plName_select("#setting-parkIds", true); fun.createTableData(); fun.popDateinitHand(); fun.popDateinitIntel(); }, strFormatter: function (value) { if (value == undefined || value == null || value == "") { return '-'; } return value; }, //手动排班 生效时间初始化 popDateinitHand:function () { $('#timeinStartDatehand').val(moment().subtract('days', -1).format('YYYY-MM-DD')); $("#timeinStartDatehand").datetimepicker({ startDate: moment().subtract('days', 0).format('YYYY-MM-DD'), format: 'yyyy-mm-dd', autoclose: true, startView: 2, //maxDate:moment().subtract('months', 3), minView: 2, forceParse: false, clearBtn: true, //添加清除按钮,可选值:true/false locale: "zh-CN", language: 'zh-CN', pickerPosition: "bottom-right" }).on('changeDate', function(ev){ console.log((ev.date).toLocaleDateString()) console.log(timestartaddDate) if ((ev.date).toLocaleDateString() ==timestartaddDate){ $('#sche_alertmodel').modal('show'); } }); }, //智能排班 生效时间初始化 popDateinitIntel:function () { $('#timeinStartDate').val(moment().subtract('days', -1).format('YYYY-MM-DD')); $("#timeinStartDate").datetimepicker({ startDate: moment().subtract('days', 0).format('YYYY-MM-DD'), format: 'yyyy-mm-dd', autoclose: true, startView: 2, //maxDate:moment().subtract('months', 3), minView: 2, forceParse: false, clearBtn: true, //添加清除按钮,可选值:true/false locale: "zh-CN", language: 'zh-CN', pickerPosition: "bottom-right" }).on('changeDate', function(ev){ console.log((ev.date).toLocaleDateString()) console.log(timestartaddDate) if ((ev.date).toLocaleDateString() ==timestartaddDate){ $('#sche_alertmodel').modal('show'); } }); }, createTableData: function () { //结算记录表格 $('#sch-settingtable').bootstrapTable('destroy').bootstrapTable({ striped: true, //表格显示条纹 pagination: true, //启动分页 pageNumber: 1, //当前第几页 // showColumns: true, pageSize: 10, //每页显示的记录数 pageList: [10, 15, 20], //记录数可选列表 sidePagination: 'server', //表示服务端分页 queryParamsType: 'limit', method: 'POST', //请求方法 // fixedColumns: true, // fixedNumber: 1, // leftFixedColumns: true, // leftFixedNumber: 3, //rightFixedColumns: true, //rightFixedNumber: 1, // selectItemName: 'personCustName', paginationPreText: '<', paginationNextText: '>', ajax: schsettingRequest, //自定义ajax加载数据 uniqueId: 'id', columns: [ { field: 'id', title: 'id', width: '10%', visible: false, align: "left" }, { field: 'planName', title: '名称', width: '10%', visible: true, align: "center", formatter: function (value, row, index) { return '
' + value + '
' } }, { field: 'employeeNum', title: '收费员数量', width: '10%', visible: true, align: "center", formatter: function (value, row, index) { return '
' + value + '
' } }, { field: 'plNum', title: '停车场数量', width: '10%', align: "center", formatter: function (value, row, index) { return '
' + value + '
' } }, { field: 'berthRangeNum', title: '泊位区间数量', width: '10%', align: "center", formatter: function (value, row, index) { return '
' + value + '
' } }, { field: 'dutyCycle', title: '轮转周期', width: '10%', align: "center", formatter: function (value, row, index) { return '
' + value + '
' } }, { field: 'oper', title: '操作', width: '10%', align: "center", formatter: function (value, row, index) { var html = '查看 '; html += '删除' return html; } }, ] }); }, //正式提交排班计划 submitDutyRoster: function () { var planId = fun.generatorDutyRosterPlanId(); var planName = fun.getDutyRosterPlanName(); var restStrategy = fun.getRestStrategy(); var infoMap = fun.getSelectPlNoInfo(); var berthRangeNos = infoMap.berthRangeNos; var plNos=infoMap.plNos; var effectTime = Date.parse($('#timeinStartDate').val().replace(/-/g,"/")); var charCodes = fun.getSelectedCharger(); var req = { sysCode: sysComm.sysCode, planName: planName, planId: planId, plNum: plNos.length, employeeNum: charCodes.length, dutyCycle: restStrategy.dutyCycle, restType: restStrategy.restType, berthRangeNum: berthRangeNos.length, effectTime:effectTime }; var opt = { method: 'post', url: dataUrl.util.submitDutyRoster(), data: JSON.stringify(req), contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (res) { // console.log('正式提交排班计划:') // console.log(res) if (res.code == '8888') { //成功刷新table fun.createTableData(); $('#schedulingsetting-con').removeClass('display-none'); $('#schedulingsetting-wrap').addClass('display-none'); $('#plan-onestep-wrap').addClass('display-none'); $('#plan-twostep-wrap').addClass('display-none'); $('#plan-threestep-wrap').addClass('display-none'); $('#plan-fourstep-wrap').addClass('display-none'); $('#schplan_rule').addClass('display-none').text(''); } else { alert('保存失败'); } } }; sysAjax(opt); }, //提交排班计划 --手工排班 submitDutyRosterByHand: function () { var planId = fun.generatorDutyRosterPlanIdByHand(); var planName = fun.getDutyRosterPlanNameByHand(); var infoMap = fun.getSelectPlNoInfoByHand(); var berthRangeNos = infoMap.berthRangeNos; var plNos =infoMap.plNos; var dutyCycle = fun.getDutyDaysNumByHand(); var dutyData = JSON.parse($('#hand_duty_roster_data').data('handdata')); //生效时间 var effectTime = Date.parse($('#timeinStartDatehand').val().replace(/-/g,"/")); var charCodes = []; $.each(dutyData, function (index, item) { if ($.inArray(item.chargerCode, charCodes) < 0) { charCodes.push(item.chargerCode); } }); var req = { sysCode: sysComm.sysCode, planName: planName, planId: planId, plNum: plNos.length, employeeNum: charCodes.length, dutyCycle: dutyCycle, restType: '手工排班', berthRangeNum: berthRangeNos.length, effectTime:effectTime }; var opt = { method: 'post', url: dataUrl.util.submitDutyRoster(), data: JSON.stringify(req), contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (res) { // console.log('正式提交排班计划:') // console.log(res) if (res.code == '8888') { //成功刷新table fun.createTableData(); $('#schedulingsetting-con').removeClass('display-none'); $('#schedulingsetting-wraphand').addClass('display-none'); $('#plan-onestep-wraphand').addClass('display-none'); $('#plan-twostep-wraphand').addClass('display-none'); $('#plan-threestep-wraphand').addClass('display-none'); $('#plan-fourstep-wraphand').addClass('display-none'); $('#schplan_rulehand').addClass('display-none').text(''); } else { alert('保存失败'); } } }; sysAjax(opt); }, //生成智能排班计划临时数据 makeDutyRosterForAI: function () { //生效时间 var effectTime = Date.parse($('#timeinStartDate').val().replace(/-/g,"/")); var planId = fun.generatorDutyRosterPlanId(); var infoMap = fun.getSelectPlNoInfo(); var plNos = infoMap.plNos; var berthRangeNos = infoMap.berthRangeNos; var chargerCodes = fun.getSelectedChargerCodes(); var restStrategy = fun.getRestStrategy(); var req = { sysCode: sysComm.sysCode, plNos: plNos, berthRangeNos:berthRangeNos, planId: planId, chargerCodes: chargerCodes, cycleNum: restStrategy.dutyCycle, maxWorkDayNum: restStrategy.worknum, maxRestDayNum: 1, effectTime:effectTime }; var opt = { method: 'post', url: dataUrl.util.makeDutyRosterForAI(), data: JSON.stringify(req), contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (res) { // console.log('排班计划临时数据:') // console.log(res) if (res.code == '8888') { //将生成的数据放到 页面上 $('#ai_duty_roster_data').data('aidata', JSON.stringify(res.data)); fun.handelChargerViewDutyRosterDataset(res.data, 'preview'); $('#plan-threestep-wrap').addClass('display-none'); $('#plan-fourstep-wrap').removeClass('display-none'); $('#step-wrap').find('li').eq(3).addClass('step-wrap-active').siblings().removeClass('step-wrap-active'); } else { alert('生成失败'); } } }; sysAjax(opt); }, //查询排班计划基础数据 queryDutyRosterBase: function () { var planId = $('#schplan-toptablook').data('planid'); $("#toll-wrap").empty(); var req = { sysCode: sysComm.sysCode, planId: planId, }; if (fun.isChargerViewForViewPage()) { req.viewType = 10; req.workState = [10, 20]; } else { req.viewType = 20; req.workState = [10] } var opt = { method: 'post', url: dataUrl.util.queryDutyRosterBase(), data: JSON.stringify(req), contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (res) { // console.log('查询排班计划基础数据:') if (res.code == '8888') { if (fun.isChargerViewForViewPage()) { fun.handelChargerViewDutyRosterDataset(res.data, 'view'); } else { fun.handelParkViewDutyRosterDataset(res.data, 'view'); } } else { alert('查询失败'); } } }; sysAjax(opt); }, /** * 预览视图 表头 */ createDutyRosterViewTitle: function (dataLength, viewType) { if (viewType == undefined || null == viewType) { viewType = 'preview' } var html = '' //查看页面 是收费员视图 或者 预览页面 并且是收费员视图 if ((viewType == 'view' && fun.isChargerViewForViewPage()) || (viewType == 'preview' && fun.isChargerViewForPreview())) { html = '