From 512d5d7e79e0a64b36e24cbe5d7c5f8d0adc0b94 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 26 九月 2024 17:46:48 +0800
Subject: [PATCH] 1.升级了element-plus版本 2.对外支持模块新设备匹配工地功能完成 3.新增设备匹配模块单挑匹配记录编辑功能(未完成)

---
 src/views/fysp/support/components/DeviceMatch.vue |   67 +++++++++++++++++++++++++++++++--
 1 files changed, 63 insertions(+), 4 deletions(-)

diff --git a/src/views/fysp/support/components/DeviceMatch.vue b/src/views/fysp/support/components/DeviceMatch.vue
index 338bbe7..1cb78e1 100644
--- a/src/views/fysp/support/components/DeviceMatch.vue
+++ b/src/views/fysp/support/components/DeviceMatch.vue
@@ -11,23 +11,44 @@
       <el-row justify="space-between">
         <div>
           <!-- <el-button type="primary" plain :disabled="!enabled">鍚嶇О鍚屾</el-button> -->
-          <el-button type="primary" plain :disabled="!enabled">褰曞叆璁惧淇℃伅</el-button>
+          <el-button type="primary" plain :disabled="!enabled" @click="setNewDevice"
+            >褰曞叆璁惧淇℃伅</el-button
+          >
         </div>
-        <el-button type="danger" :disabled="!enabled">涓婁紶鍖归厤淇℃伅</el-button>
+        <el-button type="danger" :disabled="!enabled" @click="uploadMatchScene"
+          >涓婁紶鍖归厤淇℃伅</el-button
+        >
       </el-row>
-      <el-row></el-row>
+      <div v-if="newDevice">
+        <el-text>鏂板璁惧</el-text>
+        <FormDevice :form-info="newDevice" :is-edit="true"></FormDevice>
+      </div>
+      <div v-if="deviceList.length > 0">
+        <el-text>宸叉湁璁惧</el-text>
+        <FormDevice v-for="item in deviceList" :key="item.diId" :form-info="item"></FormDevice>
+      </div>
     </template>
   </el-card>
 </template>
 <script setup>
 import { ref, computed, watch } from 'vue';
 import deviceApi from '@/api/fysp/deviceApi';
+import constructionApi from '@/api/additional-jingan/constructionApi';
+import { useFetchData } from '@/composables/fetchData';
+import { ElMessage } from 'element-plus';
+
+import FormDevice from './FormDevice.vue';
 
 const props = defineProps({
   device: Object,
   scene: Object
 });
 
+const emit = defineEmits(['success']);
+
+// 鏂板璁惧淇℃伅
+const newDevice = ref();
+// 鍦烘櫙宸叉湁璁惧淇℃伅
 const deviceList = ref([]);
 
 const enabled = computed(() => {
@@ -38,7 +59,7 @@
   () => props.scene,
   (nV, oV) => {
     if (nV != oV) {
-      fetchDeviceInfo();
+      // fetchDeviceInfo();
     }
   }
 );
@@ -48,4 +69,42 @@
     deviceList.value = res.data;
   });
 }
+
+function setNewDevice() {
+  newDevice.value = {
+    diName: props.device.name,
+    diMnCode: props.device.code,
+    diType: 1,
+    diSupplier: null,
+    diMaintainer: null,
+    diRunningStatus: true,
+    diRemoved: false
+  };
+}
+
+const { loading, fetchData } = useFetchData();
+/**
+ * 涓婁紶璁惧鍏宠仈宸ュ湴
+ */
+function uploadMatchScene() {
+  const param = {
+    name: props.scene.name,
+    address: props.scene.location,
+    street: props.scene.townname,
+    lon: props.device.lon,
+    lat: props.device.lat,
+    sbCode: props.device.code,
+    sbName: props.device.name
+  };
+  
+  fetchData(() => {
+    return constructionApi.uploadConstructionDevice(param).then((res) => {
+      ElMessage({
+        message: res.message,
+        type: 'success'
+      });
+      emit('success');
+    });
+  });
+}
 </script>

--
Gitblit v1.9.3