diff --git a/erp-produce/src/main/resources/template/js/departmentMachining/arrange.js b/erp-produce/src/main/resources/template/js/departmentMachining/arrange.js index d30f980e92cd83c2bf85b821e5504aea49efa68b..f13145802bd86330325cc32a414e8a9032a40408 100644 --- a/erp-produce/src/main/resources/template/js/departmentMachining/arrange.js +++ b/erp-produce/src/main/resources/template/js/departmentMachining/arrange.js @@ -1,212 +1,150 @@ -// 已经选择的资产集合key:表格的行trId,value:资产信息 -// 改 -var allChooseFarm = {}; - layui.config({ base: basePath, version: skyeyeVersion }).extend({ window: 'js/winui.window' -}).define(['window', 'table','jquery', 'winui', 'form'], function (exports) { +}).define(['window', 'jquery', 'winui', 'form', 'laydate'], function (exports) { winui.renderColor(); var index = parent.layer.getFrameIndex(window.name); var $ = layui.$, form = layui.form, - table = layui.table; - // var selTemplate = getFileContent('tpl/template/select-option.tpl'); - let farmId = getNotUndefinedVal(GetUrlParam("id")); - // 改 - // let assetMap = {}; + laydate = layui.laydate; + var selTemplate = getFileContent('tpl/template/select-option.tpl'); + var id = GetUrlParam("id"); - initTableChooseUtil.initTable({ - id: "arrangeList", - cols: [ - {id: 'workshopId', title: '安排车间', formType: 'select', width: '150', verify: 'required',templet: function(d) { - var options = queryWorkshopList(); - return ''; - } - }, - {id: 'taskNumber', title: '安排任务数量', formType: 'input', width: '140', verify: 'required|number'} - ], - deleteRowCallback: function (trcusid) { - delete allChooseFarm[trcusid]; - }, - addRowCallback: function (trcusid) { - // if (!isNull(farmId)) { - // if (isNull(assetMap[farmId])) { - // AjaxPostUtil.request({url: sysMainMation.admBasePath + "queryAssetById", params: {"id": farmId}, type: 'json', method: 'GET', callback: function (json) { - // assetMap[farmId] = json.bean - // }, async: false}); - // } - // let chooseAssetMation = assetMap[farmId] - // // 获取表格行号 - // var thisRowKey = trcusid.replace("tr", ""); - // // 资产名称赋值 - // $("#farmId" + thisRowKey).val(chooseAssetMation.name); - // $("#farmId" + thisRowKey).attr(initTableChooseUtil.chooseInputDataIdKey, chooseAssetMation.id); - // // 资产赋值 - // allChooseFarm[trcusid] = chooseAssetMation; - // } - }, - form: form, - minData: 1 - }); - // - // var workshopId = ""; - // form.on('select(workshopId)', function(data) { - // console.log(555,data) - // // var thisRowValue = data.value; - // // workshopId = isNull(thisRowValue) ? "" : thisRowValue; - // aaa(); - // }); - // 渲染表格 -// function aaa(){ -// table.render({ -// id: 'arrangeList',//表格 -// elem: '#workshopId', //表格里的元素 -// method: 'post', -// url: sysMainMation.erpBasePath + 'erpfarm001', -// where: getTableParams(), -// even: true, -// page: true, -// limits: getLimits(), -// limit: getLimit(), -// done: function(json){ -// // 表格渲染完成后的回调 -// // 在这里添加事件监听 -// $('select[name="workshop"]').on('change', function(){ -// console.log('Workshop selected', $(this).val()); -// // 如果需要,可以在这里打印'123'或进行其他操作 -// }); -// -// $('input[name="taskNumber"]').on('click', function(){ -// console.log('taskNumber input clicked'); -// // 打印'123'或其他操作 -// }); -// } -// // done: function(json){ -// // console.log(json) -// // // matchingLanguage(); -// // // $('select[name="workshop"]').each(function(){ -// // // $(this).empty(); -// // // workshopData.forEach(function(item){ -// // // $(this).append(''); -// // // }, $(this)); -// // // }); -// // } -// }); -// } + AjaxPostUtil.request({url: sysMainMation.erpBasePath + "queryMachinProcedureById", params: {id: id}, type: 'json', method: 'GET', callback: function (json) { + $("#showForm").html(getDataUseHandlebars($("#beanTemplate").html(), json)); - function queryWorkshopList() { - // 假设您有一个函数可以处理Ajax请求 - AjaxPostUtil.request({ - url: sysMainMation.erpBasePath + "erpfarm001", - params: {page: 1, limit: 30}, - type: 'json', - method: "POST", - callback: function(json) { - console.log(666, json); - } + let par = { + workProcedureId: json.bean.procedureId + }; + let farmModelHtml = ''; + // 根据工序id查询可以执行该工序的车间 + AjaxPostUtil.request({url: sysMainMation.erpBasePath + "queryExecuteFarmByWorkProcedureId", params: par, type: 'json', method: 'GET', callback: function (json) { + farmModelHtml = getDataUseHandlebars(selTemplate, json); + }, async: false}); + + initTableChooseUtil.initTable({ + id: "arrangeList", + cols: [ + {id: 'farmId', title: '安排车间', formType: 'select', width: '200', verify: 'required', modelHtml: farmModelHtml }, + {id: 'targetNum', title: '安排任务数量', formType: 'input', width: '140', verify: 'required|number' }, + {id: 'stateName', title: '状态', formType: 'detail', width: '140' } + ], + deleteRowCallback: function (trcusid) {}, + addRowCallback: function (trcusid) {}, + form: form, + minData: 1 }); - } -// $("body").on("click", "workshopId", function (e) { -// // 查询车间列表 -// AjaxPostUtil.request({url: sysMainMation.erpBasePath + "erpfarm001", params: {page:1,limit:30}, type: 'json', method: "POST", callback: function(json) { -// console.log(666,json) -// // $("#workshopId").html(getDataUseHandlebars(selTemplate, json)); -// // form.render('select'); -// // initTable(); -// }, async: false}); -// }); + initTableChooseUtil.deleteAllRow('arrangeList'); + $.each(json.bean.machinProcedureFarmList, function(i, item) { + item.stateName = skyeyeClassEnumUtil.getEnumDataNameByCodeAndKey("machinProcedureFarmState", 'id', item.state, 'name'); + var trcusid = initTableChooseUtil.resetData('arrangeList', item); + var thisRowKey = trcusid.replace("tr", ""); + if (item.state != 'waitReceive') { + // 只有【待接收】的任务可以删除 + let itemBox = $('input[type="checkbox"][rowId="row' + thisRowKey + '"]'); + itemBox.prop('disabled', true); + itemBox.addClass('layui-btn-disabled'); + itemBox.next().css("cursor", "not-allowed"); + } + }); - // var workshopId = ""; - // form.on('select(workshopId)', function(data) { - // var thisRowValue = data.value; - // workshopId = isNull(thisRowValue) ? "" : thisRowValue; - // loadTable(); - // }); + var planStartTime = laydate.render({ + elem: '#planStartTime', //指定元素 + format: 'yyyy-MM-dd', + theme: 'grid', + done:function(value, date){ + planEndTime.config.min = { + year: date.year, + month: date.month - 1,//关键 + date: date.date, + hours: date.hours, + minutes: date.minutes, + seconds: date.seconds + }; + } + }); - // AjaxPostUtil.request({url: sysMainMation.erpBasePath + "erpfarm001", params: {page: page, limit: 15}, type: 'json', method: 'POST', callback: function (json) { - // parent.layer.close(index); - // parent.refreshCode = '0'; - // }}); + var planEndTime = laydate.render({ + elem: '#planEndTime', //指定元素 + format: 'yyyy-MM-dd', + theme: 'grid', + done:function(value, date){ + planStartTime.config.max = { + year: date.year, + month: date.month - 1,//关键 + date: date.date, + hours: date.hours, + minutes: date.minutes, + seconds: date.seconds + } + } + }); - matchingLanguage(); - form.render(); - form.on('submit(formAddBean)', function (data) { - if (winui.verifyForm(data.elem)) { - var result = initTableChooseUtil.getDataList('arrangeList'); - if (!result.checkResult) { - return false; + var actualStartTime = laydate.render({ + elem: '#actualStartTime', //指定元素 + format: 'yyyy-MM-dd', + theme: 'grid', + done:function(value, date){ + actualEndTime.config.min = { + year: date.year, + month: date.month - 1,//关键 + date: date.date, + hours: date.hours, + minutes: date.minutes, + seconds: date.seconds + }; } - var noError = false; - var tableData = []; - $.each(result.dataList, function(i, item) { - // 获取行编号 - var thisRowKey = item["trcusid"].replace("tr", ""); - if (parseInt(item.taskNumber) == 0) { - $("#taskNumber" + thisRowKey).addClass("layui-form-danger"); - $("#taskNumber" + thisRowKey).focus(); - winui.window.msg('数量不能为0', {icon: 2, time: 2000}); - noError = true; - return false; + }); + + var actualEndTime = laydate.render({ + elem: '#actualEndTime', //指定元素 + format: 'yyyy-MM-dd', + theme: 'grid', + done:function(value, date){ + actualStartTime.config.max = { + year: date.year, + month: date.month - 1,//关键 + date: date.date, + hours: date.hours, + minutes: date.minutes, + seconds: date.seconds } - // 车间对象 - // 更换下面两个 - // assert - // allChooseAsset - // inTableDataArrayByAssetarId - var farm = allChooseFarm["tr" + thisRowKey]; - if (inTableDataArrayByAssetarId(farm.id, tableData)) { - winui.window.msg('一张单中不允许出现相同的资产信息.', {icon: 2, time: 2000}); - noError = true; + } + }); + + matchingLanguage(); + form.render(); + form.on('submit(formAddBean)', function (data) { + if (winui.verifyForm(data.elem)) { + var result = initTableChooseUtil.getDataList('arrangeList'); + if (!result.checkResult) { return false; } - item["farmId"] = farm.id; - tableData.push(item); - }); - if (noError) { - return false; - } - var params = { - list: JSON.stringify(tableData), - }; - AjaxPostUtil.request({url: sysMainMation.admBasePath + "insertAssetReport", params: params, type: 'json', method: 'POST', callback: function (json) { + var params = { + id: id, + planStartTime: $("#planStartTime").val(), + planEndTime: $("#planEndTime").val(), + actualStartTime: $("#actualStartTime").val(), + actualEndTime: $("#actualEndTime").val(), + machinProcedureFarmList: JSON.stringify(result.dataList), + }; + AjaxPostUtil.request({url: sysMainMation.erpBasePath + "setMachinProcedureById", params: params, type: 'json', method: 'POST', callback: function (json) { parent.layer.close(index); parent.refreshCode = '0'; }}); - } - return false; - }); - - // 判断选中的资产是否也在数组中 - function inTableDataArrayByAssetarId(farmId, array) { - var isIn = false; - $.each(array, function(i, item) { - if(item.farmId === farmId) { - isIn = true; - return false; } + return false; }); - return isIn; - } + }}); + // 取消 $("body").on("click", "#cancle", function() { parent.layer.close(index); }); - function loadTable() { - table.reloadData("arrangeList", {where: getTableParams()}); - } - - function getTableParams() { - var params = { - type: 'farm', - objectId: workshopId - } - return $.extend(true, params, initTableSearchUtil.getSearchValue("messageTable")); - } }); \ No newline at end of file diff --git a/erp-produce/src/main/resources/template/js/departmentMachining/machiningGantt.js b/erp-produce/src/main/resources/template/js/departmentMachining/machiningGantt.js index 5113d4e572a722a248ee6484d72c43ba0867ff78..b2804842a0620c7a60d590f6cedeea00eef29e5e 100644 --- a/erp-produce/src/main/resources/template/js/departmentMachining/machiningGantt.js +++ b/erp-produce/src/main/resources/template/js/departmentMachining/machiningGantt.js @@ -11,22 +11,25 @@ layui.config({ var id = GetUrlParam("id"); let noteList = []; - // 根据id查询加工单信息 - AjaxPostUtil.request({url: sysMainMation.erpBasePath + "queryMachinForGanttById", params: {id: id}, type: 'json', method: 'GET', callback: function (json) { - matchingLanguage(); - form.render(); - renderPanel(); + loadDate(); + function loadDate() { + // 根据id查询加工单信息 + AjaxPostUtil.request({url: sysMainMation.erpBasePath + "queryMachinForGanttById", params: {id: id}, type: 'json', method: 'GET', callback: function (json) { + matchingLanguage(); + form.render(); + renderPanel(); - gantt.config.start_date = new Date(json.bean.mathinTime.start_time); - gantt.config.end_date = new Date(json.bean.mathinTime.end_time); - gantt.clearAll(); //清空缓存 - // 解析 - noteList = json.bean.node; - gantt.parse({ - data: json.bean.node, - links: json.bean.link - }); - }}); + gantt.config.start_date = new Date(json.bean.mathinTime.start_date); + gantt.config.end_date = new Date(json.bean.mathinTime.end_date); + gantt.clearAll(); //清空缓存 + // 解析 + noteList = json.bean.node; + gantt.parse({ + data: json.bean.node, + links: json.bean.link + }); + }}); + } function renderPanel() { document.getElementById('device_load').style.cssText = 'height:' + $(window).height() + 'px'; @@ -100,15 +103,14 @@ layui.config({ // e 参数是点击事件的事件对象 let item = getInPoingArr(noteList, "id", id, null); if (item.types != "project") { - console.log(item) _openNewWindows({ - url: "../../tpl/departmentMachining/arrange.html?id=" + id, + url: "../../tpl/departmentMachining/arrange.html?id=" + item.data.id, title: "车间任务安排", pageId: "workshopTaskArrangement", area: ['90vw', '90vh'], callBack: function (refreshCode) { winui.window.msg(systemLanguage["com.skyeye.successfulOperation"][languageType], {icon: 1, time: 2000}); - loadTable(); + loadDate(); }}); } // 返回true以允许默认行为继续,返回false可以阻止默认行为 diff --git a/erp-produce/src/main/resources/template/tpl/departmentMachining/arrange.html b/erp-produce/src/main/resources/template/tpl/departmentMachining/arrange.html index c10f10e2b0709f9b35025ba6c74b308cf3324870..e7b3cd79f5e2201429b3680a8d1bb15bb9faa1d0 100644 --- a/erp-produce/src/main/resources/template/tpl/departmentMachining/arrange.html +++ b/erp-produce/src/main/resources/template/tpl/departmentMachining/arrange.html @@ -6,67 +6,60 @@
-