/* 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-v4'; 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 '../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);