From 032a374b420f16b3a7c01a97e7b11913bd98043c Mon Sep 17 00:00:00 2001
From: gaosp <gaosp>
Date: 星期二, 16 一月 2024 00:40:39 +0800
Subject: [PATCH] update

---
 src/container/Map/Map.vue |  143 +++++++++++++++++++++++++++++++++--------------
 1 files changed, 100 insertions(+), 43 deletions(-)

diff --git a/src/container/Map/Map.vue b/src/container/Map/Map.vue
index f39d5b6..85117c2 100644
--- a/src/container/Map/Map.vue
+++ b/src/container/Map/Map.vue
@@ -1,7 +1,7 @@
 <!--
  * @Date: 2024-01-05 23:47:53
  * @LastEditors: Sneed
- * @LastEditTime: 2024-01-15 23:13:00
+ * @LastEditTime: 2024-01-16 00:19:18
  * @FilePath: /belleson-frontend/Users/mache/Documents/demo/mdc/src/container/Map/Map.vue
 -->
 <template>
@@ -17,8 +17,8 @@
                 <el-input class="input" v-show="status !==2" v-model="rows" />
                 <span>鍒楁暟:</span>
                 <el-input class="input" v-show="status !==2" v-model="cols" />
-                <div class="plant-name" v-if="status===2">{{plantName}}</div>
-                
+                <!-- <div class="plant-name" v-if="status===2">{{plantName}}</div> -->
+                <el-input class="plant-name" v-model="plantName" placeholder="璇疯緭鍏ュ巶鍚�"/>
             </div>
             <div class="table" :class="$route.name ==='preview' ? 'active' : ''" >
                 <div class="table-action" :style="position" v-show="showAction && status !== 2">
@@ -27,11 +27,6 @@
                     <div @click="sign(1)">杩囬亾</div>
                     <div @click="sign(2)">鏈哄簥</div>
                     <div @click="sign(0)">鍙栨秷</div>
-                    <div @click="edit" v-if="showEdit">淇敼鏈哄簥</div>
-                    <!-- <div>澧炲姞琛�</div> -->
-                    <!-- <div>鍒犻櫎琛�</div> -->
-                    <!-- <div>澧炲姞鍒�</div> -->
-                    <!-- <div>鍒犻櫎鍒�</div> -->
                 </div>
                 <div :style="{width: (cols * height + 'px'),height: rows * height + 'px'}">
                     <table >
@@ -41,14 +36,28 @@
                             :height="v.rowspan* height + 'px'"
                             :class="{'active': (range.x !=='' && v.rowIndex >=range.x && v.rowIndex<=range.x1 && v.colIndex>=range.y && v.colIndex<=range.y1),aisle: v.type ===1}" @mousedown="e => onMousedown(e, v)" @mousemove="e => onMouseMove(e, v)" v-for="v in item"
                                 :rowspan="v.rowspan" :colspan="v.colspan" :key="v.rowIndex + '-' + v.colIndex">
-                                <img @click="addDevice($event,v)" @mousedown="e => e.stopPropagation()" v-if="v.type ===2 && status!==2 && !v.id" src="./img/+.png" alt="">
-                                <Device v-if="v.id" :id="v.id" style="width: 100%;height: 100%;"></Device>
+                                <img @click="addDevice($event,v)" @mousedown="e => e.stopPropagation()" v-if="v.type ===2 && status!==2 && !v.id" src="./img/+.png" alt="娣诲姞鏈哄簥" title="娣诲姞鏈哄簥">
+                                <Device v-if="v.id" :id="v.id" style="width: 100%;height: 100%;" :deviceList="deviceList"
+:plantDeviceList="plantDeviceList"></Device>
                             </td>
                         </tr>
                     </table>
                 </div>
             </div>
         </div>
+        <el-dialog
+        :title="娣诲姞璁惧"
+        :close-on-click-modal="false"
+        width="20%"
+        :visible.sync="addStatus">
+        <el-select class="wkshoplist" clearable v-model="deviceId" placeholder="璇烽�夋嫨">
+            <el-option v-for="item in deviceList" :key="item.machineId" :label="item.machineName" :value="item.machineId">
+            </el-option>
+        </el-select>
+        <span slot="footer" class="dialog-footer">
+            <el-button size="mini" type="primary" style="background-color: #409EFF;" @click="saveDevice">淇濆瓨</el-button>
+        </span>
+      </el-dialog>
     </div>
 </template>
 <script>
@@ -60,13 +69,13 @@
     }
 }
 import mixins  from '@/mixins/index'
