Commit dd2a1e3ef55be930f7df139d59fff181a36b9fb5
1 parent
10114102
1.工艺卡增加删除全部,删除选中功能
Showing
2 changed files
with
194 additions
and
22 deletions
src/components/Common/CommonListEvent.js
| @@ -1527,7 +1527,7 @@ export default (ChildComponent) => { | @@ -1527,7 +1527,7 @@ export default (ChildComponent) => { | ||
| 1527 | } | 1527 | } |
| 1528 | 1528 | ||
| 1529 | /* 单据页复制到 */ | 1529 | /* 单据页复制到 */ |
| 1530 | - handleCopyTo = async (name, sActiveId) => { | 1530 | + handleCopyTo = async (name, sActiveId, iFlag) => { |
| 1531 | /* 待用数据声明 */ | 1531 | /* 待用数据声明 */ |
| 1532 | const { | 1532 | const { |
| 1533 | slaveConfig, slaveSelectedData, token, app, sModelsId, formRoute, slaveInfoConfig, slaveInfoSelectedData, slaveFilterCondition, | 1533 | slaveConfig, slaveSelectedData, token, app, sModelsId, formRoute, slaveInfoConfig, slaveInfoSelectedData, slaveFilterCondition, |
| @@ -1859,6 +1859,23 @@ export default (ChildComponent) => { | @@ -1859,6 +1859,23 @@ export default (ChildComponent) => { | ||
| 1859 | sendSocketMessage('copy', 'execute', sId, userinfo.sId, null, null); | 1859 | sendSocketMessage('copy', 'execute', sId, userinfo.sId, null, null); |
| 1860 | } | 1860 | } |
| 1861 | } | 1861 | } |
| 1862 | + } else if (dataReturn.code === -7) { | ||
| 1863 | + // eslint-disable-next-line no-underscore-dangle | ||
| 1864 | + const _this = this; | ||
| 1865 | + confirm({ | ||
| 1866 | + title: '是否继续', /* 防呆校验 */ | ||
| 1867 | + content: dataReturn.msg, | ||
| 1868 | + onOk() { | ||
| 1869 | + iFlag = 1; | ||
| 1870 | + _this.handleCopyTo(name,sActiveId, iFlag); | ||
| 1871 | + }, | ||
| 1872 | + onCancel() { | ||
| 1873 | + }, | ||
| 1874 | + }); | ||
| 1875 | + this.props.onSaveState({ | ||
| 1876 | + loading: false, | ||
| 1877 | + }); | ||
| 1878 | + return true; | ||
| 1862 | } else { | 1879 | } else { |
| 1863 | this.props.getServiceError(dataReturn); | 1880 | this.props.getServiceError(dataReturn); |
| 1864 | } | 1881 | } |
src/components/Manufacture/ProcessCardPackTableTreeNew/index.js
| @@ -17,6 +17,7 @@ import CommonView from "@/components/Common/CommonView"; | @@ -17,6 +17,7 @@ import CommonView from "@/components/Common/CommonView"; | ||
| 17 | import StaticEditTable from "@/components/Common/CommonTable"; | 17 | import StaticEditTable from "@/components/Common/CommonTable"; |
| 18 | import CommonViewDragable from "@/components/Common/CommonViewDragable"; | 18 | import CommonViewDragable from "@/components/Common/CommonViewDragable"; |
| 19 | import styles from "./index.less"; | 19 | import styles from "./index.less"; |
| 20 | +import { Button, Space } from "antd"; | ||
| 20 | 21 | ||
| 21 | const { Panel } = Collapse; | 22 | const { Panel } = Collapse; |
| 22 | 23 | ||
| @@ -3679,29 +3680,32 @@ const materialsProps = props => { | @@ -3679,29 +3680,32 @@ const materialsProps = props => { | ||
| 3679 | returnProps.onDataRowDel = ({ name, tableSelectedRowKeys }) => { | 3680 | returnProps.onDataRowDel = ({ name, tableSelectedRowKeys }) => { |
| 3680 | if (name === "materials0") { | 3681 | if (name === "materials0") { |
| 3681 | /* 删除全部材料时 对应删除替代料 */ | 3682 | /* 删除全部材料时 对应删除替代料 */ |
| 3682 | - const { [`${name}SelectedRowKeys`]: tableSelectedRowKeys, materials0Data } = props; | ||
| 3683 | - if (commonUtils.isEmptyArr(tableSelectedRowKeys)) { | 3683 | + const { materials0Data } = props; |
| 3684 | + const selectedRowAllKeys = tableSelectedRowKeys || props[`${name}SelectedRowKeys`] ; | ||
| 3685 | + console.log('删除数据:', selectedRowAllKeys); | ||
| 3686 | + | ||
| 3687 | + if (commonUtils.isEmptyArr(selectedRowAllKeys)) { | ||
| 3684 | message.error("请选择数据!"); | 3688 | message.error("请选择数据!"); |
| 3685 | return; | 3689 | return; |
| 3686 | } | 3690 | } |
| 3687 | if (commonUtils.isNotEmptyArr(materials0Data)) { | 3691 | if (commonUtils.isNotEmptyArr(materials0Data)) { |
| 3688 | - const materials0ChildData = materials0Data.filter(item => tableSelectedRowKeys.includes(item.sParentMaterialsId)); | 3692 | + const materials0ChildData = materials0Data.filter(item => selectedRowAllKeys.includes(item.sParentMaterialsId)); |
| 3689 | if (commonUtils.isNotEmptyArr(materials0ChildData)) { | 3693 | if (commonUtils.isNotEmptyArr(materials0ChildData)) { |
| 3690 | materials0ChildData.forEach(item => { | 3694 | materials0ChildData.forEach(item => { |
| 3691 | - tableSelectedRowKeys.push(item.sId); | 3695 | + selectedRowAllKeys.push(item.sId); |
| 3692 | }); | 3696 | }); |
| 3693 | } | 3697 | } |
| 3694 | 3698 | ||
| 3695 | /* 删除子墨 */ | 3699 | /* 删除子墨 */ |
| 3696 | - const materials0InkData = materials0Data.filter(item => tableSelectedRowKeys.includes(item.sInkFatherMaterialsTbId)); | 3700 | + const materials0InkData = materials0Data.filter(item => selectedRowAllKeys.includes(item.sInkFatherMaterialsTbId)); |
| 3697 | if (commonUtils.isNotEmptyArr(materials0InkData)) { | 3701 | if (commonUtils.isNotEmptyArr(materials0InkData)) { |
| 3698 | materials0InkData.forEach(item => { | 3702 | materials0InkData.forEach(item => { |
| 3699 | - tableSelectedRowKeys.push(item.sId); | 3703 | + selectedRowAllKeys.push(item.sId); |
| 3700 | }); | 3704 | }); |
| 3701 | } | 3705 | } |
| 3702 | 3706 | ||
| 3703 | - const materials0ReturnData = props.otherTableDel("materials0", tableSelectedRowKeys, "sId"); /* 全部材料删除 */ | ||
| 3704 | - const materials0ChildReturnData = props.otherTableDel("materials0Child", tableSelectedRowKeys, "sId"); /* 替代料删除 */ | 3707 | + const materials0ReturnData = props.otherTableDel("materials0", selectedRowAllKeys, "sId"); /* 全部材料删除 */ |
| 3708 | + const materials0ChildReturnData = props.otherTableDel("materials0Child", selectedRowAllKeys, "sId"); /* 替代料删除 */ | ||
| 3705 | props.onSaveState({ | 3709 | props.onSaveState({ |
| 3706 | ...materials0ReturnData, | 3710 | ...materials0ReturnData, |
| 3707 | ...materials0ChildReturnData, | 3711 | ...materials0ChildReturnData, |
| @@ -4271,6 +4275,144 @@ const OtherComponent = props => { | @@ -4271,6 +4275,144 @@ const OtherComponent = props => { | ||
| 4271 | } | 4275 | } |
| 4272 | return str; | 4276 | return str; |
| 4273 | }; | 4277 | }; |
| 4278 | + // 删除材料方法 | ||
| 4279 | + const handleDelAllMaterials = (filterData, bPartDel) => { | ||
| 4280 | + console.log("handleDelAllMaterials", filterData, bPartDel); | ||
| 4281 | + console.log('sss', props); | ||
| 4282 | + const { materials0SelectedRowKeys = [], materials0Data = [] } = props; | ||
| 4283 | + | ||
| 4284 | + // 如果是撤销操作 (bPartDel === 7) | ||
| 4285 | + if (bPartDel === 7) { | ||
| 4286 | + const undo = async () => { | ||
| 4287 | + try { | ||
| 4288 | + const { masterData, sModelsId, token, slaveData, controlData = [], controlSelectedRowKeys = [], | ||
| 4289 | + slaveSelectedRowKeys = [], | ||
| 4290 | + processData = [], | ||
| 4291 | + materialsConfig | ||
| 4292 | + } = props; | ||
| 4293 | + const controlRow = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? | ||
| 4294 | + controlData.find(item => controlSelectedRowKeys.includes(item.sId)) : controlData[0]; | ||
| 4295 | + const sCombineMemoObj = commonUtils.isNotEmptyObject(controlRow?.sCombinedMemo) && commonUtils.isJSON(controlRow.sCombinedMemo) ? | ||
| 4296 | + JSON.parse(controlRow.sCombinedMemo) : [] ; | ||
| 4297 | + console.log(sCombineMemoObj, controlRow, 's'); | ||
| 4298 | + let slaveObj = slaveData.find(item => | ||
| 4299 | + sCombineMemoObj?.some(obj => obj.sProductNo === item.sProductNo) | ||
| 4300 | + ); | ||
| 4301 | + if(commonUtils.isNotEmptyObject(slaveObj)){ | ||
| 4302 | + if(commonUtils.isNotEmptyArr(slaveSelectedRowKeys)){ | ||
| 4303 | + slaveObj = slaveData.find(item => slaveSelectedRowKeys.includes(item.sId)) | ||
| 4304 | + } else{ | ||
| 4305 | + slaveObj = slaveData[0]; | ||
| 4306 | + } | ||
| 4307 | + } | ||
| 4308 | + | ||
| 4309 | + const btnRoveObj = materialsConfig?.gdsconfigformslave.find(item => item.sControlName?.includes('BtnRevoke')); | ||
| 4310 | + const materialsAssignField = btnRoveObj?.materialsAssignField; | ||
| 4311 | + const dataUrl = `${commonConfig.server_host}salesorder/getMaterialsCardDataByCustomIdProductId/?sModelsId=${sModelsId}`; | ||
| 4312 | + const sRowData = commonUtils.isNotEmptyObject(slaveObj) ? [slaveObj] : []; | ||
| 4313 | + const condition = { sRowData }; | ||
| 4314 | + const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data; | ||
| 4315 | + if (dataReturn.code === 1) { | ||
| 4316 | + message.success("撤销成功!"); | ||
| 4317 | + const returnData = dataReturn.dataset.rows[0]; | ||
| 4318 | + const materialsReturnData = returnData?.materialsData || []; | ||
| 4319 | + const newCopyTo = { control: controlRow } | ||
| 4320 | + if (commonUtils.isNotEmptyArr(materialsReturnData)) { | ||
| 4321 | + materialsReturnData.filter(item => item.sType !== '2').forEach((materialsItem) => { | ||
| 4322 | + const newSid = commonUtils.createSid(); | ||
| 4323 | + let materialsRow = commonFunc.getDefaultData(materialsConfig, newCopyTo, { newSid }); // 取默认值 | ||
| 4324 | + if(materialsAssignField) { | ||
| 4325 | + materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; | ||
| 4326 | + } | ||
| 4327 | + // materialsRow = {...materialsItem}; | ||
| 4328 | + materialsRow.handleType = 'add'; | ||
| 4329 | + materialsRow.sId = newSid; | ||
| 4330 | + materialsRow.sParentId = masterData.sId; | ||
| 4331 | + materialsRow.sControlId = controlRow.sId; | ||
| 4332 | + materialsRow.sPartsName = controlRow.sPartsName; | ||
| 4333 | + materialsRow.sSlaveId = slaveObj?.sId; | ||
| 4334 | + materialsRow.sOriginalId = materialsItem.sId; | ||
| 4335 | + materialsRow.sZmldlt = materialsItem.sZmldlt; | ||
| 4336 | + materialsRow.sProcessId = materialsItem.sProcessId; | ||
| 4337 | + materialsRow.sInkFatherMaterialsTbId = materialsItem.sInkFatherMaterialsTbId; | ||
| 4338 | + // 材料对应工序的ID要变化 | ||
| 4339 | + if (commonUtils.isNotEmptyArr(processData)) { | ||
| 4340 | + const iProcessIndex = processData.findIndex(prow => prow.sControlId === controlRow.sId | ||
| 4341 | + && materialsRow.sProcessId === prow.sProcessId | ||
| 4342 | + ); | ||
| 4343 | + if (iProcessIndex > -1) { | ||
| 4344 | + materialsRow.sProcessTbId = processData[iProcessIndex].sId; | ||
| 4345 | + } | ||
| 4346 | + } | ||
| 4347 | + materials0Data.push(materialsRow); | ||
| 4348 | + }); | ||
| 4349 | + } | ||
| 4350 | + | ||
| 4351 | + // 这里可以根据返回的数据更新界面 | ||
| 4352 | + console.log("撤销返回数据:", materialsReturnData); | ||
| 4353 | + console.log("汇总:", materials0Data); | ||
| 4354 | + props.onSaveState({materials0Data}) | ||
| 4355 | + } else { | ||
| 4356 | + message.error(dataReturn.msg || "撤销失败!"); | ||
| 4357 | + } | ||
| 4358 | + } catch (error) { | ||
| 4359 | + message.error(error + "撤销操作失败!"); | ||
| 4360 | + } | ||
| 4361 | + }; | ||
| 4362 | + | ||
| 4363 | + Modal.confirm({ | ||
| 4364 | + title: "确认要撤销操作吗?", | ||
| 4365 | + onOk() { | ||
| 4366 | + undo(); | ||
| 4367 | + }, | ||
| 4368 | + okText: '确定', | ||
| 4369 | + cancelText: '取消' | ||
| 4370 | + }); | ||
| 4371 | + return; | ||
| 4372 | + } | ||
| 4373 | + | ||
| 4374 | + // 原有的删除逻辑 | ||
| 4375 | + const partFilterData = filterData.filter(item => item.bMark); | ||
| 4376 | + console.log('ffff', partFilterData); | ||
| 4377 | + if (bPartDel) { | ||
| 4378 | + if (!partFilterData.length) { | ||
| 4379 | + message.info("请先选择要删除的数据!"); | ||
| 4380 | + return; | ||
| 4381 | + } | ||
| 4382 | + } | ||
| 4383 | + | ||
| 4384 | + const delAll = () => { | ||
| 4385 | + const sIds = filterData.map(item => item.sId); | ||
| 4386 | + // 尝试调用删除方法 - 参数需要匹配 CommonBase 的 handleTableDel 方法签名 | ||
| 4387 | + if (props.onDataRowDel && typeof props.onDataRowDel === 'function') { | ||
| 4388 | + console.log('删除全部材料sId222集合', sIds); | ||
| 4389 | + props.onDataRowDel("materials0", false, sIds, undefined); | ||
| 4390 | + } else { | ||
| 4391 | + console.error("onDataRowDel 方法不存在或不是函数"); | ||
| 4392 | + message.error("删除错误"); | ||
| 4393 | + } | ||
| 4394 | + } | ||
| 4395 | + | ||
| 4396 | + const delPart = () => { | ||
| 4397 | + const sIds = partFilterData.map(item => item.sId); | ||
| 4398 | + // 尝试调用删除方法 - 参数需要匹配 CommonBase 的 handleTableDel 方法签名 | ||
| 4399 | + if (props.onDataRowDel && typeof props.onDataRowDel === 'function') { | ||
| 4400 | + props.onDataRowDel("materials0", false, sIds, undefined); | ||
| 4401 | + } else { | ||
| 4402 | + console.error("onDataRowDel 方法不存在或不是函数"); | ||
| 4403 | + message.error("删除功能不可用"); | ||
| 4404 | + } | ||
| 4405 | + } | ||
| 4406 | + | ||
| 4407 | + Modal.confirm({ | ||
| 4408 | + title: `确认要删除${bPartDel ? "选中" : "全部"}吗?`, | ||
| 4409 | + onOk() { | ||
| 4410 | + bPartDel ? delPart() : delAll(); | ||
| 4411 | + }, | ||
| 4412 | + okText: '确定', | ||
| 4413 | + cancelText: '取消' | ||
| 4414 | + }); | ||
| 4415 | + }; | ||
| 4274 | 4416 | ||
| 4275 | const [activeKey, setActiveKey] = useState(["process", "material", "color", "vision", ...materialsChildInfoList]); | 4417 | const [activeKey, setActiveKey] = useState(["process", "material", "color", "vision", ...materialsChildInfoList]); |
| 4276 | const getHeaderIcon = tablename => ( | 4418 | const getHeaderIcon = tablename => ( |
| @@ -4293,7 +4435,7 @@ const OtherComponent = props => { | @@ -4293,7 +4435,7 @@ const OtherComponent = props => { | ||
| 4293 | </Panel> | 4435 | </Panel> |
| 4294 | 4436 | ||
| 4295 | <Panel collapsible="header" header={getHeaderIcon("material")} showArrow={false} extra={panelExtra("material")} key="material"> | 4437 | <Panel collapsible="header" header={getHeaderIcon("material")} showArrow={false} extra={panelExtra("material")} key="material"> |
| 4296 | - <MaterialsComponent {...props} materialsTabValue={materialsTabValue} /> | 4438 | + <MaterialsComponent {...props} materialsTabValue={materialsTabValue} onDelAllMaterials={handleDelAllMaterials}/> |
| 4297 | </Panel> | 4439 | </Panel> |
| 4298 | {materialsChildInfoListFilter.map(tablename => { | 4440 | {materialsChildInfoListFilter.map(tablename => { |
| 4299 | const { showName } = props[`${tablename}Config`]; | 4441 | const { showName } = props[`${tablename}Config`]; |
| @@ -4501,20 +4643,33 @@ const MaterialsComponent = props => { | @@ -4501,20 +4643,33 @@ const MaterialsComponent = props => { | ||
| 4501 | <div className="dlhStyle"> | 4643 | <div className="dlhStyle"> |
| 4502 | <div style={{ position: "relative", width: sWidth }}> | 4644 | <div style={{ position: "relative", width: sWidth }}> |
| 4503 | <StaticEditTable {...materialsOtherPropsType} /> | 4645 | <StaticEditTable {...materialsOtherPropsType} /> |
| 4504 | - {/* {index === 0 && ( | 4646 | + {true && ( |
| 4505 | <div className={styles.delAll}> | 4647 | <div className={styles.delAll}> |
| 4506 | - <Button | ||
| 4507 | - type="primary" | ||
| 4508 | - disabled={!props.enabled} | ||
| 4509 | - // onClick={props.onDeleteAllMaterials.bind( | ||
| 4510 | - // this, | ||
| 4511 | - // materialsOtherPropsType.data | ||
| 4512 | - // )} | ||
| 4513 | - > | ||
| 4514 | - 删除全部 | ||
| 4515 | - </Button> | 4648 | + <Space> |
| 4649 | + <Button | ||
| 4650 | + type="primary" | ||
| 4651 | + disabled={!props.enabled || commonUtils.isEmptyArr(materialsOtherPropsType.data)} | ||
| 4652 | + onClick={() => props.onDelAllMaterials?.(materialsOtherPropsType.data, false)} | ||
| 4653 | + > | ||
| 4654 | + 删除全部 | ||
| 4655 | + </Button> | ||
| 4656 | + {/*<Button*/} | ||
| 4657 | + {/* type="primary"*/} | ||
| 4658 | + {/* disabled={!props.enabled || commonUtils.isNotEmptyArr(materialsOtherPropsType.data)}*/} | ||
| 4659 | + {/* onClick={() => props.onDelAllMaterials?.(materialsOtherPropsType.data, 7)}*/} | ||
| 4660 | + {/*>*/} | ||
| 4661 | + {/* 撤销*/} | ||
| 4662 | + {/*</Button>*/} | ||
| 4663 | + <Button | ||
| 4664 | + type="primary" | ||
| 4665 | + disabled={!props.enabled || commonUtils.isEmptyArr(materialsOtherPropsType.data)} | ||
| 4666 | + onClick={() => props.onDelAllMaterials?.(materialsOtherPropsType.data, true)} | ||
| 4667 | + > | ||
| 4668 | + 删除选中 | ||
| 4669 | + </Button> | ||
| 4670 | + </Space> | ||
| 4516 | </div> | 4671 | </div> |
| 4517 | - )} */} | 4672 | + )} |
| 4518 | </div> | 4673 | </div> |
| 4519 | {materialsChildTableProps ? ( | 4674 | {materialsChildTableProps ? ( |
| 4520 | <div style={{ width: sRightWidth, position: "relative" }}> | 4675 | <div style={{ width: sRightWidth, position: "relative" }}> |