gongchunyi
2026-05-28 19f2e3bdbe04e7ea79c6a0bdc8c7318d4837b189
src/views/inventoryManagement/receiptManagement/Record.vue
@@ -1,14 +1,14 @@
<template>
  <div>
    <div class="search_form" style="margin-bottom: 10px;">
      <el-form
          ref="searchFormRef"
    <div class="search_form"
         style="margin-bottom: 10px;">
      <el-form ref="searchFormRef"
          :model="searchForm"
          class="demo-form-inline"
      >
               class="demo-form-inline">
        <el-row :gutter="20">
          <el-col :span="4">
            <el-form-item label="入库日期" prop="timeStr">
            <el-form-item label="入库日期"
                          prop="timeStr">
              <el-date-picker v-model="searchForm.timeStr"
                              type="date"
                              placeholder="请选择日期"
@@ -18,16 +18,17 @@
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="产品大类" prop="productName">
            <el-form-item label="产品大类"
                          prop="productName">
              <el-input v-model="searchForm.productName"
                        style="width: 240px"
                        placeholder="请输入"
                        clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="产品规格" prop="model">
            <el-form-item label="规格型号"
                          prop="model">
              <el-input v-model="searchForm.model"
                        style="width: 240px"
                        placeholder="请输入"
@@ -35,7 +36,8 @@
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="批号" prop="batchNo">
            <el-form-item label="批号"
                          prop="batchNo">
              <el-input v-model="searchForm.batchNo"
                        style="width: 240px"
                        placeholder="请输入"
@@ -43,7 +45,8 @@
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="来源" prop="recordType">
            <el-form-item label="来源"
                          prop="recordType">
              <el-select v-model="searchForm.recordType"
                         style="width: 240px"
                         placeholder="请选择"
@@ -58,10 +61,10 @@
          <!-- 按钮 -->
          <el-col :span="4">
            <el-form-item>
              <el-button type="primary" @click="getList">
              <el-button type="primary"
                         @click="getList">
                搜索
              </el-button>
              <el-button @click="resetSearch">
                重置
              </el-button>
@@ -132,8 +135,7 @@
            {{ getRecordType(scope.row.recordType) }}
          </template>
        </el-table-column>
        <el-table-column
            v-if="showSourceOrderNoColumn"
        <el-table-column v-if="showSourceOrderNoColumn"
            label="源单号"
            width="150"
            prop="sourceOrderNo"
@@ -146,7 +148,8 @@
                         prop="approvalStatus"
                         show-overflow-tooltip>
          <template #default="scope">
            <el-tag :type="getApprovalStatusTagType(scope.row.approvalStatus)" size="small">
            <el-tag :type="getApprovalStatusTagType(scope.row.approvalStatus)"
                    size="small">
              {{ getApprovalStatusLabel(scope.row.approvalStatus) }}
            </el-tag>
          </template>
@@ -190,13 +193,13 @@
  type: {
    type: String,
    required: true,
    default: '0'
      default: "0",
  },
  topParentProductId: {
    type: [String, Number],
    default: undefined
  }
})
      default: undefined,
    },
  });
const tableData = ref([]);
const selectedRows = ref([]);
@@ -225,11 +228,14 @@
  searchFormRef.value?.resetFields();
  page.current = 1;
  getList();
}
  };
const getRecordType = (recordType) => {
  return stockRecordTypeOptions.value.find(item => item.value === recordType)?.label || ''
}
  const getRecordType = recordType => {
    return (
      stockRecordTypeOptions.value.find(item => item.value === recordType)
        ?.label || ""
    );
  };
