/* eslint-disable */ import React, { Component } from 'react'; import { Layout, message, Input, Menu, Dropdown, Icon, Row, Col } from 'antd'; const { TextArea } = Input; import { Form } from '@ant-design/compatible'; import '@ant-design/compatible/assets/index.css'; import { routerRedux } from 'dva/router'; import StaticEditTable from '../../components/Common/CommonTable'; import oeeStyle from './oee.less'; import * as commonBusiness from '../../components/Common/commonBusiness'; import * as commonFunc from '../../components/Common/commonFunc'; import * as commonUtils from '../../utils/utils'; import * as commonConfig from '../../utils/config'; // import CommonBase from '../../components/Common/CommonBase'; // import CommonSales from '../../components/Common/CommonBillEvent'; import * as commonServices from '../../services/services'; import AntdDraggableModal from '../../components/Common/AntdDraggableModal'; import OeeChooseEmployee from '../../routes/oee/common/oeeChooseEmployee'; import OeeDownCountTime from '../../oee/common/oeeDownCountTime'; import styles from '../../routes/IndexPage.less'; import ShowType from '../../components/Common/CommonComponent'; import ShowImgStyle from '../../components/Common/ShowImage/ShowImage.less'; import ShowImg from '../../components/Common/ShowImage/ShowImage'; import faceReg from '../../assets/oee/facescan.svg'; import delIcon from '../../assets/oee/del0.png'; import voiceIcon from '../../assets/oee/voice0.png'; import refreshIcon from '../../assets/oee/refresh0.png'; import qrCode from '../../assets/oee/qr2.png'; // import {routerRedux} from "dva/router"; // const { Option } = Select; class OeeCurrentState extends Component { constructor(props) { super(props); this.state = { enabled: true, size: 'default', sTeamNameArr: [], // 班组下拉数组 isRender1: true, // 只渲染一次 imgAddWidth: false, // 图片放大 bool: true, // 重复点击 imgOffsetWidth: 0, // 图片的实际大小 imgOffsetHeight: 0, boxWidth: 0, // 图片外框大小 boxHeight: 0, // 图片外框大小 previewVisible: false, /* 图片预览弹窗 */ showimgs: false, // 必须字段控制弹框显示隐藏 firstIndex: 0, // 点击时默认下标s previewImage: '', insertList: [], }; this.timer = null; } componentDidUpdate() { // 设置table中的ant-table-body的高度,使滚动条至底 if (document.getElementsByClassName('employee-table')[0]) { const employeeStateHeight = document.getElementsByClassName('employeeState')[0].offsetHeight; const configsValueDivHeight = document.getElementsByClassName('configsValueDiv')[0].offsetHeight; const antTableHeader = document.getElementsByClassName('employee-table')[0].getElementsByClassName('ant-table-header')[0].offsetHeight; document.getElementsByClassName('employee-table')[0].getElementsByClassName('ant-table-body')[0].style.height = `${employeeStateHeight - 6 - configsValueDivHeight - antTableHeader}px`; } } componentDidMount() { this.props.onSaveState({ sBarcode: this.state.insertList.length ? this.state.insertList[0]: '' }); let insertArr = commonUtils.isJSON(localStorage.getItem(`xlybusinessiInsertCode_${this.props.sModelsId}`)) ? JSON.parse(localStorage.getItem(`xlybusinessiInsertCode_${this.props.sModelsId}`)) : ['', '', '', '']; this.setState({ insertList: insertArr }, () => { let idx = 0; let count = 0; for(let i = 0; i < this.state.insertList.length; i++) { if(this.state.insertList[i] === '') { idx = i; count++; break; } } if(!count) { idx = this.state.insertList.length; const arr = this.state.insertList.slice(0); arr.push(''); this.setState({ insertList: arr }) } this.props.onSaveState({ sBarcode: this.state.insertList.length ? this.state.insertList[0] : '' }) const focusInput = setInterval(() => { if(document.getElementById('input_' + idx)) { document.getElementById('input_' + idx).focus(); clearInterval(focusInput); } }, 500) }) window.oeeStartworkHandleRefresh = () => { this.handleRefresh(); } } componentWillUnmount() { clearInterval(this.timer); this.timer = null; window.oeeStartworkHandleRefresh = null; } async componentWillMount() { const { masterData: masterDataOld, token, sModelsId, slaveConfig, } = this.props; if (commonUtils.isNotEmptyObject(masterDataOld) && masterDataOld.dAllMoney <= 0) { // 取得主表中得默认计件工资 masterDataOld.dWageMoney = await commonBusiness.getFormulaValue({ token, sModelsId, masterDataOld, tableDataRow: masterDataOld, sComputeId: masterDataOld.sWageId, }); const returnData = await this.handleMasterChange('master', 'dProcessQty', { dProcessQty: masterDataOld.dProcessQty }, '', [], true); const statusMenus = await this.handleGetMenu(); this.props.onSaveState({ ...returnData, statusMenus, slaveConfig, }); if (commonUtils.isNotEmptyObject(masterDataOld.sMachinePicturePath)) { const dom = document.getElementById('picturesItem').getElementsByTagName('div')[0].getElementsByTagName('img')[0]; /* 如果超过屏幕高度 则为屏幕高度,否则传原图 */ let realWidth = dom.naturalWidth; let realHeight = dom.naturalHeight; // const viewWidth = document.body.clientWidth; /* 可视区域宽度 */ // const viewHeight = document.body.clientHeight; /* 可视区域高度 */ const viewWidth = window.screen.width; /* 屏幕宽度 */ const viewHeight = window.screen.height; /* 屏幕高度 */ realWidth = viewWidth; realHeight = viewHeight; const boxWidth = realWidth < 950 ? 950 : realWidth; const boxHeight = realWidth < 600 ? 600 : realHeight; this.setState({ // 获得图片的实际高宽度 imgOffsetWidth: realWidth, imgOffsetHeight: realHeight, boxWidth, boxHeight, }); } } } async componentWillReceiveProps(nextProps) { const { masterData: masterDataOld, app, slaveConfig, statusMenus, isFresh, } = nextProps; const { sTeamNameSId } = app; localStorage.setItem(`${commonConfig.prefix}oeeEmployeeData_${sTeamNameSId}`, JSON.stringify(nextProps.employeeData)); localStorage.setItem(`xlybusinessiInsertCode_${this.props.sModelsId}`, JSON.stringify(this.state.insertList)); // if (commonUtils.isNotEmptyObject(masterDataOld) && masterDataOld.dAllMoney <= 0 && this.state.isRender1) { // // 取得主表中得默认计件工资 // masterDataOld.dWageMoney = await commonBusiness.getFormulaValue({ // token, sModelsId, masterDataOld, tableDataRow: masterDataOld, sComputeId: masterDataOld.sWageId, // }); // const returnData = await this.handleMasterChange('master', 'dProcessQty', { dProcessQty: masterDataOld.dProcessQty }, '', [], true); // const statusMenus = await this.handleGetMenu(); // this.props.onSaveState({ // ...returnData, statusMenus, slaveConfig, // }); // // if (commonUtils.isNotEmptyObject(masterDataOld.sMachinePicturePath)) { // const dom = document.getElementById('picturesItem').getElementsByTagName('div')[0].getElementsByTagName('img')[0]; // /* 如果超过屏幕高度 则为屏幕高度,否则传原图 */ // let realWidth = dom.naturalWidth; // let realHeight = dom.naturalHeight; // // const viewWidth = document.body.clientWidth; /* 可视区域宽度 */ // // const viewHeight = document.body.clientHeight; /* 可视区域高度 */ // const viewWidth = window.screen.width; /* 屏幕宽度 */ // const viewHeight = window.screen.height; /* 屏幕高度 */ // realWidth = viewWidth; // realHeight = viewHeight; // const boxWidth = realWidth < 950 ? 950 : realWidth; // const boxHeight = realWidth < 600 ? 600 : realHeight; // this.setState({ // 获得图片的实际高宽度 // imgOffsetWidth: realWidth, // imgOffsetHeight: realHeight, // boxWidth, // boxHeight, // }); // } // this.setState({ // isRender1: false, // }); // } /* 初始化 按钮操作后 界面回刷时 都进行按钮状态亮与灰的判断 */ if (commonUtils.isNotEmptyObject(masterDataOld) && this.state.isRender1) { /* 如果iPlcNo > 0 则 上报数量控制不可输入 */ this.handleGetBtnStus(slaveConfig, masterDataOld); /* 根据状态控制按钮的亮与灰色 */ if (masterDataOld.iPlcNo > 0) { const iIndex = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.findIndex(item => item.sName === 'dProcessQty') : -1; if (iIndex > -1) { slaveConfig.gdsconfigformslave[iIndex].iTag = 2; } if(!this.timer) { this.timer = setInterval(async () => { await this.handleGetPlcData(masterDataOld, slaveConfig); }, 15000); } } if (commonUtils.isEmpty(statusMenus)) { /* 回刷页面 当机器状态数据为空时 调用接口获取状态下拉数据集 */ const buttonConfigs = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.sName === '' && item.showName !== '' && item.sControlName !== '' && item.bVisible && item.sControlName.indexOf('BtnEndWorkStatus') > -1) : []; if (commonUtils.isNotEmptyArr(buttonConfigs) && buttonConfigs.length > 0) { const statusMenus = await this.handleGetMenu(buttonConfigs); if (commonUtils.isNotEmptyArr(statusMenus)) { this.props.onSaveState({ statusMenus }); } } } this.setState({ isRender1: false, }); } if (isFresh) { this.props.onSaveState({ masterData: masterDataOld, isFresh: false, }); } } shouldComponentUpdate(nextProps) { const { employeeColumn } = nextProps; return commonUtils.isNotEmptyArr(employeeColumn); } handleGetMenu=async (configs) => { const { slaveConfig, sModelsId } = this.props; let dropdownData = []; // 取得配置中的按钮; let buttonConfigs = []; if (commonUtils.isEmptyArr(configs)) { buttonConfigs = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.sName === '' && item.showName !== '' && item.sControlName !== '' && item.bVisible && item.sControlName.indexOf('BtnEndWorkStatus') > -1) : []; } else { buttonConfigs = configs; } if (commonUtils.isNotEmptyArr(buttonConfigs) && buttonConfigs.length > 0) { const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', buttonConfigs[0]); /* 根据sName得到过滤数据s */ dropdownData = sqlDropDownData.dropDownData; return dropdownData; } } handleGetBtnStus=(slaveConfig, masterDataOld) => { /* 根据状态控制按钮的亮与灰色 */ // 取得配置中的按钮 const buttonConfigs = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.sName === '' && item.sControlName !== '' && item.bVisible && item.sControlName.indexOf('Btn') > -1) : []; if (commonUtils.isNotEmptyArr(buttonConfigs)) { buttonConfigs.forEach((btnItem) => { if (btnItem.sControlName === 'BtnEndWorkReset') { /* 生产复位 */ if (masterDataOld.sStatus !== 'waitingWork' && masterDataOld.sStatus !== 'startWorking' && masterDataOld.sStatus !== 'adjustment' && masterDataOld.sStatus !== 'doWorkEnd' && masterDataOld.sStatus !== 'endWorked') { /* 不等于生产中/调机中/停机待料时 生产复位亮 */ btnItem.btnStatus = true; } else { btnItem.btnStatus = false; } } else if (btnItem.sControlName === 'BtnEndWorkPart') { // if (masterDataOld.sStatus === 'startWorking' || masterDataOld.sStatus === 'adjustment') { /* 生产中、调机中 生产完工、部分完工 按钮亮 */ // btnItem.btnStatus = true; // } else { // btnItem.btnStatus = false; // } btnItem.btnStatus = true; } else if (btnItem.sControlName === 'BtnEndWork') { if (masterDataOld.sStatus === 'endWorked') { /* 生产中、调机中 生产完工、部分完工 按钮亮 */ btnItem.btnStatus = false; } else { btnItem.btnStatus = true; } } else if (btnItem.sControlName === 'BtnEndWorkOver') { /* 调机结束(机长首检) */ if (masterDataOld.sStatus !== 'startWorking' && masterDataOld.sStatus !== 'endWorked') { /* 调机中 调机结束亮 */ btnItem.btnStatus = true; } else { btnItem.btnStatus = false; } } else if (btnItem.sControlName === 'BtnEndWorkSearchPill') { /* 查看工单 */ btnItem.btnStatus = true; } else if (btnItem.sControlName === 'BtnEndWorkRemoveVoice') { /* 消音常亮 */ btnItem.btnStatus = true; } else if (btnItem.sControlName.indexOf('RightSelf')) { /* 自定义按钮常量 */ btnItem.btnStatus = true; } if (masterDataOld.sStatus === 'offwork' && btnItem.sControlName !== 'BtnEndWorkSearchPill') { btnItem.btnStatus = false; } const sIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === btnItem.sControlName); if (sIndex > -1) { slaveConfig.gdsconfigformslave[sIndex] = btnItem; } }); } } /* 每隔秒数 调用接口 */ handleGetPlcData = async (masterDataOld, slaveConfig) => { const dataUrl = `${commonConfig.server_host}oee/getPlcDataById/${masterDataOld.sId}?sModelsId=${this.props.sModelsId}&sBarcode=${this.props.sBarcode ? this.props.sBarcode.split('\n')[0] : ''}`; const dataReturn = (await commonServices.getService(this.props.app.token, dataUrl)).data; // const dataUrlWarn = `${commonConfig.server_host}oee/doSysMesMsg/delete/${masterDataOld.sId}?sModelsId=${this.props.sModelsId}`; // const dataReturnWarn = (await commonServices.getService(this.props.app.token, dataUrlWarn)).data; if (dataReturn.code === 1) { const returnData = dataReturn.dataset.rows; if (commonUtils.isNotEmptyArr(returnData)) { const addState = returnData[0]; // addState.dProcessQty = returnData[0].dProcessQty; // addState.sStatus = returnData[0].sStatus; if (commonUtils.isNotEmptyObject(addState)) { // masterDataOld = { ...masterDataOld, dProcessQty: addState.dProcessQty, status: addState.sStatus }; masterDataOld = { ...masterDataOld, ...addState }; this.handleGetBtnStus(slaveConfig, masterDataOld); if(addState.bFlushBarCode) { this.shiftInsertCode(); } this.props.onSaveState({ masterData: masterDataOld }); } } } else { this.props.getServiceError(dataReturn); } } handleInterfaceCall = async (obj, showTip, key) => { let bResult = false; const { app, sModelsId, masterData, slaveSelectedRowKeys} = this.props; const sInterfaceName = obj.sInterfaceName; const sApiUrl = obj.sApiUrl; /* 如果key是BtnSendList 传从表的主键集合 */ let idArr = ''; if(commonUtils.isNotEmptyObject(masterData)) { idArr = masterData.sId; } const value = { sId: idArr, userInfo: app.userinfo }; const url = `${commonConfig.interface_host}interfaceDefine/callthirdparty/${sInterfaceName}?sModelsId=${sModelsId}`; const returnData = (await commonServices.postValueService(app.token, value, url, app)).data; console.log('接口打印:', returnData); // if (showTip) { // if ((!returnData || returnData.code != 1)) { // if (returnData.code === -8) { // Modal.info({ // title: '温馨提示:', // content: ( //
// {this.handleGetMsg(returnData.msg)} //
// ), // okText: '确认', // onOk() {}, // }); // } // // message.error('同步INFOR失败!'); // return; // } else { // message.success('同步INFOR成功!'); // } // } // let inforEvent = ['itemiss', 'jobmatliss', 'jobmatliss-bz', 'jobmatliss-tl', 'jobmatliss-cx']; // if (obj && inforEvent.indexOf(obj.sInterfaceName) !== -1) { // if ((!returnData || returnData.code != 1)) { // if (returnData) { // if (returnData.code === -8) { // Modal.info({ // title: '温馨提示:', // content: ( //
// {this.handleGetMsg(returnData.msg)} //
// ), // okText: '确认', // onOk() {}, // }); // } else { // message.error(returnData.erroMsg); // } // } else { // message.error('审核失败!'); // } // return false; // } // } // // if (returnData.code === 1) { // bResult = true; // } else if (returnData.code === -8) { // Modal.info({ // title: '温馨提示:', // content: ( //
// {this.handleGetMsg(returnData.msg)} //
// ), // okText: '确认', // onOk() {}, // }); // } else { // bResult = false; // this.props.getServiceError(returnData); // } // return bResult; } handleEndWork = async (partEndWork) => { // partEndWork为true时 部分完工 const { masterConfig, employeeConfig, employeeData, employeeDelData, token, sModelsId, app, slaveData, slaveConfig, onSaveCurrentState, sBarcode, } = this.props; let { masterData } = this.props; const { systemData } = app; /* 根据后台配置校验字段是否不能为空,或为0 */ if (!commonBusiness.validateMaster(masterConfig, masterData, this.props)) { return; } let interfaceArr = ''; const buttonConfigArr = slaveConfig.gdsconfigformslave.filter(item => item.sControlName && item.sControlName ==='BtnEndWork'); if(commonUtils.isNotEmptyArr(buttonConfigArr)){ const buttonConfig = buttonConfigArr[0]; interfaceArr = buttonConfig.interface; } /* 校验动态参数不能为空*/ console.log('调试点0', 111); for (let i = 1; i < 20; i++) { const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`); if (iIndex > -1 && !commonUtils.isEmpty(masterData[`sParam${i.toString()}`])) { masterConfig.gdsconfigformslave[iIndex].showName = masterData[`sParam${i.toString()}`]; // processConfig.gdsconfigformslave[iIndex].bVisible = !itemProcess[`sParam${i.toString()}`].includes('参数值'); const sParamNotEmpty = `sParamNotEmpty${i.toString()}`; if(masterData[sParamNotEmpty]) { console.log('调试点', masterData[`sParam${i.toString()}`], masterData[sParamNotEmpty]); if (commonUtils.isEmpty(masterData[`sParamValue${i.toString()}`])) { console.log('调试点2', masterData[`sParamValue${i.toString()}`]); const sShowName = masterData[`sParam${i.toString()}`]; message.error(sShowName +'参数值不能为空!'); return; } } } } // const iPlcNo = commonUtils.isNotEmptyObject(app.iPlcNo) ? commonUtils.convertStrToNumber(app.iPlcNo) : 0; if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyArr(employeeData)) { if ((commonUtils.isNotEmptyNumber(masterData.dProcessQty) && masterData.dProcessQty > 0) || masterData.dProductionReportQty > 0) { // if (iPlcNo > 0 || (masterData.sStatus === 'startWorking' || masterData.sStatus === 'adjustment')) { /* 调机中、生产中 可以上报 */ if (true) { /* 任何状态均可上报 */ const value = {}; value.data = {}; value.sFormId = ''; const btnCopyToConfigs = masterConfig.gdsconfigformslave.filter(item => item.sName === '' && item.bVisible && item.sControlName.indexOf('BtnCopyTo.over') > -1); const sAssignField = {}; if (commonUtils.isNotEmptyArr(btnCopyToConfigs)) { // eslint-disable-next-line array-callback-return btnCopyToConfigs.map((item) => { if (commonUtils.isNotEmptyStr(item.sActiveId) && commonUtils.isEmptyStr(value.sFormId)) { value.sFormId = item.sActiveId; } const tableName = item.sControlName.split('.')[2]; sAssignField[tableName] = item.sAssignField; }); } /* 上报前 重新计算上报公式 */ // eslint-disable-next-line prefer-destructuring const sFactCapacityId = masterData.sFactCapacityId; if (commonUtils.isNotEmptyObject(sFactCapacityId)) { /* 根据工时公式 获取工时 */ masterData.dHour = await commonBusiness.getFormulaValue({ token, sModelsId, masterData, tableDataRow: masterData, sComputeId: sFactCapacityId, }); } else { /* 没有公式时 取相减得出的时间 */ const startTime = masterData.tCreateDate; const date2 = new Date(); //结束时间 const date3 = date2.getTime() - new Date(startTime).getTime(); //时间差的毫秒数 // const dSecond = date3 / 1000; const dSecond = Math.floor(date3 / 1000); masterData.dHour = commonUtils.isNull(dSecond,0); } // eslint-disable-next-line prefer-destructuring const sWageId = masterData.sWageId; if (commonUtils.isNotEmptyObject(sWageId)) { masterData.sMachineId = this.props.app.sMachineNameSId; /* 上报机台id */ masterData.sMachineName = this.props.app.sMachineNameStr; /* 上报机台name */ masterData.dWageMoney = await commonBusiness.getFormulaValue({ token, sModelsId, masterData, tableDataRow: masterData, sComputeId: sWageId, }); const dWageMoneyTotal = masterData.dWageMoney; let dProportionTotal = 0; let employeeSlaveData = []; if (commonUtils.isNotEmptyArr(employeeData)) { employeeSlaveData = employeeData.filter(item => item.sParentId === this.props.app.sTeamNameSId); } employeeSlaveData.forEach((item) => { if (commonUtils.isNotEmptyNumber(item.dProportion) && item.dProportion !== 0) { dProportionTotal += item.dProportion; } }); employeeSlaveData.forEach((item) => { if (commonUtils.isNotEmptyNumber(item.dProportion)) { const index1 = employeeData.findIndex(item1 => item1.sId === item.sId); employeeData[index1] = { ...item, dWageMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dWageMoney, 0), 6), dTimeMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dTimeMoney, 0), 6), dLossMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dLossMoney, 0), 6), dOtherMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dOtherMoney, 0), 6), dJobMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dJobMoney, 0), 6), handleType: commonUtils.isEmpty(item.handleType) ? 'update' : item.handleType, }; if (commonUtils.isNotEmptyNumber(masterData.dMakeReadyHour) && masterData.dMakeReadyHour > 0) { /* 有计时工资情况下按计时工资算 */ employeeData[index1].dTimeMoney = commonUtils.convertFixNum((item.dHourWage) * commonUtils.isNull(masterData.dMakeReadyHour, 0), 6); } } }); /* 选择计件方案后 算总金额 */ const dWageMoney = commonUtils.isNotEmptyNumber(dWageMoneyTotal) ? commonUtils.convertFixNum(dWageMoneyTotal, 6) : 0; const dTimeMoney = commonUtils.isNotEmptyNumber(masterData.dTimeMoney) ? commonUtils.convertFixNum(masterData.dTimeMoney, 6) : 0; const dLossMoney = commonUtils.isNotEmptyNumber(masterData.dLossMoney) ? commonUtils.convertFixNum(masterData.dLossMoney, 6) : 0; masterData.dAllMoney = commonUtils.convertFixNum((dWageMoney + dTimeMoney) - dLossMoney, 6); } const employeeDataTatil = employeeDelData.concat(employeeData); value.data[employeeConfig.sTbName.toLowerCase()] = employeeDataTatil; value.data[masterConfig.sTbName.toLowerCase()] = []; // const endWorked = commonFunc.showMessage(app.commonConst, 'endWorked');/* 完工 */ if (commonUtils.isNotEmptyObject(masterData)) { // masterData.sStatus = 'endWorked'; /* 塞sBarcode 数据 */ if(commonUtils.isNotEmptyObject(sBarcode)){ masterData.sBarcode =sBarcode; } value.data[masterConfig.sTbName.toLowerCase()].push(masterData); } value.sAssignField = sAssignField; value.sTeamId = app.sTeamNameSId; value.sMachineId = app.sMachineNameSId; let dataUrl = ''; if (partEndWork) { // 不停机上报 const copyToConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.sControlName === 'BtnCopyTo.productionReport') : ''; // 获取开工配置 value.sWorkAssignField = commonUtils.isNotEmptyObject(copyToConfig) ? copyToConfig[0].sAssignField : ''; dataUrl = `${commonConfig.server_host}oee/doOutputReportPart?sModelsId=${sModelsId}`; } else { // 停机上报 dataUrl = `${commonConfig.server_host}oee/doOutputReport?sModelsId=${sModelsId}`; } const dataReturn = (await commonServices.postValueService(token, value, dataUrl)).data; if (dataReturn.code === 1) { /* 推送接口 */ if(commonUtils.isNotEmptyArr(interfaceArr)) { /* 之后调用 */ const asyncFunc = async () => { for (let i = 0; i < interfaceArr.length; i++) { await this.handleInterfaceCall(interfaceArr[i],true); } } await asyncFunc(); } let bCkxOEEToTask = '0'; message.success(dataReturn.msg); if (commonUtils.isNotEmptyArr(slaveData) && !partEndWork) { if (commonUtils.isNotEmptyArr(systemData)) { const filterData = systemData.filter(item => (item.sName === 'CkxOEEToTask')); if (commonUtils.isNotEmptyArr(filterData)) { bCkxOEEToTask = filterData[0].sValue; if (bCkxOEEToTask === '1') { const url = '/indexOee/processReportList'; this.handleLinkTo(url, '3'); } else { onSaveCurrentState(slaveData, true, undefined, undefined, 2); } } } } else if (partEndWork) { const returnData = dataReturn.dataset.rows[0]; masterData = { ...masterData, ...returnData }; if(commonUtils.isNotEmptyArr(slaveData)){ slaveData[0]= { ...slaveData[0], ...returnData }; } /* 移除条形码 */ masterData.sBarcode=''; this.props.onSaveState({ masterData, }); } await this.props.onButtonClick('BtnRefresh', bCkxOEEToTask !== '1'); } else { this.props.getServiceError(dataReturn); } } else { message.error(commonFunc.showMessage(app.commonConst, 'sToExamineCheck')); } } else { message.warning(commonFunc.showMessage(app.commonConst, 'dProcessQtyNoNull')); } } // this.handleRecoveryClick(); // 恢复按钮点击 } handlePartEndWork = async () => { // 部分完工 await this.handleEndWork(true); } /* 系统设定OEE完工转任务若打钩,则OEE上报完成后 跳转到生产任务界面 */ handleLinkTo = (path, linkToActiveKey) => { const { dispatch, onSaveCurrentState, } = this.props; dispatch(routerRedux.push(path)); onSaveCurrentState(undefined, undefined, linkToActiveKey);// 变为当前设备的未清页面 } handleSearchPill = () => { // 查看工单 const { masterData, masterConfig, token, } = this.props; const sWorkOrderConfig = commonUtils.isNotEmptyObject(masterConfig) ? masterConfig.gdsconfigformslave.filter(item => item.sName === 'sWorkOrderNo' && item.bVisible)[0] : {}; if (commonUtils.isNotEmptyObject(sWorkOrderConfig) && commonUtils.isNotEmptyObject(masterData)) { const printPdf = sWorkOrderConfig.sControlName; /* 工单号配置调到打印界面,跳转打印页面 */ // eslint-disable-next-line prefer-destructuring const sActiveKey = sWorkOrderConfig.sActiveKey; /* 弹出界面对应数据主字段 */ if (commonUtils.isNotEmptyObject(printPdf) && printPdf === 'printPdf' && commonUtils.isNotEmptyObject(sActiveKey)) { // eslint-disable-next-line prefer-destructuring const sActiveId = sWorkOrderConfig.sActiveId === '1' ? commonUtils.isEmpty(masterData.sFormId) ? masterData.sSrcFormId : masterData.sFormId : masterData.sActiveId; const printsId = masterData[sActiveKey]; const urlPrint = `${commonConfig.file_host}printReport/printPdfByFromDataId/${printsId}.pdf?sModelsId=${sActiveId}&sId=${printsId}&token=${encodeURIComponent(token)}`; window.open(urlPrint); } } // this.handleRecoveryClick(); // 恢复按钮点击 } handleRemoveVoice = async () => { // 消音 const { app, sModelsId, masterData } = this.props; if (masterData.iPlcNo > 0) { const sMachineId = this.props.app.sMachineNameSId; /* 上报机台id */ const dataUrl = `${commonConfig.server_host}oee/doVoicePlc/${sMachineId}?sModelsId=${sModelsId}`; const dataReturn = (await commonServices.postValueService(app.token, {}, dataUrl)).data; if (dataReturn.code === 1) { message.success('消音成功!'); } else { /* 失败 */ this.props.getServiceError(dataReturn); } } else { message.error('没有消音功能!'); } } handleDelVoice = async () => { // 消音 const { app, sModelsId, masterData } = this.props; if (masterData.iPlcNo > 0) { const sMachineId = this.props.app.sMachineNameSId; /* 上报机台id */ const dataUrl = `${commonConfig.server_host}oee/doSysMesMsg/delete/${sMachineId}?sModelsId=${sModelsId}`; const dataReturn = (await commonServices.postValueService(app.token, {}, dataUrl)).data; if (dataReturn.code === 1) { message.success('删除成功!'); } else { /* 失败 */ this.props.getServiceError(dataReturn); } } else { message.error('没有删除功能!'); } } handleRefresh = async () => { await this.handleGetPlcData(this.props.masterData, this.props.slaveConfig); } handleRecoveryClick = () => { setTimeout(() => { // 防止多次点击,回复点击 this.setState({ bool: true, }); }, 1000); } handleBtnClick = async (btnConfig) => { const { app, slaveConfig } = this.props; this.setState({ bool: false, }); let interfaceArr = ''; const buttonConfigArr = slaveConfig.gdsconfigformslave.filter(item => item.sControlName && item.sControlName.indexOf(btnConfig.sControlName) > -1); if(commonUtils.isNotEmptyArr(buttonConfigArr)){ const buttonConfig = buttonConfigArr[0]; interfaceArr = buttonConfig.interface; } if (true) { if(btnConfig.sControlName === 'BtnEndWorkPart') { let idx = 0; for(let i = 0; i < this.state.insertList.length; i++) { if(this.state.insertList[i] === '') { idx = i; break; } } if(idx == 0) { document.getElementById('input_' + idx).focus(); message.error('请扫流转卡条码!'); return; } } if (btnConfig.sControlName === 'BtnEndWork' || btnConfig.sControlName === 'BtnMenuRight.BtnEndWork') { // 停机上报 await this.handleEndWork(false); } else if (btnConfig.sControlName.includes('BtnEndWorkPart')) { // 不停机上报 await this.handlePartEndWork(); } else if (btnConfig.sControlName.includes('BtnEndWorkOver')|| btnConfig.sControlName.includes('BtnEndWorkReset')) { // 生产复位 、调机结束 const { sModelsId, app, slaveConfig } = this.props; let { masterData } = this.props; if (commonUtils.isNotEmptyObject(masterData)) { const iPlcNo = commonUtils.isNotEmptyObject(masterData.iPlcNo) ? commonUtils.convertStrToNumber(masterData.iPlcNo) : 0; const value = { plcMachinedata: masterData, }; let doWorkEnd = 'startWorking'; if (btnConfig.sControlName.includes('BtnEndWorkReset')) { doWorkEnd = 'waitingWork'; } else if (iPlcNo > 0 && btnConfig.sControlName.includes('BtnEndWorkOver')) { doWorkEnd = 'doWorkEnd'; } const url = `${commonConfig.server_host}oee/doUpdateStatus/${doWorkEnd}?sModelsId=${sModelsId}`; const returnData = (await commonServices.postValueService(app.token, value, url)).data; if (returnData.code === 1) { const dataRturn = returnData.dataset.rows[0]; /* 推送接口 */ if(commonUtils.isNotEmptyArr(interfaceArr)) { /* 之后调用 */ const asyncFunc = async () => { for (let i = 0; i < interfaceArr.length; i++) { await this.handleInterfaceCall(interfaceArr[i],true); } } await asyncFunc(); } masterData = { ...masterData, ...dataRturn }; this.handleGetBtnStus(slaveConfig, masterData); /* 根据状态控制按钮的亮与灰色 */ this.props.onSaveState({ masterData, bResetTimer: true, }); message.success(returnData.msg); this.props.onButtonClick('BtnRefresh'); } else { /* 失败 */ this.props.getServiceError(returnData); } } // this.handleRecoveryClick(); // 恢复按钮点击 } else if (btnConfig.sControlName && btnConfig.sControlName.includes('BtnEndWorkSearchPill')) { // 查看工单 this.handleSearchPill(); } else if (btnConfig.sControlName && btnConfig.sControlName.includes('BtnEndWorkRemoveVoice')) { // 消音 this.handleRemoveVoice(); } else if (btnConfig.sControlName.includes('BtnEnterLabel')) { // 标签打印 const { slaveSelectedRowKeys, getSlaveSelectedRowKeys } = this.props; if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) { message.warn('请选择数据!'); return; } const { slaveData, onSaveCurrentState } = this.props; /* 打印标签跳转的界面模块ID */ onSaveCurrentState(slaveData, undefined, undefined, btnConfig); this.props.onOeeLabelCopyTo(btnConfig.sControlName, btnConfig.sActiveId); this.props.dispatch(routerRedux.push('/indexOee/labelPrint')); if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) { // 向父组件中存slaveSelectedRowKeys getSlaveSelectedRowKeys(slaveSelectedRowKeys); } } else if (btnConfig.sControlName.includes('OeeCopyTo')) { /* OEE单据 */ const { slaveSelectedRowKeys, getSlaveSelectedRowKeys } = this.props; if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) { message.warn('请选择数据!'); return; } const { slaveData, onSaveCurrentState } = this.props; onSaveCurrentState(slaveData, undefined, undefined, btnConfig, undefined, true); // this.props.onOeeBillCopyTo(btnConfig.sControlName, btnConfig.sActiveId, btnConfig); await this.props.onOeeBillCopyTo(btnConfig.sControlName, btnConfig.sActiveId, btnConfig, () => { this.setState({ bool: true, }); }); // this.props.dispatch(routerRedux.push('/indexOee/commonBillOee')); if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) { // 向父组件中存slaveSelectedRowKeys getSlaveSelectedRowKeys(slaveSelectedRowKeys); } } else if (commonUtils.isNotEmptyObject(btnConfig.sControlName) && btnConfig.sControlName.indexOf('Repair') > -1) { /* 自定义按钮 */ this.props.onOeeBtnEent(btnConfig); } // 停机上报删除一条 if(btnConfig.sControlName === 'BtnEndWork' || btnConfig.sControlName === 'BtnEndWorkPart') { this.shiftInsertCode(); } } else { message.warning(commonFunc.showMessage(app.commonConst, 'donotRepeat')); } if (!btnConfig.sControlName.includes('OeeCopyTo')) { this.setState({ bool: true, }); } } shiftInsertCode() { const prevList = this.state.insertList.slice(0); prevList.shift(); if(prevList.length < 4) { prevList.push(''); } this.setState({ insertList: prevList, }); this.props.onSaveState({ sBarcode: this.state.insertList.length ? this.state.insertList[0] : '' }) setTimeout(() => { let idx = 0; for(let i = 0; i < this.state.insertList.length; i++) { if(this.state.insertList[i] === '') { idx = i; break; } } if(document.getElementById('input_' + idx)) { document.getElementById('input_' + idx).focus(); } }, 0) } /* 状态改变 */ handleBtnStatusClick = async (item) => { this.setState({ bool: false }) if (commonUtils.isNotEmptyObject(item.sName)) { // 调机结束 const { sModelsId, app, slaveConfig } = this.props; let { masterData } = this.props; if (commonUtils.isNotEmptyObject(masterData)) { const value = { plcMachinedata: masterData, }; const doWorkEnd = item.sName; const url = `${commonConfig.server_host}oee/doUpdateStatus/${doWorkEnd}?sModelsId=${sModelsId}`; const returnData = (await commonServices.postValueService(app.token, value, url)).data; if (returnData.code === 1) { const dataRturn = returnData.dataset.rows[0]; masterData = { ...masterData, ...dataRturn }; let interfaceArr = ''; const buttonConfigArr = slaveConfig.gdsconfigformslave.filter(item => item.sControlName && item.sControlName.includes('BtnEndWorkStatusHeader')); if(commonUtils.isNotEmptyArr(buttonConfigArr)){ const buttonConfig = buttonConfigArr[0]; interfaceArr = buttonConfig.interface; console.log('切换状态接口:', interfaceArr); } /* 推送接口 */ if(commonUtils.isNotEmptyArr(interfaceArr)) { /* 之后调用 */ const asyncFunc = async () => { for (let i = 0; i < interfaceArr.length; i++) { await this.handleInterfaceCall(interfaceArr[i],true); } } await asyncFunc(); } this.handleGetBtnStus(slaveConfig, masterData); /* 根据状态控制按钮的亮与灰色 */ this.props.onSaveState({ masterData, }); message.success(returnData.msg); // this.handleRecoveryClick(); // 恢复按钮点击 // this.props.onButtonClick('BtnRefresh'); } else { /* 失败 */ this.props.getServiceError(returnData); } } } this.setState({ bool: true }) // const { app } = this.props; // this.setState({ // bool: false, // }); // if (this.state.bool) { // if (btnConfig.sControlName === 'BtnEndWork') { // 停机上报 // this.handleEndWork(false); // } else if (btnConfig.sControlName === 'BtnEndWorkPart') { // 不停机上报 // this.handlePartEndWork(); // } else if (btnConfig.sControlName === 'BtnEndWorkOver') { // 调机结束 // const { sModelsId, app } = this.props; // let { masterData } = this.props; // if (commonUtils.isNotEmptyObject(masterData)) { // const value = { // plcMachinedata: masterData, // }; // const doWorkEnd = 'doWorkEnd'; // const url = `${commonConfig.server_host}oee/doUpdateStatus/${doWorkEnd}?sModelsId=${sModelsId}`; // const returnData = (await commonServices.postValueService(app.token, value, url)).data; // if (returnData.code === 1) { // const dataRturn = returnData.dataset.rows[0]; // masterData = { ...masterData, ...dataRturn }; // this.props.onSaveState({ // masterData, // }); // message.success(returnData.msg); // this.props.onButtonClick('BtnRefresh'); // } else { /* 失败 */ // this.props.getServiceError(returnData); // } // } // this.handleRecoveryClick(); // 恢复按钮点击 // } else if (btnConfig.sControlName === 'BtnEndWorkSearchPill') { // 查看工单 // this.handleSearchPill(); // } } /** 表格数据更改 */ handleMasterChange = async (name, sFieldName, changeValue, sId, dropDownData, isWait) => { /* 从CommonBase获取默认参数 */ if (name === 'master') { const { sModelsId, token, employeeDelData: employeeDelDataOld, masterConfig, } = this.props; let { employeeData, [`${name}Data`]: tableData, } = this.props; const employeeDelData = commonUtils.isEmptyArr(employeeDelDataOld) ? [] : employeeDelDataOld; let tableDataRow = await this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, true); if(commonUtils.isNotEmptyObject(tableDataRow) && commonUtils.isNotEmptyObject(tableDataRow.masterData)) { const addState = commonBusiness.getKeyUpEvent(name, sFieldName, masterConfig, tableDataRow.masterData, {}, true); if (commonUtils.isNotEmptyObject(addState)) { tableDataRow = addState; } } tableData = commonUtils.isNotEmptyObject(tableDataRow.masterData) ? tableDataRow.masterData : tableDataRow; const masterData = commonUtils.isNotEmptyObject(tableDataRow.masterData) ? tableDataRow.masterData : tableDataRow; if (tableDataRow === undefined) return; if (sFieldName === 'sTeamName' || sFieldName === 'sTeamId') { // eslint-disable-next-line prefer-destructuring const sTeamId = masterData.sTeamId; const sSlaveId = masterData.sId; // eslint-disable-next-line prefer-destructuring const sParentId = masterData.sId; // let handleType = tableData[iIndex].handleType;/* 获取操作类型 */ // handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType; const url = `${commonConfig.server_host}eleteamemployee/getEleteamemployee?sModelsId=${sModelsId}&sTeamId=${sTeamId}&sSlaveId=${sSlaveId}&sParentId=${sParentId}`; const dataReturn = (await commonServices.getService(token, url)).data; if (dataReturn.code === 1) { let employeeDataNew = []; if (commonUtils.isNotEmptyArr(employeeData)) { employeeData.filter(item => item.sSlaveId === sId).forEach((item) => { item.handleType = 'del'; employeeDelData.push(item); }); employeeDataNew = employeeData.filter(item => item.sSlaveId !== sId); } const returnData = dataReturn.dataset.rows; const employeeSlaveData = []; returnData.forEach((child) => { employeeSlaveData.push({ sId: child.sId, sParentId: child.sParentId, sSlaveId: child.sSlaveId, sEmployeeId: child.sEmployeeId, sEmployeeNo: child.sEmployeeNo, sEmployeeName: child.sEmployeeName, dProportion: child.dProportion !== 0 ? child.dProportion : commonUtils.convertFixNum(1 / returnData.length, 6), handleType: 'add', }); }); /* 班组变化时,算每个工作人员计件工资 */ let dProportionTotal = 0; employeeSlaveData.forEach((item) => { if (commonUtils.isNotEmptyNumber(item.dProportion) && item.dProportion !== 0) { dProportionTotal += commonUtils.convertFixNum(item.dProportion, 6); dProportionTotal = commonUtils.convertFixNum(dProportionTotal, 6); } }); employeeSlaveData.forEach((item) => { if (commonUtils.isNotEmptyNumber(item.dProportion)) { const index1 = employeeSlaveData.findIndex(item1 => item1.sId === item.sId); employeeSlaveData[index1] = { ...item, dWageMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dWageMoney, 0), 6), dTimeMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dTimeMoney, 0), 6), dLossMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dLossMoney, 0), 6), dOtherMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dOtherMoney, 0), 6), dJobMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dJobMoney, 0), 6), handleType: commonUtils.isEmpty(item.handleType) ? 'update' : item.handleType, }; } }); employeeData = employeeDataNew.concat(employeeSlaveData); } else { /* 失败 */ this.props.getServiceError(dataReturn); } } else if (sFieldName === 'dProcessQty' || sFieldName === 'sWageId' || sFieldName === 'sWageName') { // eslint-disable-next-line prefer-destructuring // const sWageId = masterData.sWageId; // if (commonUtils.isNotEmptyObject(sWageId)) { // masterData.dWageMoney = await commonBusiness.getFormulaValue({ // token, sModelsId, masterData, tableDataRow: tableDataRow.masterData, sComputeId: sWageId, // }); // } // const dWageMoneyTotal = masterData.dWageMoney; // let dProportionTotal = 0; // let employeeSlaveData = []; // if (commonUtils.isNotEmptyArr(employeeData)) { // employeeSlaveData = employeeData.filter(item => item.sParentId === this.props.app.sTeamNameSId); // } // employeeSlaveData.forEach((item) => { // if (commonUtils.isNotEmptyNumber(item.dProportion) && item.dProportion !== 0) { // dProportionTotal += item.dProportion; // } // }); // employeeSlaveData.forEach((item) => { // if (commonUtils.isNotEmptyNumber(item.dProportion)) { // const index1 = employeeData.findIndex(item1 => item1.sId === item.sId); // employeeData[index1] = { // ...item, // dWageMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dWageMoney, 0), 6), // dTimeMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dTimeMoney, 0), 6), // dLossMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dLossMoney, 0), 6), // dOtherMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dOtherMoney, 0), 6), // dJobMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dJobMoney, 0), 6), // handleType: commonUtils.isEmpty(item.handleType) ? 'update' : item.handleType, // }; // } // }); // /* 选择计件方案后 算总金额 */ // const dWageMoney = commonUtils.isNotEmptyNumber(dWageMoneyTotal) ? commonUtils.convertFixNum(dWageMoneyTotal, 6) : 0; // const dTimeMoney = commonUtils.isNotEmptyNumber(masterData.dTimeMoney) ? commonUtils.convertFixNum(masterData.dTimeMoney, 6) : 0; // const dLossMoney = commonUtils.isNotEmptyNumber(masterData.dLossMoney) ? commonUtils.convertFixNum(masterData.dLossMoney, 6) : 0; // masterData.dAllMoney = commonUtils.convertFixNum((dWageMoney + dTimeMoney) - dLossMoney, 6); } else if (sFieldName === 'dTimeMoney' || sFieldName === 'dLossMoney') { /* 总金额=计件工资+工时工资-损失金额 */ let dProportionTotal = 0; const employeeSlaveData = employeeData.filter(item => item.sSlaveId === sId); employeeSlaveData.forEach((item) => { if (commonUtils.isNotEmptyNumber(item.dProportion) && item.dProportion !== 0) { dProportionTotal += item.dProportion; } }); employeeSlaveData.forEach((item) => { if (commonUtils.isNotEmptyNumber(item.dProportion)) { const index1 = employeeData.findIndex(item1 => item1.sId === item.sId); employeeData[index1] = { ...item, dWageMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dWageMoney, 0), 6), dTimeMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dTimeMoney, 0), 6), dLossMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dLossMoney, 0), 6), dOtherMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dOtherMoney, 0), 6), dJobMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dJobMoney, 0), 6), handleType: commonUtils.isEmpty(item.handleType) ? 'update' : item.handleType, }; } }); const dWageMoney = commonUtils.isNotEmptyNumber(masterData.dWageMoney) ? commonUtils.convertFixNum(masterData.dWageMoney, 6) : 0; const dTimeMoney = commonUtils.isNotEmptyNumber(masterData.dTimeMoney) ? commonUtils.convertFixNum(masterData.dTimeMoney, 6) : 0; const dLossMoney = commonUtils.isNotEmptyNumber(masterData.dLossMoney) ? commonUtils.convertFixNum(masterData.dLossMoney, 6) : 0; masterData.dAllMoney = commonUtils.convertFixNum((dWageMoney + dTimeMoney) - dLossMoney, 6); } else if (sFieldName === 'dMakeReadyHour' && commonUtils.isNotEmptyNumber(masterData.dMakeReadyHour) && masterData.dMakeReadyHour > 0) { /* 计时工资 =上报填的计时小时数*每个员工对应的员工表里面的计时单价 */ let employeeSlaveData = []; if (commonUtils.isNotEmptyArr(employeeData)) { employeeSlaveData = employeeData.filter(item => item.sParentId === this.props.app.sTeamNameSId); } let dTimeMoneyTotal = 0; employeeSlaveData.forEach((item) => { if (commonUtils.isNotEmptyNumber(item.dHourWage)) { const index1 = employeeData.findIndex(item1 => item1.sId === item.sId); employeeData[index1] = { ...item, dTimeMoney: commonUtils.convertFixNum((item.dHourWage) * commonUtils.isNull(masterData.dMakeReadyHour, 0), 6), handleType: commonUtils.isEmpty(item.handleType) ? 'update' : item.handleType, }; dTimeMoneyTotal += employeeData[index1].dTimeMoney; } }); /* 调机用时输入后 算总金额 */ const dWageMoney = commonUtils.isNotEmptyNumber(masterData.dWageMoney) ? commonUtils.convertFixNum(masterData.dWageMoney, 6) : 0; const dTimeMoney = commonUtils.isNotEmptyNumber(dTimeMoneyTotal) ? commonUtils.convertFixNum(dTimeMoneyTotal, 6) : 0; const dLossMoney = commonUtils.isNotEmptyNumber(masterData.dLossMoney) ? commonUtils.convertFixNum(masterData.dLossMoney, 6) : 0; masterData.dTimeMoney = dTimeMoney; masterData.dAllMoney = commonUtils.convertFixNum((dWageMoney + dTimeMoney) - dLossMoney, 6); } if (isWait) { return { [`${name}Data`]: tableData, employeeData, employeeDelData, enabled: true, }; } else { this.props.onSaveState({ [`${name}Data`]: tableData, employeeData, employeeDelData, enabled: true, }); } } else if (name === 'employee') { /* 班组变化时,算每个工作人员计件工资 */ // 讲json数据赋值到state // if (this.props.formRoute === '/indexOee/processReport') { // if (localStorage.getItem(`${commonConfig.prefix}oeeEmployeeData`) && JSON.parse(localStorage.getItem(`${commonConfig.prefix}oeeEmployeeData`)).length > 0 && !this.props.employeeDataSetted) { // this.props.onSaveState({ // employeeData: JSON.parse(localStorage.getItem(`${commonConfig.prefix}oeeEmployeeData`)), // employeeDataSetted: true, // }); // } // } const { masterData, [`${name}Data`]: tableData, app, } = this.props; const tableDataRow = await this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true); if (tableDataRow === undefined) return; const iIndex = tableData.findIndex(item => item.sId === sId); if (iIndex > -1) { tableData[iIndex] = tableDataRow; } let dProportionTotal = 0; tableData.filter(item => item.sParentId === app.sTeamNameSId).forEach((item) => { if (commonUtils.isNotEmptyNumber(item.dProportion) && item.dProportion !== 0) { dProportionTotal += commonUtils.convertFixNum(item.dProportion, 6); dProportionTotal = commonUtils.convertFixNum(dProportionTotal, 6); } }); tableData.filter(item => item.sParentId === app.sTeamNameSId).forEach((item) => { if (commonUtils.isNotEmptyNumber(item.dProportion)) { const index1 = tableData.findIndex(item1 => item1.sId === item.sId); tableData[index1] = { ...item, dWageMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dWageMoney, 0), 6), dTimeMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dTimeMoney, 0), 6), dLossMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dLossMoney, 0), 6), dOtherMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dOtherMoney, 0), 6), dJobMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dJobMoney, 0), 6), handleType: commonUtils.isEmpty(item.handleType) ? 'update' : item.handleType, }; } }); this.props.onSaveState({ [`${name}Data`]: tableData, masterData, enabled: true }); localStorage.setItem(`${commonConfig.prefix}oeeEmployeeData_${app.sTeamNameSId}`, JSON.stringify(tableData)); } else { this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, isWait); } }; // 班组切换 // handleSelectChange = async (name, sFieldName, changeValue, sId, dropDownData) => { // this.setState({ sTeamNameOneNamesId: changeValue.sTeamName }); // // return; // let { masterData, employeeData } = this.props; // const { // slaveData, // slaveSelectedRowKeys, // employeeDelData: employeeDelDataOld, // sModelsId, // token, // } = this.props; // const employeeDelData = commonUtils.isEmptyArr(employeeDelDataOld) ? [] : employeeDelDataOld; // const iIndex = dropDownData.findIndex(item => item.sId === changeValue.sTeamId);/* 拿到主表下拉选中的班组的名称 */ // const addStata = {}; // addStata.sTeamName = dropDownData[iIndex].sTeamName; // addStata.sTeamId = dropDownData[iIndex].sId; // masterData = { ...masterData, ...addStata }; // if (iIndex > -1) { // if (commonUtils.isNotEmptyArr(slaveData) && slaveData.length > 0) { // const sTeamId = dropDownData[iIndex].sId; // const sSlaveId = masterData.sId; // const sParentId = masterData.sId; // if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) { /* 第一个从表数据默认选中 */ // slaveSelectedRowKeys.push(sSlaveId); // } // const url = `${commonConfig.server_host}eleteamemployee/getEleteamemployee?sModelsId=${sModelsId}&sTeamId=${sTeamId}&sSlaveId=${sSlaveId}&sParentId=${sParentId}`; // const dataReturn = (await commonServices.getService(token, url)).data; // const handleType = commonUtils.isEmptyObject(masterData.handleType) ? 'update' : masterData.handleType; // masterData.handleType = handleType; // // masterData[index] = { ...slaveItem, ...addStata }; // const employeeSlaveData = []; // let employeeDataNew = []; // let employeeDelDataNew = []; // if (dataReturn.code === 1) { // const returnData = dataReturn.dataset.rows; // if (commonUtils.isNotEmptyObject(returnData) && returnData.length > 0) { // if (commonUtils.isNotEmptyArr(employeeData)) { // employeeDataNew = employeeData.filter(item => item.sSlaveId !== masterData.sId); // employeeDelDataNew = employeeData.filter(item => item.sSlaveId === masterData.sId); // } // employeeDelDataNew.forEach((item) => { // item.handleType = 'del'; // employeeDelData.push(item); // }); // if (commonUtils.isEmptyArr(employeeSlaveData)) { /* 当班组人员无数据时 */ // returnData.forEach((child) => { // employeeSlaveData.push({ // sId: commonUtils.createSid(), // sParentId: masterData.sId, // sSlaveId: masterData.sId, // sEmployeeId: child.sEmployeeId, // sEmployeeName: child.sEmployeeName, // dProportion: child.dProportion !== 0 ? child.dProportion : commonUtils.convertFixNum(1 / returnData.length, 6), // handleType: 'add', // }); // }); // } // } // const dWageMoneyTotal = commonUtils.isNotEmptyNumber(masterData.dWageMoney) ? masterData.dWageMoney : 0; // if (commonUtils.isNotEmptyNumber(dWageMoneyTotal)) { // let dProportionTotal = 0; // employeeSlaveData.forEach((item) => { // if (commonUtils.isNotEmptyNumber(item.dProportion) && item.dProportion !== 0) { // dProportionTotal += commonUtils.convertFixNum(item.dProportion, 6); // dProportionTotal = commonUtils.convertFixNum(dProportionTotal, 6); // } // }); // employeeSlaveData.forEach((item) => { // if (commonUtils.isNotEmptyNumber(item.dProportion)) { // const index1 = employeeSlaveData.findIndex(item1 => item1.sId === item.sId); // employeeSlaveData[index1] = { // ...item, // dWageMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dWageMoney, 0), 6), // dTimeMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dTimeMoney, 0), 6), // dLossMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dLossMoney, 0), 6), // dOtherMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dOtherMoney, 0), 6), // dJobMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(masterData.dJobMoney, 0), 6), // handleType: commonUtils.isEmpty(item.handleType) ? 'update' : item.handleType, // }; // } // }); // } // employeeData = employeeDataNew.concat(employeeSlaveData); // } // } // } // this.props.onSaveState({ // masterData, slaveData, employeeData, employeeDelData, // }); // } // 关闭选择人员弹出框 handleAddEmployeeCancel = () => { this.props.onSaveState({ employeeVisble: false }); } // 选择人员弹出框确认 handleAddEmployee = () => { // const {} = this.props; this.props.onSaveState({ employeeVisble: false }); } handleReciveSelectData = (data) => { if (data === 'closeDoor') { this.props.onSaveState({ employeeVisble: false }); } else { const { employeeData: employeeDataOld, app } = this.props; const employeeData = commonUtils.isNotEmptyArr(employeeDataOld) ? employeeDataOld : []; if (commonUtils.isNotEmptyArr(data)) { // eslint-disable-next-line array-callback-return data.map((item) => { employeeData.push(item); }); } localStorage.setItem(`${commonConfig.prefix}oeeEmployeeData_${app.sTeamNameSId}`, JSON.stringify(employeeData)); this.props.onSaveState({ employeeData, employeeVisble: false }); } } hanleImgClick = (dataUrl) => { // 放大图片 const data = []; if (commonUtils.isNotEmptyObject(dataUrl)) { const imgPreviewUrl = `${commonConfig.server_host}file/download?savePathStr=${dataUrl}&width=${this.state.imgOffsetWidth}&height=${this.state.imgOffsetHeight}&sModelsId=100&token=${this.props.app.token}`; data.push(imgPreviewUrl); } this.setState({ // imgAddWidth: !isImgAddWidth, previewVisible: true, showimgs: true, firstIndex: 0, data, }); } showimg = (i) => { this.setState({ showimgs: true, firstIndex: i }); }; toggleshow = () => { this.setState({ showimgs: false, previewVisible: false }); }; handleInputChage= (e,scode, idx) => { const addState ={}; if(commonUtils.isNotEmptyObject(scode)){ let prevList = this.state.insertList.slice(0); prevList[idx] = e.target.value; this.setState({ insertList: prevList }) addState.sBarcode = this.state.insertList.length ? this.state.insertList[0] : ''; }else{ addState.inputValue =e.target.value; } this.props.onSaveState({...addState }); } handleInputKeyDown = (e, idx) => { if(e.which == 13) { // 扫码枪输入的时候,最后一个字符为回车键 // 回车后focus下一个input let prevList = this.state.insertList.slice(0); // 去重 if (prevList.indexOf(e.target.value) !== -1 && prevList.indexOf(e.target.value) !== idx) { prevList[idx] = ""; this.setState({ insertList: prevList }) return; } // 最后一行 if (idx == this.state.insertList.length - 1) { prevList.push(''); this.setState({ insertList: prevList }) } setTimeout(() => { document.getElementById(`input_${idx + 1}`) && document.getElementById(`input_${idx + 1}`).focus() }, 0); } } /* 扫码文本框enter,员工表增一条数据 */ handlePressEnter = async (e) => { const { app, masterData, sModelsId, employeeConfig, employeeData, } = this.props; const sValue = e.target.value; const filterData = commonUtils.isNotEmptyArr(employeeData) ? employeeData.filter(item => item.sEmployeeNo === sValue.trim()) : []; if (commonUtils.isNotEmptyArr(filterData)) { message.error('该员工已添加,不能重复添加!'); return; } let dropdownData = []; const showConfig = employeeConfig.gdsconfigformslave.filter(item => item.sName === 'sEmployeeName'); if (commonUtils.isNotEmptyArr(showConfig) && showConfig.length > 0) { const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', showConfig[0]); /* 根据sName得到过滤数据s */ dropdownData = sqlDropDownData.dropDownData; if (commonUtils.isNotEmptyArr(dropdownData)) { const dropdownFilterData = dropdownData.filter(item => item.sEmployeeNo === sValue); if (commonUtils.isNotEmptyArr(dropdownFilterData)) { const sEmployeeObj = dropdownFilterData[0]; /* 员工对象 */ sEmployeeObj.handleType = 'add'; sEmployeeObj.sParentId = app.sTeamNameSId; sEmployeeObj.dProportion = 1; sEmployeeObj.sId = commonUtils.createSid(); sEmployeeObj.sSlaveId = masterData.sId; employeeData.push(sEmployeeObj); this.props.onSaveState({ employeeData, inputValue: '' }); } else { message.error('该员工不存在!'); } } } } render() { return (
); } } const CommonOeeReportComponent = Form.create({ mapPropsToFields(props) { const { masterData } = props; const obj = commonFunc.mapPropsToFields(masterData, Form); return obj; }, })((props) => { const { app, form, onReturnForm, slavePagination, masterConfig, isSmall, // onSearchPill, // onEndWork, // onPartEndWork, // sModelsId, employeeVisble, // handleSelectChange, onAddEmployee, employeeData, handleReciveSelectData, masterData, onAddEmployeeCancel, // isDisabled, token, slaveConfig, // employeeAndProcessData, // 人员和工序数据 previewVisible, firstIndex, showimgs, data, inputValue, statusMenus, handleRemoveVoice, handleDelVoice, handleRefresh } = props; // isSmall将分页变小,以及去掉跳转页面和总条数记录 /* 回带表单 */ if (commonUtils.isNotEmptyObject(slavePagination)) { if (isSmall) { slavePagination.showTotal = null; } } // const child = { // bCanInput: false, // bEntireLine: false, // bFilter: false, // bFind: false, // bFirstEmpty: false, // bIsOther: false, // bMergeCell: false, // bMultipleChoice: false, // bNewRecord: false, // bNotEmpty: false, // bNotRepeat: false, // bReadonly: false, // bSum: false, // bTree: false, // bVisible: true, // iColValue: 1, // iFitWidth: 120, // iIncrement: 53571, // iOrder: 54, // iVisCount: 1, // sAssignField: 'sTeamName:sTeamName,sTeamNo:sTeamNo,sTeamId:sId', // sBig5: '班組名稱', // sBig5DropDown: 'select sTeamName,sTeamNo, sId from eleteam where 1=1 #companyId#', // sBrandsId: '1111111111', // sButtonEnabled: '', // sButtonParam: '', // sChinese: '班组名称', // sChineseDropDown: 'select sTeamName,sTeamNo, sId from eleteam where 1=1 #companyId#', // sColor: '', // sColorTerms: '', // sControlName: '', // sDateFormat: '', // sDropDownType: 'sql', // sFieldToContent: '', // sId: '15852869860002568585987478299600', // sMakePerson: '彭敏', // sMaxValue: '', // sMinValue: '', // sName: 'sTeamName', // sParentId: '19211681019715476042694990', // sRelation: 'sTeamId&eleteam&sId&sTeamName', // sSelectRelation: '', // sSubsidiaryId: '1111111111', // showDropDown: 'select sTeamName,sTeamNo, sId from eleteam where 1=1 #companyId#', // showName: '', // }; // const showTypeProps = { // app, // record: masterData, // sId: '', /* 修改当前编号(数据格式:字符串 ) */ // name: 'master', // form: props.form, // formId: sModelsId, // getSqlDropDownData: props.getSqlDropDownData, // handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, // getFloatNum: props.getFloatNum, // getDateFormat: props.getDateFormat, // onChange: handleSelectChange, // showConfig: child, // formItemLayout: {}, // textArea: false, // enabled: true, // dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.sTeamName, // bTable: false, // onFilterDropDownData: props.onFilterDropDownData, // onSaveState: props.onSaveState, // }; onReturnForm(form); const employeePropsType = { ...commonBusiness.getTableTypes('employee', props), filteredValue: props.slaveSelectedRowKeys, onFilterData: props.onFilterData, onDataChange: props.onChange, tableProps: { rowSelection: null, AutoTableHeight: '100px' // scroll: { y: 240 }, }, formRoute: props.formRoute, }; const configs = commonUtils.isNotEmptyObject(masterConfig) ? masterConfig.gdsconfigformslave.filter(item => item.sName !== '' && item.bVisible && item.sControlName.indexOf('Btn') === -1 && item.iTag === 2) : []; const ableConfigs = commonUtils.isNotEmptyObject(masterConfig) ? masterConfig.gdsconfigformslave.filter(item => item.sName !== '' && item.bVisible && item.sControlName.indexOf('Btn') === -1 && (item.iTag === 3 || item.iTag === 1)) : []; // if (commonUtils.isNotEmptyObject(app.employeeAndProcessData) && commonUtils.isNotEmptyArr(app.employeeAndProcessData.processData)) { // ableConfigs = ableConfigs.concat(app.employeeAndProcessData.processData); // } const addEmployee = commonFunc.showMessage(app.commonConst, 'addEmployee');/* 请选择人员 */ // cosnt slaveData = addState.masterData.findIndex(item => item.sStatus === 'startWorking')[0]; const masterDataNew = commonUtils.isEmptyObject(masterData) ? {} : masterData; // 取得配置中的按钮; const buttonConfigs = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.sName === '' && item.showName !== '' && item.sControlName !== '' && item.bVisible && (item.sControlName.indexOf('BtnEndWork') > -1 || item.sControlName.indexOf('Right') > -1) && item.sControlName.indexOf('BtnCopyTo') === -1) : []; const buttonMenuConfigs = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.sName === '' && item.showName !== '' && item.sControlName !== 'BtnMenuRight' && item.bVisible && (item.sControlName.indexOf('MenuRight') > -1)) : []; /* 有条码配置即可显示条码框 */ const qrCodeConfig =commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.sName.toLowerCase()==='sbarcode' && item.bVisible ) : []; const imgAddStyle = { position: 'absolute', top: 0, left: 0, bottom: 0, right: 0, margin: 'auto', zIndex: 11111, }; const imgAddStyleDiv = { position: 'absolute', width: '100%', height: '100%', top: 0, left: 0, bottom: 0, right: 0, background: 'rgba(0,0,0,0.5)', zIndex: 11110, }; const bCanClick = props.bool; /* 按钮是否可点击,true:可点击,false:禁用 */ const bCanClickMenuBtn = masterDataNew.sStatus !== 'offwork' && bCanClick; const menu = ( { commonUtils.isNotEmptyArr(statusMenus) && statusMenus.map((item) => { return ( {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} {/* props.onBtnStatusClick(item)} >*/} props.onBtnStatusClick(item) : ''} > {item.sStatusName} ); }) } {/* */} {/* */} {/* 1st menu item */} {/* */} {/* */} {/* */} {/* */} {/* 2nd menu item */} {/* */} {/* */} {/* */} {/* */} {/* 3rd menu item */} {/* */} {/* */} ); /* 下拉按钮组件 */ const selfMenu = ( { commonUtils.isNotEmptyArr(buttonMenuConfigs) && buttonMenuConfigs.map((item) => { return ( {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} {/* props.onBtnStatusClick(item)} >*/} props.onBtnClick(item) : null} > {item.showName} ); }) } ); return (
{ commonUtils.isNotEmptyArr(configs) ? configs.map((item, index) => { return ( // eslint-disable-next-line react/no-array-index-key
{item.showName}
{masterDataNew[item.sName]}
); }) : '' } {/*
*/} {/*
班组
*/} {/*
*/} {/* */} {/*
*/} {/*
*/}
{/* 右侧 */}
{ masterData && masterData.MsgData && masterData.MsgData.length ? {masterData.MsgData[0].sContent}{masterData.MsgData[0].sContent}{masterData.MsgData[0].sContent} : 警报提示 }
{/* 倒计时 */}
{ (masterConfig && qrCodeConfig.length > 0) ?
{props.insertList.map((item, idx) => (
props.onInputKeyDown(e, idx)} onChange={(e) => props.onInputChage(e,'scode', idx)}>
))}
: '' }
{/* 修改配置值 */}
0)? 'picturesPadding' : ''}`}> {/* eslint-disable-next-line no-return-assign */}
{ commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyObject(masterData.sMachinePicturePath) ?
: '产品图片' }
{ commonUtils.isNotEmptyArr(ableConfigs) ? ableConfigs.map((child, index) => { const sMemo = child.sName.toLowerCase().endsWith('memo'); let enabledNew = !child.bReadonly; if (child.iTag === 1) { enabledNew = false; } else if (child.iTag === 3) { enabledNew = true; } /* 上报参数 如果没值则取默认值 */ let sDataValue = ''; if (commonUtils.isNotEmptyObject(masterDataNew)) { sDataValue = masterDataNew[child.sName]; const sDefaultName = child.sName.includes('Value') ? child.sName.replace('Value', 'Default') : ''; let sDefaultValue = ''; if (sDefaultName) { sDefaultValue = masterDataNew[sDefaultName]; } if ((commonUtils.isEmptyObject(sDataValue) || sDataValue === "0" ) && commonUtils.isNotEmptyObject(sDefaultValue)) { masterDataNew[child.sName] = sDefaultValue; } } const showTypeProps = { name: 'master', form: props.form, getSqlDropDownData: props.getSqlDropDownData, getSqlCondition: props.getSqlCondition, handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, getFloatNum: props.getFloatNum, onChange: props.onChange, showConfig: child, formItemLayout : { labelCol: { span: 6 }, wrapperCol: { span: 18 } }, textArea: sMemo, enabled: enabledNew, dataValue: masterDataNew[child.sName], bTable: false, formRoute: props.formRoute, }; let iColValue = child.iColValue; let colSpan = 24; if (iColValue) { iColValue = Number(iColValue); switch (iColValue) { case 2: colSpan = 12; showTypeProps.formItemLayout = { labelCol: { span: 12 }, wrapperCol: { span: 12 } }; break; case 3: colSpan = 8; showTypeProps.formItemLayout = { labelCol: { span: 12 }, wrapperCol: { span: 12 } }; break; case 4: colSpan = 6; showTypeProps.formItemLayout = { labelCol: { span: 12 }, wrapperCol: { span: 12 } }; break; default: break; } } return ; }) : '' }
{ employeeVisble ? : '' } { previewVisible ?
{/* 图片正常的列表显示 */} {/* 引入的image组件 */}
: '' }
{/* 底部按钮 */}
props.onInputChage(e)} onPressEnter={e => props.onPressEnter(e)} />
{ commonUtils.isNotEmptyArr(buttonConfigs) ? buttonConfigs.map((item, index) => { if (commonUtils.isNotEmptyObject(item.sControlName) && item.sControlName.includes('BtnEndWorkStatus')) { /* 改变状态下拉 */ return ( {/* eslint-disable-next-line react/no-array-index-key,jsx-a11y/anchor-is-valid,jsx-a11y/anchor-has-content */} {/* props.onBtnClick(item)} >
{item.showName}
*/} props.onBtnClick(item) : null} >
{item.showName}
); }else if (commonUtils.isNotEmptyObject(item.sControlName) && item.sControlName === 'BtnMenuRight') { /* 下拉按钮 */ return ( {/* eslint-disable-next-line react/no-array-index-key,jsx-a11y/anchor-is-valid,jsx-a11y/anchor-has-content */} {/* props.onBtnClick(item)} >
{item.showName}
*/} props.onBtnClick(item) : null} >
{item.showName}
); } else if(commonUtils.isNotEmptyObject(item.sControlName) && !item.sControlName.includes('MenuRight')) { return ( // eslint-disable-next-line jsx-a11y/anchor-is-valid,react/no-array-index-key // props.onBtnClick(item) : null}> props.onBtnClick(item) : null}> {item.showName} ); } }) : '' }
); }); export default OeeCurrentState;