Commit 1179656cddcb199d2b08324214e011bb8c72cb81

Authored by 陈鑫涛
1 parent 307d638d

移动端

Showing 82 changed files with 21724 additions and 7 deletions

Too many changes to show.

To preserve performance only 14 of 82 files are displayed.

.umirc.ts
... ... @@ -18,6 +18,15 @@ export default defineConfig({
18 18 component: "@/routes/indexPage",
19 19 routes: [{ path: "*" }],
20 20 },
  21 + {
  22 + path: "/loginMobile",
  23 + component: "@/routes/mobile/login/LoginMobile",
  24 + },
  25 + {
  26 + path: '/indexMobile',
  27 + component:'@/routes/mobile/IndexMobile',
  28 + routes: [{ path: "*" }],
  29 + },
21 30 ],
22 31  
23 32 npmClient: "pnpm",
... ...
package.json
... ... @@ -17,7 +17,8 @@
17 17 "@js-preview/excel": "^1.7.14",
18 18 "@js-preview/pdf": "^2.0.10",
19 19 "antd": "^5.24.3",
20   - "antd-mobile": "2.3.4",
  20 + "antd-mobile": "5.37.1",
  21 + "antd-mobile-v2": "2.3.4",
21 22 "antd-v4": "npm:antd@4.24.16",
22 23 "braft-editor": "^2.3.9",
23 24 "classnames": "^2.5.1",
... ...
src/components/Common/CommonListSelectProductMaterial.js
... ... @@ -15,7 +15,7 @@ import StaticEditTable from './CommonTable';/* 可编辑表格 */
15 15 import CommonBase from './CommonBase';/* 获取配置及数据 */
16 16 import * as commonBusiness from './commonBusiness';/* 单据业务功能 */
17 17 import SearchComponent from './SearchComponent';/* 搜索组件 */
18   -// import * as commonConfig from '../../utils/config';
  18 +// import commonConfig from '../../utils/config';
19 19 import config from '../../utils/config';
20 20 import * as commonUtils from '../../utils/utils';
21 21 import Eject from '../../assets/eject.svg';
... ...
src/components/Common/PrintPdf/PreviewPdf.js
... ... @@ -3,7 +3,7 @@
3 3 import React from 'react';
4 4 import { InputItem, Icon } from 'antd-mobile';
5 5 import { Document, Page, pdfjs } from 'react-pdf';
6   -import 'antd-mobile/dist/antd-mobile.css';
  6 +import 'antd-mobile-v2/dist/antd-mobile.css';
7 7 import pdfstyles from './printpdf.less';
8 8 import * as commonUtils from '../../../utils/utils';
9 9  
... ...
src/components/PrintPdf/PreviewPdf.js
... ... @@ -3,7 +3,7 @@
3 3 import React from 'react';
4 4 import { InputItem, Icon } from 'antd-mobile';
5 5 import { Document, Page, pdfjs } from 'react-pdf';
6   -import 'antd-mobile/dist/antd-mobile.css';
  6 +import 'antd-mobile-v2/dist/antd-mobile.css';
7 7 import * as commonUtils from '@/utils/utils';
8 8 import pdfstyles from './printpdf.less';
9 9  
... ...
src/components/productionSchedule/productionPlanChangeMacheInfo.js
... ... @@ -9,7 +9,7 @@ import StaticEditTable from './CommonTable';/* 可编辑表格 */
9 9 import CommonBase from './CommonBase';/* 获取配置及数据 */
10 10 import * as commonBusiness from './commonBusiness';/* 单据业务功能 */
11 11 import SearchComponent from './SearchComponent';/* 搜索组件 */
12   -import * as commonConfig from '../../utils/config';
  12 +import commonConfig from '../../utils/config';
13 13  
14 14 const { Content } = Layout;
15 15  
... ...
src/components/productionScheduleTree/productionPlanChangeMacheInfo.js
... ... @@ -9,7 +9,7 @@ import StaticEditTable from './CommonTable';/* 可编辑表格 */
9 9 import CommonBase from './CommonBase';/* 获取配置及数据 */
10 10 import * as commonBusiness from './commonBusiness';/* 单据业务功能 */
11 11 import SearchComponent from './SearchComponent';/* 搜索组件 */
12   -import * as commonConfig from '../../utils/config';
  12 +import commonConfig from '../../utils/config';
13 13  
14 14 const { Content } = Layout;
15 15  
... ...
src/components/productionScheduleTree/productionScheduleTreeBack.js
... ... @@ -34,7 +34,7 @@ import Reset from '@/assets/reset.svg';
34 34 import DisableReset from '@/assets/disablereset.svg';
35 35 import * as commonUtils from '@/utils/utils';
36 36 import ShowType from '@/components/Common/CommonComponent';
37   -import * as commonConfig from '@/utils/config';
  37 +import commonConfig from '@/utils/config';
38 38 import AntdDraggableModal from '@/components/Common/AntdDraggableModal';
39 39 import Gantt from '@/components/Charts/Gantt';
40 40 import * as commonServices from '@/services/services';
... ...
src/mobile/common/BarCodeUtil.js 0 → 100644
  1 +
  2 +
  3 +class BarCodeUtil {
  4 + static barcode = null;
  5 +
  6 + /**
  7 + * @private
  8 + */
  9 + static hasLight = false;
  10 +
  11 +
  12 + /**
  13 + * 停止扫码
  14 + */
  15 + static stopScan() {
  16 + if (this.barcode !== null) {
  17 + this.barcode.close();
  18 + }
  19 + }
  20 +
  21 + /**
  22 + * 切换闪光灯
  23 + * @return {boolean} 切换后闪光灯是否开启
  24 + */
  25 + static switchLight() {
  26 + if (this.barcode !== null) {
  27 + this.hasLight = !this.hasLight;
  28 + this.barcode.setFlash(this.hasLight);
  29 + }
  30 + return this.hasLight;
  31 + }
  32 +
  33 + static typeToString(type) {
  34 + const { plus } = window;
  35 + // eslint-disable-next-line guard-for-in
  36 + for (const key in plus.barcode) {
  37 + const value = plus.barcode[key];
  38 + if (type === value) {
  39 + return key;
  40 + }
  41 + }
  42 + return '未知';
  43 + }
  44 +
  45 + /**
  46 + * 开始扫码
  47 + * @param { (type, code)=>void } successHandler 扫码成功的处理方法
  48 + */
  49 + static startScan(successHandler) {
  50 + this.stopScan();
  51 + let view = null;
  52 + const { plus } = window;
  53 + const height = plus.screen.resolutionHeight - plus.navigator.getStatusbarHeight();
  54 + this.barcode = plus.barcode.create(
  55 + 'barcode',
  56 + [
  57 + plus.barcode.QR,
  58 + plus.barcode.EAN13,
  59 + plus.barcode.EAN8,
  60 + plus.barcode.AZTEC,
  61 + plus.barcode.DATAMATRIX,
  62 + plus.barcode.UPCA,
  63 + plus.barcode.UPCE,
  64 + plus.barcode.CODABAR,
  65 + plus.barcode.CODE39,
  66 + plus.barcode.CODE93,
  67 + plus.barcode.CODE128,
  68 + plus.barcode.ITF,
  69 + plus.barcode.MAXICODE,
  70 + plus.barcode.PDF417,
  71 + plus.barcode.RSS14,
  72 + plus.barcode.RSSEXPANDED,
  73 + ],
  74 + {
  75 + top: '0',
  76 + left: '0px',
  77 + width: '100%',
  78 + buttom: '0',
  79 + position: 'absolute',
  80 + zIndex: '1',
  81 + },
  82 + );
  83 + this.barcode.onmarked = (type, result) => {
  84 + this.stopScan();
  85 + newBaseView.close();
  86 + successHandler(type, result);
  87 + };
  88 +
  89 + view = new plus.nativeObj.View(
  90 + 'test',
  91 + {
  92 + top: '20px', left: '20px', height: '30px', width: '80px',
  93 + },
  94 + [
  95 + {
  96 + tag: 'font',
  97 + id: 'font',
  98 + text: '关闭',
  99 + textStyles: { size: '18px', color: '#fff' },
  100 + position: {
  101 + top: '0px',
  102 + left: '0px',
  103 + width: '100%',
  104 + height: '30px',
  105 + },
  106 + },
  107 + ],
  108 + );
  109 +
  110 + // view.interceptTouchEvent(true);
  111 + // plus.webview.currentWebview().append(view);
  112 +
  113 + const id = Date.now().toString();
  114 + const newBaseView = plus.webview.create('', id, { top: '0px', bottom: '0px', height });
  115 + newBaseView.append(this.barcode);
  116 + newBaseView.append(view);
  117 + newBaseView.show();
  118 + this.barcode.start();
  119 + view.addEventListener('click', () => {
  120 + newBaseView.close();
  121 + this.barcode.close();
  122 + }, false);
  123 + }
  124 +
  125 + /* 调用手机摄像头并拍照 */
  126 + static getImage() {
  127 + const { plus } = window;
  128 + const cmr = plus.camera.getCamera();
  129 + cmr.captureImage((p) => {
  130 + plus.io.resolveLocalFileSystemURL(p, (entry) => {
  131 + this.uploadImage(entry.toLocalURL(), entry.name); // 上传拍照的图片
  132 + }, (e) => {
  133 + plus.nativeUI.toast(`读取拍照文件错误:${e.message}`);
  134 + });
  135 + }, (e) => {
  136 + plus.nativeUI.toast(`调用摄像头错误:${e.message}`);
  137 + }, {
  138 + filter: 'image',
  139 + });
  140 + }
  141 +
  142 + /* 相册选择图片 */
  143 + static getPhoto() {
  144 + const { plus } = window;
  145 + plus.gallery.pick((path) => {
  146 + const name = path.substring(path.lastIndexOf('/') + 1);
  147 + this.uploadImage(path, name);// 上传选择的图片
  148 + }, (e) => {
  149 + plus.nativeUI.toast(`选取图片错误:${e.message}`);
  150 + }, { filter: 'image' });
  151 + }
  152 +
  153 + /* 图片上传入库 */
  154 + static uploadImage(url, filename) {
  155 + console.log('uploadImage:', url, filename);
  156 + }
  157 +}
  158 +
  159 +export default BarCodeUtil;
