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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<template>
<!-- 配置文件更新到设备对话框 -->
<el-dialog
@close="close"
opened="open"
v-dialogDrag
style="font-size: 10px; " width='600px'
:title="$t('DeviceConfigurationManagement.profileUpdateTitle')"
v-if="configurationUpdate"
:visible.sync="configurationUpdate">
<el-table
fit="true"
height="350"
ref="singleTable"
:data="configList"
header-row-class-name="table-header"
cell-class-name="table-cell"
highlight-current-row
stripe
tooltip-effect="dark"
@selection-change="handleSelectionChangeUpdate">
<el-table-column
type="selection"
:selectable='checkboxT'
width="28">
</el-table-column>
<el-table-column
prop="configFileName"
:label="$t('ProfileManagement.configFileName')"
:show-overflow-tooltip="true">
</el-table-column>
<el-table-column
prop="timestamp"
:formatter="formatTime"
:label="$t('ProfileManagement.timestamp')"
:show-overflow-tooltip="true">
</el-table-column>
<el-table-column
prop="description"
:label="$t('ProfileManagement.description')"
:show-overflow-tooltip="true">
</el-table-column>
</el-table>
<el-row slot="footer" class="dialog-footer" style="line-height: 30px;">
<el-checkbox style="margin:0px;position: absolute;left:14px;" v-model="flagUpdate">
{{$t("ProfileManagement.effectiveImmediately")}}
</el-checkbox>
<el-button size='mini' type="primary" @click="updateProfile"
v-loading.fullscreen.lock="fullscreenLoading">{{$t("DeviceConfigurationManagement.updateProfile")}}
</el-button>
<el-button size='mini' @click="close">
{{$t("common.cancel")}}
</el-button>
</el-row>
</el-dialog>
</template>
<script>
import ConfigFileService from '@/domain/services/ConfigFileService.js'
import HelperUtil from '../../../utils/HelperUtil'
let curThis = ''
export default {
props: ['command'],
data () {
return {
configList: [],
// 为了禁用当前行
currentIndex: -1,
// 是否立即生效提示
downloadToDeviceFlag: -1,
flagUpdate: false,
multipleSelectionUpdate: [],
configurationUpdate: false,
currentDevice: this.command.target,
currentDeviceKey: null,
currentConfKey: null,
// 数据加载过程中,覆盖界面
fullscreenLoading: false
}
},
methods: {
/**
* @Description : 格式化时间
* @author : ls
* @date : 2020/6/11 16:44
* @param :
* @return :
*/
formatTime (val) {
return HelperUtil.timeTran(val.timestamp)
},
// 更新配置文件:复选框
checkboxT (row, rowIndex) {
if (rowIndex === this.currentIndex) {
return false
} else {
return true
}
},
open () {
console.log('获取全部配置信息:')
this.getAllConfigFile()
},
close () {
this.command.done()
},
getAllConfigFile () {
console.log('获取全部配置信息:')
let _this = this
// 为了测试其他先注释了
ConfigFileService.getAllConfigFileCollection().then(result => {
// 成功
_this.configList = Object.values(result)
for (var i = 0; i < _this.configList.length; i++) {
if (_this.configList[i].configFileKey == _this.currentConfKey) {
_this.currentIndex = i
}
}
}).catch(err => {
// 失败
_this.InfoTip.errorTip(_this, err)
})
},
/**
* @Description :设备配置更新表格多选框改变时,将所选行进行保存
* @author :
* @param :
* @return :
* @exception :
* @date :
*/
handleSelectionChangeUpdate (val) {
this.multipleSelectionUpdate = val
},
/**
* @Description :第二步:更新配置信息选中数目验证
* @author :
* @param :
* @date :
*/
updateProfile: function () {
if (this.multipleSelectionUpdate.length == 0) {
this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.UPDATE_SELECT_CODE))
} else if (this.multipleSelectionUpdate.length > 1) {
this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.UPDATE_ONLY_ONE_CODE))
} else {
// 第三步生效提示
this.updateEffectiveTip()
}
},
/**
* @Description :第三步:更新配置信息生效提示
* @author :
* @param :
* @date :
*/
updateEffectiveTip: function () {
if (this.flagUpdate == true) {
this.$confirm(this.$t('ProfileManagement.EffectiveImmediatelyRebootNow'),
this.$t('ProfileManagement.Attention'), {
confirmButtonText: this.$t('common.ok'),
cancelButtonText: this.$t('common.cancel'),
type: 'warning',
center: true
}).then(() => {
this.downloadToDeviceFlag = 1
this.$options.methods.updateToDevice()
}).catch(() => {
})
} else if (this.flagUpdate == false) {
this.$confirm(this.$t('ProfileManagement.NotEffectiveImmediatelyNotRebootNow'),
this.$t('ProfileManagement.Attention'), {
confirmButtonText: this.$t('common.ok'),
cancelButtonText: this.$t('common.cancel'),
type: 'warning',
center: true
}).then(() => {
this.downloadToDeviceFlag = 0
this.$options.methods.updateToDevice()
}).catch(() => {
})
}
},
/**
* @Description :第四步:更新配置信息
* @author :
* @param :
* @date :
*/
updateToDevice: function () {
let _this = curThis
var deviceKeyList = []
deviceKeyList.push(_this.currentDeviceKey)
let loadingInstance = _this.Loading.openLoading()
ConfigFileService.downloadConfigToDevice(_this.multipleSelectionUpdate[0].configFileKey, _this.downloadToDeviceFlag, deviceKeyList).then(result => {
_this.Loading.closeLoading(loadingInstance)
_this.InfoTip.successTip(_this, HelperUtil.getStatusCodeObjectByCode(_this.successCode.OTHERS_CODE))
_this.close()
}).catch(err => {
_this.Loading.closeLoading(loadingInstance)
_this.InfoTip.errorTip(_this, err)
})
}
},
created () {
curThis = this
},
mounted () {
this.configurationUpdate = true
this.getAllConfigFile()
this.currentDeviceKey = this.currentDevice.deviceKey
this.currentConfKey = this.currentDevice.configFileKey
}
}
</script>
<style scoped>
</style>