From 6f393bea8db5898684b573b8bebc64890fcc9183 Mon Sep 17 00:00:00 2001
From: suerprisePlus <15810472099@163.com>
Date: 星期一, 08 七月 2024 10:52:06 +0800
Subject: [PATCH] three.js页面添加,obj模型添加

---
 src/views/iot/device/device-edit.vue |  439 ++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 292 insertions(+), 147 deletions(-)

diff --git a/src/views/iot/device/device-edit.vue b/src/views/iot/device/device-edit.vue
index a90b2ff..16282d6 100644
--- a/src/views/iot/device/device-edit.vue
+++ b/src/views/iot/device/device-edit.vue
@@ -1,125 +1,154 @@
 <template>
-  <el-card style="margin: 6px; padding-bottom: 100px">
+  <el-card style="margin: 6px;width:calc(100% - 12px); height: calc(100% - 12px);position:absolute; ">
     <el-tabs v-model="activeName" tab-position="left" @tab-click="tabChange" style="padding: 10px; min-height: 400px">
       <el-tab-pane name="basic">
         <span slot="label">* 鍩烘湰淇℃伅</span>
-        <el-form ref="form" :model="form" :rules="rules" label-width="100px">
-          <el-row :gutter="100">
-            <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
-              <el-form-item label="璁惧鍚嶇О" prop="deviceName">
-                <el-input v-model="form.deviceName" placeholder="璇疯緭鍏ヨ澶囧悕绉�">
-                  <el-button slot="append" @click="openSummaryDialog" v-if="form.deviceId != 0">鎽樿</el-button>
-                </el-input>
-              </el-form-item>
-              <el-form-item label="" prop="productName">
-                <template slot="label">
-                  <span style="color: red">*</span>
-                  鎵�灞炰骇鍝�
-                </template>
-                <el-input readonly v-model="form.productName" placeholder="璇烽�夋嫨浜у搧" :disabled="form.status != 1">
-                  <el-button slot="append" @click="selectProduct()" :disabled="form.status != 1">閫夋嫨</el-button>
-                </el-input>
-              </el-form-item>
-              <el-form-item label="" prop="serialNumber">
-                <template slot="label">
-                  <span style="color: red">*</span>
-                  璁惧缂栧彿
-                </template>
-                <el-input v-model="form.serialNumber" placeholder="璇疯緭鍏ヨ澶囩紪鍙�" :disabled="form.status !== 1" maxlength="32">
-                  <el-button slot="append" @click="generateNum" :loading="genDisabled"
-                    :disabled="form.status !== 1">鐢熸垚</el-button>
-                </el-input>
-              </el-form-item>
-              <el-form-item v-if="openServerTip">
-                <template>
-                  <el-alert type="info" show-icon description="褰撳墠閫夋嫨TCP鍗忚,璁惧缂栧彿鐢熸垚涓篐EX鏍煎紡"></el-alert>
-                </template>
-              </el-form-item>
-              <el-form-item v-if="openTip">
-                <template>
-                  <el-alert type="success" show-icon description="褰撳墠閫夋嫨鐨勪骇鍝佸睘浜巑odbus鍗忚,灏嗗湪缃戝叧璁惧鍒涘缓鍚庢牴鎹噰闆嗙偣妯℃澘鐢熸垚瀛愯澶�"></el-alert>
-                </template>
-              </el-form-item>
-              <el-form-item label="鍥轰欢鐗堟湰" prop="firmwareVersion">
-                <el-input v-model="form.firmwareVersion" placeholder="璇疯緭鍏ュ浐浠剁増鏈�" type="number" step="0.1"
-                  :disabled="form.status != 1 || form.deviceType === 3">
-                  <template slot="prepend">Version</template>
-                </el-input>
-              </el-form-item>
-              <el-form-item label="妯℃嫙璁惧" prop="isSimulate">
-                <el-switch v-model="form.isSimulate" active-text="" inactive-text="" :active-value="1" :inactive-value="0"
-                  :disabled="form.deviceType === 3"></el-switch>
-              </el-form-item>
-              <el-form-item label="璁惧褰卞瓙" prop="isShadow">
-                <el-switch v-model="form.isShadow" active-text="" inactive-text="" :active-value="1" :inactive-value="0"
-                  :disabled="form.deviceType === 3"></el-switch>
-              </el-form-item>
-              <el-form-item label="绂佺敤璁惧" prop="deviceStatus">
-                <el-switch v-model="deviceStatus" active-text="" inactive-text=""
-                           :disabled="form.status === 1 || form.deviceType === 3" :active-value="1" :inactive-value="0"
-                           active-color="#F56C6C"></el-switch>
-              </el-form-item>
-              <el-form-item label="澶囨敞淇℃伅" prop="remark">
-                <el-input v-model="form.remark" type="textarea" placeholder="璇疯緭鍏ュ唴瀹�" rows="1" />
-              </el-form-item>
-            </el-col>
-            <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
-              <el-form-item label="瀹氫綅鏂瑰紡" prop="locationWay">
-                <el-select v-model="form.locationWay" placeholder="璇烽�夋嫨璁惧鐘舵��" clearable size="small" style="width: 100%"
-                  :disabled="form.deviceType === 3">
-                  <el-option v-for="dict in dict.type.iot_location_way" :key="dict.value" :label="dict.label"
-                    :value="Number(dict.value)" />
-                </el-select>
-              </el-form-item>
-              <el-form-item label="璁惧缁忓害" prop="longitude">
-                <el-input v-model="form.longitude" placeholder="璇疯緭鍏ヨ澶囩粡搴�" type="number" :disabled="form.locationWay != 3">
-                  <el-link slot="append" :underline="false" href="https://api.map.baidu.com/lbsapi/getpoint/index.html"
-                    target="_blank" :disabled="form.locationWay != 3">鍧愭爣鎷惧彇</el-link>
-                </el-input>
-              </el-form-item>
-              <el-form-item label="璁惧绾害" prop="latitude">
-                <el-input v-model="form.latitude" placeholder="璇疯緭鍏ヨ澶囩含搴�" type="number" :disabled="form.locationWay != 3">
-                  <el-link slot="append" :underline="false" href="https://api.map.baidu.com/lbsapi/getpoint/index.html"
-                    target="_blank" :disabled="form.locationWay != 3">鍧愭爣鎷惧彇</el-link>
-                </el-input>
-              </el-form-item>
-              <el-form-item label="鎵�鍦ㄥ湴鍧�" prop="networkAddress">
-                <el-input v-model="form.networkAddress" placeholder="璇疯緭鍏ヨ澶囨墍鍦ㄥ湴鍧�" :disabled="form.locationWay != 3" />
-              </el-form-item>
-              <el-form-item label="鍏ョ綉鍦板潃" prop="networkIp">
-                <el-input v-model="form.networkIp" placeholder="璁惧鍏ョ綉IP" disabled />
-              </el-form-item>
-              <el-form-item label="婵�娲绘椂闂�" prop="activeTime">
-                <el-date-picker clearable v-model="form.activeTime" type="date" value-format="yyyy-MM-dd"
-                  placeholder="璁惧婵�娲绘椂闂�" disabled style="width: 100%"></el-date-picker>
-              </el-form-item>
-              <el-form-item label="璁惧淇″彿" prop="rssi">
-                <el-input v-model="form.rssi" placeholder="璁惧淇″彿寮哄害" disabled />
-              </el-form-item>
-              <el-form-item label="鍏朵粬淇℃伅" prop="remark" v-if="form.deviceId != 0">
-                <dict-tag :options="dict.type.iot_device_status" :value="form.status"
-                  style="display: inline-block; margin-right: 8px" />
-                <el-button size="small" @click="handleViewMqtt()">璁よ瘉淇℃伅</el-button>
-                <el-button size="small" @click="openCodeDialog()">浜岀淮鐮�</el-button>
-              </el-form-item>
-            </el-col>
-            <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" v-if="form.deviceId != 0">
-              <div
-                style="border: 1px solid #dfe4ed; border-radius: 5px; padding: 5px; text-align: center; line-height: 400px">
-                <div id="map" style="height: 435px; width: 100%">鍦板浘灞曠ず鍖哄煙锛屾柊澧炲悗鏄剧ず</div>
-              </div>
-            </el-col>
-          </el-row>
-        </el-form>
 
