ZN
2026-03-19 a74fb3a81cce704299f765078ababc7a743bab9d
src/views/productionManagement/productionReporting/index.vue
@@ -19,19 +19,10 @@
                    style="width: 200px;"
                    @change="handleQuery" />
        </el-form-item>
        <el-form-item label="工单状态:">
          <el-select v-model="searchForm.workOrderStatus"
                     placeholder="请选择工单状态"
                     style="width: 140px"
                     clearable>
            <el-option label="待确认"
                       :value="1"></el-option>
            <el-option label="待生产"
                       :value="2"></el-option>
            <el-option label="生产中"
                       :value="3"></el-option>
            <el-option label="已生产"
                       :value="4"></el-option>
        <el-form-item label="审核状态:">
          <el-select v-model="searchForm.auditStatus" placeholder="请选择" style="width: 200px;" @change="handleQuery">
              <el-option v-for="item in auditStatusOptions" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
@@ -115,7 +106,7 @@
              </template>
            </el-table-column>
            <el-table-column label="操作"
                             width="60">
                             >
              <template #default="scope">
                <el-button link
                           type="primary"
@@ -134,42 +125,83 @@
        </template>
      </PIMTable>
    </div>
    <el-dialog
      v-model="auditDialogVisible"
      title="审核意见"
      width="1200px"
      :close-on-click-modal="false"
    >
      <!-- 审核表单 -->
      <div style=" padding: 15px; border-radius: 4px;">
        <el-form ref="auditFormRef" :model="form" :rules="auditFormRules" label-width="100px">
          <el-form-item label="审核结果" prop="auditResult">
            <el-radio-group v-model="form.auditResult" @change="handleAuditResultChange" size="large">
              <el-radio label=1 >通过</el-radio>
              <el-radio label=2 >不通过</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="备注意见" prop="remarks">
            <el-input
              v-model="form.remarks"
              type="textarea"
              :rows="4"
              placeholder="请输入备注或意见(不通过时为必填)"
              maxlength="500"
              show-word-limit
            />
          </el-form-item>
        </el-form>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="primary" @click="submitAudit">提交审核</el-button>
          <el-button :disabled="auditLoading" @click="auditDialogVisible = false">取消</el-button>
        </span>
      </template>
    </el-dialog>
    <form-dia ref="formDia"
              @close="handleQuery"></form-dia>
    <input-modal v-if="isShowInput"
                 v-model:visible="isShowInput"
                 :production-product-main-id="isShowingId" />
    <output-modal v-if="isShowOutput"
                  v-model:visible="isShowOutput"
                  :production-product-main-id="isShowingId" />
  </div>
