Commit a68770c46e6f6ed8d3efa58f275f55585a8a25df

Authored by 陈鑫涛
1 parent d624af2a

排产

Showing 54 changed files with 16356 additions and 123 deletions

Too many changes to show.

To preserve performance only 6 of 54 files are displayed.

src/components/AuditInformation/AuditInformation.js 0 → 100644
  1 +/* eslint-disable no-const-assign,prefer-destructuring */
  2 +/**
  3 + * Created by mar105 on 2019-01-04.
  4 + */
  5 +// , Switch, Icon
  6 +import React, { Component } from 'react';
  7 +import { Form } from '@ant-design/compatible';
  8 +import '@ant-design/compatible/assets/index.css';
  9 +import { Layout, Spin, Tabs, Avatar, message, Select, Input, Button } from 'antd';
  10 +import * as commonFunc from './../Common/commonFunc';/* 通用单据方法 */ /* 通用单据方法 */
  11 +import StaticEditTable from '../Common/CommonTable';/* 可编辑表格 */
  12 +import styles from './../../index.less';
  13 +import CommonView from './../Common/CommonView';
  14 +import CommonBase from './../Common/CommonBase';/* 获取配置及数据 */
  15 +import * as commonUtils from './../../utils/utils';/* 通用方法 */
  16 +import * as commonBusiness from './../Common/commonBusiness';/* 单据业务功能 */
  17 +import commonConfig from './../../utils/config';
  18 +import * as commonServices from './../../services/services';/* 服务类 */
  19 +
  20 +const { TabPane } = Tabs;
  21 +const { Option } = Select;
  22 +const { Content } = Layout;
  23 +
  24 +class AuditInformation extends Component {
  25 + constructor(props) {
  26 + super(props);
  27 + this.state = {};
  28 + }
  29 + componentWillReceiveProps(nextProps) {
  30 + const {
  31 + formData, currentId, checkData, app,
  32 + } = nextProps;
  33 + let { masterConfig, canSendMsg } = nextProps;
  34 + const { userinfo } = app;
  35 + if (commonUtils.isEmptyArr(masterConfig) && formData.length > 0) {
  36 + const sId = currentId !== undefined ? currentId : '';
  37 + /* 数据Id */
  38 + masterConfig = formData.filter(item => !item.bGrd)[0];
  39 + const checkConfig = formData.filter(item => item.bGrd && item.sTbName === 'sysbillcheckresult')[0];
  40 + const checkColumn = commonFunc.getHeaderConfig(checkConfig);
  41 + this.handleGetData(masterConfig, checkConfig);
  42 + this.props.onSaveState({
  43 + masterConfig, sId, pageLoading: false, checkConfig, checkColumn, checked: true, canSendMsg: false,
  44 + });
  45 + } else if (commonUtils.isNotEmptyArr(checkData) && (JSON.stringify(this.props.checkData) !== JSON.stringify(checkData))) {
  46 + const iIndex = checkData.findIndex(item => item.sResult !== '1' && item.sResult !== '2' && item.sCheckPersonId === userinfo.sId);
  47 + if (iIndex > -1) {
  48 + canSendMsg = true;
  49 + }
  50 + this.props.onSaveState({ canSendMsg });
  51 + }
  52 + }
  53 +
  54 + shouldComponentUpdate(nextProps) {
  55 + const { checkColumn, masterConfig } = nextProps;
  56 + return commonUtils.isNotEmptyArr(checkColumn) || commonUtils.isNotEmptyObject(masterConfig);
  57 + }
  58 + /** 获取主表数据 */
  59 + handleGetData = async (masterConfig, checkConfig) => {
  60 + const { currentId } = this.props; /* 当前页签数据 */
  61 + const sId = currentId !== undefined ? currentId : '';
  62 + await this.props.handleGetDataOne({ name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' } });
  63 + const { masterData } = this.props;
  64 + if (!commonUtils.isEmptyObject(checkConfig) && !commonUtils.isEmptyObject(masterData)) {
  65 + this.props.handleGetDataSet({
  66 + name: 'check', configData: checkConfig, condition: { sSqlCondition: { sBillId: masterData.sBillId } },
  67 + });
  68 + }
  69 + };
  70 + handleForm = (form) => {
  71 + this.form = form;
  72 + };
  73 + handleSelectChange = (value) => {
  74 + let iReply = 1;
  75 + if (value === 'approve') {
  76 + iReply = 1;
  77 + } else if (value === 'refuse') {
  78 + iReply = 0;
  79 + }
  80 + this.props.onSaveState({ iReply });
  81 + };
  82 + handleSwitchChange = (value) => {
  83 + this.props.onSaveState({ checked: value });
  84 + };
  85 + handleSubmit = async () => {
  86 + const {
  87 + sModelsId, masterData, masterConfig, checkConfig,
  88 + } = this.props;
  89 + let { iReply } = this.props;
  90 + const sReply = document.getElementById('sReply').value;
  91 + iReply = commonUtils.isEmptyNumber(iReply) ? 1 : iReply;
  92 + const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
  93 + const value = {
  94 + sProName: 'Sp_System_ReplyCheckMsg',
  95 + paramsMap: {
  96 + sMsgGuid: masterData.sId,
  97 + sBillGuid: masterData.sBillId,
  98 + iReply,
  99 + sReply,
  100 + },
  101 + };
  102 + const returnData = (await commonServices.postValueService(this.props.app.token, value, url)).data;
  103 + if (returnData.code === 1) {
  104 + if (returnData.dataset.rows[0].dataSet.outData[0].sCode === 1) {
  105 + this.handleGetData(masterConfig, checkConfig);
  106 + message.success(returnData.msg);
  107 + } else {
  108 + message.error(returnData.dataset.rows[0].dataSet.outData[0].sReturn);
  109 + }
  110 + } else { /* 失败 */
  111 + this.props.getServiceError(returnData);
  112 + }
  113 + };
  114 + render() {
  115 + const { pageLoading, masterData } = this.props;
  116 + const imgSrc = commonBusiness.handleAddIcon(masterData);
  117 + return (
  118 + <Spin spinning={pageLoading}>
  119 + <WorkOrderComponent
  120 + {...this.props}
  121 + {...this.state}
  122 + onReturnForm={this.handleForm}
  123 + onSelectChange={this.handleSelectChange}
  124 + onSwitchChange={this.handleSwitchChange}
  125 + onSubmit={this.handleSubmit}
  126 + imgSrc={imgSrc}
  127 + />
  128 + </Spin>
  129 + );
  130 + }
  131 +}
  132 +
  133 +const WorkOrderComponent = Form.create({
  134 + mapPropsToFields(props) {
  135 + const { masterData } = props;
  136 + const obj = commonFunc.mapPropsToFields(masterData, Form);
  137 + return obj;
  138 + },
  139 +})((props) => {
  140 + const {
  141 + form, onReturnForm, onSelectChange, onSubmit, checked,
  142 + } = props;
  143 + /* 回带表单 */
  144 + onReturnForm(form);
  145 + const propsType = {
  146 + ...props,
  147 + onChange: props.onMasterChange,
  148 + };
  149 + const style = checked ? 'block' : 'none';
  150 + /*
  151 + <div style={{ padding: '10px 12px' }}>显示审核记录: &nbsp;
  152 + <Switch
  153 + checkedChildren={<Icon type="check" />}
  154 + unCheckedChildren={<Icon type="close" />}
  155 + onChange={onSwitchChange}
  156 + />
  157 + </div>
  158 + */
  159 + return (
  160 + <Form>
  161 + <Layout>
  162 + <Layout id="AudiInfomation" className={styles.clayout} style={{ padding: '90px 0 0 0' }}>
  163 + <Content className={styles.content} >
  164 + <div className="bill-search-group" >
  165 + <CommonView {...propsType} />
  166 + </div>
  167 + <div id="slaveTabs" className={styles.bShow} style={{ overflow: 'auto', display: style }}>
  168 + <div>
  169 + <Avatar src={props.imgSrc} />
  170 + </div>
  171 + <Tabs tabBarStyle={{ paddingLeft: '10px' }} >
  172 + <TabPane tab="审批信息" key={3} >
  173 + <StaticEditTable {...commonBusiness.getTableTypes('check', props)} footer="hidden" />
  174 + </TabPane>
  175 + </Tabs>
  176 + </div>
  177 + { props.canSendMsg ? (
  178 + <div style={{ paddingLeft: '13px', width: '30%' }}>
  179 + <span style={{ height: '40px', lineHeight: '40px' }}>回答内容:</span>
  180 + <Select defaultValue="approve" onChange={onSelectChange}>
  181 + <Option value="approve">批准</Option>
  182 + <Option value="refuse">拒绝</Option>
  183 + </Select>
  184 + </div>) : ''
  185 + }
  186 + { props.canSendMsg ? (<Input id="sReply" addonBefore="备注:" style={{ paddingLeft: '13px', width: '30%' }} />) : ''}
  187 + { props.canSendMsg ? (
  188 + <div style={{ marginTop: '8px', paddingLeft: '13px' }}>
  189 + <Button type="primary" htmlType="submit" onClick={onSubmit}>发送</Button>
  190 + </div>) : ''}
  191 + </Content>
  192 + </Layout>
  193 + </Layout>
  194 + </Form>
  195 + );
  196 +});
  197 +
  198 +export default CommonBase(AuditInformation);
src/components/Common/CommonCalculator.js 0 → 100644
  1 +/* eslint-disable function-paren-newline */
  2 +import React, { Component } from 'react';
  3 +import { Form } from '@ant-design/compatible';
  4 +import '@ant-design/compatible/assets/index.css';
  5 +import { Row, Col, Button } from 'antd';
  6 +import * as commonUtils from '../../utils/utils';
  7 +import commonConfig from '../../utils/config';
  8 +import * as commonFunc from './commonFunc';
  9 +import styles from '../../index.less';
  10 +
  11 +const FormItem = Form.Item;
  12 +
  13 +class CommonCalculatorComponent extends Component {
  14 + constructor(props) {
  15 + super(props);
  16 + this.state = {
  17 + };
  18 + }
  19 + /** 渲染前只执行一次 */
  20 + componentWillMount() {
  21 + this.assignmentWillProps(this.props);
  22 + }
  23 +
  24 + componentWillReceiveProps(nextProps) {
  25 + this.assignmentWillProps(nextProps);
  26 + }
  27 +
  28 + assignmentWillProps = (props) => {
  29 + this.setState({ disabled: props.enabled === undefined ? true : !props.enabled });
  30 + }
  31 +
  32 + handleClick = (e, child) => {
  33 + this.props.onButtonChange('calculator', child);
  34 + }
  35 +
  36 + handleField = () => {
  37 + this.props.onField();
  38 + };
  39 +
  40 + render() {
  41 + const { disabled } = this.state; /* 中文部分 */
  42 + const { masterConfig, gdsformconst, gdsjurisdiction } = this.props;
  43 + const gdsconfigformslave = commonUtils.isNotEmptyObject(masterConfig) ? masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '') : [];
  44 + const barContent = [];
  45 + const button = JSON.parse(JSON.stringify(commonConfig.jsqData));
  46 + button.forEach((btn) => {
  47 + const btnConfig = commonFunc.getConfig('', btn.sName, gdsconfigformslave, gdsformconst, gdsjurisdiction, btn.showName);
  48 + if (btnConfig.bVisible) {
  49 + barContent.push(
  50 + <Col span={5} key={btn.sName}>
  51 + <Button disabled={disabled} onClick={e => this.handleClick(e, btn.showName)}>
  52 + {btnConfig.showName}
  53 + </Button>
  54 + </Col>);
  55 + }
  56 + });
  57 + return (
  58 + <FormItem className={styles.subForm} style={{ marginTop: 0 }}>
  59 + <Row type="flex" justify="space-between">
  60 + <Col span={5}>
  61 + <Button disabled={disabled} onClick={e => this.handleClick(e, 1)}>1</Button>
  62 + <Button disabled={disabled} onClick={e => this.handleClick(e, 4)}>4</Button>
  63 + <Button disabled={disabled} onClick={e => this.handleClick(e, 7)}>7</Button>
  64 + <Button disabled={disabled} onClick={e => this.handleClick(e, 0)}>0</Button>
  65 + <Button disabled={disabled} onClick={e => this.handleClick(e, '(')}>(</Button>
  66 + <Button disabled={disabled} onClick={e => this.handleClick(e, '>=')}>&gt;=</Button>
  67 + </Col>
  68 + <Col span={5}>
  69 + <Button disabled={disabled} onClick={e => this.handleClick(e, 2)}>2</Button>
  70 + <Button disabled={disabled} onClick={e => this.handleClick(e, 5)}>5</Button>
  71 + <Button disabled={disabled} onClick={e => this.handleClick(e, 8)}>8</Button>
  72 + <Button disabled={disabled} onClick={e => this.handleClick(e, '00')}>00</Button>
  73 + <Button disabled={disabled} onClick={e => this.handleClick(e, ')')}>)</Button>
  74 + <Button disabled={disabled} onClick={e => this.handleClick(e, '<=')}>&lt;=</Button>
  75 + </Col>
  76 + <Col span={5}>
  77 + <Button disabled={disabled} onClick={e => this.handleClick(e, 3)}>3</Button>
  78 + <Button disabled={disabled} onClick={e => this.handleClick(e, 6)}>6</Button>
  79 + <Button disabled={disabled} onClick={e => this.handleClick(e, 9)}>9</Button>
  80 + <Button disabled={disabled} onClick={e => this.handleClick(e, '.')}>.</Button>
  81 + <Button disabled={disabled} onClick={e => this.handleClick(e, '>')}>&gt;</Button>
  82 + <Button disabled={disabled} onClick={e => this.handleClick(e, '=')}>=</Button>
  83 + </Col>
  84 + <Col span={5}>
  85 + <Button disabled={disabled} onClick={e => this.handleClick(e, '+')}>+</Button>
  86 + <Button disabled={disabled} onClick={e => this.handleClick(e, '-')}>-</Button>
  87 + <Button disabled={disabled} onClick={e => this.handleClick(e, '*')}>*</Button>
  88 + <Button disabled={disabled} onClick={e => this.handleClick(e, '/')}>/</Button>
  89 + <Button disabled={disabled} onClick={e => this.handleClick(e, '<')}>&lt;</Button>
  90 + <Button disabled={disabled} onClick={e => this.handleClick(e, '<>')}>&lt; &gt;</Button>
  91 + </Col>
  92 + </Row>
  93 +
  94 + <Row type="flex" justify="space-between">
  95 + {barContent}
  96 + <Col span={5}>
  97 + <Button disabled={disabled} onClick={this.handleField}>验证</Button>
  98 + </Col>
  99 + </Row>
  100 + </FormItem>
  101 + );
  102 + }
  103 +}
  104 +
  105 +export default CommonCalculatorComponent;
src/components/Common/CommonImportDataEvent.js 0 → 100644
  1 +/* eslint-disable array-callback-return,no-undef,prefer-destructuring */
  2 +import React, { Component } from 'react';
  3 +import { message } from 'antd';
  4 +import commonConfig from '../../utils/config';
  5 +import * as commonUtils from '../../utils/utils'; /* 通用方法 */
  6 +import * as commonServices from './../../services/services'; /* 服务类 */
  7 +import * as commonFunc from '../Common/commonFunc';
  8 +
  9 +// const { confirm } = Modal;
  10 +
  11 +export default (ChildComponent) => {
  12 + return class extends Component {
  13 + constructor(props) {
  14 + super(props);
  15 + this.state = {};
  16 + this.form = {};
  17 + /* 表单对象 */
  18 + }
  19 + componentWillReceiveProps(nextProps) {
  20 + const { isReceive, formData, app } = nextProps;
  21 +
  22 + if (!isReceive && formData.length > 0) {
  23 + const templateConfig = formData.filter(item => item.bGrd);
  24 + let selectOptions = '{';
  25 + templateConfig.forEach((item, i) => {
  26 + if (i !== 0) { selectOptions = selectOptions.concat(','); }
  27 + selectOptions = selectOptions.concat(`"${item.sId}"`).concat(':').concat(`"${item.showName}"`);
  28 + });
  29 + selectOptions = selectOptions.concat('}');
  30 +
  31 + const importConfigTypes = [];
  32 +
  33 + const DataTemplate = commonFunc.showMessage(app.commonConst, 'DataTemplate');/* 数据模板 */
  34 + const BtnUploadCheck = commonFunc.showMessage(app.commonConst, 'BtnUploadCheck');/* 上传校验 */
  35 + const importData = commonFunc.showMessage(app.commonConst, 'importData');/* 导入数据 */
  36 + const BtnExportTemplate = commonFunc.showMessage(app.commonConst, 'BtnExportTemplate');/* 导出模板 */
  37 + importConfigTypes.push(commonFunc.getImitateGdsconfigTypes(DataTemplate, 'sMasterId', 'sMasterId', false, 'const', selectOptions, false));
  38 + importConfigTypes.push(commonFunc.getImitateGdsconfigTypes(BtnUploadCheck, 'btnUpload', '', false, '', '', true));
  39 + importConfigTypes.push(commonFunc.getImitateGdsconfigTypes(importData, 'btnSave', '', false, '', '', false));
  40 + importConfigTypes.push(commonFunc.getImitateGdsconfigTypes(BtnExportTemplate, 'btnExport', '', false, '', '', false));
  41 +
  42 + const currConfig = {};
  43 + currConfig.rowGdsconfig = [{ gdsconfigformslave: importConfigTypes }];
  44 +
  45 + const masterData = {};
  46 + masterData.handleType = '';
  47 + masterData.sId = commonUtils.createSid();
  48 +
  49 + this.props.onSaveState({
  50 + masterData,
  51 + templateConfig,
  52 + isReceive: true,
  53 + masterConfig: currConfig,
  54 + pageLoading: false,
  55 + enabled: true,
  56 + });
  57 + this.handleGetChangeData({ name: 'importMenu' }, 'importMenu');
  58 + }
  59 + }
  60 +
  61 + shouldComponentUpdate(nextProps, nextState) {
  62 + let flag = true;
  63 + /* 追加弹出框数值回填放行判断ppopupPane */
  64 + if (nextProps.sTabId === nextProps.app.currentPane.key || ((nextProps.app.ppopupPane !== undefined
  65 + && nextProps.app.ppopupPane.mainConfig !== undefined)
  66 + ? nextProps.sTabId === nextProps.app.ppopupPane.mainConfig.key : false)) {
  67 + if (nextState.disabled !== this.state.disabled) {
  68 + return true;
  69 + }
  70 + flag = true;
  71 + } else {
  72 + flag = false;
  73 + }
  74 + return flag;
  75 + }
  76 +
  77 + /** 表单回带 */
  78 + handleForm = (form) => {
  79 + this.form = form;
  80 + };
  81 + /** 主表控件是否全部显示 */
  82 + handleToggle = () => {
  83 + const { expand } = this.props;
  84 + this.props.onSaveState({ expand: !expand });
  85 + };
  86 + /* save */
  87 + handleValidateSave = async () => {
  88 + const {
  89 + token, sModelsId, sJurisdictionClassifyId, sUserId, treeSaveParams, app,
  90 + } = this.props;
  91 + const value = {};
  92 + if ((commonUtils.isEmptyArr(sJurisdictionClassifyId) || commonUtils.isEmptyArr(sUserId)) && commonUtils.isEmptyArr(treeSaveParams)) {
  93 + message.warn(commonFunc.showMessage(app.commonConst, 'NotEmptyJurisdictionGroup'));
  94 + return;
  95 + }
  96 + value.data = treeSaveParams;
  97 + const dataUrl = `${commonConfig.server_host}/sysjurisdiction/addSysjurisdiction?sModelsId=${sModelsId}`;
  98 + const dataReturn = (await commonServices.postValueService(token, value, dataUrl)).data;
  99 + /* 成功的话返回数据 */
  100 + if (dataReturn.code === 1) { /* 成功 */
  101 + message.success(dataReturn.msg);
  102 + return dataReturn;
  103 + } else { /* 失败 */
  104 + this.props.getServiceError(dataReturn);
  105 + return false;
  106 + }
  107 + }
  108 +
  109 + /* get */
  110 + handleGetChangeData = async (params, urlKey) => {
  111 + const { app, sModelsId } = this.props;
  112 + const { token } = app;
  113 + const { name, gdsconfigformmasterId } = params; // name,
  114 + let dataUrl = '';// ImportMenu
  115 + if (urlKey === 'importMenu') { // yw_获取导入模板菜单
  116 + dataUrl = `${commonConfig.server_host}import/getImportMenu?sModelsId=${sModelsId}`;
  117 + } else if (urlKey === 'exportTemplet') { // yw_导出将要导入的模板execl
  118 + dataUrl = `${commonConfig.server_host}import/exportTemplet?gdsconfigformmasterId=${gdsconfigformmasterId}&token=${token}`;
  119 + }
  120 + const dataReturn = (await commonServices.getService(token, dataUrl)).data;
  121 + if (dataReturn.code === 1) {
  122 + const returnData = dataReturn.dataset.rows;
  123 + this.props.onSaveState({ [`${name}Data`]: returnData });
  124 + } else {
  125 + this.props.getServiceError(dataReturn);
  126 + }
  127 + }
  128 +
  129 + /* post */
  130 + handlePostData = async (params, urlKey) => {
  131 + const { app, sModelsId } = this.props;
  132 + const { token } = app;
  133 + const {
  134 + name, gdsconfigformmasterId, file, execlData, sTableName,
  135 + } = params; // name,
  136 + let dataUrl = '';
  137 + const value = {};
  138 + if (urlKey === 'checkExcel') { // yw_校验导入模板数据
  139 + value.gdsconfigformmasterId = gdsconfigformmasterId;
  140 + value.file = file;
  141 + dataUrl = `${commonConfig.server_host}import/checkExcel?sModelsId=${sModelsId}`;
  142 + } else if (urlKey === 'addImport') {
  143 + dataUrl = `${commonConfig.server_host}import/addImport?sModelsId=${sModelsId}`;
  144 + value.sTableName = sTableName;
  145 + value.execlData = execlData;
  146 + }
  147 + const dataReturn = (await commonServices.postValueService(token, value, dataUrl)).data;
  148 + if (dataReturn.code === 1) {
  149 + if (urlKey === 'checkExcel') {
  150 + const returnData = dataReturn.dataset.rows;
  151 + const allInitArr = [];
  152 + const allInitMap = new Map();
  153 + this.handleAllCheckKeys(allInitArr, allInitMap, returnData);
  154 + this.props.onSaveState({ [`${name}Data`]: returnData, treeAllCheckKeys: allInitArr, treeAllNodes: allInitMap });
  155 + } else if (urlKey === 'addImport') {
  156 + this.props.onSaveState({ nocanbeInsertData: [], canbeInsertData: [] });
  157 + message.info(dataReturn.msg);
  158 + }
  159 + } else {
  160 + this.props.getServiceError(dataReturn);
  161 + }
  162 + }
  163 +
  164 + /** 修改主表数据 */
  165 + handleMasterChange = (name, sFieldName, changeValue, sId, dropDownData) => {
  166 + const addState = this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, true);
  167 + const gdsconfigformmasterId = {};
  168 + const { templateConfig } = this.props;
  169 + if (sFieldName === 'sMasterId') {
  170 + addState.gdsconfigformmasterId = changeValue[sFieldName];
  171 + const iIndex = templateConfig.findIndex(item => item.sId === changeValue[sFieldName]);
  172 + const configTypes = [];// importMenuData
  173 + configTypes.push(commonFunc.getImitateGdsconfigTypes('原因', 'sReason', 'sReason', false, '', '', false));
  174 +
  175 + const canbeInsertConfig = templateConfig[iIndex];
  176 + const canbeInsertColumn = commonFunc.getHeaderConfig(canbeInsertConfig);
  177 +
  178 + const nocanbeInsertConfig = { gdsconfigformslave: configTypes.concat(templateConfig[iIndex].gdsconfigformslave) };
  179 + const nocanbeInsertColumn = commonFunc.getHeaderConfig(nocanbeInsertConfig);
  180 +
  181 + addState.nocanbeInsertConfig = nocanbeInsertConfig;
  182 + addState.nocanbeInsertColumn = nocanbeInsertColumn;
  183 + addState.canbeInsertConfig = canbeInsertConfig;
  184 + addState.canbeInsertColumn = canbeInsertColumn;
  185 + addState.nocanbeInsertData = [];
  186 + addState.canbeInsertData = [];
  187 + }
  188 + this.props.onSaveState({ gdsconfigformmasterId, ...addState });
  189 + };
  190 +
  191 + handleUploadChange = (sControlName, info) => {
  192 + /* 获取上传后的一些信息 */
  193 + const { file } = info;
  194 + let { [`${sControlName}UploadInfo`]: uploads } = this.props;
  195 + if (commonUtils.isEmptyArr(uploads)) {
  196 + uploads = [];
  197 + uploads.push(file);
  198 + } else {
  199 + uploads.push(file);
  200 + }
  201 + this.props.onSaveState({ [`${sControlName}UploadInfo`]: uploads });
  202 + };
  203 +
  204 + /* 按钮点击功能 */
  205 + handleBtnClick = (e, btnName) => {
  206 + const {
  207 + masterData, app, canbeInsertData, nocanbeInsertData,
  208 + } = this.props;
  209 + const { token } = app;
  210 + const { sMasterId, sTableName } = masterData;
  211 + if (btnName === 'btnExport') {
  212 + if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyObject(sMasterId)) {
  213 + // window.location.href = `${commonConfig.server_host}import/exportTemplet?gdsconfigformmasterId=${sMasterId}&token=${token}`;
  214 + const url = `${commonConfig.server_host}import/exportTemplet?gdsconfigformmasterId=${sMasterId}&token=${token}`;
  215 + window.open(url);
  216 + } else {
  217 + const chooseImprtTemplete = commonFunc.showMessage(app.commonConst, 'chooseImprtTemplete');/* 请选择要导出的模板 */
  218 + message.error(chooseImprtTemplete);
  219 + }
  220 + } else if (btnName === 'btnSave') {
  221 + if (commonUtils.isNotEmptyArr(nocanbeInsertData) && commonUtils.isNotEmptyArr(canbeInsertData) && commonUtils.isNotEmptyObject(sTableName) && nocanbeInsertData.length === canbeInsertData.length) {
  222 + this.handlePostData({ name: 'addImport', execlData: canbeInsertData, sTableName }, 'addImport');
  223 + } else {
  224 + message.error(commonFunc.showMessage(app.commonConst, 'ErrorImport')); /* 有错误数据,不能导入 */
  225 + }
  226 + }
  227 + };
  228 +
  229 + /* 按钮点击功能 */
  230 + handleShowUploadData = (response) => {
  231 + const { masterData } = this.props;
  232 +
  233 + if (response.code === 1) {
  234 + const returnData = response.dataset.rows[0];
  235 + const {
  236 + nocanbeInsert, canbeInsert, sTableName,
  237 + } = returnData;
  238 +
  239 + masterData.sTableName = sTableName;
  240 + this.props.onSaveState({
  241 + masterData,
  242 + nocanbeInsertData: nocanbeInsert.concat(canbeInsert),
  243 + canbeInsertData: canbeInsert,
  244 + });
  245 + } else {
  246 + message.error(response.msg);
  247 + }
  248 + };
  249 +
  250 + render() {
  251 + return (
  252 + <ChildComponent
  253 + {...this.props}
  254 + {...this.state}
  255 + onReturnForm={this.handleForm}
  256 + onToggle={this.handleToggle}
  257 + onSubmit={this.handleValidateSave}
  258 + onDataChange={this.handleTableChange}
  259 + onChange={this.handleMasterChange}
  260 + onUploadChange={this.handleUploadChange}
  261 + onBtnClick={this.handleBtnClick}
  262 + onShowData={this.handleShowUploadData}
  263 + />
  264 + );
  265 + }
  266 + };
  267 +};
