/* eslint-disable */
/* eslint-disable prefer-destructuring,no-loop-func */
/**
* Created by mar105 on 2019-01-04.
*/
import React, { Component } from 'react';
import moment from 'moment';
import { Form } from '@ant-design/compatible';
// import '@ant-design/compatible/assets/index.css';
import { Modal, Layout, Spin, Avatar, Select, message, Button, Slider, Tabs, Table, Checkbox, Row, Col, } from 'antd-v4';
import AddIcon from '../../../assets/add.svg';
import DisableAddIcon from '../../../assets/disableadd.svg';
import DelIcon from '../../../assets/delete.svg';
import DisableDelIcon from '../../../assets/disabledelete.svg';
import CopyIcon from '../../../assets/copy.svg';
import CopyAllIcon from '../../../assets/copyall.svg';
import DisableCopyIcon from '../../../assets/disablecopy.svg';
import DisableCopyAllIcon from '../../../assets/disablecopyall.svg';
import MateriallIcon from '../../../assets/material.svg';
import DisableMateriallIcon from '../../../assets/disablematerial.svg';
import ProcessIcon from '../../../assets/process.svg';
import DisableProcessIcon from '../../../assets/disableprocess.svg';
import CommonSales from '../../Common/CommonBillEvent'; /* 继承销售模块业务功能 */
import * as commonFunc from '../../Common/commonFunc'; /* 通用单据方法 */ /* 通用单据方法 */
import Toolbar from '../../Common/ToolBar/ToolBarNew';
import StaticEditTable from '../../Common/CommonTable'; /* 可编辑表格 */
import styles from '../../../index.less';
import selfstyles from '../index.less';
import CommonView from '../../Common/CommonView';
import SplitPaste from '../Quotation/SplitPasteQuotation';
import CommonBase from '../../Common/CommonBase'; /* 获取配置及数据 */
import * as commonUtils from '../../../utils/utils'; /* 通用方法 */
import * as commonBusiness from '../../Common/commonBusiness'; /* 单据业务功能 */
import commonConfig from '../../../utils/config';
import * as commonServices from '../../../services/services'; /* 服务类 */
import CommonListSelect from '../../Common/CommonListSelect'; /* 选择界面 */
import CommonListSelectFlex from '../../Common/CommonListSelectFlex';/* 可编辑的选择界面 */
import CommonListSelectTree from '../../Common/CommonListSelectTree';/* 树形选择界面 */
import ProcessUp from '../../../assets/processUp.svg';
import ProcessDown from '../../../assets/processDown.svg';
import DisableProcessUp from '../../../assets/disableprocessUp.svg';
import DisableProcessDown from '../../../assets/disableprocessDown.svg';
import ProcessTop from '../../../assets/processTop.svg';
import DisableProcessTop from '../../../assets/disableprocessTop.svg';
import ProcessBottom from '../../../assets/processBottom.svg';
import DisableProcessBottom from '../../../assets/disableprocessBottom.svg';
import SlavesInfo from '../../Common/SlavesInfo';
import AntdDraggableModal from '../../Common/AntdDraggableModal';
import StaticEditTree from '../../Common/Tree/StaticTree';
import Close from '../../../assets/closeleft.svg';
import AddChildIcon from '../../../assets/addChild.svg';
import DisableAddChildIcon from '../../../assets/disableaddChild.svg';
import AntdDraggableDiv from '../../Common/AntdDraggableDiv';
import Eject from '../../../assets/ejectleft.svg';
import ShowType from '../../Common/CommonComponent';
import ContextMenuModal from '../../Common/ContextMenuModal';
import CommonListSelectProductProcess from '../../Common/CommonListSelectAssignment';
import CommonListSelectProductMaterial from '../../Common/CommonListSelectProductMaterial';
import SvgIcon from "../../SvgIcon";
const { Header, Content, Sider } = Layout;
const { Option } = Select;
const { confirm } = Modal;
const { TabPane } = Tabs;
const isQianCai = false;
class QuotationPack extends Component {
constructor(props) {
super(props);
this.state = {
currentTab: 1,
};
}
async componentWillReceiveProps(nextProps) {
let {
controlColumn, materialsColumn, processColumn, manyqtysColumn, colorColumn, packColumn,
} = nextProps;
const { formData, currentId } = nextProps;
if (commonUtils.isEmptyArr(controlColumn) && formData.length > 0) {
const sId = currentId || nextProps.masterData?.sId || '';
/* 数据Id */
const masterConfig = formData.filter(item => !item.bGrd)[0];
/* bGrd代表是否是表格 */
const slaveConfig = formData.filter(item => item.bGrd && item.sTbName !== 'sysbillcheckresult')[0];
const slaveColumn = commonFunc.getHeaderConfig(slaveConfig);
const checkConfig = formData.filter(item => item.bGrd && item.sTbName === 'sysbillcheckresult')[0];
const checkColumn = commonFunc.getHeaderConfig(checkConfig);
const controlConfig = formData.filter(item => item.sTbName.toUpperCase() === 'QuoQuotationControl'.toUpperCase())[0];
controlColumn = commonFunc.getHeaderConfig(controlConfig, controlColumn);
const materialsConfig = formData.filter(item => item.sTbName.toUpperCase() === 'QuoQuotationMaterials'.toUpperCase())[0];
materialsColumn = commonFunc.getHeaderConfig(materialsConfig, materialsColumn);
const finishedMaterialsConfig = formData.filter(item => item.sTbName.toUpperCase() === 'QuoQuotationMaterials'.toUpperCase() && item.showName === '成品材料')[0];
const finishedMaterialsColumn = finishedMaterialsConfig ? commonFunc.getHeaderConfig(finishedMaterialsConfig) : false;
const processConfig = formData.filter(item => item.sTbName.toUpperCase() === 'QuoQuotationProcess'.toUpperCase())[0];
const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === 'sMachineId');
const finishedProcessConfig = formData.filter(item => item.sTbName.toUpperCase() === 'QuoQuotationProcess'.toUpperCase() && item.showName === '成品工序')[0];
const finishedProcessColumn = finishedProcessConfig ? commonFunc.getHeaderConfig(finishedProcessConfig) : false;
if (iIndex > -1) {
processConfig.gdsconfigformslave[iIndex].bReGetDropDown = true;
}
processColumn = commonFunc.getHeaderConfig(processConfig, processColumn);
/* 合版信息表 */
const packConfig = formData.filter(item => item.sTbName.toUpperCase() === 'quoquotationcontrolcombine'.toUpperCase())[0];
const slaveChooseConfig = slaveConfig.gdsconfigformslave.filter(item => (item.sName === 'sCustomerName'
|| item.sName === 'sProductId'
|| item.sName === 'sCustomerId'
|| item.sName === 'sProductNo'
|| item.sName === 'sProductName'
|| item.sName === 'dProductQty'
|| item.sName === 'sProductStyle'
|| item.sName === 'sProductUnit')); /* 拼接从表配置,客户名称 ,产品名称,生产数 */
const salveChooseConfigFilter = [];
if (commonUtils.isNotEmptyArr(slaveChooseConfig)) {
slaveChooseConfig.forEach((item) => {
const iIndex = packConfig.gdsconfigformslave.findIndex(itemNew => itemNew.sName === item.sName);
if (iIndex === -1) {
const itemNew = Object.assign({}, item);
itemNew.bNotEmpty = false;
salveChooseConfigFilter.push(itemNew);
}
});
}
/* 拼接排序 */
if (commonUtils.isNotEmptyArr(salveChooseConfigFilter)) {
let packFilter = packConfig.gdsconfigformslave.filter(item => item.sName === 'iOrder');
packFilter = packFilter.concat(salveChooseConfigFilter);
const packFilterOther = packConfig.gdsconfigformslave.filter(item => item.sName !== 'iOrder');
packFilter = packFilter.concat(packFilterOther);
packConfig.gdsconfigformslave = packFilter;
}
packColumn = commonFunc.getHeaderConfig(packConfig, packColumn);
const manyqtysConfig = formData.filter(item => item.sTbName.toUpperCase() === 'QuoQuotationManyQtys'.toUpperCase())[0];
manyqtysColumn = commonFunc.getHeaderConfig(manyqtysConfig, manyqtysColumn);
let colorConfigGrdVisible;
const colorConfigTrue = formData.filter(item => item.sTbName.toUpperCase() === 'quoquotationparam'.toUpperCase())[0];
if (commonUtils.isNotEmptyObject(colorConfigTrue)) {
colorConfigGrdVisible = colorConfigTrue.bGrdVisible;
if (colorConfigGrdVisible) {
colorColumn = commonFunc.getHeaderConfig(colorConfigTrue, colorColumn);
}
}
let addState = {};
const colorConfig = colorConfigGrdVisible ? colorConfigTrue : '';
if (sId === '') {
const config = {};
config.masterConfig = masterConfig;
config.slaveConfig = slaveConfig;
config.controlConfig = controlConfig;
config.materialsConfig = materialsConfig;
config.processConfig = processConfig;
config.manyqtysConfig = manyqtysConfig;
config.packConfig = packConfig;
config.colorConfig = colorConfig;
addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
} else {
this.props.onGetData(masterConfig, slaveConfig, checkConfig);
this.handleGetData(controlConfig, materialsConfig, processConfig, manyqtysConfig, colorConfig, packConfig);
}
this.props.onSaveState({
masterConfig,
slaveConfig,
slaveColumn,
checkConfig,
checkColumn,
sId,
pageLoading: false,
controlConfig,
controlColumn,
materialsConfig,
materialsColumn,
finishedMaterialsColumn,
finishedMaterialsConfig,
finishedProcessColumn,
finishedProcessConfig,
processConfig,
processColumn,
manyqtysConfig,
manyqtysColumn,
colorConfig,
colorColumn,
packConfig,
packColumn,
...addState,
colorConfigGrdVisible,
});
}
if (nextProps.treeData && this.props.treeData) {
if ((nextProps.treeData.length > this.props.treeData.length) && (nextProps.treeData[nextProps.treeData.length - 1].key !== this.props.treeData[this.props.treeData.length - 1].key)) {
this.handleTreeScrollToBottom();
}
}
}
shouldComponentUpdate(nextProps) {
const { controlColumn, slaveConfig } = nextProps;
return typeof slaveConfig === 'object' && Object.keys(slaveConfig).length > 0 && commonUtils.isNotEmptyArr(controlColumn);
}
onChange1 = (checkedValues) => {
this.props.onSaveState({
dataPersonArray: checkedValues,
});
};
/** 行选择s */
// onRowClick = (name, record) => {
// if (name === 'control') {
// this.props.onTableSelectRowChange(name, [record.sId]);
// }
// };
//
// onRowMouseEnter = (name, record) => {
// if (this.props.enabled && name === 'control') {
// this.props.onTableSelectRowChange(name, [record.sId]);
// }
// }
//
// onDoubleClick = (name, record) => {
// if (this.props.onDoubleClick !== undefined) {
// this.props.onDoubleClick(record);
// }
// };
getMenuStatus = (menu) => {
if (menu.sControlName === 'BtnCalculation' || menu.sControlName === 'BtnFastOrder' || menu.sControlName === 'BtnChooseProcess' || menu.sControlName === 'BtnChooseMaterials') {
return !this.props.enabled;
}
};
handleEject = () => {
const { currentPane, panes } = this.props.app;
if (commonUtils.isNotEmptyArr(panes) && commonUtils.isNotEmptyObject(currentPane)) {
// const index = panes.indexOf(currentPane);
const index = panes.findIndex(item => item.formId === currentPane.formId && item.key === currentPane.key && item.notCurrentPane === currentPane.notCurrentPane && item.route === currentPane.route && item.title === currentPane.title && item.sModelsType === currentPane.sModelsType && item.sProcName === currentPane.sProcName);
/* 当前页签 */
let currentTab = document.getElementById('navTabWrap').children[index];
if (commonUtils.isEmpty(currentTab)) {
const oChildren = document.getElementById('navTabWrap').getElementsByClassName('ant-tabs-content')[0].children;
for (const child of oChildren) {
if (child.nodeName === 'DIV' && index !== undefined && child.getAttribute('id') === `navTabWrap-panel-${panes[index].key}`) {
currentTab = child;
}
}
}
// const currentTab = document.getElementById('tabs').getElementsByClassName('ant-tabs-content-no-animated')[0].children[index];
if (!commonUtils.isEmpty(currentTab)) {
const filterTreeArr = currentTab.getElementsByClassName('xly-filter-tree');/* 获取当前页签下的树组件 */
if (commonUtils.isNotEmptyArr(filterTreeArr)) {
const filterTree = filterTreeArr[0];
if (filterTree.style.display === 'block') {
filterTree.style.display = 'none';
} else {
filterTree.style.display = 'block';
}
}
}
}
};
handleTreeScrollToBottom = () => {
const { currentPane, panes } = this.props.app;
if (commonUtils.isNotEmptyArr(panes) && commonUtils.isNotEmptyObject(currentPane)) {
const index = panes.findIndex(item => item.formId === currentPane.formId && item.key === currentPane.key && item.notCurrentPane === currentPane.notCurrentPane && item.route === currentPane.route && item.title === currentPane.title && item.sModelsType === currentPane.sModelsType && item.sProcName === currentPane.sProcName);
let currentTab = document.getElementById('navTabWrap').children[index];
if (commonUtils.isEmpty(currentTab)) {
const oChildren = document.getElementById('navTabWrap').getElementsByClassName('ant-tabs-content')[0].children;
for (const child of oChildren) {
if (child.nodeName === 'DIV' && index !== undefined && child.getAttribute('id') === `navTabWrap-panel-${panes[index].key}`) {
currentTab = child;
}
}
}
const treeNode = currentTab.getElementsByClassName('xly-control-tree')[0];
if (treeNode) {
setTimeout(() => {
treeNode.scrollTop = treeNode.scrollHeight;
}, 0);
}
}
};
/* 获取表数据 */
handleGetData = async (controlConfig, materialsConfig, processConfig, manyqtysConfig, colorConfig, packConfig, extraState = {}) => {
const { currentId, slaveData } = this.props; /* 当前页签数据 */
const sId = currentId || this.props.masterData?.sId || ''; /* 数据Id */
const addStateControl = await this.props.handleGetDataSet({
name: 'control', configData: controlConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
});
const { controlData, controlSelectedRowKeys } = addStateControl; /* 同步树选中节点与部件选中节点 */
const treeState = this.handleGetControlTreeData(controlData, true);
const addStateMaterials = await this.props.handleGetDataSet({
name: 'materials', configData: materialsConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
});
const addStateProcess = await this.props.handleGetDataSet({
name: 'process', configData: processConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
});
if (addStateProcess) {
if (Array.isArray(addStateProcess.processData)) {
// eslint-disable-next-line array-callback-return
addStateProcess.processData.map((itemProcess) => {
if (commonUtils.isNotEmptyObject(itemProcess.sProcessParam)) {
itemProcess.sProcessParamStr = '';
// eslint-disable-next-line no-plusplus
for (let i = 1; i < 7; i++) {
const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`);
if (iIndex > -1 && !commonUtils.isEmpty(itemProcess[`sParam${i.toString()}`])) {
itemProcess.sProcessParamStr += `${itemProcess[`sParam${i.toString()}`]}:${itemProcess[`sParamValue${i.toString()}`]},`;
}
}
if (itemProcess.sProcessParamStr === '') {
itemProcess.sProcessParamStr = '工艺参数';
}
}
});
addStateProcess.processData = this.sortData(addStateControl.controlData, addStateProcess.processData);
}
// addStateProcess.slaveSelectedRowKeys = commonUtils.isEmptyArr(addStateControl.controlData) ? [] : [addStateControl.controlData[0].sSlaveId];
addStateProcess.controlSelectedRowKeys = commonUtils.isEmptyArr(addStateControl.controlData) ? [] : [addStateControl.controlData[0].sId];
}
const addStatePack = await this.props.handleGetDataSet({
name: 'pack', configData: packConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
});
this.props.handleGetDataSet({
name: 'manyqtys', configData: manyqtysConfig, condition: { sSqlCondition: { sParentId: sId } },
});
let addStateColor = {};
if (colorConfig) {
addStateColor = await this.props.handleGetDataSet({
name: 'color', configData: colorConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
});
}
/* 合版表合并产品信息 */
if (commonUtils.isNotEmptyArr(slaveData)) {
const { packData } = addStatePack;
slaveData.forEach((itemSlave) => {
const packDataFilter = packData.filter(itemNew => itemNew.sSlaveId === itemSlave.sId);
if (commonUtils.isNotEmptyArr(packDataFilter)) {
packDataFilter.forEach((itemPack) => {
const iIndex = packData.findIndex(child => child.sId === itemPack.sId);
if (iIndex > -1) {
const packRowAdd = this.handlePackDataAdd(itemSlave);
if (commonUtils.isNotEmptyObject(packRowAdd)) {
packData[iIndex] = { ...packData[iIndex], ...packRowAdd };
}
}
});
}
});
addStatePack.packData = packData;
}
this.props.onSaveState({
pageLoading: false, ...addStateControl,...addStateMaterials, ...addStateProcess, ...addStateColor, ...addStatePack, ...treeState, treeSelectedKeys: controlSelectedRowKeys, ...extraState,
});
};
/** 获取部件树 */
handleGetControlTreeData= (controlData, isWait) => {
/* 生成部件树结构 */
let treeData = [];
const expandedKeys = [];
let { treeSelectedKeys } = this.props;
if (commonUtils.isNotEmptyArr(controlData)) {
const rootData = commonUtils.isNotEmptyArr(controlData) ? controlData.filter(item => commonUtils.isEmpty(item.sControlParentId)) : []; /* 找到所有一级树结构 */
rootData.forEach((item) => {
const treeDataRow = {};
const { sId, sPartsName } = item;
treeDataRow.key = sId;
treeDataRow.showName = sPartsName;
treeDataRow.sAllId = item.sAllId;
const children = this.handleGetControlTreeChildData(sId, controlData);
let sChildren = '1'; /* 树形结构最后一个节点设置为1 */
if (commonUtils.isNotEmptyArr(children)) {
sChildren = '0'; /* 树形结构其他节点设置为0 */
}
treeDataRow.sChildren = sChildren;
/* 添加sChildren,sAllId 值 */
const iIndex = controlData.findIndex(item => item.sId === sId);
if (iIndex > -1) {
// controlData[iIndex].sAllId = sAllId;
controlData[iIndex].sChildren = sChildren;
}
treeDataRow.children = commonUtils.isNotEmptyArr(children) ? children : [];
treeData.push(treeDataRow);
});
if (commonUtils.isEmptyArr(treeSelectedKeys)) {
expandedKeys.push(treeData[treeData.length - 1].key);
}
} else {
treeSelectedKeys = [];
treeData = [];
}
if (isWait) {
return { treeData };
} else {
this.props.onSaveState({
treeData,
// expandedKeys,
});
}
};
/** 获取子节点数据 */
handleGetControlTreeChildData= (sParentId, controlData) => {
if (commonUtils.isNotEmptyObject(sParentId) && commonUtils.isNotEmptyArr(controlData)) {
const childTree = commonUtils.isNotEmptyArr(controlData) ? controlData.filter(item => item.sControlParentId === sParentId) : [];
const children = [];
if (commonUtils.isNotEmptyArr(childTree)) {
childTree.forEach((child) => {
const { sId, sPartsName } = child;
const treeDataRow = {};
treeDataRow.key = sId;
treeDataRow.showName = sPartsName;
treeDataRow.parentKey = sParentId;
treeDataRow.sAllId = child.sAllId;
const data = this.handleGetControlTreeChildData(sId, controlData);
let sChildren = '1'; /* 最后一个节点设置为1 */
if (commonUtils.isNotEmptyArr(data)) {
sChildren = '0';
}
treeDataRow.sChildren = sChildren;
/* 添加sChildren,sAllId 值 */
const iIndex = controlData.findIndex(item => item.sId === sId);
if (iIndex > -1) {
// controlData[iIndex].sAllId = sAllId;
controlData[iIndex].sChildren = sChildren;
}
treeDataRow.children = commonUtils.isNotEmptyArr(data) ? data : [];
children.push(treeDataRow);
});
}
return children;
}
};
/** 根据key查找树节点并改变属性 */
handleSearchNodes= (key, data, showNameNew) => {
if (commonUtils.isNotEmptyObject(showNameNew)) {
data.forEach((item) => {
if (item.key === key) {
item.showName = showNameNew;
} else if (commonUtils.isNotEmptyArr(item.children)) {
this.handleSearchNodes(key, item.children, showNameNew);
}
});
}
};
handleBackProcessData = async (config, isWait) => {
const { token } = this.props.app;
const { sModelsId, sBackProcessData } = this.props;
const masterConfig = commonUtils.isEmpty(config) ? this.props.masterConfig : config.masterConfig;
if (sBackProcessData === undefined || sBackProcessData === '') {
const sBackProcess = masterConfig.gdsconfigformslave.filter(item => item.sName === 'sBackProcess')[0];
const url = `${commonConfig.server_host}business/getSelectDataBysControlId/${sBackProcess.sId}?sModelsId=${sModelsId}`;
const values = { sKeyUpFilterName: '', sSqlCondition: {} };
const masterReturn = (await commonServices.postValueService(token, values, url)).data;
if (masterReturn.code === 1) {
const sBackProcessDataValue = masterReturn.dataset.rows;
if (isWait) {
return { sBackProcessData: sBackProcessDataValue };
} else {
this.props.onSaveState({ sBackProcessData: sBackProcessDataValue });
}
} else {
message.warn(masterReturn.msg);
}
}
};
handleForm = (form) => {
this.form = form;
};
/* 非列表联动下拉 */
handleMasterChange = async (name, sFieldName, changeValue, sId, dropDownData, config, isWait) => {
/* 数据集类型,对象型为Map 数组型为List */
const {
sModelsId, app,
} = this.props;
const masterData = commonUtils.isEmpty(config) ? this.props.masterData : config.masterData;
const masterConfig = commonUtils.isEmpty(config) ? this.props.masterConfig : config.masterConfig;
const { token } = app;
let { sBackProcessClassifyData } = this.props;
let { sAllPartsName } = masterData;
let backProcessData;
if (sFieldName === 'sProductClassifyId' || sFieldName === 'sProductId' || sFieldName === 'sProductClassifyName' || sFieldName === 'sProductName') {
backProcessData = await this.handleBackProcessData(config, true);
let allPartsName = [];
if (sAllPartsName !== undefined) {
allPartsName = sAllPartsName.split(',');
}
if (allPartsName.length > 0 && masterConfig.gdsconfigformslave.filter(item => item.sName === `sMaterialsName${allPartsName[0]}`).length > 0 &&
(sBackProcessClassifyData !== undefined && sBackProcessClassifyData !== '' && sBackProcessClassifyData.length > 0 &&
masterConfig.gdsconfigformslave.filter(item => item.sName === `${sBackProcessClassifyData[0].sId}${allPartsName[0]}`).length > 0)) {
let iIndex;
allPartsName.forEach((sPartsName) => {
iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === `dSumPQty${sPartsName}`);
if (iIndex > -1) {
masterConfig.gdsconfigformslave.splice(iIndex, 1);
}
iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === `sMaterialsName${sPartsName}`);
if (iIndex > -1) {
masterConfig.gdsconfigformslave.splice(iIndex, 1);
}
iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === `iPrintModePo${sPartsName}`);
if (iIndex > -1) {
masterConfig.gdsconfigformslave.splice(iIndex, 1);
}
iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === `iPositiveColor${sPartsName}`);
if (iIndex > -1) {
masterConfig.gdsconfigformslave.splice(iIndex, 1);
}
if (sBackProcessClassifyData !== '') {
sBackProcessClassifyData.filter(processClassify => processClassify.sType !== '3').forEach((processClassify) => {
iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === processClassify.sId + sPartsName);
if (iIndex > -1) {
masterConfig.gdsconfigformslave.splice(iIndex, 1);
}
});
}
});
if (sBackProcessClassifyData !== '') {
sBackProcessClassifyData.filter(processClassify => processClassify.sType === '3').forEach((processClassify) => {
iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === processClassify.sId);
if (iIndex > -1) {
masterConfig.gdsconfigformslave.splice(iIndex, 1);
}
});
}
}
let sProductClassifyId;
if (changeValue !== null && changeValue !== undefined) {
sProductClassifyId = commonUtils.isEmpty(changeValue.sProductClassifyId) ? masterData.sProductClassifyId : changeValue.sProductClassifyId;
sAllPartsName = commonUtils.isEmpty(changeValue.sAllPartsName) ? masterData.sAllPartsName : changeValue.sAllPartsName;
} else {
sProductClassifyId = masterData.sProductClassifyId;
}
if (commonUtils.isEmpty(sProductClassifyId)) {
return;
}
const sBackProcessClassify = masterConfig.gdsconfigformslave.filter(item => (item.sName.toLowerCase() === 'sbackprocessclassify'))[0];
const values = { sKeyUpFilterName: '', sSqlCondition: { sProductClassifyId } };
const dataReturn = (await commonServices.postValueService(token, values, `${commonConfig.server_host}business/getSelectDataBysControlId/${sBackProcessClassify.sId}?sModelsId=${sModelsId}`)).data;
/* 接收返回值 */
/* 成功的话刷新页面(同步主表和从表数据),不成功就弹出错误提示 */
if (dataReturn.code === 1) { /* 成功 */
const { rows } = dataReturn.dataset;
allPartsName = [];
if (sAllPartsName !== undefined) {
allPartsName = sAllPartsName.split(',');
}
sBackProcessClassifyData = rows;
if (allPartsName.length > 0 && masterConfig.gdsconfigformslave.filter(item => item.sName === `sMaterialsName${allPartsName[0]}`).length <= 0 &&
sBackProcessClassifyData !== undefined && sBackProcessClassifyData !== '' && sBackProcessClassifyData.length > 0 &&
masterConfig.gdsconfigformslave.filter(item => item.sName === `${sBackProcessClassifyData[0].sId}${allPartsName[0]}`).length <= 0) {
const sumPQtyConfig = masterConfig.gdsconfigformslave.filter(item => item.sName === 'dSumPQty').length > 0 ? masterConfig.gdsconfigformslave.filter(item => item.sName === 'dSumPQty')[0] : [];
const materialsNameConfig = masterConfig.gdsconfigformslave.filter(item => item.sName === 'sMaterialsName').length > 0 ? masterConfig.gdsconfigformslave.filter(item => item.sName === 'sMaterialsName')[0] : [];
const printModePoConfig = masterConfig.gdsconfigformslave.filter(item => item.sName === 'iPrintModePo').length > 0 ? masterConfig.gdsconfigformslave.filter(item => item.sName === 'iPrintModePo')[0] : [];
const positiveColorConfig = masterConfig.gdsconfigformslave.filter(item => item.sName === 'iPositiveColor').length > 0 ? masterConfig.gdsconfigformslave.filter(item => item.sName === 'iPositiveColor')[0] : [];
const processNameConfig = masterConfig.gdsconfigformslave.filter(item => item.sName === 'sProcessName').length > 0 ? masterConfig.gdsconfigformslave.filter(item => item.sName === 'sProcessName')[0] : [];
let ConfigNew;
allPartsName.forEach((item) => {
ConfigNew = { ...sumPQtyConfig };
ConfigNew.sName = `dSumPQty${item}`;
ConfigNew.sAssignField = commonUtils.isEmpty(ConfigNew.sAssignField) ? '' : ConfigNew.sAssignField.replace(/:/g, `${item}:`);
masterConfig.gdsconfigformslave.push(ConfigNew);
ConfigNew = { ...materialsNameConfig };
ConfigNew.sName = `sMaterialsName${item}`;
ConfigNew.sAssignField = commonUtils.isEmpty(ConfigNew.sAssignField) ? '' : ConfigNew.sAssignField.replace(/:/g, `${item}:`);
masterConfig.gdsconfigformslave.push(ConfigNew);
ConfigNew = { ...printModePoConfig };
ConfigNew.sName = `iPrintModePo${item}`;
ConfigNew.sAssignField = commonUtils.isEmpty(ConfigNew.sAssignField) ? '' : ConfigNew.sAssignField.replace(/:/g, `${item}:`);
masterConfig.gdsconfigformslave.push(ConfigNew);
ConfigNew = { ...positiveColorConfig };
ConfigNew.sName = `iPositiveColor${item}`;
ConfigNew.sAssignField = commonUtils.isEmpty(ConfigNew.sAssignField) ? '' : ConfigNew.sAssignField.replace(/:/g, `${item}:`);
masterConfig.gdsconfigformslave.push(ConfigNew);
if (sBackProcessClassifyData !== '') {
sBackProcessClassifyData.filter(processClassify => processClassify.sType !== '3').forEach((processClassify) => {
ConfigNew = { ...processNameConfig };
ConfigNew.sName = processClassify.sId + item;
masterConfig.gdsconfigformslave.push(ConfigNew);
});
}
});
if (sBackProcessClassifyData !== '') {
sBackProcessClassifyData.filter(processClassify => processClassify.sType === '3').forEach((processClassify) => {
ConfigNew = { ...processNameConfig };
ConfigNew.sName = processClassify.sId;
masterConfig.gdsconfigformslave.push(ConfigNew);
});
}
}
const returnChange = await this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, true, masterData);
const masterDataDefault = commonFunc.getDefaultData(masterConfig, {});
returnChange.masterData = { ...masterDataDefault, ...returnChange.masterData };
if (isWait) {
return {
...returnChange, sBackProcessClassifyData, masterConfig, ...backProcessData,
};
} else {
this.props.onSaveState({
...returnChange, sBackProcessClassifyData, masterConfig, ...backProcessData,
});
}
} else { /* 失败 */
this.props.getServiceError(dataReturn);
}
} else if (sFieldName === 'sCustomerId' || sFieldName === 'sCustomerNo' || sFieldName === 'sCustomerName') {
const returnChange = await this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, true);
if (returnChange !== undefined && returnChange.masterData !== undefined) {
returnChange.masterData.sProductId = '';
returnChange.masterData.sProductNo = '';
returnChange.masterData.sProductName = '';
}
this.props.onSaveState({ ...returnChange });
} else {
this.props.onChange(name, sFieldName, changeValue, sId, dropDownData);
}
};
/* 数据生成按钮 */
handleDataCreate= async () => {
let { checkProcessClassifyData } = this.props;
const {
masterData, slaveConfig, materialsConfig, processConfig, sModelsId, app, dispatch,
} = this.props;
const { token } = this.props.app;
const paramMap = {};
const { sAllPartsName } = masterData;
let allPartsName = [];
if (sAllPartsName !== undefined) {
allPartsName = sAllPartsName.split(',');
}
let timValue = 0;
if (this.props.app.webSocket === null || this.props.app.webSocket.readyState !== WebSocket.OPEN) {
this.props.dispatch({ type: 'app/createWebSocket', payload: { reStart: true, dispatch } });
timValue = 3000;
}
setTimeout(async () => {
this.props.app.webSocket.onmessage = (msg) => {
const rtmsg = JSON.parse(msg.data);
if (rtmsg.action === 'quotationAllprogress') {
this.props.onSaveState({
quotationAllprogress: rtmsg.msg,
});
} else if (rtmsg.action === 'loginOut') {
if (location.pathname.indexOf('/indexOee') > -1) {
dispatch({ type: 'app/throwErrorOee', payload: { code: -2, msg: rtmsg.msg } });
} else if (location.pathname.indexOf('/indexMobile') > -1) {
dispatch({ type: 'app/throwErrorMobile', payload: { code: -2, msg: rtmsg.msg } });
} else {
dispatch({ type: 'app/throwError', payload: { code: -2, msg: rtmsg.msg } });
}
} else if (this.props.app.webSocket.homeAction) {
this.props.app.webSocket.homeAction(msg);
}
};
let cpProcessName = '';
checkProcessClassifyData = commonUtils.isEmptyArr(checkProcessClassifyData) ? [] : checkProcessClassifyData;
// paramMap.modelName = masterData.modelName;
paramMap.bQuotation = true;
paramMap.sCustomerId = masterData.sCustomerId;
paramMap.sCustomerName = masterData.sCustomerName;
paramMap.sProductClassifyId = masterData.sProductClassifyId;
paramMap.sProductId = masterData.sProductId;
paramMap.sProductName = masterData.sProductName;
paramMap.sProductStyleId = masterData.sProductStyleId;
paramMap.sProductStyle = masterData.sProductStyle;
paramMap.dProductWidth = !commonUtils.isEmpty(masterData.sProductStyle) && masterData.sProductStyle.split('*').length > 0 ? masterData.sProductStyle.split('*')[1] : 0;
paramMap.dProductLength = !commonUtils.isEmpty(masterData.sProductStyle) && masterData.sProductStyle.split('*').length > 0 ? masterData.sProductStyle.split('*')[0] : 0;
paramMap.dProductHeight = 0;
paramMap.dProductQty = masterData.dProductQty;
const partsInfo = [];
allPartsName.forEach((item) => {
const partInfo = {};
partInfo.sPartsName = item;
partInfo.dPartsQty = masterData.dProductQty;
partInfo.dSumPQty = masterData[`dSumPQty${item}`];
const materialsInfo = [];
const material = {};
material.sMaterialsId = masterData[`sMaterialsId${item}`];
material.sMaterialsNo = masterData[`sMaterialsNo${item}`];
material.sMaterialsName = masterData[`sMaterialsName${item}`] !== undefined && masterData[`sMaterialsName${item}`].split('[-]').length > 1 ? masterData[`sMaterialsName${item}`].split('[-]')[1] : masterData[`sMaterialsName${item}`];
materialsInfo.push(material);
partInfo.materialsInfo = materialsInfo;
partInfo.iPositiveColor = masterData[`iPositiveColor${item}`];
partInfo.iPrintModePo = masterData[`iPrintModePo${item}`];
if (material.sMaterialsId !== undefined && material.sMaterialsId !== '') {
const processInfo = [];
checkProcessClassifyData.filter(card => card.sPartsName === item && card.sType !== '3').forEach((card) => {
if (!commonUtils.isEmpty(masterData[card.sId + item])) {
if (commonUtils.isEmpty(partInfo.sPrintProcessId) && card.sType === '1') {
partInfo.sPrintProcessId = masterData[card.sId + item];
} else {
const process = {};
process.sProductClassifyId = card.sId;
process.sProcessId = masterData[card.sId + item];
if (masterData[card.sId + card.sName + item] !== undefined) {
process.sProcessName = masterData[card.sId + card.sName + item];
process.sType = masterData[card.sId + card.sType + item];
processInfo.push(process);
}
}
}
});
partInfo.processInfo = processInfo;
partsInfo.push(partInfo);
}
});
const productProcess = [];
checkProcessClassifyData.filter(card => card.sType === '3').forEach((card) => {
if (!commonUtils.isEmpty(masterData[card.sId])) {
const process = {};
process.sProductClassifyId = card.sId;
process.sProcessId = masterData[card.sId];
process.sProcessName = masterData[card.sId + card.sName];
if (masterData[card.sId + card.sName] !== undefined) {
cpProcessName = cpProcessName === '' ? masterData[card.sId + card.sName] : `${cpProcessName},${masterData[card.sId + card.sName]}`;
productProcess.push(process);
}
}
});
paramMap.cpProcessName = cpProcessName;
paramMap.productProcessInfo = productProcess;
paramMap.partsInfo = partsInfo;
let numErr = false;
let numName = '';
let num = 0;
// eslint-disable-next-line array-callback-return
paramMap.partsInfo.map((item) => {
if (masterData.sProductClassifyId === '15736273370008507016374163380000' && item.dSumPQty < 4) {
num = item.dSumPQty;
numName = item.sPartsName;
}
if (item.dSumPQty % 2 !== 0 && item.dSumPQty !== undefined) {
numErr = true;
numName = item.sPartsName;
}
});
if (numErr) {
message.error(`${numName}P数必须是2的倍数!`);
return;
}
if (num === 2) {
message.error(`${numName}P数必须大于4P!`);
return;
}
if (commonUtils.isEmpty(paramMap.sProductName) || commonUtils.isEmpty(paramMap.sProductStyle) || commonUtils.isEmpty(paramMap.dProductWidth) ||
commonUtils.isEmpty(paramMap.dProductLength) || commonUtils.isEmpty(paramMap.dProductQty)) {
// this.props.onSaveState({ fastOrderModalVisible: false });
message.error(commonFunc.showMessage(app.commonConst, 'ProductError'));/* 产品信息不正确 */
return;
}
/* 验证产品规格是否 符合数字*数字格式 */
const sProductStyle = paramMap.sProductStyle;
if (commonUtils.isNotEmptyObject(sProductStyle) && sProductStyle.indexOf('*') > -1) { /* 首先查看产品规格输入是否有*号 */
const arr = sProductStyle.split('*');
const numCheck = /^(-?\d+)(\.?)(\d{1,6})?$/;
if (commonUtils.isNotEmptyArr(arr) && arr.length > 0) {
for (let i = 0; i < arr.length; i += 1) {
if (!numCheck.test(arr[i])) { /* 验证是否数字 */
message.error(commonFunc.showMessage(app.commonConst, 'sProductStyleErr'));
return;
}
}
} else {
message.error(commonFunc.showMessage(app.commonConst, 'sProductStyleErr'));
return;
}
/* 验证*两边是否是数字 */
} else {
message.error(commonFunc.showMessage(app.commonConst, 'sProductStyleErr'));
return;
}
this.props.onSaveState({
Loading: true,
});
// onSendSocketMessage('quotationSplitPaste', 'noAction', masterData.sId, userinfo.sId, null, null);
const url = `${commonConfig.server_host}calculationStd/countMoney?sModelsId=${sModelsId}`;
const dataReturn = (await commonServices.postValueService(token, paramMap, url)).data;
if (dataReturn.code === 1) {
const {
productClassify, partsNewInfo, productProcessInfo, partsInfo: partsOldInfo,
} = dataReturn.dataset.rows[0];
const slaveData = [];
const controlData = [];
const materialsData = [];
let processData = [];
const tableDataRow = {};
for (const item of slaveConfig.gdsconfigformslave) {
tableDataRow[item.sName] = masterData[item.sName];
}
tableDataRow.sId = commonUtils.createSid();
tableDataRow.handleType = 'add';
tableDataRow.iOrder = 1;
tableDataRow.sParentId = masterData.sId;
// const productIdDropDown = commonUtils.getStoreDropDownData(sModelsId, 'slave', 'sProductName');
let productIdDropDown;
const slaveIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProductName');
if (slaveIndex > -1) {
const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', slaveConfig.gdsconfigformslave[slaveIndex], tableDataRow);
productIdDropDown = sqlDropDownData.dropDownData;
}
const iProductIdIndex = commonUtils.isEmptyArr(productIdDropDown) ? -1 : productIdDropDown.findIndex(item => item.sId === tableDataRow.sProductId);
if (iProductIdIndex === -1) {
tableDataRow.sProductId = tableDataRow.sProductName;
tableDataRow.sProductInfo = JSON.stringify({
sProductId: tableDataRow.sProductName,
sProductName: tableDataRow.sProductName,
sProductStyle: tableDataRow.sProductStyle,
sProductUnit: tableDataRow.sProductUnit,
sProductNo: tableDataRow.sProductNo,
sCustomerProductNo: tableDataRow.sCustomerProductNo,
sProductClassifyId: tableDataRow.sProductClassifyId,
sProductClassifyName: tableDataRow.sProductClassifyName,
});
} else {
tableDataRow.sProductInfo = '';
}
slaveData.push(tableDataRow);
const sInfoArr = [];
if (!commonUtils.isEmptyArr(partsOldInfo)) {
partsOldInfo.forEach((item) => {
if (commonUtils.isNotEmptyObject(item) && !commonUtils.isEmpty(item.errorFlag)) {
this.props.getServiceError({ msg: `${item.sPartsName} ${item.errorFlag}` });
}
});
}
if (this.props.app.userinfo.sType === 'sysadmin') { /* 超级管理员,弹窗显示接口返回的sInfo */
partsNewInfo.forEach((item) => {
const { sPartsName, sInfo } = item;
const sInfoObj = {};
sInfoObj.sPartsName = sPartsName;
sInfoObj.sInfo = sInfo;
sInfoArr.push(sInfoObj);
});
}
const bProcessAssort = true;
let returnProcessAssort = [];
let processAssignAssort = '';
let dropDownDataProcessName;
if (bProcessAssort) {
const dataUrl = `${commonConfig.server_host}salesorder/getProcessAssort?sModelsId=${sModelsId}`;
const dataProcessAssort = (await commonServices.postValueService(token, {}, dataUrl)).data;
if (dataProcessAssort.code === 1) {
returnProcessAssort = dataProcessAssort.dataset.rows[0].processassort;
const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProcessName');
if (iIndex > -1) {
const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', processConfig.gdsconfigformslave[iIndex]);
dropDownDataProcessName = sqlDropDownData.dropDownData;
processAssignAssort = processConfig.gdsconfigformslave[iIndex].sAssignField;
}
}
}
const newCopyTo = {};
newCopyTo.master = masterData;
newCopyTo.slave = commonUtils.isEmptyArr(slaveData) ? {} : slaveData[0];
await partsNewInfo.forEach(async (partInfo, iIndex) => {
const partsDataRow = {};
for (const child of Object.keys(partInfo)) {
partsDataRow[child] = partInfo[child];
}
partsDataRow.handleType = 'add';
partsDataRow.iOrder = iIndex + 1;/* 快速下单编号从1开始 */
partsDataRow.sId = commonUtils.createSid();
partsDataRow.sParentId = masterData.sId;
// partsDataRow.sSlaveId = ' ';
if (partsDataRow.iPrintMode !== 3) {
partsDataRow.iOppositeColor = partsDataRow.iPositiveColor;
}
delete partsDataRow.dMaterialsKQty;
delete partsDataRow.dMaterialsLength;
delete partsDataRow.dMaterialsWidth;
if (productClassify.bSpecialRules) {
partsDataRow.dMachineLength = partsDataRow.dMaxMachineLength;
partsDataRow.dMachineWidth = partsDataRow.dMaxMachineWidth;
}
controlData.push(partsDataRow);
// 材料信息
await partInfo.materialsInfo.forEach(async (materialInfo, iOrder) => {
let materialDataRow = {};
for (const item of materialsConfig.gdsconfigformslave) {
materialDataRow[item.sName] = materialInfo[item.sName];
}
materialDataRow.handleType = 'add';
materialDataRow.sType = '0';
materialDataRow.iPartOrder = iIndex;
materialDataRow.iOrder = iOrder + 1;
materialDataRow.sPartsName = partsDataRow.sPartsName;
materialDataRow.sId = commonUtils.createSid();
materialDataRow.sParentId = masterData.sId;
materialDataRow.sControlId = partsDataRow.sId;
// materialDataRow.sSlaveId = ' ';
materialDataRow.dMaterialsKQty = partsDataRow.iNumberofMaterial;
const models = 'Materials';
materialDataRow = await this.props.onMaterialsChange(materialDataRow, sModelsId, masterData, [], 'dAuxiliaryQty', app, token, models);
materialDataRow = commonBusiness.getCalculateAllMoney(app, models, 'dAuxiliaryQty', masterData, materialDataRow);
materialsData.push(materialDataRow);
});
// 工序信息
let processPrintDataRow = {};
processPrintDataRow.handleType = 'add';
processPrintDataRow.sProcessId = partInfo.sProcessId;
const iProcessPrintIndex = dropDownDataProcessName.findIndex(item => item.sId === processPrintDataRow.sProcessId);
if (iProcessPrintIndex > -1) {
processPrintDataRow = { ...processPrintDataRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iProcessPrintIndex], newCopyTo) }; // 取赋值字段
}
processPrintDataRow.sType = partInfo.sType;
processPrintDataRow.iPartOrder = iIndex;
processPrintDataRow.iOrder = 1;
processPrintDataRow.sProcessName = partInfo.sProcessName;
processPrintDataRow.sPartsName = partsDataRow.sPartsName;
processPrintDataRow.dProcessInQty = partInfo.dProcessInQty;
processPrintDataRow.dLossQty = partInfo.dLossQty;
processPrintDataRow.dProcessOutQty = partInfo.dProcessOutQty;
processPrintDataRow.sId = commonUtils.createSid();
processPrintDataRow.sParentId = masterData.sId;
processPrintDataRow.sControlId = partsDataRow.sId;
// processPrintDataRow.sSlaveId = ' ';
processData.push(processPrintDataRow);
// 配套工序
if (bProcessAssort) {
returnProcessAssort.filter(item => item.sParentId === processPrintDataRow.sProcessId).forEach(((itemProcessAssort) => {
const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
const iProcessIndex = -1;
const iNewProcessIndex = processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === partsDataRow.sId);
if (iIndex > -1 && iProcessIndex < 0 && iNewProcessIndex < 0) {
let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sControlId = partsDataRow.sId;
processRow.sPartsName = partsDataRow.sPartsName;
processRow.sType = dropDownDataProcessName[iIndex].sType;
// processRow.sSlaveId = ' ';
processData.push(processRow);
}
}));
}
partInfo.processInfo.forEach((process, iOrder) => {
let processAfterDataRow = {};
for (const item of processConfig.gdsconfigformslave) {
processAfterDataRow[item.sName] = process[item.sName];
}
for (const child of Object.keys(process)) {
processAfterDataRow[child] = process[child];
}
processAfterDataRow.handleType = 'add';
processAfterDataRow.sProcessId = process.sProcessId;
const iProcessAfterIndex = dropDownDataProcessName.findIndex(item => item.sId === processAfterDataRow.sProcessId);
if (iProcessAfterIndex > -1) {
processAfterDataRow = { ...processAfterDataRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iProcessAfterIndex], newCopyTo) }; // 取赋值字段
}
processAfterDataRow.sType = process.sType;
processAfterDataRow.iPartOrder = iIndex;
processAfterDataRow.iOrder = iOrder + 1;
processAfterDataRow.sPartsName = partsDataRow.sPartsName;
processAfterDataRow.sId = commonUtils.createSid();
processAfterDataRow.sParentId = masterData.sId;
processAfterDataRow.sControlId = partsDataRow.sId;
// processAfterDataRow.sSlaveId = ' ';
processData.push(processAfterDataRow);
// 配套工序
if (bProcessAssort) {
returnProcessAssort.filter(item => item.sParentId === processPrintDataRow.sProcessId).forEach(((itemProcessAssort) => {
const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
const iProcessIndex = -1;
const iNewProcessIndex = processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === partsDataRow.sId);
if (iIndex > -1 && iProcessIndex < 0 && iNewProcessIndex < 0) {
let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sControlId = partsDataRow.sId;
processRow.sPartsName = partsDataRow.sPartsName;
processRow.sType = dropDownDataProcessName[iIndex].sType;
// processRow.sSlaveId = ' ';
processData.push(processRow);
}
}));
}
});
});
productProcessInfo.forEach((process, iOrder) => {
let processProductDataRow = {};
for (const item of processConfig.gdsconfigformslave) {
processProductDataRow[item.sName] = process[item.sName];
}
for (const child of Object.keys(process)) {
processProductDataRow[child] = process[child];
}
const iProductProcessIndex = dropDownDataProcessName.findIndex(item => item.sId === processProductDataRow.sProcessId);
if (iProductProcessIndex > -1) {
processProductDataRow = { ...processProductDataRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iProductProcessIndex], newCopyTo) }; // 取赋值字段
}
processProductDataRow.handleType = 'add';
processProductDataRow.sType = '3';
processProductDataRow.sPartsName = '';
processProductDataRow.iPartOrder = 999;
processProductDataRow.iOrder = iOrder + 1;
processProductDataRow.sId = commonUtils.createSid();
processProductDataRow.sParentId = masterData.sId;
// processProductDataRow.sSlaveId = ' ';
processData.push(processProductDataRow);
// 配套工序
if (bProcessAssort) {
returnProcessAssort.filter(item => item.sParentId === processProductDataRow.sProcessId).forEach(((itemProcessAssort) => {
const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
const iProcessIndex = -1;
const iNewProcessIndex = processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId);
if (iIndex > -1 && iProcessIndex < 0 && iNewProcessIndex < 0) {
let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sType = dropDownDataProcessName[iIndex].sType;
// processRow.sSlaveId = ' ';
processData.push(processRow);
}
}));
}
});
processData = this.sortData(controlData, processData);
const addState = { controlSelectedRowKeys: ['0000000'] };
if (!commonUtils.isEmptyArr(slaveData)) {
addState.slaveSelectedRowKeys = [slaveData[0].sId];
}
this.props.onSaveState({
materialsConfig,
slaveData,
controlData,
materialsData,
processData,
fastOrderModalVisible: false,
quotationAllprogress: 0,
materialsSelectedRowKeys: [],
...addState,
sInfoArr,
bVisiblesInfo: !!commonUtils.isNotEmptyArr(sInfoArr),
Loading: false,
});
} else {
this.props.getServiceError(dataReturn);
this.props.onSaveState({
Loading: false,
});
}
}, timValue);
};
/* 勾选工序分类 */
handleProcessChange=(e, value, sPartsName) => {
let { checkProcessClassifyData } = this.props;
let index = -1;
if (commonUtils.isNotEmptyArr(checkProcessClassifyData)) {
index = checkProcessClassifyData.findIndex(item => (item.sId === value.sId && item.sPartsName === sPartsName));
} else {
checkProcessClassifyData = [];
}
if (e.target.checked) {
if (index <= -1) {
const newvalue = { ...value };
newvalue.sPartsName = sPartsName;
checkProcessClassifyData.push(newvalue);
}
} else if (index > -1) {
checkProcessClassifyData.splice(index, 1);
}
this.props.onSaveState({ checkProcessClassifyData });
};
handleSelectChangeProcess = (sAssignField, value, option) => {
const { masterData, sBackProcessClassifyData } = this.props;
let { checkProcessClassifyData } = this.props;
if (sAssignField !== undefined) {
// 这一段是处理工序的赋值字段,原因工序是动态生成,没用showtype
const sAssignFields = sAssignField.split(',');
const recordRow = option.props['data-recordrow'];
sAssignFields.forEach((item, iAssignIndex) => {
const itemsplits = item.split(':');
masterData[`${itemsplits[0]}`] = recordRow[itemsplits[1]];
if (iAssignIndex === 0) {
let index = -1;
const sPartsName = itemsplits[0].replace(recordRow.sParentId, '');
if (commonUtils.isNotEmptyArr(checkProcessClassifyData)) {
index = checkProcessClassifyData.findIndex(item => (item.sId === recordRow.sParentId && item.sPartsName === sPartsName));
} else {
checkProcessClassifyData = [];
}
if (index <= -1) {
const iBackProcessIndex = sBackProcessClassifyData.findIndex(item => item.sId === recordRow.sParentId);
if (iBackProcessIndex > -1) {
const newvalue = { ...sBackProcessClassifyData[iBackProcessIndex] };
newvalue.sPartsName = sPartsName;
checkProcessClassifyData.push(newvalue);
}
}
}
});
this.props.onSaveState({ masterData, checkProcessClassifyData });
}
};
handleA = (sId) => {
const { sBackProcessData } = this.props;
const data = sBackProcessData.filter(item => item.sParentId === sId);
const optionProcess = [];
data.forEach((item) => {
optionProcess.push();
});
return optionProcess;
};
handleSave = async () => {
this.form.validateFields((err) => {
/* 验证通过与不通过走不同的流程 */
if (err) { /* 验证失败 */
/* 直接渲染显示错误提示 */
for (const key of Object.keys(err)) {
message.warning(err[key].errors[0].message);
}
this.props.onSaveState({
loading: false,
});
} else { /* 验证成功 */
const {
masterConfig, masterData, slaveConfig, slaveData, slaveDelData, controlConfig, controlData, controlDelData, colorConfig,
colorData, colorDelData, materialsConfig, materialsData, materialsDelData, processConfig, processData, processDelData, app, manyqtysConfig, manyqtysData, manyqtysDelData, packConfig, packData, packDelData,
} = this.props;
if (commonUtils.isEmptyArr(slaveData)) {
message.warning(`从表${commonFunc.showMessage(this.props.app.commonConst, 'isNotNull')}`);
this.props.onSaveState({
loading: false,
});
return;
}
if (!commonBusiness.validateTable(slaveConfig, slaveData, this.props) || !commonBusiness.validateTable(controlConfig, controlData, this.props) ||
(!commonBusiness.validateTable(materialsConfig, materialsData, this.props)) || !commonBusiness.validateTable(processConfig, processData, this.props) ||
!commonBusiness.validateTable(colorConfig, colorData, this.props) || !commonBusiness.validateTable(packConfig, packData, this.props)) {
this.props.onSaveState({
loading: false,
});
return;
}
if (commonUtils.isNotEmptyArr(materialsData)) {
let flag = true;
for (const item of materialsData) {
if (commonUtils.isNotEmptyObject(item.sMaterialsType) && item.sMaterialsType === 'paper' && commonUtils.isEmptyObject(item.sMaterialsStyle)) {
message.error(item.sMaterialsName + commonFunc.showMessage(app.commonConst, 'NoStyle'));/* 请填写"${item.sMaterialsName}"的规格 */
flag = false;
break;
}
}
if (!flag) {
this.props.onSaveState({
loading: false,
});
return;
}
}
const data = [];
data.push(commonBusiness.mergeData('master', masterConfig.sTbName, [masterData]));
data.push(commonBusiness.mergeData('slave', slaveConfig.sTbName, slaveData, slaveDelData));
data.push(commonBusiness.mergeData('control', controlConfig.sTbName, controlData, controlDelData));
data.push(commonBusiness.mergeData('materials', materialsConfig.sTbName, materialsData, materialsDelData));
data.push(commonBusiness.mergeData('process', processConfig.sTbName, processData, processDelData));
data.push(commonBusiness.mergeData('manyqtys', manyqtysConfig.sTbName, manyqtysData, manyqtysDelData));
data.push(commonBusiness.mergeData('color', colorConfig.sTbName, colorData, colorDelData));
data.push(commonBusiness.mergeData('pack', packConfig.sTbName, packData, packDelData));
this.props.onSaveData({
data, sClientType: '1', loading: false, sSysLogSrcId: masterData.sId,
});
}
});
};
/** 处理选择行发生改变 */
handleTableSelectRowChange = (name, selectedRowKeys) => {
/* 外置处理业务 */
if (name === 'slave') {
const { controlData } = this.props;
const addState = this.props.onTableSelectRowChange(name, selectedRowKeys, true);
if (!commonUtils.isEmptyArr(controlData) && controlData.length === 1) {
addState.controlSelectedRowKeys = [controlData[0].sId];
addState.treeSelectedKeys = [controlData[0].sId];
} else {
addState.controlSelectedRowKeys = [];
addState.treeSelectedKeys = [];
}
this.props.onSaveState(addState);
} else if (name === 'control') {
const addState = this.props.onTableSelectRowChange(name, selectedRowKeys, true);
if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
const { treeData } = this.props; /* 赋值给树组件节点 */
let { treeSelectedKeys } = this.props; /* 赋值给树组件节点 */
if (treeData !== undefined) {
treeSelectedKeys = selectedRowKeys; /* 把树形选中节点赋值给表格部件选中节点 */
addState.treeSelectedKeys = treeSelectedKeys;
}
}
this.props.onSaveState(addState);
} else if (name === 'materials' || name === 'process') {
const { [`${name}Data`]: tableData, enabled } = this.props;
const addState = this.props.onTableSelectRowChange(name, selectedRowKeys, true);
if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
const iIndex = tableData.findIndex(item => item.sId === selectedRowKeys.toString());
if (enabled && iIndex > -1 && !commonUtils.isEmpty(tableData[iIndex].sControlId)) {
addState.controlSelectedRowKeys = [tableData[iIndex].sControlId];
}
}
this.props.onSaveState(addState);
} else {
this.props.onTableSelectRowChange(name, selectedRowKeys);
}
};
/** 控制选择控制表时,显示部件工序与成品工序 */
handleFilterData = (name, dataIndex, value, record) => {
if (value === undefined) {
return true;
}
if (name === 'process') {
return (commonUtils.isNotEmptyStr(record.sType) && record.sType === '3') ||
(commonUtils.isNotEmptyStr(record.sControlId) && record.sControlId.toString().toLowerCase().includes(value.toLowerCase()));
} else {
return (commonUtils.isNotEmptyStr(record.sType) && record.sType === '2') ||
(commonUtils.isNotEmptyStr(record.sControlId) && record.sControlId.toString().toLowerCase().includes(value.toLowerCase()));
}
};
/** 控制选择控制表时,显示成品材料与成品工序 */
handleFilterProductData = (name, dataIndex, value, record) => {
const { slaveSelectedRowKeys } = this.props;
if (value === undefined) {
return true;
}
this.handleTableRowLock(name, record);
if (name === 'process') {
return (commonUtils.isNotEmptyStr(record.sType) && record.sType === '3') &&
((commonUtils.isNotEmptyStr(record.sCombinePartsName) && record.sCombinePartsName === slaveSelectedRowKeys[0]) || !record.sCombinePartsName);
} else {
return (commonUtils.isNotEmptyStr(record.sType) && record.sType === '2') ||
((commonUtils.isNotEmptyStr(record.sCombinePartsName) && record.sCombinePartsName === slaveSelectedRowKeys[0]) || !record.sCombinePartsName);
}
};
/** 控制选择控制表时,显示部件工序与成品工序 */
handleGetFilterData = (name, bFinished) => {
const { [`${name}Data`]: data, controlSelectedRowKeys, slaveSelectedRowKeys } = this.props;
if (data !== undefined && ((commonUtils.isNotEmptyArr(controlSelectedRowKeys) && !bFinished) || bFinished)) {
if (name === 'materials' && bFinished) { /* 新增成品材料 */
return data.filter(item => item.sType === '2' && (item.sCombinePartsName === slaveSelectedRowKeys[0] || !item.sCombinePartsName)).length;
} else if (name === 'process' && bFinished) { /* 新增成品工序s */
return data.filter(item => item.sType === '3' && (item.sCombinePartsName === slaveSelectedRowKeys[0] || !item.sCombinePartsName)).length;
} else {
const newArr = data.filter((item) => {
return (commonUtils.isNotEmptyStr(item.sControlId) && item.sControlId.toString().toLowerCase().includes(controlSelectedRowKeys.toString()));
});
return newArr.length;
}
}
};
handleKeyDown = (e, record, sName, name) => {
/* 生产施工单,当印刷方式是“自翻”时,反面颜色不应该可输入 */
if (commonUtils.isNotEmptyObject(record) && sName === 'iOppositeColor' && record.iPrintMode === 0) {
if (e.key !== 'F12') {
e.preventDefault();
}
} else {
this.props.onKeyDown(e, record, sName, name);
}
};
/** 添加表格空行 */
handleTableAdd = (name, flag, bchild, bFinished, bModalAdd) => {
const { masterConfig } = this.props;
if(bModalAdd === true) {
if(name === 'materials') {
const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === "BtnChooseProductMaterials");
if (iIndex > -1) {
this.props.onBtnChoose('productMaterials', 'materials', masterConfig.gdsconfigformslave[iIndex]);
}
}
if(name === 'process') {
const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === "BtnChooseProductProcess");
if (iIndex > -1) {
this.props.onBtnChoose('productProcess', 'process', masterConfig.gdsconfigformslave[iIndex]);
}
}
return;
}
/* 外置处理业务 */
const {
gdsformconst, slaveData, controlData, slaveSelectedRowKeys, controlSelectedRowKeys, [`${name}Data`]: tableData,
} = this.props;
if (name === 'control') {
/* 增加子部件 */
const {
[`${name}SelectedRowKeys`]: treeSelectedKeys,
} = this.props;
if ((bchild === 'childNode' || bchild === 'sameNode') && (commonUtils.isEmptyArr(treeSelectedKeys) || commonUtils.isEmptyArr(controlSelectedRowKeys))) {
message.warn('请选择部件!'); // 请选择部件
return;
}
const tableDataRow = this.props.onDataRowAdd(name, true);
if (bchild === 'sameNode') { /* 添加同级 */
const iIndex = controlData.findIndex(item => item.sId === treeSelectedKeys[0]);
/* 找到同级子元素的sControlParentId */
if (iIndex > -1) {
tableDataRow.sControlParentId = controlData[iIndex].sControlParentId;
/* 找到同级父级sAllId */
const pId = controlData[iIndex].sControlParentId;
const sControlParentId = controlData.findIndex(item => item.sId === pId);
if (sControlParentId > -1) {
const sAllId = controlData[sControlParentId].sAllId;
if (commonUtils.isEmptyObject(sAllId)) {
message.warn('部件数据生成错误![sAllId为空]');
return;
}
tableDataRow.sAllId = `${controlData[sControlParentId].sAllId},${tableDataRow.sId}`;
} else {
tableDataRow.sAllId = tableDataRow.sId;
}
}
}
if (bchild === 'childNode') { /* 添加子级 */
tableDataRow.sControlParentId = treeSelectedKeys[0];
const iIndex = controlData.findIndex(item => item.sId === treeSelectedKeys[0]);
if (iIndex > -1) {
const sAllId = controlData[iIndex].sAllId;
if (commonUtils.isEmptyObject(sAllId)) {
message.warn('子部件数据生成错误![sAllId为空]'); // 获取父节点的sAllId
return;
}
tableDataRow.sAllId = `${controlData[iIndex].sAllId},${tableDataRow.sId}`;
}
}
let dPartsQty = 0;
/* 主表配置bProductQtyAdd 则代表产品数量不叠加备货数 赠送数 */
let bProductQtySelf = false;
if (commonUtils.isNotEmptyObject(this.props.masterConfig) && commonUtils.isNotEmptyArr(this.props.masterConfig.gdsconfigformslave)) {
const iIndex = this.props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'bProductQtySelf');
if (iIndex > -1) {
bProductQtySelf = true;
}
}
if (commonUtils.isNotEmptyArr(slaveData)) {
slaveData.forEach((item) => {
if (bProductQtySelf) {
dPartsQty += commonUtils.isNull(item.dProductQty, 0);
} else {
dPartsQty += commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0);
}
});
}
tableDataRow.sSlaveId = ' ';
tableDataRow.dPartsQty = dPartsQty;
tableData.push(tableDataRow);
const treeState = this.handleGetControlTreeData(tableData, true);
this.props.onSaveState({
...treeState, [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: [tableDataRow.sId], treeSelectedKeys: [tableDataRow.sId],
});
} else if (name === 'materials' || name === 'process') {
if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
message.warn(commonFunc.showMessage(gdsformconst, 'pleaseChooseSlave')); // 请选择从表数据
return;
}
if (commonUtils.isEmptyArr(controlSelectedRowKeys) && !bFinished) {
message.warn(commonFunc.showMessage(gdsformconst, 'pleaseChooseParts')); // 请选择部件
return;
}
const tableDataRow = this.props.onDataRowAdd(name, true);
if(bFinished) {
const iIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
if (iIndex > -1) {
tableDataRow.sCombinePartsNameNew = `${slaveData[iIndex].sCustomerName}-${slaveData[iIndex].sProductName}`;
tableDataRow.sCombinePartsName = slaveData[iIndex].sId;
if (name === 'materials') { /* 新增成品材料 */
tableDataRow.sType = '2';
}
if (name === 'process') { /* 新增成品工序 */
tableDataRow.sType = '3';
}
}
} else {
const iIndex = controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]);
if (iIndex > -1) {
if (commonUtils.isEmpty(controlData[iIndex].sPartsName) === '') {
message.warn(commonFunc.showMessage(gdsformconst, 'partsNameNotNull')); // 部件名称不能为空
return;
}
tableDataRow.sControlId = controlData[iIndex].sId;
tableDataRow.sPartsName = controlData[iIndex].sPartsName;
if (name === 'materials' && bFinished) { /* 新增成品材料 */
tableDataRow.sType = '2';
}
if (name === 'process' && bFinished) { /* 新增成品工序 */
tableDataRow.sType = '3';
}
}
}
tableData.push(tableDataRow);
this.props.onSaveState({ [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: [tableDataRow.sId] });
} else if (name === 'slave') {
const { [`${name}SelectedRowKeys`]: tableSelectedRowKeys, app, packData } = this.props;
const tableDataRow = this.props.onDataRowAdd(name, true);
if (commonUtils.isNotEmptyArr(slaveData) && commonUtils.isEmptyArr(tableSelectedRowKeys)) {
message.warning(commonFunc.showMessage(app.commonConst, 'selectedRowKeysNo'));
return;
}
if (commonUtils.isNotEmptyArr(controlData)) {
controlData.forEach((item) => {
/* 合版信息表增加一条从表数据 */
const packDataRow = this.handlePackDataAdd(tableDataRow, slaveData.length, item.sId, 'add');
if (commonUtils.isNotEmptyObject(packDataRow)) {
// packDataRow.dCombineQty = 1;
packData.push(packDataRow);
}
});
}
tableData.push(tableDataRow);
this.props.onSaveState({ [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: [tableDataRow.sId] }, packData);
} else {
return this.props.onDataRowAdd(name, flag);
}
};
/** 删除表格数据 */
otherTableDel = (name, tableSelectedRowKeys, sField) => {
const tableData = this.props[`${name}Data`];
let tableDelData = this.props[`${name}DelData`];
tableDelData = commonUtils.isEmptyArr(tableDelData) ? [] : tableDelData;
const sFieldName = commonUtils.isEmpty(sField) ? 'sControlId' : sField;
for (const sId of tableSelectedRowKeys) {
/* 看看删除集合和从表中是否都存在该条数据 */
let tableDataIndex = tableData.findIndex(item => item[sFieldName] === sId);
while (tableDataIndex > -1) {
/* 删除从表中的数据并存入删除集合中 */
const slaveDataFilter = tableData[tableDataIndex];
tableData.splice(tableDataIndex, 1);
slaveDataFilter.handleType = 'del';
tableDelData.push(slaveDataFilter);
tableDataIndex = tableData.findIndex(item => item[sFieldName] === sId);
}
}
return { [`${name}Data`]: tableData, [`${name}DelData`]: tableDelData, [`${name}SelectedRowKeys`]: [] };
}
/** 删除表格数据 */
handleTableDel = async (name, flag, tableSelectedRowKeys) => {
if (name === 'slave') {
/* 删除sSlaveId关联的合版表 */
const { [`${name}SelectedRowKeys`]: tableSelectedRowKeys } = this.props;
if (commonUtils.isNotEmptyArr(tableSelectedRowKeys)) {
const packReturnData = this.otherTableDel('pack', tableSelectedRowKeys, 'sSlaveId');
const materielReturnData = this.otherTableDel('materials', tableSelectedRowKeys, 'sCombinePartsName'); /* 删除成品材料 */
const processReturnData = this.otherTableDel('process', tableSelectedRowKeys, 'sCombinePartsName'); /* 删除成品工序 */
const slaveReturnData = this.props.onDataRowDel(name, true, tableSelectedRowKeys);
this.props.onSaveState({
...materielReturnData,
...processReturnData,
...packReturnData,
...slaveReturnData,
});
return true;
} else {
message.warn('请选择要删除的部件!');
return false;
}
} else if (name === 'control') {
const {
controlData, treeSelectedKeys, [`${name}SelectedRowKeys`]: tableSelectedRowKeys, app,
} = this.props;
if (commonUtils.isNotEmptyArr(tableSelectedRowKeys)) {
/* 删除该节点及所有子节点 */
const controlChildData = controlData.filter(item => commonUtils.isNotEmptyObject(item.sAllId) && item.sAllId.indexOf(treeSelectedKeys[0]) > -1 && item.sId !== treeSelectedKeys[0]);
if (commonUtils.isNotEmptyArr(controlData)) {
controlChildData.forEach((itemNew) => {
tableSelectedRowKeys.push(itemNew.sId);
});
}
const materialsReturnData = this.otherTableDel('materials', tableSelectedRowKeys);
const processReturnData = this.otherTableDel('process', tableSelectedRowKeys);
const packReturnData = this.otherTableDel('pack', tableSelectedRowKeys);
const controlReturnData = this.props.onDataRowDel(name, true, tableSelectedRowKeys);
const treeState = this.handleGetControlTreeData(controlReturnData.controlData, true);
this.props.onSaveState({
...treeState,
...materialsReturnData,
...processReturnData,
...packReturnData,
...controlReturnData,
});
return true;
} else {
message.warn(commonFunc.showMessage(app.commonConst, 'selectedRowKeysNo'));/* 请选择数据 */
return false;
}
} else if (name === 'process') {
const {
sModelsId, [`${name}Data`]: tableData, materialsConfig, materialsData, token,
} = this.props;
const iIndex = tableData.findIndex(item => item.sId === tableSelectedRowKeys.toString());
const dataUrl = `${commonConfig.server_host}salesorder/getProcessAssort?sModelsId=${sModelsId}`;
const dataProcessAssort = (await commonServices.postValueService(token, {}, dataUrl)).data;
const tableDelData = [];
let returnProcessAssort = [];
if (dataProcessAssort.code === 1) {
returnProcessAssort = dataProcessAssort.dataset.rows[0].processassort;
}
let iMaterialsIndex = -1;
iMaterialsIndex = materialsData.findIndex(item => item.sControlId === tableData[iIndex].sControlId && item.sProcessId === tableData[iIndex].sProcessId);
const sProcessId = tableData[iIndex].sProcessId;
const sControlId = tableData[iIndex].sControlId;
const processReturnData = this.props.onDataRowDel(name, true, tableSelectedRowKeys);
returnProcessAssort.filter(item => item.sParentId === sProcessId).forEach(((itemProcessAssort) => {
const iProcessIndex = processReturnData.processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === sControlId);
if (iProcessIndex > -1) {
const slaveDataFilter = processReturnData.processData[iProcessIndex];
tableData.splice(iProcessIndex, 1);
slaveDataFilter.handleType = 'del';
tableDelData.push(slaveDataFilter);
}
}));
processReturnData.processDelData.concat(tableDelData);
if (iMaterialsIndex > -1) {
materialsData[iMaterialsIndex].sProcessId = '';
materialsData[iMaterialsIndex].sProcessTbId = '';
materialsData[iMaterialsIndex].sMaterialsProcessName = '';
}
this.props.onSaveState({
...processReturnData,
materialsConfig,
materialsSelectedRowKeys: [],
});
return true;
} else {
return this.props.onDataRowDel(name, flag, tableSelectedRowKeys);
}
};
handleCalculation = async () => {
const dataUrl = `${commonConfig.server_host}business/addQuotationsheet?sModelsId=${this.props.sModelsId}`;
const {
masterConfig, slaveConfig, controlConfig, materialsConfig, processConfig, app, manyqtysConfig, packConfig,
} = this.props;
let {
slaveData, controlData, materialsData, processData, masterData, manyqtysData, packData,
} = this.props;
const sMakePerson = masterData.sMakePerson;
const data = [];
data.push(commonBusiness.mergeData('master', `${masterConfig.sTbName.toLowerCase()}_Tmp`, [masterData], [], true));
data.push(commonBusiness.mergeData('slave', `${slaveConfig.sTbName.toLowerCase()}_tmp`, slaveData, [], true));
data.push(commonBusiness.mergeData('control', `${controlConfig.sTbName.toLowerCase()}_tmp`, controlData, [], true));
data.push(commonBusiness.mergeData('materials', `${materialsConfig.sTbName.toLowerCase()}_tmp`, materialsData, [], true));
data.push(commonBusiness.mergeData('process', `${processConfig.sTbName.toLowerCase()}_tmp`, processData, [], true));
data.push(commonBusiness.mergeData('manyqtys', `${manyqtysConfig.sTbName.toLowerCase()}_tmp`, manyqtysData, [], true));
data.push(commonBusiness.mergeData('pack', `${packConfig.sTbName.toLowerCase()}_tmp`, packData, [], true));
const value = { data, sClientType: '1', sGuid: masterData.sId };
const dataReturn = (await commonServices.postValueService(this.props.app.token, value, dataUrl)).data;
if (dataReturn.code === 1) { /* 成功 */
const valueReturn = dataReturn.dataset.rows[0];
const masterDataArr = valueReturn[`${masterConfig.sTbName.toLowerCase()}_tmp`];
if (commonUtils.isNotEmptyArr(masterDataArr)) {
masterData = masterDataArr[0];
}
if (masterData.handleType === 'update' && !commonUtils.isEmpty(sMakePerson)) {
masterData.sMakePerson = sMakePerson;
}
slaveData = valueReturn[`${slaveConfig.sTbName.toLowerCase()}_tmp`];
controlData = valueReturn[`${controlConfig.sTbName.toLowerCase()}_tmp`];
materialsData = valueReturn[`${materialsConfig.sTbName.toLowerCase()}_tmp`];
processData = valueReturn[`${processConfig.sTbName.toLowerCase()}_tmp`];
processData = this.sortData(controlData, processData);
manyqtysData = valueReturn[`${manyqtysConfig.sTbName.toLowerCase()}_tmp`];
packData = valueReturn[`${packConfig.sTbName.toLowerCase()}_tmp`];
this.props.onSaveState({
slaveData, controlData, materialsData, processData, masterData, manyqtysData, loading: false, packData,
});
message.success(commonFunc.getConfigShowName(masterConfig, 'BtnCalculation') + commonFunc.showMessage(app.commonConst, 'handleSuccess'));
} else { /* 失败 */
this.props.onSaveState({
loading: false,
});
this.props.getServiceError(dataReturn);
}
};
/** 按钮操作事件 */
handleButtonClick = async (name) => {
if (name === 'BtnCalculation') {
this.props.onSaveState({
loading: true,
});
this.handleCalculation();
} else if (name === 'BtnChooseProcess') {
const {
slaveData, controlData, slaveSelectedRowKeys, masterConfig, app,
} = this.props;
if (commonUtils.isEmptyArr(slaveData)) {
message.error(commonFunc.showMessage(app.commonConst, 'NoSlaveData'));/* 请填写从表数据 */
return;
}
const slaveSelectedData = slaveData.filter(item => item.sId === slaveSelectedRowKeys[0]);
if (commonUtils.isEmptyArr(slaveSelectedData)) {
message.error(commonFunc.showMessage(app.commonConst, 'pleaseChooseSlaveData'));/* 请选择从表数据 */
return;
}
if (commonUtils.isEmptyStr(slaveSelectedData[0].sProductId)) {
message.error(commonFunc.showMessage(app.commonConst, 'pleaseChooseProduct'));/* 请选择产品 */
return;
}
if (commonUtils.isEmptyObject(controlData)) {
message.error(commonFunc.showMessage(app.commonConst, 'NoControlData'));/* 请填写控制表数据 */
return;
}
const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === name);
if (iIndex > -1) {
this.props.onBtnChoose('process', name, masterConfig.gdsconfigformslave[iIndex]);
}
} else if (name === 'BtnChooseMaterials') {
const {
slaveData, controlData, slaveSelectedRowKeys, masterConfig, app,
} = this.props;
if (commonUtils.isEmptyArr(slaveData)) {
message.error(commonFunc.showMessage(app.commonConst, 'NoSlaveData'));/* 请填写从表数据 */
return;
}
const slaveSelectedData = slaveData.filter(item => item.sId === slaveSelectedRowKeys[0]);
if (commonUtils.isEmptyArr(slaveSelectedData)) {
message.error(commonFunc.showMessage(app.commonConst, 'pleaseChooseSlaveData'));/* 请选择从表数据 */
return;
}
if (commonUtils.isEmptyStr(slaveSelectedData[0].sProductId)) {
message.error(commonFunc.showMessage(app.commonConst, 'pleaseChooseProduct'));/* 请选择产品 */
return;
}
if (commonUtils.isEmptyObject(controlData)) {
message.error(commonFunc.showMessage(app.commonConst, 'NoControlData'));/* 请填写控制表数据 */
return;
}
const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === name);
if (iIndex > -1) {
this.props.onBtnChoose('materials', name, masterConfig.gdsconfigformslave[iIndex]);
}
} else if (name === 'BtnFastOrder') {
const {
masterData, masterConfig, sModelsId, slaveData, controlData, materialsData, checkProcessClassifyData, processData,
} = this.props;
const addState = {};
if (commonUtils.isEmpty(masterData.sProductClassifyId)) {
const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProductClassifyName');
if (iIndex > -1) {
const returnValue = {};
const { sAssignField } = masterConfig.gdsconfigformslave[iIndex];
const sqlDropDownData = (sModelsId, 'master', masterConfig.gdsconfigformslave[iIndex]);
const dropDownData = sqlDropDownData.dropDownData;
const [changeData] = dropDownData.filter(item => item.sType === 'huace');
if (!commonUtils.isEmpty(sAssignField)) {
/* 赋值数组 */
const sAssignFieldObj = sAssignField.split(',');
if (commonUtils.isNotEmptyObject(changeData)) {
for (const child of sAssignFieldObj) {
if (child.indexOf(':') > -1) {
const sFieldName = child.split(':')[0].trim();
const sValueName = child.split(':')[1].trim();
returnValue[sFieldName] = changeData[sValueName];
}
}
}
}
await this.handleMasterChange('master', 'sProductClassifyName', returnValue, masterData.sId, null);
}
} else if (commonUtils.isNotEmptyArr(slaveData) && !commonUtils.isEmpty(slaveData[0].sProductClassifyId)) {
const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProductClassifyName');
if (iIndex > -1) {
const returnValue = {};
const { sAssignField } = masterConfig.gdsconfigformslave[iIndex];
const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', masterConfig.gdsconfigformslave[iIndex]);
const dropDownData = sqlDropDownData.dropDownData;
const [changeData] = dropDownData.filter(item => item.sId === slaveData[0].sProductClassifyId);
if (!commonUtils.isEmpty(sAssignField)) {
/* 赋值数组 */
const sAssignFieldObj = sAssignField.split(',');
if (commonUtils.isNotEmptyObject(changeData)) {
for (const child of sAssignFieldObj) {
if (child.indexOf(':') > -1) {
const sFieldName = child.split(':')[0].trim();
const sValueName = child.split(':')[1].trim();
returnValue[sFieldName] = changeData[sValueName];
}
}
}
}
if (commonUtils.isNotEmptyArr(slaveData)) {
returnValue.sProductClassifyId = slaveData[0].sProductClassifyId;
returnValue.sProductClassifyName = slaveData[0].sProductClassifyName;
returnValue.sCustomerId = slaveData[0].sCustomerId;
returnValue.sCustomerNo = slaveData[0].sCustomerNo;
returnValue.sCustomerName = slaveData[0].sCustomerName;
returnValue.sProductId = slaveData[0].sProductId;
returnValue.sProductNo = slaveData[0].sProductNo;
returnValue.sProductName = slaveData[0].sProductName;
returnValue.sProductStyle = slaveData[0].sProductStyle;
returnValue.dProductQty = slaveData[0].dProductQty;
}
if (commonUtils.isEmptyArr(checkProcessClassifyData) && commonUtils.isNotEmptyArr(controlData) && !commonUtils.isEmpty(changeData) && !commonUtils.isEmpty(changeData.sAllPartsName)) {
const allPartsName = changeData.sAllPartsName.split(',');
const checkProcessClassifyNewData = [];
allPartsName.forEach((item) => {
const iControlIndex = controlData.findIndex(itemControl => itemControl.sPartsName === item);
if (iControlIndex > -1) {
returnValue[`dSumPQty${item}`] = controlData[iControlIndex].dSumPQty;
returnValue[`iPrintModePo${item}`] = controlData[iControlIndex].iPrintModePo;
returnValue[`iPositiveColor${item}`] = controlData[iControlIndex].iPositiveColor;
const iMaterialsIndex = materialsData.findIndex(materialsItem => materialsItem.sControlId === controlData[iControlIndex].sId);
if (iMaterialsIndex > -1) {
returnValue[`sMaterialsId${item}`] = materialsData[iMaterialsIndex].sMaterialsId;
returnValue[`sMaterialsNo${item}`] = materialsData[iMaterialsIndex].sMaterialsNo;
returnValue[`sMaterialsName${item}`] = materialsData[iMaterialsIndex].sMaterialsName;
}
processData.filter(processItem => processItem.sControlId === controlData[iControlIndex].sId && processItem.sType !== '3').forEach((processItem) => {
checkProcessClassifyNewData.push({ sId: processItem.sProcessClassifyId, sPartsName: item });
returnValue[processItem.sProcessClassifyId + item] = processItem.sProcessId;
returnValue[processItem.sProcessClassifyId + processItem.sProcessClassifyName + item] = processItem.sProcessName;
});
}
});
processData.filter(processItem => processItem.sType === '3').forEach((processItem) => {
checkProcessClassifyNewData.push({ sId: processItem.sProcessClassifyId });
returnValue[processItem.sProcessClassifyId] = processItem.sProcessId;
returnValue[processItem.sProcessClassifyId + processItem.sProcessClassifyName] = processItem.sProcessName;
});
addState.checkProcessClassifyData = checkProcessClassifyNewData;
}
await this.handleMasterChange('master', 'sProductClassifyName', returnValue, masterData.sId, null);
}
}
this.props.onSaveState({ fastOrderModalVisible: true, quotationAllprogress: 0, ...addState });
} else if (name === 'BtnDraft') {
const {
masterConfig, masterData, slaveConfig, slaveData, slaveDelData, controlConfig, controlData, controlDelData,
materialsConfig, materialsData, materialsDelData, processConfig, processData, processDelData, colorConfig,
colorData, colorDelData,
} = this.props;
const data = [];
slaveConfig.gdsconfigformslave.forEach((itemConfig) => {
slaveData.filter(itemData => itemData.handleType === 'add' || itemData.handleType === 'update').forEach((itemData) => {
itemData.NoVerify = 'NoVerify';
const firstDataIndex = itemConfig.sName.substring(0, 1);
if (commonUtils.isEmpty(itemData[itemConfig.sName])) {
itemData[itemConfig.sName] = firstDataIndex === 's' ? '' :
firstDataIndex === 'd' || firstDataIndex === 'i' ? 0 :
firstDataIndex === 'b' ? false :
firstDataIndex === 't' ? moment(new Date()).format(this.props.app.dateFormat) : undefined;
}
});
});
controlConfig.gdsconfigformslave.forEach((itemConfig) => {
controlData.filter(itemData => itemData.handleType === 'add' || itemData.handleType === 'update').forEach((itemData) => {
itemData.NoVerify = 'NoVerify';
const firstDataIndex = itemConfig.sName.substring(0, 1);
if (commonUtils.isEmpty(itemData[itemConfig.sName])) {
itemData[itemConfig.sName] = firstDataIndex === 's' ? '' :
firstDataIndex === 'd' || firstDataIndex === 'i' ? 0 :
firstDataIndex === 'b' ? false :
firstDataIndex === 't' ? moment(new Date()).format(this.props.app.dateFormat) : undefined;
}
});
});
materialsConfig.gdsconfigformslave.forEach((itemConfig) => {
materialsData.filter(itemData => itemData.handleType === 'add' || itemData.handleType === 'update').forEach((itemData) => {
itemData.NoVerify = 'NoVerify';
const firstDataIndex = itemConfig.sName.substring(0, 1);
if (commonUtils.isEmpty(itemData[itemConfig.sName])) {
itemData[itemConfig.sName] = firstDataIndex === 's' ? '' :
firstDataIndex === 'd' || firstDataIndex === 'i' ? 0 :
firstDataIndex === 'b' ? false :
firstDataIndex === 't' ? moment(new Date()).format(this.props.app.dateFormat) : undefined;
}
});
});
processConfig.gdsconfigformslave.forEach((itemConfig) => {
processData.filter(itemData => itemData.handleType === 'add' || itemData.handleType === 'update').forEach((itemData) => {
itemData.NoVerify = 'NoVerify';
const firstDataIndex = itemConfig.sName.substring(0, 1);
if (commonUtils.isEmpty(itemData[itemConfig.sName])) {
itemData[itemConfig.sName] = firstDataIndex === 's' ? '' :
firstDataIndex === 'd' || firstDataIndex === 'i' ? 0 :
firstDataIndex === 'b' ? false :
firstDataIndex === 't' ? moment(new Date()).format(this.props.app.dateFormat) : undefined;
}
});
});
if (commonUtils.isNotEmptyObject(colorConfig)) {
colorConfig.gdsconfigformslave.forEach((itemConfig) => {
colorData.filter(itemData => itemData.handleType === 'add' || itemData.handleType === 'update').forEach((itemData) => {
itemData.NoVerify = 'NoVerify';
const firstDataIndex = itemConfig.sName.substring(0, 1);
if (commonUtils.isEmpty(itemData[itemConfig.sName])) {
itemData[itemConfig.sName] = firstDataIndex === 's' ? '' :
firstDataIndex === 'd' || firstDataIndex === 'i' ? 0 :
firstDataIndex === 'b' ? false :
firstDataIndex === 't' ? moment(new Date()).format(this.props.app.dateFormat) : undefined;
}
});
});
}
data.push(commonBusiness.mergeData('master', masterConfig.sTbName, [masterData]));
data.push(commonBusiness.mergeData('slave', slaveConfig.sTbName, slaveData, slaveDelData));
data.push(commonBusiness.mergeData('control', controlConfig.sTbName, controlData, controlDelData));
data.push(commonBusiness.mergeData('materials', materialsConfig.sTbName, materialsData, materialsDelData));
data.push(commonBusiness.mergeData('process', processConfig.sTbName, processData, processDelData));
if (commonUtils.isNotEmptyObject(colorConfig)) {
data.push(commonBusiness.mergeData('color', colorConfig.sTbName, colorData, colorDelData));
}
this.props.onSaveData({
data, sClientType: '1', loading: false, sSysLogSrcId: masterData.sId, bIsUnCcg: false,
});
} else {
this.props.onButtonClick(name);
}
};
/* 上一条、下一条、首条、末条 */
handleSearchData = async (handleType) => {
const {
controlConfig, materialsConfig, processConfig, manyqtysConfig, packConfig
} = this.props;
const bReturn = await this.props.onSearchData(handleType);
if (bReturn) {
this.handleGetData(controlConfig, materialsConfig, processConfig, manyqtysConfig, undefined, packConfig);
}
};
/** 点击修改按钮操作 */
handleEdit = () => {
const {
controlConfig, materialsConfig, processConfig, manyqtysConfig, packConfig,
} = this.props;
this.props.onEdit(() => {
this.handleGetData(controlConfig, materialsConfig, processConfig, manyqtysConfig, undefined, packConfig, { loading: false, enabled: true });
});
};
/* 单据页复制到 */
handleCopyTo = async (name, sActiveId) => {
/* 待用数据声明 */
const {
masterConfig, masterData, slaveData, controlData, materialsData, processData, manyqtysData, packData, formRoute, colorData, app, token, sModelsId,
} = this.props;
// 从表有sCopyToCondition则不能复制,并提示
if (commonUtils.isNotEmptyArr(slaveData) && name.includes('.')) {
const sCopyToConditionIndex = slaveData.findIndex(item => item.sCopyToCondition);
if (sCopyToConditionIndex !== -1) {
message.warning(slaveData[sCopyToConditionIndex].sCopyToCondition);
return;
}
}
const copyTo = {};
const copyToConfig = masterConfig.gdsconfigformslave.filter(item => item.sControlName.includes(name));
copyTo.name = name;
copyTo.config = copyToConfig;
copyTo.masterData = masterData;
copyTo.slaveData = slaveData;
copyTo.controlData = controlData;
copyTo.materialsData = materialsData;
copyTo.processData = processData;
copyTo.manyqtysData = manyqtysData;
copyTo.packData = packData;
copyTo.colorData = colorData;
copyTo.srcFormRoute = formRoute;
const tbSuffix = '';
let sId = '';
if (!commonUtils.isEmpty(slaveData)) {
sId = slaveData[0].sId;
}
const dataUrl = `${commonConfig.server_host}bill/billCopyToCheck/?sModelsId=${sModelsId}&sActiveId=${sActiveId}&tbSuffix=${tbSuffix}&sName=${formRoute}`;
const values = { sSlaveId: sId };
const dataReturn = (await commonServices.postValueService(token, values, dataUrl)).data;
if (dataReturn.code === 1) {
// eslint-disable-next-line no-underscore-dangle
const _this = this; // 解决confirm中this指向问题;
if (dataReturn.dataset.rows.length > 0) {
confirm({
title: commonFunc.showMessage(app.commonConst, 'beUsedToNew'), /* 单据已存在,是否填写新单据 */
onOk() {
_this.handleDispatch(copyTo, sActiveId);
},
onCancel() {
},
});
} else {
this.handleDispatch(copyTo, sActiveId);
}
}
};
handleDispatch = (copyTo, sActiveId) => {
const { dispatch } = this.props;
dispatch({
type: 'content/onRouter',
payload: {
url: `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sActiveId}?sModelsId=${sActiveId}`, /* 接口地址 */
copyTo,
},
});
}
/* 确定要删除 */
handleOkDel = async (props) => {
/* 数据参数 */
const {
token, sModelsId, masterConfig, masterData, slaveConfig, checkConfig, controlConfig, materialsConfig, processConfig,
} = props;
const value = {
sClientType: '1',
data: {
sMasterTable: masterConfig.sTbName,
sId: [masterData.sId],
sSlaveTable: [
{
tableName: slaveConfig.sTbName,
relationName: 'sParentId',
}, {
tableName: checkConfig.sTbName,
relationName: 'sBillId',
}, {
tableName: controlConfig.sTbName,
relationName: 'sParentId',
}, {
tableName: materialsConfig.sTbName,
relationName: 'sParentId',
}, {
tableName: processConfig.sTbName,
relationName: 'sParentId',
}],
},
};
const { sBillNo, sId } = masterData || {};
const url = `${commonConfig.server_host}business/delMasSlaBusinessData?sModelsId=${sModelsId}&sBillNo=${sBillNo}&sSysLogSrcId=${sId}`;
/* 接收返回值 */
const { data } = await commonServices.postValueService(token, value, url);
if (data.code === 1) {
/* 数据删除成功 */
if (this.props.app.currentPane.refresh !== undefined) {
this.props.app.currentPane.refresh();
}
this.props.onDelDataSuccess(props);
} else { /* 失败 */
this.props.getServiceError(data);
}
};
/* 删除 */
handleDel = (obj) => {
const props = { ...this.props, ...this.state };
const onOkDel = this.handleOkDel;
confirm({
title: obj.title,
onOk() {
onOkDel(props);
},
onCancel() {
},
});
};
/* 取消操作 */
handleCancel = (obj) => {
/* 待用数据声明 */
const {
masterConfig, slaveConfig, checkConfig, controlConfig, materialsConfig, processConfig, manyqtysConfig, colorConfig, packConfig, app,
} = this.props;
const onGetData = this.props.onGetData;
const onGetDataOk = this.handleGetData;
const onSaveStateOk = this.props.onSaveState;
const onSendSocketMessage = this.props.handleSendSocketMessage;
const { copyTo } = app.currentPane;
const { userinfo } = app;
confirm({
title: obj.title,
onOk() {
onGetData(masterConfig, slaveConfig, checkConfig);
onGetDataOk(controlConfig, materialsConfig, processConfig, manyqtysConfig, colorConfig, packConfig);
onSaveStateOk({ enabled: false });
if (commonUtils.isNotEmptyObject(copyTo)) {
const { slaveData } = copyTo;
const sIdArray = [];
slaveData.forEach((item) => {
const redisKey = item.sSlaveId;
sIdArray.push(redisKey);
});
const sId = sIdArray.toString();
onSendSocketMessage('copyfinish', 'noAction', sId, userinfo.sId, null, null);
}
},
onCancel() {
},
});
};
/** 点击新增按钮 */
handleAdd = async (config, copyTo, isWait) => {
if (commonUtils.isEmptyObject(config)) {
const {
masterConfig, slaveConfig, controlConfig, processConfig, materialsConfig, manyqtysConfig, colorConfig,
} = this.props;
config = config === undefined ? {} : config;
config.masterConfig = masterConfig;
config.slaveConfig = slaveConfig;
config.materialsConfig = materialsConfig;
config.controlConfig = controlConfig;
config.processConfig = processConfig;
config.manyqtysConfig = manyqtysConfig;
config.colorConfig = colorConfig;
}
let state = await this.props.onAdd(config, copyTo, true);
let { slaveData, masterData } = state;
let controlData = [];
let packData = [];
let materialsData = [];
let processData = [];
const colorData = [];
const manyqtysData = [];
let bProductQtySelf = false;
if (commonUtils.isNotEmptyObject(this.props.masterConfig) && commonUtils.isNotEmptyArr(this.props.masterConfig.gdsconfigformslave)) {
const iProductQtyIndex = this.props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'bProductQtySelf');
if (iProductQtyIndex > -1) {
bProductQtySelf = true; /* 生产数量无需叠加 */
}
}
if (commonUtils.isNotEmptyObject(copyTo)) {
const {
app, sModelsId, token, sModelsType,
} = this.props;
const bCkxCopyFromTechnology = app.systemData.filter(item => item.sName === 'CkxCopyFromTechnology')[0].sValue;
if (bCkxCopyFromTechnology === '1') {
if (slaveData.length > 1) {
const dataUrl = `${commonConfig.server_host}business/getCopyToQuotationData/?sModelsId=${sModelsId}`;
const data = [];
data.push(commonBusiness.mergeData('master', `${config.masterConfig.sTbName.toLowerCase()}_Tmp`, [masterData], [], true));
data.push(commonBusiness.mergeData('slave', `${config.slaveConfig.sTbName.toLowerCase()}_tmp`, slaveData, [], true));
const value = {
data, sClientType: '1', sGuid: masterData.sId, sConfigId: copyTo.config[0].sId, sControlName: copyTo.name,
};
const dataReturn = (await commonServices.postValueService(token, value, dataUrl)).data;
if (dataReturn.code === 1) {
const valueReturn = dataReturn.dataset.rows[0];
const masterDataArr = valueReturn[`${config.masterConfig.sTbName.toLowerCase()}_tmp`];
if (commonUtils.isNotEmptyArr(masterDataArr)) {
masterData = masterDataArr[0];
}
slaveData = valueReturn[`${config.slaveConfig.sTbName.toLowerCase()}_tmp`];
controlData = valueReturn[`${config.controlConfig.sTbName.toLowerCase()}_tmp`];
packData = valueReturn[`${config.packConfig.sTbName.toLowerCase()}_tmp`];
materialsData = valueReturn[`${config.materialsConfig.sTbName.toLowerCase()}_tmp`];
processData = valueReturn[`${config.processConfig.sTbName.toLowerCase()}_tmp`];
processData = this.sortData(controlData, processData);
} else {
this.props.getServiceError(dataReturn.msg);
}
} else {
const sCustomerId = commonUtils.isEmptyStr(copyTo.masterData.sCustomerId) ? copyTo.slaveData[0].sCustomerId : copyTo.masterData.sCustomerId;
const sProductIdArray = [];
copyTo.slaveData.forEach((slaveItem) => {
const sProductId = slaveItem.sProductId;
if (commonUtils.isNotEmptyStr(sProductId)) {
sProductIdArray.push(sProductId);
}
});
const sProductIds = sProductIdArray.toString();
const condition = { sCustomerId, sProductIds };
const dataUrl = `${commonConfig.server_host}salesorder/getProcessCardDataByCustomIdProductId/?sModelsId=${sModelsId}`;
const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
if (dataReturn.code === 1) {
const returnData = dataReturn.dataset.rows[0];
const copyToMasterDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.masterdetail`.toLowerCase());
const copyToSlaveDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slavedetail`.toLowerCase());
const copyToControlConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.control`.toLowerCase());
const copyToMaterialsConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.materials`.toLowerCase());
const copyToProcessConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.process`.toLowerCase());
const copyToColorConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.param`.toLowerCase());
const copyToPackConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.pack`.toLowerCase());
const masterDetailAssignField = commonUtils.isNotEmptyArr(copyToMasterDetailConfig) ? copyToMasterDetailConfig[0].sAssignField : '';
const slaveDetailAssignField = commonUtils.isNotEmptyArr(copyToSlaveDetailConfig) ? copyToSlaveDetailConfig[0].sAssignField : '';
const controlAssignField = commonUtils.isNotEmptyArr(copyToControlConfig) ? copyToControlConfig[0].sAssignField : '';
const materialsAssignField = commonUtils.isNotEmptyArr(copyToMaterialsConfig) ? copyToMaterialsConfig[0].sAssignField : '';
const processAssignField = commonUtils.isNotEmptyArr(copyToProcessConfig) ? copyToProcessConfig[0].sAssignField : '';
const colorAssignField = commonUtils.isNotEmptyArr(copyToColorConfig) ? copyToColorConfig[0].sAssignField : '';
const packAssignField = commonUtils.isNotEmptyArr(copyToPackConfig) ? copyToPackConfig[0].sAssignField : '';
const bProcessAssort = true;
let returnProcessAssort = [];
let processAssignAssort = '';
let dropDownDataProcessName;
if (bProcessAssort) {
const dataUrl = `${commonConfig.server_host}salesorder/getProcessAssort?sModelsId=${sModelsId}`;
const dataProcessAssort = (await commonServices.postValueService(token, {}, dataUrl)).data;
if (dataProcessAssort.code === 1) {
returnProcessAssort = dataProcessAssort.dataset.rows[0].processassort;
const iIndex = config.processConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProcessName');
if (iIndex > -1) {
const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', config.processConfig.gdsconfigformslave[iIndex]);
dropDownDataProcessName = sqlDropDownData.dropDownData;
processAssignAssort = config.processConfig.gdsconfigformslave[iIndex].sAssignField;
}
}
}
const newCopyTo = {};
newCopyTo.master = copyTo.masterData;
newCopyTo.slave = commonUtils.isEmptyArr(slaveData) ? {} : slaveData[0];
if (commonUtils.isNotEmptyArr(returnData.controlData)) {
let dProductQty = 0;
if (commonUtils.isNotEmptyArr(returnData.slaveData)) {
masterData = { ...masterData, ...commonFunc.getAssignFieldValue(masterDetailAssignField, returnData.slaveData[0], newCopyTo) }; // 取赋值字段
}
slaveData.forEach((item, iSlaveIndex) => {
if (commonUtils.isNotEmptyArr(returnData.slaveData)) {
item = { ...item, ...commonFunc.getAssignFieldValue(slaveDetailAssignField, returnData.slaveData[0], newCopyTo) }; // 取赋值字段
}
slaveData[iSlaveIndex] = item;
if (bProductQtySelf) {
dProductQty += commonUtils.isNull(item.dProductQty, 0);
} else {
dProductQty += commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0);
}
});
const treeCopyNodes = new Map();
await returnData.controlData.forEach(async (controlItem) => {
newCopyTo.control = controlItem;
let controlRow = commonFunc.getDefaultData(config.controlConfig, newCopyTo); // 取默认值
controlRow = { ...controlRow, ...commonFunc.getAssignFieldValue(controlAssignField, controlItem, newCopyTo) }; // 取赋值字段
controlRow.handleType = 'add';
controlRow.sId = commonUtils.createSid();
controlRow.sParentId = masterData.sId;
controlRow.dPartsQty = dProductQty;
const sAllOldId = controlItem.sAllId;
let arr = [];
if (commonUtils.isNotEmptyObject(sAllOldId)) {
arr = sAllOldId.split(',');
}
const newId = controlRow.sId;
let sOldParentId = '';
let sNewParentAllId = '';
if (arr.length < 2) { /* 根节点复制 */
controlRow.sAllId = newId;
sOldParentId = newId;
sNewParentAllId = newId;
} else {
sOldParentId = arr[arr.length - 2];
if (treeCopyNodes.has(sOldParentId)) {
sNewParentAllId = treeCopyNodes.get(sOldParentId);
} else {
const obj = arr[arr.length - 1];
sNewParentAllId = sAllOldId.replace((`,${obj}`), '');
}
const sNewArr = sNewParentAllId.split(',');
controlRow.sControlParentId = sNewArr[sNewArr.length - 1];
sNewParentAllId = `${sNewParentAllId},${newId}`;
controlRow.sAllId = sNewParentAllId;
}
treeCopyNodes.set(controlItem.sId, sNewParentAllId);
controlData.push(controlRow);
/* 复制到时增加合版表 */
if (commonUtils.isNotEmptyArr(returnData.packData)) {
await copyTo.packData.filter(item => item.sControlId === controlItem.sId).forEach(async (packItem) => {
newCopyTo.pack = packItem;
let packRow = commonFunc.getDefaultData(config.packConfig, newCopyTo); // 取默认值
packRow = { ...packRow, ...commonFunc.getAssignFieldValue(packAssignField, packItem, newCopyTo) }; // 取赋值字段
packRow.sOriginalId = packItem.sId;/* 翻单前的sId */
/* sSlaveId赋值 */
const iSlaveIndex = slaveData.findIndex(item => item.sOriginalId === packItem.sSlaveId);
if (iSlaveIndex > -1) {
const slaveDataRow = slaveData[iSlaveIndex];
const packRowAdd = this.handlePackDataAdd(slaveDataRow, 0, controlRow.sId, 'add');
if (commonUtils.isNotEmptyObject(packRowAdd)) {
packRow = { ...packRow, ...packRowAdd };
packData.push(packRow);
}
}
});
}
if (commonUtils.isNotEmptyArr(returnData.processData)) {
returnData.processData.filter(item => item.sControlId === controlItem.sId && item.sType !== '3').forEach((processItem) => {
newCopyTo.process = processItem;
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sControlId = controlRow.sId;
processRow.sPartsName = controlRow.sPartsName;
/* 根据合版表的源sOriginalId找到新sId */
let sNewIds = '';
let sNewNames = '';
const sOldIds = processItem.sCombinePartsName;
if (commonUtils.isNotEmptyObject(sOldIds)) {
const sOldArr = sOldIds.split(',');
for (const sId of sOldArr) {
const index = packData.findIndex(item => item.sOriginalId === sId);
if (index > -1) {
const tableDataRow = packData[index];
sNewIds += `${tableDataRow.sId},`;
sNewNames += `${tableDataRow.sCustomerName}-${tableDataRow.sProductName}-${tableDataRow.sCombinePartsName},`;
}
}
sNewIds = commonUtils.isNotEmptyObject(sNewIds) ? sNewIds.substr(0, sNewIds.length - 1) : '';
sNewNames = commonUtils.isNotEmptyObject(sNewNames) ? sNewNames.substr(0, sNewNames.length - 1) : '';
}
processRow.sCombinePartsName = sNewIds;
processRow.sCombinePartsNameNew = sNewNames;
// if (commonUtils.isNotEmptyArr(slaveData)) {
// processRow.sSlaveId = slaveData[0].sId;
// }
processData.push(processRow);
// 配套工序
if (bProcessAssort) {
returnProcessAssort.filter(item => item.sParentId === processRow.sProcessId).forEach(((itemProcessAssort) => {
const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
const iProcessIndex = returnData.processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlItem.sId);
const iNewProcessIndex = processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlRow.sId);
if (iIndex > -1 && iProcessIndex < 0 && iNewProcessIndex < 0) {
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sControlId = controlRow.sId;
processRow.sPartsName = controlRow.sPartsName;
processRow.sType = dropDownDataProcessName[iIndex].sType;
// if (commonUtils.isNotEmptyArr(slaveData)) {
// processRow.sSlaveId = slaveData[0].sId;
// }
processData.push(processRow);
}
}));
}
});
}
if (commonUtils.isNotEmptyArr(returnData.materialsData)) {
await returnData.materialsData.filter(item => item.sControlId === controlItem.sId && item.sType !== '2').forEach(async (materialsItem) => {
newCopyTo.materials = materialsItem;
let materialsRow = commonFunc.getDefaultData(config.materialsConfig, newCopyTo); // 取默认值
materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
materialsRow.handleType = 'add';
materialsRow.sId = commonUtils.createSid();
materialsRow.sParentId = masterData.sId;
materialsRow.sControlId = controlRow.sId;
materialsRow.sPartsName = controlRow.sPartsName;
// if (commonUtils.isNotEmptyArr(slaveData)) {
// materialsRow.sSlaveId = slaveData[0].sId;
// }
if (Object.keys(materialsRow).length > 0 && Object.keys(materialsRow).findIndex(item => item === 'dMaterialsStockAuxiliaryQty') > -1) {
const urlMaterialsStock = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const valueMaterialsStock = {
sProName: 'Sp_Inventory_MaterialsInventoryV56',
paramsMap: {
sMaterialsGuid: materialsRow.sMaterialsId,
sMaterialsStyle: materialsRow.sMaterialsStyle,
sWarehouseGuid: materialsRow.sWarehouseId,
sLocationalGuid: materialsRow.sLocationId,
sWarehouseLocationGuid: materialsRow.sWarehouseLocationId,
sDefine_no: materialsRow.sDefineNo,
sDefine_no2: materialsRow.sDefineNo2,
iGetQty: 1,
iHasZero: 1,
},
};
const returnDataMaterialsStock = (await commonServices.postValueService(app.token, valueMaterialsStock, urlMaterialsStock)).data;
if (returnDataMaterialsStock.code === 1) {
materialsRow.dMaterialsStockAuxiliaryQty = returnDataMaterialsStock.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
}
}
if (Object.keys(materialsRow).length > 0 && Object.keys(materialsRow).findIndex(item => item === 'dMaterialsStockAvailableQty') > -1) {
const urlMaterialsAvailableQty = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const valueMaterialsAvailableQty = {
sProName: 'Sp_Inventory_MaterialsInventoryV56',
paramsMap: {
sMaterialsGuid: materialsRow.sMaterialsId,
sMaterialsStyle: materialsRow.sMaterialsStyle,
sWarehouseGuid: materialsRow.sWarehouseId,
sLocationalGuid: materialsRow.sLocationId,
sWarehouseLocationGuid: materialsRow.sWarehouseLocationId,
sDefine_no: materialsRow.sDefineNo,
sDefine_no2: materialsRow.sDefineNo2,
iGetQty: 2,
iHasZero: 1,
},
};
const returnDataMaterialsAvailableQty = (await commonServices.postValueService(app.token, valueMaterialsAvailableQty, urlMaterialsAvailableQty)).data;
if (returnDataMaterialsAvailableQty.code === 1) {
materialsRow.dMaterialsStockAvailableQty = returnDataMaterialsAvailableQty.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
}
}
// 材料对应工序的ID要变化
if (commonUtils.isNotEmptyArr(returnData.processData)) {
const iProcessIndex = processData.findIndex(item => item.sControlId === controlRow.sId && item.sSrcProcessTbId === materialsItem.sProcessTbId);
if (iProcessIndex > -1) {
materialsRow.sProcessTbId = processData[iProcessIndex].sId;
}
}
materialsData.push(materialsRow);
});
}
});
}
if (commonUtils.isNotEmptyArr(returnData.materialsData)) {
await returnData.materialsData.filter(item => item.sType === '2').forEach(async (materialsItem) => {
newCopyTo.materials = materialsItem;
let materialsRow = commonFunc.getDefaultData(config.materialsConfig, newCopyTo); // 取默认值
materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
materialsRow.handleType = 'add';
materialsRow.sId = commonUtils.createSid();
materialsRow.sParentId = masterData.sId;
// if (commonUtils.isNotEmptyArr(slaveData)) {
// materialsRow.sSlaveId = slaveData[0].sId;
// }
/* 根据从表源sOriginalId找到新sId */
let sNewIds = '';
let sNewNames = '';
const sOldIds = materialsItem.sCombinePartsName;
if (commonUtils.isNotEmptyObject(sOldIds)) {
const sOldArr = sOldIds.split(',');
for (const sId of sOldArr) {
const index = slaveData.findIndex(item => item.sOriginalId === sId);
if (index > -1) {
const tableDataRow = slaveData[index];
sNewIds += `${tableDataRow.sId},`;
sNewNames += `${tableDataRow.sProductName},`;
}
}
sNewIds = commonUtils.isNotEmptyObject(sNewIds) ? sNewIds.substr(0, sNewIds.length - 1) : '';
sNewNames = commonUtils.isNotEmptyObject(sNewNames) ? sNewNames.substr(0, sNewNames.length - 1) : '';
}
materialsRow.sCombinePartsName = sNewIds;
materialsRow.sCombinePartsNameNew = sNewNames;
if (Object.keys(materialsRow).length > 0 && Object.keys(materialsRow).findIndex(item => item === 'dMaterialsStockAuxiliaryQty') > -1) {
const urlMaterialsStock = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const valueMaterialsStock = {
sProName: 'Sp_Inventory_MaterialsInventoryV56',
paramsMap: {
sMaterialsGuid: materialsRow.sMaterialsId,
sMaterialsStyle: materialsRow.sMaterialsStyle,
sWarehouseGuid: materialsRow.sWarehouseId,
sLocationalGuid: materialsRow.sLocationId,
sWarehouseLocationGuid: materialsRow.sWarehouseLocationId,
sDefine_no: materialsRow.sDefineNo,
sDefine_no2: materialsRow.sDefineNo2,
iGetQty: 1,
iHasZero: 1,
},
};
const returnDataMaterialsStock = (await commonServices.postValueService(app.token, valueMaterialsStock, urlMaterialsStock)).data;
if (returnDataMaterialsStock.code === 1) {
materialsRow.dMaterialsStockAuxiliaryQty = returnDataMaterialsStock.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
}
}
if (Object.keys(materialsRow).length > 0 && Object.keys(materialsRow).findIndex(item => item === 'dMaterialsStockAvailableQty') > -1) {
const urlMaterialsAvailableQty = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const valueMaterialsAvailableQty = {
sProName: 'Sp_Inventory_MaterialsInventoryV56',
paramsMap: {
sMaterialsGuid: materialsRow.sMaterialsId,
sMaterialsStyle: materialsRow.sMaterialsStyle,
sWarehouseGuid: materialsRow.sWarehouseId,
sLocationalGuid: materialsRow.sLocationId,
sWarehouseLocationGuid: materialsRow.sWarehouseLocationId,
sDefine_no: materialsRow.sDefineNo,
sDefine_no2: materialsRow.sDefineNo2,
iGetQty: 2,
iHasZero: 1,
},
};
const returnDataMaterialsAvailableQty = (await commonServices.postValueService(app.token, valueMaterialsAvailableQty, urlMaterialsAvailableQty)).data;
if (returnDataMaterialsAvailableQty.code === 1) {
materialsRow.dMaterialsStockAvailableQty = returnDataMaterialsAvailableQty.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
}
}
materialsData.push(materialsRow);
});
}
if (commonUtils.isNotEmptyArr(returnData.processData)) {
returnData.processData.filter(item => item.sType === '3').forEach((processItem) => {
newCopyTo.process = processItem;
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
/* 根据合版表的源sOriginalId找到新sId */
let sNewIds = '';
let sNewNames = '';
const sOldIds = processItem.sCombinePartsName;
if (commonUtils.isNotEmptyObject(sOldIds)) {
const sOldArr = sOldIds.split(',');
for (const sId of sOldArr) {
const index = packData.findIndex(item => item.sOriginalId === sId);
if (index > -1) {
const tableDataRow = packData[index];
sNewIds += `${tableDataRow.sId},`;
sNewNames += `${tableDataRow.sCustomerName}-${tableDataRow.sProductName}-${tableDataRow.sCombinePartsName},`;
}
}
sNewIds = commonUtils.isNotEmptyObject(sNewIds) ? sNewIds.substr(0, sNewIds.length - 1) : '';
sNewNames = commonUtils.isNotEmptyObject(sNewNames) ? sNewNames.substr(0, sNewNames.length - 1) : '';
}
processRow.sCombinePartsName = sNewIds;
processRow.sCombinePartsNameNew = sNewNames;
processData.push(processRow);
// 成品配套工序
if (bProcessAssort) {
returnProcessAssort.filter(item => item.sParentId === processRow.sProcessId).forEach(((itemProcessAssort) => {
const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
const iProcessIndex = returnData.processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId);
const iNewProcessIndex = processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId);
if (iIndex > -1 && iProcessIndex < 0 && iNewProcessIndex < 0) {
if (itemProcessAssort.sType === 'single') {
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sType = dropDownDataProcessName[iIndex].sType;
// if (commonUtils.isNotEmptyArr(slaveData)) {
// processRow.sSlaveId = slaveData[0].sId;
// }
processData.push(processRow);
} else if (itemProcessAssort.sType === 'all') {
controlData.forEach((controlItem) => {
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sControlId = controlItem.sId;
processRow.sPartsName = controlItem.sPartsName;
processRow.sType = dropDownDataProcessName[iIndex].sType;
// if (commonUtils.isNotEmptyArr(slaveData)) {
// processRow.sSlaveId = slaveData[0].sId;
// }
processData.push(processRow);
});
}
}
}));
}
});
}
if (commonUtils.isNotEmptyArr(returnData.colorData)) {
if (commonUtils.isNotEmptyObject(config.colorConfig)) {
returnData.colorData.forEach((colorItem) => {
newCopyTo.color = colorItem;
let colorRow = commonFunc.getDefaultData(config.colorConfig, newCopyTo); // 取默认值
colorRow = { ...colorRow, ...commonFunc.getAssignFieldValue(colorAssignField, colorItem, newCopyTo) }; // 取赋值字段
colorRow.handleType = 'add';
colorRow.sId = commonUtils.createSid();
colorRow.sParentId = masterData.sId;
colorData.push(colorRow);
});
}
}
} else {
this.props.getServiceError(dataReturn.msg);
}
}
} else {
const copyToControlConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.control`.toLowerCase());
const copyToMaterialsConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.materials`.toLowerCase());
const copyToProcessConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.process`.toLowerCase());
const copyToManyqtysConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.manyqtys`.toLowerCase());
const copyToColorConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.param`.toLowerCase());
const copyToPackConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.pack`.toLowerCase());
const controlAssignField = commonUtils.isNotEmptyArr(copyToControlConfig) ? copyToControlConfig[0].sAssignField : '';
const materialsAssignField = commonUtils.isNotEmptyArr(copyToMaterialsConfig) ? copyToMaterialsConfig[0].sAssignField : '';
const processAssignField = commonUtils.isNotEmptyArr(copyToProcessConfig) ? copyToProcessConfig[0].sAssignField : '';
const manyqtysAssignField = commonUtils.isNotEmptyArr(copyToManyqtysConfig) ? copyToManyqtysConfig[0].sAssignField : '';
const colorAssignField = commonUtils.isNotEmptyArr(copyToColorConfig) ? copyToColorConfig[0].sAssignField : '';
const packAssignField = commonUtils.isNotEmptyArr(copyToPackConfig) ? copyToPackConfig[0].sAssignField : '';
const newCopyTo = {};
newCopyTo.master = copyTo.masterData;
newCopyTo.slave = commonUtils.isEmptyArr(slaveData) ? {} : slaveData[0];
let bProcessAssort = true;
/* 翻单不生成配套工序 */
if (sModelsType === 'quotation/quotation') {
bProcessAssort = false;
}
if (commonUtils.isEmptyArr(copyTo.controlData) && commonUtils.isNotEmptyArr(copyTo.slaveData)) {
const { token } = this.props;
const sParentId = commonUtils.isNotEmptyStr(copyTo.slaveData[0].sParentId) ? copyTo.slaveData[0].sParentId : copyTo.slaveData[0].sId;
// const condition = { sSlaveId: copyTo.slaveData[0].sSlaveId };
const condition = { sParentId };
const dataUrl = `${commonConfig.server_host}salesorder/getPartsInfo?sModelsId=${sModelsId}`;
const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
// bProcessAssort = false;
if (dataReturn.code === 1) {
const returnData = dataReturn.dataset.rows[0];
copyTo.controlData = returnData.controlData;
copyTo.materialsData = returnData.materialsData;
copyTo.processData = returnData.processData;
copyTo.packData = returnData.packData;
copyTo.colorData = returnData.colorData;
} else {
this.props.getServiceError(dataReturn);
}
}
let returnProcessAssort = [];
let processAssignAssort = '';
let dropDownDataProcessName;
if (bProcessAssort) {
const dataUrl = `${commonConfig.server_host}salesorder/getProcessAssort?sModelsId=${sModelsId}`;
const dataProcessAssort = (await commonServices.postValueService(token, {}, dataUrl)).data;
if (dataProcessAssort.code === 1) {
returnProcessAssort = dataProcessAssort.dataset.rows[0].processassort;
const iIndex = config.processConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProcessName');
if (iIndex > -1) {
const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', config.processConfig.gdsconfigformslave[iIndex]);
dropDownDataProcessName = sqlDropDownData.dropDownData;
processAssignAssort = config.processConfig.gdsconfigformslave[iIndex].sAssignField;
}
}
}
if (commonUtils.isNotEmptyArr(copyTo.controlData)) {
// let dProductQty = 0;
// slaveData.forEach((item) => {
// dProductQty += commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0);
// });
const treeCopyNodes = new Map();
await copyTo.controlData.forEach(async (controlItem) => {
newCopyTo.control = controlItem;
let controlRow = commonFunc.getDefaultData(config.controlConfig, newCopyTo); // 取默认值
controlRow = { ...controlRow, ...commonFunc.getAssignFieldValue(controlAssignField, controlItem, newCopyTo) }; // 取赋值字段
controlRow.handleType = 'add';
controlRow.sId = commonUtils.createSid();
controlRow.sParentId = masterData.sId;
// controlRow.dPartsQty = dProductQty;
// controlRow.sSlaveId = ' ';
/* CopyTo时sAllId,sControlParentId 设置 */
const sAllOldId = controlItem.sAllId;
let arr = [];
if (commonUtils.isNotEmptyObject(sAllOldId)) {
arr = sAllOldId.split(',');
}
const newId = controlRow.sId;
let sOldParentId = '';
let sNewParentAllId = '';
if (arr.length < 2) { /* 根节点复制 */
controlRow.sAllId = newId;
sOldParentId = newId;
sNewParentAllId = newId;
} else {
sOldParentId = arr[arr.length - 2];
if (treeCopyNodes.has(sOldParentId)) {
sNewParentAllId = treeCopyNodes.get(sOldParentId);
} else {
const obj = arr[arr.length - 1];
sNewParentAllId = sAllOldId.replace((`,${obj}`), '');
}
const sNewArr = sNewParentAllId.split(',');
controlRow.sControlParentId = sNewArr[sNewArr.length - 1];
sNewParentAllId = `${sNewParentAllId},${newId}`;
controlRow.sAllId = sNewParentAllId;
}
treeCopyNodes.set(controlItem.sId, sNewParentAllId);
controlData.push(controlRow);
/* 复制到时增加合版表 */
if (commonUtils.isNotEmptyArr(copyTo.packData)) {
await copyTo.packData.filter(item => item.sControlId === controlItem.sId).forEach(async (packItem) => {
newCopyTo.pack = packItem;
let packRow = commonFunc.getDefaultData(config.packConfig, newCopyTo); // 取默认值
packRow = { ...packRow, ...commonFunc.getAssignFieldValue(packAssignField, packItem, newCopyTo) }; // 取赋值字段
packRow.sOriginalId = packItem.sId;/* 翻单前的sId */
/* sSlaveId赋值 */
const iSlaveIndex = slaveData.findIndex(item => item.sOriginalId === packItem.sSlaveId);
if (iSlaveIndex > -1) {
const slaveDataRow = slaveData[iSlaveIndex];
const packRowAdd = this.handlePackDataAdd(slaveDataRow, 0, controlRow.sId, 'add');
if (commonUtils.isNotEmptyObject(packRowAdd)) {
packRow = { ...packRow, ...packRowAdd };
/* 将控制表中的合版备注sId为新的sId */
let JsonData = [];
const jsonStr = controlRow.sCombinedMemo;
if (commonUtils.isNotEmptyObject(jsonStr) && commonUtils.isJSON(jsonStr)) {
JsonData = JSON.parse(jsonStr);
if (commonUtils.isNotEmptyArr(JsonData)) {
let sCombinedMemoNew = '';
JsonData.forEach((item, index) => {
if (item.sId === packItem.sId) {
JsonData[index].sId = packRow.sId;
}
});
sCombinedMemoNew = JSON.stringify(JsonData);
controlRow.sCombinedMemo = sCombinedMemoNew;
const icontrolIndex = controlData.findIndex(item => item.sId === controlRow.sId);
if (icontrolIndex) {
controlData[icontrolIndex] = { ...controlData[icontrolIndex], sCombinedMemo: sCombinedMemoNew };
}
}
}
packData.push(packRow);
}
}
});
}
if (commonUtils.isNotEmptyArr(copyTo.processData)) {
copyTo.processData.filter(item => item.sControlId === controlItem.sId && item.sType !== '3').forEach((processItem) => {
newCopyTo.process = processItem;
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sControlId = controlRow.sId;
processRow.sPartsName = controlRow.sPartsName;
processRow.sType = processItem.sType;
/* 根据合版表的源sOriginalId找到新sId */
let sNewIds = '';
let sNewNames = '';
const sOldIds = processItem.sCombinePartsName;
if (commonUtils.isNotEmptyObject(sOldIds)) {
const sOldArr = sOldIds.split(',');
for (const sId of sOldArr) {
const index = packData.findIndex(item => item.sOriginalId === sId);
if (index > -1) {
const tableDataRow = packData[index];
sNewIds += `${tableDataRow.sId},`;
sNewNames += `${tableDataRow.sCustomerName}-${tableDataRow.sProductName}-${tableDataRow.sCombinePartsName},`;
}
}
sNewIds = commonUtils.isNotEmptyObject(sNewIds) ? sNewIds.substr(0, sNewIds.length - 1) : '';
sNewNames = commonUtils.isNotEmptyObject(sNewNames) ? sNewNames.substr(0, sNewNames.length - 1) : '';
}
processRow.sCombinePartsName = sNewIds;
processRow.sCombinePartsNameNew = sNewNames;
// processRow.sSlaveId = ' ';
processData.push(processRow);
if (bProcessAssort) {
returnProcessAssort.filter(item => item.sParentId === processRow.sProcessId).forEach(((itemProcessAssort) => {
const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
const iProcessIndex = copyTo.processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlItem.sId);
const iNewProcessIndex = processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlRow.sId);
if (iIndex > -1 && iProcessIndex < 0 && iNewProcessIndex < 0) {
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sControlId = controlRow.sId;
processRow.sPartsName = controlRow.sPartsName;
processRow.sType = dropDownDataProcessName[iIndex].sType;
// processRow.sSlaveId = slaveData[0].sId;
processData.push(processRow);
}
}));
}
});
}
if (commonUtils.isNotEmptyArr(copyTo.materialsData)) {
await copyTo.materialsData.filter(item => item.sControlId === controlItem.sId && item.sType !== '2').forEach(async (materialsItem) => {
newCopyTo.materials = materialsItem;
let materialsRow = commonFunc.getDefaultData(config.materialsConfig, newCopyTo); // 取默认值
materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
materialsRow.handleType = 'add';
materialsRow.sId = commonUtils.createSid();
materialsRow.sParentId = masterData.sId;
materialsRow.sControlId = controlRow.sId;
materialsRow.sPartsName = controlRow.sPartsName;
materialsRow.sType = materialsItem.sType;
// materialsRow.sSlaveId = slaveData[0].sId;
if (Object.keys(materialsRow).length > 0 && Object.keys(materialsRow).findIndex(item => item === 'dMaterialsStockAuxiliaryQty') > -1) {
const urlMaterialsStock = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const valueMaterialsStock = {
sProName: 'Sp_Inventory_MaterialsInventoryV56',
paramsMap: {
sMaterialsGuid: materialsRow.sMaterialsId,
sMaterialsStyle: materialsRow.sMaterialsStyle,
sWarehouseGuid: materialsRow.sWarehouseId,
sLocationalGuid: materialsRow.sLocationId,
sWarehouseLocationGuid: materialsRow.sWarehouseLocationId,
sDefine_no: materialsRow.sDefineNo,
sDefine_no2: materialsRow.sDefineNo2,
iGetQty: 1,
iHasZero: 1,
},
};
const returnDataMaterialsStock = (await commonServices.postValueService(app.token, valueMaterialsStock, urlMaterialsStock)).data;
if (returnDataMaterialsStock.code === 1) {
materialsRow.dMaterialsStockAuxiliaryQty = returnDataMaterialsStock.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
}
}
if (Object.keys(materialsRow).length > 0 && Object.keys(materialsRow).findIndex(item => item === 'dMaterialsStockAvailableQty') > -1) {
const urlMaterialsAvailableQty = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const valueMaterialsAvailableQty = {
sProName: 'Sp_Inventory_MaterialsInventoryV56',
paramsMap: {
sMaterialsGuid: materialsRow.sMaterialsId,
sMaterialsStyle: materialsRow.sMaterialsStyle,
sWarehouseGuid: materialsRow.sWarehouseId,
sLocationalGuid: materialsRow.sLocationId,
sWarehouseLocationGuid: materialsRow.sWarehouseLocationId,
sDefine_no: materialsRow.sDefineNo,
sDefine_no2: materialsRow.sDefineNo2,
iGetQty: 2,
iHasZero: 1,
},
};
const returnDataMaterialsAvailableQty = (await commonServices.postValueService(app.token, valueMaterialsAvailableQty, urlMaterialsAvailableQty)).data;
if (returnDataMaterialsAvailableQty.code === 1) {
materialsRow.dMaterialsStockAvailableQty = returnDataMaterialsAvailableQty.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
}
}
// 材料对应工序的ID要变化
if (commonUtils.isNotEmptyArr(copyTo.processData)) {
const iProcessIndex = processData.findIndex(item => item.sControlId === controlRow.sId && item.sSrcProcessTbId === materialsItem.sProcessTbId);
if (iProcessIndex > -1) {
materialsRow.sProcessTbId = processData[iProcessIndex].sId;
}
}
materialsData.push(materialsRow);
});
}
});
}
if (commonUtils.isNotEmptyArr(copyTo.materialsData)) {
await copyTo.materialsData.filter(item => item.sType === '2').forEach(async (materialsItem) => {
newCopyTo.materials = materialsItem;
let materialsRow = commonFunc.getDefaultData(config.materialsConfig, newCopyTo); // 取默认值
materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
materialsRow.handleType = 'add';
materialsRow.sId = commonUtils.createSid();
materialsRow.sParentId = masterData.sId;
materialsRow.sType = materialsItem.sType;
// materialsRow.sSlaveId = slaveData[0].sId;
/* 根据从表源sOriginalId找到新sId */
let sNewIds = '';
let sNewNames = '';
const sOldIds = materialsItem.sCombinePartsName;
if (commonUtils.isNotEmptyObject(sOldIds)) {
const sOldArr = sOldIds.split(',');
for (const sId of sOldArr) {
const index = slaveData.findIndex(item => item.sOriginalId === sId);
if (index > -1) {
const tableDataRow = slaveData[index];
sNewIds += `${tableDataRow.sId},`;
sNewNames += `${tableDataRow.sProductName},`;
}
}
sNewIds = commonUtils.isNotEmptyObject(sNewIds) ? sNewIds.substr(0, sNewIds.length - 1) : '';
sNewNames = commonUtils.isNotEmptyObject(sNewNames) ? sNewNames.substr(0, sNewNames.length - 1) : '';
}
materialsRow.sCombinePartsName = sNewIds;
materialsRow.sCombinePartsNameNew = sNewNames;
if (Object.keys(materialsRow).length > 0 && Object.keys(materialsRow).findIndex(item => item === 'dMaterialsStockAuxiliaryQty') > -1) {
const urlMaterialsStock = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const valueMaterialsStock = {
sProName: 'Sp_Inventory_MaterialsInventoryV56',
paramsMap: {
sMaterialsGuid: materialsRow.sMaterialsId,
sMaterialsStyle: materialsRow.sMaterialsStyle,
sWarehouseGuid: materialsRow.sWarehouseId,
sLocationalGuid: materialsRow.sLocationId,
sWarehouseLocationGuid: materialsRow.sWarehouseLocationId,
sDefine_no: materialsRow.sDefineNo,
sDefine_no2: materialsRow.sDefineNo2,
iGetQty: 1,
iHasZero: 1,
},
};
const returnDataMaterialsStock = (await commonServices.postValueService(app.token, valueMaterialsStock, urlMaterialsStock)).data;
if (returnDataMaterialsStock.code === 1) {
materialsRow.dMaterialsStockAuxiliaryQty = returnDataMaterialsStock.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
}
}
if (Object.keys(materialsRow).length > 0 && Object.keys(materialsRow).findIndex(item => item === 'dMaterialsStockAvailableQty') > -1) {
const urlMaterialsAvailableQty = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const valueMaterialsAvailableQty = {
sProName: 'Sp_Inventory_MaterialsInventoryV56',
paramsMap: {
sMaterialsGuid: materialsRow.sMaterialsId,
sMaterialsStyle: materialsRow.sMaterialsStyle,
sWarehouseGuid: materialsRow.sWarehouseId,
sLocationalGuid: materialsRow.sLocationId,
sWarehouseLocationGuid: materialsRow.sWarehouseLocationId,
sDefine_no: materialsRow.sDefineNo,
sDefine_no2: materialsRow.sDefineNo2,
iGetQty: 2,
iHasZero: 1,
},
};
const returnDataMaterialsAvailableQty = (await commonServices.postValueService(app.token, valueMaterialsAvailableQty, urlMaterialsAvailableQty)).data;
if (returnDataMaterialsAvailableQty.code === 1) {
materialsRow.dMaterialsStockAvailableQty = returnDataMaterialsAvailableQty.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
}
}
materialsData.push(materialsRow);
});
}
if (commonUtils.isNotEmptyArr(copyTo.processData)) {
copyTo.processData.filter(item => item.sType === '3').forEach((processItem) => {
newCopyTo.process = processItem;
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sType = processItem.sType;
/* 根据从表的源sOriginalId找到新sId */
let sNewIds = '';
let sNewNames = '';
const sOldIds = processItem.sCombinePartsName;
if (commonUtils.isNotEmptyObject(sOldIds)) {
const sOldArr = sOldIds.split(',');
for (const sId of sOldArr) {
const index = slaveData.findIndex(item => item.sOriginalId === sId);
if (index > -1) {
const tableDataRow = slaveData[index];
sNewIds += `${tableDataRow.sId},`;
sNewNames += `${tableDataRow.sCustomerName}-${tableDataRow.sProductName},`;
}
}
sNewIds = commonUtils.isNotEmptyObject(sNewIds) ? sNewIds.substr(0, sNewIds.length - 1) : '';
sNewNames = commonUtils.isNotEmptyObject(sNewNames) ? sNewNames.substr(0, sNewNames.length - 1) : '';
}
processRow.sCombinePartsName = sNewIds;
processRow.sCombinePartsNameNew = sNewNames;
// processRow.sSlaveId = slaveData[0].sId;
processData.push(processRow);
if (bProcessAssort) {
returnProcessAssort.filter(item => item.sParentId === processRow.sProcessId).forEach(((itemProcessAssort) => {
const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
const iProcessIndex = copyTo.processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId);
const iNewProcessIndex = processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId);
if (iIndex > -1 && iProcessIndex < 0 && iNewProcessIndex < 0) {
if (itemProcessAssort.sType === 'single') {
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sType = dropDownDataProcessName[iIndex].sType;
// processRow.sSlaveId = slaveData[0].sId;
processData.push(processRow);
} else if (itemProcessAssort.sType === 'all') {
controlData.forEach((controlItem) => {
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sControlId = controlItem.sId;
processRow.sPartsName = controlItem.sPartsName;
processRow.sType = dropDownDataProcessName[iIndex].sType;
// processRow.sSlaveId = slaveData[0].sId;
processData.push(processRow);
});
}
}
}));
}
});
}
if (commonUtils.isNotEmptyArr(copyTo.manyqtysData)) {
copyTo.manyqtysData.forEach((manyqtysItem) => {
newCopyTo.manyqtys = manyqtysItem;
let manyqtyRow = commonFunc.getDefaultData(config.manyqtysConfig, newCopyTo); // 取默认值
manyqtyRow = { ...manyqtyRow, ...commonFunc.getAssignFieldValue(manyqtysAssignField, manyqtysItem, newCopyTo) }; // 取赋值字段
manyqtyRow.handleType = 'add';
manyqtyRow.sId = commonUtils.createSid();
manyqtyRow.sParentId = masterData.sId;
manyqtysData.push(manyqtyRow);
});
}
if (commonUtils.isNotEmptyArr(copyTo.colorData)) {
if (commonUtils.isNotEmptyObject(config.colorConfig)) {
copyTo.colorData.forEach((colorItem) => {
newCopyTo.color = colorItem;
let colorRow = commonFunc.getDefaultData(config.colorConfig, newCopyTo); // 取默认值
colorRow = { ...colorRow, ...commonFunc.getAssignFieldValue(colorAssignField, colorItem, newCopyTo) }; // 取赋值字段
colorRow.handleType = 'add';
colorRow.sId = commonUtils.createSid();
colorRow.sParentId = masterData.sId;
colorData.push(colorRow);
});
}
}
}
if (controlData.length === 0) {
if (!commonUtils.isEmpty(slaveData[0].sProductId)) {
const iIndex = config.slaveConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProductName');
if (iIndex > -1) {
const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', config.slaveConfig.gdsconfigformslave[iIndex]);
const dropDownData = sqlDropDownData.dropDownData;
const [changeData] = dropDownData.filter(item => item.sProductId === slaveData[0].sProductId);
const sParentId = commonUtils.isEmpty(changeData) ? '' : changeData.sParentId;
if (!commonUtils.isEmpty(sParentId)) {
const iIndex = config.masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProductClassifyName');
if (iIndex > -1) {
let dProductQty = 0;
slaveData.forEach((item) => {
if (bProductQtySelf) {
dProductQty += commonUtils.isNull(item.dProductQty, 0);
} else {
dProductQty += commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0);
}
});
const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', config.masterConfig.gdsconfigformslave[iIndex]);
const dropDownData = sqlDropDownData.dropDownData;
const [changeData] = dropDownData.filter(item => item.sId === sParentId);
const sAllPartsName = commonUtils.isEmpty(changeData) ? '' : changeData.sAllPartsName;
if (commonUtils.isNotEmptyStr(sAllPartsName)) {
const sAssignFieldObj = sAllPartsName.split(',');
for (const child of sAssignFieldObj) {
let allTableData = {};
allTableData = {};
allTableData.master = masterData;
allTableData.slave = commonUtils.isEmptyArr(slaveData) ? {} : slaveData[0];
const tableDataRow = commonFunc.getDefaultData(config.controlConfig, allTableData);
tableDataRow.handleType = 'add';
tableDataRow.sId = commonUtils.createSid();
tableDataRow.sParentId = masterData && masterData.sId ? masterData.sId : null;
tableDataRow.key = tableDataRow.sId;
tableDataRow.bDefault = false;
tableDataRow.iOrder = 0;
tableDataRow.sPartsName = child;
tableDataRow.dPartsQty = dProductQty;
tableDataRow.sAllId = tableDataRow.sId;
tableDataRow.sControlParentId = '';
// tableDataRow.sSlaveId = slaveData[0].sId;
controlData.push(tableDataRow);
}
}
}
}
}
}
} else {
processData = this.sortData(controlData, processData);
}
} else {
state.fastOrderModalVisible = this.props.bFastOrderView;
const { sModelsId } = this.props;
if (commonUtils.isEmpty(masterData.sProductClassifyId)) {
const iIndex = config.masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProductClassifyName');
if (iIndex > -1) {
const returnValue = {};
const { sAssignField } = config.masterConfig.gdsconfigformslave[iIndex];
const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', config.masterConfig.gdsconfigformslave[iIndex]);
const dropDownData = sqlDropDownData.dropDownData;
const [changeData] = dropDownData.filter(item => item.sType === 'huace');
if (!commonUtils.isEmpty(sAssignField)) {
/* 赋值数组 */
const sAssignFieldObj = sAssignField.split(',');
if (commonUtils.isNotEmptyObject(changeData)) {
for (const child of sAssignFieldObj) {
if (child.indexOf(':') > -1) {
const sFieldName = child.split(':')[0].trim();
const sValueName = child.split(':')[1].trim();
returnValue[sFieldName] = changeData[sValueName];
}
}
}
}
const changeValue = isWait ? { ...masterData, ...returnValue } : returnValue;
const addState = await this.handleMasterChange('master', 'sProductClassifyName', changeValue, masterData.sId, null, { masterData, masterConfig: config.masterConfig }, true);
state = { ...state, ...addState };
}
}
}
if (controlData.length === 0) {
const allTableData = {};
allTableData.master = masterData;
allTableData.slave = commonUtils.isEmptyArr(slaveData) ? {} : slaveData[0];
const tableDataRow = commonFunc.getDefaultData(config.controlConfig, allTableData);
tableDataRow.handleType = 'add';
tableDataRow.sId = commonUtils.createSid();
tableDataRow.sParentId = masterData && masterData.sId ? masterData.sId : null;
tableDataRow.key = tableDataRow.sId;
tableDataRow.bDefault = false;
tableDataRow.iOrder = 1;
tableDataRow.sSlaveId = ' ';
tableDataRow.sCombinedMemo = '合版信息';
tableDataRow.sAllId = tableDataRow.sId;
let dProductQty = 0;
slaveData.forEach((item) => {
if (bProductQtySelf) {
dProductQty += commonUtils.isNull(item.dProductQty, 0);
} else {
dProductQty += commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0);
}
});
tableDataRow.dPartsQty = dProductQty;
controlData.push(tableDataRow);
}
/* 新增时,增加一条合版信息 */
if (packData.length === 0) {
slaveData.forEach((item, index) => {
const tableDataRow = this.handlePackDataAdd(item, index, controlData[0].sId, 'add');
if (commonUtils.isNotEmptyObject(tableDataRow)) {
// tableDataRow.dCombineQty = 1;
packData.push(tableDataRow);
}
});
}
const treeState = this.handleGetControlTreeData(controlData, true); /* 加载树形结构数据 */
const stateNew = {
...state,
...treeState,
// slaveSelectedRowKeys: commonUtils.isEmptyArr(controlData) ? [] : [controlData[0].sSlaveId],
controlData,
// controlSelectedRowKeys: commonUtils.isEmptyArr(controlData) ? [] : [controlData[0].sId],
controlSelectedRowKeys: [],
packData,
materialsData,
materialsSelectedRowKeys: [],
processData,
colorData,
processSelectedRowKeys: [],
checkProcessClassifyData: [],
manyqtysData,
manyqtysSelectedRowKeys: [],
};
if (isWait) {
return stateNew;
} else {
this.props.onSaveState(stateNew);
}
};
handleSelect = async (name, selectConfig, selectData) => {
const {
[`${name}Data`]: tableData, [`${name}Config`]: tableConfig, masterConfig, controlSelectedRowKeys, sModelsId, token,
slaveConfig, controlConfig, materialsConfig, processConfig, colorConfig, slaveData, controlData: controlDataOld, materialsData: materialsDataOld, processData: processDataOld, colorData: colorDataOld,
controlDelData: controlDelDataOld, materialsDelData: materialsDelDataOld, processDelData: processDelDataOld, colorDelData: colorDelDataOld,
} = this.props;
let { masterData } = this.props;
if (name === 'productProcessInfo') {
if (commonUtils.isNotEmptyArr(selectData)) {
const controlData = [];
const materialsData = [];
const processData = [];
const colorData = [];
const addState = {};
const controlDelData = commonUtils.isEmptyArr(controlDelDataOld) ? [] : controlDelDataOld;
const materialsDelData = commonUtils.isEmptyArr(materialsDelDataOld) ? [] : materialsDelDataOld;
const processDelData = commonUtils.isEmptyArr(processDelDataOld) ? [] : processDelDataOld;
const colorDelData = commonUtils.isEmptyArr(colorDelDataOld) ? [] : colorDelDataOld;
controlDataOld.forEach((item) => {
item.handleType = 'del';
controlDelData.push(item);
});
addState.controlDelData = controlDelData;
materialsDataOld.forEach((item) => {
item.handleType = 'del';
materialsDelData.push(item);
});
addState.materialsDelData = materialsDelData;
processDataOld.forEach((item) => {
item.handleType = 'del';
processDelData.push(item);
});
if (commonUtils.isNotEmptyArr(colorDataOld) && colorDataOld.length > 0) {
colorDataOld.forEach((item) => {
item.handleType = 'del';
colorDelData.push(item);
});
}
addState.colorDelData = colorDelData;
addState.processDelData = processDelData;
const config = {};
config.masterConfig = masterConfig;
config.slaveConfig = slaveConfig;
config.controlConfig = controlConfig;
config.materialsConfig = materialsConfig;
config.processConfig = processConfig;
config.colorConfig = colorConfig;
const condition = { sCardId: selectData[0].sId };
const dataUrl = `${commonConfig.server_host}salesorder/getProcessCardDataByCustomIdProductId/?sModelsId=${sModelsId}`;
const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
if (dataReturn.code === 1) {
const copyTo = { config: masterConfig.gdsconfigformslave, name: selectConfig.sControlName };
const returnData = dataReturn.dataset.rows[0];
const copyToMasterDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}`.toLowerCase());
const copyToSlaveDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave`.toLowerCase());
const copyToControlConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.control`.toLowerCase());
const copyToMaterialsConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.materials`.toLowerCase());
const copyToProcessConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.process`.toLowerCase());
const copyToColorConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.param`.toLowerCase());
const masterDetailAssignField = commonUtils.isNotEmptyArr(copyToMasterDetailConfig) ? copyToMasterDetailConfig[0].sAssignField : '';
const slaveDetailAssignField = commonUtils.isNotEmptyArr(copyToSlaveDetailConfig) ? copyToSlaveDetailConfig[0].sAssignField : '';
const controlAssignField = commonUtils.isNotEmptyArr(copyToControlConfig) ? copyToControlConfig[0].sAssignField : '';
const materialsAssignField = commonUtils.isNotEmptyArr(copyToMaterialsConfig) ? copyToMaterialsConfig[0].sAssignField : '';
const processAssignField = commonUtils.isNotEmptyArr(copyToProcessConfig) ? copyToProcessConfig[0].sAssignField : '';
const colorAssignField = commonUtils.isNotEmptyArr(copyToColorConfig) ? copyToColorConfig[0].sAssignField : '';
const newCopyTo = {};
newCopyTo.master = copyTo.masterData;
newCopyTo.slave = commonUtils.isEmptyArr(slaveData) ? {} : slaveData[0];
const bProcessAssort = true;
let returnProcessAssort = [];
let processAssignAssort = '';
let dropDownDataProcessName;
if (bProcessAssort) {
const dataUrl = `${commonConfig.server_host}salesorder/getProcessAssort?sModelsId=${sModelsId}`;
const dataProcessAssort = (await commonServices.postValueService(token, {}, dataUrl)).data;
if (dataProcessAssort.code === 1) {
returnProcessAssort = dataProcessAssort.dataset.rows[0].processassort;
const iIndex = config.processConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProcessName');
if (iIndex > -1) {
const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', config.processConfig.gdsconfigformslave[iIndex]);
dropDownDataProcessName = sqlDropDownData.dropDownData;
processAssignAssort = config.processConfig.gdsconfigformslave[iIndex].sAssignField;
}
}
}
if (commonUtils.isNotEmptyArr(returnData.controlData)) {
let dProductQty = 0;
let bProductQtySelf = false;
if (commonUtils.isNotEmptyObject(this.props.masterConfig) && commonUtils.isNotEmptyArr(this.props.masterConfig.gdsconfigformslave)) {
const iProductQtyIndex = this.props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'bProductQtySelf');
if (iProductQtyIndex > -1) {
bProductQtySelf = true; /* 生产数量无需叠加 */
}
}
if (commonUtils.isNotEmptyArr(returnData.slaveData)) {
masterData = { ...masterData, ...commonFunc.getAssignFieldValue(masterDetailAssignField, returnData.slaveData[0], newCopyTo) }; // 取赋值字段
}
slaveData.forEach((item, iSlaveIndex) => {
if (commonUtils.isNotEmptyArr(returnData.slaveData)) {
item = { ...item, ...commonFunc.getAssignFieldValue(slaveDetailAssignField, returnData.slaveData[0], newCopyTo) }; // 取赋值字段
}
slaveData[iSlaveIndex] = item;
if (bProductQtySelf) {
dProductQty += commonUtils.isNull(item.dProductQty, 0);
} else {
dProductQty += commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0);
}
});
const treeCopyNodes = new Map();
returnData.controlData.forEach((controlItem) => {
newCopyTo.control = controlItem;
let controlRow = commonFunc.getDefaultData(config.controlConfig, newCopyTo); // 取默认值
controlRow = { ...controlRow, ...commonFunc.getAssignFieldValue(controlAssignField, controlItem, newCopyTo) }; // 取赋值字段
controlRow.handleType = 'add';
controlRow.sId = commonUtils.createSid();
controlRow.sParentId = masterData.sId;
controlRow.dPartsQty = dProductQty;
const sAllOldId = controlItem.sAllId;
let arr = [];
if (commonUtils.isNotEmptyObject(sAllOldId)) {
arr = sAllOldId.split(',');
}
const newId = controlRow.sId;
let sOldParentId = '';
let sNewParentAllId = '';
if (arr.length < 2) { /* 根节点复制 */
controlRow.sAllId = newId;
sOldParentId = newId;
sNewParentAllId = newId;
} else {
sOldParentId = arr[arr.length - 2];
if (treeCopyNodes.has(sOldParentId)) {
sNewParentAllId = treeCopyNodes.get(sOldParentId);
} else {
const obj = arr[arr.length - 1];
sNewParentAllId = sAllOldId.replace((`,${obj}`), '');
}
const sNewArr = sNewParentAllId.split(',');
controlRow.sControlParentId = sNewArr[sNewArr.length - 1];
sNewParentAllId = `${sNewParentAllId},${newId}`;
controlRow.sAllId = sNewParentAllId;
}
treeCopyNodes.set(controlItem.sId, sNewParentAllId);
// const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
// if (iSlaveIndex > -1) {
// controlRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
controlData.push(controlRow);
if (commonUtils.isNotEmptyArr(returnData.processData)) {
returnData.processData.filter(item => item.sControlId === controlItem.sId && item.sType !== '3').forEach((processItem) => {
newCopyTo.process = processItem;
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sControlId = controlRow.sId;
processRow.sPartsName = controlRow.sPartsName;
// const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
// if (iSlaveIndex > -1) {
// processRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
processData.push(processRow);
// 配套工序
if (bProcessAssort) {
returnProcessAssort.filter(item => item.sParentId === processRow.sProcessId).forEach(((itemProcessAssort) => {
const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
const iProcessIndex = returnData.processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlItem.sId);
const iNewProcessIndex = processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlRow.sId);
if (iIndex > -1 && iProcessIndex < 0 && iNewProcessIndex < 0) {
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sControlId = controlRow.sId;
processRow.sPartsName = controlRow.sPartsName;
processRow.sType = dropDownDataProcessName[iIndex].sType;
// const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
// if (iSlaveIndex > -1) {
// processRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
processData.push(processRow);
}
}));
}
});
}
if (commonUtils.isNotEmptyArr(returnData.materialsData)) {
returnData.materialsData.filter(item => item.sControlId === controlItem.sId && item.sType !== '2').forEach((materialsItem) => {
newCopyTo.materials = materialsItem;
let materialsRow = commonFunc.getDefaultData(config.materialsConfig, newCopyTo); // 取默认值
materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
materialsRow.handleType = 'add';
materialsRow.sId = commonUtils.createSid();
materialsRow.sParentId = masterData.sId;
materialsRow.sControlId = controlRow.sId;
materialsRow.sPartsName = controlRow.sPartsName;
// const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
// if (iSlaveIndex > -1) {
// materialsRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
// 材料对应工序的ID要变化
if (commonUtils.isNotEmptyArr(returnData.processData)) {
const iProcessIndex = processData.findIndex(item => item.sControlId === controlRow.sId && item.sSrcProcessTbId === materialsItem.sProcessTbId);
if (iProcessIndex > -1) {
materialsRow.sProcessTbId = processData[iProcessIndex].sId;
}
}
materialsData.push(materialsRow);
});
}
});
}
if (commonUtils.isNotEmptyArr(returnData.materialsData)) {
returnData.materialsData.filter(item => item.sType === '2').forEach((materialsItem) => {
newCopyTo.materials = materialsItem;
let materialsRow = commonFunc.getDefaultData(config.materialsConfig, newCopyTo); // 取默认值
materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
materialsRow.handleType = 'add';
materialsRow.sId = commonUtils.createSid();
materialsRow.sParentId = masterData.sId;
// const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
// if (iSlaveIndex > -1) {
// materialsRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
materialsData.push(materialsRow);
});
}
if (commonUtils.isNotEmptyArr(returnData.processData)) {
returnData.processData.filter(item => item.sType === '3').forEach((processItem) => {
newCopyTo.process = processItem;
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
// const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
// if (iSlaveIndex > -1) {
// processRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
processData.push(processRow);
// 成品配套工序
if (bProcessAssort) {
returnProcessAssort.filter(item => item.sParentId === processRow.sProcessId).forEach(((itemProcessAssort) => {
const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
const iProcessIndex = returnData.processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId);
const iNewProcessIndex = processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId);
if (iIndex > -1 && iProcessIndex < 0 && iNewProcessIndex < 0) {
if (itemProcessAssort.sType === 'single') {
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sType = dropDownDataProcessName[iIndex].sType;
// const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
// if (iSlaveIndex > -1) {
// processRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
processData.push(processRow);
} else if (itemProcessAssort.sType === 'all') {
controlData.forEach((controlItem) => {
let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sControlId = controlItem.sId;
processRow.sPartsName = controlItem.sPartsName;
processRow.sType = dropDownDataProcessName[iIndex].sType;
// const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
// if (iSlaveIndex > -1) {
// processRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
processData.push(processRow);
});
}
}
}));
}
});
}
if (commonUtils.isNotEmptyArr(returnData.colorData)) {
if (commonUtils.isNotEmptyObject(config.colorConfig)) {
returnData.colorData.forEach((colorItem) => {
newCopyTo.color = colorItem;
let colorRow = commonFunc.getDefaultData(config.colorConfig, newCopyTo); // 取默认值
colorRow = { ...colorRow, ...commonFunc.getAssignFieldValue(colorAssignField, colorItem, newCopyTo) }; // 取赋值字段
colorRow.handleType = 'add';
colorRow.sId = commonUtils.createSid();
colorRow.sParentId = masterData.sId;
colorData.push(colorRow);
});
}
}
const treeState = this.handleGetControlTreeData(controlData, true);
this.props.onSaveState({
[`${name}ChooseVisible`]: false,
processData,
materialsData,
controlData,
...treeState,
colorData,
controlSelectedRowKeys: ['0000000'],
materialsSelectedRowKeys: [],
processSelectedRowKeys: [],
...addState,
});
} else {
this.props.getServiceError(dataReturn.msg);
}
}
} else {
const { controlData } = this.props;
const iControlIndex = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]) : -1;
if (commonUtils.isNotEmptyArr(selectData)) {
for (const item of selectData) {
const newCopyTo = {};
newCopyTo.master = masterData;
if (iControlIndex > -1) {
newCopyTo.control = controlData[iControlIndex];
}
let tableDataRow = commonFunc.getDefaultData(tableConfig, newCopyTo); // 取默认值
tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
tableDataRow.handleType = 'add';
tableDataRow.sId = commonUtils.createSid();
tableDataRow.sParentId = masterData.sId;
if (name === 'process') {
/* 设置工单参数下拉 */
if (commonUtils.isNotEmptyObject(tableDataRow.sProcessParam)) {
tableDataRow = { ...tableDataRow, ...commonUtils.convertStrToObj(tableDataRow.sProcessParam) };
}
const value = { sSqlCondition: { sParentId: item.sId } };
const configDataId = '11811781131121915166093023980';
const dataUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${configDataId}?sModelsId=${sModelsId}`;
const returnData = (await commonServices.postValueService(token, value, dataUrl)).data;
if (returnData.code === 1) {
const eleprocessmachineData = returnData.dataset.rows[0].dataSet;
const newData = eleprocessmachineData.filter(item => item.bDefault);
if (commonUtils.isNotEmptyArr(newData)) {
tableDataRow.sMachineId = newData[0].sMachineId;
}
}
const bProcessAssort = true;
let returnProcessAssort = [];
let processAssignAssort = '';
let dropDownDataProcessName;
if (bProcessAssort) {
const dataUrl = `${commonConfig.server_host}salesorder/getProcessAssort?sModelsId=${sModelsId}`;
const dataProcessAssort = (await commonServices.postValueService(token, {}, dataUrl)).data;
if (dataProcessAssort.code === 1) {
returnProcessAssort = dataProcessAssort.dataset.rows[0].processassort;
const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProcessName');
if (iIndex > -1) {
const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', processConfig.gdsconfigformslave[iIndex]);
dropDownDataProcessName = sqlDropDownData.dropDownData;
processAssignAssort = processConfig.gdsconfigformslave[iIndex].sAssignField;
}
}
}
// 配套工序
if (bProcessAssort) {
returnProcessAssort.filter(item => item.sParentId === tableDataRow.sProcessId).forEach(((itemProcessAssort) => {
const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
if (iIndex > -1) {
const iProcessIndex = selectData.findIndex(item => item.sId === itemProcessAssort.sProcessId);
const iNewProcessIndex = dropDownDataProcessName[iIndex].sType === '3' ?
tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId) :
tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlData[iControlIndex].sId);
if (iProcessIndex < 0 && iNewProcessIndex < 0) {
let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sType = dropDownDataProcessName[iIndex].sType;
if (iControlIndex > -1 && processRow.sType !== '3') {
processRow.sControlId = controlData[iControlIndex].sId;
processRow.sPartsName = controlData[iControlIndex].sPartsName;
}
// const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
// if (iSlaveIndex > -1) {
// processRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
tableData.push(processRow);
if (itemProcessAssort.sType === 'all') {
controlData.filter(item => item.sId !== controlData[iControlIndex].sId).forEach((controlTableRow) => {
const iNewProcessIndex = dropDownDataProcessName[iIndex].sType === '3' ?
tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId) :
tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlTableRow.sId);
if (iNewProcessIndex < 0) {
let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sType = dropDownDataProcessName[iIndex].sType;
// processRow.sSlaveId = slaveData[iSlaveIndex].sId;
if (iControlIndex > -1 && processRow.sType !== '3') {
processRow.sControlId = controlTableRow.sId;
processRow.sPartsName = controlTableRow.sPartsName;
}
// if (iSlaveIndex > -1) {
// processRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
tableData.push(processRow);
}
});
}
}
}
}));
}
}
// const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
// if (iSlaveIndex > -1) {
// tableDataRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
if (iControlIndex > -1 && tableDataRow.sType !== '3') {
tableDataRow.sControlId = controlData[iControlIndex].sId;
tableDataRow.sPartsName = controlData[iControlIndex].sPartsName;
tableData.push(tableDataRow);
} else if (tableDataRow.sType === '3') {
tableData.push(tableDataRow);
}
}
}
const tableDataNew = this.sortData(controlData, tableData);
this.props.onSaveState({
[`${name}Data`]: tableDataNew, [`${name}ChooseVisible`]: false, materialsConfig, materialsSelectedRowKeys: [],
});
}
};
/* 选择成品工序点击确定业务处理 */
handleSelectProductMaterial = async (name, selectConfig, selectData, slaveFinalSelectedData) => {
// 选择成品材料,将sType改为2
if (name === 'productMaterials') {
selectData = selectData.map(val => ({ ...val, sType: '2' }));
name = 'materials';
}
const {
[`${name}Data`]: tableData, [`${name}Config`]: tableConfig, controlSelectedRowKeys, materialsConfig,masterConfig,
} = this.props;
const { masterData } = this.props;
const { controlData } = this.props;
const iControlIndex = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]) : -1;
/* 取选择工序从表配置 */
const slavesControlName = commonUtils.isNotEmptyObject(selectConfig.sControlName) ? `${selectConfig.sControlName}.slave` : '';
let slaveSelectConfig = {};
let slaveIndex = -1;
if (commonUtils.isNotEmptyObject(masterConfig)) {
slaveIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === slavesControlName);
if (slaveIndex > -1) {
slaveSelectConfig = masterConfig.gdsconfigformslave[slaveIndex];
}
}
if (commonUtils.isNotEmptyArr(slaveFinalSelectedData)) {
for (const slaveObj of slaveFinalSelectedData) {
if (commonUtils.isNotEmptyArr(selectData)) {
for (const item of selectData) {
const newCopyTo = {};
newCopyTo.master = masterData;
if (iControlIndex > -1) {
newCopyTo.control = controlData[iControlIndex];
}
let tableDataRow = commonFunc.getDefaultData(tableConfig, newCopyTo); // 取默认值
tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
if (commonUtils.isNotEmptyObject(slaveSelectConfig)) {
tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(slaveSelectConfig.sAssignField, slaveObj, newCopyTo) }; // 取从表赋值字段
}
tableDataRow.handleType = 'add';
tableDataRow.sId = commonUtils.createSid();
tableDataRow.sParentId = masterData.sId;
tableDataRow.sCombinePartsName = slaveObj.sId; /* 成品材料sCombinePartsName 为从表id */
tableDataRow.sCombinePartsNameNew = slaveObj.sProductName;
// tableDataRow.sSlaveProductId = slaveObj.sId;
if (iControlIndex > -1 && tableDataRow.sType !== '2') {
tableDataRow.sControlId = controlData[iControlIndex].sId;
tableDataRow.sPartsName = controlData[iControlIndex].sPartsName;
tableData.push(tableDataRow);
} else if (tableDataRow.sType === '2') {
tableData.push(tableDataRow);
}
}
}
}
} else {
message.error('请选择产品!');
return;
}
const tableDataNew = this.sortData(controlData, tableData);
this.props.onSaveState({
[`${name}Data`]: tableDataNew, [`${name}ChooseVisible`]: false, materialsConfig, materialsSelectedRowKeys: [],
});
}
/* 选择成品工序点确定 */
/* 工单从表选中selectedRowKeys */
handleSelectFinalProcess = async (name, selectConfig, selectData, slaveFinalSelectedData) => {
const targetname = 'process';
const {
[`${targetname}Data`]: tableData, [`${targetname}Config`]: tableConfig, controlSelectedRowKeys, sModelsId, token,
materialsConfig, processConfig,masterConfig,
} = this.props;
const { masterData } = this.props;
if (name === 'chooseProductProcess') {
const { controlData } = this.props;
const iControlIndex = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]) : -1;
/* 取选择工序从表配置 */
const slavesControlName = commonUtils.isNotEmptyObject(selectConfig.sControlName) ? `${selectConfig.sControlName}.slave` : '';
let slaveSelectConfig = {};
let slaveIndex = -1;
if (commonUtils.isNotEmptyObject(masterConfig)) {
slaveIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === slavesControlName);
if (slaveIndex > -1) {
slaveSelectConfig = masterConfig.gdsconfigformslave[slaveIndex];
}
}
/* 通过slaveFinalSelectedRowKeys找到slaveData数据 */
if (commonUtils.isNotEmptyArr(slaveFinalSelectedData)) {
for (const slaveObj of slaveFinalSelectedData) {
if (commonUtils.isNotEmptyArr(selectData)) {
for (const item of selectData) {
const newCopyTo = {};
newCopyTo.master = masterData;
if (iControlIndex > -1) {
newCopyTo.control = controlData[iControlIndex];
}
let tableDataRow = commonFunc.getDefaultData(tableConfig, newCopyTo); // 取默认值
tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
if (commonUtils.isNotEmptyObject(slaveSelectConfig)) {
tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(slaveSelectConfig.sAssignField, slaveObj, newCopyTo) }; // 取从表赋值字段
}
tableDataRow.handleType = 'add';
tableDataRow.sId = commonUtils.createSid();
tableDataRow.sParentId = masterData.sId;
tableDataRow.sCombinePartsName = slaveObj.sId; /* 成品工序sCombinePartsName 为从表id */
tableDataRow.sCombinePartsNameNew = slaveObj.sProductName; /* 成品工序sCombinePartsName 为从表产品名称 */
// tableDataRow.sSlaveProductId = slaveObj.sId;
tableDataRow.sType = '3';
if (targetname === 'process') {
const value = { sSqlCondition: { sParentId: item.sId } };
const configDataId = '11811781131121915166093023980';
const dataUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${configDataId}?sModelsId=${sModelsId}`;
const returnData = (await commonServices.postValueService(token, value, dataUrl)).data;
if (returnData.code === 1) {
const eleprocessmachineData = returnData.dataset.rows[0].dataSet;
const newData = eleprocessmachineData.filter(item => item.bDefault);
if (commonUtils.isNotEmptyArr(newData)) {
tableDataRow.sMachineId = newData[0].sMachineId;
}
}
const bProcessAssort = true;
let returnProcessAssort = [];
let processAssignAssort = '';
let dropDownDataProcessName;
if (bProcessAssort) {
const dataUrl = `${commonConfig.server_host}salesorder/getProcessAssort?sModelsId=${sModelsId}`;
const dataProcessAssort = (await commonServices.postValueService(token, {}, dataUrl)).data;
if (dataProcessAssort.code === 1) {
returnProcessAssort = dataProcessAssort.dataset.rows[0].processassort;
const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProcessName');
if (iIndex > -1) {
const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', processConfig.gdsconfigformslave[iIndex]);
dropDownDataProcessName = sqlDropDownData.dropDownData;
processAssignAssort = processConfig.gdsconfigformslave[iIndex].sAssignField;
}
}
}
// 配套工序
if (bProcessAssort) {
returnProcessAssort.filter(item => item.sParentId === tableDataRow.sProcessId).forEach(((itemProcessAssort) => {
const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
if (iIndex > -1) {
const iProcessIndex = selectData.findIndex(item => item.sId === itemProcessAssort.sProcessId);
const iNewProcessIndex = tableDataRow.sType === '3' ?
tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId) :
tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlData[iControlIndex].sId);
if (iProcessIndex < 0 && iNewProcessIndex < 0) {
let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sType = dropDownDataProcessName[iIndex].sType;
if (iControlIndex > -1 && processRow.sType !== '3') {
processRow.sControlId = controlData[iControlIndex].sId;
processRow.sPartsName = controlData[iControlIndex].sPartsName;
}
tableData.push(processRow);
if (itemProcessAssort.sType === 'all') {
controlData.filter(item => item.sId !== controlData[iControlIndex].sId).forEach((controlTableRow) => {
const iNewProcessIndex = dropDownDataProcessName[iIndex].sType === '3' ?
tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId) :
tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlTableRow.sId);
if (iNewProcessIndex < 0) {
let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sType = dropDownDataProcessName[iIndex].sType;
if (iControlIndex > -1 && processRow.sType !== '3') {
processRow.sControlId = controlTableRow.sId;
processRow.sPartsName = controlTableRow.sPartsName;
}
tableData.push(processRow);
}
});
}
}
}
}));
}
}
// const processLen = commonBusiness.getTableTypes('process', this.props).data.filter(item => this.state.currentTab.process.split('-').indexOf(item.sType) !== -1).length;
// tableDataRow.iOrder = processLen;
if (iControlIndex > -1 && tableDataRow.sType !== '3') {
tableDataRow.sControlId = controlData[iControlIndex].sId;
tableDataRow.sPartsName = controlData[iControlIndex].sPartsName;
tableData.push(tableDataRow);
} else if (tableDataRow.sType === '3') {
tableData.push(tableDataRow);
}
}
}
}
} else {
message.error('请选择产品!');
return;
}
const tableDataNew = this.sortData(controlData, tableData);
this.props.onSaveState({
[`${targetname}Data`]: tableDataNew, [`${name}ChooseVisible`]: false, materialsConfig, materialsSelectedRowKeys: [],
});
}
}
handleViewChoose= (name, sName, record) => {
const { sId } = record; /* 控制表主键 */
const { enabled, slaveData } = this.props;
let { packData } = this.props;
if (name === 'control') {
const packSelectedRowKeys = [];
/* 合并从表相同客户、产品数据 */
const slaveDataMerge = [];
slaveData.forEach((item) => {
const iIndex = slaveDataMerge.findIndex(child => child.sCustomerId === item.sCustomerId && child.sProductId === item.sProductId);
if (iIndex === -1) {
const itemNew = JSON.parse(JSON.stringify(item));
slaveDataMerge.push(itemNew);
} else if (iIndex > -1) {
const dProductQtyNew = commonUtils.isNull(slaveDataMerge[iIndex].dProductQty, 0) + commonUtils.isNull(item.dProductQty, 0); /* 生产数量叠加 */
const dGiveQtyNew = commonUtils.isNull(slaveDataMerge[iIndex].dGiveQty, 0) + commonUtils.isNull(item.dGiveQty, 0); /* 赠送数量叠加 */
const dStockupQtyNew = commonUtils.isNull(slaveDataMerge[iIndex].dStockupQty, 0) + commonUtils.isNull(item.dStockupQty, 0); /* 备货数量叠加 */
slaveDataMerge[iIndex].dProductQty = dProductQtyNew;
slaveDataMerge[iIndex].dGiveQty = dGiveQtyNew;
slaveDataMerge[iIndex].dStockupQty = dStockupQtyNew;
}
});
/* 合并合版表相同客户、产品数据 */
const packDataMerge = [];
packData.forEach((item) => {
const iIndex = packDataMerge.findIndex(child => commonUtils.isNotEmptyObject(item.sCombinePartsName) && child.sCombinePartsName === item.sCombinePartsName && commonUtils.isNotEmptyObject(item.sProductId) && child.sProductId === item.sProductId);
if (iIndex === -1) {
const itemNew = JSON.parse(JSON.stringify(item));
packDataMerge.push(itemNew);
} else if (iIndex > -1) {
const dProductQtyNew = commonUtils.isNull(packDataMerge[iIndex].dProductQty, 0) + commonUtils.isNull(item.dProductQty, 0); /* 生产数量叠加 */
const dGiveQtyNew = commonUtils.isNull(packDataMerge[iIndex].dGiveQty, 0) + commonUtils.isNull(item.dGiveQty, 0); /* 赠送数量叠加 */
const dStockupQtyNew = commonUtils.isNull(packDataMerge[iIndex].dStockupQty, 0) + commonUtils.isNull(item.dStockupQty, 0); /* 备货数量叠加 */
packDataMerge[iIndex].dProductQty = dProductQtyNew;
packDataMerge[iIndex].dGiveQty = dGiveQtyNew;
packDataMerge[iIndex].dStockupQty = dStockupQtyNew;
}
});
if (commonUtils.isNotEmptyArr(packDataMerge)) {
packData = packDataMerge;
}
/* 填充合版信息数值 如果packData为空,则填充从表所有数据 */
if (commonUtils.isNotEmptyArr(slaveDataMerge)) {
slaveDataMerge.forEach((item, index) => {
const packDataFilter = packData.filter(itemNew => itemNew.sSlaveId === item.sId && itemNew.sControlId === sId);
if (commonUtils.isNotEmptyArr(packDataFilter)) {
packDataFilter.forEach((itemPack) => {
const iIndex = packData.findIndex(child => child.sId === itemPack.sId);
if (iIndex > -1) {
const packRowAdd = this.handlePackDataAdd(item);
if (commonUtils.isNotEmptyObject(packRowAdd)) {
packData[iIndex] = { ...packData[iIndex], ...packRowAdd };
if (itemPack.dCombineQty !== undefined && itemPack.dCombineQty !== null && itemPack.dCombineQty !== 0) {
packSelectedRowKeys.push(itemPack.sId);
}
}
}
});
} else {
const tableDataRow = this.handlePackDataAdd(item, index, sId, 'add');
if (commonUtils.isNotEmptyObject(tableDataRow)) {
packData.push(tableDataRow);
}
}
});
}
this.props.onSaveState({
productCombinationVisible: true,
sCombinationsControlId: sId, /* 合版产品控制表sId */
enabled,
packSelectedRowKeys,
packData,
});
} else if (name === 'process' && sName === 'sCombinePartsNameNew') {
const { [`${name}Data`]: tableData } = this.props;
const iIndex = tableData.findIndex(item => item.sId === sId);
let packDataFilter = [];
const combinePartsSelectedRowKeys = [];
if (iIndex > -1) {
if (commonUtils.isNotEmptyArr(slaveData)) {
if (tableData[iIndex].sType === '3') { /* 成品工序跟着从表走 */
packDataFilter = JSON.parse(JSON.stringify(slaveData));
packDataFilter.forEach((itemPack, index) => {
const packRowAdd = {};
packRowAdd.sSlaveOldId = packRowAdd.sSlaveId;
packRowAdd.sSlaveId = commonUtils.createSid();
packDataFilter[index] = { ...packDataFilter[index], ...packRowAdd };
});
} else { /* 成品工序跟着合版表走 */
packDataFilter = packData.filter(itemNew => itemNew.sControlId === tableData[iIndex].sControlId && itemNew.dCombineQty > 0);
if (commonUtils.isNotEmptyArr(packDataFilter)) {
packDataFilter.forEach((itemPack, index) => {
let slaveDataRow = {};
let packRowAdd = {};
const iIndex = slaveData.findIndex(itemSlave => itemSlave.sId === itemPack.sSlaveId);
if (iIndex > -1) {
slaveDataRow = slaveData[iIndex];
}
if (commonUtils.isNotEmptyObject(slaveDataRow)) {
packRowAdd = this.handlePackDataAdd(slaveDataRow);
}
packRowAdd.sSlaveOldId = packRowAdd.sSlaveId;
packRowAdd.sSlaveId = commonUtils.createSid();
packDataFilter[index] = { ...packDataFilter[index], ...packRowAdd };
});
}
}
}
const sCombinePartsIds = tableData[iIndex].sCombinePartsName;
if (commonUtils.isNotEmptyObject(sCombinePartsIds) && commonUtils.isNotEmptyArr(packDataFilter)) {
const DataIds = sCombinePartsIds.split(',');
for (const sId of DataIds) {
const index = packDataFilter.findIndex(item => item.sId === sId);
if (index > -1) {
const rowKey = packDataFilter[index].sSlaveId;
combinePartsSelectedRowKeys.push(rowKey);
}
}
}
}
this.props.onSaveState({
combinePartsChooseVisible: true,
combinePartsData: packDataFilter,
processSelectedRowId: sId, /* 工序表选中行sId */
combinePartsSelectedRowKeys,
});
} else if (name === 'materials' && sName === 'sCombinePartsNameNew') {
const { [`${name}Data`]: tableData } = this.props;
const iIndex = tableData.findIndex(item => item.sId === sId);
let packDataFilter = [];
const combinePartsSelectedRowKeys = [];
if (iIndex > -1) {
if (commonUtils.isNotEmptyArr(slaveData)) {
if (tableData[iIndex].sType === '2') { /* 成品材料跟着从表走 */
packDataFilter = JSON.parse(JSON.stringify(slaveData));
packDataFilter.forEach((itemPack, index) => {
const packRowAdd = {};
packRowAdd.sSlaveOldId = packRowAdd.sSlaveId;
packRowAdd.sSlaveId = commonUtils.createSid();
packDataFilter[index] = { ...packDataFilter[index], ...packRowAdd };
});
}
}
const sCombinePartsIds = tableData[iIndex].sCombinePartsName;
if (commonUtils.isNotEmptyObject(sCombinePartsIds) && commonUtils.isNotEmptyArr(packDataFilter)) {
const DataIds = sCombinePartsIds.split(',');
for (const sId of DataIds) {
const index = packDataFilter.findIndex(item => item.sId === sId);
if (index > -1) {
const rowKey = packDataFilter[index].sSlaveId;
combinePartsSelectedRowKeys.push(rowKey);
}
}
}
}
this.props.onSaveState({
combinePartsChooseVisible: true,
combinePartsData: packDataFilter,
materialsSelectedRowId: sId, /* 工序表选中行sId */
openTable: 'materials',
combinePartsSelectedRowKeys,
});
} else if (name === 'process' && sName === 'sColorSerialMemo') {
this.props.onViewChoose(name, sName, record);
}
}
handlePackDataAdd= (item, index, sControlId, handleType) => {
const tableDataRow = {};
if (handleType === 'add') {
tableDataRow.sId = commonUtils.createSid();
tableDataRow.handleType = 'add';
tableDataRow.sSlaveId = item.sId;
tableDataRow.iOrder = item.iOrder;
}
tableDataRow.sParentId = item.sParentId;
if (commonUtils.isNotEmptyObject(sControlId)) {
tableDataRow.sControlId = sControlId;
}
// if (commonUtils.isNotEmptyObject(index)) {
// tableDataRow.iOrder = index + 1;
// }
tableDataRow.sProductId = item.sProductId; /* 产品id */
tableDataRow.sCustomerId = item.sCustomerId; /* 客户id */
tableDataRow.sCustomerName = item.sCustomerName; /* 客户名称 */
tableDataRow.sProductName = item.sProductName; /* 产品名称 */
tableDataRow.sProductNo = item.sProductNo; /* 产品编号 */
/* 主表配置bProductQtyAdd 则代表产品数量不叠加备货数 赠送数 */
let bProductQtySelf = false;
if (commonUtils.isNotEmptyObject(this.props.masterConfig) && commonUtils.isNotEmptyArr(this.props.masterConfig.gdsconfigformslave)) {
const iIndex = this.props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'bProductQtySelf');
if (iIndex > -1) {
bProductQtySelf = true;
}
}
if (bProductQtySelf) {
tableDataRow.dProductQty = commonUtils.isNull(item.dProductQty, 0);
} else {
tableDataRow.dProductQty = commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0); /* 生产数量 */
}
tableDataRow.sProductUnit = item.sProductUnit; /* 单位 */
tableDataRow.sProductStyle = item.sProductStyle; /* 产品规格 */
return tableDataRow;
}
sortData = (tableData, processData) => {
processData.sort((g1, g2) => {
const iIndex1 = tableData.findIndex(item => item.sId === g1.sControlId) === -1 ? 999 : tableData.findIndex(item => item.sId === g1.sControlId);
if (g1.iOrder === undefined) {
g1.iOrder = '';
}
if (g2.iOrder === undefined) {
g2.iOrder = '';
}
let sPartOrder1 = `0000${iIndex1}`;
sPartOrder1 = sPartOrder1.substring(sPartOrder1.length - 3);
let sOrder1 = `00000${g1.iOrder.toString()}`;
sOrder1 = sOrder1.indexOf('.') > -1 ? sOrder1 : `${sOrder1}.00`;
sOrder1 = sOrder1.replace('.', '');
sOrder1 = sOrder1.substring(sOrder1.length - 5);
const iIndex2 = tableData.findIndex(item => item.sId === g2.sControlId) === -1 ? 999 : tableData.findIndex(item => item.sId === g2.sControlId);
let sPartOrder2 = `0000${iIndex2}`;
sPartOrder2 = sPartOrder2.substring(sPartOrder2.length - 3);
let sOrder2 = `00000${g2.iOrder.toString()}`;
sOrder2 = sOrder2.indexOf('.') > -1 ? sOrder2 : `${sOrder2}.00`;
sOrder2 = sOrder2.replace('.', '');
sOrder2 = sOrder2.substring(sOrder2.length - 5);
return parseFloat(sPartOrder1 + g1.sType + sOrder1) - parseFloat(sPartOrder2 + g2.sType + sOrder2);
});
return processData;
};
/* 控制排序 */
orderData = (e, name, type) => {
const {
[`${name}SelectedRowKeys`]: tableselectedRowKeys, controlData, controlSelectedRowKeys, app,
} = this.props;
let { [`${name}Data`]: processData } = this.props;
if (name === 'process') {
if (commonUtils.isEmptyArr(tableselectedRowKeys)) {
message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseMoveData'));/* 请勾选要移动数据 */
return;
}
if (commonUtils.isEmptyArr(processData)) {
message.warn(commonFunc.showMessage(app.commonConst, 'NoProcessData'));/* 请填写工序表数据 */
return;
}
const processNew = processData.filter((item) => { /* 获取勾选数据集 */
return tableselectedRowKeys.indexOf(item.sId) > -1;
});
if (commonUtils.isEmptyArr(processNew)) {
message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseMoveData'));/* 请选择要移动数据 */
return;
}
const len = processData.length;
const newLen = processNew.length;
let num = 0.01;/* 循环增加体 */
let targetiOrder = -1;
if (type === 1) { /* 上移 */
const iIndex = processData.findIndex(item => item.sId === processNew[0].sId);/* 选中第一个节点的下标 */
if (iIndex === 0) {
message.warn(commonFunc.showMessage(app.commonConst, 'NoUp'));/* 无需上移 */
return;
} else {
targetiOrder = processData[iIndex - 1].iOrder - 1; /* 目标排序号 */
}
} else if (type === 2) { /* 下移 */
const iIndex = processData.findIndex(item => item.sId === processNew[newLen - 1].sId);/* 选中最后一个节点的下标 */
if (iIndex === len - 1) {
message.warn(commonFunc.showMessage(app.commonConst, 'NoDown')); /* 无需下移 */
return;
} else {
targetiOrder = processData[iIndex + 1].iOrder;
}
} else if (type === 0) { /* 置顶 */
const iIndex = processData.findIndex(item => item.sId === processNew[0].sId);/* 选中第一个节点的下标 */
if (iIndex === 0) {
message.warn(commonFunc.showMessage(app.commonConst, 'NoTop')); /* 无需置顶 */
return;
} else {
targetiOrder = processData[0].iOrder - 1;
}
} else if (type === 3) { /* 置底 */
const iIndex = processData.findIndex(item => item.sId === processNew[newLen - 1].sId);/* 选中最后一个节点的下标 */
if (iIndex === len - 1) {
message.warn(commonFunc.showMessage(app.commonConst, 'NoBottom')); /* 无需置底 */
return;
} else {
targetiOrder = processData[len - 1].iOrder + 1;
}
}
processNew.forEach((item) => {
if (commonUtils.isEmptyObject(item.sType)) {
message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseProcessType'));/* 请选择工序名称 */
return;
}
const index1 = processData.findIndex(item1 => item1.sId === item.sId);
processData[index1] = { ...item, iOrder: targetiOrder + num };
num += 0.01;
});
processData = this.sortData(controlData, processData);
const processSortData = this.props.orderNum(processData, controlSelectedRowKeys);
if (commonUtils.isNotEmptyArr(processSortData)) {
processData = processSortData;
}
this.props.onSaveState({ [`${name}Data`]: processData });
}
};
/** 表格数据更改 */
// name 不写完整的state名称作用为了要用到total // (name, changeValue, sId, dropDownData)
handleTableChange = async (name, sFieldName, changeValue, sId, dropDownData) => {
/* 从CommonBase获取默认参数 */
if (name === 'slave') {
const {
sModelsId, [`${name}Data`]: tableData, masterConfig, controlConfig, controlData: controlDataOld, masterData, app, packData,
} = this.props;
const { dNetMoney } = app.decimals;
let tableDataRow = await this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
if (tableDataRow === undefined) return;
const iIndex = tableData.findIndex(item => item.sId === sId);
tableData[iIndex] = tableDataRow;
let bCkxNoTaxProcessPrice = '0';
const filterData = app.systemData.filter(item => (item.sName === 'CkxNoTaxProcessPrice'));
if (commonUtils.isNotEmptyArr(filterData) && filterData.length > 0) {
bCkxNoTaxProcessPrice = filterData[0].sValue;
}
const dCurrencyRate = commonUtils.convertIsNotNumToNumber1(tableDataRow.dCurrencyRate); /* 汇率 */
const addState = {};
/* 主表配置bProductQtyAdd 则代表产品数量不叠加备货数 赠送数 */
let bProductQtySelf = false;
if (commonUtils.isNotEmptyObject(this.props.masterConfig) && commonUtils.isNotEmptyArr(this.props.masterConfig.gdsconfigformslave)) {
const iIndex = this.props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'bProductQtySelf');
if (iIndex > -1) {
bProductQtySelf = true;
}
}
if (sFieldName === 'dProductQty' || sFieldName === 'dGiveQty' || sFieldName === 'dStockupQty') {
let dPartsQty = 0;
tableData.forEach((item) => {
if (bProductQtySelf) {
dPartsQty += commonUtils.isNull(item.dProductQty, 0);
} else {
dPartsQty += commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0);
}
});
/* 找到所有一级部件 */
const controlRootData = commonUtils.isNotEmptyArr(controlDataOld) ? controlDataOld.filter(item => commonUtils.isEmpty(item.sControlParentId)) : [];
if (commonUtils.isNotEmptyArr(controlRootData)) {
controlRootData.forEach((item) => {
let itemNew = { ...item };
/* 父级的dPartsQty为dPartsQty */
itemNew.dPartsQty = dPartsQty;
itemNew = this.singlePQtyChange(itemNew);
/* 找到子部件 */
const controlChildData = controlDataOld.filter(itemOld => commonUtils.isNotEmptyObject(itemOld.sAllId) && itemOld.sAllId.indexOf(item.sId) > -1 && itemOld.sId !== item.sId);
if (commonUtils.isNotEmptyArr(controlChildData)) {
const { dMachineQty } = itemNew;
controlChildData.forEach((child) => {
let tableDataRow = { ...child };
const iIndex = controlDataOld.findIndex(item => item.sId === child.sId);
if (iIndex > -1) {
/* 子部件部件数量为父部件上机数量 */
tableDataRow.dPartsQty = dMachineQty;
tableDataRow = this.singlePQtyChange(tableDataRow);
controlDataOld[iIndex] = tableDataRow;
}
});
}
const addStata = {};
addStata.dPartsQty = dPartsQty;
const iRootIndex = controlDataOld.findIndex(itemControl => itemControl.sId === item.sId);
controlDataOld[iRootIndex] = { ...controlDataOld[iRootIndex], ...itemNew };
});
}
addState.controlData = controlDataOld;
} else if (sFieldName === 'sCustomerId' || sFieldName === 'sCustomerNo' || sFieldName === 'sCustomerName') {
// commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductId', []);
// commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductNo', []);
// commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductName', []);
tableDataRow.sProductId = '';
tableDataRow.sProductNo = '';
tableDataRow.sProductName = '';
tableData[iIndex] = tableDataRow;
} else if ((sFieldName === 'dProductMoney' || sFieldName === 'dProductPrice' || sFieldName === 'dProductForeignMoney') && !commonUtils.isEmpty(tableDataRow.dStandardMoney)) {
let dProductMoney = commonUtils.isNull(tableDataRow.dProductMoney, 0);
if (sFieldName === 'dProductForeignMoney') {
const dProductForeignMoney = commonUtils.isNull(tableDataRow.dProductForeignMoney, 0);
dProductMoney = commonUtils.convertFixNum(dCurrencyRate !== 0 ? dProductForeignMoney * dCurrencyRate : 0, dNetMoney); /* 本位币金额 */
}
/* 不启用工序价格不含税 则计算利润时 无需减掉含税金额 */
if (bCkxNoTaxProcessPrice === '0') {
tableDataRow.dProfitMoney = commonUtils.convertFixNum(commonUtils.isNull(dProductMoney, 0) - commonUtils.isNull(tableDataRow.dStandardMoney, 0) - commonUtils.isNull(masterData.dPackMoney, 0) - commonUtils.isNull(masterData.dTransportMoney, 0), dNetMoney);
} else {
tableDataRow.dProfitMoney = commonUtils.convertFixNum(commonUtils.isNull(dProductMoney, 0) - commonUtils.isNull(tableDataRow.dProductTaxMoney, 0) - commonUtils.isNull(tableDataRow.dStandardMoney, 0) - commonUtils.isNull(masterData.dPackMoney, 0) - commonUtils.isNull(masterData.dTransportMoney, 0), dNetMoney);
}
// eslint-disable-next-line no-mixed-operators
tableDataRow.dProfitRate = commonUtils.convertFixNum(commonUtils.isNull(tableDataRow.dProfitMoney, 0) / commonUtils.isNull(tableDataRow.dStandardMoney, 0) * 100, 2);
} else if ((sFieldName === 'dProfitRate') && !commonUtils.isEmpty(tableDataRow.dStandardMoney)) {
/* 利润 = 标准金额 dStandMoney * 利润率 dProfitRate */
tableDataRow.dProfitMoney = commonUtils.convertFixNum((commonUtils.isNull(tableDataRow.dStandardMoney, 0)) * (commonUtils.isNull(tableDataRow.dProfitRate, 0) / 100), dNetMoney);
if (bCkxNoTaxProcessPrice === '0') { /* 不启用 则计算利润时 无需减掉含税金额 */
tableDataRow.dProductMoney = commonUtils.isNull(tableDataRow.dStandardMoney, 0) + commonUtils.isNull(tableDataRow.dProfitMoney, 0);
} else { /* 启用工序价格含税 代表金额已含税 */
// eslint-disable-next-line no-mixed-operators
tableDataRow.dProductMoney = commonUtils.convertFixNum((commonUtils.isNull(tableDataRow.dStandardMoney, 0) + commonUtils.isNull(tableDataRow.dProfitMoney, 0)) * (1 + tableDataRow.dTaxRate / 100), dNetMoney);
}
tableDataRow = commonBusiness.getCalculateAllMoney(app, 'Product', 'dProductMoney', masterData, tableDataRow);
} else if ((sFieldName === 'dTaxRate' || sFieldName === 'sTaxId' || sFieldName === 'sTaxName')) {
// eslint-disable-next-line no-mixed-operators
const iIndex = app.systemData.findIndex(item => item.sName === 'CkxNoTaxProcessPrice');
if (iIndex > -1 && app.systemData[iIndex] === '1') {
if (!commonUtils.isEmpty(tableDataRow.dStandardMoney) && !commonUtils.isEmpty(tableDataRow.dProfitMoney) && !commonUtils.isEmpty(tableDataRow.dTaxRate)) {
// eslint-disable-next-line no-mixed-operators
tableDataRow.dProductMoney = commonUtils.convertFixNum((commonUtils.isNull(tableDataRow.dStandardMoney, 0) + commonUtils.isNull(tableDataRow.dProfitMoney, 0)) * (1 + (tableDataRow.dTaxRate / 100)), dNetMoney);
tableDataRow = commonBusiness.getCalculateAllMoney(app, 'Product', 'dProductMoney', masterData, tableDataRow);
}
}
} else if ((sFieldName === 'sProductId' || sFieldName === 'sProductNo' || sFieldName === 'sProductName') && tableDataRow.handleType === 'add') {
// const productIdDropDown = commonUtils.getStoreDropDownData(sModelsId, 'slave', sFieldName);
const iProductIdIndex = dropDownData.findIndex(item => item.sId === tableData[0].sProductId);
if (iProductIdIndex > -1 && tableDataRow.sProductId !== tableDataRow.sProductName) {
if (!commonUtils.isEmpty(tableDataRow.sProductId) && commonUtils.isEmptyArr(controlDataOld)) {
const changeData = dropDownData[iProductIdIndex];
const sParentId = commonUtils.isEmpty(changeData) ? '' : changeData.sParentId;
if (!commonUtils.isEmpty(sParentId)) {
const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProductClassifyName');
if (iIndex > -1) {
let dProductQty = 0;
tableData.forEach((item) => {
if (bProductQtySelf) {
dProductQty += commonUtils.isNull(item.dProductQty, 0);
} else {
dProductQty += commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0);
}
});
const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', masterConfig.gdsconfigformslave[iIndex]);
const dropDownData = sqlDropDownData.dropDownData;
const [changeData] = dropDownData.filter(item => item.sId === sParentId);
const sAllPartsName = commonUtils.isEmpty(changeData) ? '' : changeData.sAllPartsName;
if (commonUtils.isNotEmptyStr(sAllPartsName)) {
const sAssignFieldObj = sAllPartsName.split(',');
const controlData = [];
for (const child of sAssignFieldObj) {
let allTableData = {};
allTableData = {};
allTableData.master = masterData;
allTableData.slave = commonUtils.isEmptyArr(tableData) ? {} : tableData[0];
const tableDataRow = commonFunc.getDefaultData(controlConfig, allTableData);
tableDataRow.handleType = 'add';
tableDataRow.sId = commonUtils.createSid();
tableDataRow.sParentId = masterData && masterData.sId ? masterData.sId : null;
tableDataRow.key = tableDataRow.sId;
tableDataRow.bDefault = false;
tableDataRow.iOrder = controlData.length + 1;
tableDataRow.sPartsName = child;
tableDataRow.dPartsQty = dProductQty;
tableDataRow.sAllId = tableDataRow.sId;
tableDataRow.sControlParentId = '';
controlData.push(tableDataRow);
}
addState.controlData = controlData;
}
}
}
}
}
}
/* 从表改变时合版表数据对应改变,从新改变packData数据 */
packData.forEach((item, index) => {
if (item.sSlaveId === tableDataRow.sId) {
const addState = {};
addState.sProductId = tableDataRow.sProductId; /* 产品id */
addState.sCustomerId = tableDataRow.sCustomerId; /* 客户id */
addState.sCustomerName = tableDataRow.sCustomerName; /* 客户名称 */
addState.sProductName = tableDataRow.sProductName; /* 产品名称 */
addState.sProductNo = tableDataRow.sProductNo; /* 产品编号 */
addState.dProductQty = tableDataRow.dProductQty; /* 生产数量 */
addState.sProductUnit = tableDataRow.sProductUnit; /* 单位 */
addState.sProductStyle = tableDataRow.sProductStyle; /* 产品规格 */
packData[index] = { ...packData[index], ...addState };
}
});
addState.packData = packData;
this.props.onSaveState({ [`${name}Data`]: tableData, ...addState });
} else if (name === 'control') {
const {
[`${name}Data`]: tableData, materialsData: materialsDataOld, processData: processDataOld, sModelsType,
} = this.props;
let tableDataRow = await this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
if (tableDataRow === undefined) return;
if (sFieldName === 'dSinglePQty' || sFieldName === 'dPartsQty' || sFieldName === 'dSumPQty' || sFieldName === 'iPrintModePo' || sFieldName === 'iPrintMode' || sFieldName === 'iPrintModePo' || sFieldName === 'iPositiveColor' ||
sFieldName === 'iPositiveSpecialColor' || sFieldName === 'iOppositeColor' || sFieldName === 'iOppositeSpecialColor') {
if (sFieldName === 'iPrintModePo') {
if (tableDataRow.iPrintModePo === 0) {
tableDataRow.iPrintMode = 3;
if (tableDataRow.iPositiveColor === 0) {
tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
tableDataRow.iOppositeColor = 0;
tableDataRow.iOppositeSpecialColor = 0;
} else {
tableDataRow.iOppositeColor = 0;
tableDataRow.iOppositeSpecialColor = 0;
}
} else if (tableDataRow.iPrintModePo === 1) {
tableDataRow.iPrintMode = 3;
if (tableDataRow.iPositiveColor === 0) {
tableDataRow.iPositiveColor = 0;
tableDataRow.iPositiveSpecialColor = 0;
tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? 4 : tableDataRow.iOppositeColor;
} else {
tableDataRow.iPositiveColor = 0;
tableDataRow.iPositiveSpecialColor = 0;
}
} else {
tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? tableDataRow.iPositiveColor : tableDataRow.iOppositeColor;
}
} else if (sFieldName === 'iPrintMode') {
if (tableDataRow.iPrintMode === 0 || tableDataRow.iPrintMode === 1) {
tableDataRow.iPositiveColor = commonUtils.isEmpty(tableDataRow.iPositiveColor) || tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
tableDataRow.iOppositeColor = tableDataRow.iPositiveColor;
tableDataRow.iOppositeSpecialColor = tableDataRow.iPositiveSpecialColor;
} else if (tableDataRow.iPrintMode === 2) {
tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? tableDataRow.iPositiveColor : tableDataRow.iOppositeColor;
} else if (tableDataRow.iPrintMode === 3) {
tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
tableDataRow.iOppositeColor = 0;
tableDataRow.iOppositeSpecialColor = 0;
} else if (tableDataRow.iPrintMode === 4) {
tableDataRow.iPositiveColor = 0;
tableDataRow.iPositiveSpecialColor = 0;
tableDataRow.iOppositeColor = 0;
tableDataRow.iOppositeSpecialColor = 0;
}
} else if (sFieldName === 'iPositiveColor' || sFieldName === 'iPositiveSpecialColor') {
if (tableDataRow.iPrintMode === 0 || tableDataRow.iPrintMode === 1) {
tableDataRow.iOppositeColor = tableDataRow.iPositiveColor;
tableDataRow.iOppositeSpecialColor = tableDataRow.iPositiveSpecialColor;
}
}
tableDataRow = this.singlePQtyChange(tableDataRow);
/* 上机数量改变时,子级部件数量同步改变 */
const { dMachineQty } = tableDataRow;
/* 查找该节的所有子节点,将上机数量改为部件数量 */
tableData.forEach((item, index) => {
if (commonUtils.isNotEmptyObject(item.sAllId) && item.sAllId.indexOf(tableDataRow.sId) > -1 && item.sId !== tableDataRow.sId) {
const addstate = {};
addstate.dPartsQty = dMachineQty;
tableData[index] = { ...tableData[index], ...addstate };
}
});
} else if (sModelsType.includes('quotation/quotation')) {
/* 计算材料开数 */
// if (sFieldName === 'dMachineLength' || sFieldName === 'dMachineWidth' || sFieldName === 'dMaterialsLength' || sFieldName === 'dMaterialsWidth') {
// let dProductLength = 0; /* 产品长 */
// let dProductWidth = 0; /* 产品宽 */
// if (commonUtils.isNotEmptyArr(slaveData)) {
// dProductLength = !commonUtils.isEmpty(slaveData[0].sProductStyle) && slaveData[0].sProductStyle.split('*').length === 2 ? slaveData[0].sProductStyle.split('*')[0] : 0;
// dProductLength = commonUtils.convertStrToNumber(commonUtils.isNull(dProductLength, 0)); /* 产品长 */
// dProductLength = (typeof dProductLength === 'number' && !isNaN(dProductLength)) ? dProductLength : 0; /* 产品长 */
// dProductWidth = !commonUtils.isEmpty(slaveData[0].sProductStyle) && slaveData[0].sProductStyle.split('*').length === 2 ? slaveData[0].sProductStyle.split('*')[1] : 0;
// dProductWidth = commonUtils.convertStrToNumber(commonUtils.isNull(dProductWidth, 0)); /* 产品宽 */
// dProductWidth = (typeof dProductLength === 'number' && !isNaN(dProductLength)) ? dProductWidth : 0; /* 产品宽 */
// }
// const dMachineLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineLength, 0)); /* 上机长 */
// const dMachineWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineWidth, 0)); /* 上机宽 */
// const dMaterialsLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsLength, 0)); /* 材料长 */
// const dMaterialsWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsWidth, 0)); /* 材料宽 */
//
// /* 算材料开数 */
// const mapMaterialsKQty = this.props.onResolveMachineComposing(dMachineLength, dMachineWidth, dMaterialsLength, dMaterialsWidth);
// if (commonUtils.isNotEmptyObject(mapMaterialsKQty)) {
// const dMaterialsKQty = mapMaterialsKQty.totalNum;
// tableDataRow.dMaterialsKQty = dMaterialsKQty;
// }
//
// /* 算拼版数 */
// if (dProductLength !== 0 && dProductWidth !== 0) {
// const mapSinglePQty = this.props.onResolveMachineComposing(dProductLength, dProductWidth, dMachineLength, dMachineWidth);
// if (commonUtils.isNotEmptyObject(mapSinglePQty)) {
// const dSinglePQty = mapSinglePQty.totalNum;
// tableDataRow.dSinglePQty = dSinglePQty;
// }
// }
// }
}
const materialsData = [];
const processData = [];
materialsDataOld.forEach((item) => {
const itemNew = { ...item };
if (itemNew.sControlId === sId) {
itemNew.sPartsName = tableDataRow.sPartsName;
}
materialsData.push(itemNew);
});
processDataOld.forEach((item) => {
const itemNew = { ...item };
if (itemNew.sControlId === sId) {
itemNew.sPartsName = tableDataRow.sPartsName;
}
processData.push(itemNew);
});
const materialsDataNew = this.sortData(tableData, materialsData);
const processDataNew = this.sortData(tableData, processData);
if (sFieldName === 'sPartsName') { /* 部件名称与子部件同步 */
const { sPartsName } = tableDataRow;
const { treeSelectedKeys, treeData } = this.props;
if (commonUtils.isNotEmptyArr(treeSelectedKeys)) {
this.handleSearchNodes(treeSelectedKeys[0], treeData, sPartsName);
}
}
const iIndex = tableData.findIndex(item => item.sId === sId);
tableData[iIndex] = tableDataRow;
this.props.onSaveState({ [`${name}Data`]: tableData, materialsData: materialsDataNew, processData: processDataNew });
} else if (name === 'materials') {
const {
[`${name}Data`]: tableData, controlData, controlSelectedRowKeys, app, sModelsId,
} = this.props;
const tableDataRow = await this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
if (tableDataRow === undefined) return;
if (Object.keys(changeValue).length > 0 && Object.keys(changeValue).findIndex(item => item === 'dMaterialsStockAuxiliaryQty') > -1) {
const urlMaterialsStock = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const valueMaterialsStock = {
sProName: 'Sp_Inventory_MaterialsInventoryV56',
paramsMap: {
sMaterialsGuid: tableDataRow.sMaterialsId,
sMaterialsStyle: tableDataRow.sMaterialsStyle,
sWarehouseGuid: tableDataRow.sWarehouseId,
sLocationalGuid: tableDataRow.sLocationId,
sWarehouseLocationGuid: tableDataRow.sWarehouseLocationId,
sDefine_no: tableDataRow.sDefineNo,
sDefine_no2: tableDataRow.sDefineNo2,
iGetQty: 1,
iHasZero: 1,
},
};
const returnDataMaterialsStock = (await commonServices.postValueService(app.token, valueMaterialsStock, urlMaterialsStock)).data;
if (returnDataMaterialsStock.code === 1) {
tableDataRow.dMaterialsStockAuxiliaryQty = returnDataMaterialsStock.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
}
}
if (Object.keys(changeValue).length > 0 && Object.keys(changeValue).findIndex(item => item === 'dMaterialsStockAvailableQty') > -1) {
const urlMaterialsAvailableQty = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const valueMaterialsAvailableQty = {
sProName: 'Sp_Inventory_MaterialsInventoryV56',
paramsMap: {
sMaterialsGuid: tableDataRow.sMaterialsId,
sMaterialsStyle: tableDataRow.sMaterialsStyle,
sWarehouseGuid: tableDataRow.sWarehouseId,
sLocationalGuid: tableDataRow.sLocationId,
sWarehouseLocationGuid: tableDataRow.sWarehouseLocationId,
sDefine_no: tableDataRow.sDefineNo,
sDefine_no2: tableDataRow.sDefineNo2,
iGetQty: 2,
iHasZero: 1,
},
};
const returnDataMaterialsAvailableQty = (await commonServices.postValueService(app.token, valueMaterialsAvailableQty, urlMaterialsAvailableQty)).data;
if (returnDataMaterialsAvailableQty.code === 1) {
tableDataRow.dMaterialsStockAvailableQty = returnDataMaterialsAvailableQty.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
}
}
const iIndex = tableData.findIndex(item => item.sId === sId);
if (iIndex > -1) {
tableData[iIndex] = tableDataRow;
}
if (sFieldName === 'sType') {
if (tableData[iIndex].sType === '2') {
tableData[iIndex].sControlId = '';
tableData[iIndex].sPartsName = '';
} else {
const iControlIndex = commonUtils.isEmptyArr(controlSelectedRowKeys) ? -1 : controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]);
if (iControlIndex > -1) {
tableData[iIndex].sControlId = controlData[iControlIndex].sId;
tableData[iIndex].sPartsName = controlData[iControlIndex].sPartsName;
}
}
}
this.props.onSaveState({ [`${name}Data`]: tableData });
} else if (name === 'process') {
const {
[`${name}Data`]: tableData, sModelsId, masterData, slaveData, controlData, controlSelectedRowKeys, materialsData, processConfig, token,
} = this.props;
let { processDelData, materialsDelData } = this.props;
const tableDataRow = await this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
if (tableDataRow === undefined) return;
let iIndex = tableData.findIndex(item => item.sId === sId);
let tableDataRowOld = {};
let iMaterialsIndex = -1;
let sControlId = '';
if (iIndex > -1) {
iMaterialsIndex = materialsData.findIndex(item => item.sControlId === tableData[iIndex].sControlId && item.sProcessId === tableData[iIndex].sProcessId);
tableDataRowOld = tableData[iIndex];
tableData[iIndex] = tableDataRow;
sControlId = tableData[iIndex].sControlId;
}
const addState = {};
if (sFieldName === 'sProcessId' || sFieldName.includes('sProcessName')) {
const bProcessAssort = true;
let returnProcessAssort = [];
let processAssignAssort = '';
let dropDownDataProcessName;
const sProcessParamStriIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProcessParamStr' && item.bVisible);
if (sProcessParamStriIndex > -1 && commonUtils.isNotEmptyObject(tableData[iIndex].sProcessParam)) {
tableData[iIndex].sProcessParamStr = '工艺参数';
} else if (sProcessParamStriIndex > -1) {
tableData[iIndex].sProcessParamStr = '';
}
/* 设置工艺参数下拉 */
if (commonUtils.isNotEmptyObject(tableData[iIndex].sProcessParam)) {
tableData[iIndex] = { ...tableData[iIndex], ...commonUtils.convertStrToObj(tableData[iIndex].sProcessParam) };
}
if (bProcessAssort) {
const dataUrl = `${commonConfig.server_host}salesorder/getProcessAssort?sModelsId=${sModelsId}`;
const dataProcessAssort = (await commonServices.postValueService(token, {}, dataUrl)).data;
if (dataProcessAssort.code === 1) {
returnProcessAssort = dataProcessAssort.dataset.rows[0].processassort;
const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProcessName');
if (iIndex > -1) {
const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', processConfig.gdsconfigformslave[iIndex]);
dropDownDataProcessName = sqlDropDownData.dropDownData;
processAssignAssort = processConfig.gdsconfigformslave[iIndex].sAssignField;
}
}
}
const iControlIndex = commonUtils.isEmptyArr(controlSelectedRowKeys) ? -1 : controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]);
// 配套工序
if (bProcessAssort) {
const newCopyTo = {};
newCopyTo.master = masterData;
if (commonUtils.isNotEmptyArr(slaveData)) {
newCopyTo.slave = slaveData[0];
}
/* 切换工序时 先删除原工序配套工序 */
if (commonUtils.isEmptyArr(processDelData)) {
processDelData = [];
}
if (commonUtils.isEmptyArr(materialsDelData)) {
materialsDelData = [];
}
returnProcessAssort.filter(item => item.sParentId === tableDataRowOld.sProcessId).forEach(((itemProcessAssort) => {
const iProcessIndex = tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === sControlId);
if (iProcessIndex > -1) {
const processDataRow = tableData[iProcessIndex];
tableData.splice(iProcessIndex, 1);
processDataRow.handleType = 'del';
processDelData.push(processDataRow);
/* 删除配套材料 */
const iMaterialsIndex = materialsData.findIndex(item => item.sMaterialsName === processDataRow.sProcessName && item.sControlId === sControlId);
if (iMaterialsIndex > -1) {
const materialsDataRow = materialsData[iMaterialsIndex];
materialsData.splice(iMaterialsIndex, 1);
materialsDataRow.handleType = 'del';
materialsDelData.push(materialsDataRow);
}
}
}));
if (commonUtils.isNotEmptyArr(processDelData)) {
addState.processDelData = processDelData;
}
if (commonUtils.isNotEmptyArr(materialsDelData)) {
addState.materialsDelData = materialsDelData;
}
iIndex = tableData.findIndex(item => item.sId === tableDataRow.sId);
returnProcessAssort.filter(item => item.sParentId === tableDataRow.sProcessId).forEach(((itemProcessAssort) => {
const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
if (iIndex > -1) {
const iNewProcessIndex = dropDownDataProcessName[iIndex].sType === '3' ?
tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId) :
tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlData[iControlIndex].sId);
if (iIndex > -1 && iNewProcessIndex < 0) {
let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sType = dropDownDataProcessName[iIndex].sType;
if (iControlIndex > -1 && processRow.sType !== '3') {
processRow.sControlId = controlData[iControlIndex].sId;
processRow.sPartsName = controlData[iControlIndex].sPartsName;
}
// const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
// if (iSlaveIndex > -1) {
// processRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
tableData.push(processRow);
if (itemProcessAssort.sType === 'all') {
controlData.filter(item => item.sId !== controlData[iControlIndex].sId).forEach((controlTableRow) => {
const iNewProcessIndex = dropDownDataProcessName[iIndex].sType === '3' ?
tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId) :
tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlTableRow.sId);
if (iNewProcessIndex < 0) {
let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = 'add';
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sType = dropDownDataProcessName[iIndex].sType;
if (iControlIndex > -1 && processRow.sType !== '3') {
processRow.sControlId = controlTableRow.sId;
processRow.sPartsName = controlTableRow.sPartsName;
}
// const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
// if (iSlaveIndex > -1) {
// processRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
tableData.push(processRow);
}
});
}
}
}
}));
}
if (tableData[iIndex].sType === '3') {
tableData[iIndex].sControlId = '';
tableData[iIndex].sPartsName = '';
} else if (iControlIndex > -1) {
tableData[iIndex].sControlId = controlData[iControlIndex].sId;
tableData[iIndex].sPartsName = controlData[iControlIndex].sPartsName;
if (iMaterialsIndex > -1) {
materialsData[iMaterialsIndex].sProcessId = tableData[iIndex].sProcessId;
materialsData[iMaterialsIndex].sProcessTbId = tableData[iIndex].sId;
materialsData[iMaterialsIndex].sMaterialsProcessName = tableData[iIndex].sProcessName;
}
}
}
this.props.onSaveState({ [`${name}Data`]: tableData, materialsSelectedRowKeys: [], ...addState });
} else if (name === 'pack') {
const { packData, packSelectedRowKeys } = this.props;
const tableDataRow = await this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
if (tableDataRow === undefined) return;
const iIndex = packData.findIndex(item => item.sId === sId);
packData[iIndex] = tableDataRow;
if (sFieldName === 'dCombineQty' || sFieldName === 'dProductQty') {
this.handleGetdFactProductQty(packSelectedRowKeys, packData);
this.props.onSaveState({ packData });
}
} else {
this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData);
}
};
/* 重新计算实际生产数 */
handleGetdFactProductQty = (selectedRowKeys, tableData) => {
const maxArr = [];
if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
const tableFilter = tableData.filter(item => selectedRowKeys.includes(item.sId) && item.dCombineQty > 0);
if (selectedRowKeys.length === 1 || tableFilter.length === 1) { /* 当选中行只有一行时,实际生产数等于生产数 */
const iSlaveIndex = tableData.findIndex(item => item.sId === selectedRowKeys[0]);
if (iSlaveIndex > -1) {
const dProductQty = tableData[iSlaveIndex].dProductQty;
tableData[iSlaveIndex] = { ...tableData[iSlaveIndex], dFactProductQty: dProductQty };
}
} else {
for (const sId of selectedRowKeys) {
const iSlaveIndex = tableData.findIndex(item => item.sId === sId);
if (iSlaveIndex > -1) {
const slaveDataRow = tableData[iSlaveIndex];
const { dCombineQty, dProductQty } = slaveDataRow;
if (dCombineQty > 0) {
let dNum = commonUtils.convertFixNum(dCombineQty !== 0 ? dProductQty / dCombineQty : 0, 2); /* 生产数/排版数 取最大值 */
dNum = Math.ceil(dNum);
maxArr.push(dNum);
}
}
}
let dMax = 0;
if (commonUtils.isNotEmptyArr(maxArr)) {
dMax = Math.max(...maxArr);
}
dMax = commonUtils.isNotNum(dMax) ? 0 : dMax;
for (const sId of selectedRowKeys) {
const iSlaveIndex = tableData.findIndex(item => item.sId === sId);
if (iSlaveIndex > -1) {
const slaveDataRow = tableData[iSlaveIndex];
let { dCombineQty } = slaveDataRow;
if (dCombineQty > 0) {
dCombineQty = commonUtils.isNotNum(dCombineQty) ? 0 : dCombineQty;
const dFactProductQty = commonUtils.convertFixNum(dCombineQty * dMax, 2); /* 实际生产数 =最大值 * 排版数 */
tableData[iSlaveIndex] = { ...tableData[iSlaveIndex], dFactProductQty };
}
}
}
}
this.props.onSaveState({ packData: tableData });
}
}
handleCancelFastOrderModal = () => {
this.props.onSaveState({ fastOrderModalVisible: false, quotationAllprogress: 0, Loading: false });
};
handleCancelProcessChooseModal = () => {
this.props.onSaveState({ processChooseVisible: false });
};
handleCancelMaterialsChooseModal = () => {
this.props.onSaveState({ materialsChooseVisible: false });
};
handleCancelProductProcessInfoChooseModal = () => {
this.props.onSaveState({ productProcessInfoChooseVisible: false });
};
handleCancelProductCombinationChooseModal = () => {
this.props.onSaveState({ productCombinationVisible: false });
};
handleSelectProductCombination= () => {
const {
controlData, sCombinationsControlId, packData, enabled, app,
} = this.props;
let { packSelectedRowKeys: selectedRowKeys } = this.props;
let sCombinedMemo = '';
const tableCombineSelectedData = [];
selectedRowKeys = commonUtils.isNotEmptyArr(selectedRowKeys) ? selectedRowKeys : [];
const maxArr = [];
const maxMap = new Map();
for (const sId of selectedRowKeys) {
const iIndex = packData.findIndex(item => item.sId === sId);
if (iIndex > -1) {
const tableDataRow = packData[iIndex];
const {
sId, sProductNo, dCombineQty, dProductQty, dFactProductQty, sCombinePartsName,
} = tableDataRow;
if (dCombineQty > 0) { /* 排版数大于0时,把数据带回到控制表 */
const jsonObj = {};
jsonObj.sId = sId;
jsonObj.sProductNo = sProductNo; /* 产品编号 */
jsonObj.dCombineQty = commonUtils.isNotEmptyNumber(dCombineQty) ? dCombineQty : 0; /* 排版数 */
jsonObj.dProductQty = commonUtils.isNotEmptyNumber(dProductQty) ? dProductQty : 0; /* 生产数 */
jsonObj.dFactProductQty = commonUtils.isNotEmptyNumber(dFactProductQty) ? dFactProductQty : 0; /* 实际生产数 */
jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */
tableCombineSelectedData.push(jsonObj);
maxMap.set(dFactProductQty, jsonObj);
maxArr.push(dFactProductQty);
} else {
message.warn(commonFunc.showMessage(app.commonConst, 'pleaseInputQty'));/* 请填写合拼排版数 */
return;
}
}
}
/* 没勾选的合版数据 合拼排版数置为0 */
const packNoChooseData = packData.filter(item => item.sControlId === sCombinationsControlId && !selectedRowKeys.includes(item.sId));
if (commonUtils.isNotEmptyArr(packNoChooseData) && packNoChooseData.length > 0) {
packNoChooseData.forEach((item) => {
const iIndex = packData.findIndex(child => child.sId === item.sId);
if (iIndex > -1) {
packData[iIndex].dCombineQty = 0;
}
});
}
let iMax = 0;
if (commonUtils.isNotEmptyArr(maxArr)) {
iMax = Math.max(...maxArr);
}
sCombinedMemo = commonUtils.isNotEmptyArr(tableCombineSelectedData) ? JSON.stringify(tableCombineSelectedData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
const iControlIndex = controlData.findIndex(item => item.sId === sCombinationsControlId);
if (iControlIndex > -1 && enabled) {
const addState = {};
const maxObj = maxMap.get(iMax);
let { handleType } = controlData[iControlIndex];
handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
addState.handleType = handleType;
addState.sCombinedMemo = sCombinedMemo;
addState.dPartsQty = iMax;
addState.dSinglePQty = commonUtils.isNotEmptyObject(maxObj) ? maxObj.dCombineQty : 0;
controlData[iControlIndex] = { ...controlData[iControlIndex], ...addState };
}
this.props.onSaveState({
productCombinationVisible: false,
packData,
controlData,
});
};
handleCancelCombinePartsChooseModal = () => {
this.props.onSaveState({ combinePartsChooseVisible: false });
};
/* 选择合版部件名称 */
handleSelectCombineParts = (name, selectConfig, selectData) => {
const {
processData, processSelectedRowId, materialsData, materialsSelectedRowId, openTable,
} = this.props;
let sCombinedStr = '';
let sCombinedId = '';
if (selectData !== undefined) {
if (commonUtils.isNotEmptyArr(selectData)) {
selectData.forEach((item) => {
const { sId } = item;
let { sProductName } = item;
let { sCombinePartsName } = item;
sProductName = commonUtils.isNotEmptyObject(sProductName) ? sProductName : '';
sCombinePartsName = commonUtils.isNotEmptyObject(sCombinePartsName) ? sCombinePartsName : '';
// sCombinedStr += `${sCustomerName}-${sProductName}-${sCombinePartsName},`;
if (commonUtils.isNotEmptyObject(sCombinePartsName)) {
sCombinedStr += `${sProductName}-${sCombinePartsName},`;
sCombinedId += `${sId},`;
} else {
sCombinedStr += `${sProductName},`;
sCombinedId += `${sId},`;
}
});
// sCombinedStr = `${selectData.length.toString()} `;
if (commonUtils.isNotEmptyObject(sCombinedStr)) {
sCombinedStr = commonUtils.isNotEmptyObject(sCombinedStr) ? sCombinedStr.substr(0, sCombinedStr.length - 1) : '';
}
if (commonUtils.isNotEmptyObject(sCombinedId)) {
sCombinedId = commonUtils.isNotEmptyObject(sCombinedId) ? sCombinedId.substr(0, sCombinedId.length - 1) : '';
}
}
if (commonUtils.isNotEmptyObject(openTable) && openTable === 'materials') {
const iIndex = materialsData.findIndex(item => item.sId === materialsSelectedRowId);
if (iIndex > -1) {
const addState = {};
let { handleType } = processData[iIndex];
handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
addState.handleType = handleType;
addState.sCombinePartsNameNew = sCombinedStr;
addState.sCombinePartsName = sCombinedId;
materialsData[iIndex] = { ...materialsData[iIndex], ...addState };
}
this.props.onSaveState({ materialsData, combinePartsChooseVisible: false });
} else {
const iIndex = processData.findIndex(item => item.sId === processSelectedRowId);
if (iIndex > -1) {
const addState = {};
let { handleType } = processData[iIndex];
handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
addState.handleType = handleType;
addState.sCombinePartsNameNew = sCombinedStr;
addState.sCombinePartsName = sCombinedId;
processData[iIndex] = { ...processData[iIndex], ...addState };
}
this.props.onSaveState({ processData, combinePartsChooseVisible: false });
}
}
// this.props.onSaveState({ processData, combinePartsChooseVisible: false });
};
handleCancelModal = (modelVisible) => {
this.props.onSaveState({
[modelVisible]: false,
});
}
/** 复制 */
handleTableCopy = (name, isWait) => {
/* 部件树节点复制功能 */
const {
[`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: tableSelectedRowKeys, [`${name}Pagination`]: tablePagination, packData, slaveData,
} = this.props;
if (name === 'control') {
const {
[`${name}SelectedRowKeys`]: treeSelectedKeys,
} = this.props;
if (commonUtils.isEmptyArr(treeSelectedKeys)) {
message.warn('请选择部件!'); // 请选择部件
return;
}
/* 获取复制节点下的所有子节点 */
const controlChildData = tableData.filter(item => item.sAllId.indexOf(treeSelectedKeys[0]) > -1 && item.sId !== treeSelectedKeys[0]);
if (commonUtils.isNotEmptyArr(tableData)) {
controlChildData.forEach((itemNew) => {
tableSelectedRowKeys.push(itemNew.sId);
});
}
const treeCopyNodes = new Map();
for (const sId of tableSelectedRowKeys) {
const tableDataIndex = tableData.findIndex(item => item.sId === sId);
if (tableDataIndex > -1) {
const tableDataRow = JSON.parse(JSON.stringify(tableData[tableDataIndex]));
const sAllOldId = tableData[tableDataIndex].sAllId;
const arr = sAllOldId.split(',');
const newId = commonUtils.createSid();
tableDataRow.sId = newId;
let sOldParentId = '';
let sNewParentAllId = '';
if (arr.length < 2) { /* 根节点复制 */
tableDataRow.sAllId = newId;
sOldParentId = newId;
sNewParentAllId = newId;
} else {
sOldParentId = arr[arr.length - 2];
if (treeCopyNodes.has(sOldParentId)) {
sNewParentAllId = treeCopyNodes.get(sOldParentId);
} else {
const obj = arr[arr.length - 1];
sNewParentAllId = sAllOldId.replace((`,${obj}`), '');
}
const sNewArr = sNewParentAllId.split(',');
tableDataRow.sControlParentId = sNewArr[sNewArr.length - 1];
sNewParentAllId = `${sNewParentAllId},${newId}`;
tableDataRow.sAllId = sNewParentAllId;
}
treeCopyNodes.set(sId, sNewParentAllId);
tableDataRow.handleType = 'add';
tableDataRow.key = tableDataRow.sId;
tableDataRow.sSrcSlaveId = '';
tableDataRow.sSrcId = '';
tableDataRow.dSrcQty = null;
const iOrderArr = [];
tableData.forEach((item) => {
const iOrder = commonUtils.isNotEmptyNumber(item.iOrder) ? item.iOrder : 0; /* 获取tableData中iOrder最大值 */
iOrderArr.push(iOrder);
});
const iOrderMax = Math.max(...iOrderArr);
tableDataRow.iOrder = commonUtils.isNotEmptyArr(tableData) ? iOrderMax + 1 : 0;
if (commonUtils.isNotEmptyObject(tableDataRow.sMaterialsMemo)) {
tableDataRow.sMaterialsMemo = '';
}
if (commonUtils.isNotEmptyObject(tableDataRow.sProcessMemo)) {
tableDataRow.sProcessMemo = '';
}
tableData.push(tableDataRow);
const tableSelectedNewRowKeys = [];
if (commonUtils.isNotEmptyObject(newId)) {
tableSelectedNewRowKeys.push(newId);
}
if (commonUtils.isNotEmptyArr(slaveData)) {
slaveData.forEach((item, index) => {
/* 合版信息表增加一条从表数据 */
const packDataRow = this.handlePackDataAdd(item, index, tableDataRow.sId, 'add');
if (commonUtils.isNotEmptyObject(packDataRow)) {
// packDataRow.dCombineQty = 1;
packData.push(packDataRow);
}
});
}
this.props.onSaveState({
[`${name}Data`]: tableData, [`${name}Pagination`]: { ...tablePagination, total: tableData.length, current: 9999 }, [`${name}SelectedRowKeys`]: tableSelectedNewRowKeys, treeSelectedKeys: tableSelectedNewRowKeys, packData,
});
}
}
this.handleGetControlTreeData(tableData);
} else if (name === 'slave') {
const { packData, controlData } = this.props;
if (commonUtils.isEmptyArr(tableSelectedRowKeys)) {
message.warn('请选择数据!'); // 请选择从表数据
return;
}
for (const sId of tableSelectedRowKeys) {
const tableDataIndex = tableData.findIndex(item => item.sId === sId);
if (tableDataIndex > -1) {
const tableDataRow = this.props.onDataRowCopy(name, true);
if (commonUtils.isNotEmptyArr(controlData)) {
controlData.forEach((item) => {
/* 合版信息表增加一条从表数据 */
const packDataRow = this.handlePackDataAdd(tableDataRow, tableData.length, item.sId, 'add');
if (commonUtils.isNotEmptyObject(packDataRow)) {
// packDataRow.dCombineQty = 1;
packData.push(packDataRow);
}
});
}
tableData.push(tableDataRow);
this.props.onSaveState({
[`${name}Data`]: tableData, packData, [`${name}Pagination`]: { ...tablePagination, total: tableData.length, current: 9999 },
});
}
}
} else {
this.props.onDataRowCopy(name, isWait);
}
}
/** 复制全部 */
handleTableCopyAll = (name, isWait) => {
const {
[`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: tableSelectedRowKeys, materialsData, app, packData, slaveData,
} = this.props;
let { processData } = this.props;
if (name === 'control') {
const {
[`${name}SelectedRowKeys`]: treeSelectedKeys,
} = this.props;
if (commonUtils.isEmptyArr(tableSelectedRowKeys)) {
message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseCopyData'));/* 请选择复制数据 */
} else {
/* 获取复制节点下的所有子节点 */
const controlChildData = tableData.filter(item => item.sAllId.indexOf(treeSelectedKeys[0]) > -1 && item.sId !== treeSelectedKeys[0]);
if (commonUtils.isNotEmptyArr(tableData)) {
controlChildData.forEach((itemNew) => {
tableSelectedRowKeys.push(itemNew.sId);
});
}
const treeCopyNodes = new Map();
for (const sId of tableSelectedRowKeys) {
const tableDataIndex = tableData.findIndex(item => item.sId === sId);
if (tableDataIndex > -1) {
const tableDataRow = JSON.parse(JSON.stringify(tableData[tableDataIndex]));
tableDataRow.sId = commonUtils.createSid();
tableDataRow.handleType = 'add';
tableDataRow.key = tableDataRow.sId;
tableDataRow.sPartsName = `${tableData[tableDataIndex].sPartsName}new`;
const sAllOldId = tableData[tableDataIndex].sAllId;
const arr = sAllOldId.split(',');
const newId = tableDataRow.sId;
let sOldParentId = '';
let sNewParentAllId = '';
if (arr.length < 2) { /* 根节点复制 */
tableDataRow.sAllId = newId;
sOldParentId = newId;
sNewParentAllId = newId;
} else {
sOldParentId = arr[arr.length - 2];
if (treeCopyNodes.has(sOldParentId)) {
sNewParentAllId = treeCopyNodes.get(sOldParentId);
} else {
const obj = arr[arr.length - 1];
sNewParentAllId = sAllOldId.replace((`,${obj}`), '');
}
const sNewArr = sNewParentAllId.split(',');
tableDataRow.sControlParentId = sNewArr[sNewArr.length - 1];
sNewParentAllId = `${sNewParentAllId},${newId}`;
tableDataRow.sAllId = sNewParentAllId;
}
treeCopyNodes.set(sId, sNewParentAllId);
const iOrderArr = [];
tableData.forEach((item) => {
const iOrder = commonUtils.isNotEmptyNumber(item.iOrder) ? item.iOrder : 0; /* 获取tableData中iOrder最大值 */
iOrderArr.push(iOrder);
});
const iOrderMax = Math.max(...iOrderArr);
tableDataRow.iOrder = commonUtils.isNotEmptyArr(tableData) ? iOrderMax + 1 : 0;
if (isWait) {
return tableDataRow;
} else if (commonUtils.isNotEmptyObject(tableDataRow)) {
tableData.push(tableDataRow);
processData.filter(item => item.sControlId === sId && item.sType !== '3').forEach((item) => {
const processRow = JSON.parse(JSON.stringify(item));
processRow.sId = commonUtils.createSid();
processRow.handleType = 'add';
processRow.sControlId = tableDataRow.sId;
processRow.sPartsName = tableDataRow.sPartsName;
processRow.sSrcProcessTbId = item.sId;
processData.push(processRow);
});
processData = this.sortData(tableData, processData);
materialsData.filter(item => item.sControlId === sId && item.sType !== '2').forEach((materialsItem) => {
const materialsRow = JSON.parse(JSON.stringify(materialsItem));
materialsRow.sId = commonUtils.createSid();
materialsRow.handleType = 'add';
materialsRow.sControlId = tableDataRow.sId;
materialsRow.sPartsName = tableDataRow.sPartsName;
// 材料对应工序的ID要变化
if (commonUtils.isNotEmptyArr(processData)) {
const iProcessIndex = processData.findIndex(item => item.sControlId === tableDataRow.sId && item.sSrcProcessTbId === materialsItem.sProcessTbId);
if (iProcessIndex > -1) {
materialsRow.sProcessTbId = processData[iProcessIndex].sId;
}
}
materialsData.push(materialsRow);
});
const treeState = this.handleGetControlTreeData(tableData, true);
const tableSelectedNewRowKeys = [];
if (commonUtils.isNotEmptyObject(newId)) {
tableSelectedNewRowKeys.push(newId);
}
if (commonUtils.isNotEmptyArr(slaveData)) {
slaveData.forEach((item, index) => {
/* 合版信息表增加一条从表数据 */
const packDataRow = this.handlePackDataAdd(item, index, tableDataRow.sId, 'add');
if (commonUtils.isNotEmptyObject(packDataRow)) {
// packDataRow.dCombineQty = 1;
packData.push(packDataRow);
}
});
}
this.props.onSaveState({
...treeState,
[`${name}Data`]: tableData,
[`${name}Pagination`]: { total: tableData.length, current: 9999 },
[`${name}SelectedRowKeys`]: tableSelectedNewRowKeys,
treeSelectedKeys: tableSelectedNewRowKeys,
materialsSelectedRowKeys: [],
materialsData,
processData,
packData,
});
}
}
}
}
}
};
singlePQtyChange = (tableDataRow) => {
const bZfZf = tableDataRow.iPrintMode === 2; // 正反版
const bSample = tableDataRow.dSumPQty >= 4; // 样本
tableDataRow.iPrintModePo = tableDataRow.iPrintMode <= 2 ? 2 : tableDataRow.iPrintMode === 3 ? 0 : -1;
if (bSample) {
if (tableDataRow.dSinglePQty > 0) {
tableDataRow.dPlateQty = Math.ceil(tableDataRow.dSumPQty / tableDataRow.dSinglePQty);
}
if (bZfZf && (tableDataRow.iPrintModePo === 2)) { // 双面样本,正反
if (tableDataRow.dPlateQty < 2) { // 不管建议放正自翻版了,点方式什么是什么
tableDataRow.dPlateQty = 2;
tableDataRow.iStick = Math.ceil(commonUtils.isNull(tableDataRow.dPlateQty, 0) / 2);
tableDataRow.dSumPlateQty = tableDataRow.iStick * (
commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0));
} else {
if (tableDataRow.iPrintModePo !== 2) { // 单面样本
tableDataRow.dPlateQty = (commonUtils.isNull(tableDataRow.dSumPQty, 0) * 0.5) / tableDataRow.dSinglePQty;
tableDataRow.iStick = Math.ceil(tableDataRow.dPlateQty);
tableDataRow.dSumPlateQty = tableDataRow.iStick * (commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0));
} else {
tableDataRow.dPlateQty = commonUtils.isNull(tableDataRow.dSumPQty, 0) / commonUtils.isNull(commonUtils.nullIf(tableDataRow.dSinglePQty, 0), 1);
tableDataRow.iStick = Math.ceil(tableDataRow.dPlateQty / 2);
}
tableDataRow.dSumPlateQty = tableDataRow.iStick * (
commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0));
}
} else {
if (tableDataRow.iPrintModePo !== 2) { // 单面样本
tableDataRow.dPlateQty = (commonUtils.isNull(tableDataRow.dSumPQty, 0) * 0.5) / tableDataRow.dSinglePQty;
} else {
tableDataRow.dPlateQty = commonUtils.isNull(tableDataRow.dSumPQty, 0) / commonUtils.isNull(commonUtils.nullIf(tableDataRow.dSinglePQty, 0), 1);
}
tableDataRow.iStick = Math.ceil(tableDataRow.dPlateQty);
tableDataRow.dSumPlateQty = tableDataRow.iStick * (
commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0));
}
if (tableDataRow.iStick > 0 && tableDataRow.dSinglePQty > 0) {
tableDataRow.dMachineQty = commonUtils.convertFixNum((commonUtils.isNull(tableDataRow.dPartsQty, 0) * commonUtils.isNull(tableDataRow.dSumPQty, 0) * 0.5) / tableDataRow.dSinglePQty / tableDataRow.iStick, 0);
tableDataRow.dSumMachineQty = tableDataRow.dMachineQty * tableDataRow.iStick;
}
} else {
tableDataRow.iStick = 1;
tableDataRow.dSumPlateQty = tableDataRow.iStick * (
commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0));
if (bZfZf && tableDataRow.iPrintModePo === 2) {
tableDataRow.dPlateQty = 2;
tableDataRow.dSumPlateQty = tableDataRow.iStick * (commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) + commonUtils.isNull(tableDataRow.iOppositeColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0));
} else {
tableDataRow.dPlateQty = 1;
tableDataRow.dSumPlateQty = tableDataRow.iStick * (commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0));
}
if (tableDataRow.dSinglePQty > 0) {
if (tableDataRow.iPage > 1) { // 笔记本 用 非样本 来做, 倍率是每页都一样才可以用 原先 /2 是指页数, 现在直接按张数
tableDataRow.dMachineQty = commonUtils.convertFixNum((tableDataRow.dPartsQty * tableDataRow.iPage) / tableDataRow.dSinglePQty, 0);
} else {
tableDataRow.dMachineQty = commonUtils.convertFixNum(commonUtils.isNull(tableDataRow.dPartsQty, 0) / tableDataRow.dSinglePQty, 0);
tableDataRow.dSumMachineQty = tableDataRow.dMachineQty * tableDataRow.iStick;
}
}
}
/* 计算材料开数 */
// const dMachineLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineLength, 0)); /* 上机长 */
// const dMachineWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineWidth, 0)); /* 上机宽 */
// const dMaterialsLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsLength, 0)); /* 材料长 */
// const dMaterialsWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsWidth, 0)); /* 材料宽 */
// const sResult = this.props.onResolveMachineComposing(dMachineLength, dMachineWidth, dMaterialsLength, dMaterialsWidth);
// if (commonUtils.isNotEmptyObject(sResult)) {
// const dMaterialsKQty = sResult.totalNum;
// tableDataRow.dMaterialsKQty = dMaterialsKQty;
// }
return tableDataRow;
};
handleCancel1 = () => {
this.props.onSaveState({
visible: false,
});
};
handleOk = async (flag, tmpCheck, isWait) => {
const {
sModelsId, masterData, app, checkConditions, sCheckModelId, checkPersonData, currentId, masterConfig, slaveConfig, checkConfig,
} = this.props;
const { currentPane } = app;
const bCkxTmpCheck = app.systemData.filter(item => item.sName === 'CkxTmpCheck')[0].sValue;
if (bCkxTmpCheck === '1') {
const returnData = await this.props.onDataAudit(flag, tmpCheck, isWait);
if (returnData.code === 1) {
if (returnData.dataset.rows[0].dataSet.outData[0].sCode === 1) {
this.props.onGetData(masterConfig, slaveConfig, checkConfig);
message.success(returnData.msg);
} else {
message.error(returnData.dataset.rows[0].dataSet.outData[0].sReturn);
}
} else { /* 失败 */
this.props.getServiceError(returnData);
}
} else {
const dataPersonArray = commonUtils.isEmptyObject(this.props.dataPersonArray) ? [] : this.props.dataPersonArray;
if (commonUtils.isEmptyObject(dataPersonArray)) {
checkPersonData.forEach((item) => {
dataPersonArray.push(item.sUserId);
});
}
const dataPersonString = dataPersonArray.join(',');
const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const value = {
sProName: 'Sp_System_AutoSendCheckMsg',
paramsMap: {
sFormGuid: sModelsId,
sBillKey: currentPane.sProcName,
sTbName: masterConfig.sTbName,
sGuid: masterData.sId,
sBillNo: masterData.sBillNo,
sCheckCondition: checkConditions,
sMemo: '',
sCheckModelGuid: sCheckModelId,
sCheckPerson: dataPersonString,
},
};
const returnData = (await commonServices.postValueService(app.token, value, url)).data;
if (returnData.code === 1) {
const noCheckMsg = commonFunc.showMessage(app.commonConst, 'NoCheckMsg'); /* 您有消息待审核 */
if (returnData.dataset.rows[0].dataSet.outData[0].sCode === 1) {
this.props.handleSendSocketMessage('examine', 'showImg', currentId, dataPersonString, noCheckMsg, null);
const urlCanCheckBill = `${commonConfig.server_host}checkModel/getCanCheckBill?sModelsId=${sModelsId}`;
const valueCanCheckBill = { sCheckModelId, checkPersonData, sBillId: masterData.sId };
const returnCanCheckBill = (await commonServices.postValueService(app.token, valueCanCheckBill, urlCanCheckBill)).data;
if (returnCanCheckBill.code === 1) {
if (returnCanCheckBill.dataset.rows[0].iCount === 1) {
this.props.onDataAudit(1, 1);
this.props.onSaveState({
visible: false,
});
return;
}
} else { /* 失败 */
this.props.getServiceError(returnCanCheckBill);
}
this.props.handleSendSocketMessage('reflush', 'showImg', currentId, dataPersonString, noCheckMsg, null);
message.success(returnData.msg);
} else {
message.error(returnData.dataset.rows[0].dataSet.outData[0].sReturn);
}
} else { /* 失败 */
this.props.getServiceError(returnData);
}
}
this.props.onSaveState({
visible: false,
});
};
/** 树节点选中 */
handleTreeSelect = (name, checkedKeys, e) => {
let { controlSelectedRowKeys } = this.props;
controlSelectedRowKeys = checkedKeys; /* 把树形选中节点赋值给表格部件选中节点 */
this.props.onTreeSelect(name, checkedKeys, e);
this.props.onSaveState({
controlSelectedRowKeys,
});
};
handleTabChange = (value) => {
this.setState({
currentTab: +value,
});
}
handleCancelProcessParamsModalVisible = () => { // 工艺参数弹窗消失
this.props.onSaveState({
sProcessParamsModalVisible: false,
});
}
handleProcessParamsOk = () => { // 工艺参数弹窗确定按钮
const {
processData,
processRecord,
processConfig,
} = this.props;
if (commonUtils.isNotEmptyArr(processData) && commonUtils.isNotEmptyObject(processRecord)) {
const processSelectDataIndex = processData.findIndex(item => item.sId === processRecord.sId);
if (processSelectDataIndex > -1) {
let sProcessParamStr = '';
// eslint-disable-next-line no-plusplus
for (let i = 1; i < 7; i++) {
const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`);
if (iIndex > -1 && !commonUtils.isEmpty(processData[processSelectDataIndex][`sParam${i.toString()}`])) {
sProcessParamStr += `${processData[processSelectDataIndex][`sParam${i.toString()}`]}:${processData[processSelectDataIndex][`sParamValue${i.toString()}`] === undefined ? '' : processData[processSelectDataIndex][`sParamValue${i.toString()}`]},`;
}
}
processData[processSelectDataIndex] = { ...processData[processSelectDataIndex], sProcessParamStr };
}
}
this.props.onSaveState({
processData,
sProcessParamsModalVisible: false,
});
}
handleDrag = (data) => {
let { controlSelectedRowKeys } = this.props;
if(this.props.enabled && controlSelectedRowKeys.length) {
if(isQianCai) {
// process : 0-1-2 部品工序 : 3成品工序;
let processData = this.props.processData.slice(0);
let preDataIndex = 0;
let preData = data.filter(item => item.sType === '0' && item.sControlId === this.props.controlSelectedRowKeys[0]).map((item) => {
preDataIndex = preDataIndex + 1;
return {...item, iOrder: preDataIndex}
});
let afterDataIndex = 0;
let afterData = data.filter(item => item.sType !== '3' && item.sType !== '0' && item.sControlId === this.props.controlSelectedRowKeys[0]).map((item) => {
afterDataIndex = afterDataIndex + 1;
return {...item, iOrder: afterDataIndex}
});
let allData = preData.concat(afterData);
allData.forEach((item, index) => {
if(item.sControlId === this.props.controlSelectedRowKeys[0]) {
if(!allData[index].handleType) {
allData[index].handleType = 'update';
}
}
});
processData = processData.filter(item => item.sControlId !== this.props.controlSelectedRowKeys[0]);
processData = processData.concat(allData);
this.props.onSaveState({ processData});
} else {
// process : 0-1-2 部品工序 : 3成品工序;
let processData = this.props.processData.slice(0);
let preDataIndex = 0;
let preData = data.filter(item => item.sType === '0' && item.sControlId === this.props.controlSelectedRowKeys[0]).map((item) => {
preDataIndex = preDataIndex + 1;
return {...item, iOrder: preDataIndex}
});
let inDataIndex = 0;
let inData = data.filter(item => item.sType === '1' && item.sControlId === this.props.controlSelectedRowKeys[0]).map((item) => {
inDataIndex = inDataIndex + 1;
return {...item, iOrder: inDataIndex}
});
let afterDataIndex = 0;
let afterData = data.filter(item => item.sType === '2' && item.sControlId === this.props.controlSelectedRowKeys[0]).map((item) => {
afterDataIndex = afterDataIndex + 1;
return {...item, iOrder: afterDataIndex}
});
let allData = preData.concat(inData, afterData);
allData.forEach((item, index) => {
if(item.sControlId === this.props.controlSelectedRowKeys[0]) {
if(!allData[index].handleType) {
allData[index].handleType = 'update';
}
}
});
processData = processData.filter(item => item.sControlId !== this.props.controlSelectedRowKeys[0]);
processData = processData.concat(allData);
this.props.onSaveState({ processData});
}
}
}
handleProductDrag = (data) => {
if(this.props.enabled) {
// process : 0-1-2 部品工序 : 3成品工序;
let processData = this.props.processData.slice(0);
let dataIndex = 0;
const allData = data.filter(item => item.sType === '3' && item.sCombinePartsName === this.props.slaveSelectedRowKeys[0]).map((item) => {
dataIndex = dataIndex + 1;
return {...item, iOrder: dataIndex, handleType: item.handleType ? item.handleType : 'update'};
});
processData = processData.filter(item => item.sCombinePartsName !== this.props.slaveSelectedRowKeys[0]);
processData = processData.concat(allData);
this.props.onSaveState({ processData });
}
}
render() {
const { pageLoading, masterData, fastOrderModalVisible, sModelsType, app } = this.props;
const imgSrc = commonBusiness.handleAddIcon(masterData, sModelsType, app );
return (
,
disableimg:
,
};
const processDown = {
title: '下移',
width: { width },
height: { height },
img:
,
disableimg:
,
};
const processTop = {
title: '置顶',
width: { width },
height: { height },
img:
,
disableimg:
,
};
const processBottom = {
title: '置底',
width: { width },
height: { height },
img:
,
disableimg:
,
};
let chooseProcessConfigRow;
let onChooseProcessIndex;
/* 获取toolbar 选择工序 */
if (commonUtils.isNotEmptyObject(masterConfigOld)) {
onChooseProcessIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseProcess');
if (onChooseProcessIndex > -1) {
chooseProcessConfigRow = props.masterConfig.gdsconfigformslave[onChooseProcessIndex];
}
}
/* 获取toolbar 选择材料 */
let chooseMaterialsConfigRow;
if (commonUtils.isNotEmptyObject(masterConfigOld)) {
const iIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseMaterials');
if (iIndex > -1) {
chooseMaterialsConfigRow = props.masterConfig.gdsconfigformslave[iIndex];
}
}
/* 获取toolbar 选择成品工序 */
let bShowProductProcess = false;
let chooseProductProcessConfigRow = {};
let onChooseProductProcessIndex;
if (commonUtils.isNotEmptyObject(masterConfigOld)) {
onChooseProductProcessIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseProductProcess');
if (onChooseProductProcessIndex > -1) {
chooseProductProcessConfigRow = props.masterConfig.gdsconfigformslave[onChooseProductProcessIndex];/* 配置了成品工序按钮 */
bShowProductProcess = true;/* 配置了成品工序按钮 */
}
}
/* 获取toolbar 选择成品材料 */
let bShowProductMaterials = false;
let chooseProductMaterialsConfigRow = {};
let onChooseProductMaterialsIndex;
if (commonUtils.isNotEmptyObject(masterConfigOld)) {
onChooseProductMaterialsIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseProductMaterials');
if (onChooseProductMaterialsIndex > -1) {
chooseProductMaterialsConfigRow = props.masterConfig.gdsconfigformslave[onChooseProductMaterialsIndex];/* 配置了成品工序按钮 */
bShowProductMaterials = true;/* 配置了成品材料按钮 */
}
}
const slaveTableProps = {
...commonBusiness.getTableTypes('slave', props),
onKeyDown: props.onKeyDown,
tableProps: {
rowSelection: null, pagination, onChange: props.onTitleChange, setAdd, setCopy, setDelete, AutoTableHeight: '100%',
},
};
const controlPropsType = {
...commonBusiness.getTableTypes('control', props),
onKeyDown: props.onKeyDown,
// filteredValue: props.slaveSelectedRowKeys,
// onFilterData: props.onFilterData,
// OnGetFilterData: props.OnGetFilterData,
tableProps: {
rowSelection: null,
// setAdd,
// setCopyAll,
// setDelete,
setProcess,
setMaterial,
// bShowProductProcess, /* 是否显示成品工序 */
// bShowProductMaterials, /* 是否显示成品工序 */
chooseProcessConfigRow,
chooseMaterialsConfigRow,
// chooseProductProcessConfigRow, /* 成品工序按钮配置 */
// chooseProductMaterialsConfigRow, /* 成品材料按钮配置 */
AutoTableHeight: 132,
// onRow: (record) => {
// return {
// onClick: () => { props.onRowClick('control', record); },
// onDoubleClick: () => { props.onDoubleClick('control', record); },
// onMouseEnter: () => { props.onRowMouseEnter('control', record); },
// };
// },
},
};
const name = 'controlTree';
const treeProps = {
...commonBusiness.getTreeTypes('tree', props),
isSearch: false,
checkable: false,
disabled: false,
checkedAll: false,
unChecked: false,
[`${name}Column`]: props[`${name}Column`],
[`${name}Config`]: props[`${name}Config`],
[`${name}Data`]: props[`${name}Data`],
getFloatNum: props.getFloatNum,
getSqlDropDownData: props.getSqlDropDownData,
getSqlCondition: props.getSqlCondition,
handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord,
getDateFormat: props.getDateFormat,
onDoubleClick: props.onDoubleClick,
onSelect: props.onSelectTree,
expandedKeys: props.expandedKeys,
showLine: true,
};
const dataFilter = (data, type, bFinal) => {
// materials : 0-1部件材料 : 2成品材料;
// process : 0-1-2 部品工序 : 3成品工序;
// bfinal: 是否成品
const { slaveSelectedRowKeys, controlSelectedRowKeys } = props;
const oriData = data.data || [];
if (data.data) {
let res = [];
switch (type) {
case 'materials':
if (finishedMaterialsColumn) {
if (bFinal) { /* 成品材料 */
if (slaveSelectedRowKeys && slaveSelectedRowKeys.length) {
res = oriData.filter((val) => {
return val.sType === '2' && (val.sCombinePartsName === slaveSelectedRowKeys[0] || !val.sCombinePartsName);
});
} else {
res = oriData.filter((val) => {
return val.sType === '2';
});
}
} else { /* 部件材料 */
res = oriData.filter((val) => {
return val.sType !== '2';
});
}
} else {
res = oriData;
}
break;
case 'process':
if (finishedProcessColumn) {
if (bFinal) { /* 成品工序 */
if (slaveSelectedRowKeys && slaveSelectedRowKeys.length) {
res = oriData.filter((val) => {
return val.sType === '3' && (val.sCombinePartsName === slaveSelectedRowKeys[0] || !val.sCombinePartsName);
});
} else {
res = oriData.filter((val) => {
return val.sType === '3';
});
}
} else { /* 部件工序 */
if (controlSelectedRowKeys && controlSelectedRowKeys.length) {
res = oriData.filter((val) => {
return val.sType !== '3' && (val.sControlId === controlSelectedRowKeys[0] || !val.sControlId);
});
} else {
res = oriData.filter((val) => {
return val.sType !== '3';
});
}
if(isQianCai) {
const pre = res.filter(item => item.sType == '0').sort((a, b) => a.iOrder - b.iOrder);
const after = res.filter(item => (item.sType == '1' || item.sType == '2')).sort((a, b) => a.iOrder - b.iOrder);
res = pre.concat(after);
}
}
} else {
res = oriData;
}
break;
default:
res = oriData;
}
return res;
} else {
return oriData || [];
}
};
const materialsPropsType = {
...commonBusiness.getTableTypes('materials', props),
data: dataFilter(commonBusiness.getTableTypes('materials', props), 'materials'),
filteredValue: props.controlSelectedRowKeys,
onFilterData: props.onFilterData,
OnGetFilterData: props.OnGetFilterData,
onKeyDown: props.onKeyDown,
tableProps: {
rowSelection: null,
setAdd,
setCopy,
setDelete,
AutoTableHeight: '100%',
sticky: {
offsetHeader: stickyHeight,
},
},
};
/* 选择成品材料s */
const finishedMaterialsPropsType = {
...commonBusiness.getTableTypes('materials', props),
data: dataFilter(commonBusiness.getTableTypes('materials', props), 'materials', true),
headerColumn: finishedMaterialsColumn,
config: finishedMaterialsConfig,
filteredValue: props.controlSelectedRowKeys,
// onFilterData: props.onFilterProductData,
OnGetFilterData: props.OnGetFilterData,
onKeyDown: props.onKeyDown,
tableProps: {
rowSelection: null,
setAdd,
setCopy,
setDelete,
AutoTableHeight: '100%',
bShowProductMaterials,
chooseProductMaterialsConfigRow, /* 成品材料按钮配置 */
sticky: {
offsetHeader: stickyHeight,
},
},
};
const processPropsType = {
...commonBusiness.getTableTypes('process', props),
data: dataFilter(commonBusiness.getTableTypes('process', props), 'process'),
filteredValue: props.controlSelectedRowKeys,
onFilterData: props.onFilterData,
OnGetFilterData: props.OnGetFilterData,
onKeyDown: props.onKeyDown,
tableProps: {
rowSelection: null,
setAdd,
setCopy,
setDelete,
AutoTableHeight: '100%',
sticky: {
offsetHeader: stickyHeight,
},
},
onDrag: props.onDrag,
isDragAndDrop: true,
};
/* 选择成品材料 */
const finishedProcessPropsType = {
...commonBusiness.getTableTypes('process', props),
configName: 'finishedProcess',
data: dataFilter(commonBusiness.getTableTypes('process', props), 'process', true),
headerColumn: finishedProcessColumn,
config: finishedProcessConfig,
filteredValue: props.controlSelectedRowKeys,
// onFilterData: props.onFilterProductData,
OnGetFilterData: props.OnGetFilterData,
onKeyDown: props.onKeyDown,
tableProps: {
rowSelection: null,
setAdd,
setCopy,
setDelete,
bShowProductProcess,
chooseProductProcessConfigRow, /* 成品工序按钮配置 */
AutoTableHeight: '100%',
sticky: {
offsetHeader: stickyHeight,
},
},
onDrag: props.onProductDrag,
};
const manyqtysPropsType = {
...commonBusiness.getTableTypes('manyqtys', props),
onKeyDown: props.onKeyDown,
tableProps: {
rowSelection: null, setAdd, setCopy, setDelete, AutoTableHeight: '100%',
},
isDragAndDrop: true,
};
let colorTableProps = {};
// let cProps = {};
if (colorConfigGrdVisible) {
colorTableProps = {
...commonBusiness.getTableTypes('color', props),
onKeyDown: props.onKeyDown,
tableProps: {
rowSelection: null, setAdd, setCopy, setDelete, AutoTableHeight: '100%',
},
};
// cProps = { ...commonBusiness.createMemoProps('color', props) };
}
const packTableProps = {
...commonBusiness.getTableTypes('pack', props),
filteredValue: props.controlSelectedRowKeys,
onFilterData: props.onFilterData,
onKeyDown: props.onKeyDown,
tableProps: {
setCopy, setDelete, CalLastWidth: '1150', AutoTableHeight: '300px',
},
bRowClick: true,
};
let combinePartsConfig = {};
if (commonUtils.isNotEmptyObject(props.packConfig)) {
combinePartsConfig = JSON.parse(JSON.stringify(props.packConfig));
const gdsconfigformslaveFilter = combinePartsConfig.gdsconfigformslave.filter(item => (item.sName === 'sId'
|| item.sName === 'sCustomerName'
|| item.sName === 'sProductName'
|| item.sName === 'sCombinePartsName'));
combinePartsConfig.gdsconfigformslave = gdsconfigformslaveFilter;
combinePartsConfig.bMutiSelect = false;
}
let combinePartsColumn = [];
if (commonUtils.isNotEmptyObject(props.packColumn)) {
combinePartsColumn = JSON.parse(JSON.stringify(props.packColumn));
const packColumnFilter = props.packColumn.filter(item => (item.dataIndex === 'sId'
|| item.dataIndex === 'sCustomerName'
|| item.dataIndex === 'sProductName'
|| item.dataIndex === 'sCombinePartsName'));
combinePartsColumn = packColumnFilter;
}
const combinePartsTableProps = {
app: {
...props.app,
currentPane: {
...props.app.currentPane,
formRoute: '/indexPage/commonList',
route: '/indexPage/commonList',
name: 'combineParts',
config: combinePartsConfig,
select: props.onSelectCombinePartsChoose,
selectCancel: props.onCancelModal.bind(this, 'combinePartsChooseVisible'),
},
},
formRoute: '/indexPage/commonList',
slaveConfig: combinePartsConfig,
slaveColumn: combinePartsColumn,
slaveData: props.combinePartsData,
slaveSelectedRowKeys: props.combinePartsSelectedRowKeys,
selectedRowKeys: props.combinePartsSelectedRowKeys,
pageLoading: false,
dispatch: props.dispatch,
content: props.content,
id: new Date().getTime().toString(),
realizeHeight: props.realizeHeight, /* 拖动偏移高度 */
};
/* 工序表选择颜色 */
let chooseColorsConfig = {};
let searchColorsType = {};
if (commonUtils.isNotEmptyObject(props) && commonUtils.isNotEmptyObject(props.processConfig)) {
const iIndex = props.processConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseColors');
if (iIndex > -1) {
chooseColorsConfig = props.processConfig.gdsconfigformslave[iIndex];
}
searchColorsType = {
app: {
...props.app,
currentPane: {
name: 'sisColor',
config: chooseColorsConfig,
conditonValues: props.getSqlCondition(chooseColorsConfig),
title: '选择颜色',
route: '/indexPage/commonList',
formRoute: '/indexPage/commonList',
formId: chooseColorsConfig.sActiveId,
key: sModelsId + chooseColorsConfig.sId,
sModelsType: 'search/sisColor',
select: props.onSelectSisColor,
selectCancel: props.onSelectCancel,
},
},
enabled: props.enabled,
sisColorSelectedData: props.sisColorSelectedData,
slaveSelectedRowKeys: props.sisColorSelectedRowKeys,
dispatch: props.dispatch,
content: props.content,
id: new Date().getTime().toString(),
realizeHeight: props.realizeHeight, /* 拖动偏移高度 */
};
searchColorsType.app = {
...searchColorsType.app,
...props.showCacheData(props.isSColorSerialMemo?.current, props.processData, props.processSelectedRowId) || {},
};
}
let searchProcessType = {};
let chooseProcessConfig = {};
let setProcessTitle = commonFunc.showMessage(app.commonConst, 'setProcess');/* 选择工序标题 */
if (commonUtils.isNotEmptyObject(props.processChooseData)) {
const iIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseProcess');
if (iIndex > -1) {
chooseProcessConfig = props.masterConfig.gdsconfigformslave[iIndex];
}
setProcessTitle = props.processChooseData.sMenuName;
searchProcessType = {
app: {
...props.app,
currentPane: {
name: 'process',
config: chooseProcessConfig,
conditonValues: props.getSqlCondition(chooseProcessConfig),
title: props.processChooseData.sMenuName,
route: props.processChooseData.sName,
formId: props.processChooseData.sId,
key: sModelsId + props.processChooseData.sId,
sModelsType: props.processChooseData.sModelType,
select: props.onSelect,
selectCancel: props.onSelectCancel,
},
},
dispatch: props.dispatch,
fatherModelsType: props.sModelsType,
content: props.content,
id: new Date().getTime().toString(),
realizeHeight: props.realizeHeight, /* 拖动偏移高度 */
};
}
/* 选择成品工序 */
let chooseProdutProcessType = {};
let chooseProdutProcessConfig = {};
if (commonUtils.isNotEmptyObject(props.productProcessChooseData)) {
const iIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseProductProcess');
if (iIndex > -1) {
chooseProdutProcessConfig = props.masterConfig.gdsconfigformslave[iIndex];
}
let slaveFinalData = [];
let slaveFinalSelectedRowKeys =[];
if (commonUtils.isNotEmptyArr(props.slaveData)) {
slaveFinalData = JSON.parse(JSON.stringify(props.slaveData));
if (commonUtils.isNotEmptyArr(slaveFinalData) && slaveFinalData.length > 0) {
slaveFinalData.forEach((item) => {
item.sSlaveId = commonUtils.createSid(); /* 添加成品工序从表 */
});
}
/* 选择成品工序 只有一条从表 则默认选中 */
if(slaveFinalData.length ===1){
slaveFinalSelectedRowKeys.push(slaveFinalData[0].sSlaveId);
}
}
let slaveFinalConfig = {};
if (commonUtils.isNotEmptyObject(props.slaveConfig)) {
slaveFinalConfig = JSON.parse(JSON.stringify(props.slaveConfig));
slaveFinalConfig.bMutiSelect = true;
}
chooseProdutProcessType = {
app: {
...props.app,
currentPane: {
name: 'chooseProductProcess',
config: chooseProdutProcessConfig,
conditonValues: props.getSqlCondition(chooseProdutProcessConfig),
title: props.productProcessChooseData.sMenuName,
route: props.productProcessChooseData.sName,
formId: props.productProcessChooseData.sId,
key: sModelsId + props.productProcessChooseData.sId,
sModelsType: 'search/finalProcess',
select: props.onSelectFinalProcess, /* 选择成品工序 */
selectCancel: props.onCancelModal.bind(this, 'productProcessChooseVisible'),
},
},
slaveFinalConfig,
slaveFinalColumn: props.slaveColumn,
slaveFinalData,
slaveFinalSelectedRowKeys,
dispatch: props.dispatch,
fatherModelsType: props.sModelsType,
content: props.content,
id: new Date().getTime().toString(),
};
}
/* 选择成品材料 */
let chooseProductMaterialsType = {};
let chooseProductMaterialsConfig = {};
if (commonUtils.isNotEmptyObject(props.productMaterialsChooseData)) {
const iIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseProductMaterials');
if (iIndex > -1) {
chooseProductMaterialsConfig = props.masterConfig.gdsconfigformslave[iIndex];
}
let slaveFinalData = [];
let slaveFinalSelectedRowKeys =[];
if (commonUtils.isNotEmptyArr(props.slaveData)) {
slaveFinalData = JSON.parse(JSON.stringify(props.slaveData));
if (commonUtils.isNotEmptyArr(slaveFinalData) && slaveFinalData.length > 0) {
slaveFinalData.forEach((item) => {
item.sSlaveId = commonUtils.createSid(); /* 添加成品工序从表s */
});
}
/* 选择成品材料 只有一条从表 则默认选中 */
if(slaveFinalData.length ===1){
slaveFinalSelectedRowKeys.push(slaveFinalData[0].sSlaveId);
}
}
let slaveFinalConfig = {};
if (commonUtils.isNotEmptyObject(props.slaveConfig)) {
slaveFinalConfig = JSON.parse(JSON.stringify(props.slaveConfig));
slaveFinalConfig.bMutiSelect = true;
}
chooseProductMaterialsType = {
app: {
...props.app,
currentPane: {
name: 'productMaterials',
config: chooseProductMaterialsConfig,
conditonValues: props.getSqlCondition(chooseProductMaterialsConfig),
title: props.productMaterialsChooseData.sMenuName,
route: props.productMaterialsChooseData.sName,
formId: props.productMaterialsChooseData.sId,
key: sModelsId + props.productMaterialsChooseData.sId,
sModelsType: 'search/finalMaterials',
select: props.onSelectProductMaterial,
selectCancel: props.onCancelModal.bind(this, 'productMaterialsChooseVisible'),
},
},
slaveFinalConfig,
slaveFinalColumn: props.slaveColumn,
slaveFinalData,
slaveFinalSelectedRowKeys,
dispatch: props.dispatch,
fatherModelsType: props.sModelsType,
content: props.content,
id: new Date().getTime().toString(),
};
}
let searchMaterialsType = {};
let chooseMaterialsConfig = {};
let setMaterialTitle = commonFunc.showMessage(app.commonConst, 'setMaterial');/* 选择材料标题 */
if (commonUtils.isNotEmptyObject(props.materialsChooseData)) {
const iIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseMaterials');
if (iIndex > -1) {
chooseMaterialsConfig = props.masterConfig.gdsconfigformslave[iIndex];
}
setMaterialTitle = props.materialsChooseData.sMenuName;
searchMaterialsType = {
app: {
...props.app,
currentPane: {
name: 'materials',
config: chooseMaterialsConfig,
conditonValues: props.getSqlCondition(chooseMaterialsConfig),
title: props.materialsChooseData.sMenuName,
route: props.materialsChooseData.sName,
formId: props.materialsChooseData.sId,
key: sModelsId + props.materialsChooseData.sId,
sModelsType: props.materialsChooseData.sModelType,
select: props.onSelect,
selectCancel: props.onSelectCancel,
},
},
dispatch: props.dispatch,
content: props.content,
id: new Date().getTime().toString(),
realizeHeight: props.realizeHeight, /* 拖动偏移高度 */
};
}
let productProcessInfoType = {};
let productProcessInfoConfig = {};
let processCardSearchResult = commonFunc.showMessage(app.commonConst, 'processCardSearchResult');/* 复制从工艺卡查询结果 */
if (commonUtils.isNotEmptyObject(props.productProcessInfoChooseData)) {
const productProcessInfoCopyFromKey = props.productProcessInfoCopyFromKey;
const iIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === productProcessInfoCopyFromKey);
if (iIndex > -1) {
productProcessInfoConfig = props.masterConfig.gdsconfigformslave[iIndex];
processCardSearchResult = commonUtils.isNotEmptyObject(productProcessInfoConfig) && commonUtils.isNotEmptyObject(productProcessInfoConfig.sActiveName) ? productProcessInfoConfig.sActiveName : processCardSearchResult;
}
productProcessInfoType = {
app: {
...props.app,
currentPane: {
name: 'productProcessInfo',
config: productProcessInfoConfig,
conditonValues: props.getSqlCondition(productProcessInfoConfig),
title: props.productProcessInfoChooseData.sMenuName,
route: props.productProcessInfoChooseData.sName,
formId: props.productProcessInfoChooseData.sId,
key: sModelsId + props.productProcessInfoChooseData.sId,
sModelsType: props.productProcessInfoChooseData.sModelType,
select: props.onSelect,
selectCancel: props.onSelectCancel,
},
},
dispatch: props.dispatch,
content: props.content,
id: new Date().getTime().toString(),
realizeHeight: props.realizeHeight, /* 拖动偏移高度 */
};
}
const tabChange = (e) => {
props.onTabChange(e);
};
const pane = app.panes.filter(paneTmp => paneTmp.key === sTabId)[0];
// const productInfo = commonFunc.showMessage(app.commonConst, 'productInfo');/* 产品信息 */
const materialsInfo = commonFunc.showMessage(app.commonConst, 'materialsInfo');/* 材料信息 */
const processInfo = commonFunc.showMessage(app.commonConst, 'processInfo');/* 工序信息 */
const manyqtysInfo = commonFunc.showMessage(app.commonConst, 'manyqtysInfo');/* 多数量 */
const productMaterialsInfo = commonFunc.showMessage(app.commonConst, 'productMaterialsInfo');/* 成品材料 */
const productProcessInfo = commonFunc.showMessage(app.commonConst, 'productProcessInfo');/* 成品工序 */
const colorInfo = commonFunc.showMessage(app.commonConst, 'colorInfo');/* 颜色信息 */
const setSisColorTitle = commonFunc.showMessage(app.commonConst, 'setSisColor');/* 选择颜色标题 */
const setProductCombinationTitle = commonFunc.showMessage(app.commonConst, 'setProductCombination');/* 选择合拼产品标题 */
const setProductProcessTitle = commonFunc.showMessage(app.commonConst, 'setProductProcess');/* 选择成品工序标题 */
const setProductMaterialsTitle = commonFunc.showMessage(app.commonConst, 'setProductMaterials');/* 选择成品材料标题 */
// const processCardSearchResult = commonFunc.showMessage(app.commonConst, 'processCardSearchResult');/* 复制从工艺卡查询结果 */
const fastOrder = commonFunc.showMessage(app.commonConst, 'fastOrder');/* 快速下单 */
const comfirmOrder = commonFunc.showMessage(app.commonConst, 'comfirmOrder');/* 确认下单 */
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 sProcessParams = commonFunc.showMessage(app.commonConst, 'sProcessParams');/* 选择工艺参数标题 */
// eslint-disable-next-line jsx-a11y/anchor-is-valid
const operateAdd = {props.enabled ? setAdd.img : setAdd.disableimg} ;
// eslint-disable-next-line jsx-a11y/anchor-is-valid
const operateAddChild = {props.enabled ? setAddChild.img : setAddChild.disableimg };
// eslint-disable-next-line jsx-a11y/anchor-is-valid
const operateCopy = {props.enabled ? setCopy.img : setCopy.disableimg};
// eslint-disable-next-line jsx-a11y/anchor-is-valid
const operateUpdate = {props.enabled ? setCopyAll.img : setCopyAll.disableimg };
// eslint-disable-next-line jsx-a11y/anchor-is-valid
const operateDel = {props.enabled ? setDelete.img : setDelete.disableimg};
let bControlShow = true; /* 控制表 */
if (commonUtils.isNotEmptyObject(props.masterConfig) && commonUtils.isNotEmptyArr(props.masterConfig.gdsconfigformslave)) {
const iIndexControl = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'tbControl');
if (iIndexControl > -1) {
bControlShow = props.masterConfig.gdsconfigformslave[iIndexControl].bVisible;
}
}
let bMaterialShow = true; /* 材料表 */
if (commonUtils.isNotEmptyObject(props.masterConfig) && commonUtils.isNotEmptyArr(props.masterConfig.gdsconfigformslave)) {
const iIndexMaterial = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'tbMaterial');
if (iIndexMaterial > -1) {
bMaterialShow = props.masterConfig.gdsconfigformslave[iIndexMaterial].bVisible;
}
}
let bProcessShow = true; /* 工序表 */
if (commonUtils.isNotEmptyObject(props.masterConfig) && commonUtils.isNotEmptyArr(props.masterConfig.gdsconfigformslave)) {
const iIndexProcess = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'tbProcess');
if (iIndexProcess > -1) {
bProcessShow = props.masterConfig.gdsconfigformslave[iIndexProcess].bVisible;
}
}
const bFinalMaterialsTabShow = commonUtils.isEmptyObject(finishedMaterialsConfig) ? false :true; /* 没有成品材料配置 则材料Tab不展示 */
const bFinalProcessTabShow = commonUtils.isEmptyObject(finishedProcessConfig) ? false :true; /* 没有成品工序配置 则工序Tab不展示 */
return (