From 22e17b6db03ca58bc477a35ca067e55a09cffce7 Mon Sep 17 00:00:00 2001
From: huang <1532065656@qq.com>
Date: 星期三, 10 十二月 2025 17:04:08 +0800
Subject: [PATCH] 添加工程表及相关逻辑,防止重复导入Excel表序号重复生成
---
mes-web/src/views/device/DeviceConfigList.vue | 47 +++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/mes-web/src/views/device/DeviceConfigList.vue b/mes-web/src/views/device/DeviceConfigList.vue
index 07d95a6..72a5e45 100644
--- a/mes-web/src/views/device/DeviceConfigList.vue
+++ b/mes-web/src/views/device/DeviceConfigList.vue
@@ -4,10 +4,13 @@
<div class="search-section">
<el-form :model="searchForm" :inline="true" class="search-form">
<el-form-item label="璁惧绫诲瀷">
- <el-select v-model="searchForm.deviceType" placeholder="閫夋嫨璁惧绫诲瀷" clearable>
- <el-option label="澶ц溅璁惧" value="澶ц溅璁惧" />
- <el-option label="澶х悊鐗囩" value="澶х悊鐗囩" />
- <el-option label="鍗у紡缂撳瓨" value="鍗у紡缂撳瓨" />
+ <el-select v-model="searchForm.deviceType" placeholder="閫夋嫨璁惧绫诲瀷" clearable :loading="deviceTypesLoading">
+ <el-option
+ v-for="type in deviceTypes"
+ :key="type"
+ :label="type"
+ :value="type"
+ />
</el-select>
</el-form-item>
<el-form-item label="璁惧鐘舵��">
@@ -165,6 +168,10 @@
const selectedDevices = ref([])
const plcOperationLoading = ref(false)
+// 璁惧绫诲瀷鍒楄〃
+const deviceTypes = ref([])
+const deviceTypesLoading = ref(false)
+
// 鎼滅储琛ㄥ崟
const searchForm = reactive({
deviceType: '',
@@ -183,6 +190,37 @@
const emit = defineEmits(['device-selected', 'refresh-statistics'])
// 鏂规硶瀹氫箟
+// 鍔犺浇璁惧绫诲瀷鍒楄〃
+const loadDeviceTypes = async () => {
+ if (deviceTypes.value.length > 0) {
+ // 濡傛灉宸茬粡鍔犺浇杩囷紝涓嶅啀閲嶅鍔犺浇
+ return
+ }
+ // 鎵�鏈夋敮鎸佺殑璁惧绫诲瀷锛堢‘淇濆寘鍚墍鏈夋湁閰嶇疆缁勪欢鐨勭被鍨嬶級
+ const supportedTypes = ['澶ц溅璁惧', '澶х悊鐗囩', '鍗ц浆绔嬫壂鐮佽澶�', '鍗ц浆绔嬭澶�']
+
+ try {
+ deviceTypesLoading.value = true
+ const res = await deviceConfigApi.getDeviceTypes()
+ if (res?.data && Array.isArray(res.data)) {
+ // 鍚堝苟鏁版嵁搴撲腑鐨勭被鍨嬪拰鏀寔鐨勭被鍨嬶紝鍘婚噸骞舵帓搴�
+ const dbTypes = res.data
+ const allTypes = [...new Set([...supportedTypes, ...dbTypes])].sort()
+ deviceTypes.value = allTypes
+ } else {
+ // 濡傛灉API杩斿洖澶辫触锛屼娇鐢ㄩ粯璁ょ被鍨�
+ deviceTypes.value = supportedTypes
+ console.warn('鑾峰彇璁惧绫诲瀷鍒楄〃澶辫触锛屼娇鐢ㄩ粯璁ょ被鍨�')
+ }
+ } catch (error) {
+ console.error('鍔犺浇璁惧绫诲瀷鍒楄〃澶辫触:', error)
+ // 澶辫触鏃朵娇鐢ㄩ粯璁ょ被鍨�
+ deviceTypes.value = supportedTypes
+ } finally {
+ deviceTypesLoading.value = false
+ }
+}
+
const loadDeviceList = async () => {
try {
tableLoading.value = true
@@ -481,6 +519,7 @@
// 缁勪欢鎸傝浇鏃跺姞杞芥暟鎹�
onMounted(() => {
+ loadDeviceTypes()
loadDeviceList()
})
</script>
--
Gitblit v1.8.0