From 10562a6dac1492fe3dda566a800a4fec1f6e3bca Mon Sep 17 00:00:00 2001
From: gaosp <gaosp>
Date: 星期日, 14 一月 2024 15:09:34 +0800
Subject: [PATCH] Merge branch 'master' of http://www.beijingsoft.cn:9090/r/mdc-front

---
 src/container/Map/addMachine.vue |  142 +++++++++++++++++++++++++++++-----------------
 1 files changed, 89 insertions(+), 53 deletions(-)

diff --git a/src/container/Map/addMachine.vue b/src/container/Map/addMachine.vue
index 1a0c427..6b04565 100644
--- a/src/container/Map/addMachine.vue
+++ b/src/container/Map/addMachine.vue
@@ -1,7 +1,7 @@
 <!--
  * @Date: 2024-01-10 22:28:38
  * @LastEditors: Sneed
- * @LastEditTime: 2024-01-12 21:21:48
+ * @LastEditTime: 2024-01-14 15:04:42
  * @FilePath: /belleson-frontend/Users/mache/Documents/demo/mdc/src/container/Map/addMachine.vue
 -->
 <template>
@@ -11,12 +11,12 @@
             <el-input class="value" v-model="addInfo.name"></el-input>
         </div>
         <div class="map-add-item">
-                <span>鏈哄簥</span>
-                <el-select class="value" v-model="addInfo.id" placeholder="璇烽�夋嫨">
-                    <el-option v-for="item in accountList" :key="item.machineId" :label="item.uuid" :value="item.machineId">
-                    </el-option>
-                </el-select>
-            </div>
+            <span>鏈哄簥</span>
+            <el-select :disabled="!!machineid" class="value" v-model="addInfo.id" placeholder="璇烽�夋嫨">
+                <el-option v-for="item in accountList" :key="item.machineId" :label="item.uuid" :value="item.machineId">
+                </el-option>
+            </el-select>
+        </div>
         <div class="map-add-item">
             <span>IP</span>
             <el-input class="value" v-model="addInfo.ip"></el-input>
@@ -68,10 +68,10 @@
     </div>
 </template>
 <script>
-import { getWsl,getPcl,getRequest } from '@/api/Api'
+import { getWsl, getPcl, getRequest } from '@/api/Api'
 export default {
-    props: ['id'],
-    data () {
+    props: ['id', 'machineid'],
+    data() {
         return {
             shiftTypes: [
                 {
@@ -104,76 +104,112 @@
             },
         }
     },
-    created () {
+    watch: {
+        machineid: {
+            handler(val) {
+                if (val) {
+                    setTimeout(() => {
+                        getRequest('machineQuery', { size: 10, machineId: val }).then(res => {
+                            this.changewsl(res.data.records[0].workshopId)
+                            this.$nextTick(() => {
+                                try {
+                                    Object.keys(this.addInfo).forEach(item => {
+                                        this.addInfo[item] = res.data.records[0][item]
+                                    })
+                                    // this.addInfo.id = res.data.records[0].id
+                                } catch (error) {
+                                    console.error(error)
+                                }
+                            })
+                        })
+                    }, 1000)
+
+                }
+            },
+            immediate: true
+        }
+    },
+    created() {
         getPcl().then(res => {
             this.protocolList = res.data
         })
         getWsl().then(res => {
             this.workshopList = res.data
         })
-        getRequest('accountQuery',{}).then(res => {
+        getRequest('accountQuery', {}).then(res => {
             console.log(res)
             try {
                 this.accountList = res.data
             } catch (error) {
                 this.accountList = []
             }
-            
+
         })
     },
     methods: {
-        saveDevice () {
-            this.$emit('setmachineId',this.addInfo.id)
-            return
-            this.$http.postJson('/machine/save',{
-                ...this.addInfo,
-                plantId: this.id
-            }).then(res => {
-                this.$emit('setmachineId',this.addInfo.id)
-            })
+        saveDevice() {
+            let url = '/machine/save'
+            if (this.machineid) {
+                getRequest('machineUpdate',{
+                    ...this.addInfo,
+                    plantId: this.id
+                }).then(res => {
+                    this.$emit('setmachineId', this.addInfo.id)
+                })
+            } else {
+                getRequest('machineSave',{
+                    ...this.addInfo,
+                    plantId: this.id
+                }).then(res => {
+                    this.$emit('setmachineId', this.addInfo.id)
+                })
+            }
         },
-        changewsl (val) {
-            console.log(val)
+        changewsl(val) {
+            console.log(val, 'changewsl')
             try {
-                this.sectionIds = this.workshopList.find(item => item.id ===val).sections
+                this.sectionIds = this.workshopList.find(item => item.id === val).sections
             } catch (error) {
                 this.sectionIds = []
             }
         },
-        close () {
+        close() {
             this.$emit('close')
         }
     },
 }
 </script>
 <style lang="scss" scoped>
-    .map-add {
-        width: 100%;
-        height: 100%;
-        overflow: auto;
-        position: relative;
-        .map-add-item {
-            margin-top: 24px;
-            display: flex;
-            justify-content: center;
-            align-items: center;
-            span {
-                width: 150px;
-                font-size: 16px;
-                color: #C6DCE0;
-                text-align: right;
-                margin-right: 16px;
-            }
-            .value {
-                width: 400px;
-            }
-        }
-        .map-add-footer {
-            position: absolute;
-            bottom: 0;
+.map-add {
+    width: 100%;
+    height: 100%;
+    overflow: auto;
+    position: relative;
+
+    .map-add-item {
+        margin-top: 24px;
+        display: flex;
+        justify-content: center;
+        align-items: center;
+
+        span {
+            width: 150px;
+            font-size: 16px;
+            color: #C6DCE0;
             text-align: right;
-            padding-right: 30px;
-            width: 100%;
+            margin-right: 16px;
+        }
+
+        .value {
+            width: 400px;
         }
     }
-</style>
\ No newline at end of file
+
+    .map-add-footer {
+        position: absolute;
+        bottom: 0;
+        text-align: right;
+        padding-right: 30px;
+        width: 100%;
+    }
+}</style>
\ No newline at end of file

--
Gitblit v1.9.3