/* eslint-disable */ import React, { Component } from 'react'; import { Layout, message } from 'antd'; import { Form } from '@ant-design/compatible'; import '@ant-design/compatible/assets/index.css'; import StaticEditTable from '@/components/Common/CommonTable'; import * as commonBusiness from '@/components/Common/commonBusiness'; import * as commonFunc from '@/components/Common/commonFunc'; import * as commonUtils from '@/utils/utils'; import '@/index.less'; import CommonBase from '@/components/Common/CommonBase'; import CommonListEvent from '@/components/Common/CommonListEvent'; import * as commonConfig from '@/utils/config'; import * as commonServices from '@/services/services'; import oeeStyle from './oee.less'; import OeeSearchComponent from './oeeSearchComponent'; import AffixOeeMenu from './AffixOeeMenu'; // import { timeMillisecond } from 'd3-time'; const { Content } = Layout; class OeeCommonList extends Component { constructor(props) { super(props); this.state = { }; } shouldComponentUpdate(nextProps) { const { slaveColumn } = nextProps; return commonUtils.isNotEmptyArr(slaveColumn); } componentDidUpdate() { // 设置table中的ant-table-body的高度,使滚动条至底 if (document.getElementsByClassName('xly-normal-list') && commonUtils.isNotEmptyArr(document.getElementsByClassName('table')) && document.getElementsByClassName('table')[0].getElementsByClassName('xly-normal-list')) { const antTable = document.getElementsByClassName('table')[0].getElementsByClassName('xly-normal-list')[0].offsetHeight; const antTableHeader = document.getElementsByClassName('table')[0].getElementsByClassName('ant-table-header')[0].offsetHeight; document.getElementsByClassName('table')[0].getElementsByClassName('ant-table-body')[0].style.height = `${antTable - antTableHeader}px`; } } // 存储过程按钮调用存储过程 handleProcedureCall = async (btnConfig, proName, proInParam) => { const { app, sModelsId } = this.props; const value = { sProName: proName, paramsMap: { sMachineId: app.sMachineNameSId, sProInParam: proInParam, }, }; const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`; const returnData = (await commonServices.postValueService(app.token, value, url)).data; if (returnData.code === 1) { message.success(returnData.msg); this.props.onButtonClick('BtnRefresh'); } else { this.props.onSaveState({ loading: false }); this.props.getServiceError(returnData); } } // 根据配置解析拼接具体参数 handleProParams = (sKey, arr) => { const { [`${sKey}Data`]: tableData, [`${sKey}SelectedRowKeys`]: selectedRowKeys } = this.props; const keyData = commonUtils.isNotEmptyArr(tableData) ? tableData.filter(item => selectedRowKeys.includes(item.sId) || selectedRowKeys.includes(item.sSlaveId)) : []; if (commonUtils.isNotEmptyArr(keyData)) { const addState = {}; addState.key = sKey; const val = []; keyData.forEach((currData) => { const currVal = {}; arr.forEach((filed) => { currVal[`${filed}`] = currData[`${filed}`]; }); val.push(currVal); }); addState.value = val; return addState; } else { return undefined; } }; // 进行存储过程按钮存储过程参数解析拼接 根据存储过程按钮参数配置进行解析,配置是json格式 {"sproName":"cal_sss","inMap":"master.sSlaveId,slave.sId"} handleBtnEent = (btnConfig) => { const { masterData } = this.props; const { sButtonParam } = btnConfig; const btn = JSON.parse(sButtonParam); const sProName = btn.sproName; const inParams = []; const { inMap } = btn; const inlist = inMap.split(','); const masterArr = []; const slaveArr = []; if (inlist.length > 0) { inlist.forEach((item) => { const itemArr = item.split('.'); if (itemArr.length > 0) { const sname = itemArr[0]; const stype = itemArr[1]; if (commonUtils.isNotEmptyStr(sname) && sname === 'master') { masterArr.push(stype); } if (commonUtils.isNotEmptyStr(sname) && sname === 'slave') { slaveArr.push(stype); } } }); if (commonUtils.isNotEmptyArr(masterArr) && commonUtils.isNotEmptyObject(masterData)) { const addState = {}; addState.key = 'master'; const val = []; const currVal = {}; masterArr.forEach((filed) => { currVal[`${filed}`] = masterData[`${filed}`]; }); val.push(currVal); addState.value = val; inParams.push({ ...addState }); } if (commonUtils.isNotEmptyArr(slaveArr)) { const addState = this.handleProParams('slave', slaveArr); if (commonUtils.isNotEmptyObject(addState)) { inParams.push({ ...addState }); } } } this.handleProcedureCall(btnConfig, sProName, JSON.stringify({ params: inParams })); }; handleBtnClick = (btnConfig) => { if (btnConfig.sControlName === 'BtnCopyTo.productionReport') { this.props.onOeeCopyTo(btnConfig.sControlName, btnConfig.sActiveId); } else if (btnConfig.sControlName === 'BtnClose') { // eslint-disable-next-line prefer-destructuring const userAgent = navigator.userAgent; if (userAgent.indexOf('Firefox') !== -1 || userAgent.indexOf('Chrome') !== -1) { window.location.href = 'about:blank'; } else { window.opener = null; window.open(' ', '_self', ' '); window.close(); } } else if (commonUtils.isNotEmptyObject(btnConfig.sControlName) && btnConfig.sControlName.indexOf('BtnConvert') > -1) { this.handleBtnEent(btnConfig); } } render() { return ( ); } } const CommonOeeReportComponent = Form.create({ mapPropsToFields(props) { const { masterData } = props; const obj = commonFunc.mapPropsToFields(masterData, Form); return obj; }, })((props) => { const { form, onReturnForm, slavePagination, slaveConfig, isSmall, onBtnClick, } = props; // isSmall将分页变小,以及去掉跳转页面和总条数记录 /* 回带表单 */ if (commonUtils.isNotEmptyObject(slavePagination)) { if (isSmall) { slavePagination.showTotal = null; } } onReturnForm(form); const pagination = false; const tableProps = { ...commonBusiness.getTableTypes('slave', props), onSaveState: props.onSaveState, clearArray: props.clearArray, readOnly: true, isSmall, sGroupByList: props.sGroupByList, tableProps: { rowKey: 'sSlaveId', pagination, onChange: props.onTitleChange, }, }; // console.log('============tableProps\r\n', tableProps); // if (tableProps?.config?.gdsconfigformslave) { // tableProps.config.gdsconfigformslave.forEach(item => { // if (item.sName === 'sPicturePath') { // item.bVisible = true; // item.sName = 'sDownload'; // item.showName = '附件'; // } // }); // } // if (tableProps?.data) { // tableProps.data.forEach((item, index) => { // if (item.sPicturePath) { // item.sDownload = item.sPicturePath; // } // if (index === 2) { // item.sDownload = 'D:/xlyweberp/xlyerpfiles/tempPath/202206/101801153119616561520852730_test.pdf,D:/xlyweberp/xlyerpfiles/tempPath/202206/101801153119616561520852730_全能印厂部分流程.jpg,D:/xlyweberp/xlyerpfiles/tempPath/202206/101801153119616561520938420_包装ERP流程.vsd,D:/xlyweberp/xlyerpfiles/tempPath/202111/12012615914116379057124180_1637905703379.jpg' // } // if (index === 3) { // item.sDownload = 'D:/xlyweberp/xlyerpfiles/tempPath/202206/101801153119616561520852730_test.pdf'; // } // }); // } // 取得配置中的按钮 const buttonConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.sName === '' && item.showName !== '' && item.sControlName !== '' && item.bVisible && item.sControlName.indexOf('Btn') > -1) : []; return (
{ commonUtils.isNotEmptyArr(buttonConfig) ? buttonConfig.map((item, index) => { if (item.sControlName === 'BtnSet') { return ( // eslint-disable-next-line jsx-a11y/anchor-is-valid,react/no-array-index-key onBtnClick(item)}> {item.showName} ); } else { return ( // eslint-disable-next-line jsx-a11y/anchor-is-valid,react/no-array-index-key onBtnClick(item)}> {item.showName} ); } }) : '' }
); }); export default CommonBase(CommonListEvent(OeeCommonList));