import lodash, { add, cloneDeep } from "lodash"; import moment from "moment"; import { message, Form, Modal } from "antd"; import * as commonUtils from "@/utils/utils"; import * as commonConfig from "@/utils/config"; import * as commonServices from "@/services/services"; import * as commonFunc from "@/components/Common/commonFunc"; import FaceDetect from "@/components/FaceDetect"; import ShowType from "@/components/Common/CommonComponent"; const costomPageFun = ({ props, tableName, sFieldName, actionName }) => { const { sModelsId } = commonUtils.convertStrToObj( localStorage.xlybusinesscurrentMesPane ); let result = false; switch ( `${sModelsId}-${tableName}${ sFieldName ? `-${sFieldName}` : "" }-${actionName}` ) { case "12710101117087404588200-table0-mesTableLineAdd": case "12710101117260270570210-table0-mesTableLineAdd": case "12710101117087371044360-slave0-mesTableLineAdd": result = true; mesTableLineAdd1(props, tableName); break; case "12710101117302862361490-yftable2-mesTableLineAdd": result = true; mesTableLineAdd2(props, tableName); break; case "12710101117087404588200-table0-mesTableLineDel": case "12710101117260270570210-table0-mesTableLineDel": case "12710101117087371044360-slave0-mesTableLineDel": result = true; mesTableLineDel1(props, tableName); break; // case "12710101117087404588200-table0-tStartDate-mesTableChange": // mesTableChange1(props); // break; case "12710101117087404588200-table0-tEndDate-mesTableChange": case "12710101117260270570210-table0-tEndDate-mesTableChange": case "12710101117087371044360-slave0-tEndDate-mesTableChange": mesTableChange1(props, tableName); break; case "12710101117087397698150-table0-tWorkingDate-mesTableChange": case "12710101117087397698150-table0-sShift-mesTableChange": mesTableChange2(props, tableName); break; case "12710101117087397698150-table0-tConnectDate-mesTableChange": mesTableChange3(props, tableName); break; case "12710101117087404588200-table1-mesGetBtnsConfig": case "12710101117260270570210-table1-mesGetBtnsConfig": result = mesGetBtnsConfig1(props); break; case "12710101117087404588200-table1-mesTableBtnClick": case "12710101117260270570210-table1-mesTableBtnClick": { const { params = {} } = props; const { config = {} } = params; const { sControlName } = config; if (["BtnBelongDown", "BtnBelongUp"].includes(sControlName)) { result = true; mesTableBtnClick1({ ...props, sControlName }); } break; } case "12710101117087404588200-tableS6-mesTableBtnClick": case "12710101117087404588200-tableS77-mesTableBtnClick": { const { params = {} } = props; const { config = {} } = params; const { sControlName } = config; if (["BtnTable.View"].includes(sControlName)) { result = true; mesTableBtnClick2({ ...props, sControlName }); } break; } case "12710101117087404588200-tableS1-mesTableBtnClick": case "12710101117260270570210-tableS1-mesTableBtnClick": { const { params = {} } = props; const { config = {} } = params; const { sControlName } = config; if (["BtnTable.View"].includes(sControlName)) { result = true; mesTableBtnClick3({ ...props, sControlName, config }); } break; } case "12710101117089395856660-table1-mesTableBtnClick": { mesTableBtnClick4(props); result = true; } default: break; } switch (`${actionName}-${tableName}-${sFieldName}`) { case "mesBtnClick-slaveWypj2-BtnRight.Prior": result = true; handleSlaveWypj2BtnPre(props); break; case "mesBtnClick-slaveWypj2-BtnRight.BtnNext": result = true; handleSlaveWypj2BtnNext(props); break; case "mesBtnClick-salveWydm2-BtnRight.Prior": result = true; handleSalveWydm2BtnPre(props); break; case "mesBtnClick-salveWydm2-BtnRight.Next": result = true; handleSalveWydm2BtnNext(props); break; case "mesBtnClick-slaveWyrj2-BtnRight.Prior": result = true; handleSlaveWyrj2BtnPre(props); break; case "mesBtnClick-slaveWyrj2-BtnRight.Next": result = true; handleSlaveWyrj2BtnNext(props); break; case "mesBtnClick-tableS5-BtnRight.setting": window.bXingchejiluModal = true; case "mesBtnClick-table1-BtnRight.jzCheck": result = handleGetRefreshStatus(props); break; case "mesBtnClick-table1-BtnRight.ipqcCheck": case "mesBtnClick-table1-BtnRight.qualityCheck": case "mesBtnClick-table1-BtnRight.foremanCheck": case "mesBtnClick-table1-BtnRight.managerCheck": case "mesBtnClick-table1-BtnRight.otherCheck": result = true; handleZlxjCheck(props, sFieldName); break; default: break; } if ( ["mesBtnClick"].includes(actionName) && ["BtnRight.PriorCom", "BtnRight.NextCom"].includes(sFieldName) ) { handleUpDownData({ ...props, tableName, sFieldName }); return true; } return result; }; // 班组报工行车记录表格新增 const mesTableLineAdd1 = (props, tableName) => { // const tableName = "table0"; const { [`${tableName}SelectedRowKeys`]: selectedRowKeys, [`${tableName}Data`]: tableData = [] } = props; if (commonUtils.isEmptyObject(selectedRowKeys)) { message.info("请先选中一条行车记录数据!"); return; } const rowDataIndex = tableData.findIndex( item => item.sId === selectedRowKeys[0] ); if (rowDataIndex === -1) return; const rowData = tableData[rowDataIndex]; if (rowData.bSaveMes == 1 || rowData.bSaveAbnormal == 1) { message.info("数据已上报或已异常提报,不能拆分!"); return; } // if (rowData.sPlcMachineStatusName === "运行") { // message.info("运行中的行车记录不能执行该操作!"); // return; // } if (tableData.some(item => item.bUnChanged)) { message.info("请先修改刚新增的数据!"); return; } const rowDataCopy = JSON.parse(JSON.stringify(rowData)); rowDataCopy.sId = commonUtils.createSid(); rowDataCopy.handleType = "add"; rowDataCopy.bManual = true; if (tableName === "slave0") { rowDataCopy.sPlcMachineStatusName = "停机"; rowDataCopy.sPlcMachineStatus = "waitingWork"; rowDataCopy.sAbnormalEventId = ""; rowDataCopy.sClassifyName = ""; if (!rowData.bManual) { rowData.bUnChanged = true; } } // rowDataCopy.sPlcMachineStatusName = rowDataCopy.sPlcMachineStatusName + "-1"; rowDataCopy.sSrcHourId = rowData.sId; rowDataCopy.bUnChanged = true; rowDataCopy.bSaveMes = false; rowDataCopy.bSaveAbnormal = false; const tableDataNew = [...tableData]; tableDataNew.splice(rowDataIndex + 1, 0, rowDataCopy); props.onSaveState( { [`${tableName}Data`]: tableDataNew, [`${tableName}SelectedRowKeys`]: [rowDataCopy.sId] }, nextProps => { const name = tableName; const { [`${name}Config`]: tableConfig = {} } = nextProps; const rowClickConfig = tableConfig.gdsconfigformslave?.find( item => item.sControlName && item.sControlName.toLowerCase().includes("rowclick") ); if (!rowClickConfig) return; props.handleExecInstructSet({ btnConfig: rowClickConfig, nextProps: nextProps }); } ); }; // 研发工艺参数材料表新增 const mesTableLineAdd2 = (props, tableName) => { const oTab = document .querySelector('.ant-tabs-tabpane-active[id*="研发工艺参数"]') .querySelector(".ant-tabs-tab-active"); if (!oTab) return; const dataNodeKey = oTab.getAttribute("data-node-key") || ""; const sRev = dataNodeKey.split("_")[1]; if (!sRev) return; const newData = { sId: commonUtils.createSid(), handleType: "add", sParentId: props.yftable0Data?.[0]?.sId || "", sRev, bSave: 0 }; const { [`${tableName}Data`]: tableData = [] } = props; props.onSaveState({ [`${tableName}Data`]: [...tableData, newData] }); }; // 班组报工行车记录表格起始时间修改 const mesTableChange1 = (props, tableName) => { // const tableName = "table0"; const { [`${tableName}SelectedRowKeys`]: selectedRowKeys, [`${tableName}Data`]: tableData = [], rowDataOld } = props; let tableDataNew = lodash.cloneDeep(tableData); const rowDataIndex = tableData.findIndex( item => item.sId === selectedRowKeys[0] ); if (rowDataIndex === -1) return; const rowData = tableData[rowDataIndex]; const { sId, tStartDate, tEndDate } = rowData; if (!tEndDate && tEndDate == null) { message.info("结束时间不能为空!"); return; } let parentRowDataIndex = tableData.findIndex( item => item.sId !== sId && item.tStartDate === tStartDate ); if (parentRowDataIndex === -1) { parentRowDataIndex = tableData.findIndex( item => item.tStartDate === rowDataOld.tEndDate ); } if (parentRowDataIndex === -1) return; const parentRowData = tableData[parentRowDataIndex]; const { tStartDate: tStartDateParent, tEndDate: tEndDateParent } = parentRowData; // 检查tStartDate是否在tEndDate之前 if (moment(tEndDate).isBefore(moment(tStartDate))) { message.info("结束时间不能小于起始时间!", 3); tableDataNew[rowDataIndex] = rowDataOld; props.onSaveState({ [`${tableName}Data`]: tableDataNew }); return; } // 检查tStartDate是否在tStartDateParent之后 if (moment(tEndDate).isAfter(moment(tEndDateParent))) { message.info("结束不能大于父节点的结束时间!", 3); tableDataNew[rowDataIndex] = rowDataOld; props.onSaveState({ [`${tableName}Data`]: tableDataNew }); return; } // 检查tStartDate是否在当前时间之后 if (moment(tEndDate).isAfter(moment())) { message.info("结束不能大于当前时间!", 3); tableDataNew[rowDataIndex] = rowDataOld; props.onSaveState({ [`${tableName}Data`]: tableDataNew }); return; } // 父节点的结束时间改成当前行的起始时间 tableDataNew[rowDataIndex].bUnChanged = false; tableDataNew[parentRowDataIndex].tStartDate = tEndDate; tableDataNew[parentRowDataIndex].handleType = tableDataNew[parentRowDataIndex].handleType || "update"; // 时间倒序排序 tableDataNew.sort((a, b) => new Date(b.tEndDate) - new Date(a.tEndDate)); const addState = { [`${tableName}Data`]: tableDataNew }; props.onSaveState(addState); if (tableName === "table0") { handleMesSave({ ...props, ...addState }); } else if (tableName === "slave0") { handleMesSlave0Save({ ...props, ...addState }); } }; // 班组报工行车记录表格删除行 const mesTableLineDel1 = async (props, tableName) => { // const tableName = "table0"; const { delRowData = [{}], [`${tableName}Data`]: tableData = [] } = props; const { sSrcHourId, bUnChanged, tStartDate, tEndDate } = delRowData[0]; if (bUnChanged) { if (commonUtils.isNotEmptyArr(tableData)) { const addState = { [`${tableName}SelectedRowKeys`]: [tableData[0].sId], [`slave1SelectedRowKeys`]: [tableData[0].sAbnormalEventId] }; if (tableData.some(item => item.bUnChanged)) { addState[`${tableName}Data`] = tableData.map(item => ({ ...item, bUnChanged: undefined })); } props.onSaveState(addState); const name = tableName; const { [`${name}Config`]: tableConfig = {} } = props; const rowClickConfig = tableConfig.gdsconfigformslave?.find( item => item.sControlName && item.sControlName.toLowerCase().includes("rowclick") ); if (!rowClickConfig) return; await awaitPromiseReturn(); props.handleExecInstructSet({ btnConfig: rowClickConfig, nextProps: { ...props, [`${tableName}SelectedRowKeys`]: [tableData[0].sId] } }); } return; } // 找剩余数据中开始时间等于删除数据结束时间的那条数据 const iIndex = tableData.findIndex( item => !item.bUnChanged && (item.sSrcHourId === sSrcHourId || item.sId === sSrcHourId) && tEndDate === item.tStartDate ); if (iIndex === -1) { if (tableName === "table0") { handleMesSave1(props, delRowData[0]); } else if (tableName === "slave0") { handleMesSlave0Save1(props, delRowData[0]); } return; } const tableDataNew = lodash.cloneDeep(tableData); tableDataNew[iIndex].tStartDate = tStartDate; tableDataNew[iIndex].handleType = tableDataNew[iIndex].handleType || "update"; const addState = { [`${tableName}Data`]: tableDataNew }; props.onSaveState(addState); if (tableName === "table0") { handleMesSave1({ ...props, ...addState }, delRowData[0]); } else if (tableName === "slave0") { handleMesSlave0Save1({ ...props, ...addState }, delRowData[0]); } }; // 新增保存 const handleMesSave = props => { props.handleExecInstructSet({ nextProps: props, btnConfig: { showName: "保存", sInstruct: JSON.stringify([ { opr: "newempty", newDataset: "NewReportSlave" }, { opr: "edit", desDataset: "NewReportSlave", dataset: "table0@sec", sValue: "sNewReportSlaveId:table0.sId,sSrcHourId:table0.sSrcHourId,tEndDate:table0.tEndDate" }, { opr: "filter", srcDataset: "table0", newDataset: "OldReportSlave", dataset: "NewReportSlave,table0One", condition: "'${table0One.sId}'=='${NewReportSlave.sSrcHourId}'" }, { opr: "newempty", newDataset: "temp0" }, { opr: "edit", desDataset: "temp0", dataset: "NewReportSlave,OldReportSlave", sValue: "iOperateType:${1},sNewReportSlaveId:NewReportSlave.sNewReportSlaveId,sOldReportSlaveId:OldReportSlave.sId,tNewEndDate:NewReportSlave.tEndDate" }, { opr: "exesql", data: [ { sql: "call Sp_mes_Operate_ProductionReport(${iOperateType},${sNewReportSlaveId},${sOldReportSlaveId},${tNewEndDate})", srcDataset: "temp0" } ] }, { opr: "save", data: [ { tablename: "mftproductionreportslave", srcDataset: "table0" } ] }, { opr: "refresh", dataset: "table0,table1,table4,table0NotFirstlineSelected" } ]) }, inscallback: async () => { const name = "table0"; const { [`${name}Config`]: tableConfig = {} } = props; const rowClickConfig = tableConfig.gdsconfigformslave?.find( item => item.sControlName && item.sControlName.toLowerCase().includes("rowclick") ); if (!rowClickConfig) return; await awaitPromiseReturn(); props.handleExecInstructSet({ btnConfig: rowClickConfig, nextProps: props }); } }); }; const awaitPromiseReturn = async () => { let iCount = 0; while (window.instructSetLock) { await new Promise(resolve => setTimeout(resolve, 100)); console.log("等待执行", iCount); if (iCount > 30) break; iCount++; } }; // 新增保存 const handleMesSlave0Save = props => { props.handleExecInstructSet({ nextProps: props, btnConfig: { showName: "保存", sInstruct: JSON.stringify([ { opr: "newempty", newDataset: "NewReportSlave" }, { opr: "edit", desDataset: "NewReportSlave", dataset: "slave0@sec", sValue: "sNewReportSlaveId:slave0.sId,sSrcHourId:slave0.sSrcHourId,tEndDate:slave0.tEndDate" }, { opr: "filter", srcDataset: "slave0", newDataset: "OldReportSlave", dataset: "NewReportSlave,slave0One", condition: "'${slave0One.sId}'=='${NewReportSlave.sSrcHourId}'" }, { opr: "newempty", newDataset: "temp0" }, { opr: "edit", desDataset: "temp0", dataset: "NewReportSlave,OldReportSlave", sValue: "iOperateType:${1},sNewReportSlaveId:NewReportSlave.sNewReportSlaveId,sOldReportSlaveId:OldReportSlave.sId,tNewEndDate:NewReportSlave.tEndDate" }, { opr: "exesql", data: [ { sql: "call Sp_mes_Operate_ProductionReport(${iOperateType},${sNewReportSlaveId},${sOldReportSlaveId},${tNewEndDate})", srcDataset: "temp0" } ] }, { opr: "save", data: [ { tablename: "mftproductionreportslave", srcDataset: "slave0" } ] }, { opr: "refresh", dataset: "slave0,slave0NotFirstlineSelected" } ]) }, inscallback: async nextProps => { const name = "slave0"; const { [`${name}Config`]: tableConfig = {} } = props; const rowClickConfig = tableConfig.gdsconfigformslave?.find( item => item.sControlName && item.sControlName.toLowerCase().includes("rowclick") ); if (!rowClickConfig) return; await awaitPromiseReturn(); props.handleExecInstructSet({ btnConfig: rowClickConfig, nextProps: nextProps }); } }); }; // 删除保存 const handleMesSave1 = (props, delRow) => { props.app.globalFun.onSetMask(true); const temp0Data = []; temp0Data.push({ sNewReportSlaveId: delRow.sId, sOldReportSlaveId: delRow.sSrcHourId }); props.handleExecInstructSet({ nextProps: { ...props, temp0Data }, btnConfig: { showName: "保存", sInstruct: JSON.stringify([ { opr: "exesql", data: [ { sql: "call Sp_mes_Operate_ProductionReport(2,${sNewReportSlaveId},${sOldReportSlaveId},null)", srcDataset: "temp0" } ] }, // { // opr: "save", // // doNotRefresh: true, // data: [ // { tablename: "mftproductionreportslave", srcDataset: "table0" } // ] // }, // { // opr: "exesql", // data: [ // { // sql: // "update mftplctray A SET A.sReportTrayId= ${sOldReportSlaveId} WHERE A.sReportTrayId=${sNewReportSlaveId}", // srcDataset: "temp0" // }, // { // sql: // "delete from mftproductionreportemployee WHERE sSlaveId=${sNewReportSlaveId}", // srcDataset: "temp0" // } // ] // }, { opr: "refresh", dataset: "table0,table1,table4,tableS1,table0FirstlineSelected" } ]) }, inscallback: async nextProps => { const name = "table0"; const { [`${name}Config`]: tableConfig = {} } = props; const rowClickConfig = tableConfig.gdsconfigformslave?.find( item => item.sControlName && item.sControlName.toLowerCase().includes("rowclick") ); if (!rowClickConfig) return; await awaitPromiseReturn(); props.handleExecInstructSet({ btnConfig: rowClickConfig, nextProps: nextProps }); } }); }; // 删除保存 const handleMesSlave0Save1 = (props, delRow) => { props.app.globalFun.onSetMask(true); const temp0Data = []; temp0Data.push({ sNewReportSlaveId: delRow.sId, sOldReportSlaveId: delRow.sSrcHourId }); props.handleExecInstructSet({ nextProps: { ...props, temp0Data }, btnConfig: { showName: "保存", sInstruct: JSON.stringify([ // { // opr: "save", // // doNotRefresh: true, // data: [ // { tablename: "mftproductionreportslave", srcDataset: "slave0" } // ] // }, { opr: "exesql", data: [ { sql: "call Sp_mes_Operate_ProductionReport(2,${sNewReportSlaveId},${sOldReportSlaveId},null)", srcDataset: "temp0" } ] }, { opr: "refresh", dataset: "slave0,slave0FirstlineSelected" } ]) }, inscallback: async nextProps => { const name = "slave0"; const { [`${name}Config`]: tableConfig = {} } = props; const rowClickConfig = tableConfig.gdsconfigformslave?.find( item => item.sControlName && item.sControlName.toLowerCase().includes("rowclick") ); if (!rowClickConfig) return; await awaitPromiseReturn(); props.handleExecInstructSet({ btnConfig: rowClickConfig, nextProps: nextProps }); } }); }; // 班组报工托盘计数信息按钮 const mesGetBtnsConfig1 = props => { const { table0Data = [], table0SelectedRowKeys = [], btnsConfig = [] } = props; if (!table0SelectedRowKeys.length) { return []; } const table0Row = table0Data.find( item => item.sId === table0SelectedRowKeys[0] ); const sSrcHourId = table0Row?.sSrcHourId; // 是否新纪录 const bNewRecord = !!sSrcHourId; if (bNewRecord) { // 新纪录:调至上(不显示),第一条 调至下段亮 其他不亮 return btnsConfig.filter(item => item.sControlName !== "BtnBelongUp"); } else { // 原纪录:调至下(不显示),最后一条 调至上段亮 其他不亮 return btnsConfig.filter(item => item.sControlName !== "BtnBelongDown"); } }; // 班组报工托盘计数信息按钮点击事件 const mesTableBtnClick1 = props => { const { sControlName, table0Data = [], table0SelectedRowKeys = [], params } = props; const { record } = params; const table0Row = table0Data.find( item => item.sId === table0SelectedRowKeys[0] ); const { sId, sSrcHourId, tStartDate, tEndDate } = table0Row; let table0RowNext; if (sControlName === "BtnBelongDown") { // 调至下段 table0RowNext = table0Data.find( item => !item.bUnChanged && item.tStartDate === tEndDate && (item.sId === sSrcHourId || item.sSrcHourId === sSrcHourId || item.sSrcHourId === sId) ); } else { // 调至上段 table0RowNext = table0Data.find( item => !item.bUnChanged && item.tEndDate === tStartDate && (item.sId === sSrcHourId || item.sSrcHourId === sSrcHourId || item.sSrcHourId === sId) ); } const temp0Data = []; temp0Data.push({ sNewReportSlaveId: sId, sOldReportSlaveId: table0RowNext.sId, sTrayOutId: record.sId }); props.onExecInstructSet({ nextProps: { ...props, temp0Data }, btnConfig: { showName: "保存", sInstruct: JSON.stringify([ { opr: "exesql", data: [ { sql: "update mftplctray A SET A.sReportTrayId= ${sOldReportSlaveId} WHERE A.sReportTrayId=${sNewReportSlaveId} and A.sTrayOutId=${sTrayOutId}", srcDataset: "temp0" } ] }, { opr: "refresh", dataset: "table1" } ]) } }); }; // 班组报工历史日报查看详情按钮 const mesTableBtnClick2 = props => { const { params = {} } = props; const { record = {} } = params; const { tCreateDate, sTeamType } = record; if (!tCreateDate || !sTeamType) { message.info("缺少日期/班次!"); return; } const runningTime = moment(tCreateDate).format("YYYY-MM-DD"); const runningShift = sTeamType; props.onSaveState({ runningTime, runningShift, refreshTableList: ["table0"], selectedDataGroupFlagList: { table0: commonUtils.createSid() }, sSReserve1: record.sId, tableS0Data: [], tableS1Data: [], tableS3Data: [], tableS4Data: [], tableS5Data: [], tableS8Data: [], tableS9Data: [], tableS10Data: [] }); const oTabs = document.querySelectorAll(`.ant-tabs-tab-btn[id*="生产日报"]`); oTabs?.[0]?.click(); }; // 班组报工产量报工明细查看详情按钮 const mesTableBtnClick3 = props => { const { params = {}, table0Data = [], config } = props; const { record = {} } = params; const { sId, bHourlyReport } = record; if (bHourlyReport) { props.onExecInstructSet({ nextProps: props, btnConfig: config }); return; } const iIndex = table0Data.findIndex(item => item.sId === sId); if (iIndex === -1) { message.info("未找到对应报工任务,请检查登录班次!", 3); // props.onExecInstructSet({ // nextProps: props, // btnConfig: config // }); return; } props.onSaveState({ table0SelectedRowKeys: [], table4Data: [], table13Data: [] }); setTimeout(() => { props.onTableSelectRowChange("table0", [table0Data[iIndex].sId]); props.onSaveState({ refreshTableList: ["table0,table0NotFirstlineSelected"] }); }, 200); const oTabs = document.querySelectorAll(`.ant-tabs-tab-btn[id*="班组报工"]`); oTabs?.[0]?.click(); setTimeout(() => { const oTabs1 = document.querySelectorAll( `.ant-tabs-tab-btn[id*="产量上报信息"]` ); oTabs1?.[0]?.click(); }, 200); }; // 拼接详情上一卷按钮 const handleSlaveWypj2BtnPre = props => { const listName = "slaveWypj2"; const tableName = "slaveWypj3"; const { [`${listName}Data`]: listData = [], [`${tableName}Data`]: tableData = [] } = props; const [rowData = {}] = listData; const iIndex = tableData.findIndex(item => item.sId === rowData.sId); if (iIndex === -1) { message.info("暂无数据!"); return; } if (iIndex === 0) { message.info("已是第一条数据!"); return; } const sInstructStr = props[`${tableName}Config`]?.gdsconfigformslave.find( item => item.sControlName === "BtnTable.View" )?.sInstruct; if (!sInstructStr) return; const selectedRowKeys = [tableData[iIndex - 1].sId]; props.onSaveState( { [`${tableName}SelectedRowKeys`]: selectedRowKeys }, nextProps => { props.onExecInstructSet({ nextProps: nextProps, btnConfig: { showName: "上一卷", sInstruct: sInstructStr } }); } ); }; // 拼接详情下一卷按钮 const handleSlaveWypj2BtnNext = props => { const listName = "slaveWypj2"; const tableName = "slaveWypj3"; const { [`${listName}Data`]: listData = [], [`${tableName}Data`]: tableData = [] } = props; const [rowData = {}] = listData; const iIndex = tableData.findIndex(item => item.sId === rowData.sId); if (iIndex === -1) { message.info("暂无数据!"); return; } if (iIndex === tableData.length - 1) { message.info("已是最后一条数据!"); return; } const sInstructStr = props[`${tableName}Config`]?.gdsconfigformslave.find( item => item.sControlName === "BtnTable.View" )?.sInstruct; if (!sInstructStr) return; const selectedRowKeys = [tableData[iIndex + 1].sId]; props.onSaveState( { [`${tableName}SelectedRowKeys`]: selectedRowKeys }, nextProps => { props.onExecInstructSet({ nextProps: nextProps, btnConfig: { showName: "下一卷", sInstruct: sInstructStr } }); } ); }; // 复卷成品检验详情上一版按钮 const handleSalveWydm2BtnPre = props => { const listName = "salveWydm2"; const tableName = "salveWydm3"; const { [`${listName}Data`]: listData = [], [`${tableName}Data`]: tableData = [] } = props; const [rowData = {}] = listData; const iIndex = tableData.findIndex(item => item.sId === rowData.sId); if (iIndex === -1) { message.info("暂无数据!"); return; } if (iIndex === 0) { message.info("已是第一条数据!"); return; } const sInstructStr = props[`${tableName}Config`]?.gdsconfigformslave.find( item => item.sControlName === "BtnReelView" )?.sInstruct; if (!sInstructStr) return; const selectedRowKeys = [tableData[iIndex - 1].sId]; props.onSaveState( { [`${tableName}SelectedRowKeys`]: selectedRowKeys }, nextProps => { props.onExecInstructSet({ nextProps: nextProps, btnConfig: { showName: "上一版", sInstruct: sInstructStr } }); } ); }; // 复卷成品检验详情下一版按钮 const handleSalveWydm2BtnNext = props => { const listName = "salveWydm2"; const tableName = "salveWydm3"; const { [`${listName}Data`]: listData = [], [`${tableName}Data`]: tableData = [] } = props; const [rowData = {}] = listData; const iIndex = tableData.findIndex(item => item.sId === rowData.sId); if (iIndex === -1) { message.info("暂无数据!"); return; } if (iIndex === tableData.length - 1) { message.info("已是最后一条数据!"); return; } const sInstructStr = props[`${tableName}Config`]?.gdsconfigformslave.find( item => item.sControlName === "BtnReelView" )?.sInstruct; if (!sInstructStr) return; const selectedRowKeys = [tableData[iIndex + 1].sId]; props.onSaveState( { [`${tableName}SelectedRowKeys`]: selectedRowKeys }, nextProps => { props.onExecInstructSet({ nextProps: nextProps, btnConfig: { showName: "下一版", sInstruct: sInstructStr } }); } ); }; // 人检成品检验详情上一版按钮 const handleSlaveWyrj2BtnPre = props => { const listName = "slaveWyrj2"; const tableName = "slaveWyrj3"; const { [`${listName}Data`]: listData = [], [`${tableName}Data`]: tableData = [] } = props; const [rowData = {}] = listData; const iIndex = tableData.findIndex(item => item.sId === rowData.sId); console.log("=====rowData", rowData, tableData); if (iIndex === -1) { message.info("暂无数据!"); return; } if (iIndex === 0) { message.info("已是第一条数据!"); return; } const sInstructStr = props[`${tableName}Config`]?.gdsconfigformslave.find( item => item.sControlName === "BtnReelView" )?.sInstruct; if (!sInstructStr) return; const selectedRowKeys = [tableData[iIndex - 1].sId]; props.onSaveState( { [`${tableName}SelectedRowKeys`]: selectedRowKeys }, nextProps => { props.onExecInstructSet({ nextProps: nextProps, btnConfig: { showName: "上一版", sInstruct: sInstructStr } }); } ); }; // 人检成品检验详情下一版按钮 const handleSlaveWyrj2BtnNext = props => { const listName = "slaveWyrj2"; const tableName = "slaveWyrj3"; const { [`${listName}Data`]: listData = [], [`${tableName}Data`]: tableData = [] } = props; const [rowData = {}] = listData; const iIndex = tableData.findIndex(item => item.sId === rowData.sId); if (iIndex === -1) { message.info("暂无数据!"); return; } if (iIndex === tableData.length - 1) { message.info("已是最后一条数据!"); return; } const sInstructStr = props[`${tableName}Config`]?.gdsconfigformslave.find( item => item.sControlName === "BtnReelView" )?.sInstruct; if (!sInstructStr) return; const selectedRowKeys = [tableData[iIndex + 1].sId]; props.onSaveState( { [`${tableName}SelectedRowKeys`]: selectedRowKeys }, nextProps => { props.onExecInstructSet({ nextProps: nextProps, btnConfig: { showName: "下一版", sInstruct: sInstructStr } }); } ); }; const handleUpDownData = props => { const { tableName: showTableName, sFieldName } = props; if (typeof showTableName !== "string") return; const listName = showTableName; const tableName = showTableName.substr(0, showTableName.length - 1) + 3; const { [`${listName}Data`]: listData = [], [`${tableName}Data`]: tableData = [] } = props; const [rowData = {}] = listData; const iIndex = tableData.findIndex(item => item.sId === rowData.sId); if (iIndex === -1) { message.info("暂无数据!"); return; } if (["BtnRight.PriorCom"].includes(sFieldName) && iIndex === 0) { message.info("当前为首条数据!"); return; } if ( ["BtnRight.NextCom"].includes(sFieldName) && iIndex === tableData.length - 1 ) { message.info("已是最后一条数据!"); return; } const sInstructStr = props[`${tableName}Config`]?.gdsconfigformslave.find( item => item.sControlName === "BtnReelView" )?.sInstruct; if (!sInstructStr) return; const info = { "BtnRight.PriorCom": { index: iIndex - 1, message: "上一版" }, "BtnRight.NextCom": { index: iIndex + 1, message: "下一版" } }[sFieldName] || { index: iIndex, message: "当前" }; const selectedRowKeys = [tableData[info.index].sId]; props.onSaveState( { [`${tableName}SelectedRowKeys`]: selectedRowKeys }, nextProps => { props.onExecInstructSet({ nextProps: nextProps, btnConfig: { showName: info.message, sInstruct: sInstructStr } }); } ); }; // 生产执行-班组交接-白夜班/上班时间修改后,清空交接时间 const mesTableChange2 = (props, tableName) => { const { [`${tableName}Data`]: tableData = [] } = props; const tableDataNew = cloneDeep(tableData); delete tableDataNew[0].tConnectDate; props.onSaveState({ [`${tableName}Data`]: tableDataNew }); }; // 生产执行-班组交接-交接时间校验 早班 8:00-20:00 晚班 20:00-次日8:00 const mesTableChange3 = (props, tableName) => { const { [`${tableName}Data`]: tableData = [] } = props; const rowData = tableData[0]; const { tWorkingDate, sShift, tConnectDate } = rowData; if (!tWorkingDate) { message.warning("上班日期不能为空!"); mesTableChange2(props, tableName); return; } else if (!sShift) { message.warning("白夜班不能为空!"); mesTableChange2(props, tableName); return; } const time = moment(tWorkingDate).format("YYYY-MM-DD"); let startTime, endTime; if (sShift === "1" || sShift === "白班") { startTime = moment(`${time} 08:00:00`); endTime = moment(`${time} 20:00:00`); } else { startTime = moment(`${time} 20:00:00`); endTime = moment(`${time} 08:00:00`).add(1, "days"); } // 延迟加班的结束时间 = 当前时间 const { bDelayedOvertime } = commonUtils.getAppData("userinfo"); if (bDelayedOvertime) { endTime = moment(); } const checkTime = moment(tConnectDate); if ( !checkTime.isSameOrAfter(startTime) || !checkTime.isSameOrBefore(endTime) ) { let msg = ""; if (sShift === "1" || sShift === "白班") { if (bDelayedOvertime) { msg = `交接时间必须在${time}日8:00之后!`; } else { msg = `交接时间必须在${time}日8:00-20:00之间!`; } } else { if (bDelayedOvertime) { msg = `交接时间必须在${time}日20:00之后!`; } else { msg = `交接时间必须在${time}日20:00-次日8:00之间!`; } } message.warning(msg, 5); mesTableChange2(props, tableName); } }; const handleGetRefreshStatus = props => { const { refreshTableListCount = 0 } = props; if (!refreshTableListCount) { message.warning('请先等待页面初始化加载完成!'); return true; } else { return false; } } // 质量巡检-巡检项目-所有巡检按钮 const handleZlxjCheck = async (props, btnName) => { const { table0Data = [], table1Data = [], refreshTableListCount = 0 } = props; const { sTeamNo } = commonUtils.getAppData("userinfo"); if (!refreshTableListCount) { message.warning('请先等待页面初始化加载完成!'); return; } const typeList = { "BtnRight.ipqcCheck": '2', "BtnRight.qualityCheck": '3', "BtnRight.foremanCheck": '4', "BtnRight.managerCheck": '5', "BtnRight.otherCheck": '6' } const sCurRole = typeList[btnName]; const faceResult = await getFaceResult(props); if (!faceResult) return; const { name } = faceResult; if (!name) { message.warning('人脸信息获取失败,请重新尝试!'); return; } const table0DataNew = cloneDeep(table0Data); const table1DataNew = cloneDeep(table1Data); table0DataNew[0].sCurRole = sCurRole; table0DataNew[0].handleType = table0DataNew[0].handleType || 'update'; table1DataNew.unshift({ sId: commonUtils.createSid(), handleType: 'add', sSReserve1: sCurRole, bSave: 1, sParentId: table0Data[0].sId, tPollingTime: moment().format('YYYY-MM-DD HH:mm:ss'), sPollingPerson: name, sGroup: sTeamNo.substr(sTeamNo.length-1,1) === 'A' ? 'A' : 'B' }); props.onSaveState({ userfaceData: [faceResult], tempUserName: name, table0Data: table0DataNew, table1Data: table1DataNew }); } let loginInfo = {}; const sModelsId = "16034339700006038392152714521000"; const mesSysbrands = commonUtils.convertStrToObj( localStorage.getItem("mesSysbrands") ); const handleGetFormItem = (props, item) => { let enabledNew = true; const showTypeProps = { bNewForm: true, iColValue: 24, record: { ...mesSysbrands }, name: "master", formId: sModelsId, getSqlDropDownData: props.getSqlDropDownData, getSqlCondition: props.getSqlCondition, handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, getFloatNum: props.getFloatNum, getDateFormat: props.getDateFormat, onChange: (...args) => { loginInfo = { ...loginInfo, ...args[2] }; }, showConfig: { ...item, sDropDownType: "" }, formItemLayout: { labelCol: { span: 0 }, wrapperCol: { span: 24 } }, textArea: false, enabled: enabledNew, dataValue: undefined, bTable: item.sName !== "sPassWord", bViewTable: true, onFilterDropDownData: props.onFilterDropDownData, onSaveState: props.onSaveState, bPassWord: item.sName === "sPassWord", style: { backgroundColor: "#eaeaea" } }; return ( ); }; const getFaceResult = async (props) => { let faceResult = false; const selectMethod = commonFunc.showLocalMessage(props, 'selectMethod', '请选择验证方式'); const FriendlyReminder = commonFunc.showLocalMessage(props, 'FriendlyReminder', '温馨提示'); const accountPwd = commonFunc.showLocalMessage(props, 'account', '账号密码'); const faceRecognition = commonFunc.showLocalMessage(props, 'faceRecognition', '人脸识别'); const btnCancel = commonFunc.showLocalMessage(props, 'BtnCancel', '取消'); const btnSure = commonFunc.showLocalMessage(props, 'BtnSure', '确定'); const enterAccountPwd = commonFunc.showLocalMessage(props, 'enterAccountPwd', '请输入账号密码'); const nameNotEmpty = commonFunc.showLocalMessage(props, 'NameNotEmpty', '账号/姓名不能为空!'); const passwordNotEmpty = commonFunc.showLocalMessage(props, 'PasswordNotEmpty', '密码不能为空!'); const account = commonFunc.showLocalMessage(props, 'account', '账号'); const loginType = await new Promise(resolve => { Modal.confirm({ title: FriendlyReminder, content: selectMethod, closable: true, maskClosable: true, wrapClassName: "mesCommonModal", cancelText:accountPwd, okText: faceRecognition, onOk() { resolve(1); }, onCancel(e) { if (e.name) { resolve(2); Modal.destroyAll(); } else { resolve(0); } } }); }); if (loginType === 1) { // 人脸识别 faceResult = await new Promise(resolve => { const modal = Modal.info({ title: faceRecognition, keyboard: false, content: ( { const resultRowData = e.dataset.rows[0]; resolve(resultRowData); modal.destroy(); }} actionType={"identifyFace"} /> ), wrapClassName: "xlyFaceAuthModal", okText: btnCancel, onOk() { resolve(false); } }); }); } else if (loginType === 2) { // 账号密码登陆 let loginConfig; const configUrl = `${ commonConfig.server_host }business/getModelBysId/${sModelsId}?sModelsId=${sModelsId}&sName=/commonAuto`; const configReturn = (await commonServices.getService("", configUrl)) .data; if (configReturn.code === 1) { const dataReturn = configReturn.dataset.rows; if (commonUtils.isNotEmptyArr(dataReturn)) { const { formData } = dataReturn[0]; if (commonUtils.isNotEmptyArr(formData)) { loginConfig = formData[0].gdsconfigformslave.filter( item => item.bVisible && item.sName && ["sUserName", "sPassWord"].includes(item.sName) ); } } } else { message.error(configReturn.msg); } faceResult = await new Promise(resolve => { loginInfo = {}; Modal.confirm({ title: enterAccountPwd, content: (
{loginConfig.map(item => handleGetFormItem(props, item))}
), wrapClassName: "mesCommonModal mesLoginForm", cancelText: btnCancel, okText: btnSure, onOk(e) { if (e.name) { if (!loginInfo.sUserNo && !loginInfo.sUserName) { message.error(nameNotEmpty); return; } if (!loginInfo.sPassWord) { message.error(passwordNotEmpty); return; } const { sBrandsId, sSubsidiaryId } = mesSysbrands; const url = `${ commonConfig.server_host }userloginUserNo/${sBrandsId}/${sSubsidiaryId}`; const value = { username: loginInfo.sUserNo || loginInfo.sUserName, password: loginInfo.sPassWord }; commonServices .postValueService(null, value, url) .then(({ data: dataReturn }) => { const { msg, code, dataset } = dataReturn; if (code !== 1) { message.error(msg); return; } if (commonUtils.isNotEmptyObject(msg)) { message.warning(msg, 6); } const result = dataset.rows[0]; resolve(result); }); } }, onCancel() { resolve(false); } }); }); } Modal.destroyAll(); return faceResult; }; // 质量巡检-巡检项目-完成/修改 const mesTableBtnClick4 = async (props) => { const { params = {}, table0Data = [], table1Data = [], tempUserName } = props; const { config = {}, record } = params; const { sControlName } = config; const { sUserName } = commonUtils.getAppData("userinfo"); const { sPollingPerson, sQualityDeg } = record; const addState = {}; if (sPollingPerson && ![sUserName, tempUserName].includes(sPollingPerson)) { const faceResult = await getFaceResult(props); if (!faceResult) return; const { name } = faceResult; if (name !== sPollingPerson) { message.error("巡检人不一致!"); return; } addState.tempUserName = name; } if (sControlName === "BtnEdit") { props.onSaveState({ ...addState, table0Data: table0Data.map(item => ({ ...item, bSave: 1 })), table1Data: table1Data.map(item => { return item.sId === record.sId ? { ...item, bSave: 1 } : item; }), }) } else if (sControlName === "BtnFinish") { const bHasX = Object.keys(record).some(key => key?.startsWith("sItem") && record[key] === "✗"); if (bHasX && !sQualityDeg) { message.error("发现不合格项('✗'),但质量程度未填写,请补充!"); return; } const iIndex = table1Data.findIndex(item => item.sId === record.sId); table1Data[iIndex].bSave = 0; table1Data[iIndex].handleType = table1Data[iIndex].handleType || 'update' if (table1Data[iIndex].sSReserve1 === "1") { table1Data[iIndex].sPollingPerson = sUserName; } if (table1Data[iIndex].tPollingTime) { table1Data[iIndex].tSReserve1 = moment().format('YYYY-MM-DD HH:mm:ss'); } if (!table1Data[iIndex].tPollingTime) { table1Data[iIndex].tPollingTime = moment().format('YYYY-MM-DD HH:mm:ss'); } const addState1 = { table0Data: table0Data.map(item => ({ ...item, bSave: 0, handleType: item.handleType || 'update' })), table1Data }; props.onSaveState({ tempUserName: undefined, ...addState1 }); props.onExecInstructSet({ nextProps: { ...props, ...addState1 }, btnConfig: { showName: "保存", sInstruct: JSON.stringify([ { opr: "save", doNotRefresh: true, data: [ { tablename: "qlyqualityinspectionmaster", srcDataset: "table0" }, { tablename: "qlyqualityinspectionslave", srcDataset: "table1" } ] } ]) } }); } } export default costomPageFun;