From 1f2d6ee016348c3b430a1c5eff65000d50364793 Mon Sep 17 00:00:00 2001 From: chenxt <10125295+chen-xintao97@user.noreply.gitee.com> Date: Fri, 19 Dec 2025 11:28:17 +0800 Subject: [PATCH] 弹窗取消删除 --- src/components/Common/CommonComponent/index.js | 2 -- src/components/Common/CommonHooks/useCommonBase.js | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ src/components/Common/CommonTable/index.js | 37 ++++++++++++++++++++++++------------- src/mes/common/commonModalComponent/index.js | 5 +++-- src/mes/common/commonModelComponent/index.js | 37 +++++++++++++++++++++++-------------- src/mes/common/commonOperationBarComponent/MesToolbar.js | 6 ++++++ src/mes/common/commonOperationBarComponent/index.js | 2 +- src/mes/common/routerComponent/index.js | 2 +- src/mes/indexMes/index.js | 1 - src/routes/mes/routerComponent.js | 6 ++++-- 10 files changed, 143 insertions(+), 42 deletions(-) diff --git a/src/components/Common/CommonComponent/index.js b/src/components/Common/CommonComponent/index.js index ab19884..cc372bb 100644 --- a/src/components/Common/CommonComponent/index.js +++ b/src/components/Common/CommonComponent/index.js @@ -301,8 +301,6 @@ export default class CommonComponent extends Component { /* 若下拉配置了movesql 则离开时 调用下拉sql数据 */ if (this.props.showConfig && (this.props.showConfig.sDropDownType === 'movesql' || commonUtils.isNotEmptyObject(this.props.showConfig.sButtonParam))) { this.props.onDropDownBlur(this.props.name, this.props.showConfig.sName, this.props.record, this.props.showConfig); - console.log(this.props, 'onDropDownBlur'); - } this.onCheckFields(500); diff --git a/src/components/Common/CommonHooks/useCommonBase.js b/src/components/Common/CommonHooks/useCommonBase.js index 388193f..8e31f65 100644 --- a/src/components/Common/CommonHooks/useCommonBase.js +++ b/src/components/Common/CommonHooks/useCommonBase.js @@ -42,7 +42,7 @@ const useCommonBase = props => { const tempRef = useRef({}); let mounted = true console.log(props, 'useCommonBase'); - + const setTempRef = (params, bRewrite) => { if (bRewrite) { tempRef.current = params; @@ -2419,8 +2419,8 @@ const useCommonBase = props => { ); }; if (!dbclickPopConfig) return - let { sActiveId, sActiveName } = dbclickPopConfig; + let { sActiveId, sActiveName } = dbclickPopConfig; // 如果行数据里有sFormId, 则取sFormId作为弹窗的表单id const { sFormId, sMaintenanceLevel } = record; if (sFormId && sMaintenanceLevel) { @@ -2443,7 +2443,7 @@ const useCommonBase = props => { sActiveId = "17102090670002643282020454509600"; } } else { - sActiveId = sFormId; + sActiveId = sFormId || sActiveId; sActiveName = '编辑'; } @@ -2600,8 +2600,6 @@ const useCommonBase = props => { const values = { sConfigformId, sControlName, sRowData }; if (true) { const dataReturn = (await commonServices.postValueService(app.token, values, dataUrl)).data; - console.log(dataReturn, 'dataReturn'); - const allReturnMap = {}; if (dataReturn.code === 1) { const returnData = dataReturn.dataset.rows[0]; @@ -3284,6 +3282,82 @@ const useCommonBase = props => { } } }; + const handleDel = (obj) => { + const props = { ...this.props, ...this.state }; + const onOkDel = handleOkDel; + confirm({ + title: obj.title, + onOk() { + onOkDel(props); + }, + onCancel() { + }, + }); + }; + /* 确定要删除 */ + const handleOkDel = async (props) => { + /* 数据参数 */ + const { + token, sModelsId, sModelsType, masterConfig, masterData, slaveConfig, checkConfig, orderDetailConfig, app, + } = props; + const { userinfo, systemData } = app; + const { sMakePerson } = masterData; /* 本单据制单人 */ + const { sUserName, sType } = userinfo;/* 登录用户 */ + const iIndex = systemData.findIndex(item => item.sName === 'CkxModifyBillNoMakePerson'); + if (iIndex > -1) { + const sValue = systemData[iIndex].sValue; + if (sValue === '0') { /* 系统未启用非制单人修改单据,普通用户非制单人不可以修改制单人的单据 */ + if (sType !== 'sysadmin' && sUserName !== sMakePerson) { + message.error(commonFunc.showMessage(app.commonConst, 'NoDelByNoMakePerson')); + return; + } + } + } + const value = { + sClientType: '1', + data: { + sMasterTable: masterConfig.sTbName, + sId: [masterData.sId], + }, + }; + const sSlaveTable = []; + if (commonUtils.isNotEmptyObject(slaveConfig)) { + sSlaveTable.push({ + tableName: slaveConfig.sTbName, + relationName: 'sParentId', + }); + } + if (commonUtils.isNotEmptyObject(checkConfig)) { + sSlaveTable.push({ + tableName: checkConfig.sTbName, + relationName: 'sParentId', + }); + } + if (sModelsType === 'purchase/purchaseOrder') { + sSlaveTable.push({ + tableName: orderDetailConfig.sTbName, + relationName: 'sParentId', + }); + } + value.sSlaveTable = sSlaveTable; + const { sBillNo, sId } = masterData || {}; + const url = `${commonConfig.server_host}business/delMasSlaBusinessData?sModelsId=${sModelsId}&sBillNo=${sBillNo}&sSysLogSrcId=${sId}`; + /* 接收返回值 */ + const { data } = await commonServices.postValueService(token, value, url); + if (data.code === 1) { + /* 数据删除成功 */ + if (this.props.app.currentPane.refresh !== undefined) { + this.props.app.currentPane.refresh(); + } + if (sModelsType !== 'commonOeeBill') { + this.handleDelDataSuccess(props); + } else { + message.info('删除成功!'); + } + } else { /* 失败 */ + this.props.getServiceError(data); + } + }; const returnProps = { ...props, ...state, @@ -3315,7 +3389,8 @@ const useCommonBase = props => { onMergeTableConfig: handleMergeTableConfig, // 合并config配置和所有sButtonEnabled配置 awaitPromiseReturn: awaitPromiseReturn, onSelectCommonPopup: handleSelectCommonPopup, - onDropDownBlur: handleTableBlur + onDropDownBlur: handleTableBlur, + onDel: handleDel }; // 切换页面时,加载角标数据 diff --git a/src/components/Common/CommonTable/index.js b/src/components/Common/CommonTable/index.js index 08e24b7..2d9390b 100644 --- a/src/components/Common/CommonTable/index.js +++ b/src/components/Common/CommonTable/index.js @@ -1220,13 +1220,15 @@ class CommonTableRc extends React.Component { /** 行选择 */ onDoubleClick = (name, record) => { - if (this.props.onDoubleClickNew) { + console.log('onDoubleClick', 1111); + this.props.onDoubleClickNew({ name, record }); } else if (this.props.onDoubleClick !== undefined) { this.props.onDoubleClick(record); + console.log('onDoubleClick', 2222); } - + }; onKeyDownDiv = (e, sName) => { @@ -3557,7 +3559,7 @@ class CommonTableRc extends React.Component { rowSelection = null; } const { expKeys } = this.state; - const {sModelType} = this.props?.parentProps || {} + const { sModelType } = this.props?.parentProps || {} /* 返回值 */ return { components, @@ -8232,7 +8234,7 @@ class CommonTableRc extends React.Component { ) { btnPupopConfig = controlConfig[0]; console.log(btnPupopConfig, 'btnPupopConfig'); - + this.setState({ commonPopupVisible: true, commonPopupTbName: name, @@ -12168,7 +12170,6 @@ const useGetTableBtnOprSetting = props => { item => item.sControlName?.toLowerCase() === "btntableopr" ) || {}; let { sDefault = "" } = btnTableOprConfig; - const btnTableDelConfig = gdsconfigformslave.find( item => item.sControlName?.toLowerCase() === "btntabledel" @@ -12196,7 +12197,19 @@ const useGetTableBtnOprSetting = props => { if (location.pathname.includes("indexPad") && sDefault) { sDefault = "add,del,save"; } - sDefault = sDefault + ',materials' + const getButtonName = (sControlName) => { + if (!sControlName) return ''; + const parts = sControlName.split('.'); + return parts[parts.length - 1].replace(/^btn/i, ''); // 取最后一部分 + }; + if (sDefault === '') { + // sDefault = + const btnList = gdsconfigformslave.filter(item => item.bVisible && item.sControlName.includes('Btn')) + sDefault = btnList?.map(item => { + return getButtonName(item.sControlName.toLowerCase()) + }).join(',') + } + // sDefault = sDefault + ',materials' const { bSubmit, bCheck } = props?.parentProps?.masterData || {}; if (location.pathname.includes("indexPad") && sDefault && !props.enabled) { if (!bSubmit && !bCheck) { @@ -12209,7 +12222,6 @@ const useGetTableBtnOprSetting = props => { if (!sDefault) { return result; } - // 表格滚动到底部 const scrollToBottom = tableClassName => { setTimeout(() => { @@ -12234,7 +12246,7 @@ const useGetTableBtnOprSetting = props => { const resultTemp = {}; const list = sDefault.split(","); list.forEach(btnType => { - if (btnType === "add") { + if (btnType.includes("add")) { resultTemp.mesAdd = params => { const { sDefault: str } = btnTableAddConfig; let disabled = props.getBtnDisabled({ @@ -12266,7 +12278,7 @@ const useGetTableBtnOprSetting = props => { /> ); }; - } else if (btnType === "del") { + } else if (btnType.includes("del")) { resultTemp.mesDel = params => { const { record } = params; const { sDefault: str } = btnTableDelConfig; @@ -12290,7 +12302,7 @@ const useGetTableBtnOprSetting = props => { /> ); }; - } else if (btnType === "copy") { + } else if (btnType.includes("copy")) { resultTemp.mesCopy = params => { let disabled = false; if (props.parentProps.bMesBill) { @@ -12311,7 +12323,7 @@ const useGetTableBtnOprSetting = props => { /> } ; - } else if (btnType === "save") { + } else if (btnType.includes("slave")) { resultTemp.mesSave = () => ( } @@ -73,7 +74,7 @@ const CommonModalComponent = props => { height: "100%" }} > - + ); diff --git a/src/mes/common/commonModelComponent/index.js b/src/mes/common/commonModelComponent/index.js index 3864033..4b14816 100644 --- a/src/mes/common/commonModelComponent/index.js +++ b/src/mes/common/commonModelComponent/index.js @@ -1,3 +1,4 @@ +/* eslint-disable */ import React, { useEffect, useRef, useState } from "react"; import moment from "moment"; import { cloneDeep } from "lodash"; @@ -282,7 +283,7 @@ const useCommonModelEvent = props => { let result = {}; if (!commonUtils.isEmptyObject(copyTo) && !refreshCount) { result = await handleGetData(tableList, true, true); - + } else if (noGetData) { result = await await handleGetData( tableList.filter( @@ -327,8 +328,8 @@ const useCommonModelEvent = props => { ...addState, ...handleMergeCustomColumn(addState, tableList) }; - console.log(addState,'addState'); - + console.log(addState, 'addState'); + props.onSaveState(addState); } } @@ -408,7 +409,7 @@ const useCommonModelEvent = props => { masterDataCopyTo = tableData; } } - + const masterDataNew = { ...commonFunc.getDefaultData(masterConfig), handleType: "add", @@ -420,6 +421,11 @@ const useCommonModelEvent = props => { }, [props.bFinish] ); + const { gdsconfigformslave } = props?.slaveConfig || {} + const copyConfig = gdsconfigformslave?.filter(x => x.sControlName.includes('BtnCopyTo')) + useEffect(() => { + + }, []) // 如果是表单类型,并且主表数据为空,默认为编辑状态 // useEffect( @@ -1187,8 +1193,7 @@ const CommonModel = baseProps => { ? useCommonModelEvent(baseProps) : useCommonModelEvent(useCommonBase(baseProps)); const { bFinish } = props; - console.log(props, 'CommonModel'); - + if (!bFinish) return ""; const { tabConfig = [] } = props; @@ -1196,7 +1201,6 @@ const CommonModel = baseProps => { if (props.sModelsId === "12710101117191104477380") { return ; } - return ( <> @@ -1250,7 +1254,6 @@ const CommonModelComponent = props => { tableBtnsConfig, // 表格按钮配置 bFirstComponent: level === 0 && index === -1 }; - const commonDivHeight = useComputedCommonDivHeight(componentProps); return (
{ // 展示的数据 let viewRow = {}; const dataArr = Array.isArray(data) ? data : [data]; - console.log(dataArr,props, 'dataArr'); - + if (selectedRowKeys.length) { viewRow = dataArr.find(item => item.sId === selectedRowKeys[0]); } @@ -1559,9 +1561,8 @@ const CommonViewTableComponent = props => { const operationBarProps = { ...props, sName, - belongsToForm: true + belongsToForm: true, }; - return ( <> {sName === "master" ? ( @@ -1580,7 +1581,7 @@ const CommonViewTableComponent = props => { viewRow, tableName: sName }; - + if (commonUtils.isEmptyObject(viewRow)) { viewProps.enabledNew = false; } @@ -1820,6 +1821,14 @@ const CommonTableComponent = props => { ...props, sName }; + if (tableProps.data && tableProps.data.length === 0) { + console.log("🚀 ~ CommonTableComponent ~ tableProps:", tableProps) + + props.onMesTableLineAdd({ + tableName: tableProps.name, + // tableClassName: state.tableClassName + }) + } return ( <> @@ -1953,7 +1962,7 @@ const CommonRepairComponent = props => { footer={