gaosp
2024-01-16 f8901c0adf0afada9620203eeeebb4fe59e7ce89
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!--
 * @Date: 2024-01-05 22:26:22
 * @LastEditors: Sneed
 * @LastEditTime: 2024-01-16 22:50:48
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/mdc/src/container/mapPreview/index.vue
-->
<template>
    <div class="workshop">
        <div class="preview">
            <LeftStatus class="left" :info="info">
                <template>
                    <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>
                    </el-select>
                </template>
            </LeftStatus>
            <div class="right">
                <Status v-show="id" :info="info" />
                <div class="preview-map">
                    <Map v-if="id" :id="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'
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', {}).then(res => {
                try {
                    this.mapList = this.workshopList.filter(v => v.gridSetting && v.gridSetting != '{}')
                    if (this.mapList.length === 0) {
                        this.status = 0
                    }
                    this.id = this.mapList[0].id
                } catch (error) {
                    console.error(error)
                }
            })
        },
    },
    mounted() {
        this.getMapList()
    }
}
</script>
<style lang="scss">
.left-select {
    .el-input__inner {
        background: #435F9E;
        color: #C6DCE0;
        border: none;
    }
}
</style>
<style lang="scss" scoped>
.workshop {
    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;
            flex-direction: column;
 
            .preview-map {
                margin-top: 20px;
                flex: 1 1 auto;
                overflow: hidden;
            }
        }
    }
}
</style>