| | |
| | | </div> |
| | | <ProcessFlowConfigSelectDialog |
| | | v-model:visible="processFlowSelectDialogVisible" |
| | | :default-route-id="processFlowSelectDefaultRouteId" |
| | | :bound-route-name="processFlowSelectBoundRouteName" |
| | | @confirm="handleProcessFlowSelectConfirm" |
| | | /> |
| | | <div> |
| | |
| | | delLedgerFile, |
| | | getProductInventory, |
| | | salesLedgerProductProcessList, |
| | | saleProcessBind, |
| | | getSaleProcessBindInfo, |
| | | } from "@/api/salesManagement/salesLedger.js"; |
| | | import { modelList, productTreeList } from "@/api/basicData/product.js"; |
| | | import useFormData from "@/hooks/useFormData.js"; |
| | | import dayjs from "dayjs"; |
| | | import { getCurrentDate } from "@/utils/index.js"; |
| | | import { salesLedgerProductSetProcessFlowConfig } from "@/api/salesManagement/salesProcessFlowConfig.js"; |
| | | // import { salesLedgerProductSetProcessFlowConfig } from "@/api/salesManagement/salesProcessFlowConfig.js"; |
| | | |
| | | const userStore = useUserStore(); |
| | | const { proxy } = getCurrentInstance(); |
| | |
| | | // 工艺路线配置选择弹窗(绑定到台账产品) |
| | | const processFlowSelectDialogVisible = ref(false); |
| | | const processFlowSelectLedgerRow = ref(null); |
| | | const processFlowSelectDefaultRouteId = ref(null); |
| | | const processFlowSelectBoundRouteId = ref(null); |
| | | const processFlowSelectBoundRouteName = ref(""); |
| | | |
| | | // 用户信息表单弹框数据 |
| | | const operationType = ref(""); |
| | |
| | | }; |
| | | |
| | | // 打开“工艺路线配置”选择弹窗(必须显式选择) |
| | | const openProcessFlowSelect = (ledgerRow) => { |
| | | const openProcessFlowSelect = async (ledgerRow) => { |
| | | if (!ledgerRow) return; |
| | | if (!ledgerRow.isEdit) return; |
| | | |
| | | processFlowSelectLedgerRow.value = ledgerRow; |
| | | processFlowSelectDefaultRouteId.value = null; |
| | | processFlowSelectBoundRouteId.value = null; |
| | | processFlowSelectBoundRouteName.value = ""; |
| | | |
| | | try { |
| | | const res = await getSaleProcessBindInfo(ledgerRow.id); |
| | | const info = res?.data ?? res ?? {}; |
| | | const boundId = |
| | | info?.processRouteId ?? |
| | | info?.routeId ?? |
| | | info?.id ?? |
| | | null; |
| | | const boundName = |
| | | info?.processRouteName ?? |
| | | info?.routeName ?? |
| | | info?.name ?? |
| | | ""; |
| | | processFlowSelectBoundRouteId.value = boundId; |
| | | processFlowSelectBoundRouteName.value = boundName; |
| | | processFlowSelectDefaultRouteId.value = boundId; |
| | | } catch (e) { |
| | | // 查询失败时按未绑定处理,不阻塞弹窗 |
| | | processFlowSelectBoundRouteId.value = null; |
| | | processFlowSelectBoundRouteName.value = ""; |
| | | processFlowSelectDefaultRouteId.value = null; |
| | | } |
| | | |
| | | processFlowSelectDialogVisible.value = true; |
| | | }; |
| | | |
| | | // 将配置应用到台账下的所有未发货产品 |
| | | const handleProcessFlowSelectConfirm = async (configId) => { |
| | | // 绑定工艺路线到当前台账数据 |
| | | const handleProcessFlowSelectConfirm = async (routeId) => { |
| | | const ledgerRow = processFlowSelectLedgerRow.value; |
| | | if (!ledgerRow?.id) return; |
| | | |
| | | const finalConfigId = configId ?? null; |
| | | if (!finalConfigId) return; |
| | | const finalRouteId = routeId ?? null; |
| | | if (!finalRouteId) return; |
| | | |
| | | proxy?.$modal?.loading?.("正在应用工艺路线配置,请稍候..."); |
| | | try { |
| | | const res = await productList({ salesLedgerId: ledgerRow.id, type: 1 }); |
| | | const products = res?.data ?? res?.records ?? res ?? []; |
| | | if (!Array.isArray(products) || products.length === 0) { |
| | | proxy?.$modal?.msgWarning?.("该台账下没有产品数据"); |
| | | const oldRouteId = processFlowSelectBoundRouteId.value; |
| | | if (oldRouteId !== null && oldRouteId !== undefined && oldRouteId !== "" && String(oldRouteId) !== String(finalRouteId)) { |
| | | try { |
| | | await ElMessageBox.confirm( |
| | | "该订单已绑定工艺路线,是否确定更换?", |
| | | "提示", |
| | | { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | } |
| | | ); |
| | | } catch { |
| | | return; |
| | | } |
| | | } |
| | | |
| | | for (const product of products) { |
| | | // 已发货/审核通过不可编辑,跳过 |
| | | if (isProductShipped(product)) continue; |
| | | await salesLedgerProductSetProcessFlowConfig({ |
| | | salesLedgerProductId: product.id, |
| | | processFlowConfigId: finalConfigId, |
| | | }); |
| | | } |
| | | proxy?.$modal?.loading?.("正在绑定工艺路线,请稍候..."); |
| | | try { |
| | | await saleProcessBind({ |
| | | salesLedgerId: ledgerRow.id, |
| | | processRouteId: finalRouteId, |
| | | }); |
| | | |
| | | proxy?.$modal?.msgSuccess?.("工艺路线配置应用成功"); |
| | | |
| | | // 若当前行已展开,刷新其子产品列表 |
| | | if (expandedRowKeys.value.includes(ledgerRow.id)) { |
| | | const childRes = await productList({ salesLedgerId: ledgerRow.id, type: 1 }); |
| | | const children = childRes?.data ?? childRes?.records ?? childRes ?? []; |
| | | const index = tableData.value.findIndex((item) => item.id === ledgerRow.id); |
| | | if (index > -1) { |
| | | tableData.value[index].children = children; |
| | | } |
| | | } |
| | | proxy?.$modal?.msgSuccess?.("工艺路线绑定成功"); |
| | | processFlowSelectDialogVisible.value = false; |
| | | // 绑定后刷新列表,确保操作列再次点击能回显绑定 |
| | | await getList(); |
| | | } catch (e) { |
| | | proxy?.$modal?.msgError?.("应用失败,请稍后重试"); |
| | | proxy?.$modal?.msgError?.("绑定失败,请稍后重试"); |
| | | } finally { |
| | | proxy?.$modal?.closeLoading?.(); |
| | | } |