| | |
| | | <el-form :inline="true" :model="query" class="mb-2"> |
| | | <el-form-item label="产品大类"> |
| | | <el-input |
| | | v-model="query.productName" |
| | | v-model="query.parentName" |
| | | placeholder="输入产品大类" |
| | | clearable |
| | | :disabled="Boolean(props.fixedProductName)" |
| | |
| | | }); |
| | | |
| | | const query = reactive({ |
| | | productName: "", |
| | | parentName: "", |
| | | model: "", |
| | | }); |
| | | |
| | |
| | | } |
| | | |
| | | function onReset() { |
| | | query.productName = props.fixedProductName ? props.fixedProductName : ""; |
| | | query.parentName = props.fixedProductName ? props.fixedProductName : ""; |
| | | query.model = ""; |
| | | page.pageNum = 1; |
| | | loadData(); |
| | |
| | | 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, |
| | | }); |
| | | const records = (res?.records || []) as any[]; |
| | | }; |
| | | 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 |
| | | ? records.filter((r) => !exclude.includes(String(r?.parentName ?? ""))) |
| | | : records; |
| | | tableData.value = filtered; |
| | | total.value = exclude.length ? filtered.length : res.total; |
| | | ? 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; |
| | | } |
| | |
| | | watch(() => props.modelValue, (visible) => { |
| | | if (visible) { |
| | | multipleSelection.value = []; |
| | | // 只有传了 fixedProductName 才启用“固定大类筛选”的特殊逻辑,其它场景保持原行为不变 |
| | | // 只有传了 fixedProductName 才启用"固定大类筛选"的特殊逻辑,其它场景保持原行为不变 |
| | | if (props.fixedProductName) { |
| | | query.productName = props.fixedProductName; |
| | | query.parentName = props.fixedProductName; |
| | | page.pageNum = 1; |
| | | loadData(); |
| | | } |