| | |
| | | style="width: 240px" |
| | | placeholder="请输入" |
| | | clearable/> |
| | | <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> |
| | |
| | | <el-table-column label="产品大类" |
| | | prop="productName" |
| | | show-overflow-tooltip/> |
| | | <el-table-column label="规格型号" |
| | | <el-table-column label="图纸编号" |
| | | prop="model" |
| | | show-overflow-tooltip/> |
| | | <el-table-column label="单位" |
| | |
| | | <el-table-column label="入库数量" |
| | | prop="stockInNum" |
| | | 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="locationName" |
| | | 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> |
| | | <pagination v-show="total > 0" |
| | | :total="total" |
| | |
| | | toRefs, |
| | | onMounted, |
| | | getCurrentInstance, |
| | | nextTick, |
| | | watch, |
| | | } from "vue"; |
| | | import {ElMessageBox} from "element-plus"; |
| | | import { |
| | | getStockInRecordListPage, |
| | | batchDeleteStockInRecords, |
| | | } from "@/api/inventoryManagement/stockInRecord.js"; |
| | | import { |
| | | findAllQualifiedStockInRecordTypeOptions, findAllUnQualifiedStockInRecordTypeOptions, |
| | | } from "@/api/basicData/enum.js"; |
| | | |
| | | const {proxy} = getCurrentInstance(); |
| | | |
| | | const props = defineProps({ |
| | | type: { |
| | | type: String, |
| | | type: Number, |
| | | required: true, |
| | | default: '0' |
| | | default: 1 |
| | | } |
| | | }) |
| | | |
| | | const tableData = ref([]); |
| | | const selectedRows = ref([]); |
| | | const tableLoading = ref(false); |
| | | const activeTab = ref("production"); // 当前激活的 tab |
| | | |
| | | // 来源类型选项 |
| | | const stockRecordTypeOptions = ref([]); |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 100, |
| | | size: 10, |
| | | }); |
| | | const total = ref(0); |
| | | |
| | |
| | | searchForm: { |
| | | productName: "", |
| | | timeStr: "", |
| | | recordType: "", |
| | | type: "", |
| | | }, |
| | | }); |
| | | const {searchForm} = toRefs(data); |
| | | |
| | | // 查询列表 |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery = () => { |
| | | page.current = 1; |
| | | getList(); |
| | | }; |
| | | |
| | | /** 重置按钮操作 */ |
| | | const handleReset = () => { |
| | | searchForm.value.productName = ""; |
| | | searchForm.value.timeStr = ""; |
| | | searchForm.value.recordType = ""; |
| | | searchForm.value.type = ""; |
| | | handleQuery(); |
| | | }; |
| | | |
| | | const getRecordType = (recordType) => { |
| | | return stockRecordTypeOptions.value.find(item => item.value === recordType)?.label || '' |
| | | } |
| | | |
| | | const pageProductChange = obj => { |
| | | page.current = obj.page; |
| | |
| | | |
| | | const getList = () => { |
| | | tableLoading.value = true; |
| | | const params = {...page, type: props.type}; |
| | | const params = {...page, productType: props.type}; |
| | | params.timeStr = searchForm.value.timeStr; |
| | | params.productName = searchForm.value.productName; |
| | | params.recordType = searchForm.value.recordType; |
| | | if (searchForm.value.type !== "") { |
| | | params.type = searchForm.value.type; |
| | | } |
| | | getStockInRecordListPage(params) |
| | | .then(res => { |
| | | tableData.value = res.data.records; |
| | | total.value = res.data.total || 0; |
| | | }).finally(() => { |
| | | tableLoading.value = false; |
| | | }) |
| | | }; |
| | | |
| | | // 获取来源类型选项 |
| | | const fetchStockRecordTypeOptions = () => { |
| | | Promise.all([ |
| | | findAllQualifiedStockInRecordTypeOptions(), |
| | | findAllUnQualifiedStockInRecordTypeOptions() |
| | | ]) |
| | | .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 => { |
| | |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | // 根据不同的 tab 类型调用不同的导出接口 |
| | | let exportUrl = "/stockin/export"; |
| | | if (activeTab.value === "production") { |
| | | exportUrl = "/stockin/exportOne"; |
| | | } |
| | | proxy.download(exportUrl, {}, "入库台账.xlsx"); |
| | | const fileNameMap = { |
| | | 1: '自制入库.xlsx', |
| | | 2: '外购入库.xlsx', |
| | | 3: '委外入库.xlsx' |
| | | }; |
| | | proxy.download("/stockInRecord/exportStockInRecord", {productType: props.type}, fileNameMap[props.type] || '入库.xlsx'); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msg("已取消"); |
| | |
| | | |
| | | onMounted(() => { |
| | | getList(); |
| | | fetchStockRecordTypeOptions(); |
| | | }); |
| | | |
| | | watch(() => props.type, () => { |
| | | page.current = 1; |
| | | getList(); |
| | | fetchStockRecordTypeOptions(); |
| | | }); |
| | | </script> |
| | | |