gaoluyang
4 天以前 6e173210a874ff7601aa68eab56e912f5619c79c
src/views/inventoryManagement/dispatchLog/Record.vue
@@ -1,37 +1,84 @@
<template>
   <div>
      <div class="search_form" style="margin-bottom: 10px;">
         <div>
            <span class="search_title ml10">出库日期:</span>
            <el-date-picker
               v-model="searchForm.timeStr"
    <div class="search_form" style="margin-bottom: 10px">
      <el-form
          ref="searchFormRef"
          :model="searchForm"
          class="demo-form-inline"
      >
        <el-row :gutter="20">
          <el-col :span="4">
            <el-form-item label="出库日期" prop="timeStr">
              <el-date-picker v-model="searchForm.timeStr"
               type="date"
               placeholder="请选择日期"
               value-format="YYYY-MM-DD"
               format="YYYY-MM-DD"
               clearable
               @change="handleQuery"
            />
        <span class="search_title ml10">来源:</span>
        <el-select v-model="searchForm.recordType"
                              clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <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-input v-model="searchForm.model"
                        style="width: 240px"
                        placeholder="请输入"
                        clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="批号" prop="batchNo">
              <el-input v-model="searchForm.batchNo"
                        style="width: 240px"
                        placeholder="请输入"
                        clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="来源" prop="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
            >
            </el-form-item>
          </el-col>
          <!-- 按钮 -->
          <el-col :span="4">
            <el-form-item>
              <el-button type="primary" @click="getList">
                搜索
              </el-button>
              <el-button @click="resetSearch">
                重置
              </el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
         </div>
         <div>
    <div class="actions">
            <el-button type="primary" @click="handleBatchApprove">审批</el-button>
            <el-button @click="handleOut">导出</el-button>
            <el-button type="danger" plain @click="handleDelete">删除</el-button>
            <el-button type="primary" plain @click="handlePrint">打印</el-button>
         </div>
      </div>
      <div class="table_list">
         <el-table
@@ -62,41 +109,32 @@
               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"
            >
                  {{ getApprovalStatusLabel(scope.row.approvalStatus) }}
            </el-tag>
               </template>
            </el-table-column>
         </el-table>
@@ -124,7 +162,8 @@
   batchApproveStockOutRecords,
} from "@/api/inventoryManagement/stockOut.js";
import {
  findAllQualifiedStockOutRecordTypeOptions, findAllUnQualifiedStockOutRecordTypeOptions,
  findAllQualifiedStockOutRecordTypeOptions,
  findAllUnQualifiedStockOutRecordTypeOptions,
} from "@/api/basicData/enum.js";
const userStore = useUserStore();
@@ -144,13 +183,13 @@
  type: {
    type: String,
    required: true,
    default: '0'
    default: "0",
  },
  topParentProductId: {
    type: [String, Number],
    default: undefined
  }
})
    default: undefined,
  },
});
// 打印相关
const printPreviewVisible = ref(false);
@@ -162,16 +201,18 @@
      supplierName: "",
      timeStr: "",
    recordType: "",
   }
  },
});
const { searchForm } = toRefs(data);
// 查询列表
/** 搜索按钮操作 */
const handleQuery = () => {
const searchFormRef = ref(null);
const resetSearch = () => {
  searchFormRef.value?.resetFields();
   page.current = 1;
   getList();
};
}
const paginationChange = (obj) => {
   page.current = obj.page;
   page.size = obj.limit;
@@ -179,7 +220,11 @@
};
const getList = () => {
   tableLoading.value = true;
   getStockOutPage({ ...searchForm.value, ...page, type: props.type, topParentProductId: props.topParentProductId })
  getStockOutPage({
    ...searchForm.value,
    ...page,
    topParentProductId: props.topParentProductId,
  })
      .then((res) => {
         tableLoading.value = false;
         tableData.value = res.data.records;
@@ -194,13 +239,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: "驳回",
@@ -216,20 +265,37 @@
   return approvalStatusLabelMap[status] || "待审批";
};
// 通过/驳回固定色;其余(含待审批、空值、未映射但文案为待审批)统一用 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";
  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) => {
@@ -285,7 +351,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("已取消");
@@ -324,17 +394,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 = `
@@ -494,7 +564,7 @@
            </div>
            <div class="info-row">
              <span class="label">单号:</span>
              <span class="value">${item.code || ''}</span>
              <span class="value">${item.code || ""}</span>
            </div>
          </div>
@@ -512,12 +582,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>
@@ -526,8 +596,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>
@@ -551,7 +623,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>
@@ -582,8 +654,6 @@
      }, 500);
   };
};
// 格式化日期
const formatDate = (dateString) => {
@@ -715,7 +785,8 @@
      border-collapse: collapse;
      border: 1px solid #000;
      
      th, td {
    th,
    td {
         border: 1px solid #000;
         padding: 6px;
         text-align: center;
@@ -786,4 +857,10 @@
      page-break-after: avoid;
   }
}
.actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
</style>