liding
5 天以前 ea3e27a9b7cb6d0524073fb0c67000fba875b5fb
src/views/inventoryManagement/dispatchLog/Record.vue
@@ -1,6 +1,6 @@
<template>
   <div>
      <div class="search_form" style="margin-bottom: 10px;">
    <div class="search_form" style="margin-bottom: 10px">
         <div>
            <span class="search_title ml10">出库日期:</span>
            <el-date-picker
@@ -13,14 +13,18 @@
               @change="handleQuery"
            />
        <span class="search_title ml10">来源:</span>
        <el-select v-model="searchForm.recordType"
        <el-select
          v-model="searchForm.recordType"
                   style="width: 240px"
                   placeholder="请选择"
                   clearable>
          <el-option v-for="item in stockRecordTypeOptions"
          clearable
        >
          <el-option
            v-for="item in stockRecordTypeOptions"
                     :key="item.value"
                     :label="item.label"
                     :value="item.value"/>
            :value="item.value"
          />
        </el-select>
            <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
            >搜索</el-button
@@ -62,41 +66,30 @@
               prop="productName"
               show-overflow-tooltip
            />
            <el-table-column
               label="规格型号"
               prop="model"
               show-overflow-tooltip
            />
            <el-table-column
               label="批号"
               prop="batchNo"
               show-overflow-tooltip
            />
            <el-table-column
               label="单位"
               prop="unit"
               show-overflow-tooltip
            />
        <el-table-column label="规格型号" prop="model" show-overflow-tooltip />
        <el-table-column label="批号" prop="batchNo" show-overflow-tooltip />
        <el-table-column label="单位" prop="unit" show-overflow-tooltip />
            <el-table-column
               label="出库数量"
               prop="stockOutNum"
               show-overflow-tooltip
            />
            <el-table-column
               label="出库人"
               prop="createBy"
               show-overflow-tooltip
            />
        <el-table-column label="来源"
                         prop="recordType"
                         show-overflow-tooltip>
        <el-table-column label="出库人" prop="createBy" show-overflow-tooltip />
        <el-table-column label="来源" prop="recordType" show-overflow-tooltip>
          <template #default="scope">
            {{ getRecordType(scope.row.recordType) }}
          </template>
        </el-table-column>
            <el-table-column label="审批状态" prop="approvalStatus" show-overflow-tooltip>
        <el-table-column
          label="审批状态"
          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>