src/components/Common/CommonJurisdictionNewEvent.js 0 → 100644
  1 +/* eslint-disable array-callback-return,no-undef,prefer-destructuring */
  2 +import React, { Component } from 'react';
  3 +import { Modal, message } from 'antd';
  4 +import commonConfig from '../../utils/config';
  5 +import * as commonBusiness from './commonBusiness'; /* 单据业务功能 */
  6 +import * as commonUtils from '../../utils/utils'; /* 通用方法 */
  7 +import * as commonServices from './../../services/services';
  8 +import * as commonFunc from './commonFunc'; /* 服务类 */
  9 +
  10 +const { confirm } = Modal;
  11 +
  12 +export default (ChildComponent) => {
  13 + return class extends Component {
  14 + constructor(props) {
  15 + super(props);
  16 + this.state = {};
  17 + this.form = {};
  18 + /* 表单对象 */
  19 + }
  20 +
  21 + componentWillReceiveProps(nextProps) {
  22 + const {
  23 + formData, currentId, groupConfig, treeData, formRoute,
  24 + } = nextProps;
  25 + let { bReceived } = nextProps;
  26 + const sId = currentId !== undefined ? currentId : '';
  27 +
  28 + if (commonUtils.isEmptyObject(groupConfig) && bReceived === undefined) {
  29 + const masterConfig = formData.filter(item => !item.bGrd)[0];
  30 + this.handleGetChangeData({ name: 'tree' }, 'SysjurisdictionTree');
  31 + bReceived = true;
  32 + const group = this.initColumnConfig('group', [
  33 + this.imitateTableColumn('序号', 'iOrder', 'iOrder', 60),
  34 + this.imitateTableColumn('权限组', 'sName', 'sId', 350)]);
  35 +
  36 +
  37 + const userGroup = this.initColumnConfig('userGroup', [
  38 + this.imitateTableColumn('序号', 'iOrder', 'iOrder', 60),
  39 + this.imitateTableColumn('组成员', 'sUserName', 'sUsersId', 350)]);
  40 +
  41 + const user = this.initColumnConfig('userView', [
  42 + this.imitateTableColumn('序号', 'iOrder', 'iOrder', 60),
  43 + this.imitateTableColumn('用户', 'sUserName', 'sId', 120),
  44 + this.imitateTableColumn('权限组', 'sGroupName', 'sGroupName', 350)]);
  45 +
  46 + const groupUser = this.imitateTableColumnConfig('groupUser', [this.imitateTableColumn('所属分组', 'sGroupName', 'sGroupsId')]);
  47 +
  48 + const checkedNodes = this.imitateTableColumnConfig('checkedNodes', [this.imitateTableColumn('名称', 'showName', 'sId')]);
  49 +
  50 + const tree = this.imitateTableColumnConfig('tree', [this.imitateTableColumn('名称', 'showName', 'key')]);
  51 +
  52 + const search = this.imitateTableColumnConfig('search', [this.imitateTableColumn('名称', 'showName', 'sAllId', 300)]);
  53 +
  54 + let treeKeyName = 'key';
  55 + if (formRoute === '/indexPage/systemPermission') {
  56 + treeKeyName = 'sId';
  57 + }
  58 + this.props.onSaveState({
  59 + masterConfig,
  60 + sId,
  61 + bReceived,
  62 + treeKeyName,
  63 + showLine: false,
  64 + // pageLoading: false,
  65 + ...tree,
  66 + ...group,
  67 + ...user,
  68 + ...userGroup,
  69 + ...groupUser,
  70 + ...checkedNodes,
  71 + ...search,
  72 + });
  73 + }
  74 + if (commonUtils.isNotEmptyArr(treeData) && bReceived) {
  75 + this.handleGetChangeData({ name: 'group' }, 'GroupData');
  76 + this.handleGetChangeData({ name: 'userView' }, 'UserData');
  77 + this.props.onSaveState({
  78 + bReceived: false,
  79 + pageLoading: false,
  80 + });
  81 + }
  82 + }
  83 +
  84 +
  85 + shouldComponentUpdate(nextProps, nextState) {
  86 + let flag = true;
  87 + /* 追加弹出框数值回填放行判断ppopupPane */
  88 + if (nextProps.sTabId === nextProps.app.currentPane.key || ((nextProps.app.ppopupPane !== undefined
  89 + && nextProps.app.ppopupPane.mainConfig !== undefined)
  90 + ? nextProps.sTabId === nextProps.app.ppopupPane.mainConfig.key : false)) {
  91 + if (nextState.disabled !== this.state.disabled) {
  92 + return true;
  93 + }
  94 + flag = true;
  95 + } else {
  96 + flag = false;
  97 + }
  98 + return flag;
  99 + }
  100 +
  101 + componentWillUpdate(nextProps) {
  102 + const { masterData, sModelsType, elemachineData } = nextProps;
  103 + if (sModelsType === 'element/teamInfo' && masterData !== undefined) {
  104 + if (commonUtils.isNotEmptyObject(elemachineData)) {
  105 + elemachineData.forEach((row, index) => {
  106 + if (row.sMachineId === masterData.sMachineId) {
  107 + elemachineData[index].bDefault = true;
  108 + } else {
  109 + elemachineData[index].bDefault = false;
  110 + }
  111 + });
  112 + }
  113 + }
  114 + }
  115 +
  116 +
  117 + /** 表单回带 */
  118 + handleForm = (form) => {
  119 + this.form = form;
  120 + };
  121 + /** 主表控件是否全部显示 */
  122 + handleToggle = () => {
  123 + const { expand } = this.props;
  124 + this.props.onSaveState({ expand: !expand });
  125 + };
  126 +
  127 + handleValidateSave = async () => {
  128 + const {
  129 + token, sModelsId, sJurisdictionClassifyId, sUserId, treeAllNodes, treeCheckedKeys = [], treeAllCheckKeys,
  130 + app,
  131 + } = this.props;
  132 + const value = {};
  133 + if ((commonUtils.isEmptyArr(sJurisdictionClassifyId) && commonUtils.isEmptyArr(sUserId))) {
  134 + message.warn(commonFunc.showMessage(app.commonConst, 'NotEmptyJurisdictionGroup'));/* 组员,所属或权限组不能为空! */
  135 + this.props.onSaveState({
  136 + loading: false,
  137 + });
  138 + return;
  139 + }
  140 + if (commonUtils.isNotEmptyArr(sJurisdictionClassifyId) && commonUtils.isEmptyArr(sUserId)) {
  141 + value.sJurisdictionClassifyId = sJurisdictionClassifyId[0];
  142 + } else if (commonUtils.isNotEmptyArr(sUserId) && commonUtils.isEmptyArr(sJurisdictionClassifyId)) {
  143 + value.sUserId = sUserId[0];
  144 + } else {
  145 + message.warn(commonFunc.showMessage(app.commonConst, 'NotEmptyGroup'));/* 组或者组员不能为空 */
  146 + this.props.onSaveState({
  147 + loading: false,
  148 + });
  149 + return;
  150 + }
  151 + /*
  152 + if (commonUtils.isNotEmptyArr(treeCheckedKeys) && treeCheckedKeys.length === treeAllCheckKeys.length) {
  153 + message.warn('请选择不需要的权限!');
  154 + return;
  155 + }
  156 + */
  157 + const newCheckedKeys = []; /* 所有选中节点 */
  158 + const saveData = [];
  159 +
  160 + // 取 选中数据 用-分割后的最后一个值
  161 + const treeCheckedKeysNew = treeCheckedKeys.map((item) => {
  162 + const list = item.split('-');
  163 + return list[list.length - 1];
  164 + });
  165 +
  166 + treeAllCheckKeys.forEach((key) => {
  167 + const iIndex = treeCheckedKeysNew.indexOf(key);
  168 + if (iIndex > -1) {
  169 + newCheckedKeys.push(key);
  170 + }
  171 + });
  172 + newCheckedKeys.forEach((key) => {
  173 + const nodes = treeAllNodes.get(key);
  174 + saveData.push({
  175 + sId: nodes.sId,
  176 + sParentId: nodes.sParentId,
  177 + // sKey: nodes[`${skeyName}`],
  178 + sKey: nodes.key,
  179 + sName: commonUtils.isNotEmptyObject(nodes) && commonUtils.isNotEmptyObject(nodes.sName) ? nodes.sName : '',
  180 + sAction: commonUtils.isNotEmptyObject(nodes) && commonUtils.isNotEmptyObject(nodes.sAction) ? nodes.sAction : '',
  181 + showName: nodes.showName,
  182 + });
  183 + });
  184 +
  185 + value.data = saveData;
  186 + value.sTreeAllKet = treeAllCheckKeys;
  187 +
  188 + const dataUrl = `${commonConfig.server_host}/sysjurisdictionNew/addSysjurisdictionNew?sModelsId=${sModelsId}`;
  189 + const dataReturn = (await commonServices.postValueService(token, value, dataUrl)).data;
  190 + /* 成功的话返回数据 */
  191 + if (dataReturn.code === 1) { /* 成功 */
  192 + message.success(dataReturn.msg);
  193 + this.props.onSaveState({ enabled: false, loading: false });
  194 + return dataReturn;
  195 + } else { /* 失败 */
  196 + this.props.getServiceError(dataReturn);
  197 + this.props.onSaveState({
  198 + loading: false,
  199 + });
  200 + return false;
  201 + }
  202 + }
  203 +
  204 + /** 点击修改按钮操作 */
  205 + handleEdit = () => {
  206 + this.props.onSaveState({ enabled: true, loading: false });
  207 + }
  208 + handleCancel = (obj) => {
  209 + // const { groupUserData } = this.props;
  210 + // const onGetChangeData = this.handleGetChangeData;
  211 + const onSaveStateOk = this.props.onSaveState;
  212 + confirm({
  213 + title: obj.title,
  214 + onOk() {
  215 + // const sId = commonUtils.isNotEmptyArr(groupUserData) && groupUserData.length > 0 ? groupUserData[0].sId : '';
  216 + onSaveStateOk({ enabled: false });
  217 + // onGetChangeData({ name: 'authority', sId }, 'GroupAuthority');
  218 + },
  219 + onCancel() {
  220 + },
  221 + });
  222 + }
  223 +
  224 + handleGetSisformulaData = (masterConfig) => {
  225 + this.handleGetSlaveData('One', null, masterConfig);
  226 + }
  227 +
  228 + handleGetSlaveData = (getType, sName, currConfig) => {
  229 + const { currentId } = this.props;
  230 + /* 当前页签数据 */
  231 + const sId = currentId !== undefined ? currentId : '';
  232 + if (getType === 'One') {
  233 + this.props.handleGetDataOne({
  234 + name: 'master', configData: currConfig, condition: { sId, pageSize: '', pageNum: '' },
  235 + });
  236 + }
  237 + if (getType === 'Set') {
  238 + this.props.handleGetDataSet({
  239 + name: sName, configData: currConfig, condition: { sSqlCondition: { sParentId: sId } },
  240 + });
  241 + }
  242 + }
  243 + /* 获取分组列表
  244 + yw_权限分配
  245 + 获取分组列表
  246 + 获取人员列表
  247 + qx_获取权限树
  248 + qx_根据组sId获取已选择权限
  249 + qx_根据人sId获取已选择权限
  250 + qx_根据组sId获取组人员
  251 + 根据人员sId获取所属分组
  252 + 保存组已选权限
  253 + * */
  254 + handleGetChangeData = async (params, urlKey) => {
  255 + const { app, sModelsId } = this.props;
  256 + const { token } = app;
  257 + const { name, sId, treeComponentName } = params; // name,
  258 + let dataUrl = '';
  259 + if (urlKey === 'SysjurisdictionTree') { // 树结构
  260 + dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getSysjurisdictionTreeNew?sModelsId=${sModelsId}`;
  261 + } else if (urlKey === 'GroupData') { // 组
  262 + dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getGroupDataNew?sModelsId=${sModelsId}`;
  263 + } else if (urlKey === 'UserData') { // 用户
  264 + dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getUserDataNew?sModelsId=${sModelsId}`;
  265 + } else if (urlKey === 'UserGroupId') { // 组成员
  266 + if (commonUtils.isNotEmptyObject(sId)) {
  267 + dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getsUserGroupIdNew/${sId}?sModelsId=${sModelsId}`;
  268 + }
  269 + } else if (urlKey === 'GroupAuthority') { // 组权限
  270 + if (commonUtils.isNotEmptyObject(sId)) {
  271 + dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getHaveAuthorityGroupIdNew/${sId}?sModelsId=${sModelsId}`;
  272 + }
  273 + } else if (urlKey === 'UserAuthority') { // 用户所有权限查询 :用户权限,组权限
  274 + if (commonUtils.isNotEmptyObject(sId)) {
  275 + dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getHaveAuthorityUserIdNew/${sId}?sModelsId=${sModelsId}`;
  276 + }
  277 + }
  278 + if (commonUtils.isNotEmptyObject(dataUrl)) {
  279 + const dataReturn = (await commonServices.getService(token, dataUrl)).data;
  280 + if (commonUtils.isNotEmptyObject(dataReturn) && dataReturn.code === 1) {
  281 + const returnData = dataReturn.dataset.rows;
  282 + let addState = {};
  283 + if (urlKey === 'SysjurisdictionTree') { // 树结构
  284 + const allInitArr = [];
  285 + const allInitMap = new Map();
  286 + this.handleAllCheckKeys(allInitArr, allInitMap, returnData);
  287 + this.props.onSaveState({ [`${name}Data`]: returnData, treeAllCheckKeys: allInitArr, treeAllNodes: allInitMap });
  288 + } else if (urlKey === 'GroupData') { // 获取组后默认查询组权限,以及组成员
  289 + this.props.onSaveState({ [`${name}Data`]: returnData });
  290 + if (commonUtils.isNotEmptyArr(returnData)) {
  291 + this.handleTableSelectRowChange('group', [returnData[0].sId]); // 查询第一组成员
  292 + }
  293 + } else if (urlKey === 'UserData') { // 获取成员后默认 成员自己的权限,以及成员所属组
  294 + this.props.onSaveState({ [`${name}Data`]: returnData });
  295 + // if (commonUtils.isNotEmptyArr(returnData)) {
  296 + // this.handleGetChangeData({ name: 'groupUser', sId: returnData[0].sId }, 'GroupUserId'); // 查询第一个成员归属组
  297 + // }
  298 + } else if (urlKey === 'GroupAuthority' || urlKey === 'UserAuthority') {
  299 + let groupAuth = '';
  300 + let groupAuthData = [];
  301 + if (commonUtils.isNotEmptyArr(returnData)) {
  302 + if (commonUtils.isNotEmptyObject(returnData[0])) {
  303 + groupAuth = commonUtils.isNotEmptyObject(returnData[0]) ? returnData[0].sKeys : [];
  304 + groupAuthData = commonUtils.isNotEmptyObject(groupAuth) ? groupAuth.split(',') : [];
  305 + }
  306 + }
  307 + addState = this.handleCheckedNodeForFunction(treeComponentName, groupAuthData);
  308 + this.props.onSaveState({
  309 + [`${name}Data`]: returnData, userAuth: undefined, sJurisdictionClassifyId: sId, sUserId: undefined, ...addState,
  310 + });
  311 + } else if (false && urlKey === 'UserAuthority') {
  312 + let gAuth = '';
  313 + let groupAuthData = [];
  314 + let uAuth = '';
  315 + let userAuthData = [];
  316 + if (commonUtils.isNotEmptyArr(returnData)) {
  317 + if (commonUtils.isNotEmptyObject(returnData[0])) {
  318 + const { groupAuth, userAuth } = returnData[0];
  319 + if (commonUtils.isNotEmptyObject(groupAuth)) {
  320 + gAuth = groupAuth.sKeys;
  321 + groupAuthData = gAuth.split(',');
  322 + }
  323 +
  324 + if (commonUtils.isNotEmptyObject(userAuth)) {
  325 + uAuth = userAuth.sKeys;
  326 + userAuthData = uAuth.split(',');
  327 + }
  328 + }
  329 + }
  330 + addState = this.handleGroupForFunction(treeComponentName, groupAuthData, userAuthData);
  331 + this.props.onSaveState({
  332 + [`${name}Data`]: returnData, userAuthData, sJurisdictionClassifyId: undefined, sUserId: sId, ...addState,
  333 + });
  334 + } else {
  335 + this.props.onSaveState({ [`${name}Data`]: returnData });
  336 + }
  337 + } else {
  338 + this.props.getServiceError(dataReturn);
  339 + }
  340 + }
  341 + }
  342 +
  343 + // 模拟 列
  344 + imitateTableColumn = (title, dataIndex, key, width) => {
  345 + return {
  346 + title, dataIndex, key, width,
  347 + };
  348 + }
  349 + // 模拟config的 gdsconfigformslave 配置
  350 + imitateTableConfig = (title, dataIndex, width) => {
  351 + return {
  352 + bCanInput: false,
  353 + bFilter: false,
  354 + bFind: false,
  355 + bFirstEmpty: false,
  356 + bIsOther: false,
  357 + bNewRecord: false,
  358 + bNotEmpty: false,
  359 + bNotRepeat: false,
  360 + bReadonly: true,
  361 + bSum: false,
  362 + bTree: false,
  363 + bVisible: true,
  364 + iColValue: 1,
  365 + iFitWidth: width,
  366 + sBrandsId: '1111111111',
  367 + sChinese: title,
  368 + sChineseDropDown: '',
  369 + sControlName: 'BtnLast',
  370 + sId: commonUtils.createSid(),
  371 + sParentId: '11811781131121915102156308120',
  372 + sSubsidiaryId: '1111111111',
  373 + showName: title,
  374 + sName: dataIndex,
  375 + };
  376 + }
  377 + // 根据模拟列,模拟列配置
  378 + imitateTableColumnConfig = (name, columns) => {
  379 + const gdsconfigformslave = [];
  380 + columns.forEach((itmes) => {
  381 + gdsconfigformslave.push(this.imitateTableConfig(itmes.title, itmes.dataIndex, itmes.width));
  382 + });
  383 + const config = { bGrd: true, gdsconfigformslave };
  384 + return { [`${name}Column`]: columns, [`${name}Config`]: config };
  385 + }
  386 +
  387 + initColumnConfig = (name, columns) => {
  388 + const gdsconfigformslave = [];
  389 + columns.forEach((itmes) => {
  390 + gdsconfigformslave.push(this.imitateTableConfig(itmes.title, itmes.dataIndex, itmes.width));
  391 + });
  392 + const config = { bGrd: true, gdsconfigformslave };
  393 + const newColumns = commonFunc.getHeaderConfig(config);
  394 + return { [`${name}Column`]: newColumns, [`${name}Config`]: config };
  395 + }
  396 +
  397 +
  398 + /** 处理选择行发生改变 */
  399 + handleTableSelectRowChange = (name, selectedRowKeys) => {
  400 + const addState = {};
  401 + if (name === 'group') {
  402 + this.handleGetChangeData({ name: 'userGroup', sId: selectedRowKeys }, 'UserGroupId');
  403 + this.handleGetChangeData({ name: 'master', sId: selectedRowKeys, treeComponentName: 'tree' }, 'GroupAuthority');
  404 + addState.groupSelectedRowKeys = selectedRowKeys;
  405 + } else if (name === 'userView') {
  406 + // this.handleGetChangeData({ name: 'groupUser', sId: selectedRowKeys }, 'GroupUserId');
  407 + this.handleGetChangeData({ name: 'master', sId: selectedRowKeys, treeComponentName: 'tree' }, 'UserAuthority');
  408 + addState.userViewSelectedRowKeys = selectedRowKeys;
  409 + } else if (name === 'userGroup') {
  410 + this.handleGetChangeData({ name: 'master', sId: selectedRowKeys, treeComponentName: 'tree' }, 'UserAuthority');
  411 + addState.userGroupSelectedRowKeys = selectedRowKeys;
  412 + } else if (name === 'groupUser') {
  413 + this.handleGetChangeData({ name: 'master', sId: selectedRowKeys, treeComponentName: 'tree' }, 'GroupAuthority');
  414 + addState.groupUserSelectedRowKeys = selectedRowKeys;
  415 + }
  416 + this.props.onSaveState({ ...addState });
  417 + }
  418 +
  419 + handleCheckBoxCheck = (componentName, checkedKeys) => {
  420 + this.handleCheckedForFunction(componentName, checkedKeys);
  421 + }
  422 +
  423 + /* 选择权限同时处理保存的数据以及将要展现的已选择权限 */
  424 + handleCheckedForFunction = (componentName, checkedKeys) => {
  425 + const {
  426 + treeAllNodes,
  427 + } = this.props;
  428 + const data = [];
  429 + const checkedData = [];
  430 + if (commonUtils.isNotEmptyArr(treeAllNodes) && treeAllNodes.size > 0) {
  431 + const newCheckedKeys = [];
  432 + if (commonUtils.isNotEmptyArr(checkedKeys) && checkedKeys[0] !== null) {
  433 + checkedKeys.forEach((key, i) => {
  434 + if (checkedKeys.indexOf(key) === i) {
  435 + newCheckedKeys.push(key);
  436 + }
  437 + });
  438 + newCheckedKeys.forEach((key) => {
  439 + const nodes = treeAllNodes.get(key);
  440 + if (commonUtils.isNotEmptyObject(nodes)) {
  441 + checkedData.push({ sId: nodes.sId, showName: nodes.showName });
  442 + }
  443 + });
  444 + }
  445 + this.props.onSaveState({
  446 + [`${componentName}CheckedKeys`]: newCheckedKeys,
  447 + treeSaveParams: data,
  448 + checkedNodesData: checkedData,
  449 + });
  450 + }
  451 + }
  452 +
  453 + /* 拿接口返回的节点进行选中 */
  454 + handleCheckedNodeForFunction = (componentName, haveCheckedKeys) => {
  455 + // eslint-disable-next-line no-unused-vars
  456 + const { treeAllNodes, treeAllCheckKeys } = this.props;
  457 + const addState = {};
  458 + const checkedData = [];
  459 + let checkKeys = [];
  460 + checkKeys = haveCheckedKeys;
  461 + // if (commonUtils.isNotEmptyArr(unCheckedKeys)) {
  462 + // for (const checkId of unCheckedKeys) {
  463 + // treeAllCheckKeys.forEach((key) => {
  464 + // if (checkId.includes(key)) {
  465 + // checkKeys.forEach((item, index) => {
  466 + // if (item === key) {
  467 + // checkKeys.splice(index, 1);
  468 + // }
  469 + // });
  470 + // }
  471 + // });
  472 + // }
  473 + // }
  474 + checkKeys.forEach((key) => {
  475 + const nodes = treeAllNodes.get(key);
  476 + if (commonUtils.isNotEmptyObject(nodes)) {
  477 + checkedData.push({ sId: nodes.sId, showName: nodes.showName });
  478 + }
  479 + });
  480 + addState[`${componentName}CheckedKeys`] = checkKeys;
  481 + addState.checkedNodesData = checkedData;
  482 + addState.disabledCheckedKeys = [];
  483 + return addState;
  484 + }
  485 +
  486 +
  487 + handleUnCheckedForFunction = (componentName, unCheckedKeys) => {
  488 + const { treeAllNodes, treeAllCheckKeys } = this.props;
  489 + const addState = {};
  490 + const checkedData = [];
  491 + let checkKeys = [];
  492 + checkKeys = checkKeys.concat(treeAllCheckKeys);
  493 +
  494 + if (commonUtils.isNotEmptyArr(unCheckedKeys)) {
  495 + for (const checkId of unCheckedKeys) {
  496 + treeAllCheckKeys.forEach((key) => {
  497 + if (checkId.includes(key)) {
  498 + checkKeys.forEach((item, index) => {
  499 + if (item === key) {
  500 + checkKeys.splice(index, 1);
  501 + }
  502 + });
  503 + }
  504 + });
  505 + }
  506 + }
  507 + checkKeys.forEach((key) => {
  508 + const nodes = treeAllNodes.get(key);
  509 + if (commonUtils.isNotEmptyObject(nodes)) {
  510 + checkedData.push({ sId: nodes.sId, showName: nodes.showName });
  511 + }
  512 + });
  513 + addState[`${componentName}CheckedKeys`] = checkKeys;
  514 + addState.checkedNodesData = checkedData;
  515 + addState.disabledCheckedKeys = [];
  516 + return addState;
  517 + }
  518 +
  519 + handleGroupForFunction = (treeComponentName, groupAuthData, userAuthData) => {
  520 + const { treeAllNodes, treeAllCheckKeys } = this.props;
  521 + const addState = {};
  522 + const checkedData = [];
  523 + let checkKeys = [];
  524 + let userAuthDataNew = [];
  525 + checkKeys = checkKeys.concat(treeAllCheckKeys);
  526 + if (commonUtils.isEmptyArr(userAuthData)) { /* 只有组权限 没有用户权限时 */
  527 + userAuthDataNew = JSON.parse(JSON.stringify(groupAuthData)); /* 深拷贝 */
  528 + userAuthData = userAuthDataNew;
  529 + }
  530 + if (commonUtils.isNotEmptyArr(userAuthData)) {
  531 + treeAllCheckKeys.forEach((key) => {
  532 + for (const checkId of userAuthData) {
  533 + if (checkId.includes(key)) {
  534 + checkKeys.forEach((item, index) => {
  535 + if (item === key) {
  536 + checkKeys.splice(index, 1);
  537 + }
  538 + });
  539 + }
  540 + }
  541 + });
  542 + checkKeys.forEach((key) => {
  543 + const nodes = treeAllNodes.get(key);
  544 + if (commonUtils.isNotEmptyObject(nodes)) {
  545 + checkedData.push({ sId: nodes.sId, showName: nodes.showName });
  546 + }
  547 + });
  548 + }
  549 +
  550 + let groupCheckKeys = [];
  551 + if (commonUtils.isNotEmptyArr(groupAuthData)) {
  552 + groupCheckKeys = groupCheckKeys.concat(treeAllCheckKeys);
  553 + treeAllCheckKeys.forEach((key) => {
  554 + for (const checkId of groupAuthData) {
  555 + if (checkId === key) {
  556 + groupCheckKeys.splice(groupCheckKeys.indexOf(key), 1);
  557 + }
  558 + }
  559 + });
  560 + } else {
  561 + groupCheckKeys = treeAllCheckKeys; /* 组权限没有 */
  562 + }
  563 + addState[`${treeComponentName}CheckedKeys`] = checkKeys.concat(groupCheckKeys);
  564 + addState.checkedNodesData = checkedData;
  565 + addState.disabledCheckedKeys = groupCheckKeys;
  566 + return addState;
  567 + };
  568 +
  569 + handleAllCheckKeys = (arrObj, mapObj, returnData) => {
  570 + const { treeKeyName } = this.props;
  571 + returnData.forEach((item) => {
  572 + if (commonUtils.isNotEmptyArr(item.children) && item.children.length > 0) {
  573 + arrObj.push(item[`${treeKeyName}`]);
  574 + mapObj.set(item[`${treeKeyName}`], item);
  575 + this.handleAllCheckKeys(arrObj, mapObj, item.children);
  576 + } else {
  577 + arrObj.push(item[`${treeKeyName}`]);
  578 + mapObj.set(item[`${treeKeyName}`], item);
  579 + }
  580 + });
  581 + };
  582 + handleRefresh = () => {
  583 + this.handleGetChangeData({ name: 'tree' }, 'SysjurisdictionTree');
  584 + this.handleGetChangeData({ name: 'group' }, 'GroupData');
  585 + this.handleGetChangeData({ name: 'user' }, 'UserData');
  586 + this.props.onSaveState({
  587 + treeAllCheckKeys: undefined,
  588 + treeAllNodes: undefined,
  589 + });
  590 + }
  591 + handleSearch = async (sSearchValue) => {
  592 + const { sModelsId } = this.props;
  593 + const url = `${commonConfig.server_host}gdsmodule/getGdsmoduleList?sModelsId=${sModelsId}&sName=${sSearchValue}`;
  594 + const dataReturn = (await commonServices.getService(this.props.app.token, url)).data;
  595 + if (dataReturn.code === 1) {
  596 + /* 数据查询成功 */
  597 + this.props.onSaveState({ searchData: dataReturn.dataset.rows });
  598 + } else { /* 失败 */
  599 + this.props.getServiceError(dataReturn);
  600 + }
  601 + }
  602 + handleSetTreeOptionData = (name, optionName, value) => {
  603 + this.props.onSaveState({ [`${name}${optionName}Keys`]: value });
  604 + }
  605 +
  606 + handleSearchTable = async (searchValue, type) => {
  607 + const { token, sModelsId } = this.props;
  608 + let dataUrl = '';
  609 + if (commonUtils.isNotEmptyObject(type)) {
  610 + if (type === 'group') {
  611 + /* 组权限 */
  612 + dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getGroupDataNew?sSearchName=${searchValue}&sModelsId=${sModelsId}`;
  613 + } else if (type === 'userView') { /* 用户权限 */
  614 + dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getUserDataNew?sSearchName=${searchValue}&sModelsId=${sModelsId}`;
  615 + }
  616 + if (commonUtils.isNotEmptyObject(dataUrl)) {
  617 + const dataReturn = (await commonServices.getService(token, dataUrl)).data;
  618 + if (dataReturn.code === 1) {
  619 + const returnData = dataReturn.dataset.rows;
  620 + if (commonUtils.isNotEmptyArr(type)) {
  621 + this.props.onSaveState({ [`${type}Data`]: returnData });
  622 + }
  623 + }
  624 + }
  625 + }
  626 + }
  627 +
  628 + /* 查询组权限 */
  629 + handleSearchGroup = async (searchValue) => {
  630 + this.handleSearchTable(searchValue, 'group');
  631 + }
  632 +
  633 + /* 查询用户权限 */
  634 + handleSearchUser = async (searchValue) => {
  635 + this.handleSearchTable(searchValue, 'userView');
  636 + }
  637 + /** 按钮操作事件 */
  638 + handleButtonClick = (name, isFresh) => {
  639 + if (name.includes('BtnRepairGroup')) {
  640 + const { sJurisdictionClassifyId } = this.props;
  641 + if (commonUtils.isNotEmptyArr(sJurisdictionClassifyId)) {
  642 + const filterData = this.props.masterConfig.gdsconfigformslave.filter(item => (item.sControlName === name));
  643 + const btnConfig = commonUtils.isNotEmptyArr(filterData) ? filterData[0] : {};// sButtonEnabled sButtonParam
  644 + console.log(333, btnConfig);
  645 + if (commonUtils.isNotEmptyObject(btnConfig) && commonUtils.isNotEmptyStr(btnConfig.sButtonParam)) {
  646 + /* 找到组配置 */
  647 + const sToGroupConfig = this.props.masterConfig.gdsconfigformslave.filter(item => item.sName === 'sCopyToGroupName');
  648 + console.log(332, sToGroupConfig);
  649 + if (commonUtils.isNotEmptyArr(sToGroupConfig)) {
  650 + this.props.onSaveState({ groupModalVisible: true, sToGroupConfig, sGroupId: sJurisdictionClassifyId }); /* 打开复制从窗体sJurisdictionClassifyId */
  651 + }
  652 + }
  653 + } else {
  654 + message.error('请选择组权限');
  655 + }
  656 + } else if (name.includes('BtnRepairUser')) {
  657 + const { userViewSelectedRowKeys } = this.props;
  658 + if (commonUtils.isNotEmptyArr(userViewSelectedRowKeys)) {
  659 + const filterData = this.props.masterConfig.gdsconfigformslave.filter(item => (item.sControlName === name));
  660 + const btnConfig = commonUtils.isNotEmptyArr(filterData) ? filterData[0] : {};// sButtonEnabled sButtonParam
  661 + console.log(filterData, filterData);
  662 + if (commonUtils.isNotEmptyObject(btnConfig) && commonUtils.isNotEmptyStr(btnConfig.sButtonParam)) {
  663 + /* 找到组配置 */
  664 + const sToUserConfig = this.props.masterConfig.gdsconfigformslave.filter(item => item.sName === 'sCopyToUserName');
  665 + console.log(332, sToUserConfig);
  666 + if (commonUtils.isNotEmptyArr(sToUserConfig)) {
  667 + this.props.onSaveState({ userModalVisible: true, sToUserConfig });
  668 + }
  669 + }
  670 + } else {
  671 + message.error('请选择用户权限');
  672 + }
  673 + } else if (name === 'BtnOut') {
  674 + this.handleOut();
  675 + } else if (name === 'BtnDesignFunction') {
  676 + this.handleDesignFunction();
  677 + } else if (name === 'BtnRefresh') {
  678 + const {
  679 + slaveConfig, slavePagination, slaveFilterCondition, slaveOrderBy,
  680 + } = this.props;
  681 + this.props.onSaveState({
  682 + clearArray: [], searchText: '', slaveSelectedRowKeys: [], slaveSelectedData: [], slaveInfoSelectedRowKeys: [], slaveInfoSelectedData: [], treeSelectedKeys: [], treeFilterCondition: [], loading: false, pageLoading: true, isFresh,
  683 + });
  684 + if (slavePagination === undefined) return;
  685 + this.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, slavePagination.pageSize, slaveOrderBy, true); /* 刷新方法 */
  686 + // if (formRoute === '/indexPage/materialRequirementsPlanning') {
  687 + // if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
  688 + // this.handleGetDataInfo(slaveInfoConfig, slaveFilterCondition, 1);
  689 + // }
  690 + // }
  691 + /* 判断是否要加载过滤树数据 */
  692 + const filterTreeConfigArr = slaveConfig.gdsconfigformslave.filter(item => item.bTree);
  693 + if (commonUtils.isNotEmptyArr(filterTreeConfigArr)) {
  694 + const filterTreeConfig = filterTreeConfigArr[0];
  695 + this.handleGetFilterTreeData(filterTreeConfig, slaveFilterCondition, 1);
  696 + }
  697 + const { clearArray } = this.props;
  698 + if (!commonUtils.isEmpty(clearArray)) {
  699 + for (const item of clearArray) {
  700 + const { confirm, clearFilters } = item;
  701 + confirm();
  702 + clearFilters();
  703 + }
  704 + }
  705 + } else if (name === 'BtnOutJurisdiction') {
  706 + const { activeKey, app, sModelsId } = this.props;
  707 + const { userinfo, token } = app;
  708 + const { sBrandsId, sSubsidiaryId } = userinfo;
  709 + const sType = activeKey === '3' ? 'user' : 'group';
  710 + const url = `${commonConfig.server_host}sysjurisdictionNew/exportSysjurisdiction/${sBrandsId}/${sSubsidiaryId}/${sType}?sModelsId=${sModelsId}&token=${token}`;
  711 + window.open(url);
  712 + }
  713 + };
  714 +
  715 + handleProcedureCall = async (btnConfig, proName, proInParam, other) => {
  716 + const { app, sModelsId } = this.props;
  717 + const value = { sProName: proName, sProInParam: proInParam };
  718 + if (other?.iFlag === 1) {
  719 + value.iFlag = 1;
  720 + }
  721 + const url = `${commonConfig.server_host}procedureCall/doGenericProcedureCall?sModelsId=${sModelsId}`;
  722 + const returnData = (await commonServices.postValueService(app.token, value, url)).data;
  723 + if (returnData.code === 1) {
  724 + message.success(returnData.msg);
  725 + // this.props.onButtonClick('BtnRefresh');
  726 + // this.handleRefresh();
  727 + this.handleGetChangeData({ name: 'group' }, 'GroupData');
  728 + this.handleGetChangeData({ name: 'userView' }, 'UserData');
  729 + this.props.onSaveState({ groupModalVisible: false, userModalVisible: false });
  730 + } else {
  731 + this.props.getServiceError({ ...returnData, fn: () => this.handleProcedureCall(btnConfig, proName, proInParam, { iFlag: 1 }) });
  732 + }
  733 + this.props.onSaveState({ loading: false });
  734 + }
  735 +
  736 + handleCopyGroupModalOk =() => {
  737 + const { sJurisdictionClassifyId, masterData } = this.props;
  738 + const filterData = this.props.masterConfig.gdsconfigformslave.filter(item => (item.sControlName === 'BtnRepairGroup'));
  739 + const btnConfig = commonUtils.isNotEmptyArr(filterData) ? filterData[0] : {};// sButtonEnabled sButtonParam
  740 + if (commonUtils.isNotEmptyObject(btnConfig) && commonUtils.isNotEmptyStr(btnConfig.sButtonParam)) {
  741 + const inParams = [];
  742 + const addState = {};
  743 + addState.key = 'group';
  744 + const val = [{
  745 + sGroupId: commonUtils.isNotEmptyArr(sJurisdictionClassifyId) ? sJurisdictionClassifyId[0] : '',
  746 + sToGroupId: commonUtils.isNotEmptyObject(masterData) && masterData.sCopyToGroupId,
  747 + }];
  748 + addState.value = val;
  749 + inParams.push({ ...addState });
  750 + this.handleProcedureCall(btnConfig, 'Sp_BtnEventCopyGroupJurisdiction', JSON.stringify({ params: inParams, changeValue: 'group' }));
  751 + }
  752 + };
  753 +
  754 + handleCopyUserModalOk =() => {
  755 + const { userViewSelectedRowKeys, masterData } = this.props;
  756 + const filterData = this.props.masterConfig.gdsconfigformslave.filter(item => (item.sControlName === 'BtnRepairUser'));
  757 + const btnConfig = commonUtils.isNotEmptyArr(filterData) ? filterData[0] : {};// sButtonEnabled sButtonParam
  758 + if (commonUtils.isNotEmptyObject(btnConfig) && commonUtils.isNotEmptyStr(btnConfig.sButtonParam)) {
  759 + const inParams = [];
  760 + const addState = {};
  761 + addState.key = 'user';
  762 + const val = [{
  763 + sUserId: commonUtils.isNotEmptyArr(userViewSelectedRowKeys) ? userViewSelectedRowKeys[0] : '',
  764 + sToUserId: commonUtils.isNotEmptyObject(masterData) && masterData.sCopyToUserId,
  765 + }];
  766 + addState.value = val;
  767 + inParams.push({ ...addState });
  768 + this.handleProcedureCall(btnConfig, 'Sp_BtnEventCopyUserJurisdiction', JSON.stringify({ params: inParams, changeValue: 'user' }));
  769 + }
  770 + };
  771 +
  772 + handleModalCancel = (modelVisible) => {
  773 + this.props.onSaveState({
  774 + [modelVisible]: false,
  775 + });
  776 + };
  777 +
  778 + render() {
  779 + const { masterData } = this.props;
  780 + const imgSrc = commonBusiness.handleAddIcon(masterData);
  781 + return (
  782 + <ChildComponent
  783 + {...this.props}
  784 + {...this.state}
  785 + onReturnForm={this.handleForm}
  786 + onSubmit={this.handleValidateSave.bind(this, 'tree')}
  787 + onEdit={this.handleEdit}
  788 + onTableSelectRowChange={this.handleTableSelectRowChange}
  789 + onCancel={this.handleCancel}
  790 + imgSrc={imgSrc}
  791 + onToggle={this.handleToggle}
  792 + onTreeCheck={this.handleCheckBoxCheck}
  793 + onRefresh={this.handleRefresh}
  794 + onSearch={this.handleSearch}
  795 + onDoubleClick={this.handleDoubleClick}
  796 + onSetTreeOptionKeys={this.handleSetTreeOptionData}
  797 + onSearchTable={this.handleSearchTable}
  798 + onSearchGroup={this.handleSearchGroup}
  799 + onSearchUser={this.handleSearchUser}
  800 + onButtonClick={this.handleButtonClick}
  801 + onCopyGroupModalOk={this.handleCopyGroupModalOk}
  802 + onCopyUserModalOk={this.handleCopyUserModalOk}
  803 + onModalCance={this.handleModalCancel}
  804 + />
  805 + );
  806 + }
  807 + };
  808 +};
