/* eslint-disable array-callback-return,no-undef,prefer-destructuring */
import React, { Component } from 'react';
import moment from 'moment';
import { Modal, message } from 'antd-v4';
import * as commonFunc from './commonFunc';
import * as commonBusiness from './commonBusiness'; /* 单据业务功能 */
import * as commonUtils from '../../utils/utils'; /* 通用方法 */
import commonConfig from '../../utils/config';
import * as commonServices from '../../services/services';
const { confirm } = Modal;
export default (ChildComponent) => {
return class extends Component {
constructor(props) {
super(props);
this.state = {
};
}
componentWillReceiveProps(nextProps) {
const {
formData, sModelsId, searchSolution, masterData,
} = nextProps;
const { slaveConfig: slaveConfigOld } = nextProps;
let { iPageSize } = nextProps;
if (commonUtils.isEmptyObject(slaveConfigOld) && formData.length > 0) {
const sId = sModelsId !== undefined ? sModelsId : '';
/* 数据Id */
const slaveConfig = formData[0];
const slaveColumn = commonFunc.getHeaderConfig(slaveConfig);
let filterCondition = [];
if (commonUtils.isNotEmptyObject(masterData) && !commonUtils.isEmpty(masterData.sSearchSolutionId) && commonUtils.isNotEmptyArr(searchSolution)) {
const iIndex = searchSolution.findIndex(item => item.sId === masterData.sSearchSolutionId);
if (iIndex > -1 && !commonUtils.isEmpty(searchSolution[iIndex].sCondition)) {
filterCondition = JSON.parse(searchSolution[iIndex].sCondition);
}
}
/* 首先以下拉页数为准 否则以后台页数为准 如果以上都没有设置 则依照config配置的页码设置 */
if (commonUtils.isNotEmptyNumber(formData[0].iPageSize) && formData[0].iPageSize !== 0) {
iPageSize = formData[0].iPageSize;
}
this.handleGetData(slaveConfig, filterCondition, 1, iPageSize);
slaveConfig.gdsconfigformslave.push({
sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnFirst', sControlName: 'BtnFirst',
});
slaveConfig.gdsconfigformslave.push({
sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnPrior', sControlName: 'BtnPrior',
});
slaveConfig.gdsconfigformslave.push({
sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnNext', sControlName: 'BtnNext',
});
slaveConfig.gdsconfigformslave.push({
sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnLast', sControlName: 'BtnLast',
});
/* 如果后台配置了审核按钮 则无需配置 */
const filterExamineIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === '' && item.showName !== '' && item.sControlName === 'BtnExamine');
if (filterExamineIndex === -1) {
slaveConfig.gdsconfigformslave.push({
sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnExamine', sControlName: 'BtnExamine',
});
}
const filterCancelExamineIndex = slaveConfig.gdsconfigformslave.filter(item => item.sName === '' && item.showName !== '' && item.sControlName === 'BtnCancelExamine');
if (filterCancelExamineIndex === -1) {
slaveConfig.gdsconfigformslave.push({
sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnCancelExamine', sControlName: 'BtnCancelExamine',
});
}
slaveConfig.gdsconfigformslave.push({
sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnUpCheck', sControlName: 'BtnUpCheck',
});
slaveConfig.gdsconfigformslave.push({
sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnDownCheck', sControlName: 'BtnDownCheck',
});
slaveConfig.gdsconfigformslave.push({
sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnCopyTo', sControlName: 'BtnCopyTo',
});
slaveConfig.gdsconfigformslave.push({
sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnCopyFrom', sControlName: 'BtnCopyFrom',
});
this.props.onSaveState({
masterConfig: slaveConfig, slaveConfig, slaveColumn, sId, pageLoading: false,
});
}
if (commonUtils.isEmptyStr(this.props.sClomunType) && commonUtils.isNotEmptyObject(this.props.masterConfig)) {
const { sTbName } = this.props.masterConfig;
if (sTbName === 'cahsupplyinit' || sTbName === 'cahcustomerinit' || sTbName === 'cahcashierinit') {
this.handleGetPeriod();
}
}
}
shouldComponentUpdate(nextProps) {
const { slaveColumn } = nextProps;
return commonUtils.isNotEmptyArr(slaveColumn);
}
componentDidUpdate() {
const { app, slaveData } = this.props;
const { currentPane } = app;
if (currentPane.classifyOption === 'add' && slaveData !== undefined) {
currentPane.classifyOption = '';
this.handleAdd();
this.props.onSaveState({ currentPane });
}
}
componentWillUnmount() {
const { sModelsId } = this.props;
const { userinfo } = this.props.app;
this.props.handleSendSocketMessage('release', 'noAction', sModelsId, userinfo.sId, null, null);
}
/** 键盘事件监听 */
onKeyDown = (e, record, sName, name) => {
const { [`${name}Data`]: tableData, [`${name}Column`]: tableColumn, [`${name}Config`]: tableConfig } = this.props;
let keyCode = e.keyCode;
let firstName;
let bEnter = false;
if (keyCode === 13) {
// 判断当前单元格是否是最后,不是则跳到下一格,是则跳到下一行第一格
bEnter = true;
const uniqueTableId = `table_${this.props.sModelsId}_${tableConfig.sId}`;
const currentTable = document.getElementById(uniqueTableId);
const currentTr = currentTable.querySelector(`tr[data-row-key="${record.sId}"]`);
const allInput = currentTr.querySelectorAll(`input[id*="${record.sId}"]`);
const iIndex = Array.from(allInput).findIndex(item => item.getAttribute('id') === `${sName}${record.sId}`);
if (iIndex < allInput.length - 1) {
keyCode = 39;
} else {
const oFirstInput = allInput[0];
firstName = oFirstInput.getAttribute('id').replace(record.sId, '');
keyCode = 40;
}
}
// 以下if条件为 为解决bug2031问题入口 需求:收款单里输入的收款金额,上下键操作把加减金额改为选择上下行(通过上下方向键切换行数)
if ([38, 40].includes(keyCode)) { // 上键、下键
e.preventDefault();
if (tableData.length > 1) { // 当从表行数大于一行时才有上下移动的意义
const index = tableData.findIndex(item => item.sId === record.sId); // 获取当前编辑行的下标
if (index > -1) {
if (keyCode === 38 && index > 0) { // 方向键上键 且 当前编辑行下标大于0时,为0时无法向上
const lastSid = tableData[index - 1].sId; // 获取上一个id
this.props.onSaveState({ [`${name}SelectedRowKeys`]: [lastSid] }, () => commonUtils.focus(`${sName}${lastSid}`));
}
if (keyCode === 40 && index < tableData.length - 1) { // 方向键下键 且 当前编辑行下标小于最大值时,为最大值时无法向下
const nextSid = tableData[index + 1].sId; // 获取下一个id
this.props.onSaveState({ [`${name}SelectedRowKeys`]: [nextSid] }, () => commonUtils.focus(`${firstName || sName}${nextSid}`));
}
}
}
}
const move = (keyCode, cursortPosition, columnIndex, currentElement) => {
const inputType = currentElement.getAttribute('type');
const value = currentElement.value;
if (keyCode === 37 && columnIndex > 0 && cursortPosition < 1) { // 左移 则 列下标必须大于0, 且光标在最左侧
const lastId = `${tableColumn[columnIndex - 1].dataIndex}${record.sId}`;
if (!commonUtils.focus(lastId, e)) move(keyCode, cursortPosition, columnIndex - 1, currentElement); // 递归
}
if (keyCode === 39 && columnIndex < tableColumn.length - 1) { // 右移 则 列下标必须小于列数量-1
if (!record[sName] || cursortPosition >= value.length || inputType === 'search' || bEnter) { // 当前列为空 或 光标位置不小于当前值的长度
const nextId = `${tableColumn[columnIndex + 1].dataIndex}${record.sId}`;
if (!commonUtils.focus(nextId, e)) move(keyCode, cursortPosition, columnIndex + 1, currentElement); // 递归
}
}
};
if ([37, 39].includes(keyCode)) { // 左键、右键
const currentElement = document.getElementById(`${sName}${record.sId}`); // 当前编辑框对象
if (currentElement) {
const cursortPosition = commonUtils.getCursortPosition(currentElement); // 光标位置
const columnIndex = tableColumn.findIndex(item => item.dataIndex === sName); // 当前列下标
move(keyCode, cursortPosition, columnIndex, currentElement);
}
}
}
/** 获取表数据 */
handleGetData = async (slaveConfig, slaveFilterCondition, page, pageSize, slaveOrderBy) => {
const {
app, sModelsType, slavePagination, iPageSize,
} = this.props;
const { currentPane } = app;
const conditonValues = currentPane.conditonValues;
if (commonUtils.isNotEmptyObject(conditonValues)) {
Object.keys(conditonValues).forEach((item) => {
if (!conditonValues[item] && currentPane[item]) {
conditonValues[item] = currentPane[item];
}
});
}
const pageNum = commonUtils.isEmpty(page) ? 1 : page;
pageSize = commonUtils.isEmpty(pageSize) ? commonUtils.isEmpty(slavePagination) || commonUtils.isEmpty(slavePagination.pageSize) ? iPageSize : slavePagination.pageSize : pageSize;
const getData = await this.props.handleGetDataSet({
name: 'slave',
configData: slaveConfig,
condition: {
pageNum, pageSize, bFilter: slaveFilterCondition, sFilterOrderBy: slaveOrderBy, sSqlCondition: conditonValues,
},
isWait: true,
});
const addState = {}; /* 用于界面树形展示的slaveData */
if (sModelsType && (sModelsType === 'commonClassify/materialsClassify' || sModelsType.includes('children')) && commonUtils.isNotEmptyObject(getData)) {
const slaveData = getData.slaveData;
if (commonUtils.isNotEmptyArr(slaveData)) {
// addState = this.handleGetSlaveTreeData(slaveData);
const expandRowKeys = [];
const firstLevelData = slaveData.filter(item => commonUtils.isEmptyObject(item.sParentId));
if (commonUtils.isNotEmptyArr(firstLevelData)) {
firstLevelData.forEach((item) => {
expandRowKeys.push(item.sId);
});
addState.expKeys = expandRowKeys;
}
}
}
this.props.onSaveState({
...getData, ...addState,
});
};
/* 获取树形slaveTreeData数据 */
handleGetSlaveTreeData = (slaveData) => {
const slaveTreeData = []; /* 用于界面树形展示的slaveData */
const expKeys = [];
const addState = {};
if (commonUtils.isNotEmptyArr(slaveData)) {
const { slaveConfig } = this.props;
/* 若关联性sSqlCondition配置 则取配置 */
let keyField = 'sId';
let keyParentField = 'sParentId';
let sSqlCondition = '';
if (commonUtils.isNotEmptyObject(slaveConfig)) {
sSqlCondition = slaveConfig.sSqlCondition;
if (commonUtils.isNotEmptyObject(sSqlCondition) && commonUtils.isNotEmptyArr(sSqlCondition.split('.')) && sSqlCondition.split('.').length > 2) {
keyField = sSqlCondition.split('.')[1];
keyParentField = sSqlCondition.split('.')[2];
}
}
slaveData.forEach((tableDataRow) => {
const tableDataRowNew = JSON.parse(JSON.stringify(tableDataRow));
if (commonUtils.isEmpty(tableDataRow[keyParentField])) { /* 一级分类 */
const childrenData = this.handleGetChildData(slaveData, tableDataRowNew[keyField], keyField, keyParentField); /* 获取子数据 */
if (commonUtils.isNotEmptyArr(childrenData)) {
expKeys.push(tableDataRow.sSlaveId);
tableDataRowNew.children = childrenData;
}
slaveTreeData.push(tableDataRowNew);
}
});
}
addState.slaveTreeData = slaveTreeData;
addState.expKeys = expKeys;
return addState;
}
/* 获取子节点数据 */
handleGetChildData = (data, sId, keyField, keyParentField) => {
if (commonUtils.isNotEmptyArr(data)) {
const filterData = data.filter(item => item[keyParentField] === sId);
if (commonUtils.isNotEmptyArr(filterData)) {
filterData.forEach((child, index) => {
const filterChildData = this.handleGetChildData(data, child[keyField], keyField, keyParentField);
if (commonUtils.isNotEmptyArr(filterChildData)) {
filterData[index].children = filterChildData;
}
});
}
return filterData;
}
}
handlePaginationChange = (page) => {
const { slaveConfig, slaveFilterCondition, slavePagination } = this.props;
this.props.handleGetDataSet({
name: 'slave', configData: slaveConfig, condition: { pageNum: page, pageSize: slavePagination.pageSize, bFilter: slaveFilterCondition },
});
};
/* 取消操作 */
handleCancel = () => {
/* 待用数据声明 */
const {
sModelsId, slaveConfig, slaveFilterCondition, slavePagination, slaveOrderBy, app, iPageSize,
} = this.props;
const { userinfo } = app;
const onSendSocketMessage = this.props.handleSendSocketMessage;
const onGetDataOk = this.handleGetData;
const onSaveStateOk = this.props.onSaveState;
confirm({
title: '确定要取消',
onOk() {
onGetDataOk(slaveConfig, slaveFilterCondition, slavePagination.current, iPageSize, slaveOrderBy);
onSaveStateOk({ enabled: false });
onSendSocketMessage('release', 'noAction', sModelsId, userinfo.sId, null, null);
},
onCancel() {
},
});
};
/** 点击修改按钮操作 */
handleEdit = async () => {
const {
sModelsId, slaveConfig, slaveFilterCondition, slavePagination, slaveOrderBy, app, formSrcRoute, slaveSelectedRowKeys, dispatch, iPageSize,
} = this.props;
const { userinfo } = app;
const addState = {};
if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
message.error('请选择修改行!');
this.props.onSaveState({
loading: false,
});
return;
}
const lockUrl = `${commonConfig.server_host}business/addSysLocking?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
const value = {
tableName: slaveConfig.sTbName,
sId: [slaveSelectedRowKeys[0]],
};
const { data } = await commonServices.postValueService(app.token, value, lockUrl);
// eslint-disable-next-line no-underscore-dangle
const _this = this;
if (data.code === 1) { /* 失败 */
_this.props.onSaveState({ enabled: true, loading: false });
} else if (data.code === -7) {
// eslint-disable-next-line no-underscore-dangle
confirm({
title: '单据校验', /* 防呆校验 */
content: data.msg,
onOk() {
_this.props.onSaveState({ enabled: true });
},
onCancel() {
},
okText: '是',
cancelText: '否',
});
this.props.onSaveState({
loading: false,
});
return true;
} else if (data.code === 2 || data.code === -8) {
Modal.info({
title: '温馨提示:',
content: (
{commonFunc.getReturnMsg(data.msg)}
),
okText: '确认',
onOk() {
_this.props.onSaveState({ enabled: false, loading: false });
addState.sUseInfo = data.msg;
},
});
} else { /* 失败 */
this.props.onSaveState({ enabled: false, loading: false });
addState.sUseInfo = data.msg;
if (commonUtils.isNotEmptyObject(data.erroMsg)) {
message.error(data.erroMsg);
}
return;
}
this.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, iPageSize, slaveOrderBy);
this.props.app.webSocket.onmessageTmp = (msg) => {
const rtmsg = JSON.parse(msg.data);
if (rtmsg.action === 'showMsg') {
message.warning(rtmsg.msg);
this.props.onSaveState({ loading: false });
} else if (rtmsg.action === 'update') {
this.props.onSaveState({ enabled: true, loading: false });
}
};
this.props.handleSendSocketMessage('update', 'showMsg', sModelsId, userinfo.sId, null, null); // 分类型不能以Id来,涉及到多条修改
};
/** 点击新增按钮操作 */
handleAdd = () => {
const { sModelsType, sModelsId } = this.props;
let { slaveSelectedRowKeys, masterData } = this.props;
let { slaveData } = this.props;
if (slaveData === undefined) {
slaveData = [];
}
const newData = this.props.onDataRowAdd('slave', true);/* 调用父级新增 */
if (commonUtils.isNotEmptyObject(newData)) {
newData.iOrder = slaveData.length;
}
if (sModelsType === 'commonClassfiy/sisPosition') {
newData.maxBillNo = 'sNo';
}
if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) { /* 通用分类新增,默认新增行为选中行 */
slaveSelectedRowKeys = [];
slaveSelectedRowKeys.push(newData.sId);
}
/* 多级增加 新增同级 */
if ((sModelsType === 'commonClassify/materialsClassify' || (commonUtils.isNotEmptyObject(sModelsType) && sModelsType.includes('children')))) {
const iIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
/* 找到同级子元素的sControlParentId */
if (iIndex > -1) {
newData.sParentId = slaveData[iIndex].sParentId;
/* 找到同级父级sAllId */
const pId = slaveData[iIndex].sParentId;
const iParentIndex = slaveData.findIndex(item => item.sId === pId);
if (iParentIndex > -1) {
const sAllId = slaveData[iParentIndex].sAllId;
if (commonUtils.isEmptyObject(sAllId)) {
message.warn('数据生成错误![sAllId为空]');
return;
}
newData.sAllId = `${sAllId},${newData.sId}`;
} else {
newData.sAllId = newData.sId;
}
slaveSelectedRowKeys = [newData.sId];
} else {
newData.sAllId = newData.sId;
}
newData.sStatus = '0';
}
newData.sFormId = sModelsId;
if (commonUtils.isNotEmptyObject(masterData)) {
masterData = { ...masterData, ...newData };
}
newData.sFormId = sModelsId;
this.props.onSaveState({
slaveData: [newData, ...slaveData],
slaveSelectedRowKeys,
masterData,
enabled: true,
});
};
/** 点击新增子级按钮操作 */
handleAddChild = () => {
const { sModelsType, sModelsId } = this.props;
let { slaveSelectedRowKeys, expKeys } = this.props;
let { slaveData } = this.props;
if (slaveData === undefined) {
slaveData = [];
}
const newData = this.props.onDataRowAdd('slave', true);/* 调用父级新增 */
if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
newData.sParentId = slaveSelectedRowKeys[0];
const iIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
if (iIndex > -1) {
const sAllId = slaveData[iIndex].sAllId;
if (commonUtils.isEmptyObject(sAllId)) {
message.warn('子级数据生成错误![sAllId为空]'); // 获取父节点的sAllId
return;
}
newData.sAllId = `${sAllId},${newData.sId}`;
}
} else {
message.error('请选择父级分类!');
}
if (sModelsType === 'commonClassfiy/sisPosition') {
newData.maxBillNo = 'sNo';
}
newData.sFormId = sModelsId;
if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) { /* 通用分类新增,默认新增行为选中行 */
slaveSelectedRowKeys = [];
slaveSelectedRowKeys.push(newData.sId);
}
if (commonUtils.isEmptyArr(expKeys)) { /* 通用分类新增,默认新增行为选中行 */
expKeys = [];
expKeys.push(slaveSelectedRowKeys[0]);
} else {
expKeys.push(slaveSelectedRowKeys[0]);
}
slaveData.push(newData);
this.props.onSaveState({
slaveData,
slaveSelectedRowKeys,
enabled: true,
expKeys,
});
};
/* 删除 */
handleDel = () => {
const onOkDel = this.handleOkDel;
confirm({
title: '确定要删除',
onOk() {
onOkDel();
},
onCancel() {
},
});
};
handleOkDel = async () => {
const returnData = await this.handleTableDel('slave');
if (returnData) {
this.handleValidateSave();
}
};
handleTableDel = (name, isWait) => {
const { app } = this.props;
const { [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: tableSelectedRowKeys, sModelsType } = this.props;
let { [`${name}DelData`]: tableDelData } = this.props;
tableDelData = commonUtils.isEmptyArr(tableDelData) ? [] : tableDelData;
if (commonUtils.isNotEmptyArr(tableSelectedRowKeys)) {
if (commonUtils.isNotEmptyObject(sModelsType) && sModelsType.includes('children') && commonUtils.isNotEmptyArr(tableData)) {
/* 删除该节点及所有子节点 */
const controlChildData = tableData.filter(item => commonUtils.isNotEmptyObject(item.sAllId) && item.sAllId.indexOf(tableSelectedRowKeys[0]) > -1 && item.sId !== tableSelectedRowKeys[0]);
if (commonUtils.isNotEmptyArr(tableData)) {
controlChildData.forEach((itemNew) => {
tableSelectedRowKeys.push(itemNew.sId);
});
}
}
for (const sId of tableSelectedRowKeys) {
/* 看看删除集合和从表中是否都存在该条数据 */
const tableDataIndex = tableData.findIndex(item => item.sId === sId);
if (tableDataIndex > -1) {
/* 删除从表中的数据并存入删除集合中 */
const slaveDataFilter = tableData[tableDataIndex];
slaveDataFilter.handleType = 'del';
tableDelData.push(slaveDataFilter);
}
}
if (isWait) {
return { [`${name}Data`]: tableData, [`${name}DelData`]: tableDelData, [`${name}SelectedRowKeys`]: [] };
} else {
this.props.onSaveState({
[`${name}Data`]: tableData,
[`${name}DelData`]: tableDelData,
[`${name}SelectedRowKeys`]: [],
});
return true;
}
} else {
message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseDelData')); // 请选择删除数据
return false;
}
};
handleViewClick = (name, sName, record, index, myConfig) => {
if (sName === 'myTableConfig') {
this.handleQuickViewClick(name, sName, record, index, myConfig);
} else if (sName === 'sLookFlowHistory') {
const flowHistroyId = commonUtils.isNotEmptyObject(record) ? record.sId : '';
this.props.onSaveState({ flowHistroyVisible: true, flowHistroyId });
} else {
this.props.onViewClick(name, sName, record, index, myConfig);
}
}
handleGetTableConfig = async (name, sModelsId) => {
if (commonUtils.isNotEmptyObject(sModelsId)) {
const newConfig = await this.props.onGetTableConfig(name, sModelsId);
if (commonUtils.isNotEmptyObject(newConfig)) {
this.props.onSaveState({ [`${[name]}Config`]: newConfig });
}
}
}
handleQuickViewClick = async (name, sName, record, index, myConfigArr) => {
const {
slaveConfig,
slaveData,
slaveFilterCondition,
slavePagination,
formRoute,
sModelsId,
// slaveSelectedData,
// masterData,
// employeeConfig,
} = this.props;
let picArr = slaveConfig.gdsconfigformslave.filter(item => (item.sName === sName));
if (commonUtils.isNotEmptyArr(myConfigArr)) {
picArr = myConfigArr;
}
if (picArr.length > 0) {
const getConfig = this.handleGetTableConfig;
const tableDataRow = record;
const iIndex = index;
const [{ sActiveId }] = picArr;
let [{ sActiveKey }] = picArr;
const sFormId = sActiveId === '1' ? commonUtils.isEmpty(tableDataRow.sFormId) ? tableDataRow.sSrcFormId : tableDataRow.sFormId : sActiveId;
if (commonUtils.isNotEmptyObject(sActiveKey) && sActiveKey.includes('.')) { /* 接口按钮跳转 如果有slave.对应字段 则需要取出对应字段 */
const index = sActiveKey.lastIndexOf('.');
sActiveKey = sActiveKey.substring(index + 1, sActiveKey.length);
}
const sNameUrl = `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sFormId}?sModelsId=${sFormId}&sName=${formRoute}`;
const filterCondition = [];
const conditionValues = this.props.getSqlCondition(picArr[0], name, tableDataRow);
if (!commonUtils.isEmpty(conditionValues)) {
Object.keys(conditionValues).forEach((item) => {
if ((item === 'tStartDate_pro' || item.substring(0, 1) === 'p')) {
if (!commonUtils.isEmpty(conditionValues[item]) && conditionValues[item].length >= 2) {
const tStartDate = moment(conditionValues[item][0]).format(this.sDateFormat);
const tEndDate = moment(conditionValues[item][1]).add(1, 'days').format(this.sDateFormat);
filterCondition.push({
bFilterName: item,
bFilterCondition: '=',
bFilterValue: `${tStartDate},${tEndDate}`,
});
}
} else if ((item === 'mStartDate_pro' || item.substring(0, 1) === 'm')) {
if (!commonUtils.isEmpty(conditionValues[item])) {
const tStartDate = moment(conditionValues[item]).startOf('month').format(this.sDateFormat);
const tEndDate = moment(conditionValues[item]).endOf('month').add(1, 'days').format(this.sDateFormat);
filterCondition.push({
bFilterName: `t${item.substring(1, item.length)}`,
bFilterCondition: '=',
bFilterValue: `${tStartDate},${tEndDate}`,
});
}
} else if (item.substring(0, 1) === 't') {
filterCondition.push({
bFilterName: item,
bFilterCondition: '=',
bFilterValue: moment(conditionValues[item]).format(this.sDateFormat),
});
} else {
filterCondition.push({
bFilterName: item,
bFilterCondition: '=',
bFilterValue: conditionValues[item],
});
}
});
}
this.props.dispatch({
type: 'content/onRouter',
payload: {
url: sNameUrl,
refresh: getConfig.bind(this, name, sModelsId), /* 刷新方法 */
sTabId: commonUtils.createSid(),
sParentId: this.state.sTabId,
urlDataType: 'newPane',
checkedId: myConfigArr[0].sId,
sName: myConfigArr[0].sName,
bFilter: slaveFilterCondition,
pageSize: commonConfig.pageSize,
pages: slavePagination,
currentData: slaveData,
conditonValues: conditionValues,
newKey: tableDataRow[sActiveKey],
currentIndex: iIndex,
filterCondition,
},
});
}
};
handleViewChoose= (name, sName, record) => {
if (sName === 'sParams') { // 产量上报 工艺参数
const { enabled } = this.props;
const slaveSelectOneData = record;
const sProcessParamsSelects = [];
const sParamData = [];
let paramType = '';
if (commonUtils.isNotEmptyObject(slaveSelectOneData)) {
paramType = slaveSelectOneData.sReportParam; /* 上报参数 */
}
if (commonUtils.isEmpty(paramType)) {
message.warn('无工艺参数!');
return;
}
/* 工序参数以表格形式展示 列 */
const sParamConfig = {
bisMutiSelect: false,
bMutiSelect: false,
};
const gdsconfigformslave = [{
sId: commonUtils.createSid(),
sName: 'sId',
showName: '主键',
bVisible: false,
iFitWidth: 200,
}, {
sId: commonUtils.createSid(),
sName: 'bSelfCbx',
showName: '选择',
bVisible: true,
iFitWidth: 37,
}, {
sId: commonUtils.createSid(),
sName: 'sParamKey',
showName: '参数主键',
bVisible: false,
iFitWidth: 200,
}, {
sId: commonUtils.createSid(),
sName: 'sParamName',
showName: '参数名',
bVisible: true,
iFitWidth: 230,
}, {
sId: commonUtils.createSid(),
sName: 'sParamValue',
showName: '参数值',
bVisible: true,
iFitWidth: 230,
}];
sParamConfig.gdsconfigformslave = gdsconfigformslave;
const sParamColumn = commonFunc.getHeaderConfig(sParamConfig);
if (commonUtils.isNotEmptyObject(paramType)) {
/* 要把数据以表格的形式显示出来 */
const sParamJsonObj = JSON.parse(paramType);
for (const key of Object.keys(sParamJsonObj)) {
if (key.includes('sParam') && !key.includes('DropDown') && !key.includes('Default')) {
const obj = {};
obj.sId = commonUtils.createSid();
obj.sParamKey = key;
obj.sParamName = sParamJsonObj[key];
/* 找到数字 找到下拉数据源 */
const num = key.replace(/[^\d]/g, '').trim();
if (Number(num)) {
const number = Number(num);
const sParamDropDownKey = `sParamDropDown${number}`;
obj.sDropDownData = sParamJsonObj[sParamDropDownKey]; /* 下拉 */
const sParamDefaultKey = `sParamDefault${number}`;
obj.sParamValue = sParamJsonObj[sParamDefaultKey]; /* 默认值 */
/* 如果sParamValue有值 则替换默认值 */
const oldKey = `sParamValue${number}`;
const oldParamValue = slaveSelectOneData[oldKey]; /* 界面打开时,数据集中原始的sParamValue1,sParamValue2数据填充到数据上 */
if (commonUtils.isNotEmptyObject(oldParamValue)) {
obj.sParamValue = oldParamValue; /* 默认值 */
}
}
sParamData.push(obj);
}
}
/* 将sParam1中的数据 还原到sParamData数据中 */
if (commonUtils.isNotEmptyObject(record.sParams)) {
const selectedData = JSON.parse(record.sParams);
if (commonUtils.isNotEmptyArr(selectedData)) {
selectedData.forEach((itemS) => {
const iIndex = sParamData.findIndex(item => item.sParamName === itemS.sParamName);
if (iIndex > -1) {
const addState = {};
addState.sParamValue = itemS.sParamValue;
addState.bSelfCbx = itemS.bSelfCbx;
sParamData[iIndex] = { ...sParamData[iIndex], ...addState };
}
});
}
/* 如果数据集有一个是非选中的则非选中状态 否则全选 */
if (commonUtils.isNotEmptyArr(sParamColumn)) {
const iIndex = sParamColumn.findIndex(item => item.dataIndex === 'bSelfCbx');
if (iIndex > -1) {
const filterData = sParamData.filter(item => !item.bSelfCbx);
if (commonUtils.isNotEmptyArr(filterData)) {
sParamColumn[iIndex] = { ...sParamColumn[iIndex], bCheckAll: false };
} else {
sParamColumn[iIndex] = { ...sParamColumn[iIndex], bCheckAll: true };
}
}
}
}
}
this.props.onSaveState({
slaveRecord: record,
sProcessParamsSelects,
sParamsModalVisible: true,
sParamConfig,
sParamColumn,
sParamData,
sParamModalType: 'sReport',
enabled,
});
}
}
/* 动态参数标题选择框 全选/取消全选 */
handleCheckParamChange = () => {
const {
sParamData,
sParamColumn,
} = this.props;
/* 全选 取消全选功能 */
if (commonUtils.isNotEmptyArr(sParamData)) {
/* 标题bSelfCbx加标识 */
const iIndex = sParamColumn.findIndex(item => item.dataIndex === 'bSelfCbx');
if (iIndex > -1) {
let bSelfCbx = false;
if (sParamColumn[iIndex].bCheckAll) {
bSelfCbx = false;
} else {
bSelfCbx = true;
}
sParamColumn[iIndex] = { ...sParamColumn[iIndex], bCheckAll: bSelfCbx };
sParamData.forEach((item, index) => {
sParamData[index] = { ...sParamData[index], bSelfCbx };
});
}
this.props.onSaveState({
sParamData,
sParamColumn,
});
}
}
/* 选择上报参数点击确定 */
handleReportParamsOk = () => { // 工艺参数弹窗确定按钮
const {
slaveData,
slaveRecord,
sParamData,
// enabled,
sParamModalType,
} = this.props;
if (true) {
if (commonUtils.isNotEmptyArr(slaveData) && commonUtils.isNotEmptyObject(slaveRecord)) {
const processSelectDataIndex = slaveData.findIndex(item => item.sId === slaveRecord.sId);
if (processSelectDataIndex > -1) {
if (commonUtils.isNotEmptyArr(sParamData)) {
let sParamJsonData = '';
const sParamSeletedData = sParamData.filter(item => item.bSelfCbx);
if (commonUtils.isNotEmptyObject(sParamSeletedData)) {
sParamJsonData = JSON.stringify(sParamSeletedData);
}
let { handleType } = slaveData[processSelectDataIndex];
handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
if (sParamModalType === 'sReport') { /* 报价参数点击确定 */
slaveData[processSelectDataIndex].sParams = sParamJsonData;
}
slaveData[processSelectDataIndex].handleType = handleType;
}
}
}
this.props.onSaveState({
slaveData,
sParamsModalVisible: false,
});
} else {
this.props.onSaveState({
sParamsModalVisible: false,
});
}
}
/** toolbar审核(消审) */
handleAudit = async (flag) => {
/* 待用数据声明 */
const { masterData, gdsformconst } = this.props;
if (!commonUtils.isEmpty(masterData)) {
/* 作废订单不能审核 */
if (masterData.bInvalid) {
message.warning(gdsformconst.filter(item => (item.sName === 'sToVoid'))[0].showName);
return '';
}
/** 数据审核 */
await this.dataAudit(flag);
} else {
this.props.onSaveState({
loading: false,
});
}
};
/** 数据审核 */
dataAudit = async (flag, tmpCheck, isWait) => {
message.destroy();
/* 待用数据声明 */
const {
sModelsId, masterData, app, slaveConfig, token, sModelsType, slaveData, slaveSelectedRowKeys, slaveFilterCondition,
} = this.props;
const sSlaveIdArray = [];
if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
slaveSelectedRowKeys.forEach((item) => {
sSlaveIdArray.push(item);
});
}
const slaveId = sSlaveIdArray.toString();
/* 数据参数 */
const value = {
sClientType: '1',
paramsMap: {
iFlag: flag,
iTmpCheck: commonUtils.isEmptyNumber(tmpCheck) ? 0 : tmpCheck,
sFormGuid: sModelsId,
sGuid: masterData.sId,
sSlaveId: slaveId,
sBillNo: commonUtils.isNotEmptyObject(masterData.sBillNo) ? masterData.sBillNo : '',
},
};
let clearFlag = false;
if (sModelsType.includes('sales/salesOrder') || sModelsType.includes('manufacture/workOrder')) {
if (commonUtils.isNotEmptyArr(slaveData)) {
for (const item of slaveData) {
if (commonUtils.isNotEmptyStr(item.sProductInfo)) {
clearFlag = true;
break;
}
}
} else {
this.props.onSaveState({
loading: false,
});
return;
}
}
/* 数据审核 */
const url = `${commonConfig.server_host}business/doExamine?sModelsId=${sModelsId}`;
const returnData = (await commonServices.postValueService(app.token, value, url)).data;
if (isWait) {
return returnData;
} else {
/* 接收返回值 */
const check = commonFunc.showMessage(app.commonConst, 'BtnExamine');/* 审核 */
const BtnCancelExamine = commonFunc.showMessage(app.commonConst, 'BtnCancelExamine');/* 销审 */
if (returnData.code === 1) { /* 成功 */
this.props.onSaveState({
loading: false,
});
if (flag === 1) {
/* 审核 */
if (clearFlag && (sModelsType.includes('sales/salesOrder') || sModelsType.includes('manufacture/workOrder'))) {
commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductId', []);
commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductNo', []);
commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductName', []);
}
let outData;
if (commonUtils.isNotEmptyObject(returnData.dataset)) {
outData = returnData.dataset.rows[0].dataSet.outData;
}
if (commonUtils.isNotEmptyStr(outData[0].sReturn)) {
const sReturnArray = outData[0].sReturn.split('|');
if (outData[0].sReturn.split('-').length < 2) {
// 正常业务提示,非审核模板
// if (this.props.app.currentPane.refresh !== undefined) {
// this.props.app.currentPane.refresh();
// }
message.error(check + outData[0].sReturn);
return;
}
const checkConditions = [];
let checkPersonData = {};
sReturnArray.forEach((item) => {
const checkCondition = item.split('-')[2];
const iIndex = checkConditions.findIndex(itemCondition => itemCondition.condition === checkCondition);
if (iIndex <= -1) {
checkConditions.push({
key: commonUtils.createSid(),
condition: checkCondition,
});
}
});
const sCheckModelId = sReturnArray[0].split('-')[1];
if (commonUtils.isNotEmptyStr(sCheckModelId)) {
const urlCheck = `${commonConfig.server_host}checkModel/getUserListByModelId/${sCheckModelId}?sModelsId=${sModelsId}`;
const dataReturn = (await commonServices.getService(token, urlCheck)).data;
if (dataReturn.code === 1) {
checkPersonData = dataReturn.dataset.rows;
checkPersonData.forEach((item) => {
item.key = commonUtils.createSid();
});
this.props.onSaveState({
checkConditions, checkPersonData, sCheckModelId, visible: true,
});
return true;
} else { /* 失败 */
this.props.getServiceError({ msg: check + dataReturn });
}
}
} else {
message.success(check + returnData.msg);
}
} else {
/* 消审 */
const { outData } = returnData.dataset.rows[0].dataSet;
if (commonUtils.isNotEmptyStr(outData[0].sReturn)) {
message.error(outData[0].sReturn);
} else {
// if (this.props.app.currentPane.refresh !== undefined) {
// this.props.app.currentPane.refresh();
// }
message.success(BtnCancelExamine + returnData.msg);
}
}
await this.handleGetData(slaveConfig, slaveFilterCondition, 1);
if (this.props.app.currentPane.refresh !== undefined) {
this.props.app.currentPane.refresh();
}
} else { /* 失败 */
this.props.getServiceError(returnData);
this.props.onSaveState({
loading: false,
});
}
return true;
}
};
/** toolbar校验保存 */
handleValidateSave = async () => {
let isTrue = true;
this.form.validateFields((err) => {
/* 验证通过与不通过走不同的流程 */
if (err) { /* 验证失败 */
/* 直接渲染显示错误提示 */
for (const key of Object.keys(err)) {
message.warning(err[key].errors[0].message);
}
isTrue = false;
this.props.onSaveState({
loading: false,
});
} else { /* 验证成功 */
const {
slaveData, slaveConfig, slaveDelData,
} = this.props;
const data = [];
if (!commonBusiness.validateTable(slaveConfig, slaveData, this.props)) {
this.props.onSaveState({
loading: false,
});
isTrue = false;
return;
}
data.push(commonBusiness.mergeData('slave', slaveConfig.sTbName, slaveData, slaveDelData));
if (slaveConfig.sTbName.toLowerCase().includes('master')) {
const { sUserName = '' } = commonUtils.convertStrToObj(localStorage.getItem('xlybusinessuserinfo'));
data[0].column.forEach((item) => {
const { handleType } = item;
if (handleType !== 'add') {
item.sUpdatePerson = sUserName;
item.tUpdate = moment().format('YYYY-MM-DD HH:mm:ss');
}
});
}
this.handleSaveData({ data, sClientType: '1' });
}
});
if (!isTrue) throw new Error('异常');
};
/** toolbar保存 */
handleSaveData = async (params) => {
const {
token, sModelsId, slaveFilterCondition, slaveConfig, slavePagination, slaveOrderBy, app, slaveData, iPageSize,
} = this.props;
const { userinfo } = app;
const onSendSocketMessage = this.props.handleSendSocketMessage;
const returnData = await commonBusiness.saveData({ token, value: params, sModelsId });
if (commonUtils.isNotEmptyObject(returnData)) {
/* 防呆校验 */
if (returnData.code === -7) {
// eslint-disable-next-line no-underscore-dangle
const _this = this;
confirm({
title: '单据校验', /* 防呆校验 */
content: returnData.msg,
onOk() {
params.iFlag = 1;
_this.handleSaveData(params);
},
onCancel() {
},
okText: '保存',
cancelText: '不保存',
});
this.props.onSaveState({
loading: false,
});
return true;
} else if (returnData.code === 2 || returnData.code === -8) {
Modal.info({
title: '温馨提示:',
content: (
{commonFunc.getReturnMsg(returnData.msg)}
),
okText: '确认',
onOk() {},
});
}
commonUtils.clearStoreDropDownData();
/* 新记录时,关闭后能自动带值 */
const callBackRecord = this.props.app.currentPane.newRecordMethod;
if (callBackRecord !== undefined && commonUtils.isNotEmptyArr(slaveData) && slaveData.length > 0) {
const filterData = slaveData.filter(item => (item.handleType === 'add'));
const sId = commonUtils.isNotEmptyArr(filterData) && filterData.length > 0 ? filterData[0].sId : null;
/* 回调 传[新增的数据sId] */
if (this.props.app.currentPane.newRecordMethod !== undefined) {
this.props.app.currentPane.newRecordMethod(sId);
}
}
if (this.props.app.currentPane.refresh !== undefined) {
this.props.app.currentPane.refresh();
}
/* END */
onSendSocketMessage('release', 'noAction', sModelsId, userinfo.sId, null, null);
this.props.onSaveState({
enabled: false, slaveDelData: [], loading: false,
});
this.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, iPageSize, slaveOrderBy);
return true;
} else {
this.props.onSaveState({
slaveDelData: [],
loading: false,
});
return false;
}
};
/** 表单回带 */
handleForm = (form) => {
this.form = form;
};
/* 作废、取消作废的公用函数 */
handleInvalid = (obj) => {
const props = { ...this.props, ...this.state, ...obj };
const onOkInvaild = this.handleOkChangeInvaild;
confirm({
title: obj.title,
onOk() {
onOkInvaild(props);
},
onCancel() {
},
});
};
/* 切换作废状态 */
handleOkChangeInvaild = async (props) => {
props = this.handleOkInvalid(props);
this.setState({ ...props });
};
/** 作废,取消作废 */
handleOkInvalid = async (props) => {
const {
sModelsId, slaveData, slaveConfig, handleType, slaveSelectedRowKeys, app, slavePagination,
} = props;
if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
const { token } = props.app;
const { sTbName } = slaveConfig;
const value = {
sClientType: '1',
sId: slaveSelectedRowKeys,
sTableName: sTbName,
handleType,
sBooleanCheck: false,
};
const url = `${commonConfig.server_host}checkModel/updatebInvalid?sModelsId=${sModelsId}`;
const { data } = await commonServices.postValueService(token, value, url);
if (data.code === 1) {
message.success(data.msg);
for (const key of slaveSelectedRowKeys) {
const selectData = slaveData.filter(item => item.sId === key);
selectData.bInvalid = handleType === 'toVoid';
}
/* 作废(取消作废)后刷新页面 */
this.handlePaginationChange(slavePagination.current);
} else {
this.props.getServiceError(data);
}
return props;
} else {
message.warn(commonFunc.showMessage(app.commonConst, 'sChoosebInvalid'));/* 请选择作废数据 */
}
};
/** 按钮操作事件 */
handleButtonClick = (name) => {
if (name === 'BtnOut') {
this.handleOut();
} else if (name === 'BtnRefresh') {
const { slavePagination } = this.props;
this.handlePaginationChange(slavePagination.current);
} else if (name === 'BtnSetPeriod') {
this.handleBtnSetPeriod();
} else if (name === 'BtnRelievePeriod') {
this.handleBtnRelievePeriod();
}
};
/* 导出Excel */
handleOut = async () => {
const {
slaveConfig, formRoute, masterData,
} = this.props;
/* 导出使用Post提交 */
const url = `${commonConfig.server_host}excel/export/${slaveConfig.sId}?sModelsId=${slaveConfig.sParentId}&sName=${formRoute}&token=${encodeURIComponent(this.props.app.token)}`;
const conditionValuesStr = JSON.stringify({ sId: masterData?.sId, sBillNo: masterData?.sBillNo });
this.handleOpenOut(url, '', '', undefined, conditionValuesStr);
};
/* Get提交地址栏参数过多,更改Get提交为Post提交 */
handleOpenOut = (url, bFilter, slaveOrderBy, sGroupByList, conditionValues) => {
const newWin = window.open();
let formStr = '';
// 设置样式为隐藏,打开新标签再跳转页面前,如果有可现实的表单选项,用户会看到表单内容数据
formStr = `';
newWin.document.body.innerHTML = formStr;
newWin.document.forms[0].submit();
return newWin;
}
/* 获取期初 */
handleGetPeriod = async () => {
const { sTbName } = this.props.masterConfig;
let sClomunType = '';
if (sTbName === 'cahsupplyinit') {
sClomunType = 'bAP';
} else if (sTbName === 'cahcustomerinit') {
sClomunType = 'bAR';
} else if (sTbName === 'cahcashierinit') {
sClomunType = 'bCashier';
}
const { sModelsId } = this.props;
const { token } = this.props.app;
const url = `${commonConfig.server_host}sysAccountPeriod/getSysAccountPeriod?sModelsId=${sModelsId}`;
const value = { sClientType: '1', sClomunType };
const { data } = await commonServices.postValueService(token, value, url);
if (data.code === 1) {
const [{ isSysAccountPeriod }] = data.dataset.rows;
this.props.onSaveState({
adDisabled: isSysAccountPeriod,
sClomunType,
});
} else {
this.props.getServiceError(data);
}
};
/* 设置期初 */
handleBtnSetPeriod = async () => {
const { sTbName } = this.props.masterConfig;
let sClomunType = '';
if (sTbName === 'cahsupplyinit') {
sClomunType = 'bAP';
} else if (sTbName === 'cahcustomerinit') {
sClomunType = 'bAR';
} else if (sTbName === 'cahcashierinit') {
sClomunType = 'bCashier';
}
const { sModelsId } = this.props;
const { token } = this.props.app;
const url = `${commonConfig.server_host}sysAccountPeriod/updateSysAccountPeriod?sModelsId=${sModelsId}`;
const value = { sClientType: '1', handleType: 'add', sClomunType };
const { data } = await commonServices.postValueService(token, value, url);
if (data.code === 1) {
message.success(data.msg);
this.props.onSaveState({ adDisabled: true, enabled: false });
} else {
this.props.getServiceError(data);
}
};
/* 解除锁定 */
handleBtnRelievePeriod = async () => {
const { sModelsId } = this.props;
const { token } = this.props.app;
const { sTbName } = this.props.masterConfig;
let sClomunType = '';
if (sTbName === 'cahsupplyinit') {
sClomunType = 'bAP';
} else if (sTbName === 'cahcustomerinit') {
sClomunType = 'bAR';
} else if (sTbName === 'cahcashierinit') {
sClomunType = 'bCashier';
}
const url = `${commonConfig.server_host}sysAccountPeriod/updateSysAccountPeriod?sModelsId=${sModelsId}`;
const value = { sClientType: '1', handleType: 'reset', sClomunType };
const { data } = await commonServices.postValueService(token, value, url);
if (data.code === 1) {
message.success(data.msg);
this.props.onSaveState({ adDisabled: false });
} else {
this.props.getServiceError(data);
}
};
handleTitleChange = (slavePagination, filters, sorter) => {
const { slaveConfig, slaveFilterCondition } = this.props;
const sort = sorter.order === 'ascend' ? 'asc' : 'desc';
const slaveOrderBy = Object.keys(sorter).length > 0 ? { [sorter.columnKey]: sort } : ''; // 后端未支持空对象, 先用空表示
this.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, slavePagination.pageSize, slaveOrderBy);
};
handleTitleChangeEnabled = (slavePagination) => {
this.props.onSaveState({ slavePagination });
};
handleTableSelectRowChange = async (name, selectedRowKeys) => {
const {
[`${name}Data`]: tableData, sModelsType, sModelsId, token, masterConfig, enabled,
} = this.props;
if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
if (sModelsType === 'commonClassfiy/salesMan') {
const addState = this.props.onTableSelectRowChange(name, selectedRowKeys, true);
const { [`${name}SelectedRowKeys`]: rowKeys } = addState;
for (const sId of rowKeys) {
const tableDataIndex = tableData.findIndex(item => item.sId === sId);
const sNameIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sName');/* 判断配置中是否有员工编号字段 */
if (tableDataIndex > -1 && sNameIndex > -1) {
const tableDataRow = JSON.parse(JSON.stringify(tableData[tableDataIndex]));
masterConfig.gdsconfigformslave[sNameIndex].iTag = 0; /* 默认是0 */
if (enabled && tableDataRow.handleType !== 'add') { /* 判断销售人员是否已被占用 */
const value = {
tableName: masterConfig.sTbName,
sId: [sId],
};
const url = `${commonConfig.server_host}business/addSysLocking?sModelsId=${sModelsId}`;
/* 接收返回值 */
const { data } = await commonServices.postValueService(token, value, url);
if (data.code === 1) {
const sNameIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sName');
masterConfig.gdsconfigformslave[sNameIndex].iTag = 1; /* ,已占用销售人员,员工不能修改 即下拉不可选 */
} else { /* 失败 */
this.props.getServiceError(data);
}
}
}
}
} else if (name === 'sParam' && commonUtils.isNotEmptyArr(selectedRowKeys)) {
/* 点击工艺参数列表 根据点击行动态加载配置 */
const { sParamData, sParamConfig } = this.props;
/* 找到最后一个选中 */
const lastSelectedKeys = selectedRowKeys[selectedRowKeys.length - 1];
const iIndex = sParamData.findIndex(item => lastSelectedKeys === item.sId);
/* 选中数据时 塞入选中行的配置 */
if (iIndex > -1) {
const sParamObj = sParamData[iIndex];
const index = sParamConfig.gdsconfigformslave.findIndex(item => item.sName === 'sParamValue');
if (index > -1) {
if (commonUtils.isNotEmptyObject(sParamObj.sDropDownData)) {
sParamConfig.gdsconfigformslave[index].sDropDownType = 'const';
sParamConfig.gdsconfigformslave[index].showDropDown = JSON.stringify(sParamObj.sDropDownData);
} else {
sParamConfig.gdsconfigformslave[index].sDropDownType = '';
sParamConfig.gdsconfigformslave[index].showDropDown = undefined;
}
}
/* 点击时 若没打钩 则选择框打钩 若已经打钩则取消打钩 */
if (sParamData[iIndex].bSelfCbx) {
// sParamData[iIndex] = { ...sParamData[iIndex], bSelfCbx: false };
} else {
sParamData[iIndex] = { ...sParamData[iIndex], bSelfCbx: true };
}
this.props.onSaveState({
sParamData,
});
}
}
}
this.props.onTableSelectRowChange(name, selectedRowKeys);
}
/* 点击展开图标时,调用接口获取嵌套字表数据 */
handleOnExpand = async (expanded, record) => {
const { expKeys } = this.props;
/* 添加移除展开的sId */
const { formRoute } = this.props;
let newExp = commonUtils.isNotEmptyArr(expKeys) ? expKeys : [];
let rowKeyId = '';
if (formRoute === '/indexPage/materialRequirementsPlanning') {
rowKeyId = record.sMaterialsGS;
}
if (expanded) {
if (commonUtils.isNotEmptyObject(rowKeyId)) {
newExp.push(rowKeyId);
}
} else {
newExp = newExp.filter(item => item !== rowKeyId);
}
this.props.onSaveState({ expKeys: newExp });
}
render() {
return (
);
}
};
};