From d48f5076b64aeacad45c0d2cf5ad2188256948f9 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 24 四月 2026 10:22:22 +0800
Subject: [PATCH] fix: 仓储物流新增bug修改
---
src/views/basicData/product/ProductSelectDialog.vue | 63 ++++++++++++++++++++++++++-----
1 files changed, 52 insertions(+), 11 deletions(-)
diff --git a/src/views/basicData/product/ProductSelectDialog.vue b/src/views/basicData/product/ProductSelectDialog.vue
index 70dbb16..cdaab57 100644
--- a/src/views/basicData/product/ProductSelectDialog.vue
+++ b/src/views/basicData/product/ProductSelectDialog.vue
@@ -2,7 +2,13 @@
<el-dialog v-model="visible" title="閫夋嫨浜у搧" width="900px" destroy-on-close :close-on-click-modal="false">
<el-form :inline="true" :model="query" class="mb-2">
<el-form-item label="浜у搧澶х被">
- <el-input v-model="query.productName" placeholder="杈撳叆浜у搧澶х被" clearable @keyup.enter="onSearch" />
+ <el-input
+ v-model="query.parentName"
+ placeholder="杈撳叆浜у搧澶х被"
+ clearable
+ :disabled="Boolean(props.fixedProductName)"
+ @keyup.enter="onSearch"
+ />
</el-form-item>
<el-form-item label="鍨嬪彿鍚嶇О">
@@ -20,6 +26,7 @@
@selection-change="handleSelectionChange" @select="handleSelect">
<el-table-column type="selection" width="55" />
<el-table-column type="index" label="搴忓彿" width="60" />
+ <el-table-column prop="parentName" label="绫诲瀷" min-width="160" />
<el-table-column prop="productName" label="浜у搧澶х被" min-width="160" />
<el-table-column prop="model" label="鍨嬪彿鍚嶇О" min-width="200" />
<el-table-column prop="unit" label="鍗曚綅" min-width="160" />
@@ -43,7 +50,7 @@
<script setup lang="ts">
import { computed, onMounted, reactive, ref, watch, nextTick } from "vue";
import { ElMessage } from "element-plus";
-import { productModelList } from '@/api/basicData/productModel'
+import { productModelList } from "../../../api/basicData/productModel.js";
export type ProductRow = {
id: number;
@@ -55,6 +62,8 @@
const props = defineProps<{
modelValue: boolean;
single?: boolean; // 鏄惁鍙兘閫夋嫨涓�涓紝榛樿false锛堝彲閫夋嫨澶氫釜锛�
+ fixedProductName?: string; // 鍥哄畾鈥滀骇鍝佸ぇ绫烩�濈瓫閫夛紙渚嬪锛氳�楁潗锛夛紝浼犲叆鍚庝笉鍙紪杈戜笖閲嶇疆涓嶆竻绌�
+ excludeParentNames?: string[]; // 鎺掗櫎鈥滅被鍨嬧��(parentName)锛屼緥濡傦細['鑰楁潗']锛堜粎浼犲叆鏃剁敓鏁堬級
}>();
const emit = defineEmits(['update:modelValue', 'confirm']);
@@ -65,7 +74,7 @@
});
const query = reactive({
- productName: "",
+ parentName: "",
model: "",
});
@@ -127,7 +136,7 @@
}
function onReset() {
- query.productName = "";
+ query.parentName = props.fixedProductName ? props.fixedProductName : "";
query.model = "";
page.pageNum = 1;
loadData();
@@ -154,14 +163,40 @@
loading.value = true;
try {
multipleSelection.value = []; // 缈婚〉/鎼滅储鍚庢竻绌洪�夋嫨鏇寸鍚堥鏈�
- const res: any = await productModelList({
- productName: query.productName.trim(),
+ const queryParams = {
+ parentName: query.parentName.trim(),
model: query.model.trim(),
- current: page.pageNum,
- size: page.pageSize,
- });
- tableData.value = res.records;
- total.value = res.total;
+ };
+ const exclude = (props.excludeParentNames || []).filter(Boolean);
+
+ // 鍏堟媺鍙栧叏閮ㄦ暟鎹紝鍐嶇粺涓�杩囨护锛岄伩鍏嶁�滃彧杩囨护鍒板綋鍓嶉〉鈥濆鑷存紡鏁版嵁
+ const allRecords: any[] = [];
+ const fetchSize = 200;
+ let current = 1;
+ let serverTotal = 0;
+ while (true) {
+ const res: any = await productModelList({
+ ...queryParams,
+ current,
+ size: fetchSize,
+ });
+ const records = (res?.records || []) as any[];
+ serverTotal = Number(res?.total || 0);
+ allRecords.push(...records);
+ if (records.length === 0 || allRecords.length >= serverTotal) {
+ break;
+ }
+ current += 1;
+ }
+
+ const filtered = exclude.length
+ ? allRecords.filter((r) => !exclude.includes(String(r?.parentName ?? "")))
+ : allRecords;
+
+ total.value = filtered.length;
+ const start = (page.pageNum - 1) * page.pageSize;
+ const end = start + page.pageSize;
+ tableData.value = filtered.slice(start, end);
} finally {
loading.value = false;
}
@@ -171,6 +206,12 @@
watch(() => props.modelValue, (visible) => {
if (visible) {
multipleSelection.value = [];
+ // 鍙湁浼犱簡 fixedProductName 鎵嶅惎鐢�"鍥哄畾澶х被绛涢��"鐨勭壒娈婇�昏緫锛屽叾瀹冨満鏅繚鎸佸師琛屼负涓嶅彉
+ if (props.fixedProductName) {
+ query.parentName = props.fixedProductName;
+ page.pageNum = 1;
+ loadData();
+ }
}
});
--
Gitblit v1.9.3