/* eslint-disable */ /* eslint-disable function-paren-newline */ import React, { Component } from 'react'; // import '@ant-design/compatible/assets/index.css'; import { Row, Col, List, Card, Checkbox, Select, Form, Tree } from 'antd-v4'; import ShowType from '@/components/Common/CommonComponent'; import * as commonUtils from '@/utils/utils'; import splitstyles from '../SplitPaste.less'; import commonConfig from '../../../utils/config'; const { TreeNode } = Tree; import file from '@/assets/file.svg'; import file_single from '@/assets/file_single.svg'; // import * as commonServices from '../../../services/services'; const FormItem = Form.Item; class SplitPaste extends Component { constructor(props) { super(props); this.activeTree = []; } componentDidMount() { this.props.onSaveState({ masterData: {...this.props.masterData, sAllParam: undefined, sAllPartsName: undefined, sFormulaLengthSize: undefined, sFormulaWidthSize: undefined, sProductClassifyId: undefined, sProductClassifyName: undefined, }, sBackProcessClassifyData: undefined }) this.getTreeData(); // const height = document.getElementsByClassName('split-container')[0].offsetHeight; // document.getElementsByClassName('split-tree')[0].style.height = height > 50 ? `${height + 0.5}px` : 200 + 'px'; } componentDidUpdate() { // document.getElementsByClassName('split-tree')[0].style.height = 0 + 'px'; // const height = document.getElementsByClassName('split-container')[0].offsetHeight; // document.getElementsByClassName('split-tree')[0].style.height = height > 50 ? `${height + 0.5}px` : 200 + 'px'; } getTreeData = async () => { const { masterConfig, slaveFilterCondition, } = this.props; const filterTreeConfigArr = masterConfig.gdsconfigformslave.filter(item => item.bTree); if (commonUtils.isNotEmptyArr(filterTreeConfigArr)) { const filterTreeConfig = filterTreeConfigArr[0]; this.handleGetFilterTreeData(filterTreeConfig, slaveFilterCondition, 1); } } handleGetFilterTreeData = async (masterConfig, slaveFilterCondition, page, slaveOrderBy) => { const pageNum = commonUtils.isEmpty(page) ? 1 : page; await this.props.handleGetTreeDataSet({ name: 'master', configData: masterConfig, condition: { pageNum, pageSize: commonConfig.pageSize, bFilter: slaveFilterCondition, sFilterOrderBy: slaveOrderBy, }, flag: true, clearSelectData: true, }); if(this.props.treeData[0] && this.props.treeData[0].children[0]) { this.handleTreeSelect([this.props.treeData[0].children[0].sId], { node: { treeNode: this.props.treeData[0].children[0] } } ) } }; handleTreeSelect = async (e, select) => { if (e[0]) { this.activeTree = e; const selected = select.node.treeNode; this.props.onMasterChange('master', 'sProductClassifyName', { sAllParam: undefined, sAllPartsName: selected.sAllPartsName, sFormulaLengthSize: undefined, sFormulaWidthSize: undefined, sProductClassifyId: selected.sId, sProductClassifyName: selected.sName, }); } } handleToggle = () => { this.props.onToggle(); }; handleViewClick = (name, sName, record) => { this.props.onViewClick(name, sName, record); this.props.onSaveState({ fastOrderModalVisible: false }); }; renderTreeNodes = (data) => { return data.map((item) => { if (item.children && item.children.length > 0) { return ( {this.renderTreeNodes(item.children)} ); } return (} />); }); }; render() { const { masterConfig, enabled, sBackProcessClassifyData, checkProcessClassifyData, sModelsId, } = this.props; let { masterData } = this.props; masterData = masterData === undefined ? {} : masterData; const expand = true; const { getFieldDecorator } = this.props.form; const { sAllPartsName } = masterData; let allPartsName = []; if (sAllPartsName !== undefined) { allPartsName = sAllPartsName.split(','); } const newConfig = {}; if (commonUtils.isNotEmptyObject(masterConfig) && masterConfig.gdsconfigformslave.length > 0) { const filterConfig = masterConfig.gdsconfigformslave.filter(item => (item.sName.indexOf('dSumPQty') > -1 || item.sName.indexOf('sMaterialsName') > -1 || item.sName.indexOf('iPrintModePo') > -1 || item.sName.indexOf('iPositiveColor') > -1)); filterConfig.forEach((childNew) => { const child = { ...childNew }; child.bVisible = true; if (child.sName.indexOf('dSumPQty') > -1) { child.placeholder = 'P数'; } else if (child.sName.indexOf('sMaterialsName') > -1) { child.placeholder = '选择材料'; } else if (child.sName.indexOf('iPrintModePo') > -1) { child.placeholder = '选择单双面'; } else if (child.sName.indexOf('iPositiveColor') > -1) { child.placeholder = '印刷颜色'; } let enabledNew = (enabled && !child.bReadonly && !child.specialControl); if (child.iTag === 1) { enabledNew = false; } else if (child.iTag === 3) { enabledNew = true; } const sMemo = child.sName.toLowerCase().endsWith('memo'); const formItemLayout = { labelCol: { span: 2 }, wrapperCol: { span: 18 } }; const showTypeProps = { form: this.props.form, getSqlDropDownData: this.props.getSqlDropDownData, getSqlCondition: this.props.getSqlCondition, handleSqlDropDownNewRecord: this.props.handleSqlDropDownNewRecord, getFloatNum: this.props.getFloatNum, onChange: this.props.onMasterChange, showConfig: child, formItemLayout: sMemo ? formItemLayout : {}, textArea: sMemo, enabled: enabledNew, dataValue: masterData[child.sName], bTable: false, }; newConfig[child.sName] = showTypeProps; }); } /* 主表根据产品分类增加参数1,参数2,参数3,参数4,展开尺寸 */ const modalFilterConfig = masterConfig.gdsconfigformslave.filter(item => (item.sName.indexOf('dProductQty') > -1 || item.sName.indexOf('sProductName') > -1 || item.sName.indexOf('sCustomerName') > -1 || item.sName.indexOf('sProductClassifyName') > -1 || item.sName.indexOf('sProductStyle') > -1)); const formItemLayout = { labelCol: { span: 2 }, wrapperCol: { span: 18 } }; const fullFormItemLayout = { labelCol: { span: 0 }, wrapperCol: { span: 24, offset: 0 } }; const halfFormItemLayout = { labelCol: { span: 0 }, wrapperCol: { span: 24, offset: 0 } }; return ( { modalFilterConfig.map((child, index) => { const sMemo = child.sName.toLowerCase().endsWith('memo'); const iOrder = sMemo ? 100 : child.iOrder > 100 ? 100 : child.iOrder; /* 排序 */ let enabledNew = (enabled && !child.bReadonly && !child.specialControl); if (child.iTag === 1) { enabledNew = false; } else if (child.iTag === 3) { enabledNew = true; } const showTypeProps = { name: 'master', form: this.props.form, formId: sModelsId, record: masterData, getSqlDropDownData: this.props.getSqlDropDownData, getSqlCondition: this.props.getSqlCondition, handleSqlDropDownNewRecord: this.props.handleSqlDropDownNewRecord, getFloatNum: this.props.getFloatNum, getDateFormat: this.props.getDateFormat, onChange: this.props.onMasterChange, onViewClick: this.handleViewClick, showConfig: child, formItemLayout: sMemo ? formItemLayout : {}, textArea: sMemo, enabled: enabledNew, dataValue: masterData[child.sName], bTable: false, itemLabel: child.sName === 'sType' ? 'hide' : null, onFilterDropDownData: this.props.onFilterDropDownData, }; return ( ); }) } 产品分类 } onSelect={this.handleTreeSelect} selectedKeys={this.activeTree} defaultExpandAll={true} > {this.renderTreeNodes(this.props.treeData)} {allPartsName.length > 0 && Object.keys(newConfig).length > 4 ? ( { i === 0 ? 部件信息 : null } {sPartsName} { newConfig[`dSumPQty${sPartsName}`] && } { newConfig[`sMaterialsName${sPartsName}`] && } { i === 0 ? 印刷颜色 : null } { newConfig[`iPrintModePo${sPartsName}`] && } { newConfig[`iPositiveColor${sPartsName}`] && } { i === 0 ? 工序 : null } {sBackProcessClassifyData !== undefined && sBackProcessClassifyData !== '' ? (item.sType !== '3' && (item.sPartsName === sPartsName || item.sPartsName === '')))} size="small" renderItem={item => ( (card.sId === item.sId && card.sPartsName === sPartsName)).length > 0} onChange={(e) => { this.props.handleProcessChange(e, item, sPartsName); }} title={item} > {item.sName} {getFieldDecorator(`${item.sId + sPartsName}`, { })( option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} onSelect={this.props.handleSelectChangeProcess.bind(this, `${item.sId + sPartsName}:sId,${item.sId + item.sName + sPartsName}:sProcessName,${item.sId + item.sType + sPartsName}:sType`)} >{this.props.handleA(item.sId)} )} )} /> : ''} )} /> : ''} {sBackProcessClassifyData !== undefined && sBackProcessClassifyData !== '' ? 成品工序 : null } {sBackProcessClassifyData !== undefined && sBackProcessClassifyData !== '' ? (item.sType === '3'))} size="small" renderItem={item => ( (card.sId === item.sId)).length > 0} onChange={(e) => { this.props.handleProcessChange(e, item, ''); }} title={item} > {item.sName} {getFieldDecorator(`${item.sId}`, { })( option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} onSelect={this.props.handleSelectChangeProcess.bind(this, `${item.sId}:sId,${item.sId + item.sName}:sProcessName,${item.sId + item.sType}:sType`)} >{this.props.handleA(item.sId)} )} )} /> : ''} ); } } export default SplitPaste;