... ...
src/mobile/common/CommobileBase.js 0 → 100644
  1 +/* eslint-disable prefer-destructuring */
  2 +/**
  3 + * Created by mar105 on 2019-02-15.
  4 + */
  5 +
  6 +import React, { Component } from 'react';
  7 +import moment from 'moment';
  8 +import { Modal, Toast } from 'antd-mobile';
  9 +import { addResult } from '@/utils/common/calcuate';
  10 +import commonConfig from '../../utils/config';
  11 +import * as commonUtils from '../../utils/utils';
  12 +import * as commonServices from '../../services/services';
  13 +import * as commonFunc from '../../components/Common/commonFunc';
  14 +import * as commonBusiness from '../../components/Common/commonBusiness';
  15 +// import * as commonFunc from './commonFunc'; /* 通用单据方法 */
  16 +
  17 +export default (ChildComponent) => {
  18 + return class extends Component {
  19 + constructor(props) {
  20 + super(props);
  21 + this.state = {
  22 + pageLoading: true,
  23 + token: props.app.token,
  24 + sModelsId: props.sModelsId, /* 获取配置数据用的modelId */
  25 + formRoute: props.formRoute, /* 组件名: 路由名称 */
  26 + sModelsType: props.sModelsType, /* 组件名: 路由名称 */
  27 + formData: [], /* 所有配置 */
  28 + gdsformconst: [], /* 获取配置常量 */
  29 + gdsjurisdiction: [], /* 获取配置权限 */
  30 + currentId: props.checkedId, /* 当前数据的Id */
  31 + selectedRowKeys: [], /* 已选择的数据行(数据格式:数组) */
  32 + clearArray: [], /* table清除数组 */
  33 + };
  34 + this.sDateFormat = 'YYYY-MM-DD';
  35 + }
  36 +
  37 + async componentWillMount() {
  38 + /* 获取配置 */
  39 + this.mounted = true;
  40 + const { token, sModelsId } = this.state;
  41 + const config = await commonUtils.getStoreDropDownData(sModelsId, '', '');
  42 + if (commonUtils.isEmpty(config)) {
  43 + const configUrl = `${commonConfig.server_host}business/getModelBysId/${sModelsId}?sModelsId=${sModelsId}`;
  44 + const configReturn = (await commonServices.getService(token, configUrl)).data;
  45 + if (configReturn.code === 1) {
  46 + const [configData] = configReturn.dataset.rows;
  47 + // const { formData, gdsformconst, gdsjurisdiction, report, billnosetting } = configData;
  48 + if (this.mounted) {
  49 + // commonUtils.setStoreDropDownData(sModelsId, '', '', configData);
  50 + this.setState({ ...configData });
  51 + }
  52 + } else {
  53 + this.getServiceError(configReturn);
  54 + }
  55 + } else {
  56 + this.setState({ ...config });
  57 + }
  58 + }
  59 +
  60 + shouldComponentUpdate(nextProps, nextState) {
  61 + const { formData } = nextState;
  62 + return (formData.length > 0);
  63 + }
  64 +
  65 + componentWillUnmount() {
  66 + const {
  67 + currentId,
  68 + } = this.state;
  69 + const { copyTo } = this.props;
  70 + const { userinfo } = this.props.app;
  71 + if (commonUtils.isNotEmptyObject(copyTo)) {
  72 + const { slaveData } = copyTo;
  73 + if (commonUtils.isNotEmptyArr(slaveData)) {
  74 + const sIdArray = [];
  75 + slaveData.forEach((item) => {
  76 + const redisKey = item.sSlaveId;
  77 + sIdArray.push(redisKey);
  78 + });
  79 + const sId = sIdArray.toString();
  80 + this.handleSendSocketMessage('copyfinish', 'noAction', sId, userinfo.sId, null, null);
  81 + }
  82 + }
  83 + this.handleSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
  84 + }
  85 +
  86 + /** sql条件 */
  87 + getSqlCondition = (showConfig, name, record) => {
  88 + const conditonValues = {};
  89 + if (commonUtils.isNotEmptyStr(showConfig.sSqlCondition)) {
  90 + const conditon = showConfig.sSqlCondition.split(',');
  91 + conditon.forEach((item) => {
  92 + if (item.indexOf('.') > -1) {
  93 + const tableName = item.split('.')[0];
  94 + let fieldName = item.split('.')[1];
  95 + let fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName;
  96 + // master.sId 作为参数 master.sId.sId 作为filterDropdown过滤参数
  97 + if (showConfig.sDropDownType === 'picArr') {
  98 + fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName;
  99 + if (fieldName.indexOf('&Search') > -1) {
  100 + // 参数为&Search时认为是查找数据集中取数据
  101 + const data = this.state[`${tableName}Data`];
  102 + if (typeof data === 'object' && data.constructor === Object) {
  103 + Object.keys(data).forEach((dataItem) => {
  104 + if (`&Search${data[dataItem]}` === fieldName) {
  105 + let sTmpName = dataItem;
  106 + sTmpName = sTmpName.replace('First', 'Third');
  107 + if (data[dataItem].substring(0, 1) === 't') {
  108 + fieldName = `p${sTmpName.substring(1, dataItem.length)}`;
  109 + } else {
  110 + fieldName = data[dataItem].substring(0, 1) + sTmpName.substring(1, sTmpName.length);
  111 + }
  112 + }
  113 + });
  114 + }
  115 + } else if (fieldName.indexOf('&') > -1) {
  116 + fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName;
  117 + conditonValues[fieldNameFilter] = fieldName.replace('&', '');
  118 + return;
  119 + }
  120 + }
  121 + if (fieldName !== '') {
  122 + if (name === tableName && !commonUtils.isEmpty(record)) {
  123 + const data = record;
  124 + conditonValues[fieldNameFilter] = data[fieldName];
  125 + } else {
  126 + const data = this.state[`${tableName}Data`];
  127 + const selectedRowKeys = this.state[`${tableName}SelectedRowKeys`];
  128 + if (typeof data === 'object' && data.constructor === Object) {
  129 + conditonValues[fieldNameFilter] = data[fieldName];
  130 + } else if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
  131 + let iIndex = data.findIndex(itemData => itemData.sId === selectedRowKeys[0]);
  132 + iIndex = iIndex > -1 ? iIndex : data.findIndex(itemData => itemData.sSlaveId === selectedRowKeys[0]);
  133 + if (iIndex > -1) {
  134 + conditonValues[fieldNameFilter] = data[iIndex][fieldName];
  135 + }
  136 + } else if (commonUtils.isNotEmptyArr(data)) {
  137 + conditonValues[fieldNameFilter] = data[0][fieldName];
  138 + }
  139 + }
  140 + }
  141 + }
  142 + });
  143 + }
  144 + return conditonValues;
  145 + };
  146 +
  147 + /** 获取sql下拉数据 */
  148 + getSqlDropDownData = async (formId, name, showConfig, record, platform) => {
  149 + /* 地址 */
  150 + if (commonUtils.isEmpty(showConfig.sFieldToContent)) {
  151 + const url = `${commonConfig.server_host}business/getSelectDataBysControlId/${showConfig.sId}?sModelsId=${this.state.sModelsId}`;
  152 + /* 参数 */
  153 + const conditonValues = this.getSqlCondition(showConfig, name, record);
  154 + const body = {
  155 + sKeyUpFilterName: '', /* 边输入边过滤,暂时没用1 */
  156 + sSqlCondition: commonUtils.isEmptyObject(conditonValues) ? '' : conditonValues, /* 查询条件 */
  157 + };
  158 + /* 获取数据 */
  159 + const json = await commonServices.postValueService(this.props.app.token, body, url);
  160 + /* code为1代表获取数据成功 */
  161 + if (json && commonUtils.isNotEmptyArr(json.data.dataset) && json.data.code === 1) {
  162 + /* 获取数据集 */
  163 + const { rows } = json.data.dataset;
  164 + return rows;
  165 + } else {
  166 + if (['pda'].includes(platform)) {
  167 + // Modal.alert('温馨提示', json?.data?.msg || '出错了', [
  168 + // { text: '确认' },
  169 + // ]);
  170 + const msg = json?.data?.msg || '出错了';
  171 + Toast.fail(msg, 1);
  172 + throw new Error();
  173 + }
  174 + return [];
  175 + }
  176 + } else {
  177 + const returnData = [];
  178 + if (showConfig.sFieldToContent === '1') {
  179 + if (name === 'master') {
  180 + const { [`${name}Data`]: data } = this.state;
  181 + const sName = `sParamDropDown${showConfig.sName.replace('sParamValue', '')}`;
  182 + returnData.push(...commonUtils.objectToArr(data[sName]));
  183 + } else {
  184 + const { [`${name}Data`]: data, [`${name}SelectedRowKeys`]: selectedRowKeys } = this.state;
  185 + const sName = `sParamDropDown${showConfig.sName.replace('sParamValue', '')}`;
  186 + if (commonUtils.isNotEmptyObject(record)) {
  187 + returnData.push(...commonUtils.objectToArr(record[sName]));
  188 + } else if (commonUtils.isNotEmptyArr(data) && commonUtils.isNotEmptyArr(selectedRowKeys)) {
  189 + const iIndex = data.findIndex(item => item.sId === selectedRowKeys.toString());
  190 + if (iIndex > -1) {
  191 + returnData.push(...commonUtils.objectToArr(data[iIndex][sName]));
  192 + }
  193 + }
  194 + }
  195 + } else {
  196 + const unionCondition = showConfig.sFieldToContent.split('&&');
  197 + unionCondition.forEach((unionItem) => {
  198 + const conditon = unionItem.split(',');
  199 + const tableNameContent = conditon[0].split('.')[0];
  200 + let data = this.state[`${tableNameContent}Data`];
  201 + if (commonUtils.isNotEmptyArr(data)) {
  202 + if (showConfig.sSqlCondition !== '') {
  203 + const sSqlCondition = showConfig.sSqlCondition;
  204 + const sqlConditon = sSqlCondition.split(',');
  205 + sqlConditon.forEach((item) => {
  206 + const tableName = item.split('.')[0];
  207 + const fieldName = item.split('.')[1];
  208 + const fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName;
  209 + const dataCondition = this.state[`${tableName}Data`];
  210 + const selectedRowKeys = this.state[`${tableName}SelectedRowKeys`];
  211 + if (typeof dataCondition === 'object' && dataCondition.constructor === Object) {
  212 + data = data.filter(item => commonUtils.isNull(item[fieldNameFilter], '') === commonUtils.isNull(dataCondition[fieldName], ''));
  213 + } else if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
  214 + let iIndex = dataCondition.findIndex(itemData => itemData.sId === selectedRowKeys[0]);
  215 + iIndex = iIndex > -1 ? iIndex : dataCondition.findIndex(itemData => itemData.sSlaveId === selectedRowKeys[0]);
  216 + if (iIndex > -1) {
  217 + data = data.filter(item => commonUtils.isNull(item[fieldNameFilter], '') === commonUtils.isNull(dataCondition[iIndex][fieldName], ''));
  218 + }
  219 + } else if (commonUtils.isNotEmptyArr(data)) {
  220 + data = data.filter(item => commonUtils.isNull(item[fieldNameFilter], '') === commonUtils.isNull(dataCondition[0][fieldName], ''));
  221 + }
  222 + });
  223 + }
  224 + data.forEach((itemDataRow) => {
  225 + const dataRow = {};
  226 + conditon.forEach((item) => {
  227 + const fieldName = item.split('.')[1];
  228 + const fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName;
  229 + if (fieldName.indexOf('-') >= 0) {
  230 + fieldName.split('-').forEach((itemField) => {
  231 + const sFieldValue = commonUtils.isEmpty(itemDataRow[itemField]) ? '' : itemDataRow[itemField].toString();
  232 + dataRow[fieldNameFilter] = commonUtils.isEmpty(dataRow[fieldNameFilter]) ? sFieldValue : `${dataRow[fieldNameFilter]}-${sFieldValue}`;
  233 + });
  234 + } else {
  235 + dataRow[fieldNameFilter] = commonUtils.isEmpty(itemDataRow[fieldName]) ? '' : itemDataRow[fieldName].toString();
  236 + }
  237 + });
  238 +
  239 + returnData.push(dataRow);
  240 + });
  241 + }
  242 + });
  243 + }
  244 + return returnData;
  245 + }
  246 + };
  247 + /* 获取数字格式化规范 */
  248 + getFloatNum = (sName) => {
  249 + if (sName.toLowerCase().endsWith('price')) { /* 价格 */
  250 + return this.props.app.decimals.dNetPrice;
  251 + } else if (sName.toLowerCase().endsWith('money')) { /* 金额 */
  252 + return this.props.app.decimals.dNetMoney;
  253 + } else { /* 其它 */
  254 + return 6;
  255 + }
  256 + };
  257 +
  258 + /** 获取sql下拉数据 */
  259 + getServiceError = async (returnData) => {
  260 + this.props.dispatch({ type: 'app/throwErrorMobile', payload: returnData });
  261 + };
  262 +
  263 + /* 获取数字格式化规范 */
  264 + getDateFormat = () => {
  265 + return this.props.app.dateFormat;
  266 + };
  267 +
  268 + /* 获取配置数据用的sTabId,formId,formRoute */
  269 + handleConfigValue = (value) => {
  270 + const { secondppopupPane, ppopupPane, currentPane } = this.props.app;
  271 + return commonUtils.isNotEmptyObject(secondppopupPane)
  272 + ? secondppopupPane[value]
  273 + : commonUtils.isNotEmptyObject(ppopupPane)
  274 + ? ppopupPane[value] : currentPane[value];
  275 + };
  276 +
  277 + /* 获取后台数据(单条) */
  278 + handleGetDataOne = async (params) => {
  279 + const { token, sModelsId } = this.state;
  280 + const {
  281 + name, configData, condition, isWait,
  282 + } = params;
  283 +
  284 + const lockUrl = `${commonConfig.server_host}business/addSysLocking?sModelsId=${sModelsId}`;
  285 +
  286 + const configDataId = configData.sId;
  287 + const dataUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${configDataId}?sModelsId=${sModelsId}`;
  288 + const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
  289 + if (dataReturn.code === 1) {
  290 + const [returnData] = dataReturn.dataset.rows[0].dataSet;
  291 + const addState = {};
  292 + const value = {
  293 + tableName: configData.sTbName,
  294 + sId: [returnData.sId],
  295 + };
  296 + const { data } = await commonServices.postValueService(token, value, lockUrl);
  297 + if (data.code === 1) { /* 失败 */
  298 + addState.sUseInfo = '';
  299 + } else { /* 失败 */
  300 + addState.sUseInfo = data.msg;
  301 + }
  302 + addState[`${name}Data`] = returnData;
  303 + if (isWait) {
  304 + return addState;
  305 + } else if (this.mounted) {
  306 + this.setState({ ...addState });
  307 + }
  308 + } else {
  309 + this.getServiceError(dataReturn);
  310 + }
  311 + };
  312 +
  313 + /* 获取后台数据(数据集) */
  314 + handleGetDataSet = async (params) => {
  315 + const {
  316 + name, configData, condition, isWait,
  317 + } = params;
  318 + const {
  319 + token, sModelsId, [`${name}SelectedRowKeys`]: tableSelectedRowKeys,
  320 + } = this.state;
  321 + const configDataId = configData.sId;
  322 + const dataUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${configDataId}?sModelsId=${sModelsId}`;
  323 + const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
  324 + if (dataReturn.code === 1) {
  325 + const returnData = dataReturn.dataset.rows[0].dataSet;
  326 + const returnPagination = {
  327 + total: dataReturn.dataset.totalCount,
  328 + current: dataReturn.dataset.currentPageNo,
  329 + };
  330 + const { sumSet } = dataReturn.dataset.rows[0];
  331 + const totalData = sumSet !== undefined ? sumSet : [];
  332 + const filterCondition = commonUtils.isNotEmptyObject(condition) ? condition.bFilter : '';
  333 + const orderBy = commonUtils.isNotEmptyObject(condition) ? condition.sFilterOrderBy : '';
  334 + let addState = {
  335 + [`${name}Data`]: returnData, [`${name}Pagination`]: returnPagination, [`${name}FilterCondition`]: filterCondition, [`${name}OrderBy`]: orderBy, [`${name}SelectedRowKeys`]: tableSelectedRowKeys,
  336 + };
  337 + if (dataReturn.dataset.currentPageNo === 1) {
  338 + addState = { ...addState, [`${name}Total`]: totalData };
  339 + }
  340 + if (isWait) {
  341 + return addState;
  342 + } else if (this.mounted) {
  343 + this.setState(addState);
  344 + }
  345 + } else if (dataReturn.code === -8) {
  346 + Modal.alert('温馨提示', dataReturn.msg || '出错了', [
  347 + { text: '确认' },
  348 + ]);
  349 + } else {
  350 + this.getServiceError(dataReturn);
  351 + }
  352 + };
  353 +
  354 + /* 数据保存到state */
  355 + handleSaveState = (values) => {
  356 + if (this.mounted) {
  357 + this.setState(values);
  358 + }
  359 + };
  360 +
  361 + /** 修改主表数据 */
  362 + handleMasterChange = (name, sFieldName, changeValue, sId, dropDownData, isWait, masterDataNew) => {
  363 + const { masterData: masterDataOld } = this.state;
  364 + const { sModelsId, masterConfig } = this.state;
  365 + let masterData = masterDataNew === undefined ? masterDataOld === undefined ? {} : masterDataOld : masterDataNew;
  366 + let { handleType } = masterData;
  367 + handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
  368 + if (sFieldName.substring(0, 1).toLowerCase() === 'c') {
  369 + const sAllField = sFieldName.substring(1, sFieldName.length);
  370 + const allField = sAllField.split('_');
  371 + const value = changeValue[sFieldName];
  372 + allField.forEach((item, iArr) => {
  373 + if (value.length > iArr) {
  374 + changeValue[item] = value[iArr];
  375 + }
  376 + });
  377 + }
  378 + if (!commonUtils.isEmpty(masterConfig.gdsconfigformslave) && commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave) && !commonUtils.isEmpty(sFieldName)) {
  379 + masterConfig.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) &&
  380 + (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) &&
  381 + (item.sSqlCondition.includes(sFieldName) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => {
  382 + commonUtils.setStoreDropDownData(sModelsId, name, item.sName, []);
  383 + });
  384 + }
  385 + masterData = { ...masterData, ...changeValue, handleType };
  386 + if (isWait) {
  387 + return { masterData, sUseInfo: '' };
  388 + } else if (this.mounted) {
  389 + this.setState({ masterData, sUseInfo: '' });
  390 + return { masterData };
  391 + }
  392 + };
  393 +
  394 + /** 添加表格空行 */
  395 + handleTableAdd = (name, isWait) => {
  396 + /* 外置处理业务 */
  397 + const {
  398 + [`${name}Config`]: tableConfig, masterData, slaveData, slaveSelectedRowKeys,
  399 + } = this.state;
  400 + let { [`${name}Data`]: tableData } = this.state;
  401 + tableData = commonUtils.isEmptyObject(tableData) ? [] : tableData;
  402 + const allTableData = {};
  403 + allTableData.master = masterData;
  404 + if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
  405 + const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys.toString());
  406 + allTableData.slave = slaveData[iSlaveIndex];
  407 + } else {
  408 + allTableData.slave = slaveData[0];
  409 + }
  410 + const iOrderArr = [];
  411 + tableData.forEach((item) => {
  412 + const iOrder = commonUtils.isNotEmptyNumber(item.iOrder) ? item.iOrder : 0; /* 获取tableData中iOrder最大值 */
  413 + iOrderArr.push(iOrder);
  414 + });
  415 + const iOrderMax = Math.max(...iOrderArr);
  416 + const tableDataRow = commonFunc.getDefaultData(tableConfig, allTableData);
  417 + tableDataRow.handleType = 'add';
  418 + tableDataRow.sId = commonUtils.createSid();
  419 + tableDataRow.sParentId = masterData && masterData.sId ? masterData.sId : null;
  420 + tableDataRow.key = tableDataRow.sId;
  421 + tableDataRow.bDefault = false;
  422 + tableDataRow.iOrder = commonUtils.isNotEmptyArr(tableData) ? iOrderMax + 1 : 0;
  423 +
  424 + const iIndex = this.props.app.systemData.findIndex(item => item.sName === 'CbxMaterialsDefine');
  425 + if (iIndex > -1) {
  426 + const sCbxMaterialsDefine = this.props.app.systemData[iIndex].sValue;
  427 + if (sCbxMaterialsDefine === 'datenum') {
  428 + tableDataRow.sDefineNo = moment(new Date()).format('YYYYMMDD');
  429 + } else if (sCbxMaterialsDefine === 'datetimenum') {
  430 + tableDataRow.sDefineNo = moment(new Date()).format('YYYYMMDDHHmm');
  431 + } else if (sCbxMaterialsDefine === 'yearnum') {
  432 + tableDataRow.sDefineNo = moment(new Date()).format('YYYY');
  433 + } else if (sCbxMaterialsDefine === 'yearmonthnum') {
  434 + tableDataRow.sDefineNo = moment(new Date()).format('YYYYMM');
  435 + } else if (sCbxMaterialsDefine === 'worknum') {
  436 + tableDataRow.sDefineNo = tableDataRow.sWorkOrderNo;
  437 + } else if (sCbxMaterialsDefine === 'manuualno') {
  438 + tableDataRow.sDefineNo = tableDataRow.sManualNo;
  439 + } else if (sCbxMaterialsDefine === 'createnownum') { /* 批号根据生产日期+当前日期 */
  440 + tableDataRow.sDefineNo = moment(tableDataRow.tProductionDate).format('YYYYMMDDHHmm') + moment(new Date()).format('YYYYMMDDHHmm');
  441 + }
  442 + }
  443 +
  444 + if (isWait) {
  445 + return tableDataRow;
  446 + } else {
  447 + // tableData.splice(index, 1, tableDataRow); /* 该处会导致新增时删除首行 */
  448 + tableData.push(tableDataRow);
  449 + if (this.mounted) {
  450 + this.setState({ [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: [tableDataRow.sId] });
  451 + }
  452 + }
  453 + };
  454 +
  455 + /** 表格数据更改 */
  456 + // name 不写完整的state名称作用为了要用到total // (name, changeValue, sId, dropDownData)
  457 + handleTableChange = (name, sFieldName, changeValue, sId, dropDownData, isWait) => {
  458 + const {
  459 + [`${name}Data`]: tableData, [`${name}Config`]: tableConfig, sModelsId, masterData, slaveData, controlData,
  460 + } = this.state;
  461 + const iIndex = tableData.findIndex(item => item.sId === sId);
  462 + let { handleType } = tableData[iIndex];
  463 + handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
  464 + if (sFieldName.substring(0, 1).toLowerCase() === 'c') {
  465 + const sAllField = sFieldName.substring(1, sFieldName.length);
  466 + const allField = sAllField.split('_');
  467 + const value = changeValue[sFieldName];
  468 + allField.forEach((item, iArr) => {
  469 + if (value.length > iArr) {
  470 + changeValue[item] = value[iArr];
  471 + }
  472 + });
  473 + }
  474 + if (!commonUtils.isEmpty(tableConfig.gdsconfigformslave) && commonUtils.isNotEmptyArr(tableConfig.gdsconfigformslave) && !commonUtils.isEmpty(sFieldName)) {
  475 + tableConfig.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && item.sSqlCondition.includes(sFieldName)).forEach((item) => {
  476 + commonUtils.setStoreDropDownData(sModelsId, name, item.sName, []);
  477 + });
  478 + }
  479 + const tableAllData = {
  480 + master: masterData,
  481 + slave: slaveData,
  482 + control: controlData,
  483 + };
  484 + const tableDataRowNew = { ...tableData[iIndex], ...changeValue, handleType };
  485 + const tableDataAfter = commonBusiness.getKeyUpEvent(name, sFieldName, tableConfig, tableDataRowNew, tableDataRowNew, true, tableAllData);
  486 + console.log('tableDataAfter::', tableDataAfter);
  487 + if (commonUtils.isNotEmptyObject(tableDataAfter)) {
  488 + changeValue = { ...tableDataAfter };
  489 + }
  490 + if (isWait) {
  491 + return { ...tableData[iIndex], ...changeValue, handleType };
  492 + } else {
  493 + tableData[iIndex] = { ...tableData[iIndex], ...changeValue, handleType };
  494 + if (this.mounted) {
  495 + this.setState({ [`${name}Data`]: tableData, sUseInfo: '' });
  496 + }
  497 + }
  498 + };
  499 +
  500 + handleSendSocketMessage = (flag, showType, sId, sendTo, msgInfo, param) => {
  501 + const { token } = this.props.app;
  502 + const sendws = this.handleSendWebSocketMsg;
  503 + const { dispatch } = this.props;
  504 + if (commonUtils.isNotEmptyObject(token)) {
  505 + if (this.props.app.webSocket !== null && this.props.app.webSocket.readyState === WebSocket.OPEN) {
  506 + sendws(flag, showType, msgInfo, sId, sendTo, param);
  507 + } else {
  508 + this.props.dispatch({ type: 'app/createWebSocket', payload: { reStart: true, dispatch } });
  509 + setTimeout(() => {
  510 + console.log('====== reStart ======');
  511 + sendws(flag, showType, msgInfo, sId, sendTo, param);
  512 + }, 30000);
  513 + }
  514 + }
  515 + };
  516 +
  517 + handleSendWebSocketMsg = (flag, showType, msgInfo, sId, sendTo, param) => {
  518 + const { app } = this.props;
  519 + const { webSocket, userinfo, currentPane } = app;
  520 + const { key } = currentPane;
  521 + commonFunc.sendWebSocketMessage(webSocket, key, flag, showType, userinfo.sId, msgInfo, sId, sendTo, param);
  522 + }
  523 +
  524 + handleFilterDropDownData = (dropDownData, showConfig, name, record) => {
  525 + if (!commonUtils.isEmptyArr(dropDownData)) {
  526 + const conditon = showConfig.sSqlCondition.split(',');
  527 + let orTableName;
  528 + let orFieldName;
  529 + let orFieldNameFilter;
  530 + let orValue;
  531 + conditon.forEach((item) => {
  532 + if (item.indexOf('.') > -1) {
  533 + const tableName = item.split('.')[0];
  534 + const fieldName = item.split('.')[1];
  535 + const fieldNameFilter = item.split('.')[2];
  536 + if (tableName.indexOf('|') > -1) {
  537 + orTableName = tableName.replace('|', '');
  538 + orFieldName = fieldName;
  539 + orFieldNameFilter = fieldNameFilter;
  540 + if (orFieldName.indexOf('&') > -1) {
  541 + orValue = orFieldName.replace('&', '');
  542 + } else if (!commonUtils.isEmpty(orFieldNameFilter)) {
  543 + if (name === orTableName && !commonUtils.isEmpty(record)) {
  544 + const data = record;
  545 + orValue = data[orFieldName];
  546 + } else {
  547 + const data = this.state[`${orTableName}Data`];
  548 + const selectedRowKeys = this.state[`${orTableName}SelectedRowKeys`];
  549 + if (typeof data === 'object' && data.constructor === Object) {
  550 + orValue = data[orFieldName];
  551 + } else if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
  552 + const iIndex = data.findIndex(itemData => itemData.sId === selectedRowKeys[0]);
  553 + if (iIndex > -1) {
  554 + orValue = data[iIndex][orFieldName];
  555 + }
  556 + } else if (commonUtils.isNotEmptyArr(data)) {
  557 + orValue = data[0][orFieldName];
  558 + }
  559 + }
  560 + }
  561 + orValue = orValue.toString();
  562 + } else if (!commonUtils.isEmpty(orFieldName)) {
  563 + // master.sId 作为参数 control.sId.sControlId 作为filterDropdown过滤参数
  564 + if (!commonUtils.isEmpty(fieldNameFilter)) {
  565 + if (name === tableName && !commonUtils.isEmpty(record)) {
  566 + const data = record;
  567 + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[fieldName] || itemDrop[orFieldNameFilter] === orValue);
  568 + } else {
  569 + const data = this.state[`${tableName}Data`];
  570 + const selectedRowKeys = this.state[`${tableName}SelectedRowKeys`];
  571 + if (typeof data === 'object' && data.constructor === Object) {
  572 + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[fieldName] || itemDrop[orFieldNameFilter] === orValue);
  573 + } else if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
  574 + const iIndex = data.findIndex(itemData => itemData.sId === selectedRowKeys[0]);
  575 + if (iIndex > -1) {
  576 + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[iIndex][fieldName] || itemDrop[orFieldNameFilter] === orValue);
  577 + }
  578 + } else if (commonUtils.isNotEmptyArr(data)) {
  579 + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[0][fieldName] || itemDrop[orFieldNameFilter] === orValue);
  580 + }
  581 + }
  582 + }
  583 + } else if (!commonUtils.isEmpty(fieldNameFilter)) {
  584 + if (name === tableName && !commonUtils.isEmpty(record)) {
  585 + const data = record;
  586 + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[fieldName]);
  587 + } else {
  588 + const data = this.state[`${tableName}Data`];
  589 + const selectedRowKeys = this.state[`${tableName}SelectedRowKeys`];
  590 + if (typeof data === 'object' && data.constructor === Object) {
  591 + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[fieldName]);
  592 + } else if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
  593 + const iIndex = data.findIndex(itemData => itemData.sId === selectedRowKeys[0]);
  594 + if (iIndex > -1) {
  595 + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[iIndex][fieldName]);
  596 + }
  597 + } else if (commonUtils.isNotEmptyArr(data)) {
  598 + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[0][fieldName]);
  599 + }
  600 + }
  601 + }
  602 + }
  603 + });
  604 + }
  605 +
  606 + // let dropDownData = dropDownDataOld;
  607 + // const data = this.state[`${tableName}Data`];
  608 + // const selectedRowKeys = this.state[`${tableName}SelectedRowKeys`];
  609 + // if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
  610 + // const SelectedData = data.filter(item => item.sId === selectedRowKeys[0]);
  611 + // if (SelectedData.length > 0 && commonUtils.isNotEmptyStr(SelectedData[0][fieldName])) {
  612 + // if (commonUtils.isNotEmptyArr(dropDownData)) {
  613 + // dropDownData = dropDownData.filter(item => item[fieldName] === SelectedData[0][fieldName]);
  614 + // }
  615 + // }
  616 + // }
  617 + return dropDownData;
  618 + };
  619 +
  620 + /* 增加通用的tmpInfobySql功能 */
  621 + handleTmpInfoBySql = async (copyToConfig, sRowData, copyTo) => {
  622 + const returnObj = commonUtils.isNotEmptyObject(copyTo) ? copyTo : {};
  623 + const { token, sModelsId } = this.state;
  624 + const sControlName = copyToConfig[0].sControlName;
  625 + if (commonUtils.isNotEmptyObject(sControlName) && sControlName.toLowerCase().includes('tmpinfobysql')) { /* 根据配置下拉sql获取数据源 */
  626 + const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfoBySql/?sModelsId=${sModelsId}`;
  627 + const sConfigformId = commonUtils.isEmpty(copyToConfig) ? '' : copyToConfig[0].sParentId;
  628 + const sControlName = commonUtils.isNotEmptyObject(sControlName) ? sControlName : 'BtnCopyTo.tmpInfoBySql';
  629 + const values = { sConfigformId, sControlName, sRowData };
  630 + const dataReturn = (await commonServices.postValueService(token, values, dataUrl)).data;
  631 + if (dataReturn.code === 1) {
  632 + const returnData = dataReturn.dataset.rows[0];
  633 + if (commonUtils.isNotEmptyObject(returnData)) {
  634 + for (const key of Object.keys(returnData)) {
  635 + const sName = `${key}Data`;
  636 + const masterName = sControlName.replace('BtnCopyTo.', '').trim();
  637 + if (key === masterName) {
  638 + returnObj.masterData = returnData[key][0];
  639 + } else {
  640 + returnObj[sName] = returnData[key];
  641 + }
  642 + }
  643 + if (commonUtils.isNotEmptyArr(returnObj.masterData) && Array.isArray(returnObj.masterData)) {
  644 + returnObj.masterData = returnObj.masterData[0];
  645 + }
  646 + }
  647 + } else {
  648 + this.getServiceError(dataReturn);
  649 + }
  650 + }
  651 + return returnObj;
  652 + }
  653 +
  654 + /**
  655 + * 增加,删除, pda, copyto, onChange
  656 + * @param {*} data
  657 + * @param {*} isOutsourcedProcesses
  658 + * @param {*} tabPage
  659 + * @param {*} masterData
  660 + * @returns
  661 + */
  662 + handleMasterDefaultData = (data, isOutsourcedProcesses, tabPage, masterData, {
  663 + masterConfig, slaveChildConfig, slave0Config, slaveConfig,
  664 + } = {}) => {
  665 + let iTypeConfig = this.state.slaveChildConfig || slaveChildConfig;
  666 + const config = this.state.masterConfig || masterConfig;
  667 + if (config) {
  668 + const value = config.gdsconfigformslave?.find(i => i &&
  669 + ((['sDefaultQty'].includes(i.sName) && !isOutsourcedProcesses) ||
  670 + (isOutsourcedProcesses && ['sDefaultSlaveChild', 'sDefaultSlave0'].includes(i.sName))));
  671 + if (!value) return masterData;
  672 + } else {
  673 + return masterData;
  674 + }
  675 +
  676 + let sDefaultQty = 'sDefaultQty';
  677 + let sSlaveLength = 'sSlaveLength';
  678 + // 外发区分配置
  679 + if (isOutsourcedProcesses) {
  680 + iTypeConfig = ({
  681 + 1: slave0Config || this.state.slave0Config,
  682 + }[tabPage]) || slaveConfig || this.state.slaveConfig;
  683 +
  684 + sDefaultQty = {
  685 + 0: 'sDefaultSlaveChild',
  686 + 1: 'sDefaultSlave0',
  687 + }[tabPage] || 'sDefaultSlave';
  688 + sSlaveLength = {
  689 + 0: 'sSlaveLengthSlaveChild',
  690 + 1: 'sSlaveLengthSlave0',
  691 + }[tabPage] || 'sSlaveLengthSlave';
  692 + } else if (typeof tabPage === 'undefined') {
  693 + if (!commonUtils.isNotEmptyObject(this.state.slaveChildConfig || slaveChildConfig)) {
  694 + iTypeConfig = slaveConfig;
  695 + }
  696 + }
  697 +
  698 + const hasiType = iTypeConfig?.gdsconfigformslave?.find(item => ['itype', 'iType'].includes(item?.sName));
  699 + const iType = hasiType?.sDefault;
  700 + const type = iType !== undefined ? iType : 11;
  701 + let name = 'dAuxiliaryQty';
  702 + if (['10', '12'].includes(type)) {
  703 + name = 'dProductQty';
  704 + }
  705 +
  706 + const result = data.reduce((a, b) => {
  707 + return addResult(a, (Number(b?.[name]) || 0));
  708 + }, 0);
  709 +
  710 + return {
  711 + ...masterData || {},
  712 + [sSlaveLength]: data.length,
  713 + [sDefaultQty]: result,
  714 + };
  715 + }
  716 +
  717 + render() {
  718 + return (
  719 + <ChildComponent
  720 + style={{ height: '100%' }}
  721 + {...this.props}
  722 + {...this.state}
  723 + getSqlDropDownData={this.getSqlDropDownData}
  724 + getSqlCondition={this.getSqlCondition}
  725 + getServiceError={this.getServiceError}
  726 + onDataRowAdd={this.handleTableAdd}
  727 + getFloatNum={this.getFloatNum}
  728 + getDateFormat={this.getDateFormat}
  729 + handleGetDataOne={this.handleGetDataOne}
  730 + handleGetDataSet={this.handleGetDataSet}
  731 + onSaveState={this.handleSaveState}
  732 + onChange={this.handleMasterChange}
  733 + onDataChange={this.handleTableChange}
  734 + handleSendSocketMessage={this.handleSendSocketMessage}
  735 + onFilterDropDownData={this.handleFilterDropDownData}
  736 + onTmpInfoBySql={this.handleTmpInfoBySql}
  737 + handleMasterDefaultData={this.handleMasterDefaultData}
  738 + />
  739 + );
  740 + }
  741 + };
  742 +};
... ...
src/mobile/common/CommobileBill.js 0 → 100644
  1 +/* eslint-disable */
  2 +import React from 'react';
  3 +import weixin from 'weixin-js-sdk';
  4 +import { Flex, Button, ListView, Toast } from 'antd-mobile';
  5 +import { createForm } from 'rc-form';
  6 +import 'antd-mobile-v2/dist/antd-mobile.css';
  7 +import CommobileBase from './CommobileBase';
  8 +import CommobileBillEvent from './CommobileBillEvent';
  9 +import CommobileViewMaster from './CommobileViewMaster';
  10 +import commonConfig from '../../utils/config';
  11 +import * as commonUtils from '../../utils/utils';
  12 +import ShowType from './CommobileComponent';
  13 +import CommobileToolBar from './CommobileToolBar';
  14 +import styles from '../mobile.less';
  15 +import add from '../../assets/mobile/add-select.svg';
  16 +import scan from '../../assets/mobile/scanning.svg';
  17 +import close from '../../assets/mobile/close.svg';
  18 +import * as commonFunc from '../../components/Common/commonFunc';
  19 +import BarCodeUtil from './BarCodeUtil';
  20 +import preView from '../components/preView';
  21 +import * as commonServices from "../../services/services";
  22 +
  23 +const dataSource = new ListView.DataSource({
  24 + rowHasChanged: (row1, row2) => row2,
  25 +});
  26 +
  27 +class CommobileBill extends React.Component {
  28 + constructor(props) {
  29 + super(props);
  30 + this.state = {
  31 + };
  32 + }
  33 +
  34 + // eslint-disable-next-line react/sort-comp
  35 + handleClick = async (name, type, sId) => {
  36 + if (name === 'BtnSave') {
  37 + this.props.onSubmit();
  38 + } else if (name === 'BtnUpd') {
  39 + this.props.onEdit(name);
  40 + } else if (type === 'add') {
  41 + this.props.onDataRowAdd(name);
  42 + } else if (type === 'del') {
  43 + const { app, [`${name}Data`]: tableData } = this.props;
  44 + let { [`${name}DelData`]: tableDelData } = this.props;
  45 + tableDelData = commonUtils.isEmptyArr(tableDelData) ? [] : tableDelData;
  46 + if (sId !== '') {
  47 + const tableDataIndex = tableData.findIndex(item => item.sId === sId);
  48 + if (tableDataIndex > -1) {
  49 + const slaveDataFilter = tableData[tableDataIndex];
  50 + tableData.splice(tableDataIndex, 1);
  51 + slaveDataFilter.handleType = 'del';
  52 + tableDelData.push(slaveDataFilter);
  53 + }
  54 + this.props.onSaveState({
  55 + [`${name}Data`]: tableData,
  56 + [`${name}DelData`]: tableDelData,
  57 + [`${name}SelectedRowKeys`]: [],
  58 + });
  59 + } else {
  60 + Toast.fail(commonFunc.showMessage(app.commonConst, 'pleaseChooseDelData')); // 请选择删除数据
  61 + }
  62 + } else if (type === 'scan' || name === 'BtnScan') {
  63 + BarCodeUtil.startScan(async (type, code) => {
  64 + const {
  65 + slaveConfig, sModelsId, masterData, slaveData, sModelsType, masterConfig,
  66 + } = this.props;
  67 + /* 规则定义
  68 + 材料
  69 + sDefineNo: codeArr[0], --唯一码
  70 + sMaterialsName: codeArr[1], --材料名称
  71 + sMaterialsStyle: codeArr[2], --材料规格
  72 + dAuxiliaryQty: codeArr[3], --数量
  73 + sWareHouseName: codeArr[4], --仓库名称
  74 + sLocationName: codeArr[5], --名称
  75 + sDefineNo2: codeArr[6], --二维码
  76 + tInStoreDate: codeArr[7], --入库日期
  77 + sMaterialsId: codeArr[8], --材料ID
  78 + sWareHouseId: codeArr[9], --仓库ID
  79 + sLocationId: codeArr[10], --sLocationId
  80 + 成品
  81 + sDefineNo: codeArr[0], --唯一码
  82 + sProductName: codeArr[1], --产品名称
  83 + sProductStyle: codeArr[2], --产品规格
  84 + dProductQty: codeArr[3], --产品数量
  85 + sWarehouseName: codeArr[4], --仓库名称
  86 + sLocationName: codeArr[5], --仓库名称
  87 + sDefineNo2: codeArr[6], --二维码
  88 + tInStoreDate: codeArr[7], --入库日期
  89 + sProductId: codeArr[8], --产品ID
  90 + sWareHouseId: codeArr[9], --仓库ID
  91 + sLocationId: codeArr[10],
  92 + sCustomerName: codeArr[11], --客户名称
  93 + sCustomerShort: codeArr[12],
  94 + sOrderNo: codeArr[13], --订单号
  95 + sWorkOrderNo: codeArr[14], --工单号
  96 + sCustomerOrderNo: codeArr[15], --客户编号
  97 + sCustomerProductNo: codeArr[16], --客户产品编号
  98 + */
  99 + // const slaveData = [];
  100 + let slaveDataObj = {};
  101 + let masterdataObj = {};
  102 + let slaveDataObjAdd = {};
  103 + let masterDataObjAdd = {};
  104 + if (commonUtils.isEmptyObject(code)) {
  105 + Toast.fail('二维码扫码失败!', 1);
  106 + return;
  107 + }
  108 + const codeArr = code.split('|');
  109 + let models = '';
  110 + if (codeArr.length === 12) { /* 材料 */
  111 + models = 'Materials';
  112 + } else if (codeArr.length === 17) { /* 成品 */
  113 + models = 'Product';
  114 + } else {
  115 + models = 'Single'; /* 单一的 */
  116 + }
  117 + if (models === 'Single') { /* sModelsType === 'purchase/purchaseInstore' 扫码入库、扫码领料(唯一码) */
  118 + /* 取第一条码 */
  119 + const sDefineNo = codeArr.length > 0 ? codeArr[0] : '';
  120 + /* 如果条码已存在,提示 */
  121 + // const iIndex = slaveData.findIndex(item => commonUtils.isNotEmptyObject(item.sDefineNo) && item.sDefineNo === sDefineNo);
  122 + // if (iIndex > -1) {
  123 + // Toast.fail('条码已存在!!!', 1);
  124 + // return;
  125 + // }
  126 + /* 读取扫码配置 */
  127 + const btnScanConfigs = masterConfig.gdsconfigformslave.filter(item => item.sName === '' && item.sControlName.indexOf('BtnScan') > -1);
  128 + const AssignField = commonUtils.isNotEmptyArr(btnScanConfigs) ? btnScanConfigs[0].sAssignField : '';
  129 + const sDefineNoName = commonUtils.isNotEmptyArr(btnScanConfigs) ? btnScanConfigs[0].sActiveKey : 'sDefineNo';
  130 +
  131 + masterdataObj = {
  132 + ...masterData, [sDefineNoName] : sDefineNo
  133 + };
  134 + /* 唯一码调接口 */
  135 + let sqlDataRow ={};
  136 + if(commonUtils.isNotEmptyArr(btnScanConfigs)) {
  137 + const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', btnScanConfigs[0], masterdataObj);
  138 + if(commonUtils.isNotEmptyArr(sqlDropDownData)) {
  139 + sqlDataRow = sqlDropDownData[0];
  140 + }
  141 + }
  142 + slaveDataObj = { ...slaveDataObj, ...commonFunc.getAssignFieldValue(AssignField, masterdataObj) }; // 取主表赋值字段
  143 + if(commonUtils.isNotEmptyObject(sqlDataRow)) {
  144 + slaveDataObj = { ...slaveDataObj, ...commonFunc.getAssignFieldValue(AssignField, sqlDataRow) }; // 取接口数据源赋值字段
  145 + }
  146 + slaveDataObj.sParentId = masterdataObj.sId;
  147 + if (commonUtils.isNotEmptyArr(slaveData)) {
  148 + const len = slaveData.length;
  149 + const sDefineNoNew = slaveData[len - 1][sDefineNoName];
  150 + const { handleType } = slaveData[len - 1];
  151 + /* 若slaveData 最后一条数据没有条形码,则赋值条形码;否则新增一条数据 */
  152 + if (commonUtils.isEmptyObject(sDefineNoNew)) {
  153 + slaveDataObj.handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
  154 + // slaveData[len - 1] = slaveDataObj;
  155 + slaveData[len - 1] = { ...slaveData[len-1], ...slaveDataObj};
  156 + } else {
  157 + slaveDataObj.sId = commonUtils.createSid();
  158 + slaveDataObj.handleType = 'add';
  159 + slaveData.unshift(slaveDataObj);
  160 + }
  161 + } else {
  162 + slaveDataObj.sId = commonUtils.createSid();
  163 + slaveDataObj.handleType = 'add';
  164 + slaveData.unshift(slaveDataObj);
  165 + }
  166 + if (sModelsType === 'scan/productionmaterials') { /* 只有扫码领料连续扫码 */
  167 + this.handleClick('slave', 'scan'); /* 连续扫码 */
  168 + }
  169 + } else if (models === 'Materials') { /* sModelsType === 'materialsStock/productionmaterials' */
  170 + /* 取第一条码 */
  171 + const sDefineNo = codeArr.length > 0 ? codeArr[0] : '';
  172 + /* 如果条码已存在,提示 */
  173 + // const iIndex = commonUtils.isNotEmptyArr(slaveData) ? slaveData.findIndex(item => commonUtils.isNotEmptyObject(item.sDefineNo) && item.sDefineNo === sDefineNo) : -1;
  174 + // if (iIndex > -1) {
  175 + // Toast.fail('条码已存在!!!', 1);
  176 + // return;
  177 + // }
  178 + const dateStr = codeArr.length > 7 && commonUtils.isNotEmptyObject(codeArr[7])? codeArr[7].replace(/-/g, '/') : undefined;
  179 + // const date = new Date(dataStr);
  180 + slaveDataObjAdd = {
  181 + sDefineNo: codeArr.length > 0 ? codeArr[0] : '',
  182 + sMaterialsName: codeArr.length > 1 ? codeArr[1] : '',
  183 + sMaterialsStyle: codeArr.length > 2 ? codeArr[2] : '',
  184 + dAuxiliaryQty: codeArr.length > 3 ? commonUtils.isNull(Number(codeArr[3]), 0) : '',
  185 + sDefineNo2: codeArr.length > 6 ? codeArr[6] : '',
  186 + sMaterialsId: codeArr.length > 8 ? codeArr[8] : '',
  187 + sWareHouseId: codeArr.length > 9 ? codeArr[9] : '',
  188 + sLocationId: codeArr.length > 10 ? codeArr[10] : '',
  189 + dMaterialsQty: codeArr.length > 11 ? commonUtils.isNull(Number(codeArr[11]), 0) : '',
  190 + tInStoreDate: dateStr,
  191 + };
  192 + masterdataObj = {
  193 + ...masterData, ...slaveDataObjAdd,
  194 + };
  195 + /* 读取扫码配置 */
  196 + const btnScanConfigs = masterConfig.gdsconfigformslave.filter(item => item.sName === '' && item.sControlName.indexOf('BtnScan.slave') > -1);
  197 + // if(commonUtils.isEmptyArr(btnScanConfigs)) {
  198 + // Toast.fail('请配置扫码按钮!!!', 1);
  199 + // return;
  200 + // }
  201 + const AssignField = commonUtils.isNotEmptyArr(btnScanConfigs) ? btnScanConfigs[0].sAssignField : '';
  202 + let sqlDataRow ={};
  203 + if(commonUtils.isNotEmptyArr(btnScanConfigs)) {
  204 + const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', btnScanConfigs[0], masterdataObj);
  205 + if(commonUtils.isNotEmptyArr(sqlDropDownData)) {
  206 + sqlDataRow = sqlDropDownData[0];
  207 + }
  208 + }
  209 + if (commonUtils.isNotEmptyArr(slaveData) && slaveData.length > 0) { /* 拿原始从表值 */
  210 + const len = slaveData.length;
  211 + const sDefineNoNew = slaveData[len - 1].sDefineNo;
  212 + if (commonUtils.isEmptyArr(sDefineNoNew)) {
  213 + slaveDataObj = { ...slaveDataObj, ...slaveData[len - 1] };
  214 + }
  215 + }
  216 + slaveDataObj = { ...slaveDataObjAdd, ...commonFunc.getAssignFieldValue(AssignField, masterData) }; // 取赋值字段
  217 + if(commonUtils.isNotEmptyObject(sqlDataRow)) {
  218 + slaveDataObj = { ...slaveDataObj, ...commonFunc.getAssignFieldValue(AssignField, sqlDataRow) }; // 取接口数据源赋值字段
  219 + }
  220 +
  221 + // slaveDataObj.sDefineNo = sDefineNo;
  222 + slaveDataObj.sId = commonUtils.createSid();
  223 + slaveDataObj.iOrder = 1;
  224 + console.log('slaveDataObj1111', slaveDataObj);
  225 + const slaveDataConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave : '';
  226 + const materialsNameConfig = slaveDataConfig.filter(item => item.sName === 'sMaterialsId');
  227 + const sWareHouseNameConfig = slaveDataConfig.filter(item => item.sName === 'sWareHouseId');
  228 + const sLocationNameConfig = slaveDataConfig.filter(item => item.sName === 'sLocationId');
  229 + const onDataRowAdd = this.props.onDataRowAdd(name, true);
  230 + const materialseAssignField = commonUtils.isNotEmptyArr(materialsNameConfig) ? materialsNameConfig[0].sAssignField : '';
  231 + const sWareHouseNameAssignField = commonUtils.isNotEmptyArr(sWareHouseNameConfig) ? sWareHouseNameConfig[0].sAssignField : '';
  232 + const sLocationNameAssignField = commonUtils.isNotEmptyArr(sLocationNameConfig) ? sLocationNameConfig[0].sAssignField : '';
  233 +
  234 + let materialsNameDropDownData = [];
  235 + let sWareHouseNamedropDownData = [];
  236 + let sLocationNamedropDownData = [];
  237 + if (commonUtils.isNotEmptyObject(materialsNameConfig[0]) && materialsNameConfig[0].sDropDownType === 'sql') {
  238 + materialsNameDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', materialsNameConfig[0], slaveData);
  239 + }
  240 + if (commonUtils.isNotEmptyObject(sWareHouseNameConfig[0]) && sWareHouseNameConfig[0].sDropDownType === 'sql') {
  241 + sWareHouseNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', sWareHouseNameConfig[0], slaveData);
  242 + }
  243 + if (commonUtils.isNotEmptyObject(sLocationNameConfig[0]) && sLocationNameConfig[0].sDropDownType === 'sql') {
  244 + sLocationNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', sLocationNameConfig[0], masterData);
  245 + }
  246 + // }
  247 + let materialsNameDataOne;
  248 + let sWareHouseNameDataOne;
  249 + let sLocationNameDataOne;
  250 + if (!commonUtils.isEmpty(materialsNameDropDownData)) {
  251 + if (codeArr.length > 1) {
  252 + materialsNameDataOne = materialsNameDropDownData.filter(item => item.sMaterialsName === codeArr[1]);
  253 + }
  254 + }
  255 + if (!commonUtils.isEmpty(sWareHouseNamedropDownData)) {
  256 + if (codeArr.length > 4) {
  257 + sWareHouseNameDataOne = sWareHouseNamedropDownData.filter(item => item.sName === codeArr[4]);
  258 + }
  259 + }
  260 + if (!commonUtils.isEmpty(sLocationNamedropDownData)) {
  261 + if (codeArr.length > 5) {
  262 + sLocationNameDataOne = sLocationNamedropDownData.filter(item => item.sName === codeArr[5]);
  263 + }
  264 + }
  265 + const newCopyTo = {};
  266 + newCopyTo.master = masterdataObj;
  267 + newCopyTo.slave = commonUtils.isEmpty(slaveData) ? [] : slaveData[0];
  268 + let materialsDataDetiale = {};
  269 + let sWareHouseNameDataDetiale = {};
  270 + let sLocationNameDataDetiale = {};
  271 + materialsDataDetiale = { ...commonFunc.getAssignFieldValue(materialseAssignField, materialsNameDataOne[0], newCopyTo) };
  272 + sWareHouseNameDataDetiale = { ...commonFunc.getAssignFieldValue(sWareHouseNameAssignField, sWareHouseNameDataOne[0], newCopyTo) };
  273 + sLocationNameDataDetiale = { ...commonFunc.getAssignFieldValue(sLocationNameAssignField, sLocationNameDataOne[0], newCopyTo) };
  274 + slaveDataObj = {
  275 + ...slaveDataObj,
  276 + ...onDataRowAdd,
  277 + ...materialsDataDetiale,
  278 + ...sWareHouseNameDataDetiale,
  279 + ...slaveDataObjAdd,
  280 + ...sLocationNameDataDetiale,
  281 + };
  282 + masterdataObj = { ...masterdataObj, ...sLocationNameDataDetiale, ...sWareHouseNameDataDetiale };
  283 + } else if (sModelsType === 'Product') { // 扫码待发货 sales/salesSgoods
  284 + /* 取第一条码 */
  285 + const sDefineNo = codeArr.length > 0 ? codeArr[0] : '';
  286 + /* 如果条码已存在,提示 */
  287 + // const iIndex = commonUtils.isNotEmptyArr(slaveData) ? slaveData.findIndex(item => commonUtils.isNotEmptyObject(item.sDefineNo) && item.sDefineNo === sDefineNo) : -1;
  288 + // if (iIndex > -1) {
  289 + // Toast.fail('条码已存在!!!', 1);
  290 + // return;
  291 + // }
  292 + const dateStr = codeArr.length > 7 && commonUtils.isNotEmptyObject(codeArr[7])? codeArr[7].replace(/-/g, '/') : undefined;
  293 + slaveDataObjAdd = {
  294 + sCustomerShort: codeArr.length > 12 ? codeArr[12] : '',
  295 + sOrderNo: codeArr.length > 13 ? codeArr[13] : '',
  296 + sWorkOrderNo: codeArr.length > 14 ? codeArr[14] : '',
  297 + sCustomerOrderNo: codeArr.length > 15 ? codeArr[15] : '',
  298 + sCustomerProductNo: codeArr.length > 13 ? codeArr[16] : '',
  299 + sDefineNo: codeArr.length > 0 ? codeArr[0] : '',
  300 + sDefineNo2: codeArr.length > 6 ? codeArr[6] : '',
  301 + dProductQty: codeArr.length > 3 ? commonUtils.isNull(Number(codeArr[3]), 0): '',
  302 + tInStoreDate: dateStr,
  303 + };
  304 + masterdataObj = {
  305 + ...masterData, ...slaveDataObjAdd,
  306 + };
  307 + // masterDataObjAdd = {
  308 + // sCustomerShort: codeArr.length > 12 ? codeArr[12] : '', sDefineNo: sDefineNo,
  309 + // };
  310 + /* 读取多条扫码配置 */
  311 + const btnScanConfigs = masterConfig.gdsconfigformslave.filter(item => item.sName === '' && item.sControlName.indexOf('BtnScan.slave') > -1);
  312 + const AssignField = commonUtils.isNotEmptyArr(btnScanConfigs) ? btnScanConfigs[0].sAssignField : '';
  313 + if (commonUtils.isNotEmptyArr(slaveData) && slaveData.length > 0) { /* 拿原始从表值 */
  314 + const len = slaveData.length;
  315 + const sDefineNoNew = slaveData[len - 1].sDefineNo;
  316 + if (commonUtils.isEmptyArr(sDefineNoNew)) {
  317 + slaveDataObj = { ...slaveDataObj, ...slaveData[len - 1] };
  318 + }
  319 + }
  320 + /* 唯一码调接口 */
  321 + let sqlDataRow ={};
  322 + if(commonUtils.isNotEmptyArr(btnScanConfigs)) {
  323 + const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', btnScanConfigs[0], masterdataObj);
  324 + if(commonUtils.isNotEmptyArr(sqlDropDownData)) {
  325 + sqlDataRow = sqlDropDownData[0];
  326 + }
  327 + }
  328 + slaveDataObj = { ...slaveDataObjAdd, ...commonFunc.getAssignFieldValue(AssignField, masterdataObj) }; // 取赋值字段
  329 + if(commonUtils.isNotEmptyObject(sqlDataRow)) {
  330 + slaveDataObj = { ...slaveDataObj, ...commonFunc.getAssignFieldValue(AssignField, sqlDataRow) }; // 取接口数据源赋值字段
  331 + }
  332 + // slaveDataObj.sDefineNo = sDefineNo;
  333 + slaveDataObj.sId = commonUtils.createSid();
  334 + slaveDataObj.iOrder = 1;
  335 + const slaveDataConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave : '';
  336 + const sWareHouseNameConfig = slaveDataConfig.filter(item => item.sName === 'sWareHouseId'); // 仓库名称
  337 + const sLocationNameConfig = slaveDataConfig.filter(item => item.sName === 'sLocationId');// 库区库位
  338 + const sProductNameConfig = slaveDataConfig.filter(item => item.sName === 'sProductId');// 产品名称
  339 +
  340 +
  341 + const onDataRowAdd = this.props.onDataRowAdd(name, true);
  342 + const sWareHouseNameAssignField = commonUtils.isNotEmptyArr(sWareHouseNameConfig) ? sWareHouseNameConfig[0].sAssignField : '';
  343 + const sLocationNameAssignField = commonUtils.isNotEmptyArr(sLocationNameConfig) ? sLocationNameConfig[0].sAssignField : '';
  344 + const sProductNameAssignField = commonUtils.isNotEmptyArr(sProductNameConfig) ? sProductNameConfig[0].sAssignField : '';
  345 +
  346 +
  347 + let sWareHouseNamedropDownData = [];
  348 + let sLocationNamedropDownData = [];
  349 + let sProductNamedropDownData = [];
  350 + if (commonUtils.isNotEmptyObject(sWareHouseNameConfig[0]) && sWareHouseNameConfig[0].sDropDownType === 'sql') {
  351 + sWareHouseNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', sWareHouseNameConfig[0], slaveData);
  352 + }
  353 + if (commonUtils.isNotEmptyObject(sLocationNameConfig[0]) && sLocationNameConfig[0].sDropDownType === 'sql') {
  354 + sLocationNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', sLocationNameConfig[0], masterData);
  355 + }
  356 + if (commonUtils.isNotEmptyObject(sProductNameConfig[0]) && sProductNameConfig[0].sDropDownType === 'sql') {
  357 + sProductNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', sProductNameConfig[0], slaveData);
  358 + }
  359 + let sWareHouseNameDataOne;
  360 + let sLocationNameDataOne;
  361 + let sProductNameDataOne;
  362 + if (!commonUtils.isEmpty(sWareHouseNamedropDownData)) {
  363 + if (codeArr.length > 4) {
  364 + sWareHouseNameDataOne = sWareHouseNamedropDownData.filter(item => item.sName === codeArr[4]);
  365 + }
  366 + }
  367 + if (!commonUtils.isEmpty(sLocationNamedropDownData)) {
  368 + if (codeArr.length > 5) {
  369 + sLocationNameDataOne = sLocationNamedropDownData.filter(item => item.sName === codeArr[5]);
  370 + }
  371 + }
  372 + if (!commonUtils.isEmpty(sProductNamedropDownData)) {
  373 + if (codeArr.length > 1) {
  374 + sProductNameDataOne = sProductNamedropDownData.filter(item => item.sProductName === codeArr[1]);
  375 + }
  376 + }
  377 + const newCopyTo = {};
  378 + newCopyTo.master = masterData;
  379 + newCopyTo.slave = commonUtils.isEmpty(slaveData) ? [] : slaveData[0];
  380 + let sWareHouseNameDataDetiale = {};
  381 + let sLocationNameDataDetiale = {};
  382 + let sProductNameDataDetiale = {};
  383 + sWareHouseNameDataDetiale = { ...commonFunc.getAssignFieldValue(sWareHouseNameAssignField, sWareHouseNameDataOne[0], newCopyTo) };
  384 + sLocationNameDataDetiale = { ...commonFunc.getAssignFieldValue(sLocationNameAssignField, sLocationNameDataOne[0], newCopyTo) };
  385 + sProductNameDataDetiale = { ...commonFunc.getAssignFieldValue(sProductNameAssignField, sProductNameDataOne[0], newCopyTo) };
  386 + slaveDataObj = {
  387 + ...slaveDataObj,
  388 + ...onDataRowAdd,
  389 + ...sWareHouseNameDataDetiale,
  390 + ...slaveDataObjAdd,
  391 + ...sProductNameDataDetiale,
  392 + ...sLocationNameDataDetiale,
  393 + };
  394 + masterdataObj = {
  395 + ...masterData,
  396 + ...sLocationNameDataDetiale,
  397 + ...masterDataObjAdd,
  398 + ...sWareHouseNameDataDetiale,
  399 + };
  400 + } else {
  401 + Toast.fail('二维码不存在!!!', 1);
  402 + }
  403 + if (models !== 'Single') {
  404 + slaveData.unshift(slaveDataObj);
  405 + }
  406 + this.props.onSaveState({ slaveData, masterData: masterdataObj });
  407 + });
  408 + } else if (type === 'scan1') {
  409 + BarCodeUtil.startScan(async (type, code) => {
  410 + const {
  411 + slaveConfig, sModelsId, masterData, slaveData, sModelsType,
  412 + } = this.props;
  413 + // const slaveData = [];
  414 + let slaveDataObj = {};
  415 + let masterdataObj = {};
  416 + let slaveDataObjAdd = {};
  417 + let masterDataObjAdd = {};
  418 + const codeArr = code.split('|');
  419 + if (sModelsType === 'materialsStock/productionmaterials') {
  420 + const dataStr = codeArr[10].replace(/-/g, '/');
  421 + const date = new Date(dataStr);
  422 + slaveDataObjAdd = {
  423 + sMaterialsStyle: codeArr[1],
  424 + sDefineNo: codeArr[4],
  425 + sDefineNo2: codeArr[5],
  426 + dAuxiliaryQty: codeArr[7],
  427 + tInStoreDate: date,
  428 + };
  429 + const slaveDataConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave : '';
  430 + const materialsNameConfig = slaveDataConfig.filter(item => item.sName === 'sMaterialsId');
  431 + const sWareHouseNameConfig = slaveDataConfig.filter(item => item.sName === 'sWareHouseId');
  432 + const sLocationNameConfig = slaveDataConfig.filter(item => item.sName === 'sLocationId');
  433 + const onDataRowAdd = this.props.onDataRowAdd(name, true);
  434 + const materialseAssignField = commonUtils.isNotEmptyArr(materialsNameConfig) ? materialsNameConfig[0].sAssignField : '';
  435 + const sWareHouseNameAssignField = commonUtils.isNotEmptyArr(sWareHouseNameConfig) ? sWareHouseNameConfig[0].sAssignField : '';
  436 + const sLocationNameAssignField = commonUtils.isNotEmptyArr(sLocationNameConfig) ? sLocationNameConfig[0].sAssignField : '';
  437 +
  438 + let materialsNameDropDownData = [];
  439 + let sWareHouseNamedropDownData = [];
  440 + let sLocationNamedropDownData = [];
  441 + if (commonUtils.isNotEmptyObject(materialsNameConfig[0]) && materialsNameConfig[0].sDropDownType === 'sql') {
  442 + materialsNameDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', materialsNameConfig[0], slaveData);
  443 + }
  444 + if (commonUtils.isNotEmptyObject(sWareHouseNameConfig[0]) && sWareHouseNameConfig[0].sDropDownType === 'sql') {
  445 + sWareHouseNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', sWareHouseNameConfig[0], slaveData);
  446 + }
  447 + if (commonUtils.isNotEmptyObject(sLocationNameConfig[0]) && sLocationNameConfig[0].sDropDownType === 'sql') {
  448 + sLocationNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', sLocationNameConfig[0], masterData);
  449 + }
  450 + // }
  451 + let materialsNameDataOne;
  452 + let sWareHouseNameDataOne;
  453 + let sLocationNameDataOne;
  454 + if (!commonUtils.isEmpty(materialsNameDropDownData)) {
  455 + materialsNameDataOne = materialsNameDropDownData.filter(item => item.sMaterialsName === codeArr[6]);
  456 + }
  457 + if (!commonUtils.isEmpty(sWareHouseNamedropDownData)) {
  458 + sWareHouseNameDataOne = sWareHouseNamedropDownData.filter(item => item.sName === codeArr[2]);
  459 + }
  460 + if (!commonUtils.isEmpty(sLocationNamedropDownData)) {
  461 + sLocationNameDataOne = sLocationNamedropDownData.filter(item => item.sName === codeArr[3]);
  462 + }
  463 + const newCopyTo = {};
  464 + newCopyTo.master = masterData;
  465 + newCopyTo.slave = commonUtils.isEmpty(slaveData) ? [] : slaveData[0];
  466 + let materialsDataDetiale = {};
  467 + let sWareHouseNameDataDetiale = {};
  468 + let sLocationNameDataDetiale = {};
  469 + materialsDataDetiale = { ...commonFunc.getAssignFieldValue(materialseAssignField, materialsNameDataOne[0], newCopyTo) };
  470 + sWareHouseNameDataDetiale = { ...commonFunc.getAssignFieldValue(sWareHouseNameAssignField, sWareHouseNameDataOne[0], newCopyTo) };
  471 + sLocationNameDataDetiale = { ...commonFunc.getAssignFieldValue(sLocationNameAssignField, sLocationNameDataOne[0], newCopyTo) };
  472 + slaveDataObj = {
  473 + ...onDataRowAdd,
  474 + ...materialsDataDetiale,
  475 + ...sWareHouseNameDataDetiale,
  476 + ...slaveDataObjAdd,
  477 + ...sLocationNameDataDetiale,
  478 + };
  479 + masterdataObj = { ...masterData, ...sLocationNameDataDetiale, ...sWareHouseNameDataDetiale };
  480 + } else if (sModelsType === 'sales/salesSgoods') { // 扫码待发货
  481 + const dataStr = codeArr[12].replace(/-/g, '/');
  482 + const date = new Date(dataStr);
  483 + slaveDataObjAdd = {
  484 + sOrderNo: codeArr[9],
  485 + sWorkOrderNo: codeArr[8],
  486 + sCustomerOrderNo: codeArr[10],
  487 + sCustomerProductNo: codeArr[11],
  488 + sDefineNo: codeArr[3],
  489 + sDefineNo2: codeArr[4],
  490 + dProductQty: codeArr[6],
  491 + tInStoreDate: date,
  492 + };
  493 + masterDataObjAdd = {
  494 + sCustomerShort: codeArr[7],
  495 + };
  496 + const slaveDataConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave : '';
  497 + const sWareHouseNameConfig = slaveDataConfig.filter(item => item.sName === 'sWareHouseId'); // 仓库名称
  498 + const sLocationNameConfig = slaveDataConfig.filter(item => item.sName === 'sLocationId');// 库区库位
  499 + const sProductNameConfig = slaveDataConfig.filter(item => item.sName === 'sProductId');// 产品名称
  500 +
  501 +
  502 + const onDataRowAdd = this.props.onDataRowAdd(name, true);
  503 + const sWareHouseNameAssignField = commonUtils.isNotEmptyArr(sWareHouseNameConfig) ? sWareHouseNameConfig[0].sAssignField : '';
  504 + const sLocationNameAssignField = commonUtils.isNotEmptyArr(sLocationNameConfig) ? sLocationNameConfig[0].sAssignField : '';
  505 + const sProductNameAssignField = commonUtils.isNotEmptyArr(sProductNameConfig) ? sProductNameConfig[0].sAssignField : '';
  506 +
  507 +
  508 + let sWareHouseNamedropDownData = [];
  509 + let sLocationNamedropDownData = [];
  510 + let sProductNamedropDownData = [];
  511 + if (commonUtils.isNotEmptyObject(sWareHouseNameConfig[0]) && sWareHouseNameConfig[0].sDropDownType === 'sql') {
  512 + sWareHouseNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', sWareHouseNameConfig[0], slaveData);
  513 + }
  514 + if (commonUtils.isNotEmptyObject(sLocationNameConfig[0]) && sLocationNameConfig[0].sDropDownType === 'sql') {
  515 + sLocationNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', sLocationNameConfig[0], masterData);
  516 + }
  517 + if (commonUtils.isNotEmptyObject(sProductNameConfig[0]) && sProductNameConfig[0].sDropDownType === 'sql') {
  518 + sProductNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', sProductNameConfig[0], slaveData);
  519 + }
  520 + let sWareHouseNameDataOne;
  521 + let sLocationNameDataOne;
  522 + let sProductNameDataOne;
  523 + if (!commonUtils.isEmpty(sWareHouseNamedropDownData)) {
  524 + sWareHouseNameDataOne = sWareHouseNamedropDownData.filter(item => item.sName === codeArr[1]);
  525 + }
  526 + if (!commonUtils.isEmpty(sLocationNamedropDownData)) {
  527 + sLocationNameDataOne = sLocationNamedropDownData.filter(item => item.sName === codeArr[2]);
  528 + }
  529 + if (!commonUtils.isEmpty(sProductNamedropDownData)) {
  530 + sProductNameDataOne = sProductNamedropDownData.filter(item => item.sProductName === codeArr[5]);
  531 + }
  532 + const newCopyTo = {};
  533 + newCopyTo.master = masterData;
  534 + newCopyTo.slave = commonUtils.isEmpty(slaveData) ? [] : slaveData[0];
  535 + let sWareHouseNameDataDetiale = {};
  536 + let sLocationNameDataDetiale = {};
  537 + let sProductNameDataDetiale = {};
  538 + sWareHouseNameDataDetiale = { ...commonFunc.getAssignFieldValue(sWareHouseNameAssignField, sWareHouseNameDataOne[0], newCopyTo) };
  539 + sLocationNameDataDetiale = { ...commonFunc.getAssignFieldValue(sLocationNameAssignField, sLocationNameDataOne[0], newCopyTo) };
  540 + sProductNameDataDetiale = { ...commonFunc.getAssignFieldValue(sProductNameAssignField, sProductNameDataOne[0], newCopyTo) };
  541 + slaveDataObj = {
  542 + ...onDataRowAdd,
  543 + ...sWareHouseNameDataDetiale,
  544 + ...slaveDataObjAdd,
  545 + ...sProductNameDataDetiale,
  546 + ...sLocationNameDataDetiale,
  547 + };
  548 + masterdataObj = {
  549 + ...masterData,
  550 + ...sLocationNameDataDetiale,
  551 + ...masterDataObjAdd,
  552 + ...sWareHouseNameDataDetiale,
  553 + };
  554 + } else if (sModelsType === 'purchase/purchaseInstore' || sModelsType === 'scan/productionmaterials') { /* 扫码入库、扫码领料(唯一码) */
  555 + const { masterConfig } = this.props;
  556 + /* 取第一条码 */
  557 + const sDefineNo = codeArr[0];
  558 + /* 如果条码已存在,提示 */
  559 + const iIndex = slaveData.findIndex(item => commonUtils.isNotEmptyObject(item.sDefineNo) && item.sDefineNo === sDefineNo);
  560 + if (iIndex > -1) {
  561 + Toast.fail('条码已存在!!!', 1);
  562 + return;
  563 + }
  564 + masterdataObj = {
  565 + ...masterData,
  566 + };
  567 + /* 读取扫码配置 */
  568 + const btnScanConfigs = masterConfig.gdsconfigformslave.filter(item => item.sName === '' && item.sControlName.indexOf('BtnScan') > -1);
  569 + const AssignField = commonUtils.isNotEmptyArr(btnScanConfigs) ? btnScanConfigs[0].sAssignField : '';
  570 + if (commonUtils.isNotEmptyArr(slaveData) && slaveData.length > 0) { /* 拿原始从表值 */
  571 + const len = slaveData.length;
  572 + const sDefineNoNew = slaveData[len - 1].sDefineNo;
  573 + if (commonUtils.isEmptyArr(sDefineNoNew)) {
  574 + slaveDataObj = { ...slaveDataObj, ...slaveData[len - 1] };
  575 + }
  576 + }
  577 + slaveDataObj = { ...slaveDataObj, ...commonFunc.getAssignFieldValue(AssignField, masterData) }; // 取赋值字段
  578 + slaveDataObj.sDefineNo = sDefineNo;
  579 + slaveDataObj.sId = commonUtils.createSid();
  580 + if (commonUtils.isNotEmptyArr(slaveData)) {
  581 + const len = slaveData.length;
  582 + const sDefineNoNew = slaveData[len - 1].sDefineNo;
  583 + const { handleType } = slaveData[len - 1];
  584 + /* 若slaveData 最后一条数据没有条形码,则赋值条形码;否则新增一条数据 */
  585 + if (commonUtils.isEmptyArr(sDefineNoNew)) {
  586 + slaveDataObj.handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
  587 + slaveData[len - 1] = slaveDataObj;
  588 + } else {
  589 + slaveDataObj.handleType = 'add';
  590 + slaveData.unshift(slaveDataObj);
  591 + }
  592 + } else {
  593 + slaveDataObj.handleType = 'add';
  594 + slaveData.unshift(slaveDataObj);
  595 + }
  596 + if (sModelsType === 'scan/productionmaterials') { /* 只有扫码领料连续扫码 */
  597 + this.handleClick('slave', 'scan'); /* 连续扫码 */
  598 + }
  599 + } else {
  600 + Toast.fail('二维码不存在!!!', 1);
  601 + }
  602 + if (sModelsType !== 'purchase/purchaseInstore' && sModelsType !== 'scan/productionmaterials') {
  603 + slaveData.unshift(slaveDataObj);
  604 + }
  605 + this.props.onSaveState({ slaveData, masterData: masterdataObj });
  606 + });
  607 + } else if (commonUtils.isNotEmptyObject(name) && name.includes('BtnScan')) { /* 主表 扫流转码 */
  608 + BarCodeUtil.startScan(async (type, code) => {
  609 + const { masterConfig } = this.props;
  610 + let { masterData } = this.props;
  611 + let masterdataObj = {};
  612 + const codeArr = code.split('|');
  613 + if (commonUtils.isNotEmptyObject(codeArr)) { /* 扫流转码功能 */
  614 + /* 取第一条码 */
  615 + const sDefineNo = codeArr[0];
  616 + /* 如果条码已存在,提示 */
  617 + masterData.sDefineNo = sDefineNo;
  618 + masterdataObj = {
  619 + ...masterData,
  620 + };
  621 + /* 读取扫码配置 */
  622 + const btnScanConfigs = masterConfig.gdsconfigformslave.filter(item => item.sName === '' && item.bVisible && item.sControlName.indexOf('BtnScan') > -1);
  623 + const AssignField = commonUtils.isNotEmptyArr(btnScanConfigs) ? btnScanConfigs[0].sAssignField : '';
  624 + masterData = { ...masterdataObj, ...commonFunc.getAssignFieldValue(AssignField, masterData) }; // 取赋值字段
  625 + masterData.handleType = commonUtils.isEmpty(masterData.handleType) ? 'update' : masterData.handleType;
  626 + // this.handleClick('slave', 'scan'); /* 连续扫码 */
  627 + } else {
  628 + Toast.fail('二维码不存在!!!', 1);
  629 + }
  630 + this.props.onSaveState({ masterData });
  631 + });
  632 + } else if (name === 'BtnCamera') { /* 手机调动摄像头拍照 */
  633 + this.handleCamera();
  634 + } else if (name === 'BtnPhoto') { /* 手机相册选择图片 */
  635 + this.handleGetPhoto();
  636 + } else if (name === 'BtnCancel') {
  637 + window.history.back(-1);
  638 + } else if (name === 'BtnExamine') {
  639 + this.props.onAudit(1);
  640 + } else if (name === 'BtnCancelExamine') {
  641 + /* 销审 */
  642 + this.props.onAudit(0);
  643 + } else if (name && name.includes('BtnCalc')) { /* 实现通用计算功能 */
  644 + const { masterConfig, masterData, sModelsId, } = this.props;
  645 + const btnConfig = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => (item.sControlName === name))) ?
  646 + masterConfig.gdsconfigformslave.filter(item => (item.sControlName === name))[0] : {};// sButtonEnabled sButtonParam
  647 + if(commonUtils.isNotEmptyObject(btnConfig)) {
  648 + /* 组装allTableData */
  649 + const allTableMap ={};
  650 + const allReturnMap ={};
  651 + const slaveNameList = [];
  652 + /* 从props找到 所有的Config */
  653 + if(commonUtils.isNotEmptyArr(this.props)) {
  654 + for (const key of Object.keys(this.props)) {
  655 + if(key.includes('Config') && !key.includes('onGet') && !key.includes('report')) {
  656 + const tablename = key.replace('Config', '').trim();
  657 + slaveNameList.push(tablename);
  658 + }
  659 + }
  660 + }
  661 +
  662 + if (commonUtils.isNotEmptyArr(slaveNameList)) {
  663 + slaveNameList.forEach((name, index) => {
  664 + const tableConfig = this.props[name +'Config']; /* 动态配置 */
  665 + const tableData = this.props[name +'Data']; /* 动态配置 */
  666 + const tableSelectedRowKeys = this.props[name + 'SelectedRowKeys']; /* 选中Key */
  667 + if(commonUtils.isNotEmptyObject(tableConfig)) {
  668 + allTableMap[name +'.'+ tableConfig.sTbName] = tableData
  669 + }
  670 +
  671 + })
  672 + const masterTbName = masterConfig.sTbName;
  673 + allTableMap['master.'+ masterTbName] = masterData;
  674 + }
  675 + const sButtonParam = btnConfig.sButtonParam;
  676 + const btn = commonUtils.isJSON(sButtonParam) ? JSON.parse(sButtonParam) : '';
  677 + const sProName = btn.sproName;
  678 + const url = `${commonConfig.server_host}calcprocedure/calc?sModelsId=${sModelsId}`;
  679 + const value = {
  680 + sProName,
  681 + sButtonParam,
  682 + allTableMap
  683 + };
  684 + const dataReturn = (await commonServices.postValueService(this.props.app.token, value, url)).data;
  685 + if (dataReturn.code === 1) {
  686 + /* 数据操作 数据回传页面 */
  687 + message.success('操作成功!');
  688 + const returnData = dataReturn.dataset.rows[0];
  689 + if (commonUtils.isNotEmptyArr(slaveNameList) && commonUtils.isNotEmptyObject(returnData)) {
  690 + slaveNameList.forEach((name, index) => {
  691 + const tableConfig = this.props[name +'Config']; /* 动态配置 */
  692 + let tableDelData = this.props[name +'DelData'];
  693 + if(commonUtils.isEmptyArr(tableDelData)) {
  694 + tableDelData = [];
  695 + }
  696 + let tableDelDataNew = []
  697 + let tableData = [];
  698 + if(commonUtils.isNotEmptyObject(tableConfig)) {
  699 + tableData = returnData[name +'.'+ tableConfig.sTbName]; /* 动态配置 */
  700 + if(commonUtils.isNotEmptyArr(tableData) && Array.isArray(tableData)) {
  701 + tableDelDataNew = tableData.filter(item => item.handleType === 'del');
  702 + tableData = tableData.filter(item => item.handleType !== 'del');
  703 + tableDelData = tableDelData.concat(tableDelDataNew);
  704 + }
  705 +
  706 + }
  707 + allReturnMap[name +'Data'] = tableData;
  708 + allReturnMap[name +'DelData'] = tableDelData;
  709 + });
  710 + const masterTbName = masterConfig.sTbName;
  711 + allReturnMap.masterData = returnData['master.'+ masterTbName];
  712 + allReturnMap.masterData.enabled = true;
  713 + }
  714 + this.props.onSaveState({ ...allReturnMap });
  715 + }else if (dataReturn.code === -8 || dataReturn.code === 2) {
  716 + Modal.info({
  717 + title: '温馨提示:',
  718 + content: (
  719 + <div>
  720 + {this.handleGetMsg(dataReturn.msg)}
  721 + </div>
  722 + ),
  723 + okText: '确认',
  724 + onOk() {},
  725 + });
  726 + } else { /* 失败 */
  727 + this.props.getServiceError(dataReturn);
  728 + }
  729 +
  730 + }
  731 + }
  732 + }
  733 + handleCamera = () => {
  734 + BarCodeUtil.getImage();
  735 + }
  736 + handleGetPhoto = () => {
  737 + BarCodeUtil.getPhoto();
  738 + }
  739 +
  740 + handleGetWxCode = async (successHandler) => {
  741 + let scanResult = '';
  742 + const { app } = this.props;
  743 + // eslint-disable-next-line prefer-destructuring,no-unused-vars
  744 + const userinfo = app.userinfo;
  745 + const myUrl = location.href;
  746 + const configUrl = `${commonConfig.server_host}wechat/getWxToken`;
  747 + const values = {
  748 + url: myUrl,
  749 + sBrandsId: userinfo.sBrandsId,
  750 + sSubsidiaryId: userinfo.sSubsidiaryId,
  751 + };
  752 + // const values = {
  753 + // url: myUrl,
  754 + // sBrandsId: '1111111111',
  755 + // sSubsidiaryId: '1111111111',
  756 + // };
  757 + const configReturn = (await commonServices.postValueService(null, values, configUrl)).data;
  758 + console.log('configReturn::', configReturn, values);
  759 + if (configReturn.code === 1) {
  760 + const { rows } = configReturn.dataset;/* 获取费用分摊单据配置 */
  761 + if (commonUtils.isNotEmptyArr(rows)) {
  762 + const appId = rows[0].appId.toString();
  763 + const nonceStr = rows[0].nonceStr.toString();
  764 + const signature = rows[0].signature.toString();
  765 + const timestamp = rows[0].timestamp.toString();
  766 + weixin.config({
  767 + beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
  768 + debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  769 + appId, // 必填,公众号的唯一标识
  770 + timestamp, // 必填,生成签名的时间戳 <%= Html.Encode(ViewData["timestamp" ]) %>
  771 + nonceStr, // 必填,生成签名的随机串
  772 + signature, // 必填,签名
  773 + jsApiList: ['checkJsApi', 'scanQRCode'], // 必填,需要使用的JS接口列表, 这里只需要调用扫一扫
  774 + });
  775 + weixin.ready(() => {
  776 + weixin.checkJsApi({ // 判断当前客户端版本是否支持指定JS接口
  777 + jsApiList: ['scanQRCode'],
  778 + success(res) { // 以键值对的形式返回,可用true,不可用false。如:{"checkResult":{"scanQRCode":true},"errMsg":"checkJsApi:ok"}
  779 + console.log(res);
  780 + if (res.checkResult.scanQRCode !== true) {
  781 + Toast.fail(`URL不对,当前URL:${myUrl}请使用正式地址!`);
  782 + }
  783 + },
  784 + // eslint-disable-next-line no-unused-vars
  785 + fail(res) { // 检测getNetworkType该功能失败时处理
  786 + Toast.fail('checkJsApi error');
  787 + },
  788 +
  789 +
  790 + }); // wx.ready结束
  791 + weixin.scanQRCode({
  792 + desc: 'scanQRCode desc',
  793 + needResult: 0, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
  794 + scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
  795 + success(res) {
  796 + // console.log("调用扫描成功",res);
  797 + scanResult = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
  798 + if (commonUtils.isNotEmptyObject(scanResult)) {
  799 + const codeResult = scanResult.split(',');
  800 + if (codeResult.length > 1) {
  801 + scanResult = codeResult[1];
  802 + }
  803 + }
  804 + successHandler(scanResult);
  805 + // console.log('微信扫码结果:', scanResult);
  806 + },
  807 + error(res) {
  808 + // console.log(res);
  809 + if (res.errMsg.indexOf('function_not_exist') > 0) {
  810 + Toast.fail('版本过低请升级');
  811 + }
  812 + },
  813 + });
  814 + });
  815 + } else {
  816 + Toast.fail(configReturn.msg);
  817 + }
  818 + } else {
  819 + Toast.fail(configReturn.msg);
  820 + }
  821 + return scanResult;
  822 + }
  823 +
  824 + handleWxScan = async () => {
  825 + this.handleGetWxCode((code) => {
  826 + if (!commonUtils.isEmpty(code)) {
  827 + this.handleWxBusiness(code);
  828 + }
  829 + });
  830 + }
  831 +
  832 + handleWxBusiness = async (code) => {
  833 + const {
  834 + slaveConfig, sModelsId, masterData, slaveData, sModelsType,
  835 + } = this.props;
  836 + // const slaveData = [];
  837 + let slaveDataObj = {};
  838 + let masterdataObj = {};
  839 + let slaveDataObjAdd = {};
  840 + let masterDataObjAdd = {};
  841 + const codeArr = code.split('|');
  842 + if (sModelsType === 'materialsStock/productionmaterials') {
  843 + const dataStr = codeArr[10].replace(/-/g, '/');
  844 + const date = new Date(dataStr);
  845 + slaveDataObjAdd = {
  846 + sMaterialsStyle: codeArr[1],
  847 + sDefineNo: codeArr[4],
  848 + sDefineNo2: codeArr[5],
  849 + dAuxiliaryQty: codeArr[7],
  850 + tInStoreDate: date,
  851 + };
  852 + const slaveDataConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave : '';
  853 + const materialsNameConfig = slaveDataConfig.filter(item => item.sName === 'sMaterialsId');
  854 + const sWareHouseNameConfig = slaveDataConfig.filter(item => item.sName === 'sWareHouseId');
  855 + const sLocationNameConfig = slaveDataConfig.filter(item => item.sName === 'sLocationId');
  856 + const onDataRowAdd = this.props.onDataRowAdd(name, true);
  857 + const materialseAssignField = commonUtils.isNotEmptyArr(materialsNameConfig) ? materialsNameConfig[0].sAssignField : '';
  858 + const sWareHouseNameAssignField = commonUtils.isNotEmptyArr(sWareHouseNameConfig) ? sWareHouseNameConfig[0].sAssignField : '';
  859 + const sLocationNameAssignField = commonUtils.isNotEmptyArr(sLocationNameConfig) ? sLocationNameConfig[0].sAssignField : '';
  860 +
  861 + let materialsNameDropDownData = [];
  862 + let sWareHouseNamedropDownData = [];
  863 + let sLocationNamedropDownData = [];
  864 + if (commonUtils.isNotEmptyObject(materialsNameConfig[0]) && materialsNameConfig[0].sDropDownType === 'sql') {
  865 + materialsNameDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', materialsNameConfig[0], slaveData);
  866 + }
  867 + if (commonUtils.isNotEmptyObject(sWareHouseNameConfig[0]) && sWareHouseNameConfig[0].sDropDownType === 'sql') {
  868 + sWareHouseNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', sWareHouseNameConfig[0], slaveData);
  869 + }
  870 + if (commonUtils.isNotEmptyObject(sLocationNameConfig[0]) && sLocationNameConfig[0].sDropDownType === 'sql') {
  871 + sLocationNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', sLocationNameConfig[0], masterData);
  872 + }
  873 + // }
  874 + let materialsNameDataOne;
  875 + let sWareHouseNameDataOne;
  876 + let sLocationNameDataOne;
  877 + if (!commonUtils.isEmpty(materialsNameDropDownData)) {
  878 + materialsNameDataOne = materialsNameDropDownData.filter(item => item.sMaterialsName === codeArr[6]);
  879 + }
  880 + if (!commonUtils.isEmpty(sWareHouseNamedropDownData)) {
  881 + sWareHouseNameDataOne = sWareHouseNamedropDownData.filter(item => item.sName === codeArr[2]);
  882 + }
  883 + if (!commonUtils.isEmpty(sLocationNamedropDownData)) {
  884 + sLocationNameDataOne = sLocationNamedropDownData.filter(item => item.sName === codeArr[3]);
  885 + }
  886 + const newCopyTo = {};
  887 + newCopyTo.master = masterData;
  888 + newCopyTo.slave = commonUtils.isEmpty(slaveData) ? [] : slaveData[0];
  889 + let materialsDataDetiale = {};
  890 + let sWareHouseNameDataDetiale = {};
  891 + let sLocationNameDataDetiale = {};
  892 + materialsDataDetiale = { ...commonFunc.getAssignFieldValue(materialseAssignField, materialsNameDataOne[0], newCopyTo) };
  893 + sWareHouseNameDataDetiale = { ...commonFunc.getAssignFieldValue(sWareHouseNameAssignField, sWareHouseNameDataOne[0], newCopyTo) };
  894 + sLocationNameDataDetiale = { ...commonFunc.getAssignFieldValue(sLocationNameAssignField, sLocationNameDataOne[0], newCopyTo) };
  895 + slaveDataObj = {
  896 + ...onDataRowAdd,
  897 + ...materialsDataDetiale,
  898 + ...sWareHouseNameDataDetiale,
  899 + ...slaveDataObjAdd,
  900 + ...sLocationNameDataDetiale,
  901 + };
  902 + masterdataObj = { ...masterData, ...sLocationNameDataDetiale, ...sWareHouseNameDataDetiale };
  903 + } else if (sModelsType === 'sales/salesSgoods') { // 扫码待发货
  904 + const dataStr = codeArr[12].replace(/-/g, '/');
  905 + const date = new Date(dataStr);
  906 + slaveDataObjAdd = {
  907 + sOrderNo: codeArr[9],
  908 + sWorkOrderNo: codeArr[8],
  909 + sCustomerOrderNo: codeArr[10],
  910 + sCustomerProductNo: codeArr[11],
  911 + sDefineNo: codeArr[3],
  912 + sDefineNo2: codeArr[4],
  913 + dProductQty: codeArr[6],
  914 + tInStoreDate: date,
  915 + };
  916 + masterDataObjAdd = {
  917 + sCustomerShort: codeArr[7],
  918 + };
  919 + const slaveDataConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave : '';
  920 + const sWareHouseNameConfig = slaveDataConfig.filter(item => item.sName === 'sWareHouseId'); // 仓库名称
  921 + const sLocationNameConfig = slaveDataConfig.filter(item => item.sName === 'sLocationId');// 库区库位
  922 + const sProductNameConfig = slaveDataConfig.filter(item => item.sName === 'sProductId');// 产品名称
  923 +
  924 +
  925 + const onDataRowAdd = this.props.onDataRowAdd(name, true);
  926 + const sWareHouseNameAssignField = commonUtils.isNotEmptyArr(sWareHouseNameConfig) ? sWareHouseNameConfig[0].sAssignField : '';
  927 + const sLocationNameAssignField = commonUtils.isNotEmptyArr(sLocationNameConfig) ? sLocationNameConfig[0].sAssignField : '';
  928 + const sProductNameAssignField = commonUtils.isNotEmptyArr(sProductNameConfig) ? sProductNameConfig[0].sAssignField : '';
  929 +
  930 +
  931 + let sWareHouseNamedropDownData = [];
  932 + let sLocationNamedropDownData = [];
  933 + let sProductNamedropDownData = [];
  934 + if (commonUtils.isNotEmptyObject(sWareHouseNameConfig[0]) && sWareHouseNameConfig[0].sDropDownType === 'sql') {
  935 + sWareHouseNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', sWareHouseNameConfig[0], slaveData);
  936 + }
  937 + if (commonUtils.isNotEmptyObject(sLocationNameConfig[0]) && sLocationNameConfig[0].sDropDownType === 'sql') {
  938 + sLocationNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', sLocationNameConfig[0], masterData);
  939 + }
  940 + if (commonUtils.isNotEmptyObject(sProductNameConfig[0]) && sProductNameConfig[0].sDropDownType === 'sql') {
  941 + sProductNamedropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', sProductNameConfig[0], slaveData);
  942 + }
  943 + let sWareHouseNameDataOne;
  944 + let sLocationNameDataOne;
  945 + let sProductNameDataOne;
  946 + if (!commonUtils.isEmpty(sWareHouseNamedropDownData)) {
  947 + sWareHouseNameDataOne = sWareHouseNamedropDownData.filter(item => item.sName === codeArr[1]);
  948 + }
  949 + if (!commonUtils.isEmpty(sLocationNamedropDownData)) {
  950 + sLocationNameDataOne = sLocationNamedropDownData.filter(item => item.sName === codeArr[2]);
  951 + }
  952 + if (!commonUtils.isEmpty(sProductNamedropDownData)) {
  953 + sProductNameDataOne = sProductNamedropDownData.filter(item => item.sProductName === codeArr[5]);
  954 + }
  955 + const newCopyTo = {};
  956 + newCopyTo.master = masterData;
  957 + newCopyTo.slave = commonUtils.isEmpty(slaveData) ? [] : slaveData[0];
  958 + let sWareHouseNameDataDetiale = {};
  959 + let sLocationNameDataDetiale = {};
  960 + let sProductNameDataDetiale = {};
  961 + sWareHouseNameDataDetiale = { ...commonFunc.getAssignFieldValue(sWareHouseNameAssignField, sWareHouseNameDataOne[0], newCopyTo) };
  962 + sLocationNameDataDetiale = { ...commonFunc.getAssignFieldValue(sLocationNameAssignField, sLocationNameDataOne[0], newCopyTo) };
  963 + sProductNameDataDetiale = { ...commonFunc.getAssignFieldValue(sProductNameAssignField, sProductNameDataOne[0], newCopyTo) };
  964 + slaveDataObj = {
  965 + ...onDataRowAdd,
  966 + ...sWareHouseNameDataDetiale,
  967 + ...slaveDataObjAdd,
  968 + ...sProductNameDataDetiale,
  969 + ...sLocationNameDataDetiale,
  970 + };
  971 + masterdataObj = {
  972 + ...masterData,
  973 + ...sLocationNameDataDetiale,
  974 + ...masterDataObjAdd,
  975 + ...sWareHouseNameDataDetiale,
  976 + };
  977 + } else if (sModelsType === 'purchase/purchaseInstore' || sModelsType === 'scan/productionmaterials') { /* 扫码入库、扫码领料(唯一码) */
  978 + const { masterConfig } = this.props;
  979 + /* 取第一条码 */
  980 + const sDefineNo = codeArr[0];
  981 + /* 如果条码已存在,提示 */
  982 + const iIndex = slaveData.findIndex(item => commonUtils.isNotEmptyObject(item.sDefineNo) && item.sDefineNo === sDefineNo);
  983 + if (iIndex > -1) {
  984 + Toast.fail('条码已存在!!!', 1);
  985 + return;
  986 + }
  987 + masterdataObj = {
  988 + ...masterData,
  989 + };
  990 + /* 读取扫码配置 */
  991 + const btnScanConfigs = masterConfig.gdsconfigformslave.filter(item => item.sName === '' && item.bVisible && item.sControlName.indexOf('BtnScan') > -1);
  992 + const AssignField = commonUtils.isNotEmptyArr(btnScanConfigs) ? btnScanConfigs[0].sAssignField : '';
  993 + slaveDataObj = { ...slaveDataObj, ...commonFunc.getAssignFieldValue(AssignField, masterData) }; // 取赋值字段
  994 + slaveDataObj.sDefineNo = sDefineNo;
  995 + slaveDataObj.sId = commonUtils.createSid();
  996 + if (commonUtils.isNotEmptyArr(slaveData)) {
  997 + const len = slaveData.length;
  998 + const sDefineNoNew = slaveData[len - 1].sDefineNo;
  999 + const { handleType } = slaveData[len - 1];
  1000 + /* 若slaveData 最后一条数据没有条形码,则赋值条形码;否则新增一条数据 */
  1001 + if (commonUtils.isEmptyArr(sDefineNoNew)) {
  1002 + slaveDataObj.handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
  1003 + slaveData[len - 1] = slaveDataObj;
  1004 + } else {
  1005 + slaveDataObj.handleType = 'add';
  1006 + slaveData.push(slaveDataObj);
  1007 + }
  1008 + } else {
  1009 + slaveDataObj.handleType = 'add';
  1010 + slaveData.push(slaveDataObj);
  1011 + }
  1012 + this.handleClick('slave', 'scan'); /* 连续扫码 */
  1013 + } else {
  1014 + Toast.fail('二维码不存在!!!', 1);
  1015 + }
  1016 + if (sModelsType !== 'purchase/purchaseInstore' && sModelsType !== 'scan/productionmaterials') {
  1017 + slaveData.push(slaveDataObj);
  1018 + }
  1019 + this.props.onSaveState({ slaveData, masterData: masterdataObj });
  1020 + }
  1021 +
  1022 + getViewValue = (showConfig, record) => {
  1023 + let sValue = record === undefined ? undefined : record[showConfig.sName];
  1024 + if (showConfig.sDropDownType === 'const') {
  1025 + let showDropDown = [];
  1026 + if (typeof showConfig.showDropDown === 'object') {
  1027 + // eslint-disable-next-line prefer-destructuring
  1028 + showDropDown = showConfig.showDropDown;
  1029 + } else {
  1030 + showDropDown = commonUtils.objectToArr(commonUtils.convertStrToObj(showConfig.showDropDown));
  1031 + }
  1032 + let iIndex = commonUtils.isEmpty(record[showConfig.sName]) ? -1 : showDropDown.findIndex(item => item.sId === record[showConfig.sName].toString());
  1033 + if (iIndex === -1 && record[showConfig.sName] === '') {
  1034 + iIndex = showDropDown.findIndex(item => item.sId === '');
  1035 + }
  1036 + sValue = iIndex > -1 ? showDropDown[iIndex].value : record[showConfig.sName];
  1037 + }
  1038 + return sValue;
  1039 + };
  1040 +
  1041 + render() {
  1042 + const {
  1043 + slaveConfig, slaveData: slaveDataOld, sModelsId, enabled, app, sUseInfo, onReturnForm, masterData, masterConfig,
  1044 + } = this.props;
  1045 + onReturnForm(this.props.form);
  1046 + const slaveDataOld2 = slaveDataOld === undefined ? [] : slaveDataOld;
  1047 + const slaveData = dataSource.cloneWithRows(slaveDataOld2);
  1048 + const f1 = commonUtils.isEmptyObject(masterConfig) ? {} : masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1)[0];
  1049 + const f2 = commonUtils.isEmptyObject(masterConfig) ? {} : masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1)[1];
  1050 + const f3 = commonUtils.isEmptyObject(masterConfig) ? {} : masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1)[2];
  1051 + const f4 = commonUtils.isEmptyObject(masterConfig) ? {} : masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1)[3];
  1052 + const f5 = commonUtils.isEmptyObject(masterConfig) ? {} : masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1)[4];
  1053 + const f6 = commonUtils.isEmptyObject(masterConfig) ? {} : masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1)[5];
  1054 + const f7 = commonUtils.isEmptyObject(masterConfig) ? {} : masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1)[6];
  1055 + const f8 = commonUtils.isEmptyObject(masterConfig) ? {} : masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1)[7];
  1056 + const f9 = commonUtils.isEmptyObject(masterConfig) ? {} : masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1)[8];
  1057 + const f10 = commonUtils.isEmptyObject(masterConfig) ? {} : masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1)[9];
  1058 +
  1059 + const dWidth = document.documentElement.clientWidth || document.body.clientWidth; /* 获取手机视窗宽度 */
  1060 + const dHeight = document.documentElement.clientHeight || document.body.clientHeight; /* 获取手机视窗宽度 */
  1061 + const formItemLayout = { labelCol: { span: 2 }, wrapperCol: { span: 18 } };
  1062 + const style = {
  1063 + display: 'flex',
  1064 + justifyContent: 'center',
  1065 + alignItems: 'center',
  1066 + };
  1067 + const btnStyle = {
  1068 + fontSize: '15px',
  1069 + backgroundColor: '#f0f0f0',
  1070 + display: 'flex',
  1071 + justifyContent: 'center',
  1072 + alignItems: 'center',
  1073 + };
  1074 + const BtnStyle = {
  1075 + type: 'default',
  1076 + color: 'red',
  1077 + border: 'none',
  1078 + backgroundColor: '#f0f0f0',
  1079 + fontSize: '15px',
  1080 + };
  1081 + const divStyle = {
  1082 + display: 'flex',
  1083 + justifyContent: 'space-between',
  1084 + background: ' #f0f0f0',
  1085 + };
  1086 + const row = (rowData, sectionID, rowID) => {
  1087 + return (
  1088 + <div style={{ backgroundColor: '#f0f0f0' }} key={rowID}>
  1089 + <Flex className={styles.ProcessReportMobile}>
  1090 + {/* eslint-disable-next-line react/jsx-no-duplicate-props */}
  1091 + {
  1092 + slaveConfig.gdsconfigformslave.filter(item => item.sControlName === 'BtnChildrenAdd' && item.bVisible).length ?
  1093 + <Flex.Item style={style}>
  1094 + <Button type="button" inline disabled={!enabled} onClick={this.handleClick.bind(this, 'slave', 'add')} style={btnStyle}>
  1095 + 增加
  1096 + <img src={add} className={styles.iconStyle} style={!enabled ? { opacity: 0.3 } : { opacity: 1 }} alt="add" />
  1097 + </Button>
  1098 + </Flex.Item> : ''
  1099 + }
  1100 + {
  1101 + slaveConfig && slaveConfig.gdsconfigformslave.filter(item => item.sControlName === 'BtnChildrenScan' && item.bVisible).length ?
  1102 + <Flex.Item style={style}>
  1103 + <Button type="button" inline disabled={!enabled} onClick={this.handleClick.bind(this, 'slave', 'scan')} style={btnStyle}>
  1104 + 扫码
  1105 + <img src={scan} className={styles.iconStyle} style={!enabled ? { opacity: 0.3 } : { opacity: 1 }} alt="scan" />
  1106 + </Button>
  1107 + </Flex.Item> : ''
  1108 + }
  1109 + {
  1110 + slaveConfig && slaveConfig.gdsconfigformslave.filter(item => item.sControlName === 'BtnChildrenDel' && item.bVisible).length ?
  1111 + <Flex.Item style={style}>
  1112 + <Button type="button" inline disabled={!enabled} onClick={this.handleClick.bind(this, 'slave', 'del', rowData.sId)} style={btnStyle}>
  1113 + 删除
  1114 + <img src={close} className={styles.iconStyle} style={!enabled ? { opacity: 0.3 } : { opacity: 1 }} alt="close" />
  1115 + </Button>
  1116 + </Flex.Item> : ''
  1117 + }
  1118 + </Flex>
  1119 + {commonUtils.isEmptyObject(slaveConfig) ? '' : slaveConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '').map((child) => {
  1120 + const sMemo = child.sName.toLowerCase().endsWith('memo');
  1121 + // sUseInfo是指被其他单据调用,或者被审核
  1122 + let enabledNew = (enabled && !child.bReadonly && !child.specialControl && commonUtils.isEmpty(sUseInfo));
  1123 + if (child.iTag === 1) {
  1124 + enabledNew = false;
  1125 + } else if (child.iTag === 3) {
  1126 + enabledNew = true;
  1127 + }
  1128 + const showTypeProps = {
  1129 + app,
  1130 + masterData,
  1131 + record: rowData,
  1132 + sId: rowData.sId, /* 修改当前编号(数据格式:字符串) */
  1133 + name: 'slave',
  1134 + form: this.props.form,
  1135 + formId: sModelsId,
  1136 + getSqlDropDownData: this.props.getSqlDropDownData,
  1137 + getSqlCondition: this.props.getSqlCondition,
  1138 + handleSqlDropDownNewRecord: this.props.handleSqlDropDownNewRecord,
  1139 + getFloatNum: this.props.getFloatNum,
  1140 + getDateFormat: this.props.getDateFormat,
  1141 + onChange: this.props.onDataChange,
  1142 + showConfig: child,
  1143 + formItemLayout: sMemo ? formItemLayout : {},
  1144 + textArea: sMemo,
  1145 + enabled: enabledNew,
  1146 + dataValue: rowData[child.sName],
  1147 + bTable: true,
  1148 + onFilterDropDownData: this.props.onFilterDropDownData,
  1149 + onSaveState: this.props.onSaveState,
  1150 + };
  1151 + return (
  1152 + <ShowType {...showTypeProps} />
  1153 + );
  1154 + })}
  1155 + {slaveConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName.includes('spicture')).map((item) => {
  1156 + if (item.sName.includes('spicture') && commonUtils.isNotEmptyObject(rowData.spicture)) {
  1157 + const { token } = app;
  1158 + let imgBox = '';
  1159 + const picAddr = commonUtils.isNotEmptyObject(rowData.spicture) ? rowData.spicture.split(',') : '';
  1160 + const previewImageArr = [];
  1161 + if (commonUtils.isNotEmptyArr(picAddr)) {
  1162 + picAddr.forEach((item) => {
  1163 + const dataPreviewUrl = `${commonConfig.file_host}file/download?savePathStr=${item}&width=${dWidth}&&height=${dHeight}&sModelsId=100&token=${token}`; /* 预览 */
  1164 + previewImageArr.push(dataPreviewUrl);
  1165 + });
  1166 + const dataUrl = `${commonConfig.file_host}file/download?savePathStr=${picAddr[0]}&width=60&&height=60&sModelsId=100&token=${token}`; /* 缩略图 */
  1167 + // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
  1168 + imgBox = <div className="spictureStyle" key={rowID}> <img src={dataUrl} alt="img" onFocus={() => 0} onClick={e => preView(previewImageArr, e)} /></div>;
  1169 + }
  1170 + return imgBox;
  1171 + } else {
  1172 + return '';
  1173 + }
  1174 + })}
  1175 + </div>
  1176 + );
  1177 + };
  1178 + return (
  1179 + <div className="commobileBillContainer">
  1180 + <div style={{ padding: '5px 0' }} className={styles.onlyWordBg}>
  1181 + <Flex style={{ padding: '0 15px 5px 15px' }}>
  1182 + {
  1183 + f1 ? <Flex.Item className={styles.wordsFlow} style={{ color: '#fff', fontWeight: 'bold', fontSize: '16px' }}>{f1.showName} : {this.getViewValue(f1, masterData)}</Flex.Item> : ''
  1184 + }
  1185 + {
  1186 + f2 ? <Flex.Item className={`${styles.wordsFlow} ${styles.fr}`} style={{ fontSize: '17px' }}>{f2.showName} : {this.getViewValue(f2, masterData)}</Flex.Item> : ''
  1187 + }
  1188 + </Flex>
  1189 + <Flex style={{ padding: '0 15px 5px 15px' }}>
  1190 + {
  1191 + f3 ? <Flex.Item className={styles.wordsFlow} style={{ fontSize: '17px' }}>{f3.showName} : {this.getViewValue(f3, masterData)}</Flex.Item> : ''
  1192 + }
  1193 + </Flex>
  1194 + <Flex style={{ padding: '0 15px 5px 15px' }}>
  1195 + {
  1196 + f4 ? <Flex.Item className={styles.wordsFlow} style={{ fontSize: '17px' }}>{f4.showName} : {this.getViewValue(f4, masterData)}</Flex.Item> : ''
  1197 + }
  1198 + </Flex>
  1199 + <Flex style={{ padding: '0 15px 5px 15px' }}>
  1200 + {
  1201 + f5 ? <Flex.Item className={styles.wordsFlow} style={{ fontSize: '17px' }}>{f5.showName} : {this.getViewValue(f5, masterData)}</Flex.Item> : ''
  1202 + }
  1203 + {
  1204 + f6 ? <Flex.Item className={`${styles.wordsFlow} ${styles.fr}`} style={{ fontSize: '17px' }}>{f6.showName} : {this.getViewValue(f6, masterData)}</Flex.Item> : ''
  1205 + }
  1206 + </Flex>
  1207 + <Flex style={{ padding: '0 15px 5px 15px' }}>
  1208 + {
  1209 + f7 ? <Flex.Item className={styles.wordsFlow} style={{ fontSize: '17px' }}>{f7.showName} : {this.getViewValue(f7, masterData)}</Flex.Item> : ''
  1210 + }
  1211 + {
  1212 + f8 ? <Flex.Item className={`${styles.wordsFlow} ${styles.fr}`} style={{ fontSize: '17px' }}>{f8.showName} : {this.getViewValue(f8, masterData)}</Flex.Item> : ''
  1213 + }
  1214 + </Flex>
  1215 + <Flex style={{ padding: '0 15px 0px 15px' }}>
  1216 + {
  1217 + f9 ? <Flex.Item className={styles.wordsFlow} style={{ fontSize: '17px' }}>{f9.showName} : {this.getViewValue(f9, masterData)}</Flex.Item> : ''
  1218 + }
  1219 + {
  1220 + f10 ? <Flex.Item className={`${styles.wordsFlow} ${styles.fr}`} style={{ fontSize: '17px' }}>{f10.showName} : {this.getViewValue(f10, masterData)}</Flex.Item> : ''
  1221 + }
  1222 + </Flex>
  1223 + </div>
  1224 + <form style={{ paddingBottom: '47px' }}>
  1225 + <div className="flex-container" style={{ color: 'white' }}>
  1226 + <CommobileViewMaster {...this.props} iTag={1} />
  1227 + <CommobileViewMaster {...this.props} />
  1228 + </div>
  1229 + {commonUtils.isEmptyArr(slaveDataOld) ?
  1230 + <div>
  1231 + <Flex className={styles.ProcessReportMobile}>
  1232 + {
  1233 + slaveConfig && slaveConfig.gdsconfigformslave.filter(item => item.sControlName === 'BtnChildrenAdd' && item.bVisible).length ?
  1234 + <Flex.Item style={style}>
  1235 + <Button type="button" inline disabled={!enabled} onClick={this.handleClick.bind(this, 'slave', 'add')} style={btnStyle}>
  1236 + 增加
  1237 + <img src={add} className={styles.iconStyle} style={!enabled ? { opacity: 0.3 } : { opacity: 1 }} alt="add" />
  1238 + </Button>
  1239 + </Flex.Item> : ''
  1240 + }
  1241 + {
  1242 + slaveConfig && slaveConfig.gdsconfigformslave.filter(item => item.sControlName === 'BtnChildrenScan' && item.bVisible).length ?
  1243 + <Flex.Item style={style}>
  1244 + <Button type="button" inline disabled={!enabled} onClick={ commonConfig.isWeiXin ? this.handleWxScan.bind(this, 'slave', 'scan') : this.handleClick.bind(this, 'slave', 'scan')} style={btnStyle}>
  1245 + 扫码
  1246 + <img src={scan} className={styles.iconStyle} style={!enabled ? { opacity: 0.3 } : { opacity: 1 }} alt="scan" />
  1247 + </Button>
  1248 + </Flex.Item> : ''
  1249 + }
  1250 + </Flex>
  1251 + </div> :
  1252 + <div className={styles.listViewStyle}>
  1253 + <ListView
  1254 + dataSource={slaveData}
  1255 + renderRow={row}
  1256 + pageSize={commonConfig.pageSize}
  1257 + initialListSize={0}
  1258 + onScroll={() => {}}
  1259 + scrollRenderAheadDistance={500}
  1260 + onEndReachedThreshold={10}
  1261 + className={styles.listView}
  1262 + />
  1263 + </div>
  1264 + }
  1265 + <div
  1266 + className={`${styles.ProcessReportMobile} commobileBillToolbar`}
  1267 + style={{
  1268 + position: 'fixed', bottom: '0', width: '100%', zIndex: 1,
  1269 +}}
  1270 + >
  1271 + <CommobileToolBar {...this.props} btnStyle={BtnStyle} divStyle={divStyle} onButtonClick={this.handleClick} />
  1272 + </div>
  1273 + </form>
  1274 + </div>
  1275 + );
  1276 + }
  1277 +}
  1278 +
  1279 +const CommobileBillComponent = createForm()(CommobileBill);
  1280 +
  1281 +export default CommobileBase(CommobileBillEvent(CommobileBillComponent));
  1282 +
... ...
src/mobile/common/CommobileBillEvent.js 0 → 100644
  1 +/* eslint-disable */
  2 +/* eslint-disable prefer-destructuring,no-await-in-loop,radix,,no-loop-func */
  3 +/**
  4 + * Created by mar105 on 2019-01-08.
  5 + */
  6 +import React, { Component } from 'react';
  7 +import { Toast } from 'antd-mobile';
  8 +import * as commonUtils from '../../utils/utils';
  9 +import * as commonFunc from '../../components/Common/commonFunc';
  10 +import * as commonBusiness from '../../components/Common/commonBusiness';
  11 +import commonConfig from '../../utils/config';
  12 +import * as commonServices from '../../services/services';
  13 +import BarCodeUtil from './BarCodeUtil';
  14 +
  15 +
  16 +export default (ChildComponent) => {
  17 + return class extends Component {
  18 + constructor(props) {
  19 + super(props);
  20 + this.state = {};
  21 + }
  22 +
  23 + async componentWillReceiveProps(nextProps) {
  24 + const {
  25 + formData, currentId, masterConfig: masterConfigOld, sModelsId,
  26 + } = nextProps;
  27 + if (commonUtils.isEmptyObject(masterConfigOld) && formData.length > 0) {
  28 + const sId = currentId !== undefined ? currentId : '';
  29 + /* 数据Id */
  30 + const masterConfig = formData.filter(item => !item.bGrd)[0];
  31 + const slaveConfig = formData.filter(item => item.bGrd)[0];
  32 + /* 判断是否有汇总表 */
  33 + const slaveSumConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.bGrd && item.sGrd && item.sGrd.includes('sumTable') )) ? formData.filter(item => item.bGrd && item.sGrd && item.sGrd.includes('sumTable') )[0] : {};
  34 + let addStateMaster = {};
  35 + let userEntrustData = []; /* 委托人 */
  36 + let addState = {};
  37 + let addStateSum = {};
  38 + if (sId === '') {
  39 + const config = {};
  40 + config.masterConfig = masterConfig;
  41 + config.slaveConfig = slaveConfig;
  42 + config.slaveSumConfig = slaveSumConfig;
  43 + addState = await this.handleAdd(config, nextProps.copyTo, true);
  44 + } else {
  45 + addStateMaster = await this.props.handleGetDataOne({
  46 + name: 'master',
  47 + configData: masterConfig,
  48 + condition: { sId, pageSize: '', pageNum: '' },
  49 + isWait: true,
  50 + });
  51 + if (location.pathname === '/indexMobile/examine') {
  52 + const masterDataNew = addStateMaster.masterData;
  53 + const sParamsArr = commonUtils.isNotEmptyObject(masterDataNew) && commonUtils.isNotEmptyObject(masterDataNew.sTableParams) ? JSON.parse(masterDataNew.sTableParams) : '';
  54 + const sParamsValueArr = commonUtils.isNotEmptyObject(masterDataNew) && commonUtils.isNotEmptyObject(masterDataNew.sTableParamsValue) ? JSON.parse(masterDataNew.sTableParamsValue) : '';
  55 + /* 塞入配置 */
  56 + if (commonUtils.isNotEmptyObject(sParamsArr) && commonUtils.isNotEmptyObject(masterDataNew) && commonUtils.isNotEmptyObject(masterConfig) && commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave)) {
  57 + /* 移除最后一位元素 */
  58 + for (const key of Object.keys(sParamsArr)) {
  59 + const newConfig = {
  60 + iOrder: 300, sId: commonUtils.createSid(), bVisible: true, sParamsArr: key, showName: sParamsArr[key], sName: key,
  61 + };
  62 + const len = masterConfig.gdsconfigformslave.length;
  63 + masterConfig.gdsconfigformslave.splice(len - 1, 0, newConfig);
  64 + if (commonUtils.isNotEmptyArr(sParamsValueArr)) {
  65 + masterDataNew[key] = sParamsValueArr[key];
  66 + }
  67 + }
  68 + }
  69 + /* 拉委托人员的下拉数据源 */
  70 + const iUserIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName && item.sControlName.includes('BtnEntrust'));
  71 + if (iUserIndex > -1) {
  72 + userEntrustData = await this.props.getSqlDropDownData(sModelsId, 'master', masterConfig.gdsconfigformslave[iUserIndex], masterDataNew);
  73 + }
  74 + }
  75 + addState = await this.props.handleGetDataSet({
  76 + name: 'slave', configData: slaveConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
  77 + });
  78 + if(commonUtils.isNotEmptyObject(slaveSumConfig) && slaveSumConfig.sGrd && slaveSumConfig.sGrd.includes('sumTableSelect')) {
  79 + addStateSum = await this.props.handleGetDataSet({
  80 + name: 'slaveSum', configData: slaveSumConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
  81 + });
  82 + }
  83 + if (commonUtils.isNotEmptyArr(addState.slaveData)) {
  84 + if (commonUtils.isNotEmptyObject(addState.slaveData[0].sReportParam)) {
  85 + addState.slaveData[0] = { ...addState.slaveData[0], ...commonUtils.convertStrToObj(addState.slaveData[0].sReportParam) };
  86 + // eslint-disable-next-line no-plusplus
  87 + for (let i = 1; i < 7; i++) {
  88 + const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`);
  89 + if (iIndex > -1 && !commonUtils.isEmpty(addState.slaveData[0][`sParam${i.toString()}`])) {
  90 + slaveConfig.gdsconfigformslave[iIndex].showName = addState.slaveData[0][`sParam${i.toString()}`];
  91 + slaveConfig.gdsconfigformslave[iIndex].bVisible = !addState.slaveData[0][`sParam${i.toString()}`].includes('参数值');
  92 + } else if (iIndex > -1) {
  93 + slaveConfig.gdsconfigformslave[iIndex].bVisible = false;
  94 + }
  95 + }
  96 + } else {
  97 + // eslint-disable-next-line no-plusplus
  98 + for (let i = 1; i < 7; i++) {
  99 + const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`);
  100 + if (iIndex > -1) {
  101 + slaveConfig.gdsconfigformslave[iIndex].bVisible = false;
  102 + }
  103 + }
  104 + }
  105 + }
  106 + }
  107 + this.props.onSaveState({
  108 + masterConfig, slaveConfig, sId, pageLoading: false, ...addState, ...addStateMaster, userEntrustData, slaveSumConfig, ...addStateSum,
  109 + });
  110 + }
  111 + }
  112 +
  113 + shouldComponentUpdate(nextProps) {
  114 + const { masterConfig } = nextProps;
  115 + return commonUtils.isNotEmptyObject(masterConfig);
  116 + }
  117 +
  118 + /** 点击新增按钮 */
  119 + handleAdd = async (config, copyTo, isWait) => {
  120 + /* 外置处理业务 */
  121 + const {
  122 + sModelsId, token, sModelsType, formRoute, peopleInfosId, peopleInfoData, app,
  123 + } = this.props;
  124 + let masterConfig = commonUtils.isEmptyObject(config) ? {} : config.masterConfig;
  125 + if (!isWait) {
  126 + masterConfig = this.props.masterConfig;
  127 + }
  128 + let configNew = {};
  129 + if (commonUtils.isEmptyObject(config)) {
  130 + const { slaveConfig } = this.props;
  131 + configNew.slaveConfig = slaveConfig;
  132 + } else {
  133 + configNew = config;
  134 + }
  135 + let masterData;
  136 + if (commonUtils.isNotEmptyObject(masterConfig)) {
  137 + masterData = commonFunc.getDefaultData(masterConfig);
  138 + }
  139 + masterData.handleType = 'add';
  140 + masterData.sId = commonUtils.createSid();
  141 + masterData.sFormId = sModelsId;
  142 + masterData.maxBillNo = 'sBillNo';
  143 + if (formRoute === '/contactsInfo') {
  144 + if (commonUtils.isNotEmptyArr(peopleInfoData) && peopleInfosId !== '') {
  145 + const peopleInfo = peopleInfoData.filter(item => item.sId === peopleInfosId);
  146 + masterData = { ...masterData, ...peopleInfo[0] };
  147 + }
  148 + }
  149 + let slaveData = [];
  150 + const slaveSumData = [];
  151 + const employeeData = [];
  152 +
  153 + // const slaveTotal = [];
  154 + // const tableDataTotal = {};
  155 + let slaveAssignField = '';
  156 + if (commonUtils.isNotEmptyObject(copyTo)) {
  157 + const copyToMasterConfig = copyTo.config.filter(item => item.sControlName === copyTo.name);
  158 + const masterAssignField = commonUtils.isNotEmptyArr(copyToMasterConfig) ? copyToMasterConfig[0].sAssignField : '';
  159 + const newCopyTo = {};
  160 + newCopyTo.master = copyTo.masterData;
  161 + newCopyTo.slave = commonUtils.isEmpty(copyTo.slaveData) ? [] : copyTo.slaveData[0];
  162 + masterData = { ...masterData, ...commonFunc.getAssignFieldValue(masterAssignField, copyTo.masterData, newCopyTo) };
  163 +
  164 + const copyToSlaveConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave`.toLowerCase());
  165 + slaveAssignField = commonUtils.isNotEmptyArr(copyToSlaveConfig) ? copyToSlaveConfig[0].sAssignField : '';
  166 + if (sModelsType === 'production/productionReport') {
  167 + copyTo.slaveData = commonUtils.isEmptyArr(copyTo.slaveData) ? [] : [copyTo.slaveData[0]];
  168 + }
  169 + if (slaveAssignField !== '') {
  170 + for (const slaveItem of copyTo.slaveData) {
  171 + const newCopyTo = {};
  172 + newCopyTo.master = copyTo.masterData;
  173 + newCopyTo.slave = slaveItem;
  174 +
  175 + let slaveRow = commonFunc.getDefaultData(config.slaveConfig, newCopyTo); // 取默认值
  176 + slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(slaveAssignField, slaveItem, newCopyTo) }; // 取赋值字段
  177 + slaveRow.handleType = 'add';
  178 + slaveRow.sId = commonUtils.createSid();
  179 + slaveRow.sParentId = masterData.sId;
  180 +
  181 + if (sModelsType === 'production/productionReport') {
  182 + if (!commonUtils.isEmpty(slaveRow.sWageId)) {
  183 + slaveRow.dWageMoney = await commonBusiness.getFormulaValue({
  184 + token, sModelsId, masterData, tableDataRow: slaveRow, sComputeId: slaveRow.sWageId,
  185 + });
  186 + }
  187 + if (!commonUtils.isEmpty(slaveRow.sConversionFormulaId)) {
  188 + slaveRow.dConversionQty = await commonBusiness.getFormulaValue({
  189 + token, sModelsId, masterData, tableDataRow: slaveRow, sComputeId: slaveRow.sConversionFormulaId,
  190 + });
  191 + }
  192 + if (commonUtils.isNotEmptyObject(slaveRow.sReportParam)) {
  193 + slaveRow = { ...slaveRow, ...commonUtils.convertStrToObj(slaveRow.sReportParam) };
  194 + // eslint-disable-next-line no-plusplus
  195 + for (let i = 1; i < 7; i++) {
  196 + const iIndex = configNew.slaveConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`);
  197 + if (iIndex > -1 && !commonUtils.isEmpty(slaveRow[`sParam${i.toString()}`])) {
  198 + configNew.slaveConfig.gdsconfigformslave[iIndex].showName = slaveRow[`sParam${i.toString()}`];
  199 + configNew.slaveConfig.gdsconfigformslave[iIndex].bVisible = !slaveRow[`sParam${i.toString()}`].includes('参数值');
  200 + } else if (iIndex > -1) {
  201 + configNew.slaveConfig.gdsconfigformslave[iIndex].bVisible = false;
  202 + }
  203 + }
  204 + } else {
  205 + // eslint-disable-next-line no-plusplus
  206 + for (let i = 1; i < 7; i++) {
  207 + const iIndex = configNew.slaveConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`);
  208 + if (iIndex > -1) {
  209 + configNew.slaveConfig.gdsconfigformslave[iIndex].bVisible = false;
  210 + }
  211 + }
  212 + }
  213 + const sMachineId = app.sMachineId;
  214 + if (sMachineId) {
  215 + const sSessionTeamId = localStorage.getItem(`${commonConfig.prefix}mobile_${sMachineId}`);
  216 + if (sSessionTeamId) {
  217 + slaveRow.sTeamId = sSessionTeamId;
  218 + }
  219 + }
  220 + let returnData = JSON.parse(localStorage.getItem(`${commonConfig.prefix}employeeData`));
  221 + if (!commonUtils.isEmpty(slaveRow.sTeamId)) {
  222 + if (commonUtils.isEmptyArr(returnData)) {
  223 + const url = `${commonConfig.server_host}eleteamemployee/getEleteamemployee?sModelsId=${sModelsId}&sTeamId=${slaveRow.sTeamId}&sSlaveId=${slaveRow.sId}&sParentId=${slaveRow.sParentId}`;
  224 + const dataReturn = (await commonServices.getService(token, url)).data;
  225 + if (dataReturn.code === 1) {
  226 + returnData = dataReturn.dataset.rows;
  227 + } else { /* 失败 */
  228 + this.props.getServiceError(dataReturn);
  229 + }
  230 + }
  231 + returnData.forEach((child) => {
  232 + employeeData.push({
  233 + sId: commonUtils.createSid(),
  234 + sParentId: masterData.sId,
  235 + sSlaveId: slaveRow.sId,
  236 + sEmployeeId: child.sEmployeeId,
  237 + sEmployeeName: child.sEmployeeName,
  238 + dProportion: child.dProportion !== 0 ? child.dProportion : commonUtils.convertFixNum(1 / returnData.length, 6),
  239 + handleType: 'add',
  240 + });
  241 + });
  242 + /* 班组变化时,算每个工作人员计件工资 */
  243 + const dWageMoneyTotal = slaveRow.dWageMoney;
  244 + if (commonUtils.isNotEmptyNumber(dWageMoneyTotal)) {
  245 + let dProportionTotal = 0;
  246 + employeeData.forEach((item) => {
  247 + if (commonUtils.isNotEmptyNumber(item.dProportion) && item.dProportion !== 0) {
  248 + item.dProportion = parseFloat(item.dProportion);
  249 + dProportionTotal += commonUtils.convertFixNum(item.dProportion, 6);
  250 + dProportionTotal = commonUtils.convertFixNum(dProportionTotal, 6);
  251 + }
  252 + });
  253 + employeeData.forEach((item) => {
  254 + if (commonUtils.isNotEmptyNumber(item.dProportion)) {
  255 + const index1 = employeeData.findIndex(item1 => item1.sId === item.sId);
  256 + employeeData[index1] = {
  257 + ...item,
  258 + dWageMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * dWageMoneyTotal, 6),
  259 + handleType: commonUtils.isEmpty(item.handleType) ? 'update' : item.handleType,
  260 + };
  261 + }
  262 + });
  263 + }
  264 +
  265 +
  266 + const dWageMoney = commonUtils.isNotEmptyNumber(slaveRow.dWageMoney) ? commonUtils.convertFixNum(slaveRow.dWageMoney, 6) : 0;
  267 + const dTimeMoney = commonUtils.isNotEmptyNumber(slaveRow.dTimeMoney) ? commonUtils.convertFixNum(slaveRow.dTimeMoney, 6) : 0;
  268 + const dLossMoney = commonUtils.isNotEmptyNumber(slaveRow.dLossMoney) ? commonUtils.convertFixNum(slaveRow.dLossMoney, 6) : 0;
  269 + slaveRow.dAllMoney = commonUtils.convertFixNum((dWageMoney + dTimeMoney) - dLossMoney, 6);
  270 + }
  271 + }
  272 + slaveData.push(slaveRow);
  273 + }
  274 + }
  275 +
  276 + if (!commonUtils.isEmpty(masterData.sTestStandardId)) {
  277 + const dataUrl = `${commonConfig.server_host}eleteamemployee/getObtainInspectionStandards?sModelsId=${sModelsId}&sParentId=${masterData.sTestStandardId}`;
  278 + const dataReturn = (await commonServices.getService(this.props.app.token, dataUrl)).data;
  279 + const slaveDelData = [];
  280 + if (dataReturn.code === 1) {
  281 + const returnSlaveData = dataReturn.dataset.rows;
  282 + slaveData.forEach((item) => {
  283 + item.handleType = 'del';
  284 + slaveDelData.push(item);
  285 + });
  286 + slaveData = [];
  287 + const newCopyTo = {};
  288 + newCopyTo.master = masterData;
  289 + const iConfigIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'sTestStandardName');
  290 + const slaveConfig = commonUtils.isEmptyObject(config) ? {} : config.slaveConfig;
  291 + if (!isWait) {
  292 + masterConfig = this.props.slaveConfig;
  293 + }
  294 + const iSqlIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === 'sActValue');
  295 + returnSlaveData.forEach((item, iIndex) => {
  296 + let tableDataRow = commonFunc.getDefaultData(config.slaveConfig, {});
  297 + tableDataRow.handleType = 'add';
  298 + tableDataRow.sId = commonUtils.createSid();
  299 + tableDataRow.sParentId = masterData && masterData.sId ? masterData.sId : null;
  300 + tableDataRow.key = tableDataRow.sId;
  301 + tableDataRow.iOrder = iIndex;
  302 + if (iConfigIndex > -1) {
  303 + tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(masterConfig.gdsconfigformslave[iConfigIndex].sAssignField, item, newCopyTo) }; // 取赋值字段
  304 + // tableDataRow.sTestReference = '15S|20S';
  305 + const sTestReference = tableDataRow.sTestReference;
  306 + const sParamObj = {};
  307 + if (commonUtils.isNotEmptyObject(sTestReference)) { /* 若数据有值 渲染下拉框 */
  308 + if (sTestReference.indexOf('|') >= 0) {
  309 + sTestReference.split('|').forEach((itemField) => {
  310 + sParamObj[itemField] = itemField;
  311 + });
  312 + tableDataRow.sParamDropDownsActValue = sParamObj;
  313 + if (iSqlIndex > -1) {
  314 + slaveConfig.gdsconfigformslave[iSqlIndex].sDropDownType = 'sql';
  315 + } else {
  316 + slaveConfig.gdsconfigformslave[iSqlIndex].sDropDownType = '';
  317 + }
  318 + }
  319 + } else { /* 若数据没有值 则渲染文本框 */
  320 + tableDataRow.isText = true;
  321 + }
  322 + }
  323 + slaveData.push(tableDataRow);
  324 + });
  325 + }
  326 + }
  327 + }
  328 +
  329 + /* 剔除订单到收款单新增空行(2022.7.8朱总要求)) */
  330 + if (slaveData.length === 0 && commonUtils.isNotEmptyObject(slaveAssignField)) {
  331 + const allTableData = {};
  332 + allTableData.master = masterData;
  333 + allTableData.slave = slaveData;
  334 + let tableDataRowAdd = {};
  335 + if (commonUtils.isNotEmptyObject(configNew.slaveConfig)) {
  336 + tableDataRowAdd = commonFunc.getDefaultData(configNew.slaveConfig, allTableData);
  337 + tableDataRowAdd.handleType = 'add';
  338 + tableDataRowAdd.sId = commonUtils.createSid();
  339 + tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null;
  340 + tableDataRowAdd.key = tableDataRowAdd.sId;
  341 + tableDataRowAdd.bDefault = false;
  342 + tableDataRowAdd.iOrder = 0;
  343 + slaveData.push(tableDataRowAdd);
  344 + }
  345 + }
  346 +
  347 + const state = {
  348 + masterData,
  349 + slaveData,
  350 + slaveSumData,
  351 + employeeData,
  352 + slaveTotal: [],
  353 + slaveSelectedRowKeys: [],
  354 + searchUpDownData: {},
  355 + enabled: true,
  356 + };
  357 + state.sUseInfo = '';
  358 + if (isWait) {
  359 + return state;
  360 + } else {
  361 + this.props.onSaveState(state);
  362 + return true;
  363 + }
  364 + };
  365 +
  366 + /** toolbar保存 */
  367 + handleSaveData = async (params) => {
  368 + const {
  369 + token, sModelsId, currentId, masterData, masterConfig, slaveConfig, employeeConfig, billnosetting, app, sModelsType, copyTo, dispatch,
  370 + } = this.props;
  371 + const { userinfo } = app;
  372 + const onSendSocketMessage = this.props.handleSendSocketMessage;
  373 + const BtnSave = commonFunc.showMessage(app.commonConst, 'BtnSave');/* 保存 */
  374 + params.optName = BtnSave;
  375 + const returnData = await commonBusiness.saveData({ token, value: params, sModelsId });
  376 + if (commonUtils.isNotEmptyObject(returnData)) {
  377 + if (commonUtils.isNotEmptyObject(copyTo)) {
  378 + const { slaveData } = copyTo;
  379 + const sIdArray = [];
  380 + slaveData.forEach((item) => {
  381 + const redisKey = item.sSlaveId;
  382 + sIdArray.push(redisKey);
  383 + });
  384 + const sId = sIdArray.toString();
  385 + onSendSocketMessage('copyfinish', 'noAction', sId, userinfo.sId, null, null);
  386 + }
  387 + onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
  388 + this.props.onSaveState({
  389 + enabled: false, currentId: masterData.sId,
  390 + });
  391 + let btnSaveConfigArr = [];
  392 + const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName && item.sControlName.includes('BtnExamine'));
  393 + if (iIndex > -1) {
  394 + btnSaveConfigArr = masterConfig.gdsconfigformslave[iIndex];
  395 + }
  396 + console.log('btnSaveConfigArr', btnSaveConfigArr);
  397 + const interfaceArr = commonUtils.isNotEmptyObject(btnSaveConfigArr) ? btnSaveConfigArr.interface :[];
  398 + let bSucess = true;
  399 + if (billnosetting.bAutoCheck) {
  400 + /* 根据接口返回是之前调用还是之后调用 */
  401 + if (false && commonUtils.isNotEmptyArr(interfaceArr)) {
  402 + const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === '1');
  403 + const afterInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === '2');
  404 +
  405 + if(commonUtils.isNotEmptyArr(beforeInterfaceArr)) { /* 之前调用 */
  406 + let flag = 0;
  407 + const asyncFunc = async () => {
  408 + for (let i = 0; i < beforeInterfaceArr.length; i ++) {
  409 + const data = await this.handleInterfaceCall(beforeInterfaceArr[i]);
  410 + if (!data) {
  411 + flag += 1;
  412 + }
  413 + }
  414 + }
  415 + if (flag == 0) {
  416 + await this.handleAudit(1);
  417 + } else {
  418 + this.props.onSaveState({
  419 + loading: false,
  420 + });
  421 + }
  422 + }
  423 +
  424 + if(commonUtils.isNotEmptyArr(afterInterfaceArr)) { /* 之后调用 */
  425 + const result = await this.handleAudit(1);
  426 + if(result) { /* 只有审核成功 才能调用接口 -5代表审核失败 */
  427 + const asyncFunc = async () => {
  428 + for (let i = 0; i < afterInterfaceArr.length; i++) {
  429 + await this.handleInterfaceCall(afterInterfaceArr[i]);
  430 + }
  431 + }
  432 + await asyncFunc();
  433 + }
  434 + }
  435 + } else {
  436 + await this.handleAudit(1);
  437 + }
  438 + } else {
  439 + await this.handleGetData(masterConfig, slaveConfig);
  440 + if (sModelsType === 'production/productionReport' && !commonUtils.isEmpty(employeeConfig)) {
  441 + await this.handleGetMemoData(employeeConfig);
  442 + }
  443 + if (this.props.refresh !== undefined) {
  444 + this.props.refresh();
  445 + }
  446 + /* 通过onRouterMobile路由跳转 */
  447 + if (sModelsType === 'production/productionReport' && commonUtils.isNotEmptyObject(copyTo) && commonUtils.isNotEmptyObject(copyTo.listModelsId) && copyTo.listUrl && copyTo.listUrl.includes('commobileList')) {
  448 + const sModelsId = copyTo.listModelsId;
  449 + const sModelsType = copyTo.listModelsType;
  450 + const url = '/indexMobile/commobileList';
  451 + const sNameUrl = `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sModelsId}?sModelsId=${sModelsId}`;
  452 + dispatch({
  453 + type: 'content/onRouterMobile',
  454 + payload: {
  455 + url, /* 接口地址 */
  456 + urlKey: sNameUrl,
  457 + sModelsId,
  458 + sModelsType,
  459 + copyTo,
  460 + listFilterCondition: copyTo.listFilterCondition,
  461 + },
  462 + });
  463 + } else {
  464 + window.history.back(-1);
  465 + }
  466 + }
  467 + this.props.onSaveState({
  468 + loading: false,
  469 + });
  470 + return true;
  471 + } else {
  472 + this.props.onSaveState({
  473 + loading: false,
  474 + });
  475 + return false;
  476 + }
  477 + };
  478 +
  479 + /** toolbar校验保存 */
  480 + handleValidateSave = async () => {
  481 + const {
  482 + masterConfig, masterData, slaveConfig, slaveData, slaveDelData, sModelsType, employeeConfig, employeeData, employeeDelData, token, sModelsId, app,
  483 + slaveSumConfig, slaveSumData, slaveSumDelData,
  484 + } = this.props;
  485 + if (!commonBusiness.validateMaster(masterConfig, masterData, this.props) || !commonBusiness.validateTable(slaveConfig, slaveData, this.props)) {
  486 + this.props.onSaveState({
  487 + loading: false,
  488 + });
  489 + return;
  490 + }
  491 + if (slaveConfig && slaveConfig.bNotCanEmpty && commonUtils.isEmptyArr(slaveData)) {
  492 + Toast.info(commonFunc.showMessage(app.commonConst, 'slaveNotNull')); // 从表不能为空!
  493 + this.props.onSaveState({
  494 + loading: false,
  495 + });
  496 + return;
  497 + }
  498 +
  499 + const data = [];
  500 + data.push(commonBusiness.mergeData('master', masterConfig.sTbName, [masterData]));
  501 +
  502 + if (sModelsType === 'production/productionReport') {
  503 + for (const tableDataRow of slaveData) {
  504 + const sWageId = tableDataRow.sWageId;
  505 + tableDataRow.dWageMoney = await commonBusiness.getFormulaValue({
  506 + token, sModelsId, masterData, tableDataRow, sComputeId: sWageId,
  507 + });
  508 + const dWageMoneyTotal = tableDataRow.dWageMoney;
  509 + let dProportionTotal = 0;
  510 + const employeeSlaveData = employeeData.filter(item => item.sSlaveId === tableDataRow.sId);
  511 + employeeSlaveData.forEach((item) => {
  512 + if (commonUtils.isNotEmptyNumber(item.dProportion) && item.dProportion !== 0) {
  513 + dProportionTotal += commonUtils.convertFixNum(item.dProportion, 6);
  514 + }
  515 + });
  516 + employeeSlaveData.forEach((item) => {
  517 + if (commonUtils.isNotEmptyNumber(item.dProportion)) {
  518 + const index1 = employeeData.findIndex(item1 => item1.sId === item.sId);
  519 + employeeData[index1] = {
  520 + ...item,
  521 + dWageMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(tableDataRow.dWageMoney, 0), 6),
  522 + dTimeMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(tableDataRow.dTimeMoney, 0), 6),
  523 + dLossMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(tableDataRow.dLossMoney, 0), 6),
  524 + dOtherMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(tableDataRow.dOtherMoney, 0), 6),
  525 + dJobMoney: commonUtils.convertFixNum((item.dProportion / dProportionTotal) * commonUtils.isNull(tableDataRow.dJobMoney, 0), 6),
  526 + handleType: commonUtils.isEmpty(item.handleType) ? 'update' : item.handleType,
  527 + };
  528 + }
  529 + });
  530 + /* 选择计件方案后 算总金额 */
  531 + const dWageMoney = commonUtils.isNotEmptyNumber(dWageMoneyTotal) ? commonUtils.convertFixNum(dWageMoneyTotal, 6) : 0;
  532 + const dTimeMoney = commonUtils.isNotEmptyNumber(tableDataRow.dTimeMoney) ? commonUtils.convertFixNum(tableDataRow.dTimeMoney, 6) : 0;
  533 + const dLossMoney = commonUtils.isNotEmptyNumber(tableDataRow.dLossMoney) ? commonUtils.convertFixNum(tableDataRow.dLossMoney, 6) : 0;
  534 + tableDataRow.dAllMoney = commonUtils.convertFixNum((dWageMoney + dTimeMoney) - dLossMoney, 6);
  535 + tableDataRow.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType;
  536 + }
  537 + }
  538 + data.push(commonBusiness.mergeData('slave', slaveConfig.sTbName, slaveData, slaveDelData));
  539 +
  540 + if (sModelsType === 'production/productionReport' && !commonUtils.isEmpty(employeeConfig)) {
  541 + data.push(commonBusiness.mergeData('employee', employeeConfig.sTbName, employeeData, employeeDelData));
  542 + localStorage.setItem(`${commonConfig.prefix}sTeamId`, slaveData[0].sTeamId);
  543 + localStorage.setItem(`${commonConfig.prefix}employeeData`, JSON.stringify(employeeData));
  544 + /* 手机端报产选了机台后,进去报产,选了班组,确认之后,在返回去报第二个的时候,默认班组 */
  545 + if (commonUtils.isNotEmptyObject(slaveData[0])) {
  546 + const sMachineId = slaveData[0].sMachineId;
  547 + const sTeamId = slaveData[0].sTeamId;
  548 + if (sMachineId && sTeamId) {
  549 + localStorage.setItem(`${commonConfig.prefix}mobile_${sMachineId}`, sTeamId);
  550 + }
  551 + }
  552 + }
  553 + if(commonUtils.isNotEmptyObject(slaveSumConfig) && slaveSumConfig.sGrd && slaveSumConfig.sGrd.includes('sumTableSelect')) {
  554 + data.push(commonBusiness.mergeData('slaveSum', slaveSumConfig.sTbName, slaveSumData, slaveSumDelData));
  555 + }
  556 + this.handleSaveData({ data, sClientType: '1', sSysLogSrcId: masterData.sId });
  557 + };
  558 +
  559 + /** toolbar审核(消审) */
  560 + handleAudit = async (flag) => {
  561 + /* 待用数据声明 */
  562 + const { masterData, gdsformconst } = this.props;
  563 + let bResult = true;
  564 + /* 作废订单不能审核 */
  565 + if (masterData.bInvalid) {
  566 + Toast.info(gdsformconst.filter(item => (item.sName === 'sToVoid'))[0].showName);
  567 + return '';
  568 + }
  569 + /** 数据审核 */
  570 + bResult = await this.dataAudit(flag);
  571 + return bResult;
  572 + };
  573 +
  574 + /** 数据审核 */
  575 + dataAudit = async (flag, tmpCheck, isWait) => {
  576 + /* 待用数据声明 */
  577 + const {
  578 + sModelsId, masterData, app, masterConfig, slaveConfig, token, sModelsType, slaveData, employeeConfig, copyTo, dispatch,
  579 + } = this.props;
  580 + const sSlaveIdArray = [];
  581 + if (commonUtils.isNotEmptyArr(slaveData)) {
  582 + slaveData.forEach((item) => {
  583 + sSlaveIdArray.push(commonUtils.isNotEmptyObject(item.sId) ? item.sId : item.sSlaveId);
  584 + });
  585 + }
  586 + const slaveId = sSlaveIdArray.toString();
  587 + /* 数据参数 */
  588 + const value = {
  589 + sClientType: '1',
  590 + paramsMap: {
  591 + iFlag: flag,
  592 + iTmpCheck: commonUtils.isEmptyNumber(tmpCheck) ? 0 : tmpCheck,
  593 + sFormGuid: sModelsId,
  594 + sGuid: masterData.sId,
  595 + sSlaveId: slaveId,
  596 + sBillNo: commonUtils.isNotEmptyObject(masterData.sBillNo) ? masterData.sBillNo : '',
  597 + },
  598 + };
  599 + /* 数据审核 */
  600 + const url = `${commonConfig.server_host}business/doExamine?sModelsId=${sModelsId}`;
  601 + const returnData = (await commonServices.postValueService(app.token, value, url)).data;
  602 + if (isWait) {
  603 + return returnData;
  604 + } else {
  605 + /* 接收返回值 */
  606 + await this.handleGetData(masterConfig, slaveConfig);
  607 + const check = commonFunc.showMessage(app.commonConst, 'BtnExamine');/* 审核 */
  608 + const BtnCancelExamine = commonFunc.showMessage(app.commonConst, 'BtnCancelExamine');/* 销审 */
  609 + if (sModelsType === 'production/productionReport' && !commonUtils.isEmpty(employeeConfig)) {
  610 + await this.handleGetMemoData(employeeConfig);
  611 + }
  612 + if (this.props.refresh !== undefined) {
  613 + this.props.refresh();
  614 + }
  615 + if (returnData.code === 1) { /* 成功 */
  616 + this.props.onSaveState({
  617 + loading: false,
  618 + });
  619 + if (flag === 1) {
  620 + /* 审核 */
  621 + const { outData } = returnData.dataset.rows[0].dataSet;
  622 + if (commonUtils.isNotEmptyStr(outData[0].sReturn)) {
  623 + const sReturnArray = outData[0].sReturn.split('|');
  624 + if (outData[0].sReturn.split('-').length < 2) {
  625 + // 正常业务提示,非审核模板
  626 + // if (this.props.app.currentPane.refresh !== undefined) {
  627 + // this.props.app.currentPane.refresh();
  628 + // }
  629 + Toast.fail(check + outData[0].sReturn);
  630 + return;
  631 + }
  632 + const checkConditions = [];
  633 + let checkPersonData = {};
  634 + sReturnArray.forEach((item) => {
  635 + const checkCondition = item.split('-')[2];
  636 + checkConditions.push({
  637 + key: commonUtils.createSid(),
  638 + condition: checkCondition,
  639 + });
  640 + });
  641 + const sCheckModelId = sReturnArray[0].split('-')[1];
  642 + if (commonUtils.isNotEmptyStr(sCheckModelId)) {
  643 + const urlCheck = `${commonConfig.server_host}checkModel/getUserListByModelId/${sCheckModelId}?sModelsId=${sModelsId}`;
  644 + const dataReturn = (await commonServices.getService(token, urlCheck)).data;
  645 + if (dataReturn.code === 1) {
  646 + checkPersonData = dataReturn.dataset.rows;
  647 + checkPersonData.forEach((item) => {
  648 + item.key = commonUtils.createSid();
  649 + });
  650 + this.props.onSaveState({
  651 + checkConditions, checkPersonData, sCheckModelId, visible: true,
  652 + });
  653 + } else { /* 失败 */
  654 + this.props.getServiceError({ msg: check + dataReturn });
  655 + return false;
  656 + }
  657 + }
  658 + } else {
  659 + Toast.success(check + returnData.msg);
  660 + if (sModelsType === 'production/productionReport' && commonUtils.isNotEmptyObject(copyTo) && commonUtils.isNotEmptyObject(copyTo.listModelsId) && copyTo.listUrl && copyTo.listUrl.includes('commobileList')) {
  661 + const sModelsId = copyTo.listModelsId;
  662 + const sModelsType = copyTo.listModelsType;
  663 + const url = '/indexMobile/commobileList';
  664 + const sNameUrl = `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sModelsId}?sModelsId=${sModelsId}`;
  665 + dispatch({
  666 + type: 'content/onRouterMobile',
  667 + payload: {
  668 + url, /* 接口地址 */
  669 + urlKey: sNameUrl,
  670 + sModelsId,
  671 + sModelsType,
  672 + copyTo,
  673 + returnFilterCondition: copyTo.listFilterCondition,
  674 + },
  675 + });
  676 + } else {
  677 + window.history.back(-1);
  678 + }
  679 + }
  680 + } else {
  681 + /* 消审 */
  682 + const { outData } = returnData.dataset.rows[0].dataSet;
  683 + if (commonUtils.isNotEmptyStr(outData[0].sReturn)) {
  684 + Toast.fail(outData[0].sReturn);
  685 + return false;
  686 + } else {
  687 + // if (this.props.app.currentPane.refresh !== undefined) {
  688 + // this.props.app.currentPane.refresh();
  689 + // }
  690 + Toast.success(BtnCancelExamine + returnData.msg);
  691 + window.history.back(-1);
  692 + }
  693 + }
  694 + } else { /* 失败 */
  695 + this.props.getServiceError(returnData);
  696 + this.props.onSaveState({
  697 + loading: false,
  698 + });
  699 + return false;
  700 + }
  701 + return true;
  702 + }
  703 + };
  704 +
  705 + /* 调用后台配置的接口 */
  706 + handleThirdInterfaceCall = async (obj, showTip, key, sListSlaveId) => {
  707 + let bResult = false;
  708 + const {
  709 + app, sModelsId, masterData, slaveSelectedRowKeys,
  710 + } = this.props;
  711 + const sInterfaceName = obj.sInterfaceName;
  712 + const value = { sId: commonUtils.isNotEmptyObject(sListSlaveId) ? sListSlaveId : masterData.sId, userInfo: app.userinfo };
  713 + const url = `${commonConfig.interface_host}interfaceDefine/callthirdparty/${sInterfaceName}?sModelsId=${sModelsId}`;
  714 + const returnData = (await commonServices.postValueService(app.token, value, url, app)).data;
  715 + if (returnData.code === 1) {
  716 + bResult = true;
  717 + } else if (returnData.code === -8) {
  718 + Modal.info({
  719 + title: '温馨提示:',
  720 + width: 200,
  721 + content: (
  722 + <div>
  723 + {this.handleGetMsg(returnData.msg)}
  724 + </div>
  725 + ),
  726 + okText: '确认',
  727 + onOk() {},
  728 + });
  729 + bResult = true;
  730 + } else {
  731 + bResult = false;
  732 + this.props.getServiceError(returnData);
  733 + }
  734 + return bResult;
  735 + }
  736 +
  737 + handleForm = (form) => {
  738 + this.form = form;
  739 + };
  740 + /** 点击修改按钮操作 */
  741 + handleEdit = () => {
  742 + const {
  743 + slaveConfig, masterConfig, app, dispatch, currentId,
  744 + } = this.props;
  745 + const { userinfo } = app;
  746 +
  747 + let timValue = 0;
  748 + if (this.props.app.webSocket === null || this.props.app.webSocket.readyState !== WebSocket.OPEN) {
  749 + this.props.dispatch({ type: 'app/createWebSocket', payload: { reStart: true, dispatch } });
  750 + timValue = 3000;
  751 + }
  752 + setTimeout(() => {
  753 + this.props.app.webSocket.onmessage = (msg) => {
  754 + const rtmsg = JSON.parse(msg.data);
  755 + if (rtmsg.action === 'showMsg') {
  756 + Toast.info(rtmsg.msg);
  757 + this.props.onSaveState({ loading: false });
  758 + } else if (rtmsg.action === 'loginOut') {
  759 + if (location.pathname.indexOf('/indexOee') > -1) {
  760 + dispatch({ type: 'app/throwErrorOee', payload: { code: -2, msg: rtmsg.msg } });
  761 + } else if (location.pathname.indexOf('/indexMobile') > -1) {
  762 + dispatch({ type: 'app/throwErrorMobile', payload: { code: -2, msg: rtmsg.msg } });
  763 + } else {
  764 + dispatch({ type: 'app/throwError', payload: { code: -2, msg: rtmsg.msg } });
  765 + }
  766 + } else if (rtmsg.action === 'update') {
  767 + this.handleGetData(masterConfig, slaveConfig);
  768 + this.props.onSaveState({ enabled: true, loading: false });
  769 + } else if (this.props.app.webSocket.homeAction) {
  770 + this.props.app.webSocket.homeAction(msg);
  771 + }
  772 + };
  773 + this.props.handleSendSocketMessage('update', 'showMsg', currentId, userinfo.sId, null, null);
  774 + }, timValue);
  775 + };
  776 +
  777 + /** 获取主表、从表、审核表数据 */
  778 + handleGetData = async (masterConfig, slaveConfig) => {
  779 + const { currentId } = this.props; /* 当前页签数据 */
  780 + const sId = currentId !== undefined ? currentId : '';
  781 + await this.props.handleGetDataOne({ name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' } });
  782 + if (!commonUtils.isEmptyObject(slaveConfig)) {
  783 + this.props.handleGetDataSet({
  784 + name: 'slave', configData: slaveConfig, condition: { sSqlCondition: { sParentId: sId } },
  785 + });
  786 + }
  787 + };
  788 +
  789 + handleGetMemoData = async (employeeConfig) => {
  790 + const { currentId } = this.props; /* 当前页签数据 */
  791 + const sId = currentId !== undefined ? currentId : ''; /* 数据Id */
  792 + this.props.handleGetDataSet({
  793 + name: 'employee', configData: employeeConfig, condition: { sSqlCondition: { sParentId: sId } },
  794 + });
  795 + };
  796 +
  797 + handleMasterChange = async (name, sFieldName, changeValue, sId, dropDownData, isWait, masterDataNew) => {
  798 + // this.handleCustomerChange(name, changeValue);
  799 + const {
  800 + sModelsId, sModelsType: sModelsTypeOld, masterData: masterDataOld, slaveData, app, masterConfig, slaveConfig, token,
  801 + } = this.props;
  802 + const addState = {};
  803 + const sModelsType = commonUtils.isEmpty(sModelsTypeOld) ? '' : sModelsTypeOld;
  804 + const masterData = masterDataNew === undefined ? masterDataOld === undefined ? {} : masterDataOld : masterDataNew;
  805 + let bNewSlaveData = false;
  806 + if (sFieldName === 'sCustomerId' || sFieldName === 'sCustomerNo' || sFieldName === 'sCustomerName') {
  807 + if (commonUtils.isNotEmptyArr(slaveData)) {
  808 + // 从表有数据,请删除后修改客户!不能去掉
  809 + if (slaveData.length === 1 && commonUtils.isEmpty(slaveData[0].sProductId)) {
  810 + bNewSlaveData = true;
  811 + } else {
  812 + Toast.info(commonFunc.showMessage(app.commonConst, 'slaveHasDataPleaseDel'));
  813 + return;
  814 + }
  815 + }
  816 + changeValue.tGetPayDate = commonBusiness.getGeyPayDate({ ...masterData, ...changeValue });
  817 + // commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductId', []);
  818 + // commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductNo', []);
  819 + // commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductName', []);
  820 + //
  821 + // commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductId', []);
  822 + // commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductNo', []);
  823 + // commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductName', []);
  824 + } else if (sFieldName === 'sSupplyId' || sFieldName === 'sSupplyNo' || sFieldName === 'sSupplyName') {
  825 + changeValue.tGetPayDate = commonBusiness.getGeyPayDate({ ...masterData, ...changeValue });
  826 + } else if (sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName') {
  827 + commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sMaterialsId', []);
  828 + commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sMaterialsNo', []);
  829 + commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sMaterialsName', []);
  830 + if (sModelsType === 'materialsStock/materialsCheck' || sModelsType === 'productStock/productCheck') {
  831 + let value = {};
  832 + if (sModelsType === 'materialsStock/materialsCheck') {
  833 + value = {
  834 + sProName: 'Sp_System_AccountSquareCheck',
  835 + paramsMap: {
  836 + iType2: 1,
  837 + sWareHouseGuid: commonUtils.isNotEmptyObject(changeValue.sWareHouseId) ? changeValue.sWareHouseId : '',
  838 + },
  839 + };
  840 + } else if (sModelsType === 'productStock/productCheck') {
  841 + value = {
  842 + sProName: 'Sp_System_AccountSquareCheck',
  843 + paramsMap: {
  844 + iType2: 2,
  845 + sWareHouseGuid: commonUtils.isNotEmptyObject(changeValue.sWareHouseId) ? changeValue.sWareHouseId : '',
  846 + },
  847 + };
  848 + }
  849 + const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
  850 + const returnData = (await commonServices.postValueService(app.token, value, url)).data;
  851 + if (returnData.code === 1) {
  852 + const outData = returnData.dataset.rows[0].dataSet.outData[0];
  853 + if (outData.sCode === -1) {
  854 + Toast.fail(outData.sReturn);
  855 + return;
  856 + }
  857 + } else {
  858 + this.props.getServiceError(returnData);
  859 + return;
  860 + }
  861 + }
  862 + } else if (sModelsType.includes('cashier/') && sFieldName === 'sBillType') {
  863 + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sCustomerId', []);
  864 + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sCustomerNo', []);
  865 + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sCustomerName', []);
  866 + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sSupplyId', []);
  867 + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sSupplyNo', []);
  868 + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sSupplyName', []);
  869 + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sFamilyId', []);
  870 + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sFamilyNo', []);
  871 + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sFamilyName', []);
  872 + changeValue.sCustomerId = '';
  873 + const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sCustomerId');
  874 + if (iIndex > -1) {
  875 + masterConfig.gdsconfigformslave[iIndex].bReGetDropDown = true;
  876 + }
  877 + changeValue.sSupplyId = '';
  878 + const iSupplyIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sSupplyId');
  879 + if (iSupplyIndex > -1) {
  880 + masterConfig.gdsconfigformslave[iSupplyIndex].bReGetDropDown = true;
  881 + }
  882 + /* 财务调整中切换调整类型后,对象名称清空 */
  883 + const sBillTypeIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sFamilyName');
  884 + if (sBillTypeIndex > -1) {
  885 + masterData.sFamilyName = '';
  886 + }
  887 + this.props.onSaveState({ masterConfig });
  888 + } else if (sFieldName === 'sGetPayId') {
  889 + changeValue.tGetPayDate = commonBusiness.getGeyPayDate({ ...masterData, ...changeValue });
  890 + } else if (sFieldName === 'sSettlementId') {
  891 + if (changeValue.sSettlementId === 'cash') {
  892 + const sBankAccountIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sBankAccount');
  893 + if (sBankAccountIndex > -1) {
  894 + masterConfig.gdsconfigformslave[sBankAccountIndex].iTag = 1;
  895 + masterData.sBankAccount = '';
  896 + }
  897 + const sInvoiceNoIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sInvoiceNo');
  898 + if (sInvoiceNoIndex > -1) {
  899 + masterConfig.gdsconfigformslave[sInvoiceNoIndex].iTag = 1;
  900 + masterData.sInvoiceNo = '';
  901 + }
  902 + const sBankIdIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sBankId' || item.sName === 'sBankName');
  903 + if (sBankIdIndex > -1) {
  904 + masterConfig.gdsconfigformslave[sBankIdIndex].iTag = 1;
  905 + masterData.sBankId = '';
  906 + masterData.sBankName = '';
  907 + }
  908 + const tDueDateIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'tDueDate');
  909 + if (tDueDateIndex > -1) {
  910 + masterConfig.gdsconfigformslave[tDueDateIndex].iTag = 1;
  911 + delete masterData.tDueDate;
  912 + }
  913 + }
  914 + if (changeValue.sSettlementId === 'bank') {
  915 + const sInvoiceNoIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sInvoiceNo');
  916 + if (sInvoiceNoIndex > -1) {
  917 + masterConfig.gdsconfigformslave[sInvoiceNoIndex].iTag = 1;
  918 + masterData.sInvoiceNo = '';
  919 + }
  920 + const sBankAccountIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sBankAccount');
  921 + if (sBankAccountIndex > -1) {
  922 + masterConfig.gdsconfigformslave[sBankAccountIndex].iTag = 0;
  923 + }
  924 + const sBankIdIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sBankId' || item.sName === 'sBankName');
  925 + if (sBankIdIndex > -1) {
  926 + masterConfig.gdsconfigformslave[sBankIdIndex].iTag = 0;
  927 + }
  928 + const tDueDateIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'tDueDate');
  929 + if (tDueDateIndex > -1) {
  930 + masterConfig.gdsconfigformslave[tDueDateIndex].iTag = 1;
  931 + delete masterData.tDueDate;
  932 + }
  933 + }
  934 + if (changeValue.sSettlementId === 'bill') {
  935 + const sBankAccountIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sBankAccount');
  936 + if (sBankAccountIndex > -1) {
  937 + masterConfig.gdsconfigformslave[sBankAccountIndex].iTag = 1;
  938 + masterData.sBankAccount = '';
  939 + }
  940 + const sInvoiceNoIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sInvoiceNo');
  941 + if (sInvoiceNoIndex > -1) {
  942 + masterConfig.gdsconfigformslave[sInvoiceNoIndex].iTag = 0;
  943 + }
  944 + const sBankIdIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sBankId');
  945 + if (sBankIdIndex > -1) {
  946 + masterConfig.gdsconfigformslave[sBankIdIndex].iTag = 0;
  947 + }
  948 + const tDueDateIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'tDueDate');
  949 + if (tDueDateIndex > -1) {
  950 + masterConfig.gdsconfigformslave[tDueDateIndex].iTag = 0;
  951 + }
  952 + }
  953 + }
  954 + let returnData = this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, true, masterData);
  955 + const masterDataAfter = commonBusiness.getKeyUpEvent(name, sFieldName, masterConfig, returnData.masterData, {}, true);
  956 + if (commonUtils.isNotEmptyObject(masterDataAfter)) {
  957 + returnData.masterData = masterDataAfter;
  958 + }
  959 + if (sFieldName === 'sSupplyId' || sFieldName === 'sSupplyNo' || sFieldName === 'sSupplyName' || sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName' ||
  960 + sFieldName === 'sLocationId' || sFieldName === 'sLocationNo' || sFieldName === 'sLocationName' ||
  961 + sFieldName === 'sWareHouseLocationId' || sFieldName === 'sWareHouseLocationNo' || sFieldName === 'sWareHouseLocationName' || sFieldName === 'tDeliverDate') {
  962 + const slaveDataNew = [];
  963 + for (const item of slaveData) {
  964 + let tableDataRow = ((sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName' ||
  965 + sFieldName === 'sLocationId' || sFieldName === 'sLocationNo' || sFieldName === 'sLocationName' ||
  966 + sFieldName === 'sWareHouseLocationId' || sFieldName === 'sWareHouseLocationNo' || sFieldName === 'sWareHouseLocationName') && (sModelsType.includes('materialsStock/productionmaterialsadjust'))) ?
  967 + { ...item } : { ...item, [sFieldName]: changeValue[sFieldName] };
  968 + if (sFieldName === 'sSupplyId' || sFieldName === 'sSupplyNo' || sFieldName === 'sSupplyName') {
  969 + tableDataRow.sTaxId = changeValue.sTaxId;
  970 + tableDataRow.sTaxNo = changeValue.sTaxNo;
  971 + tableDataRow.sTaxName = changeValue.sTaxName;
  972 + tableDataRow.dTaxRate = changeValue.dTaxRate;
  973 + tableDataRow.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType;
  974 + const models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
  975 +
  976 + tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'sTaxId', masterData, tableDataRow);
  977 + let dMaterialsMoney = '';
  978 + if (sModelsType.includes('outside/')) { /* 工序发外 */
  979 + let sComputeId = '';
  980 + const sSupplyId = changeValue.sSupplyId;
  981 + const sProcessId = tableDataRow.sProcessId;
  982 + /* 根据客户id,工序id获取公式ID */
  983 + if (commonUtils.isNotEmptyObject(sSupplyId) && commonUtils.isNotEmptyObject(sProcessId)) {
  984 + sComputeId = await commonBusiness.getOutSideProcessFormula({
  985 + token, sModelsId, sSupplyId, sProcessId,
  986 + });
  987 + if (commonUtils.isNotEmptyObject(sComputeId)) {
  988 + dMaterialsMoney = await commonBusiness.getFormulaValue({
  989 + token, sModelsId, masterData, tableDataRow, sComputeId,
  990 + });
  991 + tableDataRow.dMaterialsMoney = dMaterialsMoney;
  992 + tableDataRow = commonBusiness.getCalculateMoney(app, masterData, tableDataRow, 'Materials');
  993 + }
  994 + }
  995 + }
  996 + }
  997 + if ((sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName' ||
  998 + sFieldName === 'sLocationId' || sFieldName === 'sLocationNo' || sFieldName === 'sLocationName' ||
  999 + sFieldName === 'sWareHouseLocationId' || sFieldName === 'sWareHouseLocationNo' || sFieldName === 'sWareHouseLocationName') && (!sModelsType.includes('materialsStock/productionmaterialsadjust'))) {
  1000 + if (sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName') {
  1001 + tableDataRow.sWareHouseId = changeValue.sWareHouseId;
  1002 + tableDataRow.sWarehouseId = changeValue.sWareHouseId;
  1003 + tableDataRow.sWareHouseNo = changeValue.sWareHouseNo;
  1004 + tableDataRow.sWareHouseName = changeValue.sWareHouseName;
  1005 + } else if (sFieldName === 'sLocationId' || sFieldName === 'sLocationNo' || sFieldName === 'sLocationName') {
  1006 + tableDataRow.sLocationId = changeValue.sLocationId;
  1007 + tableDataRow.sLocationNo = changeValue.sLocationNo;
  1008 + tableDataRow.sLocationName = changeValue.sLocationName;
  1009 + } else if (sFieldName === 'sWareHouseLocationId' || sFieldName === 'sWareHouseLocationNo' || sFieldName === 'sWareHouseLocationName') {
  1010 + tableDataRow.sWareHouseLocationId = changeValue.sWareHouseLocationId;
  1011 + tableDataRow.sWareHouseLocationNo = changeValue.sWareHouseLocationNo;
  1012 + tableDataRow.sWareHouseLocationName = changeValue.sWareHouseLocationName;
  1013 + }
  1014 + tableDataRow.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType;
  1015 + }
  1016 + slaveDataNew.push(tableDataRow);
  1017 + }
  1018 + addState.slaveData = slaveDataNew;
  1019 + // this.props.onSaveState({ slaveData: slaveDataNew });
  1020 + } else if ((sFieldName === 'sCustomerId' || sFieldName === 'sCustomerNo' || sFieldName === 'sCustomerName')) {
  1021 + if (bNewSlaveData) {
  1022 + const slaveDataNew = [];
  1023 + const allTableData = {};
  1024 + allTableData.master = returnData.masterData;
  1025 + const tableDataRowAdd = commonFunc.getDefaultData(slaveConfig, allTableData);
  1026 + tableDataRowAdd.handleType = 'add';
  1027 + tableDataRowAdd.sId = commonUtils.createSid();
  1028 + tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null;
  1029 + tableDataRowAdd.key = tableDataRowAdd.sId;
  1030 + tableDataRowAdd.bDefault = false;
  1031 + tableDataRowAdd.iOrder = 1;
  1032 + slaveDataNew.push(tableDataRowAdd);
  1033 + addState.slaveData = slaveDataNew;
  1034 + // this.props.onSaveState({ slaveData: slaveDataNew });
  1035 + } else if (sModelsType.includes('sales/') || sModelsType.includes('cashier/') || sModelsType.includes('manufacture/')) { // 获取应收款
  1036 + if (commonUtils.isNotEmptyObject(masterData)) {
  1037 + this.getCustomerReceipt({ masterData: returnData.masterData });
  1038 + }
  1039 + }
  1040 + } else if (sFieldName === 'sTestStandardId' || sFieldName === 'sTestStandardName') {
  1041 + const { slaveDelData: slaveDelDataOld, slaveConfig, masterConfig } = this.props;
  1042 + const dataUrl = `${commonConfig.server_host}eleteamemployee/getObtainInspectionStandards?sModelsId=${sModelsId}&sParentId=${returnData.masterData.sTestStandardId}`;
  1043 + const dataReturn = (await commonServices.getService(this.props.app.token, dataUrl)).data;
  1044 + const slaveDelData = commonUtils.isEmptyArr(slaveDelDataOld) ? [] : slaveDelDataOld;
  1045 + if (dataReturn.code === 1) {
  1046 + const returnSlaveData = dataReturn.dataset.rows;
  1047 + slaveData.forEach((item) => {
  1048 + item.handleType = 'del';
  1049 + slaveDelData.push(item);
  1050 + });
  1051 + const slaveDataNew = [];
  1052 + const newCopyTo = {};
  1053 + newCopyTo.master = masterData;
  1054 + const iConfigIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'sTestStandardName');
  1055 + const iSqlIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === 'sActValue');
  1056 + returnSlaveData.forEach((item, iIndex) => {
  1057 + let tableDataRow = commonFunc.getDefaultData(slaveConfig, {});
  1058 + tableDataRow.handleType = 'add';
  1059 + tableDataRow.sId = commonUtils.createSid();
  1060 + tableDataRow.sParentId = masterData && masterData.sId ? masterData.sId : null;
  1061 + tableDataRow.key = tableDataRow.sId;
  1062 + tableDataRow.iOrder = iIndex;
  1063 + if (iConfigIndex > -1) {
  1064 + tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(masterConfig.gdsconfigformslave[iConfigIndex].sAssignField, item, newCopyTo) }; // 取赋值字段
  1065 + // tableDataRow.sTestReference = '15S|20S';
  1066 + const sTestReference = tableDataRow.sTestReference;
  1067 + const sParamObj = {};
  1068 + if (commonUtils.isNotEmptyObject(sTestReference)) {
  1069 + if (sTestReference.indexOf('|') >= 0) {
  1070 + sTestReference.split('|').forEach((itemField) => {
  1071 + sParamObj[itemField] = itemField;
  1072 + });
  1073 + tableDataRow.sParamDropDownsActValue = sParamObj;
  1074 + if (iSqlIndex > -1) {
  1075 + slaveConfig.gdsconfigformslave[iSqlIndex].sDropDownType = 'sql';
  1076 + } else {
  1077 + slaveConfig.gdsconfigformslave[iSqlIndex].sDropDownType = '';
  1078 + }
  1079 + }
  1080 + } else { /* 若数据没有值 则渲染文本框 */
  1081 + tableDataRow.isText = true;
  1082 + }
  1083 + }
  1084 + slaveDataNew.push(tableDataRow);
  1085 + });
  1086 + addState.slaveData = slaveDataNew;
  1087 + } else {
  1088 + Toast.fail(dataReturn.msg);
  1089 + }
  1090 + }
  1091 + const models = name === 'materials' ? 'Materials' :
  1092 + sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('print/') || sModelsType.includes('quotation/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
  1093 + if (sModelsType.includes('purchase/') || sModelsType.includes('print/') || sModelsType.includes('quotation/') || sModelsType.includes('manufacture/') || sModelsType.includes('materialsStock/') || sModelsType.includes('outside/') || sModelsType.includes('quality/')) {
  1094 + let masterData = await this.handleMaterialsChange(returnData.masterData, sModelsId, masterData, changeValue, sFieldName, app, token, models);
  1095 + masterData = commonBusiness.getCalculateAllMoney(app, models, sFieldName, masterData, masterData);
  1096 + if (sFieldName !== 'dPackQty') {
  1097 + if (changeValue.dPackQty !== this.state.dPackQtyChange && changeValue.dPackQty !== undefined) {
  1098 + masterData = commonBusiness.getCalculateAllMoney(app, models, 'dPackQty', masterData, masterData);
  1099 + this.setState({ dPackQtyChange: changeValue.dPackQty });
  1100 + }
  1101 + }
  1102 + returnData = { ...returnData, masterData };
  1103 + }
  1104 + if (isWait) {
  1105 + return { ...returnData, ...addState, enabled: true };
  1106 + } else {
  1107 + this.props.onSaveState({ ...returnData, ...addState, enabled: true });
  1108 + return returnData;
  1109 + }
  1110 + }
  1111 +
  1112 + /** 表格数据更改 */
  1113 + // name 不写完整的state名称作用为了要用到total // (name, changeValue, sId, dropDownData)
  1114 + handleTableChange = async (name, sFieldName, changeValue, sId, dropDownData, isWait) => {
  1115 + /* 从CommonBase获取默认参数 */
  1116 + const {
  1117 + [`${name}Data`]: tableData, sModelsType, sModelsId, token, app,
  1118 + } = this.props;
  1119 + if (name === 'control' && sModelsType === 'sales/salesOrder') {
  1120 + const { [`${name}Data`]: tableData, materialsData: materialsDataOld, processData: processDataOld } = this.props;
  1121 + let tableDataRow = await this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
  1122 + if (tableDataRow === undefined) return;
  1123 + if (sFieldName === 'dSinglePQty' || sFieldName === 'dSumPQty' || sFieldName === 'iPrintModePo' || sFieldName === 'iPrintMode' || sFieldName === 'iPrintModePo' || sFieldName === 'iPositiveColor' ||
  1124 + sFieldName === 'iPositiveSpecialColor' || sFieldName === 'iOppositeColor' || sFieldName === 'iOppositeSpecialColor') {
  1125 + if (sFieldName === 'iPrintModePo') {
  1126 + if (tableDataRow.iPrintModePo === 0) {
  1127 + tableDataRow.iPrintMode = 3;
  1128 + if (tableDataRow.iPositiveColor === 0) {
  1129 + tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
  1130 + tableDataRow.iOppositeColor = 0;
  1131 + tableDataRow.iOppositeSpecialColor = 0;
  1132 + } else {
  1133 + tableDataRow.iOppositeColor = 0;
  1134 + tableDataRow.iOppositeSpecialColor = 0;
  1135 + }
  1136 + } else if (tableDataRow.iPrintModePo === 1) {
  1137 + tableDataRow.iPrintMode = 3;
  1138 + if (tableDataRow.iPositiveColor === 0) {
  1139 + tableDataRow.iPositiveColor = 0;
  1140 + tableDataRow.iPositiveSpecialColor = 0;
  1141 + tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? 4 : tableDataRow.iOppositeColor;
  1142 + } else {
  1143 + tableDataRow.iPositiveColor = 0;
  1144 + tableDataRow.iPositiveSpecialColor = 0;
  1145 + }
  1146 + } else {
  1147 + tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
  1148 + tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? tableDataRow.iPositiveColor : tableDataRow.iOppositeColor;
  1149 + }
  1150 + } else if (sFieldName === 'iPrintMode') {
  1151 + if (tableDataRow.iPrintMode === 0 || tableDataRow.iPrintMode === 1) {
  1152 + tableDataRow.iPositiveColor = commonUtils.isEmpty(tableDataRow.iPositiveColor) || tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
  1153 + tableDataRow.iOppositeColor = tableDataRow.iPositiveColor;
  1154 + tableDataRow.iOppositeSpecialColor = tableDataRow.iPositiveSpecialColor;
  1155 + } else if (tableDataRow.iPrintMode === 2) {
  1156 + tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
  1157 + tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? tableDataRow.iPositiveColor : tableDataRow.iOppositeColor;
  1158 + } else if (tableDataRow.iPrintMode === 3) {
  1159 + tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
  1160 + tableDataRow.iOppositeColor = 0;
  1161 + tableDataRow.iOppositeSpecialColor = 0;
  1162 + } else if (tableDataRow.iPrintMode === 4) {
  1163 + tableDataRow.iPositiveColor = 0;
  1164 + tableDataRow.iPositiveSpecialColor = 0;
  1165 + tableDataRow.iOppositeColor = 0;
  1166 + tableDataRow.iOppositeSpecialColor = 0;
  1167 + }
  1168 + } else if (sFieldName === 'iPositiveColor' || sFieldName === 'iPositiveSpecialColor') {
  1169 + if (tableDataRow.iPrintMode === 0 || tableDataRow.iPrintMode === 1) {
  1170 + tableDataRow.iOppositeColor = tableDataRow.iPositiveColor;
  1171 + tableDataRow.iOppositeSpecialColor = tableDataRow.iPositiveSpecialColor;
  1172 + }
  1173 + }
  1174 + tableDataRow = this.singlePQtyChange(tableDataRow);
  1175 + }
  1176 + const materialsData = [];
  1177 + const processData = [];
  1178 + materialsDataOld.forEach((item) => {
  1179 + const itemNew = { ...item };
  1180 + if (itemNew.sControlId === sId) {
  1181 + itemNew.sPartsName = tableDataRow.sPartsName;
  1182 + }
  1183 + materialsData.push(itemNew);
  1184 + });
  1185 + processDataOld.forEach((item) => {
  1186 + const itemNew = { ...item };
  1187 + if (itemNew.sControlId === sId) {
  1188 + itemNew.sPartsName = tableDataRow.sPartsName;
  1189 + }
  1190 + processData.push(itemNew);
  1191 + });
  1192 + const materialsDataNew = this.sortData(tableData, materialsData);
  1193 + const processDataNew = this.sortData(tableData, processData);
  1194 +
  1195 + const iIndex = tableData.findIndex(item => item.sId === sId);
  1196 + tableData[iIndex] = tableDataRow;
  1197 + this.props.onSaveState({ [`${name}Data`]: tableData, materialsData: materialsDataNew, processData: processDataNew });
  1198 + } else {
  1199 + let { masterData } = this.props;
  1200 + const iIndex = tableData.findIndex(item => item.sId === sId);
  1201 + // if (sFieldName.substring(0, 1) === 'd' && commonUtils.convertToNum(tableData[iIndex][sFieldName]) === commonUtils.convertToNum(changeValue[sFieldName])) {
  1202 + // if (!(tableData[iIndex][sFieldName] === undefined && commonUtils.convertToNum(changeValue[sFieldName]) === 0)) return;
  1203 + // }
  1204 + if (sFieldName === 'sProductName' && name === 'slave' && (sModelsType.includes('sales/salesOrder') || sModelsType.includes('manufacture/workOrder') || sModelsType.includes('quotation/quotation'))) {
  1205 + if (commonUtils.isNotEmptyObject(changeValue) && Object.keys(changeValue).length === 1 && Object.keys(changeValue)[0] === sFieldName) {
  1206 + changeValue.sProductId = changeValue.sProductName;
  1207 + }
  1208 + }
  1209 + let tableDataRow = this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
  1210 + if ((sFieldName === 'sProductId' || sFieldName === 'sProductName' || sFieldName === 'sProductStyle' || sFieldName === 'sProductUnit' || sFieldName === 'sProductNo'
  1211 + || sFieldName === 'sCustomerProductNo' || sFieldName === 'sProductClassifyId' || sFieldName === 'sProductClassifyName') && !commonUtils.isEmpty(tableDataRow.sProductId)) {
  1212 + const productIdDropDown = commonUtils.getStoreDropDownData(sModelsId, 'slave', sFieldName);
  1213 + const iProductIdIndex = commonUtils.isEmptyArr(productIdDropDown) ? -1 : productIdDropDown.findIndex(item => item.sId === tableDataRow.sProductId);
  1214 + if (iProductIdIndex === -1) {
  1215 + tableDataRow.sProductInfo = JSON.stringify({
  1216 + sProductId: tableDataRow.sProductName,
  1217 + sProductName: tableDataRow.sProductName,
  1218 + sProductStyle: tableDataRow.sProductStyle,
  1219 + sProductUnit: tableDataRow.sProductUnit,
  1220 + sProductNo: tableDataRow.sProductNo,
  1221 + sCustomerProductNo: tableDataRow.sCustomerProductNo,
  1222 + sProductClassifyId: tableDataRow.sProductClassifyId,
  1223 + sProductClassifyName: tableDataRow.sProductClassifyName,
  1224 + });
  1225 + } else {
  1226 + tableDataRow.sProductInfo = '';
  1227 + }
  1228 + if ((sFieldName === 'sProductId' || sFieldName === 'sProductName' || sFieldName === 'sProductNo') && !commonUtils.isEmpty(changeValue.sProductId)) {
  1229 + const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
  1230 + const value = {
  1231 + sProName: 'Sp_Cashier_GetProductPrice',
  1232 + paramsMap: {
  1233 + sProductGuid: changeValue.sProductId,
  1234 + },
  1235 + };
  1236 + const returnData = (await commonServices.postValueService(app.token, value, url)).data;
  1237 + if (returnData.code === 1) {
  1238 + tableDataRow.dProductPrice = returnData.dataset.rows[0].dataSet.outData[0].dPrice;
  1239 + }
  1240 + const models = name === 'materials' ? 'Materials' :
  1241 + sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('quotation/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
  1242 + if (sModelsType.includes('purchase/') || sModelsType.includes('quotation/') || sModelsType.includes('manufacture/') || sModelsType.includes('materialsStock/') || sModelsType.includes('outside/')) {
  1243 + tableDataRow = await this.handleMaterialsChange(tableDataRow, sModelsId, masterData, changeValue, 'dProductQty', app, token, models);
  1244 + }
  1245 + tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'dProductQty', masterData, tableDataRow);
  1246 + // else {
  1247 + // this.props.getServiceError(returnData);
  1248 + // }
  1249 + }
  1250 + } else if (sModelsType === 'sales/salesOrder' && (sFieldName === 'sProductClassifyId' || sFieldName === 'sProductClassifyName') && name === 'slave') {
  1251 + const { controlData } = this.props;
  1252 + if (controlData !== undefined && !commonUtils.isEmpty(tableData.sProductInfo)) {
  1253 + const controlDataFilter = controlData.filter(item => item.sSlaveId === tableData[iIndex].sId);
  1254 + const tableSelectedRowKeys = [];
  1255 + controlDataFilter.forEach((item) => {
  1256 + tableSelectedRowKeys.push(item.sId);
  1257 + });
  1258 + const materialsReturnData = this.otherTableDel('materials', tableSelectedRowKeys);
  1259 + const processReturnData = this.otherTableDel('process', tableSelectedRowKeys);
  1260 + const controlReturnData = this.props.onDataRowDel('control', true, tableSelectedRowKeys);
  1261 + this.props.onSaveState({
  1262 + ...materialsReturnData,
  1263 + ...processReturnData,
  1264 + ...controlReturnData,
  1265 + });
  1266 + }
  1267 + } else if (sModelsType.includes('cashier/') && sFieldName === 'dTotalMoney') { /* 付款单、收款单,从表付款/收款金额改变,会自动汇总到主表付款金额中 */
  1268 + const addStata = {};
  1269 + addStata.dTotalMoney = 0;
  1270 + if (iIndex > -1) { /* 选中行 */
  1271 + let dMoney = commonUtils.isNotEmptyNumber(tableDataRow.dTotalMoney) ? tableDataRow.dTotalMoney : 0;
  1272 + dMoney = commonUtils.convertStrToNumber(dMoney);
  1273 + addStata.dTotalMoney = dMoney + commonUtils.convertStrToNumber(addStata.dTotalMoney);
  1274 + }
  1275 + tableData.forEach((item, index) => { /* 非选中行 */
  1276 + if (index !== iIndex) {
  1277 + const dMoney = commonUtils.isNotEmptyNumber(item.dTotalMoney) ? item.dTotalMoney : 0;
  1278 + addStata.dTotalMoney = commonUtils.convertFixNum(dMoney, 6) + commonUtils.convertFixNum(addStata.dTotalMoney, 6);
  1279 + }
  1280 + });
  1281 + masterData = { ...masterData, ...addStata };
  1282 + this.props.onSaveState({ masterData });
  1283 + }
  1284 + // 取工艺卡数据
  1285 + if (sModelsType === 'sales/salesOrder' && (sFieldName === 'sProductId' || sFieldName === 'sProductNo' || sFieldName === 'sProductName') && name === 'slave') {
  1286 + const {
  1287 + controlConfig, materialsConfig, processConfig,
  1288 + } = this.props;
  1289 + let { controlData, materialsData, processData } = this.props;
  1290 + const sId = tableData[iIndex].sId;
  1291 + const bCkxCopyFromTechnology = '1'; // app.systemData.filter(item => item.sName === 'CkxCopyFromTechnology')[0].sValue;
  1292 + if (bCkxCopyFromTechnology === '1' && tableDataRow.sProductId !== tableDataRow.sProductName) {
  1293 + const controlSelectedData = controlData.filter(item => item.sSlaveId === sId);
  1294 + if (commonUtils.isNotEmptyObject(controlSelectedData)) {
  1295 + const materialsReturnData = this.otherTableDel('materials', controlSelectedData);
  1296 + const processReturnData = this.otherTableDel('process', controlSelectedData);
  1297 + const controlReturnData = this.props.onDataRowDel('control', true, controlSelectedData);
  1298 + controlData = controlReturnData.controlData;
  1299 + materialsData = materialsReturnData.materialsData;
  1300 + processData = processReturnData.processData;
  1301 + this.props.onSaveState({
  1302 + ...materialsReturnData,
  1303 + ...processReturnData,
  1304 + ...controlReturnData,
  1305 + });
  1306 + }
  1307 + const sCustomerId = masterData.sCustomerId;
  1308 + const sProductId = changeValue.sProductId;
  1309 + const sProductIdArray = [];
  1310 + sProductIdArray.push(sProductId);
  1311 + const sProductIds = sProductIdArray.toString();
  1312 + const condition = { sCustomerId, sProductIds };
  1313 + const dataUrl = `${commonConfig.server_host}salesorder/getProcessCardDataByCustomIdProductId/?sModelsId=${sModelsId}`;
  1314 + const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
  1315 + const config = this.props.masterConfig.gdsconfigformslave.filter(item => item.sControlName.includes('BtnCopyFrom.ActProcessCard'));
  1316 + if (dataReturn.code === 1) {
  1317 + const returnData = dataReturn.dataset.rows[0];
  1318 + const copyToControlConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Control'.toLowerCase());
  1319 + const copyToMaterialsConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Materials'.toLowerCase());
  1320 + const copyToProcessConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Process'.toLowerCase());
  1321 + const controlAssignField = commonUtils.isNotEmptyArr(copyToControlConfig) ? copyToControlConfig[0].sAssignField : '';
  1322 + const materialsAssignField = commonUtils.isNotEmptyArr(copyToMaterialsConfig) ? copyToMaterialsConfig[0].sAssignField : '';
  1323 + const processAssignField = commonUtils.isNotEmptyArr(copyToProcessConfig) ? copyToProcessConfig[0].sAssignField : '';
  1324 + const newCopyTo = {};
  1325 + newCopyTo.master = masterData;
  1326 + newCopyTo.slave = commonUtils.isEmptyArr(tableData) ? {} : tableData;
  1327 + if (commonUtils.isNotEmptyArr(returnData.controlData)) {
  1328 + // eslint-disable-next-line no-loop-func
  1329 + returnData.controlData.forEach((controlItem) => {
  1330 + newCopyTo.control = controlItem;
  1331 + let controlRow = commonFunc.getDefaultData(controlConfig, newCopyTo); // 取默认值
  1332 + controlRow = { ...controlRow, ...commonFunc.getAssignFieldValue(controlAssignField, controlItem, newCopyTo) }; // 取赋值字段
  1333 + controlRow.handleType = 'add';
  1334 + controlRow.sId = commonUtils.createSid();
  1335 + controlRow.sSlaveId = tableDataRow.sId;
  1336 + controlRow.sParentId = masterData.sId;
  1337 + controlData.push(controlRow);
  1338 +
  1339 + if (commonUtils.isNotEmptyArr(returnData.materialsData)) {
  1340 + returnData.materialsData.filter(item => item.sControlId === controlItem.sId).forEach((materialsItem) => {
  1341 + newCopyTo.materials = materialsItem;
  1342 + let materialsRow = commonFunc.getDefaultData(materialsConfig, newCopyTo); // 取默认值
  1343 + materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
  1344 + materialsRow.handleType = 'add';
  1345 + materialsRow.sId = commonUtils.createSid();
  1346 + materialsRow.sSlaveId = tableDataRow.sId;
  1347 + materialsRow.sParentId = masterData.sId;
  1348 + materialsRow.sControlId = controlRow.sId;
  1349 + materialsRow.sPartsName = controlRow.sPartsName;
  1350 +
  1351 + materialsData.push(materialsRow);
  1352 + });
  1353 + }
  1354 +
  1355 + if (commonUtils.isNotEmptyArr(returnData.processData)) {
  1356 + returnData.processData.filter(item => item.sControlId === controlItem.sId).forEach((processItem) => {
  1357 + newCopyTo.process = processItem;
  1358 + let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
  1359 + processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
  1360 + processRow.handleType = 'add';
  1361 + processRow.sId = commonUtils.createSid();
  1362 + processRow.sSlaveId = tableDataRow.sId;
  1363 + processRow.sParentId = masterData.sId;
  1364 + processRow.sControlId = controlRow.sId;
  1365 + processRow.sPartsName = controlRow.sPartsName;
  1366 + processData.push(processRow);
  1367 + });
  1368 + }
  1369 + });
  1370 + }
  1371 + if (commonUtils.isNotEmptyArr(returnData.materialsData)) {
  1372 + // eslint-disable-next-line no-loop-func
  1373 + returnData.materialsData.filter(item => item.sType === '2').forEach((materialsItem) => {
  1374 + newCopyTo.materials = materialsItem;
  1375 + let materialsRow = commonFunc.getDefaultData(materialsConfig, newCopyTo); // 取默认值
  1376 + materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
  1377 + materialsRow.handleType = 'add';
  1378 + materialsRow.sId = commonUtils.createSid();
  1379 + materialsRow.sSlaveId = tableDataRow.sId;
  1380 + materialsRow.sParentId = masterData.sId;
  1381 + materialsData.push(materialsRow);
  1382 + });
  1383 + }
  1384 +
  1385 + if (commonUtils.isNotEmptyArr(returnData.processData)) {
  1386 + // eslint-disable-next-line no-loop-func
  1387 + returnData.processData.filter(item => item.sType === '3').forEach((processItem) => {
  1388 + newCopyTo.process = processItem;
  1389 + let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
  1390 + processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
  1391 + processRow.handleType = 'add';
  1392 + processRow.sId = commonUtils.createSid();
  1393 + processRow.sSlaveId = tableDataRow.sId;
  1394 + processRow.sParentId = masterData.sId;
  1395 + processData.push(processRow);
  1396 + });
  1397 + }
  1398 + this.props.onSaveState({ controlData, materialsData, processData });
  1399 + }
  1400 + }
  1401 + } else if (sModelsType === 'sales/salesOrder' && (sFieldName === 'dProductQty' || sFieldName === 'dGiveQty' || sFieldName === 'dStockupQty') && name === 'slave') {
  1402 + const {
  1403 + controlData, slaveSelectedRowKeys,
  1404 + } = this.props;
  1405 + const controlSelectedData = controlData.filter(item => item.sSlaveId === slaveSelectedRowKeys[0]);
  1406 + for (const one of controlSelectedData) {
  1407 + one.handleType = commonUtils.isEmpty(one.handleType) ? 'update' : one.handleType;
  1408 + one.dPartsQty = commonUtils.isNull(tableDataRow.dProductQty, 0) + commonUtils.isNull(tableDataRow.dGiveQty, 0);
  1409 + }
  1410 + this.props.onSaveState({ controlData });
  1411 + } else if (sModelsType.includes('purchase/') && (sFieldName === 'sMaterialsId' || sFieldName === 'sMaterialsNo' || sFieldName === 'sMaterialsName') && name === 'slave') {
  1412 + const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
  1413 + const value = {
  1414 + sProName: 'Sp_Cashier_GetMaterialsPrice',
  1415 + paramsMap: {
  1416 + sMaterialsGuid: changeValue.sMaterialsId,
  1417 + sSupplyGuid: masterData.sSupplyId,
  1418 + },
  1419 + };
  1420 + const returnData = (await commonServices.postValueService(app.token, value, url)).data;
  1421 + if (returnData.code === 1) {
  1422 + tableDataRow.dMaterialsPrice = returnData.dataset.rows[0].dataSet.outData[0].dPrice;
  1423 + }
  1424 + const models = name === 'materials' ? 'Materials' :
  1425 + sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('quotation/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
  1426 + if (sModelsType.includes('purchase/') || sModelsType.includes('quotation/') || sModelsType.includes('manufacture/') || sModelsType.includes('materialsStock/') || sModelsType.includes('outside/')) {
  1427 + tableDataRow = await this.handleMaterialsChange(tableDataRow, sModelsId, masterData, changeValue, 'dAuxiliaryQty', app, token, models);
  1428 + }
  1429 + tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'dAuxiliaryQty', masterData, tableDataRow);
  1430 +
  1431 + if (Object.keys(changeValue).length > 0 && Object.keys(changeValue).findIndex(item => item === 'dMaterialsStockAuxiliaryQty') > -1) {
  1432 + const urlMaterialsStock = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
  1433 + const valueMaterialsStock = {
  1434 + sProName: 'Sp_Inventory_MaterialsInventoryV56',
  1435 + paramsMap: {
  1436 + sMaterialsGuid: tableDataRow.sMaterialsId,
  1437 + sMaterialsStyle: tableDataRow.sMaterialsStyle,
  1438 + sWarehouseGuid: tableDataRow.sWarehouseId,
  1439 + sLocationalGuid: tableDataRow.sLocationId,
  1440 + sWarehouseLocationGuid: tableDataRow.sWarehouseLocationId,
  1441 + sDefine_no: tableDataRow.sDefineNo,
  1442 + sDefine_no2: tableDataRow.sDefineNo2,
  1443 + iGetQty: 1,
  1444 + iHasZero: 1,
  1445 + },
  1446 + };
  1447 + const returnDataMaterialsStock = (await commonServices.postValueService(app.token, valueMaterialsStock, urlMaterialsStock)).data;
  1448 + if (returnDataMaterialsStock.code === 1) {
  1449 + tableDataRow.dMaterialsStockAuxiliaryQty = returnDataMaterialsStock.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
  1450 + }
  1451 + }
  1452 + if (Object.keys(changeValue).length > 0 && Object.keys(changeValue).findIndex(item => item === 'dMaterialsStockAvailableQty') > -1) {
  1453 + const urlMaterialsAvailableQty = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
  1454 + const valueMaterialsAvailableQty = {
  1455 + sProName: 'Sp_Inventory_MaterialsInventoryV56',
  1456 + paramsMap: {
  1457 + sMaterialsGuid: tableDataRow.sMaterialsId,
  1458 + sMaterialsStyle: tableDataRow.sMaterialsStyle,
  1459 + sWarehouseGuid: tableDataRow.sWarehouseId,
  1460 + sLocationalGuid: tableDataRow.sLocationId,
  1461 + sWarehouseLocationGuid: tableDataRow.sWarehouseLocationId,
  1462 + sDefine_no: tableDataRow.sDefineNo,
  1463 + sDefine_no2: tableDataRow.sDefineNo2,
  1464 + iGetQty: 2,
  1465 + iHasZero: 1,
  1466 + },
  1467 + };
  1468 + const returnDataMaterialsAvailableQty = (await commonServices.postValueService(app.token, valueMaterialsAvailableQty, urlMaterialsAvailableQty)).data;
  1469 + if (returnDataMaterialsAvailableQty.code === 1) {
  1470 + tableDataRow.dMaterialsStockAvailableQty = returnDataMaterialsAvailableQty.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
  1471 + }
  1472 + }
  1473 + // else {
  1474 + // this.props.getServiceError(returnData);
  1475 + // }
  1476 + } else if (sModelsType === 'sales/salesCheck' && sFieldName === 'dLossMoney' && name === 'slave') {
  1477 + if (commonUtils.isNotEmptyNumber(tableDataRow.dSrcMoney) && commonUtils.isNotEmptyNumber(tableDataRow.dLossMoney)) {
  1478 + const dPprice = this.props.getFloatNum('dProductPrice'); /* 获取系统设定小数位 */
  1479 + tableDataRow.dProductMoney = commonUtils.convertFixNum(tableDataRow.dSrcMoney - tableDataRow.dLossMoney, dPprice);
  1480 + } else if (commonUtils.isNotEmptyNumber(tableDataRow.dSrcMoney) && commonUtils.isEmptyNumber(tableDataRow.dLossMoney)) {
  1481 + tableDataRow.dProductMoney = tableDataRow.dSrcMoney;
  1482 + tableDataRow.dLossMoney = 0;
  1483 + }
  1484 + }
  1485 + /* 各种金额,税额,价格计算 */
  1486 + const models = name === 'materials' ? 'Materials' :
  1487 + sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('quotation/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
  1488 + if (sModelsType.includes('purchase/') || sModelsType.includes('quotation/') || sModelsType.includes('manufacture/') || sModelsType.includes('materialsStock/') || sModelsType.includes('outside/')) {
  1489 + tableDataRow = await this.handleMaterialsChange(tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models);
  1490 + }
  1491 + tableDataRow = commonBusiness.getCalculateAllMoney(app, models, sFieldName, masterData, tableDataRow);
  1492 + let dMaterialsMoney = '';
  1493 + if (sModelsType.includes('outside/')) { /* 工序发外 && (sFieldName === 'sSupplyName' || sFieldName === 'sProcessName' || sFieldName === 'dAuxiliaryQty') */
  1494 + let sComputeId = {};
  1495 + const sSupplyId = masterData.sSupplyId;
  1496 + const sProcessId = tableDataRow.sProcessId;
  1497 + /* 根据客户id,工序id获取公式ID */
  1498 + sComputeId = await commonBusiness.getOutSideProcessFormula({
  1499 + token, sModelsId, sSupplyId, sProcessId,
  1500 + });
  1501 + if (!commonUtils.isEmpty(sComputeId)) {
  1502 + dMaterialsMoney = await commonBusiness.getFormulaValue({
  1503 + token, sModelsId, masterData, tableDataRow, sComputeId,
  1504 + });
  1505 + tableDataRow.dMaterialsMoney = dMaterialsMoney;
  1506 + tableDataRow = commonBusiness.getCalculateMoney(app, masterData, tableDataRow, 'Materials');
  1507 + }
  1508 + }
  1509 + if (isWait) {
  1510 + return tableDataRow;
  1511 + } else {
  1512 + tableData[iIndex] = tableDataRow;
  1513 + this.props.onSaveState({ [`${name}Data`]: tableData, enabled: true });
  1514 + }
  1515 + }
  1516 + };
  1517 +
  1518 + handleMaterialsChange = async (tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models) => {
  1519 + const { sComputeId, sConversionComputeId, sReConversionComputeId } = tableDataRow;
  1520 + if (sFieldName === 'sMaterialsNo' || sFieldName === 'sMaterialsName' || sFieldName === 'dAuxiliaryQty' || sFieldName === 'dReelAuxiliaryQty' || sFieldName === 'dConversionQty' || sFieldName === 'sMaterialsStyle') {
  1521 + if (sFieldName === 'dReelAuxiliaryQty') {
  1522 + if (tableDataRow.sMaterialsUnit === '吨' && tableDataRow.bReel && tableDataRow.dGramWeight > 0) {
  1523 + tableDataRow = commonBusiness.getMaterialsQty(app, { ...tableDataRow, sMaterialsStyle: tableDataRow.sReelMaterialsStyle }, 'dReelAuxiliaryQty', 'dMaterialsQty');
  1524 + tableDataRow.dAuxiliaryQty = tableDataRow.dMaterialsQty;
  1525 + tableDataRow.sMaterialsStyle = tableDataRow.sMaterialsStyle !== undefined && tableDataRow.sMaterialsStyle.split('*').length > 1 ? tableDataRow.sMaterialsStyle.split('*')[0] : tableDataRow.sMaterialsStyle;
  1526 + tableDataRow.sAuxiliaryUnit = tableDataRow.sMaterialsUnit;
  1527 + } else if (tableDataRow.sMaterialsUnit.toUpper() === 'M2' && tableDataRow.bReel) {
  1528 + tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, 'dReelAuxiliaryQty', 'dMaterialsQty');
  1529 + tableDataRow.dAuxiliaryQty = tableDataRow.dReelAuxiliaryQty;
  1530 + } else {
  1531 + tableDataRow.dAuxiliaryQty = tableDataRow.dReelAuxiliaryQty;
  1532 + }
  1533 + }
  1534 + if (commonUtils.isEmpty(sComputeId) && sFieldName !== 'dConversionQty') {
  1535 + tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, 'dAuxiliaryQty', 'dMaterialsQty');
  1536 + } else if (!commonUtils.isEmpty(sComputeId)) {
  1537 + tableDataRow.dMaterialsQty = await commonBusiness.getFormulaValue({
  1538 + token, sModelsId, masterData, tableDataRow, sComputeId,
  1539 + });
  1540 + }
  1541 + if (sFieldName !== 'dConversionQty' && !commonUtils.isEmpty(sConversionComputeId)) {
  1542 + tableDataRow.dConversionQty = await commonBusiness.getFormulaValue({
  1543 + token, sModelsId, masterData, tableDataRow, sComputeId: sConversionComputeId,
  1544 + });
  1545 + }
  1546 + } else if (sFieldName === 'dMaterialsQty') {
  1547 + const { sReComputeId } = tableDataRow;
  1548 + if (commonUtils.isEmpty(sReComputeId) && tableDataRow.bInverse) {
  1549 + tableDataRow = commonBusiness.getAuxiliaryQty(app, tableDataRow, sFieldName, 'dAuxiliaryQty');
  1550 + } else if (tableDataRow.bInverse) {
  1551 + tableDataRow.dAuxiliaryQty = await commonBusiness.getFormulaValue({
  1552 + token, sModelsId, masterData, tableDataRow, sComputeId: sReComputeId,
  1553 + });
  1554 + }
  1555 + if (!commonUtils.isEmpty(sReConversionComputeId)) {
  1556 + tableDataRow.dConversionQty = await commonBusiness.getFormulaValue({
  1557 + token, sModelsId, masterData, tableDataRow, sComputeId: sReConversionComputeId,
  1558 + });
  1559 + }
  1560 + } else if (sFieldName === 'dAuxiliaryLossQty') {
  1561 + if (commonUtils.isEmpty(sComputeId)) {
  1562 + tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, sFieldName, 'dLossQty');
  1563 + } else {
  1564 + tableDataRow.dLossQty = await commonBusiness.getFormulaValue({
  1565 + token, sModelsId, masterData, tableDataRow, sComputeId,
  1566 + });
  1567 + }
  1568 + if (!commonUtils.isEmpty(tableDataRow.dSrcSurplusAuxiliaryQty)) {
  1569 + tableDataRow.dAuxiliaryQty = tableDataRow.dSrcSurplusAuxiliaryQty - tableDataRow.dAuxiliaryLossQty;
  1570 + tableDataRow.dMaterialsQty = commonUtils.convertFixNum(tableDataRow.dSrcSurplusQty - tableDataRow.dLossQty, 6);
  1571 + }
  1572 + } else if (sFieldName === 'dLossQty') {
  1573 + const { sReComputeId } = tableDataRow;
  1574 + if (commonUtils.isEmpty(sReComputeId) && tableDataRow.bInverse) {
  1575 + tableDataRow = commonBusiness.getAuxiliaryQty(app, tableDataRow, sFieldName, 'dAuxiliaryLossQty');
  1576 + } else if (tableDataRow.bInverse) {
  1577 + tableDataRow.dAuxiliaryLossQty = await commonBusiness.getFormulaValue({
  1578 + token, sModelsId, masterData, tableDataRow, sComputeId: sReComputeId,
  1579 + });
  1580 + }
  1581 + if (!commonUtils.isEmpty(tableDataRow.dSrcSurplusAuxiliaryQty)) {
  1582 + tableDataRow.dAuxiliaryQty = tableDataRow.dSrcSurplusAuxiliaryQty - tableDataRow.dAuxiliaryLossQty;
  1583 + tableDataRow.dMaterialsQty = tableDataRow.dSrcSurplusQty - tableDataRow.dLossQty;
  1584 + }
  1585 + } else if (sFieldName === 'sProcessId' || sFieldName === 'sProcessNo' || sFieldName === 'sProcessName') {
  1586 + const sProcessId = changeValue.sProcessId;
  1587 + const url = `${commonConfig.server_host}process/outsideprocess?sModelsId=${sModelsId}&sProcessId=${sProcessId}`;
  1588 + const dataReturn = (await commonServices.getService(token, url)).data;
  1589 + if (dataReturn.code === 1) {
  1590 + if (commonUtils.isNotEmptyArr(dataReturn.dataset.rows)) {
  1591 + tableDataRow.dMaterialsPrice = dataReturn.dataset.rows[0].dMaterialsPrice;
  1592 + }
  1593 + tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'dMaterialsPrice', masterData, tableDataRow);
  1594 + }
  1595 + }
  1596 + return tableDataRow;
  1597 + }
  1598 +
  1599 + handleCustomerChange = (name, changeValue) => {
  1600 + if (commonUtils.isNotEmptyObject(changeValue)) {
  1601 + if (changeValue.sCustomerId !== this.state.changleCustomerId) {
  1602 + const sCustomerId = [];
  1603 + sCustomerId.push(changeValue.sCustomerId);
  1604 + this.handleTableSelectRowChange(name, sCustomerId, changeValue);
  1605 + }
  1606 + }
  1607 + this.setState({ changleCustomerId: changeValue.sCustomerId });
  1608 + }
  1609 + handleMobileScan = (fieldConfig, tbName, record) => {
  1610 + if (commonUtils.isNotEmptyObject(fieldConfig)) {
  1611 + const sFieldName = fieldConfig.sName;
  1612 + const newTableName = 'master';
  1613 + BarCodeUtil.startScan(async (type, code) => {
  1614 + const {
  1615 + slaveConfig, sModelsId, masterData, slaveData, sModelsType, masterConfig,
  1616 + } = this.props;
  1617 + /* 规则定义
  1618 + 材料
  1619 + sDefineNo: codeArr[0], --唯一码
  1620 + sMaterialsName: codeArr[1], --材料名称
  1621 + sMaterialsStyle: codeArr[2], --材料规格
  1622 + dAuxiliaryQty: codeArr[3], --数量
  1623 + sWareHouseName: codeArr[4], --仓库名称
  1624 + sLocationName: codeArr[5], --名称
  1625 + sDefineNo2: codeArr[6], --二维码
  1626 + tInStoreDate: codeArr[7], --入库日期
  1627 + sMaterialsId: codeArr[8], --材料ID
  1628 + sWareHouseId: codeArr[9], --仓库ID
  1629 + sLocationId: codeArr[10], --sLocationId
  1630 + 成品
  1631 + sDefineNo: codeArr[0], --唯一码
  1632 + sProductName: codeArr[1], --产品名称
  1633 + sProductStyle: codeArr[2], --产品规格
  1634 + dProductQty: codeArr[3], --产品数量
  1635 + sWarehouseName: codeArr[4], --仓库名称
  1636 + sLocationName: codeArr[5], --仓库名称
  1637 + sDefineNo2: codeArr[6], --二维码
  1638 + tInStoreDate: codeArr[7], --入库日期
  1639 + sProductId: codeArr[8], --产品ID
  1640 + sWareHouseId: codeArr[9], --仓库ID
  1641 + sLocationId: codeArr[10],
  1642 + sCustomerName: codeArr[11], --客户名称
  1643 + sCustomerShort: codeArr[12],
  1644 + sOrderNo: codeArr[13], --订单号
  1645 + sWorkOrderNo: codeArr[14], --工单号
  1646 + sCustomerOrderNo: codeArr[15], --客户编号
  1647 + sCustomerProductNo: codeArr[16], --客户产品编号
  1648 + */
  1649 + // const slaveData = [];
  1650 + let slaveDataObj = {};
  1651 + let masterdataObj = {};
  1652 + let slaveDataObjAdd = {};
  1653 + const masterDataObjAdd = {};
  1654 + if (commonUtils.isEmptyObject(code)) {
  1655 + Toast.fail('二维码扫码失败!', 1);
  1656 + return;
  1657 + }
  1658 + const codeArr = code.split('|');
  1659 + let models = '';
  1660 + if (codeArr.length === 12) { /* 材料 */
  1661 + models = 'Materials';
  1662 + } else if (codeArr.length === 17) { /* 成品 */
  1663 + models = 'Product';
  1664 + } else {
  1665 + models = 'Single'; /* 单一的 */
  1666 + }
  1667 + if (models === 'Single') { /* sModelsType === 'purchase/purchaseInstore' 扫码入库、扫码领料(唯一码) */
  1668 + /* 取第一条码 */
  1669 + const sCode = codeArr.length > 0 ? codeArr[0] : '';
  1670 + /* 如果条码已存在,提示 */
  1671 + // const iIndex = slaveData.findIndex(item => commonUtils.isNotEmptyObject(item.sDefineNo) && item.sDefineNo === sDefineNo);
  1672 + // if (iIndex > -1) {
  1673 + // Toast.fail('条码已存在!!!', 1);
  1674 + // return;
  1675 + // }
  1676 + if (tbName === 'master') {
  1677 + masterData[sFieldName] = sCode;
  1678 + }
  1679 + if (tbName === 'master') {
  1680 + masterdataObj = {
  1681 + ...masterData, [sFieldName]: sCode,
  1682 + };
  1683 + } else if(tbName === 'slave') {
  1684 + if(commonUtils.isNotEmptyArr(slaveData)) {
  1685 + /* 如果是从表的字段配置了扫码 那么则将值赋值到字段上 */
  1686 + const iIndex = commonUtils.isNotEmptyArr(slaveData) ? slaveData.findIndex(item => item.sId === record.sId) : -1;
  1687 + if (iIndex > -1) {
  1688 + const newType = commonUtils.isEmpty(slaveData[iIndex].handleType) ? 'update' : slaveData[iIndex].handleType;
  1689 + slaveData[iIndex] = { ...slaveData[iIndex], [sFieldName]: sCode, handleType :newType };
  1690 + }
  1691 + }
  1692 + }
  1693 +
  1694 +
  1695 +
  1696 + /* 读取扫码配置 */
  1697 + // const btnScanConfigs = masterConfig.gdsconfigformslave.filter(item => item.sName === '' && item.sControlName.indexOf('BtnScan') > -1);
  1698 + // const AssignField = commonUtils.isNotEmptyArr(btnScanConfigs) ? btnScanConfigs[0].sAssignField : '';
  1699 + // /* 唯一码调接口 */
  1700 + // let sqlDataRow ={};
  1701 + // if(commonUtils.isNotEmptyArr(btnScanConfigs)) {
  1702 + // const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', btnScanConfigs[0], masterdataObj);
  1703 + // if(commonUtils.isNotEmptyArr(sqlDropDownData)) {
  1704 + // sqlDataRow = sqlDropDownData[0];
  1705 + // }
  1706 + // }
  1707 + // slaveDataObj = { ...slaveDataObj, ...commonFunc.getAssignFieldValue(AssignField, masterdataObj) }; // 取主表赋值字段
  1708 + // if(commonUtils.isNotEmptyObject(sqlDataRow)) {
  1709 + // slaveDataObj = { ...slaveDataObj, ...commonFunc.getAssignFieldValue(AssignField, sqlDataRow) }; // 取接口数据源赋值字段
  1710 + // }
  1711 + // slaveDataObj.sParentId = masterdataObj.sId;
  1712 + // if (commonUtils.isNotEmptyArr(slaveData)) {
  1713 + // const len = slaveData.length;
  1714 + // const sDefineNoNew = slaveData[len - 1].sDefineNo;
  1715 + // const { handleType } = slaveData[len - 1];
  1716 + // /* 若slaveData 最后一条数据没有条形码,则赋值条形码;否则新增一条数据 */
  1717 + // if (commonUtils.isEmptyArr(sDefineNoNew)) {
  1718 + // slaveDataObj.handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
  1719 + // // slaveData[len - 1] = slaveDataObj;
  1720 + // slaveData[len - 1] = { ...slaveData[len-1], ...slaveDataObj};
  1721 + // } else {
  1722 + // slaveDataObj.sId = commonUtils.createSid();
  1723 + // slaveDataObj.handleType = 'add';
  1724 + // slaveData.push(slaveDataObj);
  1725 + // }
  1726 + // } else {
  1727 + // slaveDataObj.sId = commonUtils.createSid();
  1728 + // slaveDataObj.handleType = 'add';
  1729 + // slaveData.push(slaveDataObj);
  1730 + // }
  1731 + if (sModelsType === 'scan/productionmaterials') { /* 只有扫码领料连续扫码 */
  1732 + this.handleClick('slave', 'scan'); /* 连续扫码 */
  1733 + }
  1734 + } else {
  1735 + Toast.fail('二维码不存在!!!', 1);
  1736 + }
  1737 + if (models !== 'Single') {
  1738 + slaveData.push(slaveDataObj);
  1739 + }
  1740 + this.props.onSaveState({ slaveData, masterData: masterdataObj });
  1741 + });
  1742 + }
  1743 + }
  1744 +
  1745 + render() {
  1746 + return (
  1747 + <ChildComponent
  1748 + {...this.props}
  1749 + {...this.state}
  1750 + onAdd={this.handleAdd}
  1751 + onSubmit={this.handleValidateSave}
  1752 + onSaveData={this.handleSaveData}
  1753 + onReturnForm={this.handleForm}
  1754 + onChange={this.handleMasterChange}
  1755 + onDataChange={this.handleTableChange}
  1756 + onMaterialsChange={this.handleMaterialsChange}
  1757 + onAudit={this.handleAudit}
  1758 + onEdit={this.handleEdit}
  1759 + onMobileScan={this.handleMobileScan}
  1760 + />
  1761 + );
  1762 + }
  1763 + };
  1764 +};
