| | |
| | | <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.productName" |
| | | placeholder="输入产品大类" |
| | | clearable |
| | | :disabled="Boolean(props.fixedProductName)" |
| | | @keyup.enter="onSearch" |
| | | /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="型号名称"> |
| | |
| | | <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; |
| | |
| | | const props = defineProps<{ |
| | | modelValue: boolean; |
| | | single?: boolean; // 是否只能选择一个,默认false(可选择多个) |
| | | fixedProductName?: string; // 固定“产品大类”筛选(例如:耗材),传入后不可编辑且重置不清空 |
| | | excludeParentNames?: string[]; // 排除“类型”(parentName),例如:['耗材'](仅传入时生效) |
| | | }>(); |
| | | |
| | | const emit = defineEmits(['update:modelValue', 'confirm']); |
| | |
| | | } |
| | | |
| | | function onReset() { |
| | | query.productName = ""; |
| | | query.productName = props.fixedProductName ? props.fixedProductName : ""; |
| | | query.model = ""; |
| | | page.pageNum = 1; |
| | | loadData(); |
| | |
| | | current: page.pageNum, |
| | | size: page.pageSize, |
| | | }); |
| | | tableData.value = res.records; |
| | | total.value = res.total; |
| | | const records = (res?.records || []) as any[]; |
| | | const exclude = (props.excludeParentNames || []).filter(Boolean); |
| | | const filtered = exclude.length |
| | | ? records.filter((r) => !exclude.includes(String(r?.parentName ?? ""))) |
| | | : records; |
| | | tableData.value = filtered; |
| | | total.value = exclude.length ? filtered.length : res.total; |
| | | } finally { |
| | | loading.value = false; |
| | | } |
| | |
| | | watch(() => props.modelValue, (visible) => { |
| | | if (visible) { |
| | | multipleSelection.value = []; |
| | | // 只有传了 fixedProductName 才启用“固定大类筛选”的特殊逻辑,其它场景保持原行为不变 |
| | | if (props.fixedProductName) { |
| | | query.productName = props.fixedProductName; |
| | | page.pageNum = 1; |
| | | loadData(); |
| | | } |
| | | } |
| | | }); |
| | | |