const approvalStatusLabelMap = {
  0: "待审批",
@@ -244,7 +250,7 @@
};
approvalStatusLabelMap[3] = "待确认";
const getApprovalStatusLabel = (status) => {
  const getApprovalStatusLabel = status => {
  if (status === null || status === undefined || status === "") {
    return "待审批";
  }
@@ -252,32 +258,64 @@
};
// 通过/驳回固定色;其余(含待审批、空值、未映射但文案为待审批)统一用 warning 预警色
const getApprovalStatusTagType = (status) => {
  if (status === 1 || status === "1" || status === "approved" || status === "APPROVED") return "success";
  if (status === 2 || status === "2" || status === "rejected" || status === "REJECTED") return "danger";
  const getApprovalStatusTagType = status => {
    if (
      status === 1 ||
      status === "1" ||
      status === "approved" ||
      status === "APPROVED"
    )
      return "success";
    if (
      status === 2 ||
      status === "2" ||
      status === "rejected" ||
      status === "REJECTED"
    )
      return "danger";
  return "warning";
};
const isPendingApproval = status => {
  return status === 0 || status === "0" || status === "pending" || status === "PENDING" || status === null || status === undefined || status === "";
    return (
      status === 0 ||
      status === "0" ||
      status === "pending" ||
      status === "PENDING" ||
      status === null ||
      status === undefined ||
      status === ""
    );
};
const isRejectedApproval = status => {
  return status === 2 || status === "2" || status === "rejected" || status === "REJECTED";
    return (
      status === 2 ||
      status === "2" ||
      status === "rejected" ||
      status === "REJECTED"
    );
};
const isRowSelectable = row => {
  return isPendingApproval(row?.approvalStatus) || isRejectedApproval(row?.approvalStatus);
    return (
      isPendingApproval(row?.approvalStatus) ||
      isRejectedApproval(row?.approvalStatus)
    );
};
const canBatchApprove = computed(() => {
  return selectedRows.value.length > 0
      && selectedRows.value.every(row => isPendingApproval(row.approvalStatus));
    return (
      selectedRows.value.length > 0 &&
      selectedRows.value.every(row => isPendingApproval(row.approvalStatus))
    );
});
const canReverseApprove = computed(() => {
  return selectedRows.value.length > 0
      && selectedRows.value.every(row => isRejectedApproval(row.approvalStatus));
    return (
      selectedRows.value.length > 0 &&
      selectedRows.value.every(row => isRejectedApproval(row.approvalStatus))
    );
});
const canDelete = computed(() => canBatchApprove.value);
@@ -286,7 +324,7 @@
  return topParentProductId === 276 || topParentProductId === 278;
});
const formatSourceOrderNo = (value) => {
  const formatSourceOrderNo = value => {
  const text = String(value ?? "").trim();
  return text || "--";
};
@@ -299,33 +337,44 @@
const getList = () => {
  tableLoading.value = true;
  getStockInRecordListPage(Object.assign({}, {...searchForm.value, ...page,  topParentProductId: props.topParentProductId}))
    getStockInRecordListPage(
      Object.assign(
        {},
        {
          ...searchForm.value,
          ...page,
          topParentProductId: props.topParentProductId,
        }
      )
    )
      .then(res => {
        tableData.value = res.data.records;
        total.value = res.data.total || 0;
      }).finally(() => {
    tableLoading.value = false;
  })
      .finally(() => {
        tableLoading.value = false;
      });
};
// 获取来源类型选项
const fetchStockRecordTypeOptions = () => {
  if (props.type === '0') {
    findAllQualifiedStockInRecordTypeOptions()
        .then(res => {
    if (props.type === "0") {
      findAllQualifiedStockInRecordTypeOptions().then(res => {
          stockRecordTypeOptions.value = res.data;
        })
    return
      });
      return;
  }
  // findAllUnQualifiedStockInRecordTypeOptions()
  //     .then(res => {
  //       stockRecordTypeOptions.value = res.data;
  //     })
}
  };
// 表格选择数据
const handleSelectionChange = selection => {
  selectedRows.value = selection.filter(item => item.id && isRowSelectable(item));
    selectedRows.value = selection.filter(
      item => item.id && isRowSelectable(item)
    );
};
const expandedRowKeys = ref([]);
@@ -378,7 +427,7 @@
              proxy.$modal.msgError("审批通过失败");
            });
      })
      .catch((action) => {
      .catch(action => {
        if (action === "cancel") {
          batchApproveStockInRecords({ids, approvalStatus: 2})
              .then(() => {
@@ -403,7 +452,11 @@
  })
      .then(() => {
        // 根据不同的 tab 类型调用不同的导出接口
        proxy.download("/stockInRecord/exportStockInRecord", {type: props.type}, props.type === '0' ? "合格入库.xlsx" : "不合格入库.xlsx");
        proxy.download(
          "/stockInRecord/exportStockInRecord",
          { type: props.type },
          props.type === "0" ? "合格入库.xlsx" : "不合格入库.xlsx"
        );
      })
      .catch(() => {
        proxy.$modal.msg("已取消");