/* eslint-disable */
import React, { useEffect, useRef, useState } from "react";
import moment from "moment";
import { cloneDeep } from "lodash";
import { Tabs, Modal, Space, Button, DatePicker, Radio, message, Avatar, Row, Col, Table } from "antd";
import * as commonUtils from "@/utils/utils";
import * as commonConfig from "@/utils/config";
import * as commonServices from "@/services/services";
import * as commonFunc from "@/components/Common/commonFunc";
import * as commonBusiness from "@/components/Common/commonBusiness";
import useCommonBase from "@/components/Common/CommonHooks/useCommonBase";
import CommonOperationBarComponent from "@/mes/common/commonOperationBarComponent";
import StaticEditTable from "@/components/Common/CommonTable";
import CommonViewTable from "@/components/Common/CommonViewTable";
import RouterComponent from "@/routes/mes/routerComponent";
import EquipmentRepair from "../../serviceUpkeep/equipmentRepair";
import SwasterTypeTable from "./Table/SWasteType";
import ChoosePalletComponent from "../choosePalletComponent";
import CommonViewDragable from "@/components/Common/CommonViewDragable";
import costomPageFun from "@/mes/costomPageFun";
import styles from "./index.less";
const { TabPane } = Tabs;
// 事件层
const useCommonModelEvent = props => {
const {
formData: formDataOld = [],
enabled,
copyTo,
sFilterConditions, // 父页面过滤条件
noGetData, // 不要加载数据,根据另一张表选中行加载时用
currentId,
isRefresh
} = props;
let formData =
props.parentProps?.btnConfig?.sActiveId === "12710101117087374661080"
? formDataOld.filter(item => item.sGrd === "Knifetable")
: formDataOld;
// 标签补打formData特殊处理
formData = useGetFormDataNew(props, formData);
// 合并自定义列
const handleMergeCustomColumn = (addState, tableList = []) => {
tableList.forEach(tableName => {
const { [`${tableName}ColumnConfig`]: columnConfig } = addState;
const config =
addState[`${tableName}Config`] || props[`${tableName}Config`];
if (columnConfig) {
const configNew = JSON.parse(JSON.stringify(config));
configNew.gdsconfigformslave.forEach(item => {
if (item.sName && item.bVisible && !item.sControlName) {
item.bVisible = false;
}
});
columnConfig.forEach(item => {
const iIndex = configNew.gdsconfigformslave.findIndex(
item1 => item1.sName && item1.sName === item.sName
);
if (iIndex > -1) {
configNew.gdsconfigformslave[iIndex].bVisible = item.bVisible;
configNew.gdsconfigformslave[iIndex].iOrder = item.iOrder;
item.showName &&
(configNew.gdsconfigformslave[iIndex].showName = item.showName);
} else {
configNew.gdsconfigformslave.push(item);
}
});
configNew.gdsconfigformslave = configNew.gdsconfigformslave.sort(
(a, b) => a.iOrder - b.iOrder
);
addState = {
...addState,
[`${tableName}Config`]: configNew,
[`${tableName}Column`]: commonFunc.getHeaderConfig(configNew)
};
}
});
return addState;
};
// 特殊情况下处理下页面布局(班组报工)
const handleGetFilterPageLayout = pageLayout => {
const bOne2Fore = JSON.stringify(pageLayout).includes("第一转到第四转");
const bOne2Six = JSON.stringify(pageLayout).includes("第一转到第六转");
if (
props.sModelsId !== "12710101117087404588200" &&
props.sModelsId !== "12710101117260270570210" &&
props.sModelsId !== "12710101117086786735350" &&
!bOne2Fore &&
!bOne2Six
)
return pageLayout;
const { sMachineId, iTeamType } = props.app.userinfo;
const [tableList, tabConfig] = pageLayout;
const tabConfigFilter = cloneDeep(tabConfig);
let tableListFilter = tableList;
// 复制第一转到第四转
let stepCopy = cloneDeep(
tabConfig?.[0].configList?.[0].children?.[1]?.configList?.[0]
);
if (bOne2Fore && stepCopy) {
try {
stepCopy.sTabName = "第一转";
tabConfigFilter[0].configList[0].children[1].configList[0] = cloneDeep(
stepCopy
);
stepCopy.sTabName = "第二转";
tabConfigFilter[0].configList[0].children[1].configList[1] = cloneDeep(
stepCopy
);
stepCopy.sTabName = "第三转";
tabConfigFilter[0].configList[0].children[1].configList[2] = cloneDeep(
stepCopy
);
stepCopy.sTabName = "第四转";
tabConfigFilter[0].configList[0].children[1].configList[3] = cloneDeep(
stepCopy
);
tabConfigFilter[0].configList[0].children[1].configList.forEach(
item => {
if (JSON.stringify(pageLayout).includes("第一转到第四转-丝印")) {
item.children[0].configList[0].sTabName = item.sTabName;
} else {
item.children[0].configList[0].sTabName += `_${item.sTabName}`;
item.children[1].configList[0].sTabName += `_${item.sTabName}`;
item.children[2].configList[0].sTabName = item.sTabName;
}
}
);
} catch (error) {
console.log("=====err", error);
}
return [tableListFilter, tabConfigFilter];
}
// 复制第一转到第六转
stepCopy = cloneDeep(
tabConfig?.[0].configList?.[0].children?.[1]?.configList?.[0]
);
if (bOne2Six) {
try {
stepCopy.sTabName = "第一转";
tabConfigFilter[0].configList[0].children[1].configList[0] = cloneDeep(
stepCopy
);
stepCopy.sTabName = "第二转";
tabConfigFilter[0].configList[0].children[1].configList[1] = cloneDeep(
stepCopy
);
stepCopy.sTabName = "第三转";
tabConfigFilter[0].configList[0].children[1].configList[2] = cloneDeep(
stepCopy
);
stepCopy.sTabName = "第四转";
tabConfigFilter[0].configList[0].children[1].configList[3] = cloneDeep(
stepCopy
);
stepCopy.sTabName = "第五转";
tabConfigFilter[0].configList[0].children[1].configList[4] = cloneDeep(
stepCopy
);
stepCopy.sTabName = "第六转";
tabConfigFilter[0].configList[0].children[1].configList[5] = cloneDeep(
stepCopy
);
tabConfigFilter[0].configList[0].children[1].configList.forEach(
item => {
item.children[0].configList[0].sTabName = item.sTabName;
}
);
} catch (error) {
console.log("=====err", error);
}
return [tableListFilter, tabConfigFilter];
}
// 工单信息非烫金时隐藏电化铝子集
if (props.sModelsId === "12710101117086786735350") {
const { currentSelectedMachineTaskDataRow = {} } = commonUtils.getAppData(
"globalData"
);
const { sProcessClassifyName = "" } = currentSelectedMachineTaskDataRow;
if (sProcessClassifyName.includes("烫金")) return pageLayout;
tableListFilter = tableList.filter(item => item !== "materials31");
try {
delete tabConfigFilter[3].configList[3];
} catch (error) { }
return [tableListFilter, tabConfigFilter];
}
if (
iTeamType === 2
// [
// "17183488470003431845359008405500",
// "127101011170917824480111",
// "127101011170917824480112",
// "127101011170917824480113",
// "127101011170917824480114"
// ].includes(sMachineId)
) {
// 包装一组
tableListFilter = tableList.filter(
item => !["table4", "table13", "table41", "table131"].includes(item)
);
try {
delete tabConfigFilter[0].configList[0].children[1].configList[2];
delete tabConfigFilter[0].configList[0].children[1].configList[1];
} catch (error) { }
} else if (
iTeamType === 1
// [
// // "17140458730005386447188915338000",
// "17140460550001912614399026018800",
// "17140461020006385813836342722000",
// "17140461340004361455002739094000"
// ].includes(sMachineId)
) {
// 人检一组
tableListFilter = tableList.filter(
item =>
!["table4", "table13", "table42", "table132", "tableS12"].includes(
item
)
);
try {
delete tabConfigFilter[0].configList[0].children[1].configList[3];
delete tabConfigFilter[0].configList[0].children[1].configList[1];
delete tabConfigFilter[0].configList[1].children[2].configList[7];
} catch (error) { }
} else {
tableListFilter = tableList.filter(
item =>
!["table41", "table131", "table42", "table132", "tableS12"].includes(
item
)
);
try {
delete tabConfigFilter[0].configList[0].children[1].configList[3];
delete tabConfigFilter[0].configList[0].children[1].configList[2];
delete tabConfigFilter[0].configList[1].children[2].configList[7];
} catch (error) { }
}
return [tableListFilter, tabConfigFilter];
};
const [refreshCount, setRefreshCount] = useState(0);
const sModelType =
Array.isArray(formData) && formData.length > 0
? (formData[0]?.sName || formData[0]?.sModelType || '')
: '';
// 初始化事件
useEffect(
async () => {
if (commonUtils.isNotEmptyArr(formData)) {
let pageLayout = [];
let addState = {};
const { gdsconfigformslave } = formData[0];
const pageLayoutConfig = gdsconfigformslave.find(
item => item.sControlName === "pageLayout"
);
if (pageLayoutConfig) {
pageLayout = commonUtils.convertStrToObj(
pageLayoutConfig.sDefault,
[]
);
}
if (commonUtils.isNotEmptyArr(pageLayout)) {
// 特殊情况下处理下页面布局
pageLayout = handleGetFilterPageLayout(pageLayout);
const [tableList, tabConfig] = pageLayout;
const colunmData = handleGetColumnData(tableList, true);
let result = {};
if (!commonUtils.isEmptyObject(copyTo) && !refreshCount) {
result = await handleGetData(tableList, true, true);
} else if (noGetData) {
result = await handleGetData(
tableList.filter(
item =>
item === "workerOrderBatchMaterial" || item === "plateInfo"
),
true,
true
);
} else {
result = await handleGetData(tableList, true, true);
}
if (!currentId) {
addState.bFinish = props.bFinish ? props.bFinish + 1 : 1;
}
addState = {
...addState,
tableList,
tabConfig,
...colunmData,
...result,
firstTableName: tableList[0]
};
// 读码时,点下料不需要选中,使用指令集 clearrowkey, 发现与这个是异步的,导致还是选中状态。
// addState["salveWydm1SelectedRowKeys"] = []; // 0806解决生成检验标示后选中状态消失
if (tableList[0] === "Knifetable") {
const globalData = commonUtils.getAppData("globalData");
const bFilter = [
{
bFilterCondition: "=",
bFilterName: "sProductId",
bFilterValue: globalData.currentWorkOrderInfo?.sProductId
}
];
addState["KnifetableFilter"] = bFilter;
addState.refreshTableList = ["Knifetable"];
}
// 如果有自定义列,合并自定义列
addState = {
...addState,
...handleMergeCustomColumn(addState, tableList),
isRefresh: false
};
props.onSaveState(addState);
}
}
},
[
formData.length,
refreshCount,
noGetData,
JSON.stringify(sFilterConditions)
]
);
useEffect(() => {
if (!isRefresh) return
handleRefresh()
}, [isRefresh])
// 初始化后执行一次指令集
useEffect(
() => {
if (!props.bFinish) return;
const { firstTableName } = props;
if (!firstTableName) return;
const tableConfig = ({} = props[`${firstTableName}Config`]);
const { sOnShowInstruct } = tableConfig;
if (sOnShowInstruct) {
window.instructSetLock = false;
props.onExecInstructSet({
btnConfig: { sInstruct: sOnShowInstruct, showName: "页面初始化" }
});
}
},
[props.bFinish]
);
// 监听表格选中数据变化,根据变化,刷新指定表格
const selectedDataGroup = useGetSelectedDataGroup(props);
const selectedDataGroupBak = useRef({});
useEffect(
() => {
if (commonUtils.isEmptyObject(selectedDataGroup)) return;
let refreshTableListNew = [];
Object.keys(selectedDataGroup).forEach(tableName => {
const item = selectedDataGroup[tableName];
const { rowData, list, refreshFlagId } = item;
const itemBak = selectedDataGroupBak.current[tableName] || {};
const {
rowData: rowDataBak = {},
refreshFlagId: refreshFlagIdBak
} = itemBak;
if (
rowData.sId !== rowDataBak.sId ||
rowData.sSlaveId !== rowDataBak.sSlaveId ||
refreshFlagId != refreshFlagIdBak
) {
// 只有数据变化了才刷新对应表格
refreshTableListNew = [...refreshTableListNew, ...list];
}
});
selectedDataGroupBak.current = selectedDataGroup;
if (refreshTableListNew.length) {
props.onSaveState({ refreshTableList: refreshTableListNew });
}
},
[JSON.stringify(selectedDataGroup)]
);
// 如果是copyto,默认为编辑状态
useEffect(
() => {
if (!props.bFinish) return;
if (commonUtils.isEmptyObject(copyTo)) return;
const { masterConfig, sModelsId, masterData } = props;
const { btnConfig = {}, copyToConfig = [], record = {} } = props?.parentProps || {}
if (masterData && masterData.sBillNo) return
let masterDataCopyTo = {};
for (const key in copyTo) {
const tableData = copyTo[key];
if (tableData && !Array.isArray(tableData)) {
masterDataCopyTo = tableData;
}
}
const masterDataNew = {
...commonFunc.getDefaultData(masterConfig),
handleType: "add",
sId: commonUtils.createSid(),
sFormId: sModelsId,
...masterDataCopyTo
};
props.onSaveState({ masterData: masterDataNew, enabled: true, });
},
[props.bFinish]
);
const { gdsconfigformslave } = props?.slaveConfig || {}
useEffect(() => {
const { btnConfig = {}, copyToConfig = [], record = {} } = props?.parentProps || {};
// 提前校验
if (
!props.masterData ||
!props.masterData.sId ||
typeof props.masterData.sId !== 'string' ||
props.masterData.sId.trim() === '' ||
props.masterData.sBillNo ||
!Array.isArray(copyToConfig) ||
copyToConfig.length === 0
) {
return;
}
const { app } = props;
const { token } = app;
const addState = {};
let count = 0;
(async () => {
try {
for (const item of copyToConfig) {
if (!item?.sControlName) continue;
if (item.sControlName.includes('tmpInfoBySql')) {
if (count > 0) continue; // 跳过后续
count += 1;
const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfoBySql/?sModelsId=${sModelsId}`;
const sConfigformId = copyToConfig[0]?.sParentId || '';
const sControlName = commonUtils.isNotEmptyObject(item?.sControlName)
? item?.sControlName
: 'BtnTableCopyTo.tmpInfoBySqlActProduceReport';
const values = {
sConfigformId,
sControlName,
sRowData: [record],
};
const response = await commonServices.postValueService(token, values, dataUrl);
const dataReturn = response.data;
if (dataReturn.code === 1) {
const returnData = dataReturn.dataset?.rows?.[0];
if (commonUtils.isNotEmptyObject(returnData)) {
for (const key of Object.keys(returnData)) {
const data = returnData[key].map(x => {
x.sParentId = props.masterData.sId
x.sId = commonUtils.createSid()
x.handleType = "add"
return x
})
addState[`${key}Data`] = data;
}
}
} else {
props.getServiceError?.(dataReturn);
}
} else {
const nameList = item.sControlName.split('.');
if (nameList.length > 2) {
const name = nameList.pop();
addState[`${name}Data`] = [{
...commonFunc.getDefaultData(props[`${name}Config`]),
handleType: "add",
sId: commonUtils.createSid(),
sParentId: props.masterData.sId,
...commonFunc.getAssignFieldValue(item.sAssignField, record),
}];
}
}
}
if (Object.keys(addState).length > 0) {
props.onSaveState?.({ ...addState });
}
} catch (error) {
message.error('数据加载失败,请重试');
}
})();
}, [props.masterData]);
// 获取表头数据
const handleGetColumnData = (tableList = [], isWait) => {
let addState = {};
for (let i = 0; i < tableList.length; i++) {
const tableName = tableList[i];
const config = formData.find(item => item.sGrd === tableName);
if (!config) continue;
const column = commonFunc.getHeaderConfig(config);
addState = {
...addState,
[`${tableName}Column`]: column,
[`${tableName}Config`]: config
};
}
if (isWait) {
return addState;
} else {
props.onSaveState(addState);
}
};
// 获取数据集
const handleGetData = async (tableList = [], isWait, bInit) => {
let addState = {};
const currentIds = currentId ? currentId : props?.parentProps?.record?.sId
for (let i = 0; i < tableList.length; i++) {
const tableName = tableList[i];
const config = formData.find(item => item.sGrd === tableName);
if (!config || tableName.includes("FirstlineSelected")) continue;
const conditonValues = props.onGetSqlConditionValues(config);
let { [`${tableName}Filter`]: bFilter } = props;
// 初始化时,加上搜索按钮上iTag为1的条件
if (!bFilter && bInit) {
const initSearchConfig = config.gdsconfigformslave.find(
item =>
item.bVisible &&
item.sControlName?.includes("BtnRight") &&
item.iTag === 1 &&
[
"近2天",
"近两天",
"近7天",
"近七天",
"近一月",
"近三月",
"近半年",
"近一年"
].includes(item.showName.trim())
);
if (initSearchConfig) {
const { showName, sActiveKey } = initSearchConfig;
const tomorrowDate = moment()
.add(1, "days")
.format("YYYY-MM-DD");
let oneMonthAgo;
switch (showName.trim()) {
case "近2天":
case "近两天":
oneMonthAgo = moment()
.subtract(2, "days")
.format("YYYY-MM-DD");
break;
case "近7天":
case "近七天":
oneMonthAgo = moment()
.subtract(7, "days")
.format("YYYY-MM-DD");
break;
case "近一月":
oneMonthAgo = moment()
.subtract(1, "months")
.format("YYYY-MM-DD");
break;
case "近三月":
oneMonthAgo = moment()
.subtract(3, "months")
.format("YYYY-MM-DD");
break;
case "近半年":
oneMonthAgo = moment()
.subtract(6, "months")
.format("YYYY-MM-DD");
break;
case "近一年":
oneMonthAgo = moment()
.subtract(12, "months")
.format("YYYY-MM-DD");
break;
default:
break;
}
const searchFieldList = config.gdsconfigformslave.filter(
item => item.bVisible && item.bFind
);
const searchField = searchFieldList[0] || {};
bFilter = [
{
bFilterCondition: "between",
bFilterName: sActiveKey || searchField.sName,
bFilterValue: `${oneMonthAgo},${tomorrowDate}`
}
];
addState[`${tableName}SelectedBtn`] = showName.trim();
addState[`${tableName}Filter`] = bFilter;
}
}
// 行车记录新增时间、白夜班条件
if (config.sId === "12710101117087404588590") {
// 判断当前时间是否小于上午8点,如果是,则默认为昨天
const now = moment();
const today8AM = moment()
.hour(8)
.minute(0)
.second(0)
.millisecond(0);
const isBefore8AM = now.isSameOrBefore(today8AM);
const {
runningTime = isBefore8AM
? now.subtract(1, "days").format("YYYY-MM-DD")
: now.format("YYYY-MM-DD"),
runningShift = props.app?.userinfo?.sShift.toString()
} = props;
conditonValues.tCreateTime = runningTime;
conditonValues.sShiftNew = runningShift;
}
//【班组报工特殊处理】历史日报查看详情如果班组报工没查到数据,用sSReserve1当历史日报的sId
if (tableName === "tableS0" && props.sSReserve1) {
conditonValues.sSReserve1 = props.sSReserve1;
}
const masterState = {};
if (currentIds && tableName === 'master') {
masterState.sId = currentId;
}
if (currentIds && tableName !== 'master') {
conditonValues.sParentId = currentIds;
}
const result =
(await props.onGetDataSet({
name: tableName,
configData: config,
condition: {
...masterState,
sId: currentIds,
sSqlCondition: { ...conditonValues, ...sFilterConditions, },
bFilter
},
sModelTypes: props.parentProps,
isWait: true
})) || {};
props.setTempRef(result);
if (tableName?.includes("master")) {
const masterData = result[`${tableName}Data`];
result[`${tableName}Data`] = masterData?.[0] || {};
} else {
// 如果选中的数据不在返回的数据中,则清空选中数据
const { [`${tableName}Data`]: tableData = [] } = result;
const { [`${tableName}SelectedRowKeys`]: selectedRowKeys = [] } = props;
if (selectedRowKeys.length) {
const selectedRowKeysNew = selectedRowKeys.filter(item =>
tableData.some(rowData =>
[rowData.sId, rowData.sSlaveId].includes(item)
)
);
result[`${tableName}SelectedRowKeys`] = selectedRowKeysNew;
}
}
// 如果配置了默认选中第一行,则默认选中第一行,刷新数据集时配置NotFirstlineSelected则不刷新
let bNotFirstlineSelected =
tableList.findIndex(
item => item === `${tableName}NotFirstlineSelected`
) > -1;
if (!bNotFirstlineSelected) {
// 如果配置了默认选中第一行,则默认选中第一行
let bFirstlineSelected = config.gdsconfigformslave.find(
item => item.sControlName === "bFirstlineSelected" && item.bVisible
);
// 配置刷新数据时,配置 数据集名称+FirstlineSelected,默认选中首行数据。
if (!bFirstlineSelected) {
bFirstlineSelected =
tableList.findIndex(
item => item === `${tableName}FirstlineSelected`
) > -1;
}
if (bFirstlineSelected) {
if (commonUtils.isNotEmptyObject(result[`${tableName}Data`])) {
result[`${tableName}SelectedRowKeys`] = [
result[`${tableName}Data`][0].sId
];
result.triggerClickTableList = result.triggerClickTableList || [];
result.triggerClickTableList.push(tableName);
}
}
}
addState = { ...addState, ...result, };
if (tableName === "tableS0" && props.sSReserve1) {
addState.sSReserve1 = undefined;
}
}
props.setTempRef({}, true);
if (isWait) {
return addState;
} else {
props.onSaveState(addState);
}
};
// 刷新页面
const handleRefresh = () => {
setRefreshCount(refreshCount + 1);
};
// 刷新指定表格
const { refreshTableList = [], clearRowKeyList = [] } = props;
useEffect(
async () => {
if (!refreshTableList.length) return;
if (refreshTableList.includes("*")) {
props.onSaveState({ refreshTableList: [] }, () => {
handleRefresh();
});
return;
}
let addState = {
refreshTableList: [],
...(await handleGetData(refreshTableList, true))
};
// 清空选中行
if (clearRowKeyList.length) {
addState.clearRowKeyList = [];
clearRowKeyList.forEach(tableName => {
addState[`${tableName}SelectedRowKeys`] = [];
});
}
// 合并自定义列
addState = {
...addState,
...handleMergeCustomColumn(addState, refreshTableList)
};
//【班组报工特殊处理】历史日报查看详情如果班组报工没查到数据,用sSReserve1当历史日报的sId
if (
refreshTableList.length === 1 &&
refreshTableList[0] === "table0" &&
!addState.table0Data.length &&
props.sSReserve1
) {
addState.refreshTableList = ["tableS0"];
}
props.onSaveState(addState, nextProps => {
// 【特殊处理】行车记录修改时间后查询到空数据时,清空所有数据(历史日报tableS6除外)
const { runningStatusConditionFlag, table0Data = [] } = nextProps;
const addState = { runningStatusConditionFlag: undefined };
if (runningStatusConditionFlag && table0Data.length === 0) {
formData.forEach(item => {
const tableName = item.sGrd;
if (tableName && tableName !== "tableS6") {
addState[`${tableName}Data`] = [];
addState[`${tableName}SelectedRowKeys`] = [];
}
});
}
props.onSaveState(addState);
if (window.rowclickAfterFunc) {
window.rowclickAfterFunc(nextProps);
window.rowclickAfterFunc = null;
}
});
},
[refreshTableList.toString()]
);
// 通用过程执行后->刷新页面->执行剩余执行集
const { onDoInstructAfterProcedure } = props;
useEffect(
() => {
if (refreshTableList.length || !onDoInstructAfterProcedure) return;
props.onSaveState({ onDoInstructAfterProcedure: null }, () => {
setTimeout(() => {
onDoInstructAfterProcedure();
}, 200);
});
},
[refreshTableList]
);
// 默认选中第一行后触发点击事件
const { triggerClickTableList = [] } = props;
useEffect(
() => {
if (!triggerClickTableList.length) return;
triggerClickTableList.forEach(tablename => {
const { [`${tablename}SelectedRowKeys`]: selectedRowKeys } = props;
props.onTableSelectRowChange(tablename, selectedRowKeys);
});
props.onSaveState({
triggerClickTableList: []
});
},
[triggerClickTableList.length]
);
// 表格按钮事件
const handleTableBtnClick = params => {
props.onTableBtnClick({
...params,
onSuccess: () => {
handleRefresh();
}
});
};
// 更新机台状态
const handleUpdateProductionplan = async ({ item, iFlag }) => {
const { app } = props;
const { sId } = item?.record || {};
const { token } = app;
const url = `${commonConfig.server_host
}oee/updateProductionplan/${sId}/${iFlag}`;
const dataReturn = (await commonServices.getService(token, url)).data;
if (dataReturn.code === 1) {
handleRefresh();
} else {
message.error(dataReturn.msg);
}
};
// 开工事件
const handleStartWork = async params => {
const { sModelsId, token, app } = props;
const { name, record, config, iFlag } = params;
const { sAssignField } = config;
const allTableData = {
[name]: record
};
let rowData = commonFunc.getDefaultData(config, allTableData); // 取默认值
rowData = {
...rowData,
...commonFunc.getAssignFieldValue(sAssignField, record, allTableData),
handleType: "add",
sId: commonUtils.createSid(),
sTeamId: app.sTeamNameSId,
sMachineId: app.sMachineNameSId,
sParentId: record.sId,
tCreateDate: new Date()
};
const valuesNew = {};
valuesNew.data = [];
valuesNew.data.push(
commonBusiness.mergeData(name, "plc_machinedata", [rowData], [])
);
if ((iFlag || Object.is(iFlag, 0)) && valuesNew.data[0]) {
valuesNew.data[0].iFlag = iFlag;
}
const BtnSave = commonFunc.showMessage(
app.commonConst,
"BtnSave"
); /* 保存 */
params.optName = BtnSave;
params.sClientType = "1";
const returnData = await commonBusiness.saveData({
token,
value: valuesNew,
sModelsId,
bMachineTask: true
});
return returnData;
};
// 查看合版信息
const handleViewChoose = (name, sName, record) => {
const { sId } = record;
const { enabled, slaveData } = props;
let { packData } = props;
const handlePackDataAdd = (item, index, sControlId, handleType) => {
const tableDataRow = {};
if (handleType === "add") {
tableDataRow.sId = commonUtils.createSid();
tableDataRow.handleType = "add";
tableDataRow.sSlaveId = item.sId;
tableDataRow.iOrder = item.iOrder;
}
tableDataRow.sParentId = item.sParentId;
if (commonUtils.isNotEmptyObject(sControlId)) {
tableDataRow.sControlId = sControlId;
}
tableDataRow.sProductId = item.sProductId; /* 产品id */
tableDataRow.sCustomerId = item.sCustomerId; /* 客户id */
tableDataRow.sCustomerName = item.sCustomerName; /* 客户名称 */
tableDataRow.sProductName = item.sProductName; /* 产品名称 */
tableDataRow.sProductNo = item.sProductNo; /* 产品编号 */
/* 主表配置bProductQtyAdd 则代表产品数量不叠加备货数 赠送数 */
let bProductQtySelf = false;
if (
commonUtils.isNotEmptyObject(props.masterConfig) &&
commonUtils.isNotEmptyArr(props.masterConfig.gdsconfigformslave)
) {
const iIndex = props.masterConfig.gdsconfigformslave.findIndex(
item => item.sControlName === "bProductQtySelf"
);
if (iIndex > -1) {
bProductQtySelf = true;
}
}
if (bProductQtySelf) {
tableDataRow.dProductQty = commonUtils.isNull(item.dProductQty, 0);
} else {
tableDataRow.dProductQty =
commonUtils.isNull(item.dProductQty, 0) +
commonUtils.isNull(item.dGiveQty, 0) +
commonUtils.isNull(item.dStockupQty, 0); /* 生产数量 */
}
tableDataRow.sProductUnit = item.sProductUnit; /* 单位 */
tableDataRow.sProductStyle = item.sProductStyle; /* 产品规格 */
return tableDataRow;
};
if (name === "control" && sName === "sCombinedMemo") {
const packSelectedRowKeys = [];
/* 合并从表相同客户、产品数据 */
const slaveDataMerge = [];
slaveData.forEach(item => {
const iIndex = slaveDataMerge.findIndex(
child =>
child.sCustomerId === item.sCustomerId &&
child.sProductId === item.sProductId
);
if (iIndex === -1) {
const itemNew = JSON.parse(JSON.stringify(item));
slaveDataMerge.push(itemNew);
} else if (iIndex > -1) {
const dProductQtyNew =
commonUtils.isNull(slaveDataMerge[iIndex].dProductQty, 0) +
commonUtils.isNull(item.dProductQty, 0); /* 生产数量叠加 */
const dGiveQtyNew =
commonUtils.isNull(slaveDataMerge[iIndex].dGiveQty, 0) +
commonUtils.isNull(item.dGiveQty, 0); /* 赠送数量叠加 */
const dStockupQtyNew =
commonUtils.isNull(slaveDataMerge[iIndex].dStockupQty, 0) +
commonUtils.isNull(item.dStockupQty, 0); /* 备货数量叠加 */
slaveDataMerge[iIndex].dProductQty = dProductQtyNew;
slaveDataMerge[iIndex].dGiveQty = dGiveQtyNew;
slaveDataMerge[iIndex].dStockupQty = dStockupQtyNew;
}
});
/* 合并合版表相同客户、产品数据 */
const packDataMerge = [];
packData.forEach(item => {
const iIndex = packDataMerge.findIndex(
child =>
commonUtils.isNotEmptyObject(item.sCombinePartsName) &&
child.sCombinePartsName === item.sCombinePartsName &&
commonUtils.isNotEmptyObject(item.sProductId) &&
child.sProductId === item.sProductId
);
if (iIndex === -1) {
const itemNew = JSON.parse(JSON.stringify(item));
packDataMerge.push(itemNew);
} else if (iIndex > -1) {
const dProductQtyNew =
commonUtils.isNull(packDataMerge[iIndex].dProductQty, 0) +
commonUtils.isNull(item.dProductQty, 0); /* 生产数量叠加 */
const dGiveQtyNew =
commonUtils.isNull(packDataMerge[iIndex].dGiveQty, 0) +
commonUtils.isNull(item.dGiveQty, 0); /* 赠送数量叠加 */
const dStockupQtyNew =
commonUtils.isNull(packDataMerge[iIndex].dStockupQty, 0) +
commonUtils.isNull(item.dStockupQty, 0); /* 备货数量叠加 */
packDataMerge[iIndex].dProductQty = dProductQtyNew;
packDataMerge[iIndex].dGiveQty = dGiveQtyNew;
packDataMerge[iIndex].dStockupQty = dStockupQtyNew;
}
});
if (commonUtils.isNotEmptyArr(packDataMerge)) {
packData = packDataMerge;
}
/* 填充合版信息数值 如果packData为空,则填充从表所有数据 */
if (commonUtils.isNotEmptyArr(slaveDataMerge)) {
slaveDataMerge.forEach((item, index) => {
const packDataFilter = packData.filter(
itemNew =>
itemNew.sSlaveId === item.sId && itemNew.sControlId === sId
);
if (commonUtils.isNotEmptyArr(packDataFilter)) {
packDataFilter.forEach(itemPack => {
const iIndex = packData.findIndex(
child => child.sId === itemPack.sId
);
if (iIndex > -1) {
const packRowAdd = handlePackDataAdd(item);
if (commonUtils.isNotEmptyObject(packRowAdd)) {
packData[iIndex] = { ...packData[iIndex], ...packRowAdd };
if (
itemPack.dCombineQty !== undefined &&
itemPack.dCombineQty !== null &&
itemPack.dCombineQty !== 0
) {
packSelectedRowKeys.push(itemPack.sId);
}
}
}
});
} else {
const tableDataRow = handlePackDataAdd(
item,
index,
sId,
"add"
);
if (commonUtils.isNotEmptyObject(tableDataRow)) {
packData.push(tableDataRow);
}
}
});
}
props.onSaveState({
viewChooseVisible: true,
packSelectedRowKeys,
packData
});
} else if (name === "process" && sName === "sParams") {
props.onSaveState({
sWorkParamsModalVisible: true
});
}
};
const { sModelsId } = props;
let name;
if (sModelsId === "12710101117192328814280") {
name = "rwtable0";
} else if (sModelsId === "17086709360008036458897337633000") {
name = "table0";
}
useEffect(
() => {
if (
!name ||
!Array.isArray(props[`${name}Data`]) ||
!props[`${name}Data`]?.length
) {
return;
}
const globalData = commonUtils.convertStrToObj(
localStorage.xlybusinessglobalData
);
const { currentSelectedMachineTaskDataRow = {} } = globalData;
// 当前选中行sId,默认取缓存数据
let currentSelectedRowKey = props[`${name}SelectedRowKeys`]?.[0];
let rowValue = {};
if (currentSelectedRowKey) {
rowValue = props[`${name}Data`]?.find(
item => item && item.sId === currentSelectedRowKey
);
} else {
rowValue = props[`${name}Data`]?.find(
item => item && item.sId === currentSelectedMachineTaskDataRow?.sId
);
if (
rowValue &&
sModelsId === currentSelectedMachineTaskDataRow?.sModelsId
) {
currentSelectedRowKey = currentSelectedMachineTaskDataRow.sId;
} else {
currentSelectedRowKey = props[`${name}Data`][0]?.sId;
rowValue = props[`${name}Data`][0];
}
if (currentSelectedRowKey) {
props.onSaveState({
[`${name}SelectedRowKeys`]: [currentSelectedRowKey]
});
}
}
// 将当前选中行保存到全局
props.dispatch({
type: "app/saveGlobalData",
payload: {
currentSelectedMachineTaskDataRow: { ...(rowValue || {}), sModelsId }
}
});
},
[props[`${name}Data`], props[`${name}SelectedRowKeys`]]
);
// 审核
/** toolbar审核(消审) */
const handleAudit = async (flag) => {
/* 待用数据声明 */
let bResult = true;
const { masterData, gdsformconst } = props;
if (!commonUtils.isEmpty(masterData)) {
/* 作废订单不能审核 */
if (masterData.bInvalid) {
message.warning(commonFunc.showMessage(app.commonConst, 'sToVoid'));
props.onSaveState({
loading: false,
});
return '';
}
/** 数据审核 */
bResult = await dataAudit(flag);
} else {
props.onSaveState({
loading: false,
});
}
return bResult;
};
/** 数据审核 */
const dataAudit = async (flag, tmpCheck, isWait) => {
message.destroy();
/* 待用数据声明 */
const {
sModelsId, masterData, app, masterConfig, slaveConfig, checkConfig, token, sModelsType = '', controlConfig, materialsConfig, processConfig, colorConfig, packConfig, slaveData, orderDetailConfig,
} = props;
const FriendlyReminder = commonFunc.showLocalMessage(props, 'FriendlyReminder', '温馨提示');
const sSlaveIdArray = [];
if (commonUtils.isNotEmptyArr(slaveData)) {
slaveData.forEach((item) => {
sSlaveIdArray.push(commonUtils.isNotEmptyObject(item.sId) ? item.sId : item.sSlaveId);
});
}
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 {
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) { /* 成功 */
props.onSaveState({
loading: false,
});
handleRefresh()
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 (false && commonUtils.isNotEmptyStr(outData[0].sReturn)) {
const sReturnArray = outData[0].sReturn.split('|');
if (outData[0].sReturn.split('-').length < 2) {
// 正常业务提示,非审核模板
// if (props.app.currentPane.refresh !== undefined) {
// 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();
});
props.onSaveState({
checkConditions, checkPersonData, sCheckModelId, visible: true,
});
return true;
} else { /* 失败 */
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 (props.app.currentPane.refresh !== undefined) {
// props.app.currentPane.refresh();
// }
message.success(BtnCancelExamine + returnData.msg);
}
}
await handleGetData(masterConfig, slaveConfig, checkConfig);
if ((sModelsType.includes('sales/salesOrder') || sModelsType.includes('manufacture/workOrder')) && !commonUtils.isEmpty(controlConfig)) {
await handleGetMemoData(controlConfig, materialsConfig, processConfig, colorConfig, packConfig);
} else if (commonUtils.isNotEmptyObject(orderDetailConfig)) {
await handleGetOneMemoData('orderDetail', orderDetailConfig);
}
// if (props.app.currentPane.refresh !== undefined) {
// props.app.currentPane.refresh();
// }
} else if (returnData.code === -8) {
Modal.info({
title: FriendlyReminder,
content: (
{handleGetMsg(returnData.msg)}
),
onOk() { },
});
props.onSaveState({
loading: false,
});
return false;
} else { /* 失败 */
props.getServiceError(returnData);
props.onSaveState({
loading: false,
});
return false;
}
return true;
}
};
/**自定义按钮事件 */
const handleCostomChange = async (name, showConfig, other) => {
const {
app,
sModelsId,
[`${name}Data`]: tableData,
[`${name}SelectedRowKeys`]: tableSelectedRowKeys,
masterData,
slave1Child0Config,
slave2Child0Config,
slave2Child0InfoConfig,
slave6Child1Config,
slave6Child1InfoConfig,
} = props;
const confirmSetting = commonFunc.showLocalMessage(props, 'confirmSetting', '请配置按钮的存储过程');
const confirmSettingParam = commonFunc.showLocalMessage(props, 'confirmSettingParam', '请先操作参数运算');
const iIndex =
commonUtils.isNotEmptyObject(tableSelectedRowKeys) &&
commonUtils.isNotEmptyArr(tableData)
? tableData.findIndex(item => tableSelectedRowKeys.includes(item.sId))
: -1;
let slaveRow = {};
if (iIndex > -1) {
slaveRow = tableData[iIndex];
} else if (commonUtils.isNotEmptyArr(tableData) && tableData.length > 0) {
slaveRow = tableData[0];
}
if (
commonUtils.isNotEmptyObject(showConfig) &&
showConfig.sControlName &&
showConfig.sControlName.includes("BtnCustom.dSplitworkQty")
) {
if (masterData.bFirstCalc !== 1) {
message.error(confirmSettingParam);
return;
}
props.onSaveState({ pageLoading: true });
/* 拆分工单单据 - 拆分工单 生成工单 */
const sButtonParam = showConfig.sButtonParam;
if (
commonUtils.isNotEmptyObject(sButtonParam) &&
commonUtils.isJSON(sButtonParam)
) {
const proObj = JSON.parse(sButtonParam);
const proName = proObj.sproName;
const sRowData = slaveRow;
const value = {
sProName: proName,
sProInParam: JSON.stringify({ params: sRowData })
};
if (other?.iFlag === 1) {
value.iFlag = 1;
}
const url = `${commonConfig.server_host
}procedureCall/doGenericProcedureCall?sModelsId=${sModelsId}`;
const returnData = (await commonServices.postValueService(
app.token,
value,
url
)).data;
if (returnData.code === 1) {
message.success(returnData.msg);
props.onSaveState({ pageLoading: false });
const conditonValues = props.onGetSqlConditionValues(slave1Child0Config);
const addState1 = await props.handleGetDataSet({
name: 'slave1Child0', configData: slave1Child0Config, condition: { sSqlCondition: { ...conditonValues, sParentId: masterData.sId } }, isWait: true,
});
props.onSaveState({
...addState1
});
} else {
props.onSaveState({ pageLoading: false });
props.getServiceError({
...returnData,
fn: () => handleCostomChange(name, showConfig, { iFlag: 1 })
});
}
} else {
message.error(confirmSetting);
}
} else if (
commonUtils.isNotEmptyObject(showConfig) &&
showConfig.sControlName &&
(showConfig.sControlName.includes("BtnCustom.tEstimateCompletDate") ||
showConfig.sControlName.includes("BtnCustom.tRecalculatedDate"))
) {
/* 单生管评审单据 - 生管评审 - 交期推算 */
const {
app,
sModelsId,
[`${name}Data`]: tableData,
slaveSelectedRowKeys: tableSelectedRowKeys
} = props;
const index =
commonUtils.isNotEmptyObject(tableSelectedRowKeys) &&
commonUtils.isNotEmptyArr(tableData)
? tableData.findIndex(item => tableSelectedRowKeys.includes(item.sId))
: -1;
slaveRow = index > -1 ? tableData[index] : slaveRow;
const controlRow = handleGetSelectedData(props, 'slave0Child1'); /* 控制表当前选中行 */
const sButtonParam = showConfig.sButtonParam;
if (
commonUtils.isNotEmptyObject(sButtonParam) &&
commonUtils.isJSON(sButtonParam)
) {
const proObj = JSON.parse(sButtonParam);
const proName = proObj.sproName;
let sRowData = slaveRow;
//取第一条BOM的id
sRowData = { ...sRowData, sBomId: tableData[0].sBomId };
const value = {
sProName: proName,
sProInParam: JSON.stringify({ params: sRowData, control: controlRow })
};
if (other?.iFlag === 1) {
value.iFlag = 1;
}
const url = `${commonConfig.server_host
}procedureCall/doGenericProcedureCall?sModelsId=${sModelsId}`;
const returnData = (await commonServices.postValueService(
app.token,
value,
url
)).data;
if (returnData.code === 1) {
message.success(returnData.msg);
if (showConfig.sControlName.includes("BtnCustom.tEstimateCompletDate")) {
const conditonValues1 = props.onGetSqlConditionValues(slave2Child0Config);
const addState1 = await props.handleGetDataSet({
name: 'slave2Child0', configData: slave2Child0Config, condition: { sSqlCondition: { ...conditonValues1, sParentId: masterData.sId } }, isWait: true,
});
const conditonValues2 = props.onGetSqlConditionValues(slave2Child0InfoConfig);
const addState2 = await props.handleGetDataSet({
name: 'slave2Child0Info', configData: slave2Child0InfoConfig, condition: { sSqlCondition: { ...conditonValues2, sParentId: masterData.sId } }, isWait: true,
});
tableData[index].handleType = commonUtils.isEmpty(tableData[index].handleType) ? "update" : tableData[index].handleType;
tableData[index].tEstimateCompletDate = returnData.dataset?.rows[0].dataSet?.proData[0].tEstimateCompletDate;
props.onSaveState({
...addState1, ...addState2,
});
} else if (showConfig.sControlName.includes("BtnCustom.tRecalculatedDate")) {
const conditonValues1 = props.onGetSqlConditionValues(slave6Child1Config);
const addState1 = await props.handleGetDataSet({
name: 'slave6Child1', configData: slave6Child1Config, condition: { sSqlCondition: { ...conditonValues1, sParentId: masterData.sId } }, isWait: true,
});
const conditonValues2 = props.onGetSqlConditionValues(slave6Child1InfoConfig);
const addState2 = await props.handleGetDataSet({
name: 'slave6Child1Info', configData: slave6Child1InfoConfig, condition: { sSqlCondition: { ...conditonValues2, sParentId: masterData.sId } }, isWait: true,
});
tableData[index].handleType = commonUtils.isEmpty(tableData[index].handleType) ? "update" : tableData[index].handleType;
tableData[index].tRecalculatedDate = returnData.dataset?.rows[0].dataSet?.proData[0].tRecalculatedDate;
props.onSaveState({
...addState1, ...addState2, [`${name}Data`]: tableData
});
}
} else {
props.getServiceError({
...returnData,
fn: () => handleCostomChange(name, showConfig, { iFlag: 1 })
});
}
} else {
message.error(confirmSetting);
}
}
};
return {
...props,
onGetColumnData: handleGetColumnData,
onRefresh: handleRefresh, // 刷新页面
onTableBtnClick: handleTableBtnClick, // 表格按钮事件
handleUpdateProductionplan,
handleStartWork,
onViewChoose: handleViewChoose,
onBtnExamine: handleAudit,
onBtnCancelExamine: handleAudit,
onCostomChange: handleCostomChange
};
};
/* 解析消息 */
const handleGetMsg = (str) => {
const msgArr = commonUtils.isNotEmptyObject(str) ? str.split('xpm') : '';
const divStr = [];
if (commonUtils.isNotEmptyArr(msgArr)) {
for (let i = 0; i < msgArr.length; i++) {
divStr.push({msgArr[i]}
);
}
}
return divStr;
}
// 计算commonDiv高度
const useComputedCommonDivHeight = props => {
let returnHeight = "calc(100% - 20px)";
const { sTabName, showType, sName, bHideTitle } = props;
const { [`${sName}Config`]: config = {} } = props;
// 是否有按钮栏
const bHasOperationBar =
sName !== "palletBatchMaterial" &&
config.gdsconfigformslave?.some(
item =>
item.bVisible &&
(item.sControlName?.includes("BtnRight") ||
item.sControlName?.includes("BtnLeft") ||
item.bFind)
);
if (bHasOperationBar) {
returnHeight = `calc(${returnHeight} - 40px)`;
}
// 如果有标题
if (sTabName && !bHideTitle) {
returnHeight = `calc(${returnHeight} - 40px)`;
}
// 如果是报工任务
if (
config.sId === "12710101117087404588590" ||
config.sId === "12710101117260270570600"
) {
returnHeight = `calc(${returnHeight} - 40px)`;
}
return returnHeight;
};
// 获取跟sSqlCondition有关的选中的数据
const useGetSelectedDataGroup = props => {
// 获取页面加载的所有表名
const { tableList = [] } = props;
// 获取所有表格配置中有sSqlCondition的配置
const [sSqlConditionGroup, setSSqlConditionGroup] = useState({});
useEffect(
() => {
if (!tableList.length) return;
const temp = tableList
.map(tableName => {
const { [`${tableName}Config`]: config = {} } = props;
const { sSqlCondition } = config;
return sSqlCondition
? {
tableName,
sSqlCondition
}
: null;
})
.filter(item => item)
.reduce((result, item) => {
const { tableName, sSqlCondition } = item;
const sSqlConditionList = sSqlCondition.split(",");
sSqlConditionList.forEach(condition => {
const [tbName] = condition.split(".");
if (tableList.includes(tbName)) {
if (!result[tbName]) {
result[tbName] = [];
}
if (!result[tbName].includes(tableName)) {
result[tbName].push(tableName);
}
}
});
return result;
}, {});
setSSqlConditionGroup(temp);
},
[tableList.length]
);
const selectedDataGroup = Object.keys(sSqlConditionGroup).reduce(
(result, tableName) => {
const {
[`${tableName}Data`]: tableData = [],
[`${tableName}SelectedRowKeys`]: selectedRowKeys = []
} = props;
if (tableName !== 'master' && selectedRowKeys.length) {
const rowData = tableData.find(
item =>
selectedRowKeys.includes(item.sId) ||
selectedRowKeys.includes(item.sSlaveId)
);
if (rowData) {
result[tableName] = { rowData, list: sSqlConditionGroup[tableName] };
if (props.selectedDataGroupFlagList?.[tableName]) {
result[tableName].refreshFlagId =
props.selectedDataGroupFlagList[tableName];
}
}
}
return result;
},
{}
);
return selectedDataGroup;
};
// 主入口
const CommonModel = baseProps => {
const props = baseProps.costomModal
? useCommonModelEvent(baseProps)
: useCommonModelEvent(useCommonBase(baseProps));
const { bFinish } = props;
if (!bFinish) return "";
const { tabConfig = [] } = props;
if (props.sModelsId === "12710101117191104477380") {
return ;
}
return (
<>
>
);
};
const CommonModelComponent = props => {
const { tabConfig = [], level, modelStyle, app, bMesBill, enabled, masterData, sModelsType } = props;
const { userinfo } = app;
const sLanguage = userinfo.sLanguage;
const getComponent = (config, index = 0) => {
const {
sName,
sTabName,
showType,
defaultEnabled,
bHideTitle,
tableBtnsConfig,
children = []
} = config;
if (showType === "none") {
if (!children.length) return "";
const footerComponent = useFooterComponent({ ...props, sTabName });
const modelStyle = footerComponent ? { height: "calc(100% - 50px)" } : {};
return (
<>
{footerComponent}
>
);
} else if (showType === "costom") {
return ;
} else {
let componentProps = {
...props,
showType, // 展示类型(表单/表格)
enabled: !bMesBill ? defaultEnabled : enabled, // 是否可编辑
sTabName, // 标题名称
sName, // 配置对应的sGrd
bHideTitle, //隐藏标题
tableBtnsConfig, // 表格按钮配置
bFirstComponent: level === 0 && index === -1
};
const commonDivHeight = useComputedCommonDivHeight(componentProps);
return (
);
}
};
const extraStyle = {};
if (bMesBill) {
extraStyle.display = 'flex';
extraStyle.flexDirection = 'column';
extraStyle.paddingTop = 5;
}
const { sModelsId } = props;
const isNotTab = sModelsId === '12710101117119423319470'
return (
<>
{tabConfig.map(item => {
const {
configList = [],
sEntireTabName,
sEnglishEntireTabName,
sBig5EntireTabName,
mode,
width = "100%",
height = "100%"
} = item;
const sEntireTabNameNew = sLanguage === 'sEnglish' ? sEnglishEntireTabName :
sLanguage === 'sBig5EntireTabName' ? sBig5EntireTabName : sEntireTabName;
const advancedStyle =
mode === "advanced"
? {
float: "left",
width,
height: height.startsWith("costomHeight")
? height.split(",")[1]
: height
}
: { width: "100%", height: "100%" };
// 产量上报信息特殊处理
if (advancedStyle.height === "calc(100% - 370px)") {
advancedStyle.overflowX = "hidden";
advancedStyle.overflowY = "auto";
}
// advancedStyle.border = "1px solid green";
// { width: "100%", height: level === 0 ? "100%" : "auto" }
if (configList.length === 1 && configList[0].showType !== "none") {
if (
[
"维修申请记录",
"设备维修记录",
"设备点检记录",
"设备点检明细",
"设备资料"
].includes(configList[0].sTabName)
) {
advancedStyle.width = "calc(100% - 300px)";
advancedStyle.height = ["设备维修记录", "设备点检明细"].includes(
configList[0].sTabName
)
? "calc(100% - 350px)"
: 350;
advancedStyle.float = "left";
const equipmentRepairProps = {
...props,
sTabName: configList[0].sTabName
};
return (
<>
{getComponent(configList[0], -1)}
>
);
}
return (
{getComponent(configList[0], -1)}
);
} else {
return (
{sEntireTabName && (
)}
{
!isNotTab ?
{
if (window.refreshTableList) {
props.onSaveState({
refreshTableList: window.refreshTableList
});
window.refreshTableList = null;
}
}}
>
{configList
.filter(
item =>
!props.hideTabList ||
!props.hideTabList.includes(item.sName)
)
.map((config, index) => {
const { sName, sEnglishTabName, sBig5TabName, sTabName } = config;
const sTabNewName = sLanguage === 'sEnglish' ? sEnglishTabName : sLanguage === 'sBig5' ?
sBig5TabName : sTabName;
let disabled = false;
if (sTabName === "拼接列表" && sName === "slaveWypj3") {
// 特殊处理:拼接详情可保存时,拼接列表tab不可点击
disabled =
props.slaveWypj2Data?.[0]?.bSave === false ||
props.slaveWypj2Data?.[0]?.bSave === 0;
} else if (
(sTabName === "复卷成品检验列表" &&
sName === "salveWydm3") ||
(sTabName === "卷盘明细" && sName === "salveWydm4")
) {
// 特殊处理:复卷成品检验详情可保存时,复卷成品检验列表/卷盘明细tab不可点击
disabled =
props.salveWydm2Data?.[0]?.bSave === false ||
props.salveWydm2Data?.[0]?.bSave === 0;
} else if (
sTabName === "成品批次列表" &&
sName === "salveWybz3"
) {
// 特殊处理:成品批次详情可保存时,成品批次列表列表tab不可点击
disabled =
props.salveWybz2Data?.[0]?.bSave === false ||
props.salveWybz2Data?.[0]?.bSave === 0;
}
return (
{getComponent(config, index)}
);
})}
:
{
(() => {
const visibleConfigs = configList.filter(
item =>
!props.hideTabList ||
!props.hideTabList.includes(item.sName)
);
const first = visibleConfigs[0];
const secondAndThird = visibleConfigs.slice(1, 3); // 索引 1 和 2
const rest = visibleConfigs.slice(3);
return (
<>
{/* 第一个单独一行 */}
{first && (
{renderConfig(first, 0)}
)}
{/* 第二和第三放一行 */}
{secondAndThird.length > 0 && (
{secondAndThird.map((config, idx) => {
const indexInOriginal = idx + 1; // 原始索引:1, 2
return (
{renderConfig(config, indexInOriginal)}
);
})}
)}
{/* 剩下的每个占一行 */}
{rest.map((config, idx) => {
const originalIndex = idx + 3;
return (
{renderConfig(config, originalIndex)}
);
})}
>
);
// 提取公共逻辑,避免重复
function renderConfig(config, index) {
const { sName, sEnglishTabName, sBig5TabName, sTabName } = config;
let disabled = false;
if (sTabName === '拼接列表' && sName === 'slaveWypj3') {
disabled =
props.slaveWypj2Data?.[0]?.bSave === false ||
props.slaveWypj2Data?.[0]?.bSave === 0;
} else if (
(sTabName === '复卷成品检验列表' && sName === 'salveWydm3') ||
(sTabName === '卷盘明细' && sName === 'salveWydm4')
) {
disabled =
props.salveWydm2Data?.[0]?.bSave === false ||
props.salveWydm2Data?.[0]?.bSave === 0;
} else if (sTabName === '成品批次列表' && sName === 'salveWybz3') {
disabled =
props.salveWybz2Data?.[0]?.bSave === false ||
props.salveWybz2Data?.[0]?.bSave === 0;
}
return getComponent(config, index);
}
})()
}
}
);
}
})}
>
);
};
// 通用标题
const TabTitleComponent = props => {
const { sTabName, bHideTitle, bFirstComponent } = props;
if (!sTabName || bHideTitle) {
if (!bFirstComponent) {
return "";
} else {
return ;
}
}
if (sTabName.split("_")[0] === "空") return "";
const costomTitle =
props.costomTitle && sTabName === "下料信息" ? props.costomTitle : "";
return (
{sTabName}
{costomTitle}
);
};
// 表单组件
const CommonViewTableComponent = props => {
const { sTabName = "", showType, sName } = props;
if (showType !== "form") return "";
const {
[`${sName}Config`]: configOld = {},
[`${sName}Data`]: data = {},
[`${sName}SelectedRowKeys`]: selectedRowKeys = []
} = props;
const config = props.onMergeTableConfig(configOld);
const { gdsconfigformslave: gdsconfigformslaveOld = [] } = config;
const gdsconfigformslave = cloneDeep(gdsconfigformslaveOld);
// 展示的数据
let viewRow = {};
const dataArr = Array.isArray(data) ? data : [data];
if (selectedRowKeys.length) {
viewRow = dataArr.find(item => item.sId === selectedRowKeys[0]);
}
if (sTabName?.startsWith("第") && sTabName?.endsWith("转")) {
viewRow = data.filter(item => item.sRev === sTabName)[0];
}
if (commonUtils.isEmptyObject(viewRow)) {
viewRow = Array.isArray(data) ? data[0] || {} : data;
}
if (
commonUtils.isNotEmptyObject(viewRow) &&
!selectedRowKeys[0] &&
viewRow.sId
) {
props.onSaveState({ [`${sName}SelectedRowKeys`]: [viewRow.sId] });
}
// 班组报工-产量上班信息【特殊处理】(取默认值)
if (
config.sId === "17087428780006438414984564455000" &&
commonUtils.isNotEmptyObject(viewRow) &&
!viewRow.tempDefaultFlag
) {
const allTableData = commonFunc.getAllTableData(props);
const viewRowDefault = commonFunc.getDefaultData(config, allTableData);
Object.keys(viewRowDefault).forEach(key => {
const value = viewRowDefault[key];
if (!viewRow[key]) {
viewRow[key] = value;
}
});
props.onSaveState({
[`${sName}Data`]: [{ ...viewRow, tempDefaultFlag: true }]
});
}
// 加载第定义表单配置
if (viewRow.sColumnConfig) {
const columnconfig = commonUtils.convertStrToObj(viewRow.sColumnConfig, []);
if (commonUtils.isNotEmptyArr(columnconfig)) {
gdsconfigformslave.forEach(item => {
const iIndex = columnconfig.findIndex(
i => i.sId === item.sId || i.sName === item.sName
);
if (iIndex !== -1) {
Object.keys(columnconfig[iIndex]).forEach(key => {
item[key] = columnconfig[iIndex][key];
});
}
});
}
}
const groupList = sTabName.split(",");
const viewConfigsList = groupList.map((tabName, index) => {
if (tabName === "隐藏") {
return [];
}
if (index === 0) {
return gdsconfigformslave.filter(
item =>
item.sName &&
item.bVisible &&
item.sControlName.indexOf("Btn") === -1 &&
item.sControlName.indexOf("_") === -1
);
} else {
return gdsconfigformslave.filter(
item =>
item.sName &&
item.bControl &&
item.sControlName.indexOf(`${tabName}_`) !== -1
);
}
});
const operationBarProps = {
...props,
sName,
belongsToForm: true,
};
const { masterData, sModelsType, app } = props
const { bCheck = false } = masterData || {}
const imgSrc = commonBusiness.handleAddIcon(masterData, sModelsType, app);
return (
<>
{sName === "master" ? (
) : (
""
)}
{viewConfigsList.map((viewConfigs, index) => {
if (!viewConfigs.length) return "";
const viewProps = {
...props,
viewConfigs,
tableConfig: config,
iColValueView: 24,
viewRow,
tableName: sName
};
if (commonUtils.isEmptyObject(viewRow)) {
viewProps.enabledNew = false;
}
console.log(viewProps, 'viewProps');
return (
<>
>
);
})}
{sName !== "master" ? (
) : (
""
)}
{
bCheck ? : ''
}
>
);
};
// 表格组件
const CommonTableComponent = props => {
const [SWasteTypeIsModalOpen, setSWasteTypeIsModalOpen] = useState(false);
const [SWasteTypeConfig, setSWasteTypeConfig] = useState({});
const [SWasteTypeName, setSWasteTypeName] = useState();
const {
sTabName,
showType,
sName,
tableBtnsConfig: tableBtnsConfigOld = []
} = props;
if (showType !== "table") return "";
if (
(sTabName === "故障率分析图" && sName === "table3") ||
(sTabName === "设备信息" && sName === "table4") ||
(sTabName === "设备信息" && sName === "elemachine") ||
(sTabName === "点检故障率分析" && sName === "spotcheckanalyze") ||
(sTabName === "设备信息" && sName === "deviceinfo")
) {
return "";
}
const {
[`${sName}Config`]: config = {},
[`${sName}Data`]: data = [{}]
} = props;
const { gdsconfigformslave = [] } = config;
let tableBtnsConfig = tableBtnsConfigOld.filter(item => item.sControlName);
let btnsConfig = [];
gdsconfigformslave.forEach(item => {
if (item.bVisible && item.sControlName) {
const tempConfig = tableBtnsConfig.find(
tConfig => item.sControlName === tConfig.sControlName
);
if (tempConfig) {
btnsConfig.push({ ...item, ...tempConfig });
}
}
});
btnsConfig =
costomPageFun({
props: { ...props, btnsConfig },
tableName: sName,
actionName: "mesGetBtnsConfig"
}) || btnsConfig;
const baseProps = commonBusiness.getTableTypes(sName, props);
if (sName === "table0" || sName === "slave") {
baseProps.allowClear = false;
}
// 过滤数据
if (props.onFilterData) {
baseProps.data = props.onFilterData(sName, baseProps.data);
}
// 表格是否可编辑自定义规则
if (props.onTableEnabled) {
const enabledNew = props.onTableEnabled(sName, baseProps.data);
if (enabledNew !== undefined) {
baseProps.enabled = enabledNew;
}
}
// 分切轮数特殊处理
if (sName === "slaveWyfq2" && props.currentSelectedStep) {
baseProps.key = `slaveWyfq2_${props.currentSelectedStep}`;
const { slaveWyfq2SelectedRowKeys = [] } = props;
if (
baseProps.data?.length &&
!baseProps.data.some(item => item.sId === slaveWyfq2SelectedRowKeys[0])
) {
props.onSaveState({ slaveWyfq2SelectedRowKeys: [baseProps.data[0].sId] });
}
}
const itemClickRef = useRef();
// 开工、暂停事件
const handleTableBtnClick = async item => {
const { record, tableData } = item;
const { iStar, bOKStartWorking } = record;
if (iStar === 1) {
// 如果只剩一条数据,询问是暂停还是完工
if (tableData.length === 1) {
const result = await new Promise(resolve => {
Modal.confirm({
title: "温馨提示:",
content: 请选择要变更的状态
,
okText: "完工",
cancelText: "暂停",
onOk() {
resolve(true);
},
onCancel() {
resolve(false);
}
});
});
if (result) {
// 走完工接口
props.handleUpdateProductionplan({ item, iFlag: 4 });
return;
}
}
// 开工中,走暂停接口
props.handleUpdateProductionplan({ item, iFlag: 3 });
} else if (iStar === 2 || iStar === 3 || iStar === 4) {
// 暂停中,走开工、完工接口
if (bOKStartWorking === 1) {
return message.error("存在开工任务,无法恢复生产", 3);
}
const dataReturn = await props.handleStartWork(item);
const { code, msg } = dataReturn;
if (code === 1) {
// 成功开工
itemClickRef.current = null;
message.success(dataReturn.msg);
if (props.taskConfirmModalVisible) {
props.onSaveState({
taskConfirmModalVisible: false,
taskConfirmModalMsg: "",
tempTaskId: ""
});
}
props.onChangeRouter({
type: "name",
path: ["生产执行", "生产执行"]
});
} else if (code === -7) {
// 如果有开工中的任务,即接口返回-7,弹出确认窗体
itemClickRef.current = { data: item };
props.onSaveState({
taskConfirmModalVisible: true,
taskConfirmModalMsg: msg,
tempTaskId: record.sId
});
} else {
// 报错
message.error(msg);
}
}
};
const onTableBtnClick = params => {
const { config = {}, name, nextProps } = params;
const { sName: sName1 = "" } = config;
if (
sName1 === "sWasteType" ||
(name === "slaveWytf1" && ["sOperatorMemo", "sQcMemo"].includes(sName1))
) {
setSWasteTypeConfig(config);
setSWasteTypeName(name);
setSWasteTypeIsModalOpen(true);
return;
}
if (
costomPageFun({
props: { ...props, params, ...nextProps },
tableName: sName,
actionName: "mesTableBtnClick"
})
) {
return;
}
// if (['BtnTable.Recover'].includes(params?.config?.sControlName)) {
// // 开工
// handleTableBtnClick({ ...params });
// return;
// }
props.onTableBtnClick(params);
};
const tableProps = {
...baseProps,
tableBtnsConfig: btnsConfig,
// tableBtnsWidth: '100px',
// tableBtnsConfig: (params) => {
// console.log('=====params', params);
// return btnsConfig;
// },
onTableBtnClick,
tableProps: {
onChange: () => { },
rowKey: baseProps?.config?.sId === "17091154460006421964039036672000" ? 'sSlaveId' : 'sId'
// AutoTableHeight: 200
},
onViewClick: (tableName, sFieldName, record, index, config) => {
// 异常事件提报-提报信息-事件类型字段点击事件
if (tableName === "slave" && sFieldName === "sClassifyName") {
props.onTableBtnClick({
name: tableName,
record,
config
});
}
},
onViewChoose: (tableName, sFieldName, record, index, isColor) => {
handleViewChoose(tableName, sFieldName, record, index, isColor);
}
};
const handleViewChoose = (tableName, sFieldName, record, index, isColor) => {
if (isColor) {
const { sId } = record; /* 控制表主键 */
const { enabled, processSelectedRowKeys } = props;
const NoProcessParameters = commonFunc.showLocalMessage(props, 'NoProcessParameters', '无工艺参数!');
const sisColorSelectedRowKeys = [];
let jsonData = [];
const { [`${tableName}Data`]: tableData } = props;
const iIndex = tableData?.findIndex(item => item.sId === sId);
if (iIndex > -1) {
const sPositiveColor = tableData[iIndex][sFieldName];
const sPositiveColorList = (sPositiveColor && sPositiveColor !== 'undefined' && sPositiveColor !== 'null')
? JSON.parse(sPositiveColor)
: [];
props.onSaveState({
sisColorChooseVisible: true,
controlSelectedRowId: sId, /* 控制表选中行sId */
processSelectedRowId: '', /* 工序表选中行sId */
sisColorSelectedRowKeys,
sisColorSelectedData: sPositiveColorList,
sisColorField: sFieldName,
sisTableName: tableName,
});
}
}
}
const stepName = sTabName?.split("_")[1] || "";
if (stepName.startsWith("第") && stepName.endsWith("转")) {
tableProps.data = tableProps.data.filter(item => item.sRev === stepName);
}
if (props.onDataFilter) {
}
// if (props.sTabName === "异常事件提报明细") {
// tableProps.fixedHeight = "calc(100vh - 420px)";
// } else if (props.sTabName === "报工任务") {
// tableProps.fixedHeight = "calc(100vh - 420px)";
// }
const operationBarProps = {
...props,
sName
};
useEffect(() => {
if (commonUtils.isEmptyObject(props.masterData)) return;
if (tableProps.data && tableProps.data.length === 0) {
const bEmptyAddLine = tableProps.config.gdsconfigformslave.find(x => x.sControlName.includes('bEmptyAddLine'))
if ((commonUtils.isNotEmptyObject(bEmptyAddLine) && bEmptyAddLine.bVisible)) {
props.onMesTableLineAdd({
tableName: tableProps.name,
})
}
}
}, [props.masterData])
console.log('tableProps', tableProps);
return (
<>
>
);
};
// repair弹窗
const CommonRepairComponent = props => {
const modalName = "commonRepairModal";
const { [`${modalName}Params`]: params = {} } = props;
const {
visible,
title,
tableName,
config,
filterConfig,
record = {},
callback,
confirmBtnName = "确认",
enabled = true,
width = 600,
height = "auto",
style = {
padding: 0,
top: "30%"
}
} = params;
if (!visible) return "";
const [viewRow, setViewRow] = useState(record);
const oBoxImg = useRef(null);
const onCancel = () => {
oBoxImg.current && document.body.removeChild(oBoxImg.current);
callback && callback(false);
props.onSaveState({
[`${modalName}Params`]: {}
});
props.onRefresh()
};
const onOk = () => {
for (const config of filterConfig) {
if (config.bNotEmpty && commonUtils.isEmpty(viewRow[config.sName])) {
message.error(`${config.showName}为必填项`);
return;
}
}
oBoxImg.current && document.body.removeChild(oBoxImg.current);
callback && callback(viewRow);
props.onSaveState({
[`${modalName}Params`]: {}
});
};
const viewProps = {
...props,
enabled,
viewConfigs: filterConfig.map(item => ({ ...item, iColValue: 24 })),
tableConfig: config,
iColValueView: 24,
viewRow,
tableName,
onDataChange: (...args) => {
const [, sFieldName, value] = args;
setViewRow(pre => ({
...pre,
[sFieldName]: value[sFieldName],
...value
}));
},
delayComputed: true
};
let bCenter = false;
if (title === "异常信息") {
style.top = "auto";
style.left = -500;
style.margin = 0;
bCenter = true;
}
useEffect(
() => {
if (visible && title === "异常信息") {
oBoxImg.current = document.createElement("div");
oBoxImg.current.className = styles.boxImg;
// oBoxImg.current.innerHTML = "盒形图";
const url =
"/data/tools/xlyerpfiles/tempPath/240606/12710101117176455089290_Image_1717645454288.png";
const fileUrl = `${commonConfig.file_host
}file/download?savePathStr=${encodeURIComponent(
url
)}&sModelsId=100&token=${props.app.token}`;
const oImg = document.createElement("img");
oImg.src = fileUrl;
oBoxImg.current.appendChild(oImg);
document.body.appendChild(oBoxImg.current);
}
},
[visible]
);
return (
}
onCancel={onCancel}
>
);
};
// (定制功能)班组报工-日报报工按钮用
const useFooterComponent = props => {
const { formData = [], sTabName } = props;
if (sTabName !== "班组报工") return "";
let filterGds = [];
formData.forEach(item => {
const { gdsconfigformslave = [] } = item;
filterGds = [
...filterGds,
...gdsconfigformslave
.filter(
item => item.bVisible && item.sControlName.includes("BtnModelFooter.")
)
.map(item => ({
...item,
sControlName: item.sControlName.replace(
"BtnModelFooter.",
"BtnRight."
)
}))
];
});
if (!filterGds.length) return "";
const footerConfig = { gdsconfigformslave: filterGds };
const operationBarProps = {
...props,
bCostom: true,
sName: "sFooter",
sFooterConfig: footerConfig
};
const footerDiv = (
);
return footerDiv;
};
// (定制功能)行车记录 条件
const RunningStatusConditionComponent = props => {
const { sTabName, sModelsId } = props;
if (sModelsId !== "12710101117087404588200" || sTabName !== "报工任务")
return "";
const { app } = props;
const { userinfo } = app;
const { sShift = "" } = userinfo;
const options = [
{ label: "数据核查", value: "1" }
// { label: "白班", value: "1" },
// { label: "夜班", value: "2" }
];
const { runningTime, runningShift = sShift.toString() } = props;
const [value, setValue] = useState(runningShift);
// 判断当前时间是否小于上午8点,如果是,则默认为昨天
const now = moment();
const today8AM = moment()
.hour(8)
.minute(0)
.second(0)
.millisecond(0);
const isBefore8AM = now.isSameOrBefore(today8AM);
const [dateValue, setDateValue] = useState(
runningTime
? moment(runningTime)
: isBefore8AM
? now.subtract(1, "days")
: now
);
const flag = useRef(false);
useEffect(
() => {
if (flag.current) {
flag.current = false;
props.onSaveState({
runningTime: dateValue.format("YYYY-MM-DD"),
runningShift: value,
refreshTableList: ["table0"],
runningStatusConditionFlag: true // 行车记录修改时间标记
});
}
},
[value, dateValue]
);
const [visible, setVisible] = useState(false);
const onCancel = () => {
props.onSaveState({ table001SelectedRowKeys: [] });
setVisible(false);
};
const onOk = () => {
const { table0SelectedRowKeys = [], table001SelectedRowKeys = [] } = props;
if (!table001SelectedRowKeys.length) {
message.error("请先选择需要合并的从数据!", 3);
return;
}
const temp0Data = [
{
sSelectedId: table0SelectedRowKeys[0],
sIds: table001SelectedRowKeys
.filter(item => item !== table0SelectedRowKeys[0])
.toString()
}
];
props.onExecInstructSet({
nextProps: { ...props, temp0Data },
btnConfig: {
showName: "保存",
sInstruct: JSON.stringify([
{
opr: "procedure",
config: {
sproName: "Sp_mes_MergeReports",
inMap: "temp0.sIds,temp0.sSelectedId"
}
},
{
opr: "refresh",
dataset: "table0"
}
])
},
callback: () => {
onCancel();
}
});
};
const { table0Data = [], table0Config, table0SelectedRowKeys = [] } = props;
const table0DataCopy = cloneDeep(table0Data);
const iIndex = table0DataCopy.findIndex(
item => item.sId === table0SelectedRowKeys[0]
);
if (iIndex !== -1) {
table0DataCopy[iIndex].bDisplayHighLight = true;
}
const table0ConfigCopy = cloneDeep(table0Config);
table0ConfigCopy.gdsconfigformslave = table0ConfigCopy.gdsconfigformslave.filter(
item => !item.sControlName?.includes("BtnTable")
);
const selectedRowData = table0Data.find(
item => item.sId === table0SelectedRowKeys[0]
);
let sSrcSlaveId = "";
if (selectedRowData) {
sSrcSlaveId = selectedRowData.sSrcSlaveId;
}
const tableProps = {
...commonBusiness.getTableTypes("table0", props),
name: "table001",
data: table0DataCopy.filter(item => item.sSrcSlaveId === sSrcSlaveId),
config: table0ConfigCopy,
selectedRowKeys: commonUtils.isNotEmptyArr(props.table001SelectedRowKeys)
? props.table001SelectedRowKeys
: table0SelectedRowKeys,
bMutiSelect: true,
tableProps: {
onChange: () => { }
}
};
return (
{
flag.current = true;
setDateValue(mDate);
}}
size="large"
/>
{/*
*/}
{/* {*/}
{/* flag.current = true;*/}
{/* setValue(e.target.value);*/}
{/* }}*/}
{/* value={value}*/}
{/* optionType="button"*/}
{/* buttonStyle="solid"*/}
{/*/>*/}
{/*
}
onCancel={() => {
onCancel();
}}
>
*/}
);
};
// (定制功能)合版信息弹窗
const CommonViewChooseComponent = props => {
const { viewChooseVisible: visible } = props;
if (!visible) return "";
const title = "合版信息";
const width = "65%";
const height = "50%";
const onOk = () => {
props.onSaveState({ viewChooseVisible: false });
};
const packTableProps = {
...commonBusiness.getTableTypes("pack", props),
filteredValue: props.controlSelectedRowKeys,
onFilterData: props.onFilterData,
onKeyDown: props.onKeyDown,
bRowClick: true
};
return (
}
onCancel={onOk}
>
);
};
// (定制功能)工单参数详情弹窗
const CommonParamsModalComponent = props => {
const modalName = "sWorkParamsModalVisible"; // commonParamVisible
const sProcessParams = "工单参数";
const handleGetSelectedData = tableName => {
const selectedRowKeys = props[`${tableName}SelectedRowKeys`] || [];
let selectedDataIndex = -1;
const tableData = props[`${tableName}Data`];
if (commonUtils.isNotEmptyArr(tableData)) {
if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
selectedDataIndex = tableData.findIndex(
item => item.sId === selectedRowKeys[0]
);
} else {
selectedDataIndex = 0;
}
}
if (selectedDataIndex > -1) {
return props[`${tableName}Data`][selectedDataIndex];
} else {
return {};
}
};
const handleBtnParamPage = type => {
/* 找到所选择控制表, 根据当前行找 上条,下条,首条,末条 */
const { processData } = props;
const processRow = handleGetSelectedData("process"); /* 工序当前选中行 */
const controlRow = handleGetSelectedData("control"); /* 控制表当前选中行 */
let filterData = [];
if (
commonUtils.isNotEmptyObject(controlRow) &&
commonUtils.isNotEmptyArr(processData)
) {
filterData = processData.filter(
item => item.sControlId === controlRow.sId
);
}
let tableDataRow = {};
if (commonUtils.isNotEmptyArr(filterData)) {
const iIndex = filterData.findIndex(item => item.sId === processRow.sId);
if (iIndex > -1) {
const len = filterData.length;
if (type === "first") {
tableDataRow = filterData[0];
} else if (type === "last") {
tableDataRow = filterData[len - 1];
} else if (type === "before") {
if (iIndex === 0 || iIndex > len - 1) {
message.error("当前是首条");
return;
}
tableDataRow = filterData[iIndex - 1];
} else if (type === "next") {
if (iIndex === len - 1 || iIndex > len - 1) {
message.error("当前是末条");
return;
}
tableDataRow = filterData[iIndex + 1];
}
if (commonUtils.isNotEmptyObject(tableDataRow)) {
props.onSaveState({ processSelectedRowKeys: [tableDataRow.sId] });
}
} else {
message.error("数据错误!");
}
} else {
message.error("数据错误!");
}
};
return props[modalName] ? (
{
props.onSaveState({ [modalName]: false });
}}
footer={
}
>
{[""].map(() => {
const commonViewDragableProps = {
...props,
hideTabsNav: true,
// bSimpleMode: true,
sParamData: [
{
sParamType: "sWorkOrder",
sParamName: "工单参数"
}
],
tableName: "process",
enabled: false
};
return ;
})}
) : (
""
);
};
// 标签补打formData特殊处理
const useGetFormDataNew = (props, formData) => {
const { sModelsId, formDataFlag } = props;
if (
!formData.length ||
sModelsId !== "12710101117203990977610" ||
formDataFlag
)
return formData;
const { app } = props;
const { userinfo } = app;
const { iInterface } = userinfo;
// {"0":"切纸","1":"胶印","2":"凹印","3":"凹印挑规","4":"凹印分切","5":"剔废","6":"拼接","7":"倒卷","8":"读码","9":"品检","10":"包装"}
const tempMap = {
0: "qztable0",
1: "jytable0",
2: "wytable0",
3: "wytgtable0",
4: ["slaveWyfq2", "jpfpbtable0"],
5: "slaveWytf1",
6: "slaveWypj2",
7: "slaveWydj",
8: "salveWydm2",
9: "slaveWyrj2",
10: "salveWybz2"
};
const tableName = tempMap[iInterface];
let formDataNew = formData.filter(item => tableName?.includes(item.sGrd));
if (iInterface === 5) {
formDataNew = formData.filter(item =>
[
"slaveWytf1",
"slaveWytf2",
"slaveWypj2",
"slaveWydj",
"salveWydm1",
"salveWydm2",
"jpfpbtable0",
"slaveWyfq2"
].includes(item.sGrd)
);
}
props.onSaveState({
formData: formDataNew,
formDataFlag: true
});
return formDataNew;
};
const TaskConfirmModal = props => {
const { taskConfirmModalVisible, taskConfirmModalMsg } = props;
if (!taskConfirmModalVisible) return "";
const handleClose = () => {
props.itemClickRef.current = null;
props.onSaveState({ taskConfirmModalVisible: false });
};
return (
}
onCancel={handleClose}
>
{taskConfirmModalMsg}
);
};
const SisColorChooseComponent = props => {
const { sisColorChooseVisible, sisColorField, sisTableName, controlSelectedRowId } = props;
const [rightData, setRightData] = useState(props?.sisColorSelectedData?.filter(item => item.bSelected) || []);
useEffect(() => {
if (props.sisColorSelectedData && props.sisColorSelectedData.length > 0) {
setRightData(props?.sisColorSelectedData?.filter(item => item.bSelected) || []);
} else {
setRightData([]);
}
}, [props.sisColorSelectedData, props.sisColorChooseVisible])
if (!sisColorChooseVisible) return "";
const handleClose = () => {
props.onSaveState({
sisColorChooseVisible: false,
});
};
const handelSubmit = () => {
const { [`${sisTableName}Data`]: tableData } = props;
const iIndex = tableData?.findIndex(item => item.sId === controlSelectedRowId);
// iPositiveColor sPositiveColor sOppositeColor
if (props?.sisColorSelectedData && props?.sisColorSelectedData?.length === 0) {
props.onSaveState({
sisColorChooseVisible: false,
sisColorSelectedData: []
});
return
}
const colorList = JSON.parse(tableData[iIndex][sisColorField]).map(item => {
const i = rightData.findIndex(rightItem => rightItem.sId === item.sId);
let newItem = {
...item
}
if (i > -1) {
newItem = {
...newItem,
bSelected: true
}
}
return newItem
});
tableData[iIndex] = {
...tableData[iIndex],
[sisColorField]: JSON.stringify(colorList),
}
const { sPositiveColor, sOppositeColor } = tableData[iIndex]
const sPositiveColorList = (sPositiveColor && sPositiveColor !== 'undefined' && sPositiveColor !== 'null')
? JSON.parse(sPositiveColor).filter(item => item.bSelected)
: [];
const sOppositeColorList = (sOppositeColor && sOppositeColor !== 'undefined' && sOppositeColor !== 'null')
? JSON.parse(sOppositeColor).filter(item => item.bSelected)
: [];
const allTotalDColor = sPositiveColorList.reduce((total, item) => total + item.dColor, 0) + sOppositeColorList.reduce((total, item) => total + item.dColor, 0);
tableData[iIndex] = {
...tableData[iIndex],
iOutsideQty: allTotalDColor,
iPublishQty: allTotalDColor
}
props.onSaveState({
[`${sisTableName}Data`]: [...tableData],
sisColorChooseVisible: false,
sisColorSelectedData: []
});
}
const handleLeftSelectChange = (selectedRowKeys, selectedRows) => {
setRightData(selectedRows);
};
const handleDeleteRight = (record) => {
const newData = rightData.filter(item => item.sId !== record.sId);
setRightData(newData);
};
const leftRowSelection = {
type: 'checkbox',
selectedRowKeys: rightData.map(item => item.sId),
onChange: handleLeftSelectChange,
};
const rowCellStyleLeft = {
fontSize: '16px',
};
const rowCellStyleRight = {
fontSize: '16px',
};
const headerCellStyle = {
fontSize: '20px',
fontWeight: 'bold',
};
const CustomCellLeft = (cellProps) => (
|
);
const CustomCellRight = (cellProps) => (
|
);
const baseColumns = [
{
title: '序号',
dataIndex: 'index',
key: 'index',
width: 60,
align: 'center',
render: (_, record, index) => index + 1,
customHeaderCell: () => ({ style: headerCellStyle }),
},
{
title: '名称',
dataIndex: 'sName',
customHeaderCell: () => ({ style: headerCellStyle }),
},
{
title: '板数',
dataIndex: 'dColor',
customHeaderCell: () => ({ style: headerCellStyle }),
},
];
const rightColumns = [
...baseColumns.map(col => ({ ...col })),
{
title: '操作',
key: 'action',
width: 80,
align: 'center',
customHeaderCell: () => ({ style: headerCellStyle }),
render: (_, record) => (
{ e.stopPropagation(); handleDeleteRight(record); }}
style={{ color: '#ff4d4f', cursor: 'pointer' }}
>
删除
),
},
];
// --- 组件映射 ---
const tableComponentsLeft = {
body: {
cell: CustomCellLeft,
},
};
const tableComponentsRight = {
body: {
cell: CustomCellRight,
},
};
return (
}
onCancel={handleClose}
>
{/* 左侧表格 */}
{/* 右侧表格 */}
);
};
export default CommonModel;