huminmin
4 天以前 1daa22ed05c77e4a8c3069124a1849d5d6504f69
src/views/officeProcessAutomation/ApproveManage/approve-list/approveListConstants.js
@@ -560,7 +560,46 @@
/** 列表行 → 编辑表单(仅用行数据回显) */
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)];