| | |
| | | saveApprovalInstance, |
| | | updateApprovalInstance, |
| | | } from "@/api/officeProcessAutomation/approvalInstance.js"; |
| | | import { productionProductMainGetInfo } from "@/api/productionManagement/productionProductMain.js"; |
| | | import { getQuotationList } from "@/api/salesManagement/salesQuotation.js"; |
| | | import { getPurchaseByCode } from "@/api/procurementManagement/procurementLedger.js"; |
| | | import { getDeliveryDetailByShippingNo } from "@/api/salesManagement/deliveryLedger.js"; |
| | | import useUserStore from "@/store/modules/user"; |
| | | import { Search } from "@element-plus/icons-vue"; |
| | | import { ElMessage, ElMessageBox } from "element-plus"; |
| | |
| | | |
| | | const detailDialog = reactive({ visible: false }); |
| | | const detailRow = ref({}); |
| | | const detailData = ref({}); |
| | | |
| | | const approveDialog = reactive({ visible: false, row: null }); |
| | | const approveOpinion = ref(""); |
| | |
| | | })); |
| | | |
| | | const tableColumn = ref([ |
| | | { label: "申请人编号", prop: "applicantNo", width: 110 }, |
| | | { label: "申请人名称", prop: "applicantName", minWidth: 100 }, |
| | | // { label: "申请人编号", prop: "applicantNo", width: 110 }, |
| | | { label: "发起人", prop: "applicantName", minWidth: 100 }, |
| | | { label: "模板类型", prop: "businessName", minWidth: 120 }, |
| | | { |
| | | label: "审批类型", |
| | |
| | | prop: "unread", |
| | | width: 90, |
| | | align: "center", |
| | | dataType: "tag", |
| | | formatData: (v) => (v ? "是" : "否"), |
| | | formatType: (v) => (v ? "success" : "danger"), |
| | | }, |
| | | { |
| | | label: "审批状态", |
| | |
| | | { |
| | | name: "修改", |
| | | type: "text", |
| | | disabled: (row) => row.approvalStatus !== "pending", |
| | | disabled: (row) => row.approvalStatus !== "pending" || Number(row?.businessType) === 19, |
| | | clickFun: (row) => openEditDialog(row), |
| | | }, |
| | | { |
| | |
| | | disabled: (row) => row.approvalStatus !== "pending" || !row.isApprove, |
| | | clickFun: (row) => openApprove(row), |
| | | }, |
| | | { |
| | | name: "删除", |
| | | type: "danger", |
| | | clickFun: (row) => removeInstance(row), |
| | | }, |
| | | // { |
| | | // name: "删除", |
| | | // type: "danger", |
| | | // clickFun: (row) => removeInstance(row), |
| | | // }, |
| | | ], |
| | | }, |
| | | ]); |
| | |
| | | fetchBusinessTypeOptions(), |
| | | listApprovalTemplate(TEMPLATE_TYPE_CUSTOM), |
| | | ]); |
| | | submitBusinessTypeOptions.value = typeOptions; |
| | | submitBusinessTypeOptions.value = typeOptions.filter((x) => ![5, 6, 7].includes(x.value)); |
| | | allSubmitTemplates.value = unwrapTemplateList(customRes) |
| | | .filter((row) => mapEnabledFromApi(row.enabled)) |
| | | .map(mapSubmitTemplateCard); |
| | |
| | | await openReimburseDetail(row, "detail"); |
| | | return; |
| | | } |
| | | |
| | | detailRow.value = { ...row }; |
| | | // 报价审批:用审批事由字段承载的"报价单号"去查报价列表 |
| | | if (row.businessType === 6) { |
| | | const quotationNo = row?.quotationNo; |
| | | if (quotationNo) { |
| | | const res = await getQuotationList({ quotationNo }); |
| | | const records = res?.data?.records || []; |
| | | detailData.value = records[0] || {}; |
| | | } |
| | | } |
| | | |
| | | // 采购审批:用审批事由字段承载的"采购合同号"去查采购详情 |
| | | else if (row.businessType === 5) { |
| | | const purchaseContractNumber = row?.purchaseContractNumber; |
| | | if (purchaseContractNumber) { |
| | | const res = await getPurchaseByCode({ purchaseContractNumber }); |
| | | detailData.value = res || {}; |
| | | } |
| | | } |
| | | |
| | | // 发货审批:用审批事由字段承载的"发货单号"去查发货详情 |
| | | else if (row.businessType === 7) { |
| | | const shippingNo = row?.shippingNo; |
| | | if (shippingNo) { |
| | | const res = await getDeliveryDetailByShippingNo({ shippingNo }); |
| | | detailData.value = res?.data || res || {}; |
| | | } |
| | | } |
| | | |
| | | // 报工审批:直接展示审批填报内容 |
| | | else if (row.businessType === 19) { |
| | | detailData.value = {}; |
| | | detailRow.value = await mergeProductionReportDetail(detailRow.value); |
| | | } |
| | | |
| | | // 其他审批类型 |
| | | else { |
| | | detailData.value = {}; |
| | | } |
| | | |
| | | detailDialog.visible = true; |
| | | } |
| | | |
| | | async function openApprove(row) { |
| | | |
| | | if (inferReimburseModuleKeyFromInstance(row)) { |
| | | approveOpinion.value = ""; |
| | | await openReimburseDetail(row, "approve"); |
| | |
| | | } |
| | | approveDialog.row = { ...row }; |
| | | approveOpinion.value = ""; |
| | | // 报价审批:用审批事由字段承载的"报价单号"去查报价列表 |
| | | if (row.businessType === 6) { |
| | | const quotationNo = row?.quotationNo; |
| | | if (quotationNo) { |
| | | const res = await getQuotationList({ quotationNo }); |
| | | const records = res?.data?.records || []; |
| | | detailData.value = records[0] || {}; |
| | | } |
| | | } |
| | | |
| | | // 采购审批:用审批事由字段承载的"采购合同号"去查采购详情 |
| | | else if (row.businessType === 5) { |
| | | const purchaseContractNumber = row?.purchaseContractNumber; |
| | | if (purchaseContractNumber) { |
| | | const res = await getPurchaseByCode({ purchaseContractNumber }); |
| | | detailData.value = res || {}; |
| | | } |
| | | } |
| | | |
| | | // 发货审批:用审批事由字段承载的"发货单号"去查发货详情 |
| | | else if (row.businessType === 7) { |
| | | const shippingNo = row?.shippingNo; |
| | | if (shippingNo) { |
| | | const res = await getDeliveryDetailByShippingNo({ shippingNo }); |
| | | detailData.value = res?.data || res || {}; |
| | | } |
| | | } |
| | | |
| | | // 报工审批:直接展示审批填报内容 |
| | | else if (row.businessType === 19) { |
| | | detailData.value = {}; |
| | | approveDialog.row = await mergeProductionReportDetail(approveDialog.row); |
| | | } |
| | | |
| | | // 其他审批类型 |
| | | else { |
| | | detailData.value = {}; |
| | | } |
| | | approveDialog.visible = true; |
| | | } |
| | | |
| | | async function mergeProductionReportDetail(row) { |
| | | const businessId = row?.businessId ?? row?.bizId ?? row?.id; |
| | | if (!businessId) return row; |
| | | try { |
| | | const res = await productionProductMainGetInfo(businessId); |
| | | const report = res?.data || res || {}; |
| | | const formConfigPayload = row?.formConfig?.formPayload || {}; |
| | | const schedulingNum = Number( |
| | | report?.schedulingNum ?? report?.planQuantity ?? formConfigPayload.schedulingNum ?? row?.schedulingNum ?? 0 |
| | | ); |
| | | const finishedNum = Number( |
| | | report?.finishedNum ?? report?.quantity ?? formConfigPayload.finishedNum ?? row?.finishedNum ?? row?.quantity ?? 0 |
| | | ); |
| | | const scrapQty = Number( |
| | | report?.scrapQty ?? formConfigPayload.scrapQty ?? row?.scrapQty ?? 0 |
| | | ); |
| | | const pendingNum = Number( |
| | | formConfigPayload.pendingNum ?? report?.pendingNum ?? row?.pendingNum ?? Math.max(schedulingNum - finishedNum, 0) |
| | | ); |
| | | const reportTypeOptions = [ |
| | | { label: "合格", value: 0 }, |
| | | { label: "轻微返工", value: 1 }, |
| | | { label: "严重返工", value: 2 }, |
| | | { label: "报废", value: 3 }, |
| | | ]; |
| | | const mergedFields = [ |
| | | { key: "productNo", label: "报工单号", type: "text" }, |
| | | { key: "userName", label: "报工人员", type: "text" }, |
| | | { key: "teamInfo", label: "班组信息", type: "text" }, |
| | | { key: "workOrderNo", label: "工单编号", type: "text" }, |
| | | { key: "pendingNum", label: "待生产数量", type: "number", precision: 2 }, |
| | | { key: "finishedNum", label: "生产合格数量", type: "number", precision: 2 }, |
| | | { key: "scrapQty", label: "报废数量", type: "number", precision: 2 }, |
| | | { key: "reportType", label: "报工类型", type: "select", options: reportTypeOptions }, |
| | | ]; |
| | | const rawReportType = report?.reportType ?? row?.formPayload?.reportType ?? row?.reportType; |
| | | const reportType = Number.isFinite(Number(rawReportType)) ? Number(rawReportType) : 0; |
| | | const formPayload = { |
| | | productNo: report?.productNo || row?.productNo || row?.formPayload?.productNo || "—", |
| | | userName: report?.userName || row?.applicantName || row?.formPayload?.userName || "—", |
| | | teamInfo: report?.teamInfo || row?.applicantName || row?.formPayload?.teamInfo || "—", |
| | | workOrderNo: report?.workOrderNo || row?.workOrderNo || row?.formPayload?.workOrderNo || "—", |
| | | pendingNum, |
| | | finishedNum, |
| | | scrapQty, |
| | | reportType, |
| | | }; |
| | | const mergedRow = { |
| | | ...row, |
| | | schedulingNum, |
| | | pendingNum, |
| | | scrapQty, |
| | | finishedNum, |
| | | formFieldDefs: mergedFields, |
| | | formPayload, |
| | | formConfig: { |
| | | ...(typeof row.formConfig === "object" ? row.formConfig : {}), |
| | | ...(row?.formConfig?.formPayload ? { formPayload: { ...row.formConfig.formPayload } } : {}), |
| | | fields: mergedFields, |
| | | formPayload, |
| | | approvalType: "production_report", |
| | | }, |
| | | }; |
| | | return mergedRow; |
| | | } catch (error) { |
| | | console.error("加载报工审批业务详情失败", error); |
| | | } |
| | | return row; |
| | | } |
| | | |
| | | function isReimburseApprovalInstance(row) { |
| | |
| | | if (!row?.id) { |
| | | ElMessage.warning("无法修改:缺少审批实例 ID"); |
| | | return; |
| | | } |
| | | if (row.businessType === 19) { |
| | | row = await mergeProductionReportDetail(row); |
| | | } |
| | | submitDialog.mode = "edit"; |
| | | submitDialog.step = 3; |
| | |
| | | tableColumn, |
| | | detailDialog, |
| | | detailRow, |
| | | detailData, |
| | | reimburseDialog, |
| | | approveDialog, |
| | | approveOpinion, |