he wei
2025-05-13 0ceafa2c894b1b22f0506229ed83be5c8587e1cc
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<template>
    <vue-seamless-scroll :data="listData" :class-option="classOption" ref="seamlessScroll" class="my-outbox">
        <div class="my-inbox">
            <div v-for="(item,index) in listData" :key='index' ref='list' @click="clickItem(item)" class="my-list">
                <div v-if="!item.isEmpty" class="item">
                    <div class="station-name" :title="item.stationName3">{{item.stationName3}}</div>  <div class="alarm-time">{{item.almStartTime}}</div>  <div class="alarm-name">{{item.almSignalIdName ||'未知'}}</div>
                </div>
                <div class="item empty" v-else :style="{'width':item.width+'px'}"></div>
            </div>
        </div>
        <!-- <div class="my-inbox" slot="copy">
            <div v-for="(item,index) in listData" :key='index' ref='list' @click="clickItem(item)" class="my-list">
                <div v-if="!item.isEmpty">
                    {{item.stationName}}在{{item.almStartTime}}出现了{{item.alarmName||'未知'}}
                    <img src="../../assets/images/new.png" class="img" v-if="item.isNew">
                </div>
                <div v-else :style="{'width':item.width+'px'}"></div>
            </div>
        </div> -->
    </vue-seamless-scroll>
</template>
 
<script>
import vueSeamlessScroll from '@/layout/components/FooterScroll.vue';
export default {
    name: 'marquee-left',
    components: {
        vueSeamlessScroll
    },
    props: {
        sendVal: {
            type: Array,
            default() {
                return [];
            }
        },
    },
    data() {
        return {
            listData: [],
            classOption: {
                limitMoveNum: 0,
                direction: 1,
                step: 0.3,
            },
            startDis: window.screen.width,
            sstationObj: {},
            alarmId: "",
            emptyIndex: null,
            distanceWid: null,
            // 每一个内容的宽度
            disArr: [],
        }
    },
    watch: {
        'sendVal': {
            handler(val) {
                this.$nextTick(() => {
                    this.listData = JSON.parse(JSON.stringify(val))
                    var item = this.$refs.list
                    var arr = []
                    // 因为设置的margin值一样,所以取第一个就行。
                    var margin = 0
                    if (item && item.length > 0) {
                        margin = this.getMargin(item[0])
                    }
                    if (this.listData.length > 0) {
                        this.listData.map((jtem, i) => {
                            if (item && item.length > 0) {
                                arr.push(item[i]?.clientWidth + margin) // 把宽度和 margin 加起来就是每一个元素需要移动的距离
                            }
                        })
                    }
                    this.disArr = arr
                    // listData length无变化,仅仅是属性变更,手动调用下组件内部的reset方法
                    this.$refs.seamlessScroll.reset()
                })
            },
            immediate: true,
        },
    },
    mounted() {
 
    },
    beforeDestroy() {
 
    },
    computed: {
        search() {
            let list = this.stationObj;
      let id = this.alarmId;
      return '?province=' + list.stationName1 + '&city=' + list.stationName2 + '&county=' + list.stationName5 +
        '&home=' + list.stationName3 + '&alamId=' + id + "&stationName=" + list.stationName
    },
    },
    methods: {
        clickItem(val) {
            this.stationObj = val.stationObj;
            this.alarmId = val.almId;
      let pageFlag = Math.random();
            if (val.alarmType == '1') {
                //设备实时告警
                this.$router.push('/alarmMager/deviceTimequery' + this.search + '&fromType=fromIndex&'+"pageFlag="+pageFlag)
            }else if(val.alarmType=='2') {
        let strNum = RegExp('^1150');
        // 通信电源设备告警
        if(strNum.test(val.battGroupId)) {
          this.$router.push('/alarmMager/powerBoxAlarm' + this.search + '&fromType=fromIndex&'+"pageFlag="+pageFlag)
        }else {
          //电源实时告警-国网页面
          this.$router.push('/alarmMager/powerRealtimeInfo' + this.search + '&fromType=fromIndex&'+"pageFlag="+pageFlag)
        }
 
      } else {
                //电池实时告警
                this.$router.push('/alarmMager/batteryrTimequery' + this.search + '&fromType=fromIndex&'+"pageFlag="+pageFlag)
            }
        },
        // 获取margin属性
        getMargin(obj) {
            var marg = window.getComputedStyle(obj, null)['margin-right']
            marg = marg.replace('px', '')
            return Number(marg) // 强制转化成数字
        },
    }
}
</script>
 
<style scoped lang="less">
.my-outbox {
    /*color: #D7BC8D;*/
    overflow: hidden;
    color: #ffffff;
    /* height: 35px; */
    /*background: #422b02;*/
}
 
.my-inbox {
    white-space: nowrap;
    display: flex;
  flex-direction: column;
    align-items: center;
}
 
.my-list {
    margin-right: 25px;
    display: inline-block;
    font-size: 0.6rem;
    height: 40px;
    line-height: 40px;
    cursor: pointer;
    position: relative;
}
 
.my-list .img {
    width: 32px;
    height: 14px;
}
.item {
  display: flex;
  .station-name {
    display: inline-block;
    color: #fff;
    max-width: 14em;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    margin-right: 0.4em;
  }
  .alarm-time {
    display: inline-block;
    color: #ebf006;
    margin-left: 0.4em;
    margin-right: 0.4em;
  }
  .alarm-name {
    display: inline-block;
    color: #fc0303;
    margin-left: 0.4em;
  }
}
 
.my-uname {
    /*color: #FF8900;*/
    color: #ffffff;
}
</style>