diff --git a/.umirc.ts b/.umirc.ts index 892a464..c5003c7 100644 --- a/.umirc.ts +++ b/.umirc.ts @@ -43,6 +43,8 @@ export default defineConfig({ { path: '/indexPage/processCardPack'}, { path: '/indexPage/processCardPackTableTree'}, { path: '/indexPage/processCardPackTableTreeNew'}, + { path: '/indexPage/workOrderPackTableTreeNew'}, + { path: '/indexPage/productionPlan'}, ], }, ], diff --git a/src/components/Common/commonFunc.js b/src/components/Common/commonFunc.js index d9bf99d..052c353 100644 --- a/src/components/Common/commonFunc.js +++ b/src/components/Common/commonFunc.js @@ -42,6 +42,9 @@ export function getConfig(type, name, config, gdsformconst, gdsjurisdiction, sDe return returnConfig; } +export function getControlConfig() { + return '' +} export function getDateFormat(systemData) { const iIndex = systemData.findIndex(item => (item.sName === 'CbxDateTime')); const sCbxDateTime = iIndex > -1 ? diff --git a/src/components/Manufacture/WorkOrderPackTableTreeNew/index.js b/src/components/Manufacture/WorkOrderPackTableTreeNew/index.js index 1903fe5..39d77f0 100644 --- a/src/components/Manufacture/WorkOrderPackTableTreeNew/index.js +++ b/src/components/Manufacture/WorkOrderPackTableTreeNew/index.js @@ -10,7 +10,7 @@ import { CommonPackEvent, CommonModal } from "../CommonPackEvent"; import * as commonBusiness from "@/components/Common/commonBusiness"; import * as commonUtils from "@/utils/utils"; import * as commonFunc from "@/components/Common/commonFunc"; -import * as commonConfig from "@/utils/config"; +import commonConfig from "@/utils/config"; import * as commonServices from "@/services/services"; import Toolbar from "@/components/Common/ToolBar/ToolBarNew"; import CommonView from "@/components/Common/CommonView"; @@ -4549,7 +4549,7 @@ const MaterialsComponent = props => { // 限制编辑-劲嘉定制 if (index === 0 || index === 3) { materialsOtherPropsType.otherlimitDisabled = params => { - const { enabledNew, record, sName } = params; + let { enabledNew, record, sName } = params; if (!["101251240115016082594412050"].includes(props.sModelsId)) return enabledNew; if (enabledNew && ["dAuxiThousheetQty"].includes(sName) && record.dPackageQty > 0) { enabledNew = false; diff --git a/src/components/ProductionPlan/ProductionPlan.js b/src/components/ProductionPlan/ProductionPlan.js new file mode 100644 index 0000000..e4148ce --- /dev/null +++ b/src/components/ProductionPlan/ProductionPlan.js @@ -0,0 +1,760 @@ +/* eslint-disable react/jsx-indent */ + +import React, { Component } from 'react'; +import { SearchOutlined, SettingOutlined } from '@ant-design/icons'; +import { Form } from '@ant-design/compatible'; +import '@ant-design/compatible/assets/index.css'; +import { + message, + Layout, + Switch, + DatePicker, + Radio, + Input, + Button, + Select, + Row, + Col, +} from 'antd'; +import moment from 'moment'; +import * as thisUtils from './ProductionPlanUtils';/* 单据业务功能 */ +import styles1 from './index.less'; +import CommonBase from '../Common/CommonBase';/* 获取配置及数据 */ +import * as commonUtils from '../../utils/utils';/* 通用方法 */ +import * as commonFunc from '../../components/Common/commonFunc'; +import StaticEditTable from '../Common/CommonTable';/* 可编辑表格 */ +import * as commonBusiness from '../Common/commonBusiness';/* 单据业务功能 */ +import AntdDraggableModal from '../Common/AntdDraggableModal'; + +const { + Header, Content, Footer, Sider, +} = Layout; +const { RangePicker } = DatePicker; +const RadioGroup = Radio.Group; +const { Option } = Select; +const InputGroup = Input.Group; +const FormItem = Form.Item; + + +// const printItem = ( +// +// 印刷排程 +// 印后排程 +// +// ) +class ProductionPlan extends Component { + constructor(props) { + super(props); + this.state = { + enabled: true, + planTop: styles1.top, + radiovalue: 0, + sSqlCondition: '', + inputCondition: '1', + inputText: '', + searchText: '', + dataFrom: moment().startOf('day').subtract(100, 'days'), + dataTo: moment().endOf('day'), + processTableVisable: false, + processTableLoding: false, + curProductName: '', + // selectedRowKeys: [], // Check here to configure the default column + // selectedMachineRowKeys: [], // Check here to configure the default column + changeMachine: true, + sChangeTeamId: '', + sChangeMachineId: '', + loading: false, + filterListData: [{ + key: '1', + value: '工单号', + }, { + key: '2', + value: '订单号', + }, { + key: '3', + value: '客户名称', + }, { + key: '4', + value: '印件名称', + }], + teamData: [], + DropDownlistMachineData: [], + // ArrangeColumns: [{ + // title: '工单号', + // dataIndex: 'sOrderNo', + // width: 300, + // ...this.getColumnSearchProps('sOrderNo'), + // render: (text, record) => + // , + // }, { + // title: '工序名称', + // dataIndex: 'sProcessName', + // width: 150, + // ...this.getColumnSearchProps('sProcessName'), + // }, { + // title: '客户', + // dataIndex: 'sCustomerName', + // width: 200, + // }, { + // title: '印件', + // dataIndex: 'sProductName', + // width: 200, + // }, { + // title: '数量', + // dataIndex: 'dProductQty', + // width: 200, + // }, { + // title: '班组', + // dataIndex: 'sTeamName', + // width: 200, + // }], + // ArrangeData: [], + }; + this.dscrollY = 'calc(100vh - 423px - 35px)'; + this.form = {}; + this.handleList(0, 0, '', '1 = 1'); // 工作中心 + // this.handleList(1, 0, '', '1 = 1'); // 排程数据 + } + componentWillReceiveProps(nextProps) { + let { + workCenterColumn, + machineColumn, + arrangeColumn, + constFind, + constReset, + constScheduling, + constOutProcessing, + constRelease, + constSuspend, + constCancelSuspend, + constReturn, + constChangeTeam, + constChangeMachine, + constConfirm, + constSave, + constPrint, + constOutExcel, + constCloseDrag, + constOpenDrag, + constRdoStatus, + constCondition, + constKeyWord, + } = nextProps; + const { formData } = nextProps; + if (commonUtils.isEmptyArr(workCenterColumn) && formData.length > 0) { + const workCenterConfig = formData.filter(item => item.sTbName.toUpperCase() === 'sisworkcenter'.toUpperCase())[0]; + workCenterColumn = commonFunc.getHeaderConfig(workCenterConfig, workCenterColumn); + const tableConfig = workCenterConfig.gdsconfigformslave; + const column = []; + for (const child of tableConfig) { + if (child.bVisible && child.sControlName !== '') { + let sDropDown = []; + if (child.sChineseDropDown !== '' && child.sChineseDropDown.indexOf(',') > 0) { + sDropDown = child.sChineseDropDown.split(','); + } + column.push({ + sControlName: child.sControlName, + sChinese: child.sChinese, + sChineseDropDown: sDropDown, + }); + } + } + constFind = commonFunc.getControlConfig('BtnFind', column); + constReset = commonFunc.getControlConfig('BtnReset', column); + constScheduling = commonFunc.getControlConfig('BtnScheduling', column); + constOutProcessing = commonFunc.getControlConfig('BtnOutProcessing', column); + constRelease = commonFunc.getControlConfig('BtnRelease', column); + constSuspend = commonFunc.getControlConfig('BtnSuspend', column); + constCancelSuspend = commonFunc.getControlConfig('BtnCancelSuspend', column); + constReturn = commonFunc.getControlConfig('BtnReturn', column); + constChangeTeam = commonFunc.getControlConfig('EdtChangeTeam', column); + constChangeMachine = commonFunc.getControlConfig('EdtChangeMachine', column); + constConfirm = commonFunc.getControlConfig('BtnConfirm', column); + constSave = commonFunc.getControlConfig('BtnSave', column); + constPrint = commonFunc.getControlConfig('BtnPrint', column); + constOutExcel = commonFunc.getControlConfig('BtnOutExcel', column); + constCloseDrag = commonFunc.getControlConfig('bCloseDrag', column); + constOpenDrag = commonFunc.getControlConfig('bOpenDrag', column); + constRdoStatus = commonFunc.getControlConfig('RdoStatus', column); + constCondition = commonFunc.getControlConfig('LstCondition', column); + constKeyWord = commonFunc.getControlConfig('EdtKeyWord', column); + // constFind = column. + // constFind: '查找', + // constReset: '重置', + // constScheduling: '生产排程', + // constOutProcessing: '发外加工', + // constRelease: '下达', + // constSuspend: '暂停', + // constCancelSuspend: '取消下达', + // constReturn: '返回重排', + // constChangeTeam: '换班组', + // constChangeMachine: '换机台', + // constConfirm: '确认更换', + // constSave: '保存', + // constPrint: '打印', + // constOutExcel: '导出', + // constDrag: '是否拖动', + // constRdoStatus: '未排程,已排程,已下达,正在生产,已暂停,冻结,已完工,全部', + // constCondition: '工单号,订单号,客户名称,印件名称', + // constKeyWord: '关键字', + + const machineConfig = formData.filter(item => item.sTbName.toUpperCase() === 'elemachine'.toUpperCase())[0]; + machineColumn = commonFunc.getHeaderConfig(machineConfig, machineColumn); + const arrangeConfig = formData.filter(item => item.sTbName.toUpperCase() === 'mftproductionplanslave'.toUpperCase())[0]; + arrangeColumn = commonFunc.getHeaderConfig(arrangeConfig, arrangeColumn); + this.props.onSaveState({ + workCenterConfig, + workCenterColumn, + machineConfig, + machineColumn, + arrangeConfig, + arrangeColumn, + constFind, + constReset, + constScheduling, + constOutProcessing, + constRelease, + constSuspend, + constCancelSuspend, + constReturn, + constChangeTeam, + constChangeMachine, + constConfirm, + constSave, + constPrint, + constOutExcel, + constCloseDrag, + constOpenDrag, + constRdoStatus, + constCondition, + constKeyWord, + }); + } + } + componentWillUpdate() { + } + + getColumnSearchProps = dataIndex => ({ + filterDropdown: ({ + setSelectedKeys, selectedKeys, confirm, clearFilters, + }) => ( + +
+ { this.searchInput = node; }} + placeholder={` ${dataIndex}`} + value={selectedKeys[0]} + onChange={e => setSelectedKeys(e.target.value ? [e.target.value] : [])} + onPressEnter={() => this.handleSearch(selectedKeys, confirm)} + style={{ width: 188, marginBottom: 8, display: 'block' }} + /> + + +
+ ), + filterIcon: filtered => , + onFilter: (value, record) => record[dataIndex].toString().toLowerCase().includes(value.toLowerCase()), + onFilterDropdownVisibleChange: (visible) => { + if (visible) { + setTimeout(() => this.searchInput.select()); + } + }, + render: text => (text), + }) + + getInputSqlCondition = (i) => { + switch (i) { + case '1': + return 'M.sWorkOrderId like '; + case '2': + return 'M.sOrderNo like '; + case '3': + return 'EM.sCustomerName like '; + default: + return 'ET.sProductName like '; + } + } + handleSelectMachineChange = (name, selectedMachineRowKeys) => { + if (this.state.radiovalue > 0) { + this.handleList(1, -1, selectedMachineRowKeys[0], `M.sMachineId =''${selectedMachineRowKeys[0]}''`); // 排程数据 + } + this.props.onSaveState({ + [`${name}SelectedRowKeys`]: selectedMachineRowKeys, + sChangeTeamId: '', + teamData: [], + }); + } + handleSelectChange = (name, selectedRowKeys) => { + const selectedData = this.props.arrangeData.filter(item => selectedRowKeys.indexOf(item.key) > -1); + this.props.onSaveState({ + [`${name}SelectedRowKeys`]: selectedRowKeys, + }); + this.setState({ + changeMachine: true, + sChangeMachineId: '', + DropDownlistMachineData: [], + }); + // 去重复 + const res = new Map(); + if (selectedData.filter(a => !res.has(a.sProcessName) && res.set(a.sProcessName, 1)).length > 1) { + this.setState({ changeMachine: false }); + } + } + handleTeamChange =(value) => { + this.setState({ + sChangeTeamId: value, + }); + } + handleMachineChange =(value) => { + this.setState({ + sChangeMachineId: value, + }); + } + handleRangePickerChange=(date) => { + this.setState({ + dataFrom: date[0], + dataTo: date[1], + }); + } + + handleListConditionChange= (value) => { + this.setState({ + inputCondition: value, + }); + } + handleInputChange = (e) => { + this.setState({ + inputText: e.target.value, + }); + } + + handlePrintChange = () => { + } + queryBillProcess = (key, value) => { + this.setState({ + processTableVisable: true, + curProductName: value, + processTableLoding: true, + }); + this.handleList(0, -1, '', '1 = 1'); // 工作中心 + } + + handleUserSet = () => { + } + handleSearch = (selectedKeys, confirm) => { + confirm(); + this.setState({ searchText: selectedKeys[0] }); + } + + handleRadioChange =(e) => { + this.setState({ + radiovalue: e.target.value, + }); + const radioValue = e.target.value; + if (radioValue < 6) { + this.handleList(0, radioValue, '', '1 = 1'); // 工作中心 无条件查 + // this.handleList(1, radioValue, '', '1 = 1'); // 排程数据 无条件查 + } else { + this.handleList(0, radioValue, '', ''); // 工作中心 根据条件查 + // this.handleList(1, radioValue, '', ''); // 排程数据 根据条件查 + } + } + handleReset = (clearFilters) => { + clearFilters(); + this.setState({ searchText: '' }); + } + + async handleList(iOperType, radioValue, sWorkCenterId, sSqlCondition, sIds, sMachineIds, sTeamId) { + const { app } = this.props; + const params = { + token: app.token, + value: { + sProName: 'Sp_Manufacture_ProducttionPlan_List', + paramsMap: { + iStates: radioValue >= 0 ? radioValue + 1 : this.state.radiovalue + 1, + iOperType, + sWorkCenterId, + sIds: sIds === undefined ? [''] : sIds.toString(), + sMachineId: sMachineIds === undefined ? [''] : sMachineIds.toString(), + sTeamId: sTeamId === undefined ? '' : sTeamId, + sSqlCondition: sSqlCondition !== '' ? sSqlCondition : `M.tStartDate >= "${this.state.dataFrom.format('YYYY-MM-DD') + }" and M.tStartDate <= "${this.state.dataTo.format('YYYY-MM-DD')}" and ${this.getInputSqlCondition(this.state.inputCondition) + }"%${this.state.inputText}%"`, + }, + }, + }; + const returnData = await thisUtils.handleGetDataSetByName(params); + const { proData, msgs } = returnData; + if (returnData !== undefined) { + if (iOperType === 0) { + this.props.onSaveState({ + workCenterData: proData, + machineData: [], + arrangeData: [], + machineSelectedRowKeys: [], + arrangeSelectedRowKeys: [], + DropDownlistMachineData: [], + teamData: [], + processTableLoding: false, + }); + // if (proData.length > 0) { + // this.handleList(2, -1, proData[0].sId); + // } + } else if (iOperType === 2) { + this.props.onSaveState({ + machineData: proData, + selectedRowKeys: [], + DropDownlistMachineData: [], + teamData: [], + }); + } else if (iOperType === 100) { // 换班组时,取班组; + this.setState({ teamData: proData }); + } else if (iOperType === 101) { // 取机台时,取机台; + this.setState({ DropDownlistMachineData: proData }); + } else { + this.props.onSaveState({ arrangeData: proData, selectedRowKeys: [] }); + } + } else { + message.error(msgs); + } + } + handleSubmit = async (e) => { + e.preventDefault(); + this.form.validateFields(async (err) => { + if (!err) { + this.handleList(1, -1, '', ''); + } + }); + }; + handleForm = (form) => { + this.form = form; + }; + handleWorkCenterClick = (record) => { + const newKey = record.key; + this.handleList(1, -1, newKey, `M.sWorkCenterId =''${newKey}''`); // 排程数据 + this.handleList(2, -1, newKey, '1 = 1'); // 机器数据 + this.props.onSaveState({ + machineSelectedRowKeys: [], + }); + }; + // start = () => { + // this.setState({ loading: true }); + // // ajax request after empty completing + // setTimeout(() => { + // this.setState({ + // selectedRowKeys: [], + // loading: false, + // }); + // }, 1000); + // } + + processTableOk = () => { + this.setState({ + processTableVisable: false, + }); + } + + processTableCancel = () => { + this.setState({ + processTableVisable: false, + }); + } + + handleTeamDropdown = (e) => { + if (e && this.props.machineSelectedRowKeys.length > 0) { + this.handleList(100, -1, '', '', '', this.props.machineSelectedRowKeys); + } + } + handleMachineDropdown = (e) => { + if (e && this.props.arrangeSelectedRowKeys.length > 0) { + this.handleList(101, -1, '', '', this.props.arrangeSelectedRowKeys[0], ''); + } + } + + handleButtonClick = (e) => { + if (this.props.arrangeSelectedRowKeys.length < 1) { + message.info('排程数据不为空'); + return; + } + if (e === 3 && this.props.machineSelectedRowKeys.length < 1) { // 生产排单 + message.info('请选择机台'); + return; + } + if (e === 11) { // 更换机台 + 班组 + if (this.state.sChangeMachineId !== '' && this.state.sChangeTeamId !== '') { + this.handleList(20, 0, '', '', this.props.arrangeSelectedRowKeys, this.state.sChangeMachineId, this.state.sChangeTeamId); + } else if (this.state.sChangeMachineId !== '') { + this.handleList(21, 0, '', '', this.props.arrangeSelectedRowKeys, this.state.sChangeMachineId, ''); + } else if (this.state.sChangeTeamId !== '') { + this.handleList(22, 0, '', '', this.props.arrangeSelectedRowKeys, '', this.state.sChangeTeamId); + } + } else { + this.handleList(e, 0, '', '', this.props.arrangeSelectedRowKeys, this.props.machineSelectedRowKeys); + } + } + + render() { + const { workCenterColumn } = this.props; + return ( +
+ {commonUtils.isNotEmptyArr(workCenterColumn) ? + + : ''} +
+ ); + } +} + +const ProductionPlanComponent = Form.create({ +})((props) => { + const { + form, + planTop, + radiovalue, + dataFrom, + dataTo, + teamData, + DropDownlistMachineData, + onRadioChange, + onTeamChange, + onMachineChange, + onRangePickerChange, + onListConditionChange, + onInputChange, + onUserSet, + filterListData, + dscrollY, + onSubmit, + onReturnForm, + onWorkCenterClick, + onSelectChange, + onSelectMachineChange, + processTableVisable, + processTableLoding, + curProductName, + // processTableOk, + onProcessTableCancel, + onProcessTableOk, + onButtonClick, + changeMachine, + onTeamDropdown, + onMachineDropdown, + constFind, + // constReset, + constScheduling, + constOutProcessing, + constRelease, + constSuspend, + constCancelSuspend, + constReturn, + constChangeTeam, + constChangeMachine, + constConfirm, + constSave, + constPrint, + constOutExcel, + constCloseDrag, + constOpenDrag, + constRdoStatus, + constCondition, + constKeyWord, + } = props; + // const dscrollRight = 'calc(100vh - 193px - 35px)'; + const { getFieldDecorator } = form; + /* 回带表单 */ + onReturnForm(form); + const left1props = { + ...commonBusiness.getTableTypes('workCenter', props), + tableProps: { + rowSelection: null, + bordered: false, + loading: processTableLoding, + className: styles1.border, + scroll: { x: 270, y: 201 }, + onRow: (record) => { return { onClick: () => { onWorkCenterClick(record); } }; }, + }, + }; + + const left2props = { + ...commonBusiness.getTableTypes('machine', props), + rowSelectionType: 'radio', + onSelectRowChange: onSelectMachineChange, + tableProps: { + bordered: false, + className: styles1.border, + scroll: { x: 270, y: dscrollY }, + }, + }; + const rightprops = { + ...commonBusiness.getTableTypes('arrange', props), + rowSelectionType: 'checkbox', + onSelectRowChange: onSelectChange, + tableProps: { + bordered: true, + className: styles1.border, + // scroll: { x: 3000, y: dscrollRight }, + }, + }; + + return ( +
+ +
+
+ + + + {getFieldDecorator('productionProcess', { + initialValue: radiovalue, + })( + { constRdoStatus.sChineseDropDown.map((o, i) => + {o}) + } + )} + + + + + {getFieldDecorator('productionTime', { + initialValue: [dataFrom, dataTo], + })()} + + + + + + {getFieldDecorator('productionSQl', { + })()} + + + {getFieldDecorator('productionSQlKey', { + })()} + + + + + +
+ +
+ +
+
+
+
+ { + processTableVisable ? + + + + : '' + } +
+ + + + +
+ +
+
+ +
+
+ + + +
+
+
+ + + + + + + + + + + + + + + + + + + {/* */} + {/* */} + {/* */} + + + + + + + +
+
+
+
+ ); +}); +export default CommonBase(ProductionPlan); diff --git a/src/components/ProductionPlan/ProductionPlanUtils.js b/src/components/ProductionPlan/ProductionPlanUtils.js new file mode 100644 index 0000000..7a79d8c --- /dev/null +++ b/src/components/ProductionPlan/ProductionPlanUtils.js @@ -0,0 +1,27 @@ +/* 用于存放业务逻辑 */ +import config from '../../utils/config'; +import * as commonServices from '../../services/services'; + +/* 上一条、下一条、首条、末条从表刷新 */ +export function setprops(props) { + props.ref = ''; + return props; +} + +export async function handleGetDataSetByName(params) { + const { token, value } = params; + const { mastersId, sModelsId } = value.paramsMap; + // const url = `${config.server_host}business/getProData?sModelsId=${sModelsId}`; + const url = `${config.server_host}treegrid/getTreeGridByPro/${mastersId}?sModelsId=${sModelsId}`; + const oReturn = (await commonServices.postValueService(token, value, url)).data; + const msgs = oReturn.msg; + if (oReturn.code === 1) { /* 成功 */ + const { proData } = oReturn.dataset.rows[0].dataSet; + for (const each of proData) { + each.key = each.sId; + } + return { proData, msgs }; + } else { /* 失败 */ + return { undefined, msgs }; + } +} diff --git a/src/components/ProductionPlan/index.less b/src/components/ProductionPlan/index.less new file mode 100644 index 0000000..0359b4b --- /dev/null +++ b/src/components/ProductionPlan/index.less @@ -0,0 +1,100 @@ +.header { + width: 100%; + padding: 10px 0 0 0!important; + height: auto!important; + line-height: inherit!important; + background: #f0f2f5!important; +} +.top { + margin: 81px 10px 0 10px; + background: #fff; + border: 1px solid #ccc; + height: 46px; + line-height: 46px; + padding: 0 10px; + :global { + .ant-form-item { + margin-bottom: 0!important; + line-height: inherit!important; + } + .ant-form-item-control { + line-height: inherit!important; + } + } + } +.content { + height: calc(~'100vh - 193px'); + background: #fff!important; + margin: 0 10px 0 10px; + border: 1px solid #ccc; + border-top: 0; +} + +.left1 { + height: 230px; + overflow: hidden; + background: #fff!important; + border: 1px solid #ccc; + border-left: 0; + border-top: 0; + :global { + .ant-input-disabled { + cursor: default; + } + .ant-input-number-input { + cursor: default; + } + } +} +.left2 { + height: calc(~'100vh - 423px'); + overflow: hidden; + background: #fff!important; + border: 1px solid #ccc; + border-left: 0; + border-top: 0; +} +.border { + border: 0; + padding: 1px 1px!important; +} + +.left { + flex: 0 0 270px!important; + width: 270px!important; + max-width: 270px!important; + } +.right { + height: calc(~'100vh - 193px'); + background: #fff!important; + margin: 0; + border: 1px solid #ccc; + border-top: 0; + overflow: hidden; + :global { + .topTable { + .ant-table-body { + margin-bottom: 0px!important; + padding-bottom: 0; + } + } + } +} +/* 界面设定图标 */ +.affixMenu { + cursor: pointer; + position: fixed; + font-size: 20px; + right: 25px; + top: 90px; +} + +.left, .right { + :global { + .ant-table-thead tr th { + padding:4px 2px!important; + } + } +} + + diff --git a/src/components/productionPlanInfo/productionHeader.js b/src/components/productionPlanInfo/productionHeader.js new file mode 100644 index 0000000..3586f7f --- /dev/null +++ b/src/components/productionPlanInfo/productionHeader.js @@ -0,0 +1,211 @@ +/** + * Created by mar105 on 2019-02-27. + */ +/* eslint-disable object-curly-newline,prefer-destructuring */ +import React, { Component } from 'react'; +import { ExportOutlined, PrinterOutlined, SaveOutlined } from '@ant-design/icons'; +import { Row, Col } from 'antd'; +import styles from '../Common/ToolBar/index.less'; +import ShowType from '../Common/CommonComponent'; +import * as commonUtils from '../../utils/utils';/* 通用方法 */ +import AffixMenu from '../../routes/common/AffixMenu'; +import ProductionPlan1 from '../../assets/ProductionPlan-1.svg'; +import ProductionPlan2 from '../../assets/ProductionPlan-2.svg'; +import ProductionPlan7 from '../../assets/ProductionPlan-7.svg'; +import ProductionPlan8 from '../../assets/ProductionPlan-8.svg'; +import ProductionPlan11 from '../../assets/ProductionPlan-11.svg'; + +export default class productionHeader extends Component { + /** 构造函数 */ + constructor(props) { + super(props); + this.state = { + enabled: props.enabled, + masterConfig: props.masterConfig, + stateValue: props.stateValue, + masterData: props.masterData, + }; + } + + /** 渲染前只执行一次 */ + componentWillMount() { + /* state和this属性赋值 */ + this.assignmentWillProps(this.props); + } + + /** props改变的时候触发 */ + componentWillReceiveProps(nextProps) { + /* state和this属性赋值 */ + this.assignmentWillProps(nextProps); + } + + /** 返回true执行渲染,返回false不渲染 */ + shouldComponentUpdate(nextProps, nextState) { + const { + masterConfig, stateValue, enabled, masterData, + } = this.state; + const ret = enabled !== nextState.enabled || JSON.stringify(masterConfig) !== JSON.stringify(nextState.masterConfig) || + JSON.stringify(masterData) !== JSON.stringify(nextState.masterData) || + JSON.stringify(stateValue) !== JSON.stringify(nextState.stateValue); + return ret; + } + + assignmentWillProps = (props) => { + this.setState({ + enabled: props.enabled, + masterConfig: props.masterConfig, + masterData: props.masterData, + stateValue: props.stateValue, + }); + } + // 获取header按钮状态 stateValue + HandlerHeaderButtonShowState = (props) => { + const { masterData, searchSolution } = props; + let filterCondition = []; + let stateValue = 99; + if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyObject(masterData.sSearchSolutionId)) { + const iIndex = searchSolution.findIndex(item => item.sId === masterData.sSearchSolutionId); + if (iIndex > -1) { + filterCondition = JSON.parse(searchSolution[iIndex].sCondition); + let state = ''; + let frozen = ''; + filterCondition.forEach((item) => { + if (item.bFilterName === 'sState') { + state = item.bFilterValue; + } + if (item.bFilterName === 'bFrozen') { + frozen = item.bFilterValue; + } + }); + + if (commonUtils.isEmptyObject(frozen) && commonUtils.isNotEmptyObject(state)) { + if (state === '未排程') { + stateValue = 0; + } else if (state === '未下达' || state === '已排程') { + stateValue = 1; + } else if (state === '已下达') { + stateValue = 2; + } else if (state === '已暂停') { + stateValue = 3; + } else if (state === '已完成') { + stateValue = 5; + } + } else if (commonUtils.isNotEmptyObject(frozen)) { + stateValue = 4; + } else if (commonUtils.isNotEmptyObject(frozen) && commonUtils.isNotEmptyObject(state)) { + stateValue = 99; + } + } + } + return { stateValue }; + } + handleClick = (iTag) => { + this.props.onButtonClick(iTag); + } + + handleSwitchChange = (value) => { + this.props.onSwitchChange(value); + } + rowReturnType = (child, i) => { + const { enabled, stateValue } = this.state; + const sMemo = child.sName.toLowerCase().endsWith('memo'); + const iColValue = sMemo ? 21 : child.iColValue * 2; + const iOrder = sMemo ? 100 : child.iOrder > 100 ? 100 : child.iOrder; + const enabledNew = (enabled && !child.bReadonly && !child.specialControl); + const type = commonUtils.isNotEmptyObject(child.sControlName) && child.sControlName.toLowerCase().startsWith('btn'); + + let showTypeProps = {}; + if (!type) { + const switchBtn = child.sControlName.toLowerCase().startsWith('switch'); + if (!switchBtn) { + showTypeProps = { + name: 'master', + form: this.props.form, + formId: this.props.sModelsId, + getSqlDropDownData: this.props.getSqlDropDownData, + getSqlCondition: this.props.getSqlCondition, + handleSqlDropDownNewRecord: this.props.handleSqlDropDownNewRecord, + getFloatNum: this.props.getFloatNum, + getDateFormat: this.props.getDateFormat, + onChange: this.props.onChange, + showConfig: child, + textArea: sMemo, + enabled: enabledNew, + dataValue: commonUtils.isNotEmptyObject(this.props.masterData) ? this.props.masterData[child.sName] : '', + bTable: false, + }; + return ( + + + + ); + } else { + return ''; + } + } else { + let displayFlag = false; + let disabledFlag = true; + if ((stateValue === '0' && child.iTag === 3) || (stateValue === '1' && child.iTag === 5) + || (stateValue === '0' && child.iTag === 5) || (stateValue === '2' && child.iTag === 4) + || (stateValue === '2' && child.iTag === 5) + || (stateValue === '2' && child.iTag === 17) + || (stateValue === '3' && child.iTag === 6) + || (child.iTag === 1) || (child.iTag === 2) + || (child.iTag === 7) || (child.iTag === 8) || (child.iTag === 11) + || (child.iTag === 12) || (child.iTag === 13) || (child.iTag === 14) || (child.iTag === 15) || (child.iTag === 16) + ) { + displayFlag = true; + } + if ((child.iTag === 1 && (stateValue === '0' || stateValue === '1')) || + (child.iTag === 2 && (stateValue === '0' || stateValue === '1' || stateValue === '2')) || + (child.iTag === 3 && (stateValue === '0' || stateValue === '1')) || + (child.iTag === 4 && stateValue === '2') || + (child.iTag === 5 && stateValue === '2') || + (child.iTag === 6 && stateValue === '3') || + (child.iTag === 7 && stateValue === '2') || + (child.iTag === 8 && stateValue === '2') || + (child.iTag === 11 && (stateValue === '0' || stateValue === '1' || stateValue === '2')) || + ((child.iTag === 12 || child.iTag === 13 || child.iTag === 14) && stateValue !== '99') + ) { + disabledFlag = false; + } + // console.log(child.showName, ' disabledFlag:', disabledFlag, 'displayFlag:', displayFlag); + return displayFlag ? ( + + {(() => { + switch (child.iTag) { + case 1: return ; + case 2: return ; + case 7: return ; + case 8: return ; + case 11: return ; + case 12: return ; + case 13: return ; + case 14: return ; + default: return null; + } + } + )()} + {child.showName} + + ) : ''; + } + } + + render() { + const { masterConfig } = this.state; + const teamMachineProps = masterConfig === undefined ? undefined : masterConfig.gdsconfigformslave; + return ( +
+ + { + commonUtils.isNotEmptyObject(teamMachineProps) ? teamMachineProps.map((child, i) => { + return this.rowReturnType(child, i); + }) : '' + } + + +
+ ); + } +} diff --git a/src/components/productionPlanInfo/productionPlanChangeMacheInfo.js b/src/components/productionPlanInfo/productionPlanChangeMacheInfo.js new file mode 100644 index 0000000..5080399 --- /dev/null +++ b/src/components/productionPlanInfo/productionPlanChangeMacheInfo.js @@ -0,0 +1,109 @@ +/* eslint-disable array-callback-return,no-undef */ +import React, { Component } from 'react'; +import { Form } from '@ant-design/compatible'; +import '@ant-design/compatible/assets/index.css'; +import { Layout, Spin, Button, Row, Col } from 'antd'; +import CommonListEvent from './CommonListEvent';/* 继承销售模块业务功能 */ +import * as commonFunc from './commonFunc';/* 通用单据方法 */ /* 通用单据方法 */ +import StaticEditTable from './CommonTable';/* 可编辑表格 */ +import CommonBase from './CommonBase';/* 获取配置及数据 */ +import * as commonBusiness from './commonBusiness';/* 单据业务功能 */ +import SearchComponent from './SearchComponent';/* 搜索组件 */ +import commonConfig from '../../utils/config'; + +const { Content } = Layout; + +class ProductionPlanChangeMachineInfoComponent extends Component { + constructor(props) { + super(props); + this.state = { + }; + } + /** 确认下单 */ + handleSelect = () => { + const { slaveSelectedData, app } = this.props; + this.props.app.currentPane.select(app.currentPane.name, app.currentPane.config, slaveSelectedData); + this.props.app.currentPane.selectCancel(app.currentPane.name); + }; + /** 关闭 */ + handleCancelModal = () => { + const { app } = this.props; + this.props.app.currentPane.selectCancel(app.currentPane.name); + }; + // ----------------------------数据修改回带end ---------------------------- // + + render() { + const { pageLoading } = this.props; + return ( +
+ +
+ +
+
+
+ ); + } +} + +const CommonListComponent = Form.create({ + mapPropsToFields(props) { + const { masterData } = props; + const obj = commonFunc.mapPropsToFields(masterData, Form); + return obj; + }, +})((props) => { + const { form, onReturnForm, slavePagination } = props; + /* 回带表单 */ + onReturnForm(form); + const pagination = { + ...slavePagination, + size: 'large', + pageSize: commonConfig.pageSize, + showQuickJumper: true, + hideOnSinglePage: true, + }; + const tableProps = { + ...commonBusiness.getTableTypes('slave', props), + tableProps: { rowKey: 'sId', pagination, onChange: props.onTitleChange }, + }; + const teamProps = { + ...commonBusiness.getTableTypes('team', props), + tableProps: { rowKey: 'sId', pagination, onChange: props.onTitleChange }, + }; + return ( +
+ + +
+
+ +
+ + + + + + + + + + +
+
+
+ + +
+
+
+ ); +}); + +export default CommonBase(CommonListEvent(ProductionPlanChangeMachineInfoComponent)); diff --git a/src/components/productionPlanInfo/productionPlanInfo.js b/src/components/productionPlanInfo/productionPlanInfo.js new file mode 100644 index 0000000..4d72a72 --- /dev/null +++ b/src/components/productionPlanInfo/productionPlanInfo.js @@ -0,0 +1,714 @@ +/* eslint-disable array-callback-return,no-undef,object-curly-newline,prefer-destructuring,no-unused-vars */ +import React, { Component } from 'react'; +import { Form } from '@ant-design/compatible'; +import '@ant-design/compatible/assets/index.css'; +import { Modal, Layout, Spin, Card, Row, Col } from 'antd'; // Switch Select, Tabs, +import styles from '../../index.less'; +import selfstyles from '../productionMainPlan/index.less'; +import * as commonFunc from '../Common/commonFunc'; +import CommonBase from '../Common/CommonBase'; +import * as commonBusiness from '../Common/commonBusiness';/* 单据业务功能 */ +import StaticEditTable from '../Common/CommonTable';/* 可编辑表格 */ +import CommonProductionPlanEvent from '../Common/CommonProductionPlanEvent'; +import Toolbar from '../Common/ToolBar/ToolBarNew'; +import MoveUp from '../../assets/processUp.svg'; +import MoveDown from '../../assets/processDown.svg'; +import DisableMoveUp from '../../assets/disableprocessUp.svg'; +import DisableMoveDown from '../../assets/disableprocessDown.svg'; +import MoveTop from '../../assets/processTop.svg'; +import DisableMoveTop from '../../assets/disableprocessTop.svg'; +import MoveBottom from '../../assets/processBottom.svg'; +import DisableMoveBottom from '../../assets/disableprocessBottom.svg'; +import ChangeMachine from '../../assets/changeMachine.svg'; +import DisableChangeMachine from '../../assets/disablechangeMachine.svg'; +import Reset from '../../assets/reset.svg'; +import DisableReset from '../../assets/disablereset.svg'; +import * as commonUtils from '../../utils/utils'; +import ShowType from '../Common/CommonComponent'; +import commonConfig from '../../utils/config'; +import AntdDraggableModal from '../Common/AntdDraggableModal'; + +// const { Option } = Select; +const { Header, Content, Sider } = Layout; +// const { TabPane } = Tabs; + +class ProductionPlanInfoComponentInfo extends Component { + constructor(props) { + super(props); + this.state = {}; + this.form = {}; /* 表单对象 */ + } + + shouldComponentUpdate(nextProps) { + const { slaveColumn, masterConfig } = nextProps; + return commonUtils.isNotEmptyArr(slaveColumn) || commonUtils.isNotEmptyObject(masterConfig); + } + // onRowMouseEnter = (name, record) => { + // console.log('record:', record); + // } + onDoubleClick = (name, record) => { + if (this.props.onDoubleClick !== undefined) { + this.props.onDoubleClick(record); + } + }; + onRowClick = (name, record, bRowClick) => { + const { slaveData } = this.props; + let { slaveSelectedRowKeys, slaveInfoSelectedRowKeys } = this.props; + slaveInfoSelectedRowKeys = commonUtils.isNotEmptyArr(slaveInfoSelectedRowKeys) ? slaveInfoSelectedRowKeys : []; + if (name === 'slave') { + if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) { + const keys = []; + keys.push(record.sSlaveId); + slaveSelectedRowKeys = keys; + const sIds = record.sSlaveId.split('-'); + slaveInfoSelectedRowKeys.push(...sIds); + } else { + const indexKey = slaveSelectedRowKeys.indexOf(record.sSlaveId); + if (indexKey === -1) { + slaveSelectedRowKeys.push(record.sSlaveId); + const sIds = record.sSlaveId.split('-'); + slaveInfoSelectedRowKeys.push(...sIds); + sIds.forEach((item) => { + const iIndex = slaveInfoSelectedRowKeys.findIndex(e => e === item); + if (iIndex === -1) { + slaveInfoSelectedRowKeys.push(item); + } + }); + } else if (indexKey !== -1) { + if (!bRowClick) { + slaveSelectedRowKeys.splice(indexKey, 1); + } + const sIds = record.sSlaveId.split('-'); + sIds.forEach((item) => { + const index = slaveInfoSelectedRowKeys.findIndex(e => e === item); + if (!bRowClick) { + slaveInfoSelectedRowKeys.splice(index, 1); + } + }); + } + } + } else if (name === 'slaveInfo') { + if (commonUtils.isEmptyArr(slaveInfoSelectedRowKeys)) { + const keys = []; + keys.push(record.sId); + slaveInfoSelectedRowKeys = keys; + const slaveDataNews = slaveData.filter(item => item.sSlaveId.split('-').includes(record.sId)); + if (commonUtils.isNotEmptyArr(slaveDataNews)) { + slaveSelectedRowKeys = [slaveDataNews[0].sSlaveId]; + } + } else { + const indexKey = slaveInfoSelectedRowKeys.indexOf(record.sId); + if (indexKey === -1) { + slaveInfoSelectedRowKeys.push(record.sId); + const slaveDataNews = slaveData.filter(item => item.sSlaveId.split('-').includes(record.sId)); + if (commonUtils.isNotEmptyArr(slaveDataNews)) { + const iIndex = slaveSelectedRowKeys.findIndex(item => item === slaveDataNews[0].sSlaveId); + if (iIndex === -1) { + slaveSelectedRowKeys.push(slaveDataNews[0].sSlaveId); + } + } + } else if (indexKey !== -1) { + /* 可输入行,行内点击时 不去除selectedRowKeys */ + if (!bRowClick) { + slaveInfoSelectedRowKeys.splice(indexKey, 1); + } + const slaveDataNews = slaveData.filter(item => item.sSlaveId.split('-').includes(record.sId)); + if (commonUtils.isNotEmptyArr(slaveDataNews)) { + const sSlaveIds = slaveDataNews[0].sSlaveId.split('-'); + if (slaveInfoSelectedRowKeys.length === 0 || sSlaveIds.length === 1) { + const iIndex = slaveSelectedRowKeys.indexOf(item => slaveDataNew[0].sSlaveId === item); + slaveSelectedRowKeys.splice(iIndex, 1); + } else { + let bdel = true; + for (const sId of sSlaveIds) { + if (slaveInfoSelectedRowKeys.findIndex(item => item === sId && item !== record.sId)) { + bdel = false; + break; + } + } + if (bdel) { + const iIndex = slaveSelectedRowKeys.indexOf(item => slaveDataNew[0].sSlaveId === item); + slaveSelectedRowKeys.splice(iIndex, 1); + } + } + } + } + } + } + let machineEnabled = false; + if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) { + const currSlave = slaveData.filter(item => item.sSlaveId === slaveSelectedRowKeys[0])[0]; + const processSlave = slaveData.filter(item => item.sProcessId === currSlave.sProcessId && slaveSelectedRowKeys.includes(item.sSlaveId)); + if (processSlave.length === slaveSelectedRowKeys.length) { + machineEnabled = true; + } + } + const { sModelsId } = this.props; + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sMachineId', []); + this.props.onSaveState({ slaveSelectedRowKeys, slaveInfoSelectedRowKeys, machineEnabled }); + }; + + onCloseChangeMachine = () => { + const { masterData } = this.props; + delete masterData.tStartDate; + delete masterData.iSplitNum; + delete masterData.bSplit; + this.props.onSaveState({ isChangeMachine: false, masterData: { ...masterData, sMachineId: '', sTeamId: '' } }); + } + + onTableSelectRowChange = (name, selectedRowKeys) => { + if (name === 'slave') { + const addState = this.props.onTableSelectRowChange(name, selectedRowKeys, true); + const slaveInfoSelectedRowKeys = []; + if (commonUtils.isNotEmptyArr(selectedRowKeys)) { + selectedRowKeys.forEach((selectedRow) => { + const sIds = selectedRow.split('-'); + slaveInfoSelectedRowKeys.push(...sIds); + }); + } + addState.slaveInfoSelectedRowKeys = slaveInfoSelectedRowKeys; + this.props.onSaveState({ ...addState }); + } else { + this.props.onTableSelectRowChange(name, selectedRowKeys); + } + // let record = {}; + // let key; + // if (name === 'slave') { + // if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isEmptyArr(slaveSelectedRowKeys) && selectedRowKeys.length === 1) { + // key = selectedRowKeys[0]; + // } else if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys) && commonUtils.isEmptyArr(selectedRowKeys) && slaveSelectedRowKeys.length === 1) { + // key = slaveSelectedRowKeys[0]; + // } else if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isNotEmptyArr(slaveSelectedRowKeys) && selectedRowKeys.length > slaveSelectedRowKeys.length) { + // key = selectedRowKeys.filter(item => !slaveSelectedRowKeys.includes(item))[0]; + // } else if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isNotEmptyArr(slaveSelectedRowKeys) && selectedRowKeys.length < slaveSelectedRowKeys.length) { + // key = slaveSelectedRowKeys.filter(item => !selectedRowKeys.includes(item))[0]; + // } + // record = tableData.filter(item => key === item.sSlaveId)[0]; + // this.onRowClick(name, record); + // } else if (name === 'slaveInfo') { + // if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isEmptyArr(slaveInfoSelectedRowKeys) && selectedRowKeys.length === 1) { + // key = selectedRowKeys[0]; + // } else if (commonUtils.isNotEmptyArr(slaveInfoSelectedRowKeys) && commonUtils.isEmptyArr(selectedRowKeys) && slaveInfoSelectedRowKeys.length === 1) { + // key = slaveInfoSelectedRowKeys[0]; + // } else if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isNotEmptyArr(slaveInfoSelectedRowKeys) && selectedRowKeys.length > slaveInfoSelectedRowKeys.length) { + // key = selectedRowKeys.filter(item => !slaveInfoSelectedRowKeys.includes(item))[0]; + // } else if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isNotEmptyArr(slaveInfoSelectedRowKeys) && selectedRowKeys.length < slaveInfoSelectedRowKeys.length) { + // key = slaveInfoSelectedRowKeys.filter(item => !selectedRowKeys.includes(item))[0]; + // } + // record = tableData.filter(item => key === item.sId)[0]; + // this.onRowClick(name, record); + // } else { + // this.props.onTableSelectRowChange(name, selectedRowKeys); + // } + }; + + /** 处理选择行发生改变 */ + handleTableFilterData = (name, data, record) => { + /* 外置处理业务 */ + if (name === 'slave') { + let slaveInfoDataNew = []; + if (commonUtils.isNotEmptyArr(data)) { + slaveInfoDataNew = data.filter(item => record.sSlaveId.split('-').includes(item.sId)); + } + return slaveInfoDataNew; + } + }; + + // 根据配置解析拼接具体参数 + handleProParams = (sKey, arr) => { + const { [`${sKey}Data`]: tableData, [`${sKey}SelectedRowKeys`]: selectedRowKeys } = this.props; + const keyData = 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; + } + }; + + sortData = (tempData) => { + tempData.sort((g1, g2) => { + return g1.iOrder - g2.iOrder; + }); + return tempData; + }; + + /* 控制排序 */ + orderData = (e, name, type) => { + const { [`${name}SelectedRowKeys`]: tableselectedRowKeys, app, slavePagination: slavePaginationOld } = this.props; + let { [`${name}Data`]: currentData } = this.props; + if (name === 'slave') { + if (commonUtils.isEmptyArr(tableselectedRowKeys)) { + message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseMoveData'));/* 请勾选要移动数据 */ + return; + } + if (commonUtils.isEmptyArr(currentData)) { + message.warn(commonFunc.showMessage(app.commonConst, 'NoProcessData'));/* 请填写工序表数据 */ + return; + } + const tempNew = currentData.filter((item) => { /* 获取勾选数据集 */ + return tableselectedRowKeys.indexOf(item.sSlaveId) > -1; + }); + if (commonUtils.isEmptyArr(tempNew)) { + message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseMoveData'));/* 请选择要移动数据 */ + return; + } + const len = currentData.length; + const newLen = tempNew.length; + let num = 0.01;/* 循环增加体 */ + let targetiOrder = -1; + if (type === 1) { /* 上移 */ + const iIndex = currentData.findIndex(item => item.sSlaveId === tempNew[0].sSlaveId);/* 选中第一个节点的下标 */ + if (iIndex === 0) { + if (newLen === 1) { + message.warn(commonFunc.showMessage(app.commonConst, 'NoUp'));/* 无需上移 */ + return; + } else { + targetiOrder = 0; + } + } else { + targetiOrder = currentData[iIndex - 1].iOrder - 1; /* 目标排序号 */ + } + } else if (type === 2) { /* 下移 */ + const iIndex = currentData.findIndex(item => item.sSlaveId === tempNew[newLen - 1].sSlaveId);/* 选中最后一个节点的下标 */ + if (iIndex === len - 1) { + if (newLen === 1) { + message.warn(commonFunc.showMessage(app.commonConst, 'NoDown')); /* 无需下移 */ + return; + } else { + targetiOrder = currentData[iIndex].iOrder; + } + } else { + targetiOrder = currentData[iIndex + 1].iOrder; + } + } else if (type === 0) { /* 置顶 */ + const iIndex = currentData.findIndex(item => item.sSlaveId === tempNew[0].sSlaveId);/* 选中第一个节点的下标 */ + if (iIndex === 0) { + if (newLen === 1) { + message.warn(commonFunc.showMessage(app.commonConst, 'NoTop')); /* 无需置顶 */ + return; + } else { + targetiOrder = currentData[iIndex].iOrder; + } + } else { + targetiOrder = currentData[0].iOrder - 1; + } + } else if (type === 3) { /* 置底 */ + const iIndex = currentData.findIndex(item => item.sSlaveId === tempNew[newLen - 1].sSlaveId);/* 选中最后一个节点的下标 */ + if (iIndex === len - 1) { + if (newLen === 1) { + message.warn(commonFunc.showMessage(app.commonConst, 'NoBottom')); /* 无需置底 */ + return; + } else { + targetiOrder = currentData[iIndex].iOrder; + } + } else { + targetiOrder = currentData[len - 1].iOrder + 1; + } + } + tempNew.forEach((item) => { + const index1 = currentData.findIndex(item1 => item1.sSlaveId === item.sSlaveId); + currentData[index1] = { ...item, iOrder: targetiOrder + num, handleType: 'update' }; + num += 0.01; + }); + currentData = this.sortData(currentData); + currentData = this.orderNum(currentData); + const iIndex = currentData.findIndex(item => item.sSlaveId === tableselectedRowKeys[0]); + const slavePagination = { ...slavePaginationOld }; + slavePagination.current = Math.ceil((iIndex + 1) / commonConfig.pageSize); + this.props.onSaveState({ [`${name}Data`]: currentData, slavePagination }); + } else if (name === 'slaveInfo') { + this.props.onSaveState({ isChangeMachine: true }); + } + }; + + /* 自定义排序号 */ + orderNum = (tableData) => { + tableData.forEach((item, index) => { + item.iOrder = index + 1; + item.handleType = 'update'; + }); + return tableData; + }; + + /** 处理选择行发生改变 */ + // handleTableFilterData = (name, data, record) => { + // /* 外置处理业务 */ + // if (name === 'slave') { + // let slaveInfoDataNew = ''; + // slaveInfoDataNew = data.filter(item => record.sSlaveId.split(',').includes(item.sId)); + // return slaveInfoDataNew; + // } + // }; + /** 处理card点击事件 */ + handleTabsCallback = (child) => { + if (commonUtils.isNotEmptyArr(this.props.teamData)) { + child.cardSelectedColor = '#fff7e6'; + const iIndex = this.props.teamData.findIndex(item => item.sId === child.sId); + const teamDataNew = this.props.teamData; + teamDataNew.forEach((item, index) => { + if (index !== iIndex) { item.cardSelectedColor = ''; } + }); + } + this.props.onSaveState({ Loading: true }); + this.props.onTabsCallback(child); + }; + // renderCards = (data) => { + // let showInfo = ''; + // data.map((item) => { + // showInfo += ( + // + // + // {item.sTeamName} {item.dHour} {'30%'} + // + // + // ); + // }); + // return showInfo; + // } + render() { + const { pageLoading } = this.props; + return ( +
+ +
+ +
+
+
+ ); + } +} + +const ProductionPlanComponent = Form.create({ + mapPropsToFields(props) { + const { masterData } = props; + const obj = commonFunc.mapPropsToFields(masterData, Form); + return obj; + }, +})((props) => { + const { + form, onReturnForm, app, masterData, sModelsId, masterConfig, teamSelectedRowKeys, clearArray, slavePagination, planLoadingSate, + Loading } = props; + // console.log('props:===', props); + /* 回带表单 */ + onReturnForm(form); + // const pageFlag = sStateSelect === '0' || sStateSelect === '1' || sStateSelect === '2'; + const pagination = { + pageSize: commonConfig.pageSize, + ...slavePagination, + size: 'large', + pageSizeOptions: commonConfig.pageSizeOptions, + // showQuickJumper: true, + hideOnSinglePage: false, + showSizeChanger: true, + current: commonUtils.isEmptyObject(slavePagination) ? 1 : slavePagination.current, + }; + const width = '18px'; + const height = '18px'; + const moveUp = { + title: '上移', + width: { width }, + height: { height }, + img: 上移, + disableimg: 上移, + }; + const moveDown = { + title: '下移', + width: { width }, + height: { height }, + img: 下移, + disableimg: 下移, + }; + const moveTop = { + title: '置顶', + width: { width }, + height: { height }, + img: 置顶, + disableimg: 置顶, + }; + const moveBottom = { + title: '置底', + width: { width }, + height: { height }, + img: 置底, + disableimg: 置底, + }; + const changeMachine = { + title: '更换机台', + width: { width }, + height: { height }, + img: 更换机台, + disableimg: 更换机台, + }; + const resetSearch = { + title: '重置搜索', + width: { width }, + height: { height }, + img: 重置搜索, + disableimg: 重置搜索, + }; + const addProps = {}; + const tableProps = { + ...commonBusiness.getTableTypes('slave', props), + onTableFilterData: props.onTableFilterData, + tableProps: { + rowKey: 'sSlaveId', + pagination, + sortSelf: true, + onRow: (record) => { + return { + onClick: () => { props.onRowClick('slave', record, true); }, + onDoubleClick: () => { props.onDoubleClick('slave', record); }, + // onMouseEnter: () => { props.onRowMouseEnter('slave', record); }, + }; + }, + onChange: props.onTitleChange.bind(this, 'slave'), + }, + clearArray: props.clearArray, + }; + + const tableInfoProps = { + ...commonBusiness.getTableTypes('slaveInfo', props), + tableProps: { + rowKey: 'sId', + pagination, + planLoadingSate, + onRow: (record) => { + return { + onClick: () => { props.onRowClick('slaveInfo', record, true); }, + onDoubleClick: () => { props.onDoubleClick('slaveInfo', record); }, + // onMouseEnter: () => { props.onRowMouseEnter('slaveInfo', record); }, + }; + }, + onChange: props.onTitleChange.bind(this, 'slaveInfo'), + }, + // data: commonUtils.isNotEmptyObject(props.slaveInfoDataNew) ? props.slaveInfoDataNew : props.slaveInfoData, + }; + const gridStyle = { + width: '100%', + textAlign: 'left', + }; + const setUp = commonFunc.showMessage(app.commonConst, 'setUp');/* 上移 */ + const setDown = commonFunc.showMessage(app.commonConst, 'setDown');/* 下移 */ + const setTop = commonFunc.showMessage(app.commonConst, 'setTop');/* 置顶 */ + const setBottom = commonFunc.showMessage(app.commonConst, 'setBottom');/* 置底 */ + const setMachine = commonFunc.showMessage(app.commonConst, 'changeMachine');/* 置底 */ + const setResetSearch = commonFunc.showMessage(app.commonConst, 'setResetSearch');/* 重置搜索 */ + const resetSearchEnabled = clearArray.length > 0; + + const iMachineIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sMachineId'); + const machineShowTypeProps = { + app, + record: masterData, + name: 'master', + form: props.form, + formId: sModelsId, + getSqlDropDownData: props.getSqlDropDownData, + getSqlCondition: props.getSqlCondition, + handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, + getFloatNum: props.getFloatNum, + getDateFormat: props.getDateFormat, + onChange: props.onChange, + showConfig: iMachineIndex > -1 ? masterConfig.gdsconfigformslave[iMachineIndex] : {}, + formItemLayout: {}, + enabled: true, + dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.sMachineId, + bTable: false, + onFilterDropDownData: props.onFilterDropDownData, + }; + const iTeamIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sTeamId'); + const teamShowTypeProps = { + app, + record: masterData, + name: 'master', + form: props.form, + formId: sModelsId, + getSqlDropDownData: props.getSqlDropDownData, + getSqlCondition: props.getSqlCondition, + handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, + getFloatNum: props.getFloatNum, + getDateFormat: props.getDateFormat, + onChange: props.onChange, + showConfig: iTeamIndex > -1 ? masterConfig.gdsconfigformslave[iTeamIndex] : {}, + formItemLayout: {}, + enabled: true, + dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.sTeamId, + bTable: false, + onFilterDropDownData: props.onFilterDropDownData, + }; + const iStartIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'tStartDate'); + const startShowTypeProps = { + app, + record: masterData, + name: 'master', + form: props.form, + formId: sModelsId, + getSqlDropDownData: props.getSqlDropDownData, + getSqlCondition: props.getSqlCondition, + handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, + getFloatNum: props.getFloatNum, + getDateFormat: props.getDateFormat, + onChange: props.onChange, + showConfig: iStartIndex > -1 ? masterConfig.gdsconfigformslave[iStartIndex] : {}, + formItemLayout: {}, + enabled: true, + dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.tStartDate, + bTable: false, + onFilterDropDownData: props.onFilterDropDownData, + }; + + const bSplitIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'bSplit'); + const splitShowTypeProps = { + app, + record: masterData, + name: 'master', + form: props.form, + formId: sModelsId, + getSqlDropDownData: props.getSqlDropDownData, + getSqlCondition: props.getSqlCondition, + handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, + getFloatNum: props.getFloatNum, + getDateFormat: props.getDateFormat, + onChange: props.onChange, + showConfig: bSplitIndex > -1 ? masterConfig.gdsconfigformslave[bSplitIndex] : {}, + formItemLayout: {}, + enabled: true, + dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.bSplit, + bTable: false, + onFilterDropDownData: props.onFilterDropDownData, + }; + + const iSplitNumIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'iSplitNum'); + const splitNumShowTypeProps = { + app, + record: masterData, + name: 'master', + form: props.form, + formId: sModelsId, + getSqlDropDownData: props.getSqlDropDownData, + getSqlCondition: props.getSqlCondition, + handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, + getFloatNum: props.getFloatNum, + getDateFormat: props.getDateFormat, + onChange: props.onChange, + showConfig: iSplitNumIndex > -1 ? masterConfig.gdsconfigformslave[iSplitNumIndex] : {}, + formItemLayout: {}, + enabled: true, + dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.iSplitNum, + bTable: false, + onFilterDropDownData: props.onFilterDropDownData, + }; + + let selectedRowKey = {}; + if (commonUtils.isNotEmptyArr(teamSelectedRowKeys)) { + selectedRowKey = teamSelectedRowKeys[0]; + } + + let teamDataNum = 0; + if (commonUtils.isNotEmptyArr(props.teamData)) { + // 取得导航按钮的行数 + if (props.teamData.length % 8 === 0) { + teamDataNum = (props.teamData.length / 8) - 1; + } else { + teamDataNum = Math.floor(props.teamData.length / 8); + } + } + return ( +
+ +
+ +
+ +
+ + + + { + commonUtils.isNotEmptyArr(props.teamData) ? props.teamData.map((child) => { + const sType = commonUtils.isNotEmptyNumber(child.sType) ? child.sType.toString() : '';/* 0 - 全部单据 1-未排程 2- 已排程 */ + const cardColor = sType === '0' ? 'allCard' : sType === '1' ? 'unCard' : 'defaultCard'; + return ( + + +
+
+
{child.tStartDate}
+
{`${child.dHour}h`}
+
+
{child.sMachineName}
+
+
+ ); + }) : '' + } +
+
+
+
+ +
+ { + props.isChangeMachine ? + + { commonUtils.isEmptyObject(masterConfig) ? '' : } + { commonUtils.isEmptyObject(masterConfig) ? '' : } + { commonUtils.isEmptyObject(masterConfig) ? '' : } + { commonUtils.isEmptyObject(masterConfig) ? '' : } + { commonUtils.isNotEmptyObject(masterConfig) && commonUtils.isNotEmptyObject(masterData) && masterData.bSplit ? : '' } + + : '' + } +
+
+ ); +}); + +export default CommonBase(CommonProductionPlanEvent(ProductionPlanInfoComponentInfo)); diff --git a/src/components/productionPlanInfo/productionPlanInfo2.js b/src/components/productionPlanInfo/productionPlanInfo2.js new file mode 100644 index 0000000..2dab945 --- /dev/null +++ b/src/components/productionPlanInfo/productionPlanInfo2.js @@ -0,0 +1,136 @@ +/* eslint-disable array-callback-return,no-undef */ +import React, { Component } from 'react'; +import { Form } from '@ant-design/compatible'; +import '@ant-design/compatible/assets/index.css'; +import { Layout, Spin, Select } from 'antd'; // Switch +import styles from '../../index.less'; +import * as commonFunc from '../Common/commonFunc'; +import CommonBase from '../Common/CommonBase'; +import * as commonBusiness from '../Common/commonBusiness';/* 单据业务功能 */ +import StaticEditTable from '../Common/CommonTable';/* 可编辑表格 */ +import SearchComponent from '../Common/SearchComponent';/* 搜索组件 */ +import CommonProductionPlanEvent from '../Common/CommonProductionPlanEvent'; +import config from '../../utils/config'; +import ProductionHeader from './productionHeader';/* 可编辑表格 */ + +const { Option } = Select; +const { Header, Content, Sider } = Layout; + +class ProductionPlanInfoComponentInfo2 extends Component { + constructor(props) { + super(props); + this.state = {}; + this.form = {}; /* 表单对象 */ + } + render() { + const { pageLoading } = this.props; + return ( +
+ +
+ +
+
+
+ ); + } +} +const ProductionPlanComponent = Form.create({ + mapPropsToFields(props) { + const { masterData } = props; + const obj = commonFunc.mapPropsToFields(masterData, Form); + return obj; + }, +})((props) => { + const { + form, onReturnForm, onSelectChange, sStateSelect, isDragAndDrop, stateOption, + } = props; + + /* 回带表单 */ + onReturnForm(form); + const pageFlag = sStateSelect === '0' || sStateSelect === '1' || sStateSelect === '2'; + const workTeamProps = { + ...commonBusiness.getTableTypes('workCenter', props), + tableProps: { rowKey: 'sWorkCenterId' }, + isKeyUsesId: false, + enabled: false, + }; + + const machineProps = { + ...commonBusiness.getTableTypes(sStateSelect === '0' ? 'unMachine' : 'machine', props), + tableProps: { rowKey: 'sMachineId' }, + isKeyUsesId: false, + enabled: false, + }; + + const pagination = { + onChange: props.onPaginationChange, + size: 'large', + pageSize: config.pageSize, + pageNum: config.pageNum, + showQuickJumper: true, + }; + + const processProps = { + ...commonBusiness.getTableTypes('slave', props), + tableProps: { pagination: pageFlag ? false : pagination }, + scrollX: 3, + isDragAndDrop, + }; + + return ( +
+ +
+ +
+ +
+ + +
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+
+
+
+
+ ); +}); + +export default CommonBase(CommonProductionPlanEvent(ProductionPlanInfoComponentInfo2)); diff --git a/src/components/productionPlanInfo/productionPlanOutside.js b/src/components/productionPlanInfo/productionPlanOutside.js new file mode 100644 index 0000000..e1e1e74 --- /dev/null +++ b/src/components/productionPlanInfo/productionPlanOutside.js @@ -0,0 +1,687 @@ +/* eslint-disable array-callback-return,no-undef,object-curly-newline,prefer-destructuring,no-unused-vars */ +import React, { Component } from 'react'; +import { Form } from '@ant-design/compatible'; +import '@ant-design/compatible/assets/index.css'; +import { Modal, Layout, Spin, Card, Row, Col, message } from 'antd'; // Switch Select, Tabs, +import styles from '../../index.less'; +import selfstyles from '../productionMainPlan/index.less'; +import * as commonFunc from '../Common/commonFunc'; +import CommonBase from '../Common/CommonBase'; +import * as commonBusiness from '../Common/commonBusiness';/* 单据业务功能 */ +import StaticEditTable from '../Common/CommonTable';/* 可编辑表格 */ +import CommonProductionPlanEvent from '../Common/CommonProductionPlanEvent'; +import Toolbar from '../Common/ToolBar/ToolBarNew'; +import MoveUp from '../../assets/processUp.svg'; +import MoveDown from '../../assets/processDown.svg'; +import DisableMoveUp from '../../assets/disableprocessUp.svg'; +import DisableMoveDown from '../../assets/disableprocessDown.svg'; +import MoveTop from '../../assets/processTop.svg'; +import DisableMoveTop from '../../assets/disableprocessTop.svg'; +import MoveBottom from '../../assets/processBottom.svg'; +import DisableMoveBottom from '../../assets/disableprocessBottom.svg'; +import ChangeMachine from '../../assets/changeMachine.svg'; +import DisableChangeMachine from '../../assets/disablechangeMachine.svg'; +import Reset from '../../assets/reset.svg'; +import DisableReset from '../../assets/disablereset.svg'; +import * as commonUtils from '../../utils/utils'; +import ShowType from '../Common/CommonComponent'; +import commonConfig from '../../utils/config'; +import AntdDraggableModal from '../Common/AntdDraggableModal'; +import CommonProductionPlanOutsideEvent from '../Common/CommonProductionPlanOutsideEvent'; + + +// const { Option } = Select; +const { Header, Content, Sider } = Layout; +// const { TabPane } = Tabs; + +class ProductionPlanOutside extends Component { + constructor(props) { + super(props); + this.state = {}; + this.form = {}; /* 表单对象 */ + } + + shouldComponentUpdate(nextProps) { + const { slaveColumn, masterConfig } = nextProps; + return commonUtils.isNotEmptyArr(slaveColumn) || commonUtils.isNotEmptyObject(masterConfig); + } + // onRowMouseEnter = (name, record) => { + // console.log('record:', record); + // } + onDoubleClick = (name, record) => { + if (this.props.onDoubleClick !== undefined) { + this.props.onDoubleClick(record); + } + }; + onRowClick = (name, record, bRowClick) => { + const { slaveData } = this.props; + let { slaveSelectedRowKeys, slaveInfoSelectedRowKeys } = this.props; + slaveInfoSelectedRowKeys = commonUtils.isNotEmptyArr(slaveInfoSelectedRowKeys) ? slaveInfoSelectedRowKeys : []; + if (name === 'slave') { + if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) { + const keys = []; + keys.push(record.sSlaveId); + slaveSelectedRowKeys = keys; + const sIds = record.sSlaveId.split('-'); + slaveInfoSelectedRowKeys.push(...sIds); + } else { + const indexKey = slaveSelectedRowKeys.indexOf(record.sSlaveId); + if (indexKey === -1) { + slaveSelectedRowKeys.push(record.sSlaveId); + const sIds = record.sSlaveId.split('-'); + slaveInfoSelectedRowKeys.push(...sIds); + sIds.forEach((item) => { + const iIndex = slaveInfoSelectedRowKeys.findIndex(e => e === item); + if (iIndex === -1) { + slaveInfoSelectedRowKeys.push(item); + } + }); + } else if (indexKey !== -1) { + if (!bRowClick) { + slaveSelectedRowKeys.splice(indexKey, 1); + } + const sIds = record.sSlaveId.split('-'); + sIds.forEach((item) => { + const index = slaveInfoSelectedRowKeys.findIndex(e => e === item); + if (!bRowClick) { + slaveInfoSelectedRowKeys.splice(index, 1); + } + }); + } + } + } else if (name === 'slaveInfo') { + if (commonUtils.isEmptyArr(slaveInfoSelectedRowKeys)) { + const keys = []; + keys.push(record.sId); + slaveInfoSelectedRowKeys = keys; + const slaveDataNews = slaveData.filter(item => item.sSlaveId.split('-').includes(record.sId)); + if (commonUtils.isNotEmptyArr(slaveDataNews)) { + slaveSelectedRowKeys = [slaveDataNews[0].sSlaveId]; + } + } else { + const indexKey = slaveInfoSelectedRowKeys.indexOf(record.sId); + if (indexKey === -1) { + slaveInfoSelectedRowKeys.push(record.sId); + const slaveDataNews = slaveData.filter(item => item.sSlaveId.split('-').includes(record.sId)); + if (commonUtils.isNotEmptyArr(slaveDataNews)) { + const iIndex = slaveSelectedRowKeys.findIndex(item => item === slaveDataNews[0].sSlaveId); + if (iIndex === -1) { + slaveSelectedRowKeys.push(slaveDataNews[0].sSlaveId); + } + } + } else if (indexKey !== -1) { + /* 可输入行,行内点击时 不去除selectedRowKeys */ + if (!bRowClick) { + slaveInfoSelectedRowKeys.splice(indexKey, 1); + } + const slaveDataNews = slaveData.filter(item => item.sSlaveId.split('-').includes(record.sId)); + if (commonUtils.isNotEmptyArr(slaveDataNews)) { + const sSlaveIds = slaveDataNews[0].sSlaveId.split('-'); + if (slaveInfoSelectedRowKeys.length === 0 || sSlaveIds.length === 1) { + const iIndex = slaveSelectedRowKeys.indexOf(item => slaveDataNew[0].sSlaveId === item); + slaveSelectedRowKeys.splice(iIndex, 1); + } else { + let bdel = true; + for (const sId of sSlaveIds) { + if (slaveInfoSelectedRowKeys.findIndex(item => item === sId && item !== record.sId)) { + bdel = false; + break; + } + } + if (bdel) { + const iIndex = slaveSelectedRowKeys.indexOf(item => slaveDataNew[0].sSlaveId === item); + slaveSelectedRowKeys.splice(iIndex, 1); + } + } + } + } + } + } + let machineEnabled = false; + if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) { + const currSlave = slaveData.filter(item => item.sSlaveId === slaveSelectedRowKeys[0])[0]; + const processSlave = slaveData.filter(item => item.sProcessId === currSlave.sProcessId && slaveSelectedRowKeys.includes(item.sSlaveId)); + if (processSlave.length === slaveSelectedRowKeys.length) { + machineEnabled = true; + } + } + const { sModelsId } = this.props; + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sMachineId', []); + this.props.onSaveState({ slaveSelectedRowKeys, slaveInfoSelectedRowKeys, machineEnabled }); + }; + + onCloseChangeMachine = () => { + const { masterData } = this.props; + delete masterData.tStartDate; + delete masterData.iSplitNum; + delete masterData.bSplit; + this.props.onSaveState({ isChangeMachine: false, masterData: { ...masterData, sMachineId: '', sTeamId: '' } }); + } + + onTableSelectRowChange = (name, selectedRowKeys) => { + if (name === 'slave') { + const addState = this.props.onTableSelectRowChange(name, selectedRowKeys, true); + const slaveInfoSelectedRowKeys = []; + if (commonUtils.isNotEmptyArr(selectedRowKeys)) { + selectedRowKeys.forEach((selectedRow) => { + const sIds = selectedRow.split('-'); + slaveInfoSelectedRowKeys.push(...sIds); + }); + } + addState.slaveInfoSelectedRowKeys = slaveInfoSelectedRowKeys; + this.props.onSaveState({ ...addState }); + } else { + this.props.onTableSelectRowChange(name, selectedRowKeys); + } + }; + + /** 处理选择行发生改变 */ + handleTableFilterData = (name, data, record) => { + /* 外置处理业务 */ + if (name === 'slave') { + let slaveInfoDataNew = []; + if (commonUtils.isNotEmptyArr(data)) { + slaveInfoDataNew = data.filter(item => record.sSlaveId.split('-').includes(item.sId)); + } + return slaveInfoDataNew; + } + }; + + // 根据配置解析拼接具体参数 + handleProParams = (sKey, arr) => { + const { [`${sKey}Data`]: tableData, [`${sKey}SelectedRowKeys`]: selectedRowKeys } = this.props; + const keyData = 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; + } + }; + + sortData = (tempData) => { + tempData.sort((g1, g2) => { + return g1.iOrder - g2.iOrder; + }); + return tempData; + }; + + /* 控制排序 */ + orderData = (e, name, type) => { + const { [`${name}SelectedRowKeys`]: tableselectedRowKeys, app, slavePagination: slavePaginationOld } = this.props; + let { [`${name}Data`]: currentData } = this.props; + if (name === 'slave') { + if (commonUtils.isEmptyArr(tableselectedRowKeys)) { + message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseMoveData'));/* 请勾选要移动数据 */ + return; + } + if (commonUtils.isEmptyArr(currentData)) { + message.warn(commonFunc.showMessage(app.commonConst, 'NoProcessData'));/* 请填写工序表数据 */ + return; + } + const tempNew = currentData.filter((item) => { /* 获取勾选数据集 */ + return tableselectedRowKeys.indexOf(item.sSlaveId) > -1; + }); + if (commonUtils.isEmptyArr(tempNew)) { + message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseMoveData'));/* 请选择要移动数据 */ + return; + } + const len = currentData.length; + const newLen = tempNew.length; + let num = 0.01;/* 循环增加体 */ + let targetiOrder = -1; + if (type === 1) { /* 上移 */ + const iIndex = currentData.findIndex(item => item.sSlaveId === tempNew[0].sSlaveId);/* 选中第一个节点的下标 */ + if (iIndex === 0) { + if (newLen === 1) { + message.warn(commonFunc.showMessage(app.commonConst, 'NoUp'));/* 无需上移 */ + return; + } else { + targetiOrder = 0; + } + } else { + targetiOrder = currentData[iIndex - 1].iOrder - 1; /* 目标排序号 */ + } + } else if (type === 2) { /* 下移 */ + const iIndex = currentData.findIndex(item => item.sSlaveId === tempNew[newLen - 1].sSlaveId);/* 选中最后一个节点的下标 */ + if (iIndex === len - 1) { + if (newLen === 1) { + message.warn(commonFunc.showMessage(app.commonConst, 'NoDown')); /* 无需下移 */ + return; + } else { + targetiOrder = currentData[iIndex].iOrder; + } + } else { + targetiOrder = currentData[iIndex + 1].iOrder; + } + } else if (type === 0) { /* 置顶 */ + const iIndex = currentData.findIndex(item => item.sSlaveId === tempNew[0].sSlaveId);/* 选中第一个节点的下标 */ + if (iIndex === 0) { + if (newLen === 1) { + message.warn(commonFunc.showMessage(app.commonConst, 'NoTop')); /* 无需置顶 */ + return; + } else { + targetiOrder = currentData[iIndex].iOrder; + } + } else { + targetiOrder = currentData[0].iOrder - 1; + } + } else if (type === 3) { /* 置底 */ + const iIndex = currentData.findIndex(item => item.sSlaveId === tempNew[newLen - 1].sSlaveId);/* 选中最后一个节点的下标 */ + if (iIndex === len - 1) { + if (newLen === 1) { + message.warn(commonFunc.showMessage(app.commonConst, 'NoBottom')); /* 无需置底 */ + return; + } else { + targetiOrder = currentData[iIndex].iOrder; + } + } else { + targetiOrder = currentData[len - 1].iOrder + 1; + } + } + tempNew.forEach((item) => { + const index1 = currentData.findIndex(item1 => item1.sSlaveId === item.sSlaveId); + currentData[index1] = { ...item, iOrder: targetiOrder + num, handleType: 'update' }; + num += 0.01; + }); + currentData = this.sortData(currentData); + currentData = this.orderNum(currentData); + const iIndex = currentData.findIndex(item => item.sSlaveId === tableselectedRowKeys[0]); + const slavePagination = { ...slavePaginationOld }; + slavePagination.current = Math.ceil((iIndex + 1) / commonConfig.pageSize); + this.props.onSaveState({ [`${name}Data`]: currentData, slavePagination }); + } else if (name === 'slaveInfo') { + this.props.onSaveState({ isChangeMachine: true }); + } + }; + + /* 自定义排序号 */ + orderNum = (tableData) => { + tableData.forEach((item, index) => { + item.iOrder = index + 1; + item.handleType = 'update'; + }); + return tableData; + }; + + /** 处理选择行发生改变 */ + // handleTableFilterData = (name, data, record) => { + // /* 外置处理业务 */ + // if (name === 'slave') { + // let slaveInfoDataNew = ''; + // slaveInfoDataNew = data.filter(item => record.sSlaveId.split(',').includes(item.sId)); + // return slaveInfoDataNew; + // } + // }; + /** 处理card点击事件 */ + handleTabsCallback = (child) => { + if (commonUtils.isNotEmptyArr(this.props.teamData)) { + child.cardSelectedColor = '#fff7e6'; + const iIndex = this.props.teamData.findIndex(item => item.sId === child.sId); + const teamDataNew = this.props.teamData; + teamDataNew.forEach((item, index) => { + if (index !== iIndex) { item.cardSelectedColor = ''; } + }); + } + this.props.onSaveState({ Loading: true }); + this.props.onTabsCallback(child); + }; + // renderCards = (data) => { + // let showInfo = ''; + // data.map((item) => { + // showInfo += ( + // + // + // {item.sTeamName} {item.dHour} {'30%'} + // + // + // ); + // }); + // return showInfo; + // } + render() { + const { pageLoading } = this.props; + return ( +
+ +
+ +
+
+
+ ); + } +} + +const ProductionPlanOutsideComponent = Form.create({ + mapPropsToFields(props) { + const { masterData } = props; + const obj = commonFunc.mapPropsToFields(masterData, Form); + return obj; + }, +})((props) => { + const { + form, onReturnForm, app, masterData, sModelsId, masterConfig, teamSelectedRowKeys, clearArray, slavePagination, planLoadingSate, + Loading } = props; + // console.log('props:===', props); + /* 回带表单 */ + onReturnForm(form); + // const pageFlag = sStateSelect === '0' || sStateSelect === '1' || sStateSelect === '2'; + const pagination = { + pageSize: commonConfig.pageSize, + ...slavePagination, + size: 'large', + pageSizeOptions: commonConfig.pageSizeOptions, + // showQuickJumper: true, + hideOnSinglePage: false, + showSizeChanger: true, + current: commonUtils.isEmptyObject(slavePagination) ? 1 : slavePagination.current, + }; + const width = '18px'; + const height = '18px'; + const moveUp = { + title: '上移', + width: { width }, + height: { height }, + img: 上移, + disableimg: 上移, + }; + const moveDown = { + title: '下移', + width: { width }, + height: { height }, + img: 下移, + disableimg: 下移, + }; + const moveTop = { + title: '置顶', + width: { width }, + height: { height }, + img: 置顶, + disableimg: 置顶, + }; + const moveBottom = { + title: '置底', + width: { width }, + height: { height }, + img: 置底, + disableimg: 置底, + }; + const changeMachine = { + title: '更换机台', + width: { width }, + height: { height }, + img: 更换机台, + disableimg: 更换机台, + }; + const resetSearch = { + title: '重置搜索', + width: { width }, + height: { height }, + img: 重置搜索, + disableimg: 重置搜索, + }; + const addProps = {}; + const tableProps = { + ...commonBusiness.getTableTypes('slave', props), + onTableFilterData: props.onTableFilterData, + tableProps: { + rowKey: 'sSlaveId', + pagination, + sortSelf: true, + onRow: (record) => { + return { + onClick: () => { props.onRowClick('slave', record, true); }, + onDoubleClick: () => { props.onDoubleClick('slave', record); }, + // onMouseEnter: () => { props.onRowMouseEnter('slave', record); }, + }; + }, + onChange: props.onTitleChange.bind(this, 'slave'), + }, + clearArray: props.clearArray, + }; + + const tableInfoProps = { + ...commonBusiness.getTableTypes('slaveInfo', props), + tableProps: { + rowKey: 'sId', + pagination, + planLoadingSate, + onRow: (record) => { + return { + onClick: () => { props.onRowClick('slaveInfo', record, true); }, + onDoubleClick: () => { props.onDoubleClick('slaveInfo', record); }, + // onMouseEnter: () => { props.onRowMouseEnter('slaveInfo', record); }, + }; + }, + onChange: props.onTitleChange.bind(this, 'slaveInfo'), + }, + // data: commonUtils.isNotEmptyObject(props.slaveInfoDataNew) ? props.slaveInfoDataNew : props.slaveInfoData, + }; + const gridStyle = { + width: '100%', + textAlign: 'left', + }; + const setUp = commonFunc.showMessage(app.commonConst, 'setUp');/* 上移 */ + const setDown = commonFunc.showMessage(app.commonConst, 'setDown');/* 下移 */ + const setTop = commonFunc.showMessage(app.commonConst, 'setTop');/* 置顶 */ + const setBottom = commonFunc.showMessage(app.commonConst, 'setBottom');/* 置底 */ + const setMachine = commonFunc.showMessage(app.commonConst, 'changeMachine');/* 置底 */ + const setResetSearch = commonFunc.showMessage(app.commonConst, 'setResetSearch');/* 重置搜索 */ + const resetSearchEnabled = clearArray.length > 0; + + const iMachineIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sMachineId'); + const machineShowTypeProps = { + app, + record: masterData, + name: 'master', + form: props.form, + formId: sModelsId, + getSqlDropDownData: props.getSqlDropDownData, + getSqlCondition: props.getSqlCondition, + handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, + getFloatNum: props.getFloatNum, + getDateFormat: props.getDateFormat, + onChange: props.onChange, + showConfig: iMachineIndex > -1 ? masterConfig.gdsconfigformslave[iMachineIndex] : {}, + formItemLayout: {}, + enabled: true, + dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.sMachineId, + bTable: false, + onFilterDropDownData: props.onFilterDropDownData, + }; + const iTeamIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sTeamId'); + const teamShowTypeProps = { + app, + record: masterData, + name: 'master', + form: props.form, + formId: sModelsId, + getSqlDropDownData: props.getSqlDropDownData, + getSqlCondition: props.getSqlCondition, + handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, + getFloatNum: props.getFloatNum, + getDateFormat: props.getDateFormat, + onChange: props.onChange, + showConfig: iTeamIndex > -1 ? masterConfig.gdsconfigformslave[iTeamIndex] : {}, + formItemLayout: {}, + enabled: true, + dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.sTeamId, + bTable: false, + onFilterDropDownData: props.onFilterDropDownData, + }; + const iStartIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'tStartDate'); + const startShowTypeProps = { + app, + record: masterData, + name: 'master', + form: props.form, + formId: sModelsId, + getSqlDropDownData: props.getSqlDropDownData, + getSqlCondition: props.getSqlCondition, + handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, + getFloatNum: props.getFloatNum, + getDateFormat: props.getDateFormat, + onChange: props.onChange, + showConfig: iStartIndex > -1 ? masterConfig.gdsconfigformslave[iStartIndex] : {}, + formItemLayout: {}, + enabled: true, + dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.tStartDate, + bTable: false, + onFilterDropDownData: props.onFilterDropDownData, + }; + + const bSplitIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'bSplit'); + const splitShowTypeProps = { + app, + record: masterData, + name: 'master', + form: props.form, + formId: sModelsId, + getSqlDropDownData: props.getSqlDropDownData, + getSqlCondition: props.getSqlCondition, + handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, + getFloatNum: props.getFloatNum, + getDateFormat: props.getDateFormat, + onChange: props.onChange, + showConfig: bSplitIndex > -1 ? masterConfig.gdsconfigformslave[bSplitIndex] : {}, + formItemLayout: {}, + enabled: true, + dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.bSplit, + bTable: false, + onFilterDropDownData: props.onFilterDropDownData, + }; + + const iSplitNumIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'iSplitNum'); + const splitNumShowTypeProps = { + app, + record: masterData, + name: 'master', + form: props.form, + formId: sModelsId, + getSqlDropDownData: props.getSqlDropDownData, + getSqlCondition: props.getSqlCondition, + handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, + getFloatNum: props.getFloatNum, + getDateFormat: props.getDateFormat, + onChange: props.onChange, + showConfig: iSplitNumIndex > -1 ? masterConfig.gdsconfigformslave[iSplitNumIndex] : {}, + formItemLayout: {}, + enabled: true, + dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.iSplitNum, + bTable: false, + onFilterDropDownData: props.onFilterDropDownData, + }; + + let selectedRowKey = {}; + if (commonUtils.isNotEmptyArr(teamSelectedRowKeys)) { + selectedRowKey = teamSelectedRowKeys[0]; + } + + let teamDataNum = 0; + if (commonUtils.isNotEmptyArr(props.teamData)) { + // 取得导航按钮的行数 + if (props.teamData.length % 8 === 0) { + teamDataNum = (props.teamData.length / 8) - 1; + } else { + teamDataNum = Math.floor(props.teamData.length / 8); + } + } + return ( +
+ +
+ +
+ +
+ + + + { + commonUtils.isNotEmptyArr(props.teamData) ? props.teamData.map((child) => { + const sType = commonUtils.isNotEmptyNumber(child.sType) ? child.sType.toString() : '';/* 0 - 全部单据 1-未排程 2- 已排程 */ + const cardColor = sType === '0' ? 'allCard' : sType === '1' ? 'unCard' : 'defaultCard'; + return ( + + +
+
+
{child.tStartDate}
+
{`${child.dHour}h`}
+
+
{child.sMachineName}
+
+
+ ); + }) : '' + } +
+
+
+
+ +
+ { + props.isChangeMachine ? + + { commonUtils.isEmptyObject(masterConfig) ? '' : } + { commonUtils.isEmptyObject(masterConfig) ? '' : } + { commonUtils.isEmptyObject(masterConfig) ? '' : } + { commonUtils.isEmptyObject(masterConfig) ? '' : } + { commonUtils.isNotEmptyObject(masterConfig) && commonUtils.isNotEmptyObject(masterData) && masterData.bSplit ? : '' } + + : '' + } +
+
+ ); +}); + +export default CommonBase(CommonProductionPlanOutsideEvent(ProductionPlanOutside)); diff --git a/src/routes/manufacture/workOrderPackTableTreeNew/workOrderPackTableTreeNew.js b/src/routes/manufacture/workOrderPackTableTreeNew/workOrderPackTableTreeNew.js new file mode 100644 index 0000000..e916d6c --- /dev/null +++ b/src/routes/manufacture/workOrderPackTableTreeNew/workOrderPackTableTreeNew.js @@ -0,0 +1,21 @@ + +import { connect } from "umi"; +import WorkOrderPackTableTreeNew from "../../../components/Manufacture/WorkOrderPackTableTreeNew"; + +function WorkOrderPackTableTreeNewComponent({ dispatch, app, content }) { + function removePane(changePanes, currentPane) { + dispatch({ type: "app/removePane", payload: { changePanes, currentPane } }); + } + + const commonProps = { + app, + content, + dispatch, + onRemovePane: removePane + }; + return ; +} + +export default connect(({ app, content }) => ({ app, content }))( + WorkOrderPackTableTreeNewComponent +); diff --git a/src/routes/productionPlan/productionPlan.js b/src/routes/productionPlan/productionPlan.js new file mode 100644 index 0000000..71f1ace --- /dev/null +++ b/src/routes/productionPlan/productionPlan.js @@ -0,0 +1,17 @@ +import { connect } from 'umi'; +import ProductionPlanComponent from '../../components/ProductionPlan/ProductionPlan'; + +function ProductionPlan({ dispatch, app, content }) { + const ProductionPlanBillProps = { + app, + content, + dispatch, + }; + + return ( + + ); +} + +export default connect(({ app, content }) => + ({ app, content }))(ProductionPlan); diff --git a/src/routes/productionPlan/productionPlanChangeMachineInfo.js b/src/routes/productionPlan/productionPlanChangeMachineInfo.js new file mode 100644 index 0000000..64be53a --- /dev/null +++ b/src/routes/productionPlan/productionPlanChangeMachineInfo.js @@ -0,0 +1,22 @@ +import { connect } from 'umi'; +import ProductionPlanChangeMachineInfo from '../../components/productionPlanInfo/productionPlanInfo'; + +function ProductionPlanChangeMachine({ dispatch, app, content }) { + function removePane(changePanes, currentPane) { + dispatch({ type: 'app/removePane', payload: { changePanes, currentPane } }); + } + + const productionPlanChangeMachineProps = { + app, + content, + dispatch, + onRemovePane: removePane, + }; + + return ( + + ); +} + +export default connect(({ app, content }) => + ({ app, content }))(ProductionPlanChangeMachine); diff --git a/src/routes/productionPlan/productionPlanInfo.js b/src/routes/productionPlan/productionPlanInfo.js new file mode 100644 index 0000000..fd4da94 --- /dev/null +++ b/src/routes/productionPlan/productionPlanInfo.js @@ -0,0 +1,22 @@ +import { connect } from 'umi'; +import ProductionPlanInfoComponentInfo from '../../components/productionPlanInfo/productionPlanInfo'; + +function ProductionPlanInfo({ dispatch, app, content }) { + function removePane(changePanes, currentPane) { + dispatch({ type: 'app/removePane', payload: { changePanes, currentPane } }); + } + + const productionPlanProps = { + app, + content, + dispatch, + onRemovePane: removePane, + }; + + return ( + + ); +} + +export default connect(({ app, content }) => + ({ app, content }))(ProductionPlanInfo); diff --git a/src/routes/productionPlan/productionPlanOutside.js b/src/routes/productionPlan/productionPlanOutside.js new file mode 100644 index 0000000..7a51a7d --- /dev/null +++ b/src/routes/productionPlan/productionPlanOutside.js @@ -0,0 +1,22 @@ +import { connect } from 'umi'; +import ProductionPlanOutsideComponentInfo from '../../components/productionPlanInfo/productionPlanOutside'; + +function ProductionPlanInfo({ dispatch, app, content }) { + function removePane(changePanes, currentPane) { + dispatch({ type: 'app/removePane', payload: { changePanes, currentPane } }); + } + + const productionPlanProps = { + app, + content, + dispatch, + onRemovePane: removePane, + }; + + return ( + + ); +} + +export default connect(({ app, content }) => + ({ app, content }))(ProductionPlanInfo); diff --git a/src/routes/tab/tab.js b/src/routes/tab/tab.js index f0b2a9b..056889b 100644 --- a/src/routes/tab/tab.js +++ b/src/routes/tab/tab.js @@ -38,6 +38,8 @@ import ProcessCardInfo from '@/routes/manufacture/processCard/processCardInfo'; import ProcessCardInfoPack from '@/routes/manufacture/processCardPack/processCardInfoPack'; import ProcessCardPackTableTree from '@/routes/manufacture/processCardPackTableTree/processCardPackTableTree'; import ProcessCardPackTableTreeNew from '@/routes/manufacture/processCardPackTableTreeNew/processCardPackTableTreeNew'; +import WorkOrderPackTableTreeNew from '@/routes/manufacture/workOrderPackTableTreeNew/workOrderPackTableTreeNew'; +import ProductionPlan from '@/routes/productionPlan/productionPlan';/* 生产排程 */ import styles from '@/index.less'; import { sendWebSocketMessage } from '@/components/Common/commonFunc'; import { isNotEmptyObject, isNotEmptyArr } from '@/utils/utils'; /* 通用方法 */ @@ -88,7 +90,9 @@ function Tab({ dispatch, app }) { '/indexPage/processCard' : , '/indexPage/processCardPack' : , '/indexPage/processCardPackTableTree' : , - '/indexPage/processCardPackTableTreeNew' : + '/indexPage/processCardPackTableTreeNew' : , + '/indexPage/workOrderPackTableTreeNew' : , + '/indexPage/productionPlan' : } const content = routeList[pane.route] || ;