src/components/Common/CommonProductionPlanEvent.js 0 → 100644
  1 +/* eslint-disable prefer-destructuring,no-await-in-loop,semi,no-unused-vars */
  2 +import React, { Component } from 'react';
  3 +import { message } from 'antd'; // Form, Modal, InputNumber
  4 +// import reactComponentDebounce from 'react-component-debounce';
  5 +import moment from 'moment';
  6 +import * as commonUtils from '../../utils/utils'; /* 通用方法 */
  7 +import * as commonBusiness from './commonBusiness'; /* 单据业务功能 */
  8 +import * as commonServices from '../../services/services'; /* 服务类 */
  9 +import commonConfig from '../../utils/config';
  10 +import * as commonFunc from './commonFunc'; /* 通用单据方法 */
  11 +
  12 +/*
  13 +const { confirm } = Modal;
  14 +const FormItem = Form.Item;
  15 +const InputNumberA = reactComponentDebounce(800)(InputNumber);
  16 +*/
  17 +
  18 +export default (ChildComponent) => {
  19 + return class extends Component {
  20 + constructor(props) {
  21 + super(props);
  22 + this.form = {}; /* 表单对象 */
  23 + }
  24 +
  25 + componentWillReceiveProps(nextProps) {
  26 + const {
  27 + app, formData, currentId, masterData, searchSolution, sGroupByList, teamSelectedRowKeys, teamData,
  28 + } = nextProps;
  29 + const { teamFilterCondition } = this.props;
  30 + let {
  31 + isReceive, teamConfig, slaveConfig, slaveInfoConfig,
  32 + } = nextProps;
  33 + const { currentPane } = app;
  34 + const { otherCondition } = currentPane;
  35 + if (formData.length > 0 && commonUtils.isEmptyObject(teamConfig) && commonUtils.isEmptyArr(searchSolution)) {
  36 + isReceive = false;
  37 + const sId = currentId !== undefined ? currentId : '';
  38 + const masterConfig = formData.filter(item => !item.bGrd && item.sTbName === 'eleteam')[0];
  39 +
  40 + teamConfig = formData.filter(item => item.sTbName === 'Sp_Manufacture_ProductionPlanInfo_WorkCenter')[0];
  41 + slaveConfig = formData.filter(item => item.sTbName === 'Sp_Manufacture_ProductionPlanInfo' && item.sGrd !== 'slaveInfo')[0];
  42 + slaveInfoConfig = formData.filter(item => item.sTbName === 'Sp_Manufacture_ProductionPlanInfo' && item.sGrd === 'slaveInfo')[0];
  43 + const productionPlanConfig = formData.filter(item => item.sTbName === 'MftProductionPlanSlave')[0];
  44 +
  45 + const teamColumn = commonFunc.getHeaderConfig(teamConfig);
  46 + const slaveColumn = commonFunc.getHeaderConfig(slaveConfig);
  47 + const slaveInfoColumn = commonFunc.getHeaderConfig(slaveInfoConfig);
  48 + const productionPlanColumn = commonFunc.getHeaderConfig(productionPlanConfig);
  49 +
  50 + let currfilterCondition = [];
  51 + if (commonUtils.isNotEmptyObject(masterData) && !commonUtils.isEmpty(masterData.sSearchSolutionId) && commonUtils.isNotEmptyArr(searchSolution)) {
  52 + const iIndex = searchSolution.findIndex(item => item.sId === masterData.sSearchSolutionId);
  53 + if (iIndex > -1 && !commonUtils.isEmpty(searchSolution[iIndex].sCondition)) {
  54 + currfilterCondition = JSON.parse(searchSolution[iIndex].sCondition);
  55 + }
  56 + }
  57 + this.handleGetData('team', teamConfig, currfilterCondition, undefined, '', false, sGroupByList);
  58 + // this.handleGetData('slave', slaveConfig, [], undefined, '', false, undefined);
  59 + // this.handleGetData('slaveInfo', slaveInfoConfig, [], undefined, '', false, undefined);
  60 +
  61 + this.props.onSaveState({
  62 + masterConfig,
  63 + teamConfig,
  64 + teamColumn,
  65 + slaveConfig,
  66 + slaveColumn,
  67 + slaveInfoConfig,
  68 + slaveInfoColumn,
  69 + productionPlanConfig,
  70 + productionPlanColumn,
  71 + sId,
  72 + pageLoading: false,
  73 + enabled: true,
  74 + dragPermission: false,
  75 + dragAndDropSwitch: false,
  76 + isReceive,
  77 + masterData: {},
  78 + tableBtnEnabled: true,
  79 + // stateOption: objValue,
  80 + });
  81 + } else if (commonUtils.isEmptyStr(teamSelectedRowKeys) && commonUtils.isEmptyArr(teamFilterCondition) && commonUtils.isNotEmptyArr(teamData) && !isReceive) {
  82 + let iIndex = -1;
  83 + if (otherCondition) {
  84 + iIndex = otherCondition.findIndex(item => item.bFilterName === 'sMachineId');
  85 + }
  86 + if (iIndex !== -1) {
  87 + const newIndex = teamData.findIndex(item => item.sMachineId === otherCondition[iIndex].bFilterValue);
  88 + if (newIndex === -1) {
  89 + this.handleCallBack({ ...teamData[0] });
  90 + } else {
  91 + this.handleCallBack({ ...teamData[newIndex] });
  92 + }
  93 + } else {
  94 + this.handleCallBack({ ...teamData[0] });
  95 + }
  96 + this.props.onSaveState({ isReceive: true });
  97 + } else if (commonUtils.isEmptyStr(teamSelectedRowKeys) && commonUtils.isEmptyArr(currentPane.filterCondition) && commonUtils.isEmptyArr(teamFilterCondition) && commonUtils.isNotEmptyArr(teamData) && !isReceive) {
  98 + this.handleGetData('slave', slaveConfig, [], undefined, '', false, undefined);
  99 + // this.handleGetData('slaveInfo', slaveInfoConfig, [], undefined, '', false, undefined);
  100 + this.props.onSaveState({ isReceive: true, teamSelectedRowKeys: teamData[0].sId });
  101 + }
  102 + }
  103 +
  104 + shouldComponentUpdate(nextProps) {
  105 + const {
  106 + slaveColumn,
  107 + } = nextProps;
  108 + return commonUtils.isNotEmptyArr(slaveColumn);
  109 + }
  110 +
  111 + componentDidUpdate(prevProps) {
  112 + const {
  113 + slaveSelectedRowKeys, moveEnabled, tableBtnEnabled,
  114 + } = prevProps;
  115 + if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys) && !moveEnabled && tableBtnEnabled) {
  116 + this.props.onSaveState({ moveEnabled: true });
  117 + } else if ((commonUtils.isEmptyArr(slaveSelectedRowKeys) && moveEnabled && tableBtnEnabled) || (moveEnabled && !tableBtnEnabled)) {
  118 + this.props.onSaveState({ moveEnabled: false });
  119 + }
  120 + }
  121 +
  122 + onChangeMachine = async () => {
  123 + const { sModelsId, masterData, slaveInfoSelectedRowKeys } = this.props;
  124 + const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
  125 + const value = {
  126 + sProName: 'Sp_Manufacture_ProductionPlanInfo_ChangeMachine',
  127 + paramsMap: {
  128 + bSplit: masterData.bSplit,
  129 + iSplitNum: masterData.iSplitNum,
  130 + sMachineId: masterData.sMachineId,
  131 + sTeamId: masterData.sTeamId,
  132 + tStartDate: masterData.tStartDate,
  133 + sProInParam: JSON.stringify({ params: { key: 'slaveInfo', value: { sId: slaveInfoSelectedRowKeys } } }),
  134 + },
  135 + };
  136 + const dataReturn = (await commonServices.postValueService(this.props.app.token, value, url)).data;
  137 + if (dataReturn.code === 1) {
  138 + /* 数据查询成功 */
  139 + this.handleRefresh();
  140 + this.props.onSaveState({ isChangeMachine: false, masterData: { ...masterData, sMachineId: '', sTeamId: '' } });
  141 + } else { /* 失败 */
  142 + this.props.getServiceError(dataReturn);
  143 + }
  144 + }
  145 +
  146 + /** 获取表数据 */
  147 + handleGetData = async (sName, slaveConfig, slaveFilterCondition, page, slaveOrderBy, clearSelectData, sGroupByListNew, nextProps, isWait) => {
  148 + const { app } = commonUtils.isEmpty(nextProps) ? this.props : nextProps;
  149 + const sGroupByList = sGroupByListNew !== undefined ? commonUtils.isEmptyArr(sGroupByListNew) ? null : sGroupByListNew : this.props.sGroupByList;
  150 + const conditonValues = app.currentPane.conditonValues;
  151 + const filterCondition = app.currentPane.filterCondition;
  152 + let bFilter = [];
  153 + if (!commonUtils.isEmptyArr(slaveFilterCondition)) {
  154 + slaveFilterCondition[0].bFilterName = slaveFilterCondition[0].bFilterName.replace('_pro', '');
  155 + bFilter.push(...slaveFilterCondition);
  156 + }
  157 + if (!commonUtils.isEmptyArr(filterCondition)) {
  158 + bFilter.push(...filterCondition);
  159 + }
  160 + const addState = {};
  161 + const pageNum = commonUtils.isEmpty(page) ? 1 : page;
  162 + addState.pageNum = pageNum;
  163 + addState.pageSize = ''; // commonConfig.pageSize;
  164 + if (sName === 'team' && commonUtils.isNotEmptyArr(filterCondition)) {
  165 + bFilter = [];
  166 + const addFilter = {};
  167 + addFilter.bFilterName = `${filterCondition[0].bFilterName}_pro`;
  168 + addFilter.bFilterCondition = '=';
  169 + addFilter.bFilterValue = filterCondition[0].bFilterValue;
  170 + bFilter.push(addFilter);
  171 + }
  172 + const returnData = await this.props.handleGetDataSet({
  173 + name: sName,
  174 + configData: slaveConfig,
  175 + condition: {
  176 + ...addState, bFilter, sFilterOrderBy: slaveOrderBy, sSqlCondition: conditonValues, sGroupList: sGroupByList,
  177 + },
  178 + flag: true,
  179 + clearSelectData,
  180 + isWait,
  181 + });
  182 + this.props.onSaveState({ Loading: false });
  183 + if (isWait) {
  184 + return { ...returnData };
  185 + }
  186 + };
  187 +
  188 + // 搜索 查询
  189 + handleGetSearchData = (config, filterCondition) => {
  190 + const {
  191 + teamConfig, sGroupByList, teamSelectedRowKeys,
  192 + } = this.props;
  193 + const iIndex = filterCondition.findIndex(item => item.bFilterName === 'sTeamId' && item.bFilterCondition === '=' && item.bFilterValue === teamSelectedRowKeys[0]);
  194 + const filter = [];
  195 + filterCondition.forEach((itme, i) => {
  196 + if (iIndex !== i) { filter.push(itme); }
  197 + });
  198 + this.handleGetData('team', teamConfig, filter, undefined, '', false, sGroupByList);
  199 + };
  200 +
  201 + handleGetSlaveData = (config, filterCondition) => {
  202 + const {
  203 + slaveConfig, slaveInfoConfig, teamData, teamSelectedRowKeys,
  204 + } = this.props;
  205 + const iIndex = filterCondition.findIndex(item => item.bFilterName === 'sTeamId' && item.bFilterCondition === '=' && item.bFilterValue === teamSelectedRowKeys[0]);
  206 + const filter = [];
  207 + filterCondition.forEach((itme, i) => {
  208 + if (iIndex !== i) { filter.push(itme); }
  209 + });
  210 +
  211 + const addFilter = {};
  212 + addFilter.bFilterName = 'sTeamId';
  213 + addFilter.bFilterCondition = '=';
  214 + addFilter.bFilterValue = teamData[0].sId;
  215 + filter.push(addFilter);
  216 +
  217 + this.handleGetData('slave', slaveConfig, filter, undefined, undefined);
  218 + // this.handleGetData('slaveInfo', slaveInfoConfig, filter, undefined, undefined);
  219 + };
  220 +
  221 + /** 主表控件是否全部显示 */
  222 + handleToggle = () => {
  223 + const { expand } = this.props;
  224 + this.props.onSaveState({ expand: !expand });
  225 + };
  226 +
  227 + /** 表单回带 */
  228 + handleForm = (form) => {
  229 + this.form = form;
  230 + };
  231 +
  232 + /** toolbar保存 */
  233 + handleSaveData = async (params) => {
  234 + const {
  235 + token, sModelsId,
  236 + } = this.props;
  237 + const returnData = await commonBusiness.saveData({ token, value: params, sModelsId });
  238 + if (commonUtils.isNotEmptyObject(returnData)) {
  239 + this.handleRefresh();
  240 + if (this.props.app.currentPane.refresh !== undefined) {
  241 + this.props.app.currentPane.refresh();
  242 + }
  243 + return true;
  244 + } else {
  245 + return false;
  246 + }
  247 + };
  248 +
  249 + /** 保存校验 */
  250 + handleValidateSave = () => {
  251 + this.form.validateFields((err) => {
  252 + /* 验证通过与不通过走不同的流程 */
  253 + if (err) { /* 验证失败 */
  254 + /* 直接渲染显示错误提示 */
  255 + for (const key of Object.keys(err)) {
  256 + message.error(err[key].errors[0].message);
  257 + }
  258 + } else { /* 验证成功 */
  259 + const {
  260 + slaveConfig, slaveData, slaveDelData, app, productionPlanConfig, productionPlanDelData, tableBtnEnabled, charGanttData, bGantt,
  261 + slaveInfoData, slaveInfoDelData,
  262 + } = this.props;
  263 + const data = [];
  264 + if (commonUtils.isEmptyArr(slaveData)) {
  265 + message.error(commonFunc.showMessage(app.commonConst, 'slaveNotNull')); // 从表不能为空!
  266 + return;
  267 + } else {
  268 + /* 如果是甘特图视图,则进入甘特图视图保存逻辑 */
  269 + if (bGantt && commonUtils.isNotEmptyObject(charGanttData)) {
  270 + const data = [];
  271 + const addState = {}
  272 + const charGanttDataFormate = [];
  273 + charGanttData.data.forEach((val) => {
  274 + val.start_date = moment(val.start_date).format('YYYY-MM-DD H:m');
  275 + val.end_date = moment(val.end_date).format('YYYY-MM-DD H:m');
  276 + charGanttDataFormate.push(val);
  277 + })
  278 + addState.name = 'slave';
  279 + addState.sTable = 'MftProductionPlanSlave';
  280 + addState.column = charGanttDataFormate;
  281 + data.push(addState);
  282 + this.handleSaveData({ data, sClientType: '1' });
  283 + return;
  284 + }
  285 + const productionPlanData = [];
  286 + const slaveFilter = slaveData.filter(item => item.sDivRowNew);
  287 + if (commonUtils.isNotEmptyArr(slaveFilter)) {
  288 + slaveFilter.forEach((item, i) => {
  289 + const index = slaveData.findIndex(itemS => itemS.sSlaveId === item.sSlaveId);
  290 + if (index <= slaveData.length) {
  291 + // slaveData[index].sDivRowNew = '';
  292 + slaveData[index + 1].sDivRow = item.sDivRowNew;
  293 + slaveData[index + 1].sDivRowNew = '';
  294 + }
  295 + });
  296 + }
  297 + for (const item of slaveData) {
  298 + const {
  299 + sSlaveId, handleType, iOrder, tStartDate, sMemo, dAdjustHour, sDivRowNew, sDivRow,
  300 + } = item;
  301 + if (commonUtils.isEmptyObject(sDivRowNew)) {
  302 + const sIds = sSlaveId.split('-');
  303 + sIds.forEach((newItem) => {
  304 + const addState = {};
  305 + addState.sId = newItem;
  306 + if (commonUtils.isEmpty(iOrder)) {
  307 + message.error('序号必填!');
  308 + return;
  309 + }
  310 + if (commonUtils.isEmpty(tStartDate)) {
  311 + message.error('时间必填!');
  312 + return;
  313 + }
  314 + addState.iOrder = iOrder;
  315 + /* 20210406 zhuzong要求排程保存时候 必传iOrder,tStartDate,sMemo,dAdjustHour 四个参数 */
  316 + addState.tStartDate = tStartDate;
  317 + // if (commonUtils.isNotEmptyObject(sMemo)) {
  318 + // addState.sMemo = sMemo;
  319 + // }
  320 + // if (dAdjustHour !== undefined) {
  321 + // addState.dAdjustHour = dAdjustHour;
  322 + // }
  323 + addState.sMemo = sMemo;
  324 + addState.dAdjustHour = dAdjustHour;
  325 + addState.handleType = handleType;
  326 + if (sDivRow) {
  327 + addState.sDivRow = sDivRow;
  328 + } else {
  329 + addState.sDivRow = '';
  330 + }
  331 + productionPlanData.push(addState);
  332 + });
  333 + }
  334 + }
  335 + data.push(commonBusiness.mergeData('productionPlan', productionPlanConfig.sTbName, productionPlanData, productionPlanDelData));
  336 + data.push(commonBusiness.mergeData('slaveInfo', productionPlanConfig.sTbName, slaveInfoData, slaveInfoDelData));
  337 + }
  338 + if (!commonBusiness.validateTable(slaveConfig, slaveData)) {
  339 + return;
  340 + }
  341 + // data.push(commonBusiness.mergeData('slave', 'MftProductionPlanSlave', slaveData, slaveDelData));
  342 + this.handleSaveData({ data, sClientType: '1' });
  343 + }
  344 + });
  345 + };
  346 +
  347 + /* 数据删除成功跳转到新路由即pane */
  348 + handleDelDataSuccess = (props) => {
  349 + const { app } = props;
  350 + let { panes, currentPane } = app;
  351 + /* 删除单据后退出当前路由后,标签panes变化后的集合 */
  352 + panes = panes.filter(pane => pane.key !== currentPane.key);
  353 + /* 跳转到panes集合的最后一个路由,因为panes集合一定含有主页路由所以panes的集合大于等于1 */
  354 + currentPane = panes[panes.length - 1];
  355 + this.props.onRemovePane(panes, currentPane);
  356 + };
  357 +
  358 + /** 表格数据更改 */
  359 + // name 不写完整的state名称作用为了要用到total // (name, changeValue, sId, dropDownData)
  360 + handleTableChange = async (name, sFieldName, changeValue, sId, dropDownData) => {
  361 + const { sModelsId } = this.props;
  362 + this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, false);
  363 + if (name === 'slave') {
  364 + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sTeamId', []);
  365 + if (sFieldName === 'iOrder') {
  366 + /* 修改汇总表数据后,slaveInfo表iOrder同步更改 */
  367 + const { slaveInfoData, slaveData } = this.props;
  368 + const iIndex = slaveData.findIndex(item => item.sId === sId);
  369 + if (iIndex > -1) {
  370 + const tableDataRow = slaveData[iIndex];
  371 + let childrenData = [];
  372 + childrenData = tableDataRow.childrenData;
  373 + if (commonUtils.isNotEmptyArr(childrenData)) {
  374 + childrenData.forEach((child) => {
  375 + const index = slaveInfoData.findIndex(item => item.sId === child.sId);
  376 + const addState = {};
  377 + addState.handleType = 'update';
  378 + addState.iOrder = tableDataRow.iOrder;
  379 + if (index > -1) {
  380 + slaveInfoData[index] = { ...slaveInfoData[index], ...addState }
  381 + }
  382 + });
  383 + this.props.onSaveState({ slaveData, slaveInfoData });
  384 + }
  385 + }
  386 + }
  387 + }
  388 + };
  389 + // 打印
  390 + handleBtnPrint = (sActiveId, checked) => {
  391 + const {
  392 + app, sModelsId, slaveConfig, slaveSelectedRowKeys, slaveFilterCondition, reportData,
  393 + } = this.props;
  394 + const { token } = app;
  395 + let slaveFilterConditionNew = slaveFilterCondition === undefined ? [] : [...slaveFilterCondition];
  396 +
  397 + let sids = '';
  398 + slaveSelectedRowKeys.forEach((item, i) => {
  399 + if (i === slaveSelectedRowKeys.length - 1) {
  400 + sids = `${sids}${item}`;
  401 + } else {
  402 + sids = `${sids}${item},`;
  403 + }
  404 + });
  405 + if (sids !== '') {
  406 + slaveFilterConditionNew = [];
  407 + const sidsNew = commonUtils.isNotEmptyObject(sids) ? sids.replace(/-/g, ',') : '';
  408 + const addFilter = {};
  409 + addFilter.bFilterName = 'sId';
  410 + addFilter.bFilterCondition = 'in';
  411 + addFilter.bFilterValue = sidsNew;
  412 + slaveFilterConditionNew.push(addFilter);
  413 + }
  414 +
  415 + const queryFilter = {};
  416 + queryFilter[slaveConfig.sId] = { bFilter: slaveFilterConditionNew };
  417 +
  418 + const queryFilterJson = encodeURIComponent(JSON.stringify(queryFilter));
  419 + /* 拿到打印报表名称 */
  420 + let printReportName = 'report';
  421 + if (commonUtils.isNotEmptyArr(reportData)) {
  422 + const iIndex = reportData.findIndex(item => item.sId === sActiveId);
  423 + if (iIndex > -1) {
  424 + printReportName = reportData[iIndex].sReportName;
  425 + }
  426 + }
  427 + const urlPrint = `${commonConfig.file_host}printReport/printPdf/${sActiveId}/${printReportName}.pdf?${checked ? 'fileType=.xlsx&' : ''}queryFilter=${queryFilterJson}&sModelsId=${sModelsId}&sMaintableId=${slaveConfig.sId}&token=${encodeURIComponent(token)}`;
  428 + window.open(urlPrint);
  429 + };
  430 + /* 导出Excel */
  431 + handleOut = () => {
  432 + const {
  433 + slaveConfig, sFilterOrderBy, slaveSelectedRowKeys, slaveFilterCondition, sGroupByList,
  434 + } = this.props;
  435 +
  436 + const newfilterCondition = slaveFilterCondition === undefined ? [] : slaveFilterCondition;
  437 +
  438 + let sids = '';
  439 + if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
  440 + slaveSelectedRowKeys.forEach((item, i) => {
  441 + if (i === slaveSelectedRowKeys.length - 1) {
  442 + sids = `${sids}${item}`;
  443 + } else {
  444 + sids = `${sids}${item},`;
  445 + }
  446 + });
  447 + const addFilter = {};
  448 + addFilter.bFilterName = 'sId';
  449 + addFilter.bFilterCondition = 'in';
  450 + addFilter.bFilterValue = sids;
  451 + newfilterCondition.push(addFilter);
  452 + }
  453 +
  454 + let url = `${commonConfig.server_host}excel/export/${slaveConfig.sId}?sModelsId=${slaveConfig.sParentId}&token=${this.props.app.token}`;
  455 + if (commonUtils.isNotEmptyArr(newfilterCondition)) {
  456 + url = `${url}&bFilter=${encodeURIComponent(JSON.stringify(newfilterCondition))}`;
  457 + }
  458 + if (sFilterOrderBy !== undefined && sFilterOrderBy !== '' && Object.keys(sFilterOrderBy).length > 0) {
  459 + url = `${url}&sFilterOrderBy=${encodeURIComponent(JSON.stringify(sFilterOrderBy))}`;
  460 + }
  461 + if (commonUtils.isNotEmptyArr(sGroupByList)) {
  462 + url = `${url}&sGroupList=${encodeURIComponent(JSON.stringify(sGroupByList))}`;
  463 + }
  464 + window.open(url);
  465 + };
  466 + handleConfirmDataChange = (value) => {
  467 + const {
  468 + masterData,
  469 + } = this.props;
  470 + masterData.dOutsideQty = value;
  471 +
  472 + this.props.onSaveState({ masterData });
  473 + };
  474 + // 按钮操作
  475 + handleButtonClick = (name) => {
  476 + if (name === 'BtnRefresh') {
  477 + this.handleRefresh();
  478 + } else if (name === 'BtnOut') {
  479 + this.handleOut();
  480 + } else if (name === 'BtnDesignFunction') {
  481 + this.handleDesignFunction();
  482 + }
  483 + };
  484 + handleDesignFunction = () => {
  485 + this.props.onSaveState({ visibleStatement: true });
  486 + };
  487 + handleUpdated = async (params) => {
  488 + const { app, sModelsId } = this.props;
  489 + const { token } = app;
  490 +
  491 + const url = `${commonConfig.server_host}productionPlan/getProcessOperation?sModelsId=${sModelsId}`;
  492 + const { data } = await commonServices.postValueService(token, params, url);
  493 +
  494 + if (data.code === 1) {
  495 + /* 数据查询成功 */
  496 + return true;
  497 + } else { /* 失败 */
  498 + this.props.getServiceError(data);
  499 + return false;
  500 + }
  501 + };
  502 +
  503 + handleMasterChange = (name, sFieldName, changeValue, sId, dropDownData, isWait) => {
  504 + const { sModelsId } = this.props;
  505 + if (sFieldName === 'sMachineId') {
  506 + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sTeamId', []);
  507 + }
  508 + if (isWait) {
  509 + return this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, isWait);
  510 + } else {
  511 + this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, isWait);
  512 + }
  513 + };
  514 +
  515 + handleCalculate = () => {
  516 + const { sModelsId, slaveData } = this.props;
  517 + const materialsInfo = [];
  518 + const slaveDataNew = [];
  519 + slaveData.forEach(async (item) => {
  520 + const index = materialsInfo.findIndex(obj => obj.sMaterialsId === item.sMaterialsId);
  521 + item.bMaterialAdequate = 0;
  522 + if (commonUtils.isNotEmptyStr(item.sMaterialsId) && index === -1) {
  523 + const url = `${commonConfig.server_host}eleMaterialsStock/getEleMaterialsStoreCurrQty?sModelsId=${sModelsId}`;
  524 + const body = {
  525 + sMaterialsId: item.sMaterialsId, /* 查询条件 */
  526 + };
  527 + const dataReturn = (await commonServices.postValueService(this.props.app.token, body, url)).data;
  528 + if (dataReturn.code === 1) {
  529 + if (commonUtils.isNotEmptyArr(dataReturn.dataset.rows[0])) {
  530 + const materials = dataReturn.dataset.rows[0];
  531 + if (commonUtils.isNotEmptyNumber(materials.dAuxiliaryQty) && commonUtils.isNotEmptyNumber(item.dPrintQty) && materials.dAuxiliaryQty > item.dPrintQty) {
  532 + item.bMaterialAdequate = 1;
  533 + materialsInfo[index].dAuxiliaryQty = materialsInfo[index].sMaterialsId - item.dPrintQty;
  534 + }
  535 + }
  536 + }
  537 + } else if (commonUtils.isNotEmptyStr(item.sMaterialsId) && index === -1) {
  538 + if (commonUtils.isNotEmptyNumber(materialsInfo[index].sMaterialsId) && commonUtils.isNotEmptyNumber(item.dPrintQty) && materialsInfo[index].sMaterialsId > item.dPrintQty) {
  539 + item.bMaterialAdequate = 1;
  540 + materialsInfo[index].dAuxiliaryQty = materialsInfo[index].sMaterialsId - item.dPrintQty;
  541 + }
  542 + }
  543 + slaveDataNew.push(item);
  544 + });
  545 + this.props.onSaveState({ slaveData: slaveDataNew });
  546 + };
  547 +
  548 + handleTitleChange = async (name, slavePagination, filters, sorter, extra) => {
  549 + // const tableBtnEnabled = commonUtils.isNotEmptyObject(filters) && commonUtils.isEmptyObject(sorter);
  550 + const addState = {}; // 搜索时不能使用排序保存,否则数据会出不来。
  551 + if (commonUtils.isNotEmptyObject(sorter)) {
  552 + const slaveData = [];
  553 + extra.currentDataSource.forEach((item, iIndex) => {
  554 + const slaveTableRow = { ...item, iOrder: iIndex + 1, handleType: 'update' };
  555 + slaveData.push(slaveTableRow);
  556 + });
  557 + if (slaveData.length === this.props.slaveData.length) {
  558 + addState.slaveData = slaveData;
  559 + }
  560 + }
  561 + this.props.onSaveState({
  562 + ...addState, slavePagination, pageLoading: false,
  563 + });
  564 + // this.props.onSaveState({
  565 + // tableBtnEnabled: false, pageLoading: true,
  566 + // });
  567 + // const { [`${name}Config`]: tableConfig, [`${name}FilterCondition`]: tableFilterCondition, sGroupByList } = this.props;
  568 + // const sort = sorter.order === 'ascend' ? 'asc' : 'desc';
  569 + // const slaveOrderBy = Object.keys(sorter).length > 0 ? { [sorter.columnKey]: sort } : ''; // 后端未支持空对象, 先用空表示
  570 + // const addState = await this.handleGetData(name, tableConfig, tableFilterCondition, undefined, slaveOrderBy, '', sGroupByList, this.props, true);
  571 + // if (addState === undefined) return;
  572 + // const { [`${name}Data`]: tempData } = addState;
  573 + // if (commonUtils.isNotEmptyArr(addState[`${name}Data`])) {
  574 + // addState[`${name}Data`].forEach((item, iIndex) => {
  575 + // addState[`${name}Data`][iIndex] = { ...item, iOrder: iIndex + 1, handleType: 'update' };
  576 + // });
  577 + // }
  578 + // this.props.onSaveState({ ...addState });
  579 + // setTimeout(() => {
  580 + // /* 刷新commList页面数据 */
  581 + // this.props.onSaveState({ pageLoading: false });
  582 + // }, 3600);
  583 + };
  584 + /** 处理选择行发生改变 */
  585 + handleCallBack = (child) => {
  586 + const {
  587 + slaveConfig, slaveInfoConfig, teamFilterCondition, bGantt,
  588 + } = this.props;
  589 + const filter = [];
  590 + let addFilter = {};
  591 + if (child.sType === '1') {
  592 + addFilter.bFilterName = 'sProcessId';
  593 + addFilter.bFilterCondition = '=';
  594 + addFilter.bFilterValue = child.sMachineId;
  595 + filter.push(addFilter);
  596 + addFilter = {};
  597 + addFilter.bFilterName = 'sState';
  598 + addFilter.bFilterCondition = '=';
  599 + addFilter.bFilterValue = '0';
  600 + filter.push(addFilter);
  601 + } else if (child.sType === '2') {
  602 + addFilter.bFilterName = 'sMachineId';
  603 + addFilter.bFilterCondition = '=';
  604 + addFilter.bFilterValue = child.sMachineId;
  605 + filter.push(addFilter);
  606 + addFilter = {};
  607 + addFilter.bFilterName = 'date_format(tStartDate, \'%y-%m-%d\')';
  608 + addFilter.bFilterCondition = '=';
  609 + addFilter.bFilterValue = child.tStartDate;
  610 + filter.push(addFilter);
  611 + }
  612 + if (commonUtils.isNotEmptyArr(teamFilterCondition)) {
  613 + filter.push(...teamFilterCondition);
  614 + }
  615 + this.handleGetData('slave', slaveConfig, filter, undefined, '', false, undefined);
  616 + /* 甘特图视图下 点击卡片刷新 */
  617 + if (bGantt) {
  618 + this.handleGanttChar('', filter)
  619 + }
  620 + // this.handleGetData('slaveInfo', slaveInfoConfig, filter, undefined, '', false, undefined);
  621 + const rowKeys = [];
  622 + rowKeys.push(child.sId);
  623 + this.props.onSaveState({
  624 + teamSelectedRowKeys: rowKeys,
  625 + });
  626 + };
  627 +
  628 + /* 获取甘特图数据 */
  629 + handleGanttChar = async (ganttChart, slaveFilterCondition) => {
  630 + const {
  631 + token, sModelsId, formRoute,
  632 + } = this.props;
  633 + const char = {};
  634 + if (commonUtils.isNotEmptyObject(ganttChart)) {
  635 + char.sProcedureName = ganttChart.sProcedureName;
  636 + char.paramsMap = ganttChart.paramsMap;
  637 + } else {
  638 + char.sProcedureName = 'Sp_Process_CommonGtChar';
  639 + char.paramsMap = {
  640 + };
  641 + }
  642 + let charGanttData = {};
  643 + const value = {
  644 + sProName: char.sProcedureName,
  645 + paramsMap: char.prodParamsMap,
  646 + bFilter: slaveFilterCondition,
  647 + };
  648 + const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}&sName=${formRoute}`;
  649 + const { data: returnData } = await commonServices.postValueService(token, value, url);
  650 + if (returnData.code === 1) {
  651 + const { dataset } = returnData;
  652 + if (commonUtils.isNotEmptyObject(dataset)) {
  653 + const outData = returnData.dataset.rows[0].dataSet.outData[0];
  654 + if (outData.sCode === -1) {
  655 + message.error(outData.sReturn);
  656 + } else {
  657 + charGanttData = commonUtils.isEmpty(outData.sReturn) ? [] : JSON.parse(outData.sReturn);
  658 + this.props.onSaveState({ charGanttData });
  659 + }
  660 + }
  661 + } else {
  662 + message.error(returnData.msg);
  663 + }
  664 + };
  665 +
  666 + /* 获取稽查模型数据 */
  667 + handleCheckModel = async (chart, slaveFilterCondition, other) => {
  668 + const { app, sModelsId } = this.props;
  669 + const obj = {};
  670 + if (commonUtils.isNotEmptyObject(obj)) {
  671 + obj.sProcedureName = chart.sProcedureName;
  672 + obj.paramsMap = chart.paramsMap;
  673 + } else {
  674 + obj.sProcedureName = 'Sp_Manufacture_GetAPSstate';
  675 + obj.paramsMap = {
  676 + };
  677 + }
  678 + const value = {
  679 + sProName: obj.sProcedureName,
  680 + bFilter: slaveFilterCondition,
  681 + };
  682 + if (other?.iFlag === 1) {
  683 + value.iFlag = 1;
  684 + }
  685 +
  686 + const url = `${commonConfig.server_host}procedureCall/doGenericProcedureCall?sModelsId=${sModelsId}`;
  687 + const returnData = (await commonServices.postValueService(app.token, value, url)).data;
  688 + if (returnData.code === 1) {
  689 + message.success(returnData.msg);
  690 + this.handleButtonClick('BtnRefresh');
  691 + this.props.onSaveState({ bCheckModel: true })
  692 + } else {
  693 + this.props.getServiceError({ ...returnData, fn: () => this.handleCheckModel(chart, slaveFilterCondition, { iFlag: 1 }) });
  694 + }
  695 + };
  696 +
  697 + /* 重算时间调用接口 执行存储过程 */
  698 + handleChangeTimer = async (other) => {
  699 + const {
  700 + app, sModelsId, slaveFilterCondition, slaveSelectedRowKeys, slaveData, masterData,
  701 + } = this.props;
  702 + let value = {};
  703 + if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
  704 + this.props.onSaveState({ bChangeTimerEnable: false })
  705 + const slaveSelectedData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sSlaveId));
  706 + const minSelectedData = this.arrayMin(slaveSelectedData); /* iOrder最小的 */
  707 + if (commonUtils.isNotEmptyArr(minSelectedData) && commonUtils.isNotEmptyObject(minSelectedData.sMachineId)) {
  708 + value = {
  709 + sProName: 'Sp_Manufacture_SetTime',
  710 + sProInParam: JSON.stringify({
  711 + sMachineId: minSelectedData.sMachineId,
  712 + iOrder: minSelectedData.iOrder,
  713 + tCStartTime: masterData.tStartDate,
  714 + }),
  715 + };
  716 + if (other?.iFlag === 1) {
  717 + value.iFlag = 1;
  718 + }
  719 + const url = `${commonConfig.server_host}procedureCall/doGenericProcedureCall?sModelsId=${sModelsId}`;
  720 + const returnData = (await commonServices.postValueService(app.token, value, url)).data;
  721 + if (returnData.code === 1) {
  722 + message.success(returnData.msg);
  723 + this.handleButtonClick('BtnRefresh');
  724 + this.props.onSaveState({ changeTimerVisible: false, bChangeTimerEnable: true })
  725 + } else {
  726 + this.props.getServiceError({ ...returnData, fn: () => this.handleChangeTimer({ iFlag: 1 }) });
  727 + }
  728 + } else {
  729 + message.error('不能重置时间!');
  730 + }
  731 + } else {
  732 + message.error('请选择一行数据!');
  733 + }
  734 + };
  735 +
  736 + // 查找数组中最小值
  737 + arrayMin = (arrs) => {
  738 + let min = arrs[0];
  739 + for (let i = 1, ilen = arrs.length; i < ilen; i += 1) {
  740 + if (arrs[i].iOrder < min.iOrder) {
  741 + min = arrs[i];
  742 + }
  743 + }
  744 + return min;
  745 + }
  746 +
  747 + /*
  748 + handleRefresh = async () => {
  749 + const {
  750 + clearArray, slaveConfig, slaveInfoConfig, teamFilterCondition, slaveFilterCondition,
  751 + } = this.props;
  752 + this.props.onSaveState({
  753 + clearArray: [], searchText: '', teamSelectedData: [], slaveSelectedRowKeys: [], slaveSelectedData: [], slaveInfoSelectedRowKeys: [], slaveInfoSelectedData: [], tableBtnEnabled: true,
  754 + }); // teamSelectedRowKeys: [],
  755 + this.handleGetData('slave', slaveConfig, slaveFilterCondition, undefined, '', false, undefined);
  756 + this.handleGetData('slaveInfo', slaveInfoConfig, slaveFilterCondition, undefined, '', false, undefined);
  757 +
  758 + if (!commonUtils.isEmpty(clearArray)) {
  759 + for (const item of clearArray) {
  760 + const { confirm, clearFilters } = item;
  761 + confirm();
  762 + clearFilters();
  763 + }
  764 + }
  765 + this.props.onSaveState({
  766 + loading: false,
  767 + });
  768 + }
  769 +*/
  770 + handleRefresh = async () => {
  771 + const {
  772 + clearArray, teamConfig, teamFilterCondition, slaveFilterCondition, teamSelectedRowKeys,
  773 + } = this.props;
  774 + let { expKeys } = this.props;
  775 + const addState = await this.handleGetData('team', teamConfig, teamFilterCondition, undefined, '', false, undefined, this.props, true);
  776 + if (addState === undefined) return;
  777 + this.props.onSaveState({
  778 + ...addState,
  779 + clearArray: [],
  780 + searchText: '',
  781 + teamSelectedData: [],
  782 + slaveSelectedRowKeys: [],
  783 + slaveSelectedData: [],
  784 + slaveInfoData: [], /* 刷新后清除slaveInfoData */
  785 + slaveInfoSelectedRowKeys: [],
  786 + slaveInfoSelectedData: [],
  787 + tableBtnEnabled: true,
  788 + machineEnabled: false,
  789 + sortedInfo: {},
  790 + });
  791 + const { teamData } = addState;
  792 + const newIndex = teamData.findIndex(item => item.sId === teamSelectedRowKeys[0]);
  793 + if (newIndex === -1) {
  794 + this.handleCallBack({ ...teamData[0] });
  795 + } else {
  796 + this.handleCallBack({ ...teamData[newIndex] });
  797 + }
  798 +
  799 + if (!commonUtils.isEmpty(clearArray)) {
  800 + for (const item of clearArray) {
  801 + const { confirm, clearFilters } = item;
  802 + confirm();
  803 + clearFilters();
  804 + }
  805 + }
  806 + /* 刷新后关闭所有expKeys */
  807 + expKeys = [];
  808 + /* 刷新后清除slaveInfoData */
  809 + this.props.onSaveState({
  810 + loading: false, expKeys,
  811 + });
  812 + }
  813 +
  814 + handleResetTableSearch = () => {
  815 + this.props.onSaveState({ clearArray: [] });
  816 + this.handleRefresh();
  817 + }
  818 + // 进行存储过程按钮存储过程参数解析拼接 根据存储过程按钮参数配置进行解析,配置是json格式 {"sproName":"cal_sss","inMap":"master.sSlaveId,slave.sId"}
  819 + handleBtnEent = (btnConfig, btnName, sValue) => {
  820 + const { masterData } = this.props;
  821 + const sButtonParam = btnConfig.sButtonParam;
  822 + const btn = JSON.parse(sButtonParam);
  823 + const sProName = btn.sproName;
  824 + const inParams = [];
  825 + const inMap = btn.inMap;
  826 + const inlist = inMap.split(',');
  827 +
  828 + const masterArr = [];
  829 + const slaveArr = [];
  830 + const slaveInfoArr = [];
  831 + const controlArr = [];
  832 + const materialsArr = [];
  833 + const processArr = [];
  834 +
  835 + if (inlist.length > 0) {
  836 + inlist.forEach((item) => {
  837 + const itemArr = item.split('.');
  838 + if (itemArr.length > 0) {
  839 + const sname = itemArr[0];
  840 + const stype = itemArr[1];
  841 + if (commonUtils.isNotEmptyStr(sname) && sname === 'master') {
  842 + masterArr.push(stype);
  843 + }
  844 + if (commonUtils.isNotEmptyStr(sname) && sname === 'slave') {
  845 + slaveArr.push(stype);
  846 + }
  847 + if (commonUtils.isNotEmptyStr(sname) && sname === 'slaveInfo') {
  848 + slaveInfoArr.push(stype);
  849 + }
  850 + if (commonUtils.isNotEmptyStr(sname) && sname === 'control') {
  851 + controlArr.push(stype);
  852 + }
  853 + if (commonUtils.isNotEmptyStr(sname) && sname === 'materials') {
  854 + materialsArr.push(stype);
  855 + }
  856 + if (commonUtils.isNotEmptyStr(sname) && sname === 'process') {
  857 + processArr.push(stype);
  858 + }
  859 + }
  860 + });
  861 +
  862 + if (commonUtils.isNotEmptyArr(masterArr) && commonUtils.isNotEmptyObject(masterData)) {
  863 + const addState = {};
  864 + addState.key = 'master';
  865 + const val = [];
  866 + const currVal = {};
  867 + masterArr.forEach((filed) => {
  868 + currVal[`${filed}`] = masterData[`${filed}`];
  869 + });
  870 + val.push(currVal);
  871 + addState.value = val;
  872 + inParams.push({ ...addState });
  873 + }
  874 + if (commonUtils.isNotEmptyArr(slaveArr)) {
  875 + const addState = this.handleProParams('slave', slaveArr);
  876 + if (commonUtils.isNotEmptyObject(addState)) {
  877 + inParams.push({ ...addState });
  878 + }
  879 + }
  880 + if (commonUtils.isNotEmptyArr(slaveInfoArr)) {
  881 + const addState = this.handleProParams('slaveInfo', slaveInfoArr);
  882 + if (commonUtils.isNotEmptyObject(addState)) {
  883 + inParams.push({ ...addState });
  884 + }
  885 + }
  886 + if (commonUtils.isNotEmptyArr(controlArr)) {
  887 + const addState = this.handleProParams('control', controlArr);
  888 + if (commonUtils.isNotEmptyObject(addState)) {
  889 + inParams.push({ ...addState });
  890 + }
  891 + }
  892 + if (commonUtils.isNotEmptyArr(materialsArr)) {
  893 + const addState = this.handleProParams('materials', materialsArr);
  894 + if (commonUtils.isNotEmptyObject(addState)) {
  895 + inParams.push({ ...addState });
  896 + }
  897 + }
  898 + if (commonUtils.isNotEmptyArr(processArr)) {
  899 + const addState = this.handleProParams('process', processArr);
  900 + if (commonUtils.isNotEmptyObject(addState)) {
  901 + inParams.push({ ...addState });
  902 + }
  903 + }
  904 + }
  905 +
  906 + this.handleProcedureCall(btnConfig, sProName, JSON.stringify({ params: inParams, changeValue: sValue }));
  907 + };
  908 + // 根据配置解析拼接具体参数
  909 + handleProParams = (sKey, arr) => {
  910 + const { [`${sKey}Data`]: tableData, [`${sKey}SelectedRowKeys`]: selectedRowKeys } = this.props;
  911 + const keyData = tableData.filter(item => selectedRowKeys.includes(item.sId) || selectedRowKeys.includes(item.sSlaveId));
  912 + if (commonUtils.isNotEmptyArr(keyData)) {
  913 + const addState = {};
  914 + addState.key = sKey;
  915 + const val = [];
  916 + keyData.forEach((currData) => {
  917 + const currVal = {};
  918 + arr.forEach((filed) => {
  919 + currVal[`${filed}`] = currData[`${filed}`];
  920 + });
  921 + val.push(currVal);
  922 + });
  923 + addState.value = val;
  924 + return addState;
  925 + } else {
  926 + return undefined;
  927 + }
  928 + };
  929 + // 存储过程按钮调用存储过程
  930 + handleProcedureCall = async (btnConfig, proName, proInParam, other) => {
  931 + const { app, sModelsId, sCurrMemoProps } = this.props;
  932 + const value = { sProName: proName, sProInParam: proInParam };
  933 + if (other?.iFlag === 1) {
  934 + value.iFlag = 1;
  935 + }
  936 + const url = `${commonConfig.server_host}procedureCall/doGenericProcedureCall?sModelsId=${sModelsId}`;
  937 + const returnData = (await commonServices.postValueService(app.token, value, url)).data;
  938 + /**
  939 + * 修改日期:2021-03-26
  940 + * 修改人:吕杰
  941 + * 区域:以下 2 行
  942 + * BUG:
  943 + * 说明:执行完接口调用后关闭弹窗
  944 + * 原代码:
  945 + */
  946 + sCurrMemoProps.bVisibleMemo = false;
  947 + this.props.onSaveState({ loading: false, sCurrMemoProps });
  948 + if (returnData.code === 1) {
  949 + message.success(returnData.msg);
  950 + this.handleButtonClick('BtnRefresh');
  951 + } else {
  952 + this.props.getServiceError({ ...returnData, fn: () => this.handleProcedureCall(btnConfig, proName, proInParam, { iFlag: 1 }) });
  953 + }
  954 + }
  955 + /* 点击展开图标时,调用接口获取嵌套字表数据 */
  956 + handleOnExpand = async (expanded, record) => {
  957 + const { sModelsId, expKeys } = this.props;
  958 + let { slaveInfoData } = this.props;
  959 + const { sSlaveId } = record;
  960 + /* 添加移除展开的sId */
  961 + let newExp = commonUtils.isNotEmptyArr(expKeys) ? expKeys : [];
  962 + if (expanded) {
  963 + if (commonUtils.isNotEmptyObject(sSlaveId)) {
  964 + newExp.push(record.sSlaveId);
  965 + }
  966 + } else {
  967 + newExp = newExp.filter(item => item !== record.sSlaveId);
  968 + }
  969 + this.props.onSaveState({ expKeys: newExp });
  970 + let childrenData = [];
  971 + if (commonUtils.isNotEmptyArr(slaveInfoData) && commonUtils.isNotEmptyObject(sSlaveId)) {
  972 + childrenData = slaveInfoData.filter(item => sSlaveId.split('-').includes(item.sId));
  973 + }
  974 + if (expanded && commonUtils.isEmptyArr(childrenData)) {
  975 + if (commonUtils.isNotEmptyObject(sSlaveId)) {
  976 + const planLoadingSate = {};
  977 + planLoadingSate.sId = sSlaveId;
  978 + planLoadingSate.planLoading = true;
  979 + this.props.onSaveState({ planLoadingSate });
  980 + const { token } = this.props;
  981 + const url = `${commonConfig.server_host}workOrderPlan/getProductionPlanInfo?sModelsId=${sModelsId}`;
  982 + const value = { sSlaveId };
  983 + const dataReturn = (await commonServices.postValueService(token, value, url)).data;
  984 + if (dataReturn.code === 1) {
  985 + const returnData = dataReturn.dataset.rows;
  986 + if (commonUtils.isNotEmptyArr(returnData)) {
  987 + childrenData = returnData;
  988 + if (commonUtils.isEmptyArr(slaveInfoData)) {
  989 + slaveInfoData = [];
  990 + }
  991 + childrenData.forEach((child) => {
  992 + // const iIndex = slaveInfoData.findIndex(item => item.sId === child.sId);
  993 + // if (iIndex === -1) {
  994 + // slaveInfoData.push(child);
  995 + // }
  996 + slaveInfoData.push(child);
  997 + });
  998 + }
  999 + planLoadingSate.planLoading = false;
  1000 + this.props.onSaveState({
  1001 + planLoadingSate, slaveInfoData,
  1002 + });
  1003 + } else {
  1004 + this.props.getServiceError(dataReturn);
  1005 + planLoadingSate.planLoading = false;
  1006 + this.props.onSaveState({ planLoadingSate });
  1007 + }
  1008 + }
  1009 + }
  1010 + }
  1011 + handlePartNameClick =(sName, showConfig, record) => {
  1012 + if (commonUtils.isNotEmptyObject(sName) && commonUtils.isNotEmptyObject(showConfig) && commonUtils.isNotEmptyObject(record)) {
  1013 + this.props.onSaveState({ workScheduleConfig: showConfig, workScheduleRecord: record, workScheduleVisible: true });
  1014 + }
  1015 + }
  1016 + handleCloseModel = (modelVisible) => {
  1017 + this.props.onSaveState({ [modelVisible]: false });
  1018 + };
  1019 + render() {
  1020 + const { masterData } = this.props;
  1021 + const imgSrc = commonBusiness.handleAddIcon(masterData);
  1022 + return (
  1023 + <ChildComponent
  1024 + {...this.props}
  1025 + {...this.state}
  1026 + onToggle={this.handleToggle}
  1027 + onSaveData={this.handleSaveData}
  1028 + onGetData={this.handleGetSearchData}
  1029 + onGetDataInfo={this.handleGetSlaveData}
  1030 + onSubmit={this.handleValidateSave}
  1031 + onReturnForm={this.handleForm}
  1032 + onSearchUpDown={this.handleSearchUpDown}
  1033 + onCancel={this.handleCancel}
  1034 + onDataChange={this.handleTableChange}
  1035 + onBtnPrint={this.handleBtnPrint}
  1036 + onChange={this.handleMasterChange}
  1037 + onButtonClick={this.handleButtonClick}
  1038 + imgSrc={imgSrc}
  1039 + style={{ height: '100%' }}
  1040 + onTabsCallback={this.handleCallBack}
  1041 + onChangeMachine={this.onChangeMachine}
  1042 + onResetTableSearch={this.handleResetTableSearch}
  1043 + onTitleChange={this.handleTitleChange}
  1044 + onBtnEent={this.handleBtnEent}
  1045 + onExpand={this.handleOnExpand}
  1046 + onGanttChar={this.handleGanttChar}
  1047 + onCheckModel={this.handleCheckModel}
  1048 + onPartNameClick={this.handlePartNameClick}
  1049 + onCloseModel={this.handleCloseModel}
  1050 + onChangeTimerPro={this.handleChangeTimer}
  1051 + />
  1052 + );
  1053 + }
  1054 + };
  1055 +};
src/components/Common/CommonProductionPlanOutsideEvent.js 0 → 100644
  1 +/* eslint-disable prefer-destructuring,no-await-in-loop,semi,no-unused-vars */
  2 +/**
  3 + * Created by mar105 on 2019-01-08.
  4 + */
  5 +import React, { Component } from 'react';
  6 +import { message } from 'antd'; // Form, Modal, InputNumber
  7 +// import reactComponentDebounce from 'react-component-debounce';
  8 +import * as commonUtils from '../../utils/utils'; /* 通用方法 */
  9 +import * as commonBusiness from './commonBusiness'; /* 单据业务功能 */
  10 +import * as commonServices from '../../services/services'; /* 服务类 */
  11 +import commonConfig from '../../utils/config';
  12 +import * as commonFunc from './commonFunc'; /* 通用单据方法 */
  13 +
  14 +/*
  15 +const { confirm } = Modal;
  16 +const FormItem = Form.Item;
  17 +const InputNumberA = reactComponentDebounce(800)(InputNumber);
  18 +*/
  19 +
  20 +export default (ChildComponent) => {
  21 + return class extends Component {
  22 + constructor(props) {
  23 + super(props);
  24 + this.form = {}; /* 表单对象 */
  25 + }
  26 +
  27 + componentWillReceiveProps(nextProps) {
  28 + const {
  29 + app, formData, currentId, masterData, searchSolution, sGroupByList, teamSelectedRowKeys, teamData,
  30 + } = nextProps;
  31 + const { teamFilterCondition } = this.props;
  32 + let {
  33 + isReceive, teamConfig, slaveConfig, slaveInfoConfig,
  34 + } = nextProps;
  35 + const { currentPane } = app;
  36 + const { otherCondition } = currentPane;
  37 + if (formData.length > 0 && commonUtils.isEmptyObject(teamConfig) && commonUtils.isEmptyArr(searchSolution)) {
  38 + isReceive = false;
  39 + const sId = currentId !== undefined ? currentId : '';
  40 + const masterConfig = formData.filter(item => !item.bGrd && item.sTbName === 'eleteam')[0];
  41 +
  42 + teamConfig = formData.filter(item => item.sTbName === 'Sp_Manufacture_ProductionPlanInfo_WorkCenter2')[0];
  43 + slaveConfig = formData.filter(item => item.sTbName === 'Viw_OpsOutsideProcess')[0];
  44 + slaveInfoConfig = formData.filter(item => item.sTbName === 'Sp_Manufacture_ProductionPlanInfo' && item.sGrd === 'slaveInfo')[0];
  45 + const productionPlanConfig = formData.filter(item => item.sTbName === 'opsoutsideprocessslave')[0];
  46 +
  47 + const teamColumn = commonFunc.getHeaderConfig(teamConfig);
  48 + const slaveColumn = commonFunc.getHeaderConfig(slaveConfig);
  49 + let slaveInfoColumn = [];
  50 + if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
  51 + slaveInfoColumn = commonFunc.getHeaderConfig(slaveInfoConfig)
  52 + }
  53 + const productionPlanColumn = commonFunc.getHeaderConfig(productionPlanConfig);
  54 +
  55 + let currfilterCondition = [];
  56 + if (commonUtils.isNotEmptyObject(masterData) && !commonUtils.isEmpty(masterData.sSearchSolutionId) && commonUtils.isNotEmptyArr(searchSolution)) {
  57 + const iIndex = searchSolution.findIndex(item => item.sId === masterData.sSearchSolutionId);
  58 + if (iIndex > -1 && !commonUtils.isEmpty(searchSolution[iIndex].sCondition)) {
  59 + currfilterCondition = JSON.parse(searchSolution[iIndex].sCondition);
  60 + }
  61 + }
  62 + this.handleGetData('team', teamConfig, currfilterCondition, undefined, '', false, sGroupByList);
  63 + // this.handleGetData('slave', slaveConfig, [], undefined, '', false, undefined);
  64 + // this.handleGetData('slaveInfo', slaveInfoConfig, [], undefined, '', false, undefined);
  65 +
  66 + this.props.onSaveState({
  67 + masterConfig,
  68 + teamConfig,
  69 + teamColumn,
  70 + slaveConfig,
  71 + slaveColumn,
  72 + slaveInfoConfig,
  73 + slaveInfoColumn,
  74 + productionPlanConfig,
  75 + productionPlanColumn,
  76 + sId,
  77 + pageLoading: false,
  78 + enabled: true,
  79 + dragPermission: false,
  80 + dragAndDropSwitch: false,
  81 + isReceive,
  82 + masterData: {},
  83 + tableBtnEnabled: true,
  84 + // stateOption: objValue,
  85 + });
  86 + } else if (commonUtils.isEmptyStr(teamSelectedRowKeys) && commonUtils.isEmptyArr(teamFilterCondition) && commonUtils.isNotEmptyArr(teamData) && !isReceive) {
  87 + const iIndex = otherCondition.findIndex(item => item.bFilterName === 'sMachineId');
  88 + if (iIndex !== -1) {
  89 + const newIndex = teamData.findIndex(item => item.sMachineId === otherCondition[iIndex].bFilterValue);
  90 + if (newIndex === -1) {
  91 + this.handleCallBack({ ...teamData[0] });
  92 + } else {
  93 + this.handleCallBack({ ...teamData[newIndex] });
  94 + }
  95 + } else {
  96 + this.handleCallBack({ ...teamData[0] });
  97 + }
  98 + this.props.onSaveState({ isReceive: true });
  99 + } else if (commonUtils.isEmptyStr(teamSelectedRowKeys) && commonUtils.isEmptyArr(currentPane.filterCondition) && commonUtils.isEmptyArr(teamFilterCondition) && commonUtils.isNotEmptyArr(teamData) && !isReceive) {
  100 + this.handleGetData('slave', slaveConfig, [], undefined, '', false, undefined);
  101 + // this.handleGetData('slaveInfo', slaveInfoConfig, [], undefined, '', false, undefined);
  102 + this.props.onSaveState({ isReceive: true, teamSelectedRowKeys: teamData[0].sId });
  103 + }
  104 + }
  105 +
  106 + shouldComponentUpdate(nextProps) {
  107 + const {
  108 + slaveColumn,
  109 + } = nextProps;
  110 + return commonUtils.isNotEmptyArr(slaveColumn);
  111 + }
  112 +
  113 + componentDidUpdate(prevProps) {
  114 + const {
  115 + slaveSelectedRowKeys, moveEnabled, tableBtnEnabled,
  116 + } = prevProps;
  117 + if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys) && !moveEnabled && tableBtnEnabled) {
  118 + this.props.onSaveState({ moveEnabled: true });
  119 + } else if ((commonUtils.isEmptyArr(slaveSelectedRowKeys) && moveEnabled && tableBtnEnabled) || (moveEnabled && !tableBtnEnabled)) {
  120 + this.props.onSaveState({ moveEnabled: false });
  121 + }
  122 + }
  123 +
  124 + onChangeMachine = async () => {
  125 + const { sModelsId, masterData, slaveInfoSelectedRowKeys } = this.props;
  126 + const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
  127 + const value = {
  128 + sProName: 'Sp_Manufacture_ProductionPlanInfo_ChangeMachine',
  129 + paramsMap: {
  130 + bSplit: masterData.bSplit,
  131 + iSplitNum: masterData.iSplitNum,
  132 + sMachineId: masterData.sMachineId,
  133 + sTeamId: masterData.sTeamId,
  134 + tStartDate: masterData.tStartDate,
  135 + sProInParam: JSON.stringify({ params: { key: 'slaveInfo', value: { sId: slaveInfoSelectedRowKeys } } }),
  136 + },
  137 + };
  138 + const dataReturn = (await commonServices.postValueService(this.props.app.token, value, url)).data;
  139 + if (dataReturn.code === 1) {
  140 + /* 数据查询成功 */
  141 + this.handleRefresh();
  142 + this.props.onSaveState({ isChangeMachine: false, masterData: { ...masterData, sMachineId: '', sTeamId: '' } });
  143 + } else { /* 失败 */
  144 + this.props.getServiceError(dataReturn);
  145 + }
  146 + }
  147 +
  148 + /** 获取表数据 */
  149 + handleGetData = async (sName, slaveConfig, slaveFilterCondition, page, slaveOrderBy, clearSelectData, sGroupByListNew, nextProps, isWait) => {
  150 + const { app } = commonUtils.isEmpty(nextProps) ? this.props : nextProps;
  151 + const sGroupByList = sGroupByListNew !== undefined ? commonUtils.isEmptyArr(sGroupByListNew) ? null : sGroupByListNew : this.props.sGroupByList;
  152 + const conditonValues = app.currentPane.conditonValues;
  153 + const filterCondition = app.currentPane.filterCondition;
  154 + let bFilter = [];
  155 + if (!commonUtils.isEmptyArr(slaveFilterCondition)) {
  156 + slaveFilterCondition[0].bFilterName = slaveFilterCondition[0].bFilterName.replace('_pro', '');
  157 + bFilter.push(...slaveFilterCondition);
  158 + }
  159 + if (!commonUtils.isEmptyArr(filterCondition)) {
  160 + bFilter.push(...filterCondition);
  161 + }
  162 + const addState = {};
  163 + const pageNum = commonUtils.isEmpty(page) ? 1 : page;
  164 + addState.pageNum = pageNum;
  165 + addState.pageSize = ''; // commonConfig.pageSize;
  166 + if (sName === 'team' && commonUtils.isNotEmptyArr(filterCondition)) {
  167 + bFilter = [];
  168 + const addFilter = {};
  169 + addFilter.bFilterName = `${filterCondition[0].bFilterName}_pro`;
  170 + addFilter.bFilterCondition = '=';
  171 + addFilter.bFilterValue = filterCondition[0].bFilterValue;
  172 + bFilter.push(addFilter);
  173 + }
  174 + const returnData = await this.props.handleGetDataSet({
  175 + name: sName,
  176 + configData: slaveConfig,
  177 + condition: {
  178 + ...addState, bFilter, sFilterOrderBy: slaveOrderBy, sSqlCondition: conditonValues, sGroupList: sGroupByList,
  179 + },
  180 + flag: true,
  181 + clearSelectData,
  182 + isWait,
  183 + });
  184 + this.props.onSaveState({ Loading: false });
  185 + if (isWait) {
  186 + return { ...returnData };
  187 + }
  188 + };
  189 +
  190 + // 搜索 查询
  191 + handleGetSearchData = (config, filterCondition) => {
  192 + const {
  193 + teamConfig, sGroupByList, teamSelectedRowKeys,
  194 + } = this.props;
  195 + const iIndex = filterCondition.findIndex(item => item.bFilterName === 'sTeamId' && item.bFilterCondition === '=' && item.bFilterValue === teamSelectedRowKeys[0]);
  196 + const filter = [];
  197 + filterCondition.forEach((itme, i) => {
  198 + if (iIndex !== i) { filter.push(itme); }
  199 + });
  200 + this.handleGetData('team', teamConfig, filter, undefined, '', false, sGroupByList);
  201 + };
  202 +
  203 + handleGetSlaveData = (config, filterCondition) => {
  204 + const {
  205 + slaveConfig, slaveInfoConfig, teamData, teamSelectedRowKeys,
  206 + } = this.props;
  207 + const iIndex = filterCondition.findIndex(item => item.bFilterName === 'sTeamId' && item.bFilterCondition === '=' && item.bFilterValue === teamSelectedRowKeys[0]);
  208 + const filter = [];
  209 + filterCondition.forEach((itme, i) => {
  210 + if (iIndex !== i) { filter.push(itme); }
  211 + });
  212 +
  213 + const addFilter = {};
  214 + addFilter.bFilterName = 'sTeamId';
  215 + addFilter.bFilterCondition = '=';
  216 + addFilter.bFilterValue = teamData[0].sId;
  217 + filter.push(addFilter);
  218 +
  219 + this.handleGetData('slave', slaveConfig, filter, undefined, undefined);
  220 + // this.handleGetData('slaveInfo', slaveInfoConfig, filter, undefined, undefined);
  221 + };
  222 +
  223 + /** 主表控件是否全部显示 */
  224 + handleToggle = () => {
  225 + const { expand } = this.props;
  226 + this.props.onSaveState({ expand: !expand });
  227 + };
  228 +
  229 + /** 表单回带 */
  230 + handleForm = (form) => {
  231 + this.form = form;
  232 + };
  233 +
  234 + /** toolbar保存 */
  235 + handleSaveData = async (params) => {
  236 + const {
  237 + token, sModelsId,
  238 + } = this.props;
  239 + const returnData = await commonBusiness.saveData({ token, value: params, sModelsId });
  240 + if (commonUtils.isNotEmptyObject(returnData)) {
  241 + this.handleRefresh();
  242 + if (this.props.app.currentPane.refresh !== undefined) {
  243 + this.props.app.currentPane.refresh();
  244 + }
  245 + return true;
  246 + } else {
  247 + return false;
  248 + }
  249 + };
  250 +
  251 + /** 保存校验 */
  252 + handleValidateSave = () => {
  253 + this.form.validateFields((err) => {
  254 + /* 验证通过与不通过走不同的流程 */
  255 + if (err) { /* 验证失败 */
  256 + /* 直接渲染显示错误提示 */
  257 + for (const key of Object.keys(err)) {
  258 + message.error(err[key].errors[0].message);
  259 + }
  260 + } else { /* 验证成功 */
  261 + const {
  262 + slaveConfig, slaveData, slaveDelData, app, productionPlanConfig, productionPlanDelData, tableBtnEnabled, charGanttData, bGantt,
  263 + } = this.props;
  264 + const data = [];
  265 + if (commonUtils.isEmptyArr(slaveData)) {
  266 + message.error(commonFunc.showMessage(app.commonConst, 'slaveNotNull')); // 从表不能为空!
  267 + return;
  268 + } else {
  269 + /* 如果是甘特图视图,则进入甘特图视图保存逻辑 */
  270 + if (bGantt && commonUtils.isNotEmptyObject(charGanttData)) {
  271 + const data = [];
  272 + const addState = {}
  273 + addState.name = 'slave';
  274 + addState.sTable = 'MftProductionPlanSlave';
  275 + addState.column = charGanttData.data;
  276 + data.push(addState);
  277 + this.handleSaveData({ data, sClientType: '1' });
  278 + return;
  279 + }
  280 + const productionPlanData = [];
  281 + for (const item of slaveData) {
  282 + const {
  283 + sSlaveId, handleType, iOrder, tStartDate, sMemo, dAdjustHour,
  284 + } = item;
  285 + const sIds = sSlaveId.split('-');
  286 + sIds.forEach((newItem) => {
  287 + const addState = {};
  288 + addState.sId = newItem;
  289 + if (commonUtils.isEmpty(iOrder)) {
  290 + message.error('序号必填!');
  291 + return;
  292 + }
  293 + if (commonUtils.isEmpty(tStartDate)) {
  294 + message.error('时间必填!');
  295 + return;
  296 + }
  297 + addState.iOrder = iOrder;
  298 + /* 20210406 zhuzong要求排程保存时候 必传iOrder,tStartDate,sMemo,dAdjustHour 四个参数 */
  299 + addState.tStartDate = tStartDate;
  300 + if (commonUtils.isNotEmptyObject(sMemo)) {
  301 + addState.sMemo = sMemo;
  302 + }
  303 + if (dAdjustHour !== undefined) {
  304 + addState.dAdjustHour = dAdjustHour;
  305 + }
  306 + addState.handleType = handleType;
  307 + productionPlanData.push(addState);
  308 + });
  309 + }
  310 + data.push(commonBusiness.mergeData('productionPlan', productionPlanConfig.sTbName, productionPlanData, productionPlanDelData));
  311 + }
  312 + if (!commonBusiness.validateTable(slaveConfig, slaveData)) {
  313 + return;
  314 + }
  315 + // data.push(commonBusiness.mergeData('slave', 'MftProductionPlanSlave', slaveData, slaveDelData));
  316 + this.handleSaveData({ data, sClientType: '1' });
  317 + }
  318 + });
  319 + };
  320 +
  321 + /* 数据删除成功跳转到新路由即pane */
  322 + handleDelDataSuccess = (props) => {
  323 + const { app } = props;
  324 + let { panes, currentPane } = app;
  325 + /* 删除单据后退出当前路由后,标签panes变化后的集合 */
  326 + panes = panes.filter(pane => pane.key !== currentPane.key);
  327 + /* 跳转到panes集合的最后一个路由,因为panes集合一定含有主页路由所以panes的集合大于等于1 */
  328 + currentPane = panes[panes.length - 1];
  329 + this.props.onRemovePane(panes, currentPane);
  330 + };
  331 +
  332 + /** 表格数据更改 */
  333 + // name 不写完整的state名称作用为了要用到total // (name, changeValue, sId, dropDownData)
  334 + handleTableChange = async (name, sFieldName, changeValue, sId, dropDownData) => {
  335 + const { sModelsId } = this.props;
  336 + this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, false);
  337 + if (name === 'slave') {
  338 + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sTeamId', []);
  339 + if (sFieldName === 'iOrder') {
  340 + /* 修改汇总表数据后,slaveInfo表iOrder同步更改 */
  341 + const { slaveInfoData, slaveData } = this.props;
  342 + const iIndex = slaveData.findIndex(item => item.sId === sId);
  343 + if (iIndex > -1) {
  344 + const tableDataRow = slaveData[iIndex];
  345 + let childrenData = [];
  346 + childrenData = tableDataRow.childrenData;
  347 + if (commonUtils.isNotEmptyArr(childrenData)) {
  348 + childrenData.forEach((child) => {
  349 + const index = slaveInfoData.findIndex(item => item.sId === child.sId);
  350 + const addState = {};
  351 + addState.handleType = 'update';
  352 + addState.iOrder = tableDataRow.iOrder;
  353 + if (index > -1) {
  354 + slaveInfoData[index] = { ...slaveInfoData[index], ...addState }
  355 + }
  356 + });
  357 + this.props.onSaveState({ slaveData, slaveInfoData });
  358 + }
  359 + }
  360 + }
  361 + }
  362 + };
  363 + // 打印
  364 + handleBtnPrint = (sActiveId, checked) => {
  365 + const {
  366 + app, sModelsId, slaveConfig, slaveSelectedRowKeys, slaveFilterCondition, reportData,
  367 + } = this.props;
  368 + const { token } = app;
  369 + let slaveFilterConditionNew = slaveFilterCondition === undefined ? [] : [...slaveFilterCondition];
  370 +
  371 + let sids = '';
  372 + slaveSelectedRowKeys.forEach((item, i) => {
  373 + if (i === slaveSelectedRowKeys.length - 1) {
  374 + sids = `${sids}${item}`;
  375 + } else {
  376 + sids = `${sids}${item},`;
  377 + }
  378 + });
  379 + if (sids !== '') {
  380 + slaveFilterConditionNew = [];
  381 + const sidsNew = commonUtils.isNotEmptyObject(sids) ? sids.replace(/-/g, ',') : '';
  382 + const addFilter = {};
  383 + addFilter.bFilterName = 'sId';
  384 + addFilter.bFilterCondition = 'in';
  385 + addFilter.bFilterValue = sidsNew;
  386 + slaveFilterConditionNew.push(addFilter);
  387 + }
  388 +
  389 + const queryFilter = {};
  390 + queryFilter[slaveConfig.sId] = { bFilter: slaveFilterConditionNew };
  391 +
  392 + const queryFilterJson = encodeURIComponent(JSON.stringify(queryFilter));
  393 + /* 拿到打印报表名称 */
  394 + let printReportName = 'report';
  395 + if (commonUtils.isNotEmptyArr(reportData)) {
  396 + const iIndex = reportData.findIndex(item => item.sId === sActiveId);
  397 + if (iIndex > -1) {
  398 + printReportName = reportData[iIndex].sReportName;
  399 + }
  400 + }
  401 + const urlPrint = `${commonConfig.file_host}printReport/printPdf/${sActiveId}/${printReportName}.pdf?${checked ? 'fileType=.xlsx&' : ''}queryFilter=${queryFilterJson}&sModelsId=${sModelsId}&sMaintableId=${slaveConfig.sId}&token=${encodeURIComponent(token)}`;
  402 + window.open(urlPrint);
  403 + };
  404 + /* 导出Excel */
  405 + handleOut = () => {
  406 + const {
  407 + slaveConfig, sFilterOrderBy, slaveSelectedRowKeys, slaveFilterCondition, sGroupByList,
  408 + } = this.props;
  409 +
  410 + const newfilterCondition = slaveFilterCondition === undefined ? [] : slaveFilterCondition;
  411 +
  412 + let sids = '';
  413 + slaveSelectedRowKeys.forEach((item, i) => {
  414 + if (i === slaveSelectedRowKeys.length - 1) {
  415 + sids = `${sids}${item}`;
  416 + } else {
  417 + sids = `${sids}${item},`;
  418 + }
  419 + });
  420 + // const addFilter = {};
  421 + // addFilter.bFilterName = 'sId';
  422 + // addFilter.bFilterCondition = 'in';
  423 + // addFilter.bFilterValue = sids;
  424 + // newfilterCondition.push(addFilter);
  425 +
  426 + let url = `${commonConfig.server_host}excel/export/${slaveConfig.sId}?sModelsId=${slaveConfig.sParentId}&token=${this.props.app.token}`;
  427 + if (commonUtils.isNotEmptyArr(newfilterCondition)) {
  428 + url = `${url}&bFilter=${encodeURIComponent(JSON.stringify(newfilterCondition))}`;
  429 + }
  430 + if (sFilterOrderBy !== undefined && sFilterOrderBy !== '' && Object.keys(sFilterOrderBy).length > 0) {
  431 + url = `${url}&sFilterOrderBy=${encodeURIComponent(JSON.stringify(sFilterOrderBy))}`;
  432 + }
  433 + if (commonUtils.isNotEmptyArr(sGroupByList)) {
  434 + url = `${url}&sGroupList=${encodeURIComponent(JSON.stringify(sGroupByList))}`;
  435 + }
  436 + window.open(url);
  437 + };
  438 + handleConfirmDataChange = (value) => {
  439 + const {
  440 + masterData,
  441 + } = this.props;
  442 + masterData.dOutsideQty = value;
  443 +
  444 + this.props.onSaveState({ masterData });
  445 + };
  446 + // 按钮操作
  447 + handleButtonClick = (name) => {
  448 + if (name === 'BtnRefresh') {
  449 + this.handleRefresh();
  450 + } else if (name === 'BtnOut') {
  451 + this.handleOut();
  452 + } else if (name === 'BtnDesignFunction') {
  453 + this.handleDesignFunction();
  454 + }
  455 + };
  456 + handleDesignFunction = () => {
  457 + this.props.onSaveState({ visibleStatement: true });
  458 + };
  459 + handleUpdated = async (params) => {
  460 + const { app, sModelsId } = this.props;
  461 + const { token } = app;
  462 +
  463 + const url = `${commonConfig.server_host}productionPlan/getProcessOperation?sModelsId=${sModelsId}`;
  464 + const { data } = await commonServices.postValueService(token, params, url);
  465 +
  466 + if (data.code === 1) {
  467 + /* 数据查询成功 */
  468 + return true;
  469 + } else { /* 失败 */
  470 + this.props.getServiceError(data);
  471 + return false;
  472 + }
  473 + };
  474 +
  475 + handleMasterChange = (name, sFieldName, changeValue, sId, dropDownData, isWait) => {
  476 + const { sModelsId } = this.props;
  477 + if (sFieldName === 'sMachineId') {
  478 + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sTeamId', []);
  479 + }
  480 + if (isWait) {
  481 + return this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, isWait);
  482 + } else {
  483 + this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, isWait);
  484 + }
  485 + };
  486 +
  487 + handleCalculate = () => {
  488 + const { sModelsId, slaveData } = this.props;
  489 + const materialsInfo = [];
  490 + const slaveDataNew = [];
  491 + slaveData.forEach(async (item) => {
  492 + const index = materialsInfo.findIndex(obj => obj.sMaterialsId === item.sMaterialsId);
  493 + item.bMaterialAdequate = 0;
  494 + if (commonUtils.isNotEmptyStr(item.sMaterialsId) && index === -1) {
  495 + const url = `${commonConfig.server_host}eleMaterialsStock/getEleMaterialsStoreCurrQty?sModelsId=${sModelsId}`;
  496 + const body = {
  497 + sMaterialsId: item.sMaterialsId, /* 查询条件 */
  498 + };
  499 + const dataReturn = (await commonServices.postValueService(this.props.app.token, body, url)).data;
  500 + if (dataReturn.code === 1) {
  501 + if (commonUtils.isNotEmptyArr(dataReturn.dataset.rows[0])) {
  502 + const materials = dataReturn.dataset.rows[0];
  503 + if (commonUtils.isNotEmptyNumber(materials.dAuxiliaryQty) && commonUtils.isNotEmptyNumber(item.dPrintQty) && materials.dAuxiliaryQty > item.dPrintQty) {
  504 + item.bMaterialAdequate = 1;
  505 + materialsInfo[index].dAuxiliaryQty = materialsInfo[index].sMaterialsId - item.dPrintQty;
  506 + }
  507 + }
  508 + }
  509 + } else if (commonUtils.isNotEmptyStr(item.sMaterialsId) && index === -1) {
  510 + if (commonUtils.isNotEmptyNumber(materialsInfo[index].sMaterialsId) && commonUtils.isNotEmptyNumber(item.dPrintQty) && materialsInfo[index].sMaterialsId > item.dPrintQty) {
  511 + item.bMaterialAdequate = 1;
  512 + materialsInfo[index].dAuxiliaryQty = materialsInfo[index].sMaterialsId - item.dPrintQty;
  513 + }
  514 + }
  515 + slaveDataNew.push(item);
  516 + });
  517 + this.props.onSaveState({ slaveData: slaveDataNew });
  518 + };
  519 +
  520 + handleTitleChange = async (name, slavePagination, filters, sorter, extra) => {
  521 + // const tableBtnEnabled = commonUtils.isNotEmptyObject(filters) && commonUtils.isEmptyObject(sorter);
  522 + const addState = {}; // 搜索时不能使用排序保存,否则数据会出不来。
  523 + if (commonUtils.isNotEmptyObject(sorter)) {
  524 + const slaveData = [];
  525 + extra.currentDataSource.forEach((item, iIndex) => {
  526 + const slaveTableRow = { ...item, iOrder: iIndex + 1, handleType: 'update' };
  527 + slaveData.push(slaveTableRow);
  528 + });
  529 + if (slaveData.length === this.props.slaveData.length) {
  530 + addState.slaveData = slaveData;
  531 + }
  532 + }
  533 + this.props.onSaveState({
  534 + ...addState, slavePagination, pageLoading: false,
  535 + });
  536 + // this.props.onSaveState({
  537 + // tableBtnEnabled: false, pageLoading: true,
  538 + // });
  539 + // const { [`${name}Config`]: tableConfig, [`${name}FilterCondition`]: tableFilterCondition, sGroupByList } = this.props;
  540 + // const sort = sorter.order === 'ascend' ? 'asc' : 'desc';
  541 + // const slaveOrderBy = Object.keys(sorter).length > 0 ? { [sorter.columnKey]: sort } : ''; // 后端未支持空对象, 先用空表示
  542 + // const addState = await this.handleGetData(name, tableConfig, tableFilterCondition, undefined, slaveOrderBy, '', sGroupByList, this.props, true);
  543 + // if (addState === undefined) return;
  544 + // const { [`${name}Data`]: tempData } = addState;
  545 + // if (commonUtils.isNotEmptyArr(addState[`${name}Data`])) {
  546 + // addState[`${name}Data`].forEach((item, iIndex) => {
  547 + // addState[`${name}Data`][iIndex] = { ...item, iOrder: iIndex + 1, handleType: 'update' };
  548 + // });
  549 + // }
  550 + // this.props.onSaveState({ ...addState });
  551 + // setTimeout(() => {
  552 + // /* 刷新commList页面数据 */
  553 + // this.props.onSaveState({ pageLoading: false });
  554 + // }, 3600);
  555 + };
  556 + /** 处理选择行发生改变 */
  557 + handleCallBack = (child) => {
  558 + const {
  559 + slaveConfig, slaveInfoConfig, teamFilterCondition, bGantt,
  560 + } = this.props;
  561 + const filter = [];
  562 + const addFilter = {};
  563 + addFilter.bFilterName = 'sWorkCenterId';
  564 + addFilter.bFilterCondition = '=';
  565 + addFilter.bFilterValue = child.sMachineId;
  566 + filter.push(addFilter);
  567 + // if (child.sType === '1') {
  568 + // addFilter.bFilterName = 'sProcessId';
  569 + // addFilter.bFilterCondition = '=';
  570 + // addFilter.bFilterValue = child.sMachineId;
  571 + // filter.push(addFilter);
  572 + // addFilter = {};
  573 + // addFilter.bFilterName = 'sState';
  574 + // addFilter.bFilterCondition = '=';
  575 + // addFilter.bFilterValue = '0';
  576 + // filter.push(addFilter);
  577 + // } else if (child.sType === '2') {
  578 + // addFilter.bFilterName = 'sMachineId';
  579 + // addFilter.bFilterCondition = '=';
  580 + // addFilter.bFilterValue = child.sMachineId;
  581 + // filter.push(addFilter);
  582 + // addFilter = {};
  583 + // addFilter.bFilterName = 'date_format(tStartDate, \'%y-%m-%d\')';
  584 + // addFilter.bFilterCondition = '=';
  585 + // addFilter.bFilterValue = child.tStartDate;
  586 + // filter.push(addFilter);
  587 + // }
  588 + if (commonUtils.isNotEmptyArr(teamFilterCondition)) {
  589 + filter.push(...teamFilterCondition);
  590 + }
  591 + this.handleGetData('slave', slaveConfig, filter, undefined, '', false, undefined);
  592 + /* 甘特图视图下 点击卡片刷新 */
  593 + if (bGantt) {
  594 + this.handleGanttChar('', filter)
  595 + }
  596 + // this.handleGetData('slaveInfo', slaveInfoConfig, filter, undefined, '', false, undefined);
  597 + const rowKeys = [];
  598 + rowKeys.push(child.sId);
  599 + this.props.onSaveState({
  600 + teamSelectedRowKeys: rowKeys,
  601 + });
  602 + };
  603 +
  604 + /* 获取甘特图数据 */
  605 + handleGanttChar = async (ganttChart, slaveFilterCondition) => {
  606 + const {
  607 + token, sModelsId, formRoute,
  608 + } = this.props;
  609 + const char = {};
  610 + if (commonUtils.isNotEmptyObject(ganttChart)) {
  611 + char.sProcedureName = ganttChart.sProcedureName;
  612 + char.paramsMap = ganttChart.paramsMap;
  613 + } else {
  614 + char.sProcedureName = 'Sp_Process_CommonGtChar';
  615 + char.paramsMap = {
  616 + };
  617 + }
  618 + let charGanttData = {};
  619 + const value = {
  620 + sProName: char.sProcedureName,
  621 + paramsMap: char.prodParamsMap,
  622 + bFilter: slaveFilterCondition,
  623 + };
  624 + const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}&sName=${formRoute}`;
  625 + const { data: returnData } = await commonServices.postValueService(token, value, url);
  626 + if (returnData.code === 1) {
  627 + const { dataset } = returnData;
  628 + if (commonUtils.isNotEmptyObject(dataset)) {
  629 + const outData = returnData.dataset.rows[0].dataSet.outData[0];
  630 + if (outData.sCode === -1) {
  631 + message.error(outData.sReturn);
  632 + } else {
  633 + charGanttData = commonUtils.isEmpty(outData.sReturn) ? [] : JSON.parse(outData.sReturn);
  634 + this.props.onSaveState({ charGanttData });
  635 + }
  636 + }
  637 + } else {
  638 + message.error(returnData.msg);
  639 + }
  640 + };
  641 + /*
  642 + handleRefresh = async () => {
  643 + const {
  644 + clearArray, slaveConfig, slaveInfoConfig, teamFilterCondition, slaveFilterCondition,
  645 + } = this.props;
  646 + this.props.onSaveState({
  647 + clearArray: [], searchText: '', teamSelectedData: [], slaveSelectedRowKeys: [], slaveSelectedData: [], slaveInfoSelectedRowKeys: [], slaveInfoSelectedData: [], tableBtnEnabled: true,
  648 + }); // teamSelectedRowKeys: [],
  649 + this.handleGetData('slave', slaveConfig, slaveFilterCondition, undefined, '', false, undefined);
  650 + this.handleGetData('slaveInfo', slaveInfoConfig, slaveFilterCondition, undefined, '', false, undefined);
  651 +
  652 + if (!commonUtils.isEmpty(clearArray)) {
  653 + for (const item of clearArray) {
  654 + const { confirm, clearFilters } = item;
  655 + confirm();
  656 + clearFilters();
  657 + }
  658 + }
  659 + this.props.onSaveState({
  660 + loading: false,
  661 + });
  662 + }
  663 +*/
  664 + handleRefresh = async () => {
  665 + const {
  666 + clearArray, teamConfig, teamFilterCondition, slaveFilterCondition, teamSelectedRowKeys,
  667 + } = this.props;
  668 + let { expKeys } = this.props;
  669 + const addState = await this.handleGetData('team', teamConfig, teamFilterCondition, undefined, '', false, undefined, this.props, true);
  670 + if (addState === undefined) return;
  671 + this.props.onSaveState({
  672 + ...addState,
  673 + clearArray: [],
  674 + searchText: '',
  675 + teamSelectedData: [],
  676 + slaveSelectedRowKeys: [],
  677 + slaveSelectedData: [],
  678 + slaveInfoData: [], /* 刷新后清除slaveInfoData */
  679 + slaveInfoSelectedRowKeys: [],
  680 + slaveInfoSelectedData: [],
  681 + tableBtnEnabled: true,
  682 + machineEnabled: false,
  683 + sortedInfo: {},
  684 + });
  685 + const { teamData } = addState;
  686 + const newIndex = teamData.findIndex(item => item.sId === teamSelectedRowKeys[0]);
  687 + if (newIndex === -1) {
  688 + this.handleCallBack({ ...teamData[0] });
  689 + } else {
  690 + this.handleCallBack({ ...teamData[newIndex] });
  691 + }
  692 +
  693 + if (!commonUtils.isEmpty(clearArray)) {
  694 + for (const item of clearArray) {
  695 + const { confirm, clearFilters } = item;
  696 + confirm();
  697 + clearFilters();
  698 + }
  699 + }
  700 + /* 刷新后关闭所有expKeys */
  701 + expKeys = [];
  702 + /* 刷新后清除slaveInfoData */
  703 + this.props.onSaveState({
  704 + loading: false, expKeys,
  705 + });
  706 + }
  707 +
  708 + handleResetTableSearch = () => {
  709 + this.props.onSaveState({ clearArray: [] });
  710 + this.handleRefresh();
  711 + }
  712 + // 进行存储过程按钮存储过程参数解析拼接 根据存储过程按钮参数配置进行解析,配置是json格式 {"sproName":"cal_sss","inMap":"master.sSlaveId,slave.sId"}
  713 + handleBtnEent = (btnConfig, btnName, sValue) => {
  714 + const { masterData } = this.props;
  715 + const sButtonParam = btnConfig.sButtonParam;
  716 + const btn = JSON.parse(sButtonParam);
  717 + const sProName = btn.sproName;
  718 + const inParams = [];
  719 + const inMap = btn.inMap;
  720 + const inlist = inMap.split(',');
  721 +
  722 + const masterArr = [];
  723 + const slaveArr = [];
  724 + const slaveInfoArr = [];
  725 + const controlArr = [];
  726 + const materialsArr = [];
  727 + const processArr = [];
  728 +
  729 + if (inlist.length > 0) {
  730 + inlist.forEach((item) => {
  731 + const itemArr = item.split('.');
  732 + if (itemArr.length > 0) {
  733 + const sname = itemArr[0];
  734 + const stype = itemArr[1];
  735 + if (commonUtils.isNotEmptyStr(sname) && sname === 'master') {
  736 + masterArr.push(stype);
  737 + }
  738 + if (commonUtils.isNotEmptyStr(sname) && sname === 'slave') {
  739 + slaveArr.push(stype);
  740 + }
  741 + if (commonUtils.isNotEmptyStr(sname) && sname === 'slaveInfo') {
  742 + slaveInfoArr.push(stype);
  743 + }
  744 + if (commonUtils.isNotEmptyStr(sname) && sname === 'control') {
  745 + controlArr.push(stype);
  746 + }
  747 + if (commonUtils.isNotEmptyStr(sname) && sname === 'materials') {
  748 + materialsArr.push(stype);
  749 + }
  750 + if (commonUtils.isNotEmptyStr(sname) && sname === 'process') {
  751 + processArr.push(stype);
  752 + }
  753 + }
  754 + });
  755 +
  756 + if (commonUtils.isNotEmptyArr(masterArr) && commonUtils.isNotEmptyObject(masterData)) {
  757 + const addState = {};
  758 + addState.key = 'master';
  759 + const val = [];
  760 + const currVal = {};
  761 + masterArr.forEach((filed) => {
  762 + currVal[`${filed}`] = masterData[`${filed}`];
  763 + });
  764 + val.push(currVal);
  765 + addState.value = val;
  766 + inParams.push({ ...addState });
  767 + }
  768 + if (commonUtils.isNotEmptyArr(slaveArr)) {
  769 + const addState = this.handleProParams('slave', slaveArr);
  770 + if (commonUtils.isNotEmptyObject(addState)) {
  771 + inParams.push({ ...addState });
  772 + }
  773 + }
  774 + if (commonUtils.isNotEmptyArr(slaveInfoArr)) {
  775 + const addState = this.handleProParams('slaveInfo', slaveInfoArr);
  776 + if (commonUtils.isNotEmptyObject(addState)) {
  777 + inParams.push({ ...addState });
  778 + }
  779 + }
  780 + if (commonUtils.isNotEmptyArr(controlArr)) {
  781 + const addState = this.handleProParams('control', controlArr);
  782 + if (commonUtils.isNotEmptyObject(addState)) {
  783 + inParams.push({ ...addState });
  784 + }
  785 + }
  786 + if (commonUtils.isNotEmptyArr(materialsArr)) {
  787 + const addState = this.handleProParams('materials', materialsArr);
  788 + if (commonUtils.isNotEmptyObject(addState)) {
  789 + inParams.push({ ...addState });
  790 + }
  791 + }
  792 + if (commonUtils.isNotEmptyArr(processArr)) {
  793 + const addState = this.handleProParams('process', processArr);
  794 + if (commonUtils.isNotEmptyObject(addState)) {
  795 + inParams.push({ ...addState });
  796 + }
  797 + }
  798 + }
  799 +
  800 + this.handleProcedureCall(btnConfig, sProName, JSON.stringify({ params: inParams, changeValue: sValue }));
  801 + };
  802 + // 根据配置解析拼接具体参数
  803 + handleProParams = (sKey, arr) => {
  804 + const { [`${sKey}Data`]: tableData, [`${sKey}SelectedRowKeys`]: selectedRowKeys } = this.props;
  805 + const keyData = tableData.filter(item => selectedRowKeys.includes(item.sId) || selectedRowKeys.includes(item.sSlaveId));
  806 + if (commonUtils.isNotEmptyArr(keyData)) {
  807 + const addState = {};
  808 + addState.key = sKey;
  809 + const val = [];
  810 + keyData.forEach((currData) => {
  811 + const currVal = {};
  812 + arr.forEach((filed) => {
  813 + currVal[`${filed}`] = currData[`${filed}`];
  814 + });
  815 + val.push(currVal);
  816 + });
  817 + addState.value = val;
  818 + return addState;
  819 + } else {
  820 + return undefined;
  821 + }
  822 + };
  823 + // 存储过程按钮调用存储过程
  824 + handleProcedureCall = async (btnConfig, proName, proInParam, other) => {
  825 + const { app, sModelsId, sCurrMemoProps } = this.props;
  826 + const value = { sProName: proName, sProInParam: proInParam };
  827 + if (other?.iFlag === 1) {
  828 + value.iFlag = 1;
  829 + }
  830 + const url = `${commonConfig.server_host}procedureCall/doGenericProcedureCall?sModelsId=${sModelsId}`;
  831 + const returnData = (await commonServices.postValueService(app.token, value, url)).data;
  832 + /**
  833 + * 修改日期:2021-03-26
  834 + * 修改人:吕杰
  835 + * 区域:以下 2 行
  836 + * BUG:
  837 + * 说明:执行完接口调用后关闭弹窗
  838 + * 原代码:
  839 + */
  840 + sCurrMemoProps.bVisibleMemo = false;
  841 + this.props.onSaveState({ loading: false, sCurrMemoProps });
  842 + if (returnData.code === 1) {
  843 + message.success(returnData.msg);
  844 + this.handleButtonClick('BtnRefresh');
  845 + } else {
  846 + this.props.getServiceError({ ...returnData, fn: () => this.handleProcedureCall(btnConfig, proName, proInParam, { iFlag: 1 }) });
  847 + }
  848 + }
  849 + /* 点击展开图标时,调用接口获取嵌套字表数据 */
  850 + handleOnExpand = async (expanded, record) => {
  851 + const { sModelsId, expKeys } = this.props;
  852 + let { slaveInfoData } = this.props;
  853 + const { sSlaveId } = record;
  854 + /* 添加移除展开的sId */
  855 + let newExp = commonUtils.isNotEmptyArr(expKeys) ? expKeys : [];
  856 + if (expanded) {
  857 + if (commonUtils.isNotEmptyObject(sSlaveId)) {
  858 + newExp.push(record.sSlaveId);
  859 + }
  860 + } else {
  861 + newExp = newExp.filter(item => item !== record.sSlaveId);
  862 + }
  863 + this.props.onSaveState({ expKeys: newExp });
  864 + let childrenData = [];
  865 + if (commonUtils.isNotEmptyArr(slaveInfoData) && commonUtils.isNotEmptyObject(sSlaveId)) {
  866 + childrenData = slaveInfoData.filter(item => sSlaveId.split('-').includes(item.sId));
  867 + }
  868 + if (expanded && commonUtils.isEmptyArr(childrenData)) {
  869 + if (commonUtils.isNotEmptyObject(sSlaveId)) {
  870 + const planLoadingSate = {};
  871 + planLoadingSate.sId = sSlaveId;
  872 + planLoadingSate.planLoading = true;
  873 + this.props.onSaveState({ planLoadingSate });
  874 + const { token } = this.props;
  875 + const url = `${commonConfig.server_host}workOrderPlan/getProductionPlanInfo?sModelsId=${sModelsId}`;
  876 + const value = { sSlaveId };
  877 + const dataReturn = (await commonServices.postValueService(token, value, url)).data;
  878 + if (dataReturn.code === 1) {
  879 + const returnData = dataReturn.dataset.rows;
  880 + if (commonUtils.isNotEmptyArr(returnData)) {
  881 + childrenData = returnData;
  882 + if (commonUtils.isEmptyArr(slaveInfoData)) {
  883 + slaveInfoData = [];
  884 + }
  885 + childrenData.forEach((child) => {
  886 + // const iIndex = slaveInfoData.findIndex(item => item.sId === child.sId);
  887 + // if (iIndex === -1) {
  888 + // slaveInfoData.push(child);
  889 + // }
  890 + slaveInfoData.push(child);
  891 + });
  892 + }
  893 + planLoadingSate.planLoading = false;
  894 + this.props.onSaveState({
  895 + planLoadingSate, slaveInfoData,
  896 + });
  897 + } else {
  898 + this.props.getServiceError(dataReturn);
  899 + planLoadingSate.planLoading = false;
  900 + this.props.onSaveState({ planLoadingSate });
  901 + }
  902 + }
  903 + }
  904 + }
  905 + render() {
  906 + const { masterData } = this.props;
  907 + const imgSrc = commonBusiness.handleAddIcon(masterData);
  908 + return (
  909 + <ChildComponent
  910 + {...this.props}
  911 + {...this.state}
  912 + onToggle={this.handleToggle}
  913 + onSaveData={this.handleSaveData}
  914 + onGetData={this.handleGetSearchData}
  915 + onGetDataInfo={this.handleGetSlaveData}
  916 + onSubmit={this.handleValidateSave}
  917 + onReturnForm={this.handleForm}
  918 + onSearchUpDown={this.handleSearchUpDown}
  919 + onCancel={this.handleCancel}
  920 + onDataChange={this.handleTableChange}
  921 + onBtnPrint={this.handleBtnPrint}
  922 + onChange={this.handleMasterChange}
  923 + onButtonClick={this.handleButtonClick}
  924 + imgSrc={imgSrc}
  925 + style={{ height: '100%' }}
  926 + onTabsCallback={this.handleCallBack}
  927 + onChangeMachine={this.onChangeMachine}
  928 + onResetTableSearch={this.handleResetTableSearch}
  929 + onTitleChange={this.handleTitleChange}
  930 + onBtnEent={this.handleBtnEent}
  931 + onExpand={this.handleOnExpand}
  932 + onGanttChar={this.handleGanttChar}
  933 + />
  934 + );
  935 + }
  936 + };
  937 +};