src/views/inventoryManagement/dispatchLog/Record.vue
@@ -12,9 +12,28 @@
               clearable
               @change="handleQuery"
            />
        <span class="search_title ml10">来源:</span>
        <el-select v-model="searchForm.recordType"
                   style="width: 240px"
                   placeholder="请选择"
                   clearable>
          <el-option v-for="item in stockRecordTypeOptions"
                     :key="item.value"
                     :label="item.label"
                     :value="item.value"/>
        </el-select>
        <span class="search_title ml10">质检状态:</span>
        <el-select v-model="searchForm.type"
                  style="width: 240px"
                  placeholder="请选择"
                  clearable>
          <el-option label="合格" :value="0" />
          <el-option label="不合格" :value="1" />
        </el-select>
            <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
            >搜索</el-button
            >
            <el-button @click="handleReset">重置</el-button>
         </div>
         <div>
            <el-button @click="handleOut">导出</el-button>
@@ -52,7 +71,7 @@
               show-overflow-tooltip
            />
            <el-table-column
               label="规格型号"
               label="图纸编号"
               prop="model"
               show-overflow-tooltip
            />
@@ -66,11 +85,28 @@
               prop="stockOutNum"
               show-overflow-tooltip
            />
            <el-table-column label="质检状态"
                         prop="type"
                         show-overflow-tooltip
                         width="100">
          <template #default="scope">
            <el-tag :type="scope.row.type == 0 ? 'success' : 'danger'" size="small">
              {{ scope.row.type == 0 ? '合格' : '不合格' }}
            </el-tag>
          </template>
        </el-table-column>
            <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>
         <pagination
            v-show="total > 0"
@@ -86,7 +122,7 @@
<script setup>
import pagination from "@/components/PIMTable/Pagination.vue";
import { ref } from "vue";
import { ref, watch } from "vue";
import { ElMessageBox } from "element-plus";
import useUserStore from "@/store/modules/user";
import { getCurrentDate } from "@/utils/index.js";
@@ -94,12 +130,17 @@
   getStockOutPage,
   delStockOut,
} from "@/api/inventoryManagement/stockOut.js";
import {
  findAllQualifiedStockOutRecordTypeOptions, findAllUnQualifiedStockOutRecordTypeOptions,
} from "@/api/basicData/enum.js";
const userStore = useUserStore();
const { proxy } = getCurrentInstance();
const tableData = ref([]);
const selectedRows = ref([]);
const tableLoading = ref(false);
// 来源类型选项
const stockRecordTypeOptions = ref([]);
const page = reactive({
   current: 1,
   size: 100,
@@ -108,9 +149,9 @@
const props = defineProps({
  type: {
    type: String,
    type: Number,
    required: true,
    default: '0'
    default: 1
  }
})
@@ -123,26 +164,9 @@
   searchForm: {
      supplierName: "",
      timeStr: "",
   },
   form: {
      supplierId: null,
      supplierName: '',
      productId: null,
      productName: '',
      userId: userStore.userId,
      nickName: '',
      model: '',
      productModelId: null,
      unit: '',
      productrecordId: null,
      taxInclusiveUnitPrice: '',
      taxInclusiveTotalPrice: '',
      taxRate: '',
      taxExclusiveTotalPrice: '',
      inboundTime: '',
      inboundBatch: '',
      inboundQuantity: ''
   },
    recordType: "",
    type: "",
   }
});
const { searchForm } = toRefs(data);
@@ -152,6 +176,15 @@
   page.current = 1;
   getList();
};
/** 重置按钮操作 */
const handleReset = () => {
  searchForm.value.supplierName = "";
  searchForm.value.timeStr = "";
  searchForm.value.recordType = "";
  searchForm.value.type = "";
  handleQuery();
};
const paginationChange = (obj) => {
   page.current = obj.page;
   page.size = obj.limit;
@@ -159,7 +192,11 @@
};
const getList = () => {
   tableLoading.value = true;
   getStockOutPage({ ...searchForm.value, ...page, type: props.type })
   const params = { ...searchForm.value, ...page, productType: props.type };
  if (searchForm.value.type !== "") {
    params.type = searchForm.value.type;
  }
   getStockOutPage(params)
      .then((res) => {
         tableLoading.value = false;
         tableData.value = res.data.records;
@@ -172,6 +209,35 @@
         tableLoading.value = false;
      });
};
const getRecordType = (recordType) => {
  return stockRecordTypeOptions.value.find(item => item.value === recordType)?.label || ''
}
// 获取来源类型选项
const fetchStockRecordTypeOptions = () => {
  Promise.all([
    findAllQualifiedStockOutRecordTypeOptions(),
    findAllUnQualifiedStockOutRecordTypeOptions()
  ])
    .then(([qualifiedRes, unQualifiedRes]) => {
      const qualifiedData = qualifiedRes.data || [];
      const unQualifiedData = unQualifiedRes.data || [];
      const allData = [...qualifiedData, ...unQualifiedData];
      const uniqueData = [];
      const valueSet = new Set();
      allData.forEach(item => {
        if (!valueSet.has(item.value)) {
          valueSet.add(item.value);
          uniqueData.push(item);
        }
      });
      stockRecordTypeOptions.value = uniqueData;
    })
    .catch(() => {
      stockRecordTypeOptions.value = [];
    });
}
// 表格选择数据
const handleSelectionChange = (selection) => {
@@ -189,7 +255,12 @@
      type: "warning",
   })
      .then(() => {
         proxy.download("/stockmanagement/export", {}, "出库台账.xlsx");
         const fileNameMap = {
        1: '自制出库台账.xlsx',
        2: '外购出库台账.xlsx',
        3: '委外出库台账.xlsx'
      };
         proxy.download("/stockOutRecord/exportStockOutRecord", {productType: props.type}, fileNameMap[props.type] || '出库台账.xlsx');
      })
      .catch(() => {
         proxy.$modal.msg("已取消");
@@ -382,7 +453,7 @@
      <div class="print-page">
        <div class="delivery-note">
          <div class="header">
            <div class="company-name">鼎诚瑞实业有限责任公司</div>
            <div class="company-name">军泰伟业机械有限公司</div>
            <div class="document-title">零售发货单</div>
          </div>
          
@@ -408,7 +479,7 @@
              <thead>
                <tr>
                  <th>产品名称</th>
                  <th>规格型号</th>
                  <th>图纸编号</th>
                  <th>单位</th>
                  <th>单价</th>
                  <th>零售数量</th>
@@ -512,6 +583,13 @@
};
onMounted(() => {
   getList();
  fetchStockRecordTypeOptions();
});
watch(() => props.type, () => {
  page.current = 1;
  getList();
  fetchStockRecordTypeOptions();
});
</script>