-        <el-form label-width="100px" style="margin-top: 50px">
-          <el-form-item style="text-align: center; margin-left: -100px; margin-top: 10px">
-            <el-button type="primary" @click="submitForm" v-hasPermi="['iot:device:edit']" v-show="form.deviceId != 0">淇�
-              鏀�</el-button>
-            <el-button type="primary" @click="submitForm" v-hasPermi="['iot:device:add']" v-show="form.deviceId == 0">鏂�
-              澧�</el-button>
-          </el-form-item>
-        </el-form>
+        <div style="width:100%;    display:flex">
+          <div class="leftCount">
+            <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+              <el-row :gutter="100">
+                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
+                  <el-form-item label="璁惧鍚嶇О" prop="deviceName">
+                    <el-input v-model="form.deviceName" placeholder="璇疯緭鍏ヨ澶囧悕绉�">
+                      <el-button slot="append" @click="openSummaryDialog" v-if="form.deviceId != 0">鎽樿</el-button>
+                    </el-input>
+                  </el-form-item>
+                  <el-form-item label="" prop="productName">
+                    <template slot="label">
+                      <span style="color: red">*</span>
+                      鎵�灞炰骇鍝�
+                    </template>
+                    <el-input readonly v-model="form.productName" placeholder="璇烽�夋嫨浜у搧" :disabled="form.status != 1">
+                      <el-button slot="append" @click="selectProduct()" :disabled="form.status != 1">閫夋嫨</el-button>
+                    </el-input>
+                  </el-form-item>
+                  <el-form-item label="" prop="serialNumber">
+                    <template slot="label">
+                      <span style="color: red">*</span>
+                      璁惧缂栧彿
+                    </template>
+                    <el-input v-model="form.serialNumber" placeholder="璇疯緭鍏ヨ澶囩紪鍙�" :disabled="form.status !== 1"
+                      maxlength="32">
+                      <el-button slot="append" @click="generateNum" :loading="genDisabled"
+                        :disabled="form.status !== 1">鐢熸垚</el-button>
+                    </el-input>
+                  </el-form-item>
+                  <el-form-item v-if="openServerTip">
+                    <template>
+                      <el-alert type="info" show-icon description="褰撳墠閫夋嫨TCP鍗忚,璁惧缂栧彿鐢熸垚涓篐EX鏍煎紡"></el-alert>
+                    </template>
+                  </el-form-item>
+                  <el-form-item v-if="openTip">
+                    <template>
+                      <el-alert type="success" show-icon
+                        description="褰撳墠閫夋嫨鐨勪骇鍝佸睘浜巑odbus鍗忚,灏嗗湪缃戝叧璁惧鍒涘缓鍚庢牴鎹噰闆嗙偣妯℃澘鐢熸垚瀛愯澶�"></el-alert>
+                    </template>
+                  </el-form-item>
+                  <el-form-item label="鍥轰欢鐗堟湰" prop="firmwareVersion">
+                    <el-input v-model="form.firmwareVersion" placeholder="璇疯緭鍏ュ浐浠剁増鏈�" type="number" step="0.1"
+                      :disabled="form.status != 1 || form.deviceType === 3">
+                      <template slot="prepend">Version</template>
+                    </el-input>
+                  </el-form-item>
+                  <el-form-item label="妯℃嫙璁惧" prop="isSimulate">
+                    <el-switch v-model="form.isSimulate" active-text="" inactive-text="" :active-value="1"
+                      :inactive-value="0" :disabled="form.deviceType === 3"></el-switch>
+                  </el-form-item>
+                  <el-form-item label="璁惧褰卞瓙" prop="isShadow">
+                    <el-switch v-model="form.isShadow" active-text="" inactive-text="" :active-value="1"
+                      :inactive-value="0" :disabled="form.deviceType === 3"></el-switch>
+                  </el-form-item>
+                  <el-form-item label="绂佺敤璁惧" prop="deviceStatus">
+                    <el-switch v-model="deviceStatus" active-text="" inactive-text=""
+                      :disabled="form.status === 1 || form.deviceType === 3" :active-value="1" :inactive-value="0"
+                      active-color="#F56C6C"></el-switch>
+                  </el-form-item>
+                  <el-form-item label="澶囨敞淇℃伅" prop="remark">
+                    <el-input v-model="form.remark" type="textarea" placeholder="璇疯緭鍏ュ唴瀹�" rows="1" />
+                  </el-form-item>
+                </el-col>
+                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
+                  <el-form-item label="瀹氫綅鏂瑰紡" prop="locationWay">
+                    <el-select v-model="form.locationWay" placeholder="璇烽�夋嫨璁惧鐘舵��" clearable size="small"
+                      style="width: 100%" :disabled="form.deviceType === 3">
+                      <el-option v-for="dict in dict.type.iot_location_way" :key="dict.value" :label="dict.label"
+                        :value="Number(dict.value)" />
+                    </el-select>
+                  </el-form-item>
+                  <el-form-item label="璁惧缁忓害" prop="longitude">
+                    <el-input v-model="form.longitude" placeholder="璇疯緭鍏ヨ澶囩粡搴�" type="number"
+                      :disabled="form.locationWay != 3">
+                      <el-link slot="append" :underline="false"
+                        href="https://api.map.baidu.com/lbsapi/getpoint/index.html" target="_blank"
+                        :disabled="form.locationWay != 3">鍧愭爣鎷惧彇</el-link>
+                    </el-input>
+                  </el-form-item>
+                  <el-form-item label="璁惧绾害" prop="latitude">
+                    <el-input v-model="form.latitude" placeholder="璇疯緭鍏ヨ澶囩含搴�" type="number"
+                      :disabled="form.locationWay != 3">
+                      <el-link slot="append" :underline="false"
+                        href="https://api.map.baidu.com/lbsapi/getpoint/index.html" target="_blank"
+                        :disabled="form.locationWay != 3">鍧愭爣鎷惧彇</el-link>
+                    </el-input>
+                  </el-form-item>
+                  <el-form-item label="鎵�鍦ㄥ湴鍧�" prop="networkAddress">
+                    <el-input v-model="form.networkAddress" placeholder="璇疯緭鍏ヨ澶囨墍鍦ㄥ湴鍧�" :disabled="form.locationWay != 3" />
+                  </el-form-item>
+                  <el-form-item label="鍏ョ綉鍦板潃" prop="networkIp">
+                    <el-input v-model="form.networkIp" placeholder="璁惧鍏ョ綉IP" disabled />
+                  </el-form-item>
+                  <el-form-item label="婵�娲绘椂闂�" prop="activeTime">
+                    <el-date-picker clearable v-model="form.activeTime" type="date" value-format="yyyy-MM-dd"
+                      placeholder="璁惧婵�娲绘椂闂�" disabled
+                      style="width: 100%"></el-date-picker>http://localhost:82/iot/template
+                  </el-form-item>
+                  <el-form-item label="璁惧淇″彿" prop="rssi">
+                    <el-input v-model="form.rssi" placeholder="璁惧淇″彿寮哄害" disabled />
+                  </el-form-item>
+                  <el-form-item label="璁惧妯″瀷" prop="modeUrl">
+                    <el-select placeholder="璇烽�夋嫨璁惧妯″瀷" v-model="modeUrl" @change="changeSelect" size="small"
+                      style="width: 100%">
+                      <el-option v-for="(item, index) in modelOption" :key="item.id" :label="item.name"
+                        :value="item.id">
+                      </el-option>
+                    </el-select>
+                  </el-form-item>
+                  <el-form-item label="鍏朵粬淇℃伅" prop="remark" v-if="form.deviceId != 0">
+                    <dict-tag :options="dict.type.iot_device_status" :value="form.status"
+                      style="display: inline-block; margin-right: 8px" />
+                    <el-button size="small" @click="handleViewMqtt()">璁よ瘉淇℃伅</el-button>
+                    <el-button size="small" @click="openCodeDialog()">浜岀淮鐮�</el-button>
+                  </el-form-item>
+                </el-col>
+                <!-- <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" v-if="form.deviceId != 0">
+               
+           
+            </el-col>   -->
+              </el-row>
+            </el-form>
+
+            <el-form label-width="100px" style="margin-top: 50px">
+              <el-form-item style="text-align: center; margin-left: -100px; margin-top: 10px">
+                <el-button type="primary" @click="submitForm" v-hasPermi="['iot:device:edit']"
+                  v-show="form.deviceId != 0">淇�
+                  鏀�</el-button>
+                <el-button type="primary" @click="submitForm" v-hasPermi="['iot:device:add']"
+                  v-show="form.deviceId == 0">鏂�
+                  澧�</el-button>
+              </el-form-item>
+            </el-form>
+          </div>
+          <div class="rightCount">
+            <div class="contebtBoder">
+              <div id="map" style="height:100%; width: 100%">鍦板浘灞曠ず鍖哄煙锛屾柊澧炲悗鏄剧ず</div>
+            </div>
+            <div   class="contebtBoder" style="margin-top: 20px;">
+              <three-js :someData="someData"></three-js>
+            </div>
+          </div>
+        </div>
+
 
         <!-- 閫夋嫨浜у搧 -->
         <product-list ref="productList" :productId="form.productId" @productEvent="getProductData($event)" />