@@ -126,7 +119,8 @@
   batchApproveStockOutRecords,
} from "@/api/inventoryManagement/stockOut.js";
import {
  findAllQualifiedStockOutRecordTypeOptions, findAllUnQualifiedStockOutRecordTypeOptions,
  findAllQualifiedStockOutRecordTypeOptions,
  findAllUnQualifiedStockOutRecordTypeOptions,
} from "@/api/basicData/enum.js";
const userStore = useUserStore();
@@ -146,13 +140,13 @@
  type: {
    type: String,
    required: true,
    default: '0'
    default: "0",
  },
  topParentProductId: {
    type: [String, Number],
    default: undefined
  }
})
    default: undefined,
  },
});
// 打印相关
const printPreviewVisible = ref(false);
@@ -164,7 +158,7 @@
      supplierName: "",
      timeStr: "",
    recordType: "",
   }
  },
});
const { searchForm } = toRefs(data);
@@ -181,7 +175,11 @@
};
const getList = () => {
   tableLoading.value = true;
   getStockOutPage({ ...searchForm.value, ...page,  topParentProductId: props.topParentProductId })
  getStockOutPage({
    ...searchForm.value,
    ...page,
    topParentProductId: props.topParentProductId,
  })
      .then((res) => {
         tableLoading.value = false;
         tableData.value = res.data.records;
@@ -196,13 +194,17 @@
};
const getRecordType = (recordType) => {
  return stockRecordTypeOptions.value.find(item => item.value === recordType)?.label || ''
}
  return (
    stockRecordTypeOptions.value.find((item) => item.value === recordType)
      ?.label || ""
  );
};
const approvalStatusLabelMap = {
   0: "待审批",
   1: "通过",
   2: "驳回",
  3: "待确认",
   pending: "待审批",
   approved: "通过",
   rejected: "驳回",
@@ -220,25 +222,35 @@
// 通过/驳回固定色;其余(含待审批、空值、未映射但文案为待审批)统一用 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";
  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 fetchStockRecordTypeOptions = () => {
  if (props.type === '0') {
    findAllQualifiedStockOutRecordTypeOptions()
        .then(res => {
  if (props.type === "0") {
    findAllQualifiedStockOutRecordTypeOptions().then((res) => {
          stockRecordTypeOptions.value = res.data;
        })
    return
    });
    return;
  }
  findAllUnQualifiedStockOutRecordTypeOptions()
      .then(res => {
  findAllUnQualifiedStockOutRecordTypeOptions().then((res) => {
        stockRecordTypeOptions.value = res.data;
      })
}
  });
};
// 表格选择数据
const handleSelectionChange = (selection) => {
@@ -294,7 +306,11 @@
      type: "warning",
   })
      .then(() => {
         proxy.download("/stockOutRecord/exportStockOutRecord", {type: props.type}, props.type === '0' ? "合格出库台账.xlsx" : "不合格出库台账.xlsx");
      proxy.download(
        "/stockOutRecord/exportStockOutRecord",
        { type: props.type },
        props.type === "0" ? "合格出库台账.xlsx" : "不合格出库台账.xlsx"
      );
      })
      .catch(() => {
         proxy.$modal.msg("已取消");
@@ -333,17 +349,17 @@
      return;
   }
   printData.value = [...selectedRows.value];
   console.log('打印数据:', printData.value);
  console.log("打印数据:", printData.value);
   printPreviewVisible.value = true;
};
// 执行打印
const executePrint = () => {
   console.log('开始执行打印,数据条数:', printData.value.length);
   console.log('打印数据:', printData.value);
  console.log("开始执行打印,数据条数:", printData.value.length);
  console.log("打印数据:", printData.value);
   
   // 创建一个新的打印窗口
   const printWindow = window.open('', '_blank', 'width=800,height=600');
  const printWindow = window.open("", "_blank", "width=800,height=600");
   
   // 构建打印内容
   let printContent = `
@@ -503,7 +519,7 @@
            </div>
            <div class="info-row">
              <span class="label">单号:</span>
              <span class="value">${item.code || ''}</span>
              <span class="value">${item.code || ""}</span>
            </div>
          </div>
@@ -521,12 +537,12 @@
              </thead>
              <tbody>
                <tr>
                  <td>${item.productName || '砂灰砖'}</td>
                  <td>${item.model || '标准'}</td>
                  <td>${item.unit || '块'}</td>
                  <td>${item.taxInclusiveUnitPrice || '0'}</td>
                  <td>${item.inboundNum || '2000'}</td>
                  <td>${item.taxInclusiveTotalPrice || '0'}</td>
                  <td>${item.productName || "砂灰砖"}</td>
                  <td>${item.model || "标准"}</td>
                  <td>${item.unit || "块"}</td>
                  <td>${item.taxInclusiveUnitPrice || "0"}</td>
                  <td>${item.inboundNum || "2000"}</td>
                  <td>${item.taxInclusiveTotalPrice || "0"}</td>
                </tr>
              </tbody>
              <tfoot>
@@ -535,8 +551,10 @@
                  <td class="total-value"></td>
                  <td class="total-value"></td>
                  <td class="total-value"></td>
                  <td class="total-value">${item.inboundNum || '2000'}</td>
                  <td class="total-value">${item.taxInclusiveTotalPrice || '0'}</td>
                  <td class="total-value">${item.inboundNum || "2000"}</td>
                  <td class="total-value">${
                    item.taxInclusiveTotalPrice || "0"
                  }</td>
                </tr>
              </tfoot>
            </table>
@@ -560,7 +578,7 @@
            <div class="footer-row">
              <div class="footer-item">
                <span class="label">操作员:</span>
                <span class="value">${userStore.nickName || '撕开前'}</span>
                <span class="value">${userStore.nickName || "撕开前"}</span>
              </div>
              <div class="footer-item">
                <span class="label">打印日期:</span>
@@ -591,8 +609,6 @@
      }, 500);
   };
};
// 格式化日期
const formatDate = (dateString) => {
@@ -724,7 +740,8 @@
      border-collapse: collapse;
      border: 1px solid #000;
      
      th, td {
    th,
    td {
         border: 1px solid #000;
         padding: 6px;
         text-align: center;