From 2291b7406cdc184abfa1b1986baeb55499771343 Mon Sep 17 00:00:00 2001
From: ZN <zhang_12370@163.com>
Date: 星期一, 16 三月 2026 17:07:15 +0800
Subject: [PATCH] fix(设备管理): 修正添加维护接口的URL路径
---
src/components/ProductSelectDialog.vue | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 180 insertions(+), 0 deletions(-)
diff --git a/src/components/ProductSelectDialog.vue b/src/components/ProductSelectDialog.vue
new file mode 100644
index 0000000..3780394
--- /dev/null
+++ b/src/components/ProductSelectDialog.vue
@@ -0,0 +1,180 @@
+<template>
+ <el-dialog
+ v-model="visibleProxy"
+ title="閫夋嫨浜у搧"
+ width="900px"
+ @close="handleClose"
+ >
+ <div class="search-row">
+ <el-input
+ v-model="keyword"
+ placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�/瑙勬牸鎼滅储"
+ clearable
+ style="width: 320px"
+ @keyup.enter="handleQuery"
+ />
+ <el-button type="primary" @click="handleQuery">鏌ヨ</el-button>
+ <el-button @click="handleReset">閲嶇疆</el-button>
+ </div>
+
+ <el-table
+ v-loading="loading"
+ :data="tableData"
+ border
+ height="420"
+ style="width: 100%"
+ @selection-change="handleSelectionChange"
+ @row-click="handleRowClick"
+ >
+ <el-table-column
+ v-if="!single"
+ type="selection"
+ width="55"
+ align="center"
+ />
+ <el-table-column label="浜у搧鍚嶇О" prop="productName" min-width="180" />
+ <el-table-column label="瑙勬牸鍨嬪彿" prop="model" min-width="180" />
+ <el-table-column label="鍗曚綅" prop="unit" width="100" />
+ <el-table-column label="浜у搧绫诲瀷" prop="parentName" width="120" />
+ </el-table>
+
+ <Pagination
+ :total="total"
+ :page="page.current"
+ :limit="page.size"
+ @pagination="handlePagination"
+ />
+
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary" :disabled="selectedRows.length === 0" @click="handleConfirm">
+ 纭畾
+ </el-button>
+ <el-button @click="visibleProxy = false">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
+</template>
+
+<script setup>
+import { computed, onMounted, reactive, ref, watch } from "vue";
+import Pagination from "@/components/PIMTable/Pagination.vue";
+import { modelListPage } from "@/api/basicData/product.js";
+
+const props = defineProps({
+ modelValue: { type: Boolean, default: false },
+ single: { type: Boolean, default: false },
+});
+
+const emit = defineEmits(["update:modelValue", "confirm"]);
+
+const visibleProxy = computed({
+ get: () => props.modelValue,
+ set: val => emit("update:modelValue", val),
+});
+
+const keyword = ref("");
+const loading = ref(false);
+const tableData = ref([]);
+const selectedRows = ref([]);
+const total = ref(0);
+
+const page = reactive({
+ current: 1,
+ size: 10,
+});
+
+const normalizeRow = row => {
+ if (!row) return row;
+ return {
+ ...row,
+ productId: row.productId ?? row.product_id ?? row.product?.id,
+ productName: row.productName ?? row.product_name ?? row.name,
+ model: row.model ?? row.productModelName ?? row.modelName ?? row.specificationModel,
+ id: row.id ?? row.productModelId ?? row.modelId,
+ unit: row.unit ?? row.productUnit,
+ productType: row.productType ?? row.type,
+ };
+};
+
+const fetchList = () => {
+ loading.value = true;
+ const params = {
+ current: page.current,
+ size: page.size,
+ };
+ if (keyword.value) {
+ params.keyword = keyword.value;
+ params.productName = keyword.value;
+ params.model = keyword.value;
+ }
+ modelListPage(params)
+ .then(res => {
+ const records = res?.data?.records || [];
+ tableData.value = records.map(normalizeRow);
+ total.value = res?.data?.total || 0;
+ })
+ .finally(() => {
+ loading.value = false;
+ });
+};
+
+const handleQuery = () => {
+ page.current = 1;
+ fetchList();
+};
+
+const handleReset = () => {
+ keyword.value = "";
+ page.current = 1;
+ fetchList();
+};
+
+const handlePagination = ({ page: p, limit }) => {
+ page.current = p;
+ page.size = limit;
+ fetchList();
+};
+
+const handleSelectionChange = selection => {
+ selectedRows.value = Array.isArray(selection) ? selection : [];
+};
+
+const handleRowClick = row => {
+ if (!props.single) return;
+ selectedRows.value = row ? [row] : [];
+};
+
+const handleConfirm = () => {
+ if (selectedRows.value.length === 0) return;
+ emit("confirm", selectedRows.value);
+ visibleProxy.value = false;
+};
+
+const handleClose = () => {
+ selectedRows.value = [];
+};
+
+watch(
+ () => props.modelValue,
+ val => {
+ if (!val) return;
+ page.current = 1;
+ selectedRows.value = [];
+ fetchList();
+ }
+);
+
+onMounted(() => {
+ if (props.modelValue) fetchList();
+});
+</script>
+
+<style scoped>
+.search-row {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ padding-bottom: 12px;
+}
+</style>
--
Gitblit v1.9.3