@@ -127,27 +156,27 @@
 
       <el-tab-pane name="runningStatus" v-if="form.deviceType !== 3 && !isSubDev">
         <span slot="label">杩愯鐘舵��</span>
-        <running-status ref="runningStatus" :device="form" @statusEvent="getDeviceStatusData($event)"/>
+        <running-status ref="runningStatus" :device="form" @statusEvent="getDeviceStatusData($event)" />
       </el-tab-pane>
 
       <el-tab-pane name="runningStatus" v-if="isSubDev">
         <span slot="label"><span style="color:red;">锟� </span>杩愯鐘舵��</span>
-        <business ref="business"/>
+        <business ref="business" />
       </el-tab-pane>
 
       <el-tab-pane name="sipChannel" :disabled="form.deviceId === 0" v-if="form.deviceType === 3">
         <span slot="label"><span style="color:red;">锟� </span>璁惧閫氶亾</span>
-        <business ref="business"/>
+        <business ref="business" />
       </el-tab-pane>
 
       <el-tab-pane :disabled="form.deviceId === 0" v-if="form.deviceType === 3" name="sipPlayer">
         <span slot="label"><span style="color:red;">锟� </span>璁惧鐩存挱</span>
-        <business ref="business"/>
+        <business ref="business" />
       </el-tab-pane>
 
       <el-tab-pane :disabled="form.deviceId === 0" v-if="form.deviceType === 3" name="sipVideo">
         <span slot="label"><span style="color:red;">锟� </span>鐩存挱褰曞儚</span>
