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/index.vue |  231 +++++++++++++++++++++++++++++----------------------------
 1 files changed, 119 insertions(+), 112 deletions(-)

diff --git a/src/container/Map/index.vue b/src/container/Map/index.vue
index f1a6efe..3532d36 100644
--- a/src/container/Map/index.vue
+++ b/src/container/Map/index.vue
@@ -1,158 +1,165 @@
 <!--
  * @Date: 2024-01-05 22:26:22
  * @LastEditors: Sneed
- * @LastEditTime: 2024-01-13 22:19:48
+ * @LastEditTime: 2024-01-13 23:14:55
  * @FilePath: /belleson-frontend/Users/mache/Documents/demo/mdc/src/container/Map/index.vue
 -->
 <template>
     <div class="workshop">
-        <Map v-if="status===0 || status === 1 && id" :status="status" :currentMap="currentMap" :name="plantName" :id="id" @out="out" />
+        <Map v-if="status === 0 || status === 1 && id" :status="status" :currentMap="currentMap" :name="plantName" :id="id"
+            @out="out" />
         <div v-else class="preview">
             <LeftStatus class="left" :info="info">
                 <template>
                     <div @click="editMap" class="edit-btn">
-                        {{id ? '杩涘叆缂栬緫鐘舵��' : '鏂板'}}
+                        {{ id ? '杩涘叆缂栬緫鐘舵��' : '鏂板' }}
                     </div>
                     <el-select clearable class="left-select" v-model="id" placeholder="璇烽�夋嫨">
-                        <el-option
-                        v-for="item in mapList"
-                        :key="item.id"
-                        :label="item.name"
-                        :value="item.id">
+                        <el-option v-for="item in mapList" :key="item.id" :label="item.name" :value="item.id">
                         </el-option>
                     </el-select>
                 </template>
             </LeftStatus>
             <div class="right">
-                <Status v-show="id" :info="info"/>
+                <Status v-show="id" :info="info" />
                 <div class="preview-map">
-                    <Map v-if="id" :status="2" :currentMap="currentMap"  @out="out" />
+                    <Map v-if="id" :status="2" :currentMap="currentMap" @out="out" />
                 </div>
             </div>
         </div>
     </div>
 </template>
 <script>
