gaosp
2024-02-03 4145f51803841d33fa68673f2b6aa6e451bf9461
src/container/mapPreview/Map.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2024-01-05 23:47:53
 * @LastEditors: Sneed
 * @LastEditTime: 2024-01-30 20:41:19
 * @LastEditTime: 2024-02-03 00:01:58
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/mdc/src/container/mapPreview/Map.vue
-->
<template>
@@ -16,7 +16,7 @@
                                :width="v.colspan * height + 'px'" :height="v.rowspan * height + 'px'" v-for="v in item"
                                :rowspan="v.rowspan" :colspan="v.colspan" :key="v.rowIndex + '-' + v.colIndex">
                                <div class="td-div" :style="{width:v.colspan * height - 2 + 'px',height: v.rowspan * height - 2 + 'px',overflow:'hidden'}">
                                    <Device v-if="v.id" :id="v.id" style="width: 100%;height: 100%;"
                                    <Device @toDetail="toDetail(v)" v-if="v.id" :id="v.id" style="width: 100%;height: 100%;"
                                        :deviceList="deviceList" :plantDeviceList="plantDeviceList"></Device>
                                </div>
                            </td>
@@ -38,6 +38,7 @@
}
import mixins from '@/mixins/index'
import Device from '../workshop/device.vue'
import { getRequest, getUrl } from '@/api/Api'
export default {
    mixins: [mixins],
    components: {
@@ -70,7 +71,8 @@
            map: null, // 地图数据
            leftMax: 0,
            marginLeft: 0,
            direction: true
            direction: true,
            plantDeviceList: []
        }
    },
    watch: {
@@ -87,8 +89,7 @@
            this.height = (document.querySelector('.table').getBoundingClientRect().height - 30) / 20
        },
        id: {
            handler() {
            handler(val) {
                if (this.move) {
                    this.marginLeft = 0
                    this.$nextTick(() => {
@@ -104,7 +105,16 @@
                        }
                    })
                }
                if(val) {
                    getRequest('machineList',{plantId: val}).then(res => {
                        this.plantDeviceList = res.list.map(item => {
                            return {
                                machineId: item.id,
                                machineName: item.machineName
                            }
                        }) || []
                    })
                }
            },
            immediate: true
        }
@@ -116,6 +126,21 @@
        }
    },
    methods: {
        toDetail(v) {
            if(this.move) return
            let info = {}
            if (v.id) {
                info = this.plantDeviceList.find(item => item.id == v.id)
            }
            window.localStorage.setItem('deviceInfo',JSON.stringify(info))
            this.$router.push({
                name: 'mapPreviewDetail',
                query: {
                    id: v.id,
                    name: info.workshop
                }
            })
        },
        moveFn() {
            if (this.marginLeft <= this.leftMax && this.marginLeft >= -5) {
                if (this.direction) {