-        <business ref="business"/>
+        <business ref="business" />
       </el-tab-pane>
 
       <el-tab-pane name="deviceTimer" :disabled="form.deviceId === 0"
@@ -172,7 +201,7 @@
         <device-func ref="deviceFuncLog" :device="form" />
       </el-tab-pane>
 
-      <el-tab-pane name="deviceMonitor" :disabled="form.deviceId == 0 "
+      <el-tab-pane name="deviceMonitor" :disabled="form.deviceId == 0"
         v-if="form.deviceType !== 3 && hasShrarePerm('monitor')">
         <span slot="label">瀹炴椂鐩戞祴</span>
         <device-monitor ref="deviceMonitor" :device="form" />
@@ -263,10 +292,15 @@
 import business from "@/views/iot/business/index.vue";
 import vueQr from 'vue-qr';
 import { loadBMap } from '@/utils/map.js';
-import { deviceSynchronization, getDevice, addDevice, updateDevice, generatorDeviceNum, listDevice, getMqttConnect } from '@/api/iot/device';
+import {
+  deviceSynchronization, getDevice, addDevice, updateDevice,
+  generatorDeviceNum, listDevice, getMqttConnect, modelSelectPublishes,
+  setModelInsertModel, setModelSelectModelByPage
+} from '@/api/iot/device';
 import { getDeviceRunningStatus } from '@/api/iot/device';
 import { cacheJsonThingsModel } from '@/api/iot/model';
 import { getDeviceTemp } from '@/api/iot/temp';
