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
| <template>
| <content-box :title="fullStationName" class="mgl8">
| <charger-status-tab-pane :info="info"></charger-status-tab-pane>
| </content-box>
| </template>
|
| <script>
| import ContentBox from "@/components/ContentBox";
| import ChargerStatusTabPane from "./components/ChargerStatusTabPane";
| import getChargerInfo from "./js/getChargerInfo";
| import {Timeout} from "@/assets/js/tools";
| import { getInfoById, getChargeDeviceData } from "@/views/dataMager/js/power";
| import createWs from "@/assets/js/websocket";
| const WSMixin = createWs("RealTime");
|
| export default {
| name: "chargerStatus",
| mixins: [WSMixin],
| components: {
| ChargerStatusTabPane,
| ContentBox
| },
| watch: {
| "$route.params.powerDeviceId"(powerDeviceId) {
| this.$nextTick(() => {
| this.getPowerInfo(powerDeviceId);
| });
| },
| },
| data() {
| return {
| isOpen: false,
| powerInfo: {
| powerDeviceId: 0,
| stationId: 0,
| stationName: "",
| stationName1: "",
| stationName2: "",
| stationName3: "",
| stationName4: " ",
| stationName5: "",
| },
| info: getChargerInfo(),
| }
| },
| methods: {
| getPowerInfo(powerDeviceId) {
| getInfoById({
| powerDeviceId: powerDeviceId
| }).then(res => {
| res = res.data;
| if (res.code && res.data.list.length) {
| this.powerInfo = res.data.list[0];
| } else {
| this.powerInfo = {
| powerDeviceId: 0,
| stationId: 0,
| stationName: "",
| stationName1: "",
| stationName2: "",
| stationName3: "",
| stationName4: " ",
| stationName5: "",
| };
| }
| // 开启查询
| this.sendMessage();
| }).catch(error => {
| console.log(error);
| });
| },
| onWSOpen() {
| this.sendMessage();
| },
| sendMessage() {
| let powerInfo = this.powerInfo;
| // console.log(powerInfo, '=====powerInfo');
| if (!powerInfo.powerDeviceId) {
| return false;
| }
| let params = {
| // battGroupId: batt.battGroupId,
| // devId: batt.fbsdeviceId,
| powerDeviceId: this.powerInfo.powerDeviceId,
| pageType: 'charger'
| };
| console.log(this.SOCKET.readyState, "====", params, JSON.stringify(params));
| this.SOCKET.send(JSON.stringify(params));
| },
| onWSMessage(res) {
| res = JSON.parse(res.data);
| let data = res.data.data;
| // console.log(data, "=====data");
| this.searchData(data.f9100Chargerstate);
| },
| searchData(res) {
| if (res) {
| if(res.code && res.data && res.data2.list.length) {
| this.info = res.data2.list[0];
| }else {
| this.info = getChargerInfo()
| }
| }
| },
| },
| computed: {
| fullStationName() {
| let powerInfo = this.powerInfo;
| if (powerInfo.powerDeviceId) {
| return powerInfo.stationName1 + "-" + powerInfo.stationName2
| + "-" + powerInfo.stationName5 + "-" + powerInfo.stationName3 + "-"+powerInfo.powerDeviceName;
| } else {
| return "未知站点名称";
| }
| }
| },
| mounted() {
| // 获取电源信息
| let powerDeviceId = this.$route.params.powerDeviceId;
| if (powerDeviceId) {
| this.getPowerInfo(powerDeviceId);
| }
| }
| }
| </script>
|
| <style scoped>
| .mgl8 {
| margin-left: 8px;
| }
| </style>
|
|