-    import Map from './Map.vue';
-    import Status from '@/components/newComp/Status'
-    import LeftStatus from './LeftStatus.vue'
-    import { getRequest, getUrl } from '@/api/Api'
-    export default {
-        components: {
-            Map,
-            Status,
-            LeftStatus
-        },
-        watch: {
-            id (val) {
-                if (!val) {
-                    this.currentMap = ''
-                    this.plantName = ''
-                    return
+import Map from './Map.vue';
+import Status from '@/components/newComp/Status'
+import LeftStatus from './LeftStatus.vue'
+import { getRequest, getUrl } from '@/api/Api'
+import { mapGetters } from 'vuex'
+export default {
+    components: {
+        Map,
+        Status,
+        LeftStatus
+    },
+    computed: {
+        ...mapGetters(['workshopList'])
+    },
+    watch: {
+        id(val) {
+            if (!val) {
+                this.currentMap = ''
+                this.plantName = ''
+                return
+            }
+            try {
+                this.currentMap = JSON.parse(this.mapList.find(item => item.id === this.id).gridSetting)
+                this.plantName = this.mapList.find(item => item.id === this.id).name
+            } catch (error) {
+
+            }
+            getRequest('machineList', {
+                plantId: this.id,
+            }).then(res => {
+                // this.list = res.data.list
+                this.info = {
+                    runRate: res.data.runRate,
+                    cutRate: res.data.cutRate,
+                    alarmRate: res.data.alarmRate,
+                    threeShiftRate: res.data.threeShiftRate,
+                    twoShiftRate: res.data.twoShiftRate,
+                    run: res.data.run,
+                    alarm: res.data.alarm,
+                    stop: res.data.stop,
+                    idle: res.data.idle
                 }
+            })
+        }
+    },
+    data() {
+        return {
+            id: '',
+            currentMap: [],
+            plantName: '',
+            mapList: [],
+            status: 2, // 0 鏂板 1缂栬緫 2鏌ョ湅
+            info: {
+                runRate: '',
+                cutRate: '',
+                alarmRate: '',
+                threeShiftRate: '',
+                twoShiftRate: '',
+                run: '',
+                alarm: '',
+                stop: '',
+                idle: '',
+            }
+        }
+    },
+    methods: {
+        getMapList() {
+            // this.$store.dispatch('GetPlanList', {})
+
+            this.$store.dispatch('GetPlanList', {}).then(res => {
                 try {
-                    this.currentMap = JSON.parse(this.mapList.find(item => item.id ===this.id).gridSetting)
-                    this.plantName = this.mapList.find(item => item.id ===this.id).name
-                } catch (error) {
-                    
-                }
-                getRequest('machineList', {
-                    plantId: this.id,
-                }).then(res => {
-                    // this.list = res.data.list
-                    this.info = {
-                        runRate: res.data.runRate,
-                        cutRate: res.data.cutRate,
-                        alarmRate: res.data.alarmRate,
-                        threeShiftRate: res.data.threeShiftRate,
-                        twoShiftRate: res.data.twoShiftRate,
-                        run: res.data.run,
-                        alarm: res.data.alarm,
-                        stop: res.data.stop,
-                        idle: res.data.idle
-                    }
-                })
-            }
-        },
-        data () {
-            return {
-                id: '',
-                currentMap: [],
-                plantName: '',
-                mapList: [],
-                status: 2, // 0 鏂板 1缂栬緫 2鏌ョ湅
-                info: {
-                    runRate: '',
-                    cutRate: '',
-                    alarmRate: '',
-                    threeShiftRate: '',
-                    twoShiftRate: '',
-                    run: '',
-                    alarm: '',
-                    stop: '',
-                    idle: '',
-                }
-            }
-        },
-        methods: {
-            getMapList() {
-                this.$store.dispatch('GetPlanList', {}).then(res => {
-                    this.mapList = res.data.filter (v => v.gridSetting && v.gridSetting!='{}')
+                    this.mapList = this.workshopList.filter(v => v.gridSetting && v.gridSetting != '{}')
                     if (this.mapList.length === 0) {
                         this.status = 0
-                    } else {
-                        this.status = 2
                     }
-                })
-            },
-            editMap () {
-                if (this.id) {
-                    this.status = 1
-                } else {
-                    this.status = 0
+                    this.id = this.mapList[0].id
+                } catch (error) {
+                    console.error(error)
                 }
-            },
-            out () {
-                this.status = 2
-                this.getMapList()
-            },
+            })
         },
-        mounted () {
+        editMap() {
+            if (this.id) {
+                this.status = 1
+            } else {
+                this.status = 0
+            }
+        },
+        out() {
+            this.status = 2
             this.getMapList()
-        }
+        },
+    },
+    mounted() {
+        this.getMapList()
     }
+}
 </script>
 <style lang="scss">
-    .left-select {
-        .el-input__inner {
-            background: #435F9E;
-            color: #C6DCE0;
-            border: none;
-        }
+.left-select {
+    .el-input__inner {
+        background: #435F9E;
+        color: #C6DCE0;
+        border: none;
     }
-    
+}
 </style>
 <style lang="scss" scoped>
-    .workshop {
+.workshop {
+    width: 100%;
+    height: 100%;
+
+    .preview {
         width: 100%;
         height: 100%;
-        .preview {
-            width: 100%;
-            height: 100%;
+        display: flex;
+
+        .right {
+            width: calc(100% - 194px);
+            padding-top: 30px;
+            flex: 0 1 auto;
             display: flex;
-            .right {
-                width: calc(100% -  194px);
-                padding-top: 30px; 
-                flex: 0 1 auto;
-                display: flex;
-                flex-direction: column;
-                
-                .preview-map {
-                    margin-top: 20px;
-                    flex: 1 1 auto;
-                    overflow: hidden;
-                }
+            flex-direction: column;
+
+            .preview-map {
+                margin-top: 20px;
+                flex: 1 1 auto;
+                overflow: hidden;
             }
         }
     }
+}
 </style>
\ No newline at end of file

--
Gitblit v1.9.3