+import threeJs from '../../threeJs/index.vue'
 
 export default {
   name: 'DeviceEdit',
@@ -283,6 +317,7 @@
     deviceTimer,
     JsonViewer,
     vueQr,
+    threeJs
   },
   watch: {
     activeName(val) {
@@ -343,7 +378,9 @@
         serialNumber: '',
         deviceType: 1,
         isSimulate: 0,
+
       },
+      modeUrl: null,
       //mqtt鍙傛暟鏌ョ湅
       listQuery: {
         clientId: 0,
@@ -389,9 +426,12 @@
         ],
       },
       isMediaDevice: false,
+      modelOption: [],
+      someData: null, showModelLayer: false,
     };
   },
   created() {
+    this.getListSource();
     let activeName = this.$route.query.activeName;
     if (activeName != null && activeName != '') {
       this.activeName = activeName;
@@ -416,6 +456,28 @@
     this.mqttUnSubscribe(this.form);
   },
   methods: {
+    // Js
+    changeSelect() {
+      this.$forceUpdate() // 寮哄埗鍒锋柊
+    },
+    getListSource() {
+      modelSelectPublishes({
+        name: '',
+        type: ''
+      }).then((response) => {
+        if (response.code == 200) {
+          if (response.data) {
+
+            this.modelOption = response.data;
+          } else {
+
+            this.modelOption = [];
+          }
+        } else {
+          this.$message('妯″瀷鏁版嵁鍒楄〃鑾峰彇澶辫触銆�');
+        }
+      })
+    },
     /* 杩炴帴Mqtt娑堟伅鏈嶅姟鍣� */
     async connectMqtt() {
       if (this.$mqttTool.client == null) {
@@ -522,7 +584,7 @@
         // 鑾峰彇鐩戞祴缁熻鏁版嵁
         if (panel.name === 'deviceStastic' && !this.isSubDev) {
           this.$refs.deviceStatistic.getListHistory();
-        } else if (panel.name === 'deviceTimer'&& !this.isSubDev) {
+        } else if (panel.name === 'deviceTimer' && !this.isSubDev) {
           this.$refs.deviceTimer.getList();
         }
       });
@@ -545,6 +607,7 @@
     },
     /**鑾峰彇璁惧璇︽儏*/
     getDevice(deviceId) {
+
       getDevice(deviceId).then(async (response) => {
         // 鍒嗕韩璁惧鑾峰彇鐢ㄦ埛鏉冮檺
         response.data.userPerms = [];
@@ -764,34 +827,58 @@
       this.$refs['form'].validate((valid) => {
         if (valid) {
           if (this.form.deviceId != 0) {
-            updateDevice(this.form).then((response) => {
-              if (response.data == 0) {
-                this.$modal.alertError(response.msg);
-              } else {
-                this.$modal.alertSuccess('淇敼鎴愬姛');
-                this.form = JSON.parse(JSON.stringify(this.form));
-                this.loadMap();
-              }
-            });
+            this.setEditDevice();
           } else {
-            addDevice(this.form).then(async (response) => {
-              // 鑾峰彇璁惧鐘舵��
-              await this.getDeviceStatusWitchThingsModel(response);
-              if (this.form.deviceId == null || this.form.deviceId == 0) {
-                this.$modal.alertError('璁惧缂栧彿宸茬粡瀛樺湪锛屾坊鍔犺澶囧け璐�');
-              } else {
-                if (this.form.status == 2) {
-                  this.deviceStatus = 1;
-                }
 
-                this.$modal.alertSuccess('娣诲姞璁惧鎴愬姛');
-                this.loadMap();
-              }
-            });
+            this.setAddDevice();
           }
         }
       });
     },
+    setAddDevice() {
+      const modeUrl = this.modeUrl;
+      const modeName = this.form.deviceName;
+      addDevice(this.form).then(async (response) => {
+        // 鑾峰彇璁惧鐘舵��
+        await this.getDeviceStatusWitchThingsModel(response);
+        if (this.form.deviceId == null || this.form.deviceId == 0) {
+          this.$modal.alertError('璁惧缂栧彿宸茬粡瀛樺湪锛屾坊鍔犺澶囧け璐�');
+        } else {
+          if (this.form.status == 2) {
+            this.deviceStatus = 1;
+          }
+          if (modeUrl && response.data.deviceId) {
+            this.setAddmodelToDevice(modeName, modeUrl, response.data.deviceId);
+          }
+          this.$modal.alertSuccess('娣诲姞璁惧鎴愬姛');
+          this.loadMap();
+        }
+      });
+    },
+    setEditDevice() {
+      updateDevice(this.form).then((response) => {
+        if (response.data == 0) {
+          this.$modal.alertError(response.msg);
+        } else {
+          this.$modal.alertSuccess('淇敼鎴愬姛');
+          this.form = JSON.parse(JSON.stringify(this.form));
+          this.loadMap();
+        }
+      });
+    },
+    setAddmodelToDevice(modeName, layerId, deviceId) {
+
+      setModelInsertModel({
+        "deviceid": deviceId,
+        "layerid": layerId,
+        "name": modeName
+      }).then(response => {
+
+      })
+    },
+
+
+
     /** 鑾峰彇璁惧鐘舵�佸拰鐗╂ā鍨� **/
     async getDeviceStatusWitchThingsModel(response) {
       // 鑾峰彇缂撳瓨鐗╂ā鍨�
@@ -809,6 +896,9 @@
       // 鏍煎紡鍖栫墿妯″瀷锛屾媶鍒嗗嚭鐩戞祴鍊�,鏁扮粍娣诲姞鍓嶇紑
       this.formatThingsModel(response.data);
       this.form = response.data;
+
+
+
       // 瑙f瀽璁惧鎽樿
       if (this.form.summary != null && this.form.summary != '') {
         this.summary = JSON.parse(this.form.summary);
@@ -819,6 +909,38 @@
       //Mqtt璁㈤槄
       this.connectMqtt();
       this.mqttSubscribe(this.form);
+
+      this.$nextTick(() => {
+        this.getModelURL(response.data.deviceId)
+      })
+
+    },
+    getModelURL(res) {
+
+      setModelSelectModelByPage({
+        deviceid: res,
+        pageIndex: 1,
+        pageSize: 10
+      }).then(response => {
+        if (response.code != 200 || response.data.length <= 0) return
+        const id = response.data[0].layerid;
+        this.modeUrl = id
+        if (this.modeUrl) {
+          const obj = this.modelOption.filter(item => {
+            if (item.id == id) {
+              return item
+            }
+          })
+          if (obj.length > 0) {
+           
+            this.showModelLayer = true;
+            this.$nextTick(()=>{
+              this.someData = obj[0].url
+            })
+            
+          }
+        }
+      })
     },
     /**閫夋嫨浜у搧 */
     selectProduct() {
@@ -930,3 +1052,26 @@
   },
 };
 </script>
+
+<style lang="scss" scoped>
+.leftCount {
+  flex: 1
+}
+
+.rightCount {
+  width: 30%;
+  height: 100%;
+  padding-left: 20px;
+
+  .contebtBoder {
+    border: 1px solid #dfe4ed;
+    border-radius: 5px;
+    padding: 5px;
+    text-align: center;
+    line-height: 400px;
+    height: 390px;
+    position: relative;
+  }
+
+}
+</style>
\ No newline at end of file

--
Gitblit v1.9.3