| | |
| | | <template> |
| | | <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-form-item label="产品名称"> |
| | | <el-input v-model="query.productName" placeholder="输入产品名称" clearable @keyup.enter="onSearch" /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="型号名称"> |
| | | <el-input v-model="query.model" placeholder="输入型号名称" clearable @keyup.enter="onSearch" /> |
| | | <el-form-item label="产品型号"> |
| | | <el-input v-model="query.model" placeholder="输入产品型号" clearable @keyup.enter="onSearch" /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item> |
| | |
| | | @selection-change="handleSelectionChange" @select="handleSelect"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column type="index" label="序号" width="60" /> |
| | | <el-table-column prop="productName" label="产品大类" min-width="160" /> |
| | | <el-table-column prop="model" label="型号名称" min-width="200" /> |
| | | <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" /> |
| | | </el-table> |
| | | |
| | |
| | | </div> |
| | | |
| | | <template #footer> |
| | | <el-button @click="close()">取消</el-button> |
| | | <el-button type="primary" :disabled="multipleSelection.length === 0" @click="onConfirm"> |
| | | 确定 |
| | | </el-button> |
| | | <el-button @click="close()">取消</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </template> |
| | |
| | | <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, productModelListByUrl } from '@/api/basicData/productModel' |
| | | |
| | | export type ProductRow = { |
| | | id: number; |
| | |
| | | const props = defineProps<{ |
| | | modelValue: boolean; |
| | | single?: boolean; // 是否只能选择一个,默认false(可选择多个) |
| | | topProductParentId?: number; // 一级产品id |
| | | requestUrl?: string; // 自定义查询接口 |
| | | }>(); |
| | | |
| | | const emit = defineEmits(['update:modelValue', 'confirm']); |
| | |
| | | loading.value = true; |
| | | try { |
| | | multipleSelection.value = []; // 翻页/搜索后清空选择更符合预期 |
| | | const res: any = await productModelList({ |
| | | const params = { |
| | | productName: query.productName.trim(), |
| | | model: query.model.trim(), |
| | | current: page.pageNum, |
| | | size: page.pageSize, |
| | | }); |
| | | tableData.value = res.records; |
| | | total.value = res.total; |
| | | topProductParentId: props.topProductParentId, |
| | | }; |
| | | const res: any = props.requestUrl |
| | | ? await productModelListByUrl(props.requestUrl, params) |
| | | : await productModelList(params); |
| | | const records = res?.records || res?.data?.records || res?.data || []; |
| | | tableData.value = Array.isArray(records) ? records : []; |
| | | total.value = Number(res?.total ?? res?.data?.total ?? tableData.value.length); |
| | | } finally { |
| | | loading.value = false; |
| | | } |