</template>
<script setup>
  import { onMounted, ref } from "vue";
  import { onMounted, ref, reactive, toRefs, nextTick, getCurrentInstance } from "vue";
  import FormDia from "@/views/productionManagement/productionReporting/components/formDia.vue";
  import { ElMessageBox } from "element-plus";
  import { ElMessageBox, ElMessage } from "element-plus";
  import {
    productionReportUpdate,
    workListPageById,
    productionReportDelete,
  } from "@/api/productionManagement/productionReporting.js";
  import { productionProductMainListPage } from "@/api/productionManagement/productionProductMain.js";
  import { productionProductMainListPage, productAudit } from "@/api/productionManagement/productionProductMain.js";
  import { userListNoPageByTenantId } from "@/api/system/user.js";
  import InputModal from "@/views/productionManagement/productionReporting/Input.vue";
  import OutputModal from "@/views/productionManagement/productionReporting/Output.vue";
  const data = reactive({
    searchForm: {
      nickName: "",
      workOrderNo: "",
      workOrderStatus: "",
      auditStatus: "", // 审核状态
    },
  });
  const { searchForm } = toRefs(data);
  const expandedRowKeys = ref([]);
  const auditDialogVisible = ref(false);
  const auditRowData = ref(null);
  const auditTableData = ref([]);
  const auditLoading = ref(false);
  const expandData = ref([]);
  const userList = ref([]);
  const auditStatusOptions = ref([
    { label: "未审核", value: 0 },
    { label: "通过", value: 1 },
    { label: "不通过", value: 2 },
  ]);
  const tableColumn = ref([
    {
      label: "报工单号",
@@ -182,84 +214,75 @@
      width: 120,
    },
    {
      label: "工序",
      prop: "process",
      width: 120,
    },
    {
      label: "工单编号",
      prop: "workOrderNo",
      width: 120,
    },
    {
      label: "报工状态",
      prop: "status",
      label: "销售合同号",
      prop: "salesContractNo",
      width: 120,
    },
    {
      label: "产品名称",
      prop: "productName",
      width: 120,
    },
    {
      label: "产品规格型号",
      prop: "productModelName",
      width: 120,
    },
    {
      label: "产出数量",
      prop: "quantity",
      width: 120,
    },
    {
      label: "报废数量",
      prop: "scrapQty",
      width: 120,
    },
    {
      label: "单位",
      prop: "unit",
      width: 120,
    },
    {
      label: "审核人",
      prop: "auditUserName",
      width: 120,
    },
    {
      label: "审核状态",
      prop: "auditStatus",
      width: 120,
      dataType: "tag",
      formatData: params => {
        if (params == 3) {
          return "已报工";
        } else if (params == 1) {
          return "待生产";
        } else {
          return "生产中";
        }
      formatData: val => {
        const statusMap = { 0: "未审核", 1: "通过", 2: "不通过" };
        return statusMap[val] ?? "未知";
      },
      formatType: params => {
        if (params == 3) {
          return "success";
        } else if (params == 1) {
          return "primary";
        } else {
          return "warning";
        }
      formatType: val => {
        const typeMap = { 0: "info", 1: "success", 2: "danger" };
        return typeMap[val] ?? "";
      },
    },
    {
      label: "工单状态",
      prop: "workOrderStatus",
      dataType: "tag",
      formatData: params => {
        switch (params) {
          case "1":
            return "待确认";
          case "2":
            return "待生产";
          case "3":
            return "生产中";
          case "4":
            return "已生产";
          default:
            return "";
        }
      },
      formatType: params => {
        switch (params) {
          case "1":
            return "primary";
          case "2":
            return "info";
          case "3":
            return "warning";
          case "4":
            return "success";
          default:
            return "";
        }
      },
    },
    {
      label: "生产时间",
      label: "创建时间",
      prop: "createTime",
      width: 120,
      formatData: params => {
        const date = new Date(params);
        return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(
          2,
          "0"
        )}-${String(date.getDate()).padStart(2, "0")}`;
      },
    },
    {
      dataType: "action",
      label: "操作",
      align: "center",
      fixed: "right",
      width: 230,
      width: 200,
      operation: [
        {
          name: "查看投入",
@@ -269,11 +292,13 @@
          },
        },
        {
          name: "查看产出",
          type: "text",
          name:"审核",
          // 黄色
          color: "#E6A23C",
          clickFun: row => {
            showOutput(row);
            handleAudit(row);
          },
          showHide: row => Number(row?.auditStatus) === 0, // 仅当未审核时显示审核按钮
        },
        {
          name: "删除",
@@ -296,6 +321,26 @@
  });
  const formDia = ref();
  const { proxy } = getCurrentInstance();
  const auditFormRef = ref(null);
  const auditFormRules = ref({
    auditResult: [{ required: true, message: "请选择审核结果", trigger: "change" }],
    remarks: [
      {
        validator: (rule, value, callback) => {
          if (form.value.auditResult === "2" && (!value || value.trim() === "")) {
            callback(new Error("不通过时必须填写备注或意见"));
          } else {
            callback();
          }
        },
        trigger: ["change", "blur"],
      },
    ],
  });
  const form = ref({
    auditResult: 1,
    remarks: "",
  });
  // 查询列表
  /** 搜索按钮操作 */
@@ -452,11 +497,69 @@
    isShowingId.value = row.id;
  };
  // 打开产出模态框
  const isShowOutput = ref(false);
  const showOutput = row => {
    isShowOutput.value = true;
    isShowingId.value = row.id;
   // 审核
  const handleAudit = (row) => {
    if (Number(row?.auditStatus) === 1) {
      ElMessage.warning("该工单已审核");
      return;
    }
    // 重置表单,默认选择通过
    form.value = {
      auditResult: "1",
      remarks: "",
    };
    auditRowData.value = row;
    const workOrderNo = row?.workOrderNo;
    const related = workOrderNo
      ? tableData.value.filter(r => r?.workOrderNo === workOrderNo)
      : [];
    auditTableData.value = related.length > 0 ? related : [row];
    auditDialogVisible.value = true;
    nextTick(() => {
      auditFormRef.value?.clearValidate();
    });
  };
  // 审核结果变更
  const handleAuditResultChange = () => {
    if (form.value.auditResult === "1") {
      // 切换为通过时清除备注校验
      auditFormRef.value?.clearValidate("remarks");
    } else {
      // 切换为不通过时重新触发备注校验
      auditFormRef.value?.validateField("remarks");
    }
  };
  // 提交审核
  const submitAudit = (auditResult) => {
    auditFormRef.value?.validate().then(() => {
      auditLoading.value = true;
      const auditData = {
        id: auditRowData.value.id,
        auditStatus: Number(form.value.auditResult),
        auditOpinion: form.value.remarks,
      };
      // 调用报工审批API
      productAudit(auditData)
        .then(res => {
          if (res.code === 200) {
            proxy.$modal.msgSuccess(auditResult === 1 ? "审核通过" : "审核不通过");
            auditDialogVisible.value = false;
            getList();
          } else {
            proxy.$modal.msgError(res.msg || "审核失败");
          }
        })
        .catch(err => {
          proxy.$modal.msgError("审核失败");
        })
        .finally(() => {
          auditLoading.value = false;
        });
    }).catch(() => {
      // 验证失败
    });
  };
  // 导出
@@ -467,7 +570,7 @@
      type: "warning",
    })
      .then(() => {
        proxy.download("/salesLedger/work/export", {}, "生产报工.xlsx");
        proxy.download("/productionProductMain/export", {}, "生产报工.xlsx");
      })
      .catch(() => {
        proxy.$modal.msg("已取消");