| | |
| | | }); |
| | | } |
| | | |
| | | // 生产报工详情 |
| | | export function productionProductMainGetInfo(id) { |
| | | return request({ |
| | | url: `/productionProductMain/${id}`, |
| | | method: "get", |
| | | }); |
| | | } |
| | |
| | | |
| | | /** 列表行 → 编辑表单(仅用行数据回显) */ |
| | | export function buildEditFormFromInstanceRow(row) { |
| | | const { fields, formPayload, templateSnapshot } = resolveInstanceFormFields(row); |
| | | let { fields, formPayload, templateSnapshot } = resolveInstanceFormFields(row); |
| | | if (Number(row?.businessType) === 19) { |
| | | const editableKeys = new Set(["finishedNum", "scrapQty", "reportType"]); |
| | | const lockedKeys = new Set(["productNo", "userName", "teamInfo", "workOrderNo", "schedulingNum", "pendingNum", "workHour", "auditStatus", "auditRemark"]); |
| | | const reportTypeOptions = [ |
| | | { label: "合格", value: 0 }, |
| | | { label: "轻微返工", value: 1 }, |
| | | { label: "严重返工", value: 2 }, |
| | | { label: "报废", value: 3 }, |
| | | ]; |
| | | fields = (fields || []) |
| | | .filter(field => String(field?.key || "") !== "schedulingNum") |
| | | .map(field => ({ |
| | | ...field, |
| | | label: String(field?.key || "") === "pendingNum" ? `${field.label}(只读)` : field.label, |
| | | options: String(field?.key || "") === "reportType" ? (field.options?.length ? field.options : reportTypeOptions) : field.options, |
| | | disabled: lockedKeys.has(String(field?.key || "")) ? true : !editableKeys.has(String(field?.key || "")), |
| | | })); |
| | | templateSnapshot = { |
| | | ...templateSnapshot, |
| | | fields, |
| | | }; |
| | | formPayload = { |
| | | ...formPayload, |
| | | }; |
| | | if (formPayload.pendingNum == null) { |
| | | const schedulingNum = Number(formPayload.schedulingNum ?? row?.schedulingNum ?? row?.planQuantity ?? 0); |
| | | const finishedNum = Number(formPayload.finishedNum ?? formPayload.quantity ?? row?.finishedNum ?? row?.quantity ?? 0); |
| | | formPayload.pendingNum = Math.max(schedulingNum - finishedNum, 0); |
| | | } |
| | | if (formPayload.finishedNum == null && formPayload.quantity != null) { |
| | | formPayload.finishedNum = formPayload.quantity; |
| | | } |
| | | if (formPayload.scrapQty == null && row?.scrapQty != null) { |
| | | formPayload.scrapQty = row.scrapQty; |
| | | } |
| | | if (formPayload.reportType != null && !Number.isNaN(Number(formPayload.reportType))) { |
| | | formPayload.reportType = Number(formPayload.reportType); |
| | | } |
| | | } |
| | | const normalized = normalizeFlowNodes(row?.flowNodes?.length ? row.flowNodes : mapTasksToFlowNodes(row?.tasks)); |
| | | const flowNodes = normalized.length ? JSON.parse(JSON.stringify(normalized)) : [createEmptyNode(1)]; |
| | | |
| | |
| | | <el-divider content-position="left">报工填报内容</el-divider> |
| | | <el-descriptions v-if="formResolved.fields.length" :column="2" border> |
| | | <el-descriptions-item |
| | | v-for="field in formResolved.fields" |
| | | v-for="field in visibleFormFields" |
| | | :key="field.key" |
| | | :label="field.label || field.key" |
| | | > |
| | |
| | | }); |
| | | |
| | | const formResolved = computed(() => resolveInstanceFormFields(props.row)); |
| | | const visibleFormFields = computed(() => |
| | | (formResolved.value.fields || []).filter(field => { |
| | | const key = String(field?.key || "").toLowerCase(); |
| | | const label = String(field?.label || "").trim(); |
| | | if (["approvalstatus", "auditstatus", "status", "workhours", "schedulingnum"].includes(key)) return false; |
| | | if (["审批状态", "审核状态", "工时", "排产数量"].includes(label)) return false; |
| | | return true; |
| | | }) |
| | | ); |
| | | |
| | | |
| | | // 是否为特殊审批类型(采购、发货、报价) |
| | |
| | | v-model="formPayload[field.key]" |
| | | :placeholder="`请输入${field.label}`" |
| | | maxlength="200" |
| | | :disabled="Boolean(field.disabled)" |
| | | /> |
| | | <el-input |
| | | v-else-if="field.type === 'textarea'" |
| | |
| | | :placeholder="`请填写${field.label}`" |
| | | maxlength="2000" |
| | | show-word-limit |
| | | :disabled="Boolean(field.disabled)" |
| | | /> |
| | | <el-input-number |
| | | v-else-if="field.type === 'number'" |
| | |
| | | :precision="field.precision ?? 0" |
| | | controls-position="right" |
| | | style="width: 100%" |
| | | :disabled="Boolean(field.disabled)" |
| | | /> |
| | | <el-date-picker |
| | | v-else-if="field.type === 'date'" |
| | |
| | | format="YYYY-MM-DD" |
| | | value-format="YYYY-MM-DD" |
| | | style="width: 100%" |
| | | :disabled="Boolean(field.disabled)" |
| | | /> |
| | | <el-date-picker |
| | | v-else-if="field.type === 'datetimerange'" |
| | |
| | | format="YYYY-MM-DD HH:mm:ss" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | style="width: 100%" |
| | | :disabled="Boolean(field.disabled)" |
| | | /> |
| | | <el-select |
| | | v-else-if="field.type === 'select'" |
| | |
| | | style="width: 100%" |
| | | clearable |
| | | filterable |
| | | :disabled="Boolean(field.disabled)" |
| | | > |
| | | <el-option |
| | | v-for="o in getOptions(field)" |
| | |
| | | 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"; |
| | |
| | | { |
| | | name: "修改", |
| | | type: "text", |
| | | disabled: (row) => row.approvalStatus !== "pending", |
| | | disabled: (row) => row.approvalStatus !== "pending" || Number(row?.businessType) === 19, |
| | | clickFun: (row) => openEditDialog(row), |
| | | }, |
| | | { |
| | |
| | | // 报工审批:直接展示审批填报内容 |
| | | else if (row.businessType === 19) { |
| | | detailData.value = {}; |
| | | detailRow.value = await mergeProductionReportDetail(detailRow.value); |
| | | } |
| | | |
| | | // 其他审批类型 |
| | |
| | | // 报工审批:直接展示审批填报内容 |
| | | else if (row.businessType === 19) { |
| | | detailData.value = {}; |
| | | approveDialog.row = await mergeProductionReportDetail(approveDialog.row); |
| | | } |
| | | |
| | | // 其他审批类型 |
| | |
| | | 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) { |
| | |
| | | ElMessage.warning("无法修改:缺少审批实例 ID"); |
| | | return; |
| | | } |
| | | if (row.businessType === 19) { |
| | | row = await mergeProductionReportDetail(row); |
| | | } |
| | | submitDialog.mode = "edit"; |
| | | submitDialog.step = 3; |
| | | submitEditRow.value = { ...row }; |