... ...
src/mobile/common/CommobileChar.js 0 → 100644
  1 +/* eslint-disable object-curly-newline */
  2 +import React, { Component } from 'react';
  3 +import { Radio } from 'antd';
  4 +import baseChar from '../../components/Common/baseChar'; /* 获取图表配置及数据 */
  5 +// import { Bar, Columnar, ColumnarGroup, BrokenLine, WaterWave, Gauge, ColumnarStack, PieGroup, Pie, TimeLineGroup } from '../../components/Charts';
  6 +import Bar from '../../components/Charts/Bar';
  7 +import Columnar from '../../components/Charts/Columnar';
  8 +import ColumnarGroup from '../../components/Charts/ColumnarGroup';
  9 +import BrokenLine from '../../components/Charts/BrokenLine';
  10 +import WaterWave from '../../components/Charts/WaterWave';
  11 +import Gauge from '../../components/Charts/Gauge';
  12 +import ColumnarStack from '../../components/Charts/ColumnarStack';
  13 +import PieGroup from '../../components/Charts/PieGroup';
  14 +import Pie from '../../components/Charts/Pie';
  15 +import TimeLineGroup from '../../components/Charts/TimeLineGroup';
  16 +
  17 +import styles from '../../components/Charts/index.less';
  18 +import * as utils from '../../utils/utils';
  19 +
  20 +class CommobileChar extends Component {
  21 + constructor(props) {
  22 + super(props);
  23 + this.state = {
  24 + ...props,
  25 + commonChar: styles.commonChar,
  26 + childChar: styles.childChar,
  27 + };
  28 + }
  29 +
  30 +
  31 + componentWillReceiveProps(nextProps) {
  32 + this.setState({ ...nextProps });
  33 + }
  34 +
  35 +
  36 + handleChar = (props) => {
  37 + const { sCharType, child } = props;
  38 + let content = '';
  39 + if (utils.isNotEmptyObject(child)) {
  40 + child.height = props.iHeight;
  41 + if (sCharType === 'sBar') {
  42 + /* 横向条形图 */
  43 + content = <Bar {...child} />;
  44 + } else if (sCharType === 'sColumnar') {
  45 + /* 纵向条形图 */
  46 + content = <Columnar {...child} />;
  47 + } else if (sCharType === 'sColumnarGroup') {
  48 + /* 纵向条形图 */
  49 + content = <ColumnarGroup {...child} />;
  50 + } else if (sCharType === 'sBrokenLine') {
  51 + content = <BrokenLine {...child} />;
  52 + } else if (sCharType === 'sWaterWave') {
  53 + content = <WaterWave {...child} />;
  54 + } else if (sCharType === 'sGauge') {
  55 + content = <Gauge {...child} />;
  56 + } else if (sCharType === 'sColumnarStack') {
  57 + content = <ColumnarStack {...child} />;
  58 + } else if (sCharType === 'sPieGroup') {
  59 + content = <PieGroup {...child} />;
  60 + } else if (sCharType === 'sPie') {
  61 + content = <Pie {...child} />;
  62 + } else if (sCharType === 'TimeLineGroup') {
  63 + content = <TimeLineGroup {...child} />;
  64 + }
  65 + }
  66 + return content;
  67 + };
  68 +
  69 + handleExtra = (menuTypeId) => {
  70 + const { charMenu } = this.state;
  71 + let content = '';
  72 + const index = charMenu.findIndex(item => item.sId === menuTypeId);
  73 + if (index > -1) {
  74 + const { childConfig, radioType } = charMenu[index];
  75 + const props = { ...this.state, index };
  76 + content = (
  77 + <Radio.Group value={radioType} onChange={e => this.handleChangeType(e, props)}>
  78 + {
  79 + childConfig.map((item) => {
  80 + const { sTypeValue, showName, sId } = item;
  81 + return (
  82 + <Radio.Button value={sTypeValue} key={sId}>{showName}</Radio.Button>
  83 + );
  84 + })
  85 + }
  86 + </Radio.Group>);
  87 + }
  88 + return content;
  89 + };
  90 +
  91 + handleChangeType = (e, props) => {
  92 + const { charMenu, charConfigAndData, index } = props;
  93 + const { childConfig } = charMenu[index];
  94 + const radioType = e.target.value; /* 更改后的菜单 */
  95 + charMenu[index].radioType = radioType;
  96 + this.setState({ charMenu });
  97 + const each = charConfigAndData[index]; /* 当前图表的配置 */
  98 + const child = childConfig.filter(item => item.sType === 'searchType' && item.sTypeValue === radioType);
  99 + if (utils.isNotEmptyArr(child)) {
  100 + const { sName } = child[0];
  101 + each.sSqlCondition = {
  102 + [sName]: radioType,
  103 + };
  104 + }
  105 + this.props.onEachChar(each);
  106 + };
  107 +
  108 + render() {
  109 + const { charConfigAndData, childChar, sModelsId } = this.props;
  110 + if (utils.isNotEmptyArr(charConfigAndData) && sModelsId !== null && sModelsId !== undefined && sModelsId.toString() === '101251240115015915037520030') {
  111 + return (
  112 + <div>
  113 + {
  114 + <div style={{ maxHeight: '700px' }}>
  115 + {
  116 + charConfigAndData.map((itemChar, index) => {
  117 + const { showName } = itemChar;
  118 + return (
  119 + // eslint-disable-next-line react/no-array-index-key
  120 + <div key={index} style={{ padding: '10px', borderRadius: '15px', backgroundColor: 'white', marginBottom: '10px' }} >
  121 + <div className={childChar} id="commonChar">
  122 + <div style={{ fontSize: '14px', fontWeight: 'bold' }}>{showName}</div>
  123 + {this.handleChar(itemChar)}
  124 + </div>
  125 + </div>
  126 + );
  127 + })
  128 + }
  129 + </div>
  130 + }
  131 + </div>
  132 + );
  133 + } else {
  134 + return (
  135 + <div>
  136 + {
  137 + <div style={{ maxHeight: '700px' }}>
  138 + {
  139 + charConfigAndData.map((itemChar, index) => {
  140 + const { showName } = itemChar;
  141 + return (
  142 + // eslint-disable-next-line react/no-array-index-key
  143 + <div key={index} style={{ padding: '10px', borderRadius: '15px', backgroundColor: 'white', marginBottom: '10px' }} >
  144 + <div className={childChar} >
  145 + <div id="commonChar" style={{ fontSize: '14px', fontWeight: 'bold' }}>{showName}</div>
  146 + {this.handleChar(itemChar)}
  147 + </div>
  148 + </div>
  149 + );
  150 + })
  151 + }
  152 + </div>
  153 + }
  154 + </div>
  155 +
  156 + );
  157 + }
  158 + }
  159 +}
  160 +
  161 +export default baseChar(CommobileChar);
