equipmentDataRetransmission.vue
8.07 KB
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<template>
<a-form :model="queryForm" layout="inline" :label-col="{ style: { width: '70px' } }">
<a-form-item label="集团:">
<a-select v-model:value="queryForm.account_id"
style="width: 200px"
:options="accountList"
@change="onAccountChange"
optionFilterProp="label"
show-search
>
</a-select>
</a-form-item>
<a-form-item label="广场:">
<a-select v-model:value="queryForm.plaza_id"
mode="multiple"
:maxTagCount="1"
@change="onPlazaChange"
style="width: 200px"
:options="plazaList"
optionFilterProp="label"
show-search
>
</a-select>
</a-form-item>
<a-form-item label="选择设备:">
<a-select v-model:value="queryForm.device_id"
style="width: 300px"
mode="multiple"
:maxTagCount="1"
optionFilterProp="label"
:options="deviceList"
show-search
></a-select>
</a-form-item>
<a-form-item label="选择日期:">
<a-date-picker v-model:value="queryForm.date" :format="'YYYY-MM-DD'" style="width: 150px"/>
</a-form-item>
<a-form-item label="选择时间:">
<a-time-picker v-model:value="queryForm.startTime" style="width: 100px"/>
<a-time-picker v-model:value="queryForm.endTime" style="width: 100px"/>
</a-form-item>
<a-form-item>
<a-button type="primary" @click="confirmSearch" style="margin-right: 10px;">查询</a-button>
<a-button type="primary" @click="implement">执行</a-button>
</a-form-item>
</a-form>
<a-table :dataSource="deviceList" v-loading="isLoading" :rowKey="record=>record.serialnum" :columns="columns" :pagination="false">
</a-table>
</template>
<script>
import {reactive, ref, toRaw} from 'vue'
import moment from 'moment'
import {isArray} from '@/PublicUtil/Judgment'
import snapshotRecordApi from '@/views/SnapshotCluster/SnapshotRecord/SnapshotRecordApi'
import api from './api.js'
import axios from 'axios'
export default{
setup(){
const accountList = ref([])
const plazaList = ref([])
const deviceList = ref([])
const columns = ref([
{
title: '序号',
align:'center',
dataIndex: "index",
},
{
title: 'IP配置',
dataIndex: 'localIp',
align:'center',
},
{
title: '设备序列号',
dataIndex: 'serialnum',
align:'center',
},
{
title: '数据重传状态',
dataIndex: 'retransmission',
align:'center',
},
{
title: '设备重启状态',
dataIndex: 'restart',
align:'center',
}
])
const queryForm = reactive(
{
account_id: '',
plaza_id: [],
device_id: [],
date: moment().format('YYYY-MM-DD'),
startTime: moment().format('YYYY-MM-DD 08:00:00'),
endTime: moment().format('YYYY-MM-DD 23:59:59'),
}
)
const getAccountList = function() {
queryForm.account_id = []
accountList.value = []
snapshotRecordApi.getAccountList().then(
(r) => {
if (isArray(r))
{
for (const item of r)
{
accountList.value.push(
{
value: item.id,
label: item.name,
}
)
}
}
}
)
}
const onAccountChange = function() {
getPlazaList()
}
const getPlazaList = function() {
queryForm.plaza_id = []
plazaList.value = []
snapshotRecordApi.getPlazaList(
{
account_id: queryForm.account_id.toString()
}
).then(
(r) => {
if (isArray(r))
{
for (const item of r)
{
plazaList.value.push(
{
value: item.id,
label: item.name,
}
)
}
}
}
)
}
const onPlazaChange = function(){
queryForm.device_id = []
deviceList.value = []
getDevice()
}
const getDevice = function(){
// 获取设备
const rawData = toRaw(queryForm)
const data = {
mallIds: rawData.plaza_id.toString()
}
api.getDeviceList(data).then(
(r) => {
if (isArray(r))
{
for (var i = 0; i < r.length; i++) {
r[i].index = i+1
r[i].label = r[i].serialnum+"——"+r[i].localIp
r[i].value = r[i].serialnum
deviceList.value.push(r[i])
}
}
}
)
}
const confirmSearch = function(){
queryForm.device_id = []
deviceList.value = []
getDevice()
}
const implement = function(){
deviceList.value.forEach(item=>{
queryForm.device_id.forEach(serialnum=>{
if(item.serialnum == serialnum){
if(item.localIp){
axios({
method:'GET',
url: 'http://'+item.localIp+':8080/do/CboxWebClient/resultresend?starttime='+moment(queryForm.date).format('YYYY-MM-DD')+' '+moment(queryForm.startTime).format('HH:mm:ss')+'&endtime='+moment(queryForm.date).format('YYYY-MM-DD')+' '+moment(queryForm.endTime).format('HH:mm:ss')
}).then(result=>{
console.log(result)
})
}
}
})
})
}
const __main = function() {
getAccountList()
}
__main()
return{
deviceList,
accountList,
plazaList,
columns,
queryForm,
onAccountChange,
confirmSearch,
implement,
onPlazaChange
}
}
}
</script>
<style>
</style>