let action = null; layui.config({ base: "/js/", version: 11 }).use(['system'], function () { var form = layui.form, $ = layui.jquery, system = layui.system, table = layui.table, u = new system.u(), areaName = 'configure', sendDataDesc = null, rowData = null, tableName = 'ProcessRoute'; action = { addOptions: function () { var options = { fromId: "#modifyForm form", url: `/${areaName}/${tableName}/Ins`, submit: "submit(fromAdd)" } return options; }, addOptionsDesc: function () { var options = { fromId: "#modifyFormDesc form", url: `/${areaName}/${tableName}/InsDesc`, content: $('#modifyFormDesc'), submit: "submit(fromAddDesc)" } return options; }, editOptions: function () { var options = { fromId: "#modifyForm form", url: `/${areaName}/${tableName}/Upd`, submit: "submit(fromUpdate)" } return options; }, editOptionsDesc: function () { var options = { fromId: "#modifyFormDesc form", url: `/${areaName}/${tableName}/UpdDesc`, content: $('#modifyFormDesc'), submit: "submit(fromUpdateDesc)" } return options; }, deleteOptions: function () { var options = { url: `/${areaName}/${tableName}/DelByIds`, keyId: "keys", titleConfirmDelete: "尽量不要删除,可以选择禁用(对应明细数据也将被删除)?" } return options; }, deleteOptionsDesc: function () { var options = { url: `/${areaName}/${tableName}/DelByIdsDesc`, keyId: "bodyKeys", titleConfirmDelete: "尽量不要删除,可以选择禁用?" } return options; }, exportOptions: function () { var options = { fromId: "listForm", url: `/${areaName}/${tableName}/Export`, isDefault: true, excelCols: { head: app.data.cols, body: app.data.colsDesc } } return options; }, queryOptions: function () { var options = { resetFrom: "form[lay-filter=listForm]", fromId: "listForm", urlExport: `/${areaName}/${tableName}/Export`, urlQuery: `/${areaName}/${tableName}/Load`, mainTable: app.data.tableIns } return options; }, uploadOptions: function () { var options = { url: `/${areaName}/${tableName}/Import` } return options; }, rowClickOptions: function () { var options = { isDefault: true, targetTableId: app.data.tableElem, tabfilter: "tableTabBody", tabId: 2, customFn: app.methods.initTableDesc } /* layer.msg('hello' + app.data.tableIns.lineCode);*/ return options; }, addBefore: function (callBack) { app.methods.initSelectProduct(); if (callBack != null) callBack(); }, addBeforeDesc: function (callBack) { $("input[name=headkeys]").val(sendDataDesc.headKeys); //callBack是回调函数,如果editBefore有ajax 放在成功之后 if (callBack != null) callBack(); }, addSaveBefore: function (data, callBack) { //$("input[name=materialCode]").attr("ts-selected", data.materialCode); if (typeof data.field.isDelete == "undefined") data.field["isDelete"] = "0"; if (callBack != null) callBack(); }, addSaveBeforeDesc: function (data, callBack) { if (typeof data.field.isDelete == "undefined") data.field["isDelete"] = "0"; //$("input[name=materialCode]").attr("ts-selected", data.materialCode); if (callBack != null) callBack(); }, editBefore: function (data, callBack) { app.methods.initSelectProduct(); //$("input[name=materialCode]").attr("ts-selected", data.materialCode); form.val("modifyForm", data); if (callBack != null) callBack(); }, editBeforeDesc: function (data, callBack) { $("input[name=headkeys]").val(sendDataDesc.headKeys); form.val("modifyFormDesc", data); if (callBack != null) callBack(); }, editSaveBefore: function (data, callBack) { if (typeof data.field.isDelete == "undefined") data.field["isDelete"] = "0"; if (callBack != null) callBack(); }, editSaveBeforeDesc: function (data, callBack) { if (typeof data.field.isDelete == "undefined") data.field["isDelete"] = "0"; if (callBack != null) callBack(); }, //当前行表格双击事件处理 customTableRowClick: function (obj, tableId) { if (tableId == app.data.tableElem) { rowData = obj.data; } }, //点击下拉框生成工序编号、工序名称 workCenterCodeFromEvent: function (data) { debugger if (data.value == "") { layer.msg("选择的工序序号错误", { icon: 6, shade: 0.4, time: u.config.errorTime }); return false; } //获取下拉框的值 var workCenterCode = data.value; //获取下拉框的值 var workCenterName = data.elem.selectedOptions[0].innerText; //自动生成 工序代码 = 工艺路线编码 + 工作中心代码 $("#oprSequenceCode").val(rowData.processCode + workCenterCode); //自动生成 工序名称 = 工艺路线名称 + 工作中心名称 $("#oprSequenceName").val(rowData.processName + workCenterName); }, //工艺产品 btnProcessProductRel: function (sU, toolbarId, obj) { debugger let checkStatus = table.checkStatus(toolbarId); if (checkStatus.data.length != 1) { layer.alert(sU.config.titleSelectOne, { icon: 2, shadeClose: true, title: sU.config.titleSelectOne }); return; } var processHeadKeys = checkStatus.data[0].keys; var lineCode = checkStatus.data[0].lineCode; var processCode = checkStatus.data[0].processCode; var processName = encodeURIComponent(checkStatus.data[0].processName); var url = `/configure/ProductHeader/Index?menuFlag=-2&selectColKeyCustom=productCode&page=ProcessRoute&processCode=${processCode}&processName=${processName}&processHeadKeys=${processHeadKeys}&lineCode=${lineCode}×tamp=${new Date().getTime()}`; var index = layer.open({ title: "工艺产品", type: 2, area: ['1000px', '600px'], content: url }); localStorage.setItem("openIndex", index); }, //所有动作成功之后 actionSuccess: (falg, curr = 1) => { u.refreshTable(app, u, sendDataDesc, falg); } } var app = { data: { cols: [[ { checkbox: true, fixed: true }, { field: 'id', width: 50, hide: true, title: 'id' }, { field: 'keys', width: 150, hide: true, title: 'keys' }, { field: 'processCode', width: 220, title: '工艺路线编码' }, { field: 'processName', width: 220, title: '工艺路线名称' }, { field: "productCode", width: 130, event: 'pageOpen', title: "产品列表详情", templet: function (d) { return `<a data-type="pageOpen" href="#" data-href="/configure/BaseProcessProductRel/Index?menuFlag=-2&processCode=${d.processCode}" style="color: cornflowerblue;text-decoration: underline;cursor:pointer">产品列表详情</a>`; } }, { field: 'lineCode', width: 80, title: '产线编码' ,hide: true }, { field: 'lineName', width: 200, title: '产线', hide: true }, { field: 'edition', width: 80, title: '版本'}, { field: 'otherCode', width: 150, title: '外部关联code' }, { field: 'plmeid', width: 150, title: 'plmeid', hide: true }, { field: 'isDelete', width: 120, title: '是否有效', templet: "#isSysDeleteTemplet" }, { field: 'createTime', width: 150, title: '建立时间' }, { field: 'createBy', width: 100, title: '建立者' }, { field: 'updateTime', width: 150, title: '更新时间' }, { field: 'updateBy', width: 100, title: '更新者' } ]], colsDesc: [[ { checkbox: true, fixed: true }, { field: 'id', width: 50, hide: true, title: 'id' }, { field: 'bodyKeys', width: 150, hide: true, title: 'bodyKeys' }, { field: 'headkeys', width: 150, hide: true, title: '用来和主表关联的guid' }, { field: 'oprSequenceCode', width: 200, title: '工序序号' }, { field: 'oprSequenceName', width: 220, title: '工序名称' }, { field: 'oprSequence', width: 100, title: '顺序' }, { field: 'workCenterCode', width: 150, title: '工作中心' }, { field: 'opeRatio', width: 100, title: '工序比例' }, { field: 'oprsequenceTime', width: 220, title: '工序耗时'}, { field: 'inspectionFlag', width: 120, title: '报检设置' }, { field: 'remarks', width: 100, title: '备注' }, { field: 'otherCode', width: 120, title: '外部编码' }, { field: 'isDelete', width: 120, title: '是否有效', templet: "#isSysDeleteTemplet" }, ]], urlTable: `/${areaName}/${tableName}/Load`, tableIns: null, tableInsDesc: null, tableElem: "mainList", tableElemDesc: "mainListDesc", selectOption: { Line: { SelType: "FromUrl", SelFrom: "/HomeRedis/GetBaseInfoByKey?key=base_line", SelLabel: "LineName", SelValue: "LineCode", Dom: [$("[name='lineCode']")] }, WorkCenter: { SelType: "FromUrl", SelFrom: "/configure/Workcenter/Load", SelLabel: "workCenterName", SelValue: "workCenterCode", Dom: [$("[name='workCenterCode']")] }, //返回的数据 用于后续操作 selectData: { } } }, methods: { initTable: function () { let options = { elem: "#" + app.data.tableElem, url: `/${areaName}/${tableName}/Load`, cols: u.columnRecord(app.data.tableElem, app.data.cols), toolbar: '#toolbarTable', height: "full-56" } app.data.tableIns = u.initTable(options); }, initTableDesc: function (obj) { sendDataDesc = { headKeys: obj.data.keys } let opt = { cols: u.columnRecord(app.data.tableElemDesc, app.data.colsDesc), elem: "#" + app.data.tableElemDesc, url: `/${areaName}/${tableName}/LoadDesc`, toolbar: '#toolbarTableDesc', height: "full-56", where: sendDataDesc } app.data.tableInsDesc = u.initTable(opt); }, initFrom: function () { u.initSelect(app.data.selectOption); }, initSelectProduct() { var opt1 = { elem: ".productCode", checkedKey: "productCode", doneKey: { key: "productCode", lableValue: "productName" }, searchKey: "productCode", searchName: "产品编码" }; u.initSelectProduct(opt1); } }, registerEvent: function () { }, init: function () { app.methods.initTable(); app.registerEvent(); app.methods.initFrom(); } }; app.init(); });