... ...
src/mobile/common/CommobileClassifyEvent.js 0 → 100644
  1 +/* eslint-disable array-callback-return,no-undef,prefer-destructuring */
  2 +import React, { Component } from 'react';
  3 +import { Modal } from 'antd-mobile';
  4 +import * as commonUtils from '../../utils/utils'; /* 通用方法 */
  5 +import commonConfig from '../../utils/config';
  6 +import * as commonServices from '../../services/services';
  7 +import * as commonBusiness from '../../components/Common/commonBusiness';
  8 +
  9 +const alert = Modal.alert;
  10 +
  11 +export default (ChildComponent) => {
  12 + return class extends Component {
  13 + constructor(props) {
  14 + super(props);
  15 + this.state = {
  16 + };
  17 + }
  18 + componentWillReceiveProps(nextProps) {
  19 + const {
  20 + formData, sModelsId, searchSolution, masterData,
  21 + } = nextProps;
  22 + const { slaveConfig: slaveConfigOld } = nextProps;
  23 + if (commonUtils.isEmptyObject(slaveConfigOld) && formData.length > 0) {
  24 + const sId = sModelsId !== undefined ? sModelsId : '';
  25 + /* 数据Id */
  26 + const slaveConfig = formData[0];
  27 + // console.log('form', formData);
  28 + let filterCondition = [];
  29 + if (commonUtils.isNotEmptyObject(masterData) && !commonUtils.isEmpty(masterData.sSearchSolutionId) && commonUtils.isNotEmptyArr(searchSolution)) {
  30 + const iIndex = searchSolution.findIndex(item => item.sId === masterData.sSearchSolutionId);
  31 + if (iIndex > -1 && !commonUtils.isEmpty(searchSolution[iIndex].sCondition)) {
  32 + filterCondition = JSON.parse(searchSolution[iIndex].sCondition);
  33 + }
  34 + }
  35 + this.handleGetData(slaveConfig, filterCondition, 1);
  36 + slaveConfig.gdsconfigformslave.push({
  37 + sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnFirst', sControlName: 'BtnFirst',
  38 + });
  39 + slaveConfig.gdsconfigformslave.push({
  40 + sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnPrior', sControlName: 'BtnPrior',
  41 + });
  42 + slaveConfig.gdsconfigformslave.push({
  43 + sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnNext', sControlName: 'BtnNext',
  44 + });
  45 + slaveConfig.gdsconfigformslave.push({
  46 + sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnLast', sControlName: 'BtnLast',
  47 + });
  48 + slaveConfig.gdsconfigformslave.push({
  49 + sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnExamine', sControlName: 'BtnExamine',
  50 + });
  51 + slaveConfig.gdsconfigformslave.push({
  52 + sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnCancelExamine', sControlName: 'BtnCancelExamine',
  53 + });
  54 +
  55 + slaveConfig.gdsconfigformslave.push({
  56 + sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnUpCheck', sControlName: 'BtnUpCheck',
  57 + });
  58 + slaveConfig.gdsconfigformslave.push({
  59 + sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnDownCheck', sControlName: 'BtnDownCheck',
  60 + });
  61 + slaveConfig.gdsconfigformslave.push({
  62 + sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnCopyTo', sControlName: 'BtnCopyTo',
  63 + });
  64 + slaveConfig.gdsconfigformslave.push({
  65 + sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnCopyFrom', sControlName: 'BtnCopyFrom',
  66 + });
  67 + this.props.onSaveState({
  68 + masterConfig: slaveConfig, slaveConfig, sId, pageLoading: false,
  69 + });
  70 + }
  71 + if (commonUtils.isEmptyStr(this.props.sClomunType) && commonUtils.isNotEmptyObject(this.props.masterConfig)) {
  72 + const { sTbName } = this.props.masterConfig;
  73 + if (sTbName === 'cahsupplyinit' || sTbName === 'cahcustomerinit' || sTbName === 'cahcashierinit') {
  74 + this.handleGetPeriod();
  75 + }
  76 + }
  77 + }
  78 +
  79 + shouldComponentUpdate(nextProps) {
  80 + const { masterConfig } = nextProps;
  81 + return commonUtils.isNotEmptyArr(masterConfig);
  82 + }
  83 + componentDidUpdate() {
  84 + const { app, slaveData } = this.props;
  85 + const { currentPane } = app;
  86 + if (currentPane.classifyOption === 'add' && slaveData !== undefined) {
  87 + currentPane.classifyOption = '';
  88 + this.handleAdd();
  89 + this.props.onSaveState({ currentPane });
  90 + }
  91 + }
  92 +
  93 + componentWillUnmount() {
  94 + const { sModelsId } = this.props;
  95 + const { userinfo } = this.props.app;
  96 + this.props.handleSendSocketMessage('release', 'noAction', sModelsId, userinfo.sId, null, null);
  97 + }
  98 +
  99 + /** 获取表数据 */
  100 + handleGetData = (slaveConfig, slaveFilterCondition, page, slaveOrderBy) => {
  101 + const { app } = this.props;
  102 + const conditonValues = app.currentPane.conditonValues;
  103 + const pageNum = commonUtils.isEmpty(page) ? 1 : page;
  104 + // console.log('slaveConfig', slaveConfig);
  105 + // console.log('pageNum', pageNum);
  106 + // console.log('slaveFilterCondition', slaveFilterCondition);
  107 + this.props.handleGetDataSet({
  108 + name: 'slave',
  109 + configData: slaveConfig,
  110 + condition: {
  111 + pageNum, bFilter: slaveFilterCondition, sFilterOrderBy: slaveOrderBy, sSqlCondition: conditonValues,
  112 + },
  113 + });
  114 + };
  115 +
  116 + handlePaginationChange = (page) => {
  117 + const { slaveConfig, slaveFilterCondition } = this.props;
  118 + this.props.handleGetDataSet({
  119 + name: 'slave', configData: slaveConfig, condition: { pageNum: page, bFilter: slaveFilterCondition },
  120 + });
  121 + };
  122 + /* 取消操作 */
  123 + handleCancel = () => {
  124 + /* 待用数据声明 */
  125 + const {
  126 + sModelsId, slaveConfig, slaveFilterCondition, slavePagination, slaveOrderBy, app,
  127 + } = this.props;
  128 + const { userinfo } = app;
  129 + const onSendSocketMessage = this.props.handleSendSocketMessage;
  130 + const onGetDataOk = this.handleGetData;
  131 + const onSaveStateOk = this.props.onSaveState;
  132 + alert('Warn', '确定要取消', [
  133 + {
  134 + text: 'Ok',
  135 + onPress: () => {
  136 + onGetDataOk(slaveConfig, slaveFilterCondition, slavePagination.current, slaveOrderBy);
  137 + onSaveStateOk({ enabled: false });
  138 + onSendSocketMessage('release', 'noAction', sModelsId, userinfo.sId, null, null);
  139 + },
  140 + },
  141 + { text: 'Cancel' },
  142 + ]);
  143 + };
  144 + /** 点击修改按钮操作 */
  145 + handleEdit = () => {
  146 + const {
  147 + sModelsId, slaveConfig, slaveFilterCondition, slavePagination, slaveOrderBy, app,
  148 + } = this.props;
  149 + const { userinfo } = app;
  150 + this.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, slaveOrderBy);
  151 + let timValue = 0;
  152 + if (this.props.app.webSocket === null || this.props.app.webSocket.readyState !== WebSocket.OPEN) {
  153 + this.props.dispatch({ type: 'app/createWebSocket', payload: { reStart: true, dispatch } });
  154 + timValue = 3000;
  155 + }
  156 + setTimeout(() => {
  157 + this.props.app.webSocket.onmessage = (msg) => {
  158 + const rtmsg = JSON.parse(msg.data);
  159 + if (rtmsg.action === 'showMsg') {
  160 + message.warning(rtmsg.msg);
  161 + this.props.onSaveState({ loading: false });
  162 + } else if (rtmsg.action === 'loginOut') {
  163 + if (location.pathname.indexOf('/indexOee') > -1) {
  164 + dispatch({ type: 'app/throwErrorOee', payload: { code: -2, msg: rtmsg.msg } });
  165 + } else if (location.pathname.indexOf('/indexMobile') > -1) {
  166 + dispatch({ type: 'app/throwErrorMobile', payload: { code: -2, msg: rtmsg.msg } });
  167 + } else {
  168 + dispatch({ type: 'app/throwError', payload: { code: -2, msg: rtmsg.msg } });
  169 + }
  170 + } else {
  171 + if (this.props.app.webSocket.homeAction) {
  172 + this.props.app.webSocket.homeAction(msg);
  173 + }
  174 + this.props.onSaveState({ enabled: true, loading: false });
  175 + }
  176 + };
  177 + this.props.handleSendSocketMessage('update', 'showMsg', sModelsId, userinfo.sId, null, null); // 分类型不能以Id来,涉及到多条修改
  178 + }, timValue);
  179 + };
  180 + /** 点击新增按钮操作 */
  181 + handleAdd = () => {
  182 + const { sModelsType } = this.props;
  183 + let { slaveSelectedRowKeys } = this.props;
  184 + let { slaveData } = this.props;
  185 + if (slaveData === undefined) {
  186 + slaveData = [];
  187 + }
  188 + const newData = this.props.onDataRowAdd('slave', true);/* 调用父级新增 */
  189 + // const newData = {
  190 + // handleType: 'add',
  191 + // sId: commonUtils.createSid(),
  192 + // iOrder: slaveData.length,
  193 + // };
  194 + if (sModelsType === 'commonClassfiy/sisPosition') {
  195 + newData.maxBillNo = 'sNo';
  196 + }
  197 + if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) { /* 通用分类新增,默认新增行为选中行 */
  198 + slaveSelectedRowKeys = [];
  199 + slaveSelectedRowKeys.push(newData.sId);
  200 + }
  201 + this.props.onSaveState({
  202 + slaveData: [newData, ...slaveData],
  203 + slaveSelectedRowKeys,
  204 + enabled: true,
  205 + });
  206 + };
  207 + /* 删除 */
  208 + handleDel = () => {
  209 + const onOkDel = this.handleOkDel;
  210 + alert('Warn', '确定要删除', [
  211 + {
  212 + text: 'Ok',
  213 + onPress: () => {
  214 + onOkDel();
  215 + },
  216 + },
  217 + { text: 'Cancel' },
  218 + ]);
  219 + };
  220 + handleOkDel = async () => {
  221 + const returnData = await this.handleTableDel('slave');
  222 + if (returnData) {
  223 + this.handleValidateSave();
  224 + }
  225 + };
  226 + handleTableDel = (name, isWait) => {
  227 + const { app } = this.props;
  228 + const { [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: tableSelectedRowKeys } = this.props;
  229 + let { [`${name}DelData`]: tableDelData } = this.props;
  230 + tableDelData = commonUtils.isEmptyArr(tableDelData) ? [] : tableDelData;
  231 + if (commonUtils.isNotEmptyArr(tableSelectedRowKeys)) {
  232 + for (const sId of tableSelectedRowKeys) {
  233 + /* 看看删除集合和从表中是否都存在该条数据 */
  234 + const tableDataIndex = tableData.findIndex(item => item.sId === sId);
  235 + if (tableDataIndex > -1) {
  236 + /* 删除从表中的数据并存入删除集合中 */
  237 + const slaveDataFilter = tableData[tableDataIndex];
  238 + slaveDataFilter.handleType = 'del';
  239 + tableDelData.push(slaveDataFilter);
  240 + }
  241 + }
  242 + if (isWait) {
  243 + return { [`${name}Data`]: tableData, [`${name}DelData`]: tableDelData, [`${name}SelectedRowKeys`]: [] };
  244 + } else {
  245 + this.props.onSaveState({
  246 + [`${name}Data`]: tableData,
  247 + [`${name}DelData`]: tableDelData,
  248 + [`${name}SelectedRowKeys`]: [],
  249 + });
  250 + return true;
  251 + }
  252 + } else {
  253 + message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseDelData')); // 请选择删除数据
  254 + return false;
  255 + }
  256 + };
  257 + /** toolbar校验保存 */
  258 + handleValidateSave = async () => {
  259 + const {
  260 + slaveData, slaveConfig, slaveDelData,
  261 + } = this.props;
  262 + const data = [];
  263 + if (!commonBusiness.validateTable(slaveConfig, slaveData, this.props)) {
  264 + this.props.onSaveState({
  265 + loading: false,
  266 + });
  267 + return;
  268 + }
  269 + data.push(commonBusiness.mergeData('slave', slaveConfig.sTbName, slaveData, slaveDelData));
  270 + // console.log('slaveData', slaveData);
  271 + // console.log('slaveDelData', slaveDelData);
  272 + // console.log('data', data);
  273 + this.handleSaveData({ data, sClientType: '1' });
  274 + };
  275 + /** toolbar保存 */
  276 + handleSaveData = async (params) => {
  277 + const {
  278 + token, sModelsId, slaveFilterCondition, slaveConfig, slavePagination, slaveOrderBy, app, slaveData,
  279 + } = this.props;
  280 + const { userinfo } = app;
  281 + const onSendSocketMessage = this.props.handleSendSocketMessage;
  282 + const returnData = await commonBusiness.saveData({ token, value: params, sModelsId });
  283 + if (commonUtils.isNotEmptyObject(returnData)) {
  284 + commonUtils.clearStoreDropDownData();
  285 + /* 新记录时,关闭后能自动带值 */
  286 + const callBackRecord = this.props.app.currentPane.newRecordMethod;
  287 + if (callBackRecord !== undefined && commonUtils.isNotEmptyArr(slaveData) && slaveData.length > 0) {
  288 + const filterData = slaveData.filter(item => (item.handleType === 'add'));
  289 + const sId = commonUtils.isNotEmptyArr(filterData) && filterData.length > 0 ? filterData[0].sId : null;
  290 + /* 回调 传[新增的数据sId] */
  291 + if (this.props.app.currentPane.newRecordMethod !== undefined) {
  292 + this.props.app.currentPane.newRecordMethod(sId);
  293 + }
  294 + }
  295 + /* END */
  296 + onSendSocketMessage('release', 'noAction', sModelsId, userinfo.sId, null, null);
  297 + this.props.onSaveState({
  298 + enabled: false, slaveDelData: [], loading: false,
  299 + });
  300 + this.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, slaveOrderBy);
  301 + return true;
  302 + } else {
  303 + this.props.onSaveState({
  304 + slaveDelData: [],
  305 + loading: false,
  306 + });
  307 + return false;
  308 + }
  309 + };
  310 + /** 表单回带 */
  311 + handleForm = (form) => {
  312 + this.form = form;
  313 + };
  314 + /* 作废、取消作废的公用函数 */
  315 + handleInvalid = (obj) => {
  316 + const props = { ...this.props, ...this.state, ...obj };
  317 + const onOkInvaild = this.handleOkChangeInvaild;
  318 + alert('Warn', obj.title, [
  319 + {
  320 + text: 'Ok',
  321 + onPress: () => {
  322 + onOkInvaild(props);
  323 + },
  324 + },
  325 + { text: 'Cancel' },
  326 + ]);
  327 + };
  328 + /* 切换作废状态 */
  329 + handleOkChangeInvaild = async (props) => {
  330 + props = this.handleOkInvalid(props);
  331 + this.setState({ ...props });
  332 + };
  333 + /** 作废,取消作废 */
  334 + handleOkInvalid = async (props) => {
  335 + const {
  336 + sModelsId, slaveData, slaveConfig, handleType, slaveSelectedRowKeys, app, slavePagination,
  337 + } = props;
  338 + if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
  339 + const { token } = props.app;
  340 + const { sTbName } = slaveConfig;
  341 + const value = {
  342 + sClientType: '1',
  343 + sId: slaveSelectedRowKeys,
  344 + sTableName: sTbName,
  345 + handleType,
  346 + sBooleanCheck: false,
  347 + };
  348 + const url = `${commonConfig.server_host}checkModel/updatebInvalid?sModelsId=${sModelsId}`;
  349 + const { data } = await commonServices.postValueService(token, value, url);
  350 + if (data.code === 1) {
  351 + message.success(data.msg);
  352 + for (const key of slaveSelectedRowKeys) {
  353 + const selectData = slaveData.filter(item => item.sId === key);
  354 + selectData.bInvalid = handleType === 'toVoid';
  355 + }
  356 + /* 作废(取消作废)后刷新页面 */
  357 + this.handlePaginationChange(slavePagination.current);
  358 + } else {
  359 + this.props.getServiceError(data);
  360 + }
  361 + return props;
  362 + } else {
  363 + message.warn(commonFunc.showMessage(app.commonConst, 'sChoosebInvalid'));/* 请选择作废数据 */
  364 + }
  365 + };
  366 + /** 按钮操作事件 */
  367 + handleButtonClick = (name) => {
  368 + if (name === 'BtnOut') {
  369 + this.handleOut();
  370 + } else if (name === 'BtnRefresh') {
  371 + const { slavePagination } = this.props;
  372 + this.handlePaginationChange(slavePagination.current);
  373 + } else if (name === 'BtnSetPeriod') {
  374 + this.handleBtnSetPeriod();
  375 + } else if (name === 'BtnRelievePeriod') {
  376 + this.handleBtnRelievePeriod();
  377 + }
  378 + };
  379 + /* 导出Excel */
  380 + handleOut = () => {
  381 + const {
  382 + slaveConfig, slaveFilterCondition, sFilterOrderBy, sGroupByList,
  383 + } = this.props;
  384 + let url = `${commonConfig.server_host}excel/export/${slaveConfig.sId}?sModelsId=${slaveConfig.sParentId}&token=${this.props.app.token}`;
  385 + if (commonUtils.isNotEmptyArr(slaveFilterCondition)) {
  386 + url = `${url}&bFilter=${encodeURIComponent(JSON.stringify(slaveFilterCondition))}`;
  387 + }
  388 + if (sFilterOrderBy !== undefined && sFilterOrderBy !== '' && Object.keys(sFilterOrderBy).length > 0) {
  389 + url = `${url}&sFilterOrderBy=${encodeURIComponent(JSON.stringify(sFilterOrderBy))}`;
  390 + }
  391 + if (commonUtils.isNotEmptyArr(sGroupByList)) {
  392 + url = `${url}&sGroupList=${encodeURIComponent(JSON.stringify(sGroupByList))}`;
  393 + }
  394 + window.open(url);
  395 + };
  396 + /* 获取期初 */
  397 + handleGetPeriod = async () => {
  398 + const { sTbName } = this.props.masterConfig;
  399 + let sClomunType = '';
  400 + if (sTbName === 'cahsupplyinit') {
  401 + sClomunType = 'bAP';
  402 + } else if (sTbName === 'cahcustomerinit') {
  403 + sClomunType = 'bAR';
  404 + } else if (sTbName === 'cahcashierinit') {
  405 + sClomunType = 'bCashier';
  406 + }
  407 + const { sModelsId } = this.props;
  408 + const { token } = this.props.app;
  409 + const url = `${commonConfig.server_host}sysAccountPeriod/getSysAccountPeriod?sModelsId=${sModelsId}`;
  410 + const value = { sClientType: '1', sClomunType };
  411 + const { data } = await commonServices.postValueService(token, value, url);
  412 + if (data.code === 1) {
  413 + const [{ isSysAccountPeriod }] = data.dataset.rows;
  414 + this.props.onSaveState({
  415 + adDisabled: isSysAccountPeriod,
  416 + sClomunType,
  417 + });
  418 + } else {
  419 + this.props.getServiceError(data);
  420 + }
  421 + };
  422 + /* 设置期初 */
  423 + handleBtnSetPeriod = async () => {
  424 + const { sTbName } = this.props.masterConfig;
  425 + let sClomunType = '';
  426 + if (sTbName === 'cahsupplyinit') {
  427 + sClomunType = 'bAP';
  428 + } else if (sTbName === 'cahcustomerinit') {
  429 + sClomunType = 'bAR';
  430 + } else if (sTbName === 'cahcashierinit') {
  431 + sClomunType = 'bCashier';
  432 + }
  433 + const { sModelsId } = this.props;
  434 + const { token } = this.props.app;
  435 + const url = `${commonConfig.server_host}sysAccountPeriod/updateSysAccountPeriod?sModelsId=${sModelsId}`;
  436 + const value = { sClientType: '1', handleType: 'add', sClomunType };
  437 + const { data } = await commonServices.postValueService(token, value, url);
  438 + if (data.code === 1) {
  439 + message.success(data.msg);
  440 + this.props.onSaveState({ adDisabled: true, enabled: false });
  441 + } else {
  442 + this.props.getServiceError(data);
  443 + }
  444 + };
  445 + /* 解除锁定 */
  446 + handleBtnRelievePeriod = async () => {
  447 + const { sModelsId } = this.props;
  448 + const { token } = this.props.app;
  449 + const { sTbName } = this.props.masterConfig;
  450 + let sClomunType = '';
  451 + if (sTbName === 'cahsupplyinit') {
  452 + sClomunType = 'bAP';
  453 + } else if (sTbName === 'cahcustomerinit') {
  454 + sClomunType = 'bAR';
  455 + } else if (sTbName === 'cahcashierinit') {
  456 + sClomunType = 'bCashier';
  457 + }
  458 + const url = `${commonConfig.server_host}sysAccountPeriod/updateSysAccountPeriod?sModelsId=${sModelsId}`;
  459 + const value = { sClientType: '1', handleType: 'reset', sClomunType };
  460 + const { data } = await commonServices.postValueService(token, value, url);
  461 + if (data.code === 1) {
  462 + message.success(data.msg);
  463 + this.props.onSaveState({ adDisabled: false });
  464 + } else {
  465 + this.props.getServiceError(data);
  466 + }
  467 + };
  468 +
  469 + handleTitleChange = (slavePagination, filters, sorter) => {
  470 + const { slaveConfig, slaveFilterCondition } = this.props;
  471 + const sort = sorter.order === 'ascend' ? 'asc' : 'desc';
  472 + const slaveOrderBy = Object.keys(sorter).length > 0 ? { [sorter.columnKey]: sort } : ''; // 后端未支持空对象, 先用空表示
  473 + this.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, slaveOrderBy);
  474 + };
  475 + handleTitleChangeEnabled = (slavePagination) => {
  476 + this.props.onSaveState({ slavePagination });
  477 + };
  478 + handleTableSelectRowChange = async (name, selectedRowKeys) => {
  479 + const {
  480 + [`${name}Data`]: tableData, sModelsType, sModelsId, token, masterConfig, enabled,
  481 + } = this.props;
  482 + if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
  483 + if (sModelsType === 'commonClassfiy/salesMan') {
  484 + const addState = this.props.onTableSelectRowChange(name, selectedRowKeys, true);
  485 + const { [`${name}SelectedRowKeys`]: rowKeys } = addState;
  486 + for (const sId of rowKeys) {
  487 + const tableDataIndex = tableData.findIndex(item => item.sId === sId);
  488 + const sNameIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sName');/* 判断配置中是否有员工编号字段 */
  489 + if (tableDataIndex > -1 && sNameIndex > -1) {
  490 + const tableDataRow = JSON.parse(JSON.stringify(tableData[tableDataIndex]));
  491 + masterConfig.gdsconfigformslave[sNameIndex].iTag = 0; /* 默认是0 */
  492 + if (enabled && tableDataRow.handleType !== 'add') { /* 判断销售人员是否已被占用 */
  493 + const value = {
  494 + tableName: masterConfig.sTbName,
  495 + sId: [sId],
  496 + };
  497 + const url = `${commonConfig.server_host}business/addSysLocking?sModelsId=${sModelsId}`;
  498 + /* 接收返回值 */
  499 + const { data } = await commonServices.postValueService(token, value, url);
  500 + if (data.code === 1) {
  501 + const sNameIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sName');
  502 + masterConfig.gdsconfigformslave[sNameIndex].iTag = 1; /* ,已占用销售人员,员工不能修改 即下拉不可选 */
  503 + } else { /* 失败 */
  504 + this.props.getServiceError(data);
  505 + }
  506 + }
  507 + }
  508 + }
  509 + }
  510 + }
  511 + this.props.onTableSelectRowChange(name, selectedRowKeys);
  512 + }
  513 +
  514 + render() {
  515 + return (
  516 + <ChildComponent
  517 + {...this.props}
  518 + {...this.state}
  519 + onCancel={this.handleCancel}
  520 + onAdd={this.handleAdd}
  521 + onEdit={this.handleEdit}
  522 + onDel={this.handleDel}
  523 + onSubmit={this.handleValidateSave}
  524 + onReturnForm={this.handleForm}
  525 + onPaginationChange={this.handlePaginationChange}
  526 + onGetData={this.handleGetData}
  527 + onButtonClick={this.handleButtonClick}
  528 + onChangeInvalid={this.handleInvalid}
  529 + onTitleChange={this.handleTitleChange}
  530 + onTitleChangeEnabled={this.handleTitleChangeEnabled}
  531 + onTableSelectRowChange={this.handleTableSelectRowChange}
  532 + />
  533 + );
  534 + }
  535 + };
  536 +};
... ...