-import AddMachine from './addMachine.vue'
+// import AddMachine from './addMachine.vue'
 import Device from '../workshop/device.vue'
 import  {mapGetters} from 'vuex'
 export default {
     mixins: [mixins],
     components: {
-        AddMachine,
+        // AddMachine,
         Device
     },
     props: {
@@ -177,7 +186,7 @@
         },
         currentMap: {
             handler () {
-                
+                console.log(this.currentMap)
                 if (!this.currentMap || this.currentMap.length === 0) return
                 if (this.currentMap.length > 0) this.map = this.currentMap
                 this.rows = this.currentMap.length;
@@ -226,22 +235,33 @@
         }
     },
     methods: {
-        createMap() {
-            let data = []
-            for (var i = 0; i < this.rows; i++) {
-                let arr = []
-                for (var j = 0; j < this.cols; j++) {
-                    arr.push({
-                        rowspan: 1,
-                        colspan: 1,
-                        rowIndex: i,
-                        colIndex: j,
-                        type: ''
-                    })
-                }
-                data.push(arr)
+        async createMap() {
+            let res=true
+            if (this.id) {
+                res = await this.$confirm('鐢熸垚鍦板浘灏嗚鐩栧綋鍓嶆墍鏈夎缃紝纭畾閲嶆柊鐢熸垚?', '鎻愮ず', {
+                    confirmButtonText: '纭畾',
+                    cancelButtonText: '鍙栨秷',
+                    type: 'warning'
+                })
+                console.log(res)
             }
-            this.map = data
+            if (res || res === 'confirm') {
+                let data = []
+                for (var i = 0; i < this.rows; i++) {
+                    let arr = []
+                    for (var j = 0; j < this.cols; j++) {
+                        arr.push({
+                            rowspan: 1,
+                            colspan: 1,
+                            rowIndex: i,
+                            colIndex: j,
+                            type: ''
+                        })
+                    }
+                    data.push(arr)
+                }
+                this.map = data
+            }
         },
         contextmenu(e) {
             console.log(e)
@@ -331,6 +351,7 @@
                 for(var j=y;j<=y1;j++) {
                     let arr = [...(this.map[i])]
                     arr[j].type = type
+                    arr[j].id = undefined
                     this.$set(this.map,i,arr)
                 }
             }
@@ -338,17 +359,37 @@
             this.$forceUpdate()
         },
         addDevice (e,v) {
-            if(this.status ===2) return 
             e.stopPropagation()
             this.addStatus = true
             this.currentAdd =  v
         },
         del () {
-            this.$http.postJson('/plant/delete',{
+            this.$confirm('纭畾瑕佹案涔呭垹闄ゆ鍘傛埧锛屽叧鑱旂殑璁惧灏嗛噸缃�?', '鎻愮ず', {
+                confirmButtonText: '纭畾',
+                cancelButtonText: '鍙栨秷',
+                type: 'warning'
+            }).then(res => {
+                this.$http.postJson('/plant/delete',{
                     ids: [this.id]
                 }).then(res => {
+                    this.$message({
+                        type: 'info',
+                        message: '鍒犻櫎鎴愬姛'
+                    })
                     this.$emit('out')
+                }).catch(() => {
+                    this.$message({
+                        type: 'info',
+                        message: '鍒犻櫎澶辫触'
+                    })
                 })
+            }, () => {
+                this.$message({
+                    type: 'info',
+                    message: '鍙栨秷鍒犻櫎'
+                })
+            })
+            
         },
         save () {
             if (!this.id) {
@@ -356,6 +397,10 @@
                     name: this.plantName,
                     gridSetting: JSON.stringify(this.map)
                 }).then(res => {
+                    this.$message({
+                    type: 'info',
+                        message: '鎿嶄綔鎴愬姛'
+                    })
                     this.$emit('out')
                     console.log(res)
                 })
@@ -365,6 +410,10 @@
                     gridSetting: JSON.stringify(this.map),
                     id: this.id
                 }).then(res => {
+                    this.$message({
+                    type: 'info',
+                        message: '鎿嶄綔鎴愬姛'
+                    })
                     this.$emit('out')
                     console.log(res)
                 })
@@ -377,20 +426,28 @@
         close () {
             this.addStatus = false
         },
-        edit (e) {
-            if(this.status ===2) return 
-            e.stopPropagation()
-            this.addStatus = true
+        saveDevice () {
+            this.setmachineId(this.deviceId)
         },
         setmachineId (id) {
-            console.log(id)
             if (!id) return
-            let i = this.currentAdd.rowIndex
-            let j = this.currentAdd.colIndex
-            let arr = [...(this.map[i])];
-            arr[j].id = id
-            this.$set(this.map,i,arr)
-            this.close()
+            try {
+                let i = this.currentAdd.rowIndex
+                let j = this.currentAdd.colIndex
+                let arr = [...(this.map[i])];
+                arr[j].id = id
+                this.$set(this.map,i,arr)
+                this.$message({
+                    type: 'info',
+                    message: '鎿嶄綔鎴愬姛'
+                })
+            } catch (error) {
+                this.$message({
+                    type: 'info',
+                    message: '鎿嶄綔澶辫触锛岃閲嶈瘯'
+                })
+            }
+            this.addStatus = false
         }
     },
 }
@@ -438,8 +495,8 @@
     }
     .plant-name {
         width: 120px;
-        margin-left: auto;
-        margin-right: 30px;
+        margin-left: 20px;
+        // margin-right: 30px;
         text-align: center;
         line-height: 28px;
         background: rgba(23,38,67,0.6);

--
Gitblit v1.9.3