vue2-client 1.2.40 → 1.2.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +109 -103
  2. package/docs/notice.md +22 -22
  3. package/package.json +1 -1
  4. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +555 -0
  5. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +149 -149
  6. package/src/base-client/components/common/XAddForm/XAddForm.vue +339 -338
  7. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +2 -1
  8. package/src/base-client/components/common/XForm/XForm.vue +275 -275
  9. package/src/base-client/components/iot/CustomerDetailsView/CustomerDetailsView.vue +225 -225
  10. package/src/base-client/components/iot/DataAnalysisView/DataAnalysisView.vue +244 -244
  11. package/src/base-client/components/iot/DeviceBrandDetailsView/DeviceBrandDetailsView.vue +452 -452
  12. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsCount.vue +330 -330
  13. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsException.vue +57 -57
  14. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsInstructOperate.vue +121 -121
  15. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsRead.vue +131 -131
  16. package/src/base-client/components/iot/DeviceTypeDetailsView/DeviceTypeDetailsView.vue +276 -276
  17. package/src/base-client/components/iot/InstructDetailsView/InstructDetailsView.vue +469 -469
  18. package/src/base-client/components/iot/LogDetailsView/LogDetailsView.vue +379 -379
  19. package/src/base-client/components/iot/MeterDetailsView/MeterDetailsView.vue +359 -359
  20. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsCount.vue +335 -335
  21. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsException.vue +184 -184
  22. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsHandPlan.vue +291 -291
  23. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsInstruct.vue +236 -236
  24. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsMain.vue +256 -256
  25. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsSellGas.vue +189 -189
  26. package/src/base-client/components/iot/WebmeterAnalysisView/WebmeterAnalysisView.vue +722 -722
  27. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +231 -231
  28. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +247 -247
  29. package/src/base-client/components/ticket/EmployeeDetailsView/EmployeeDetailsView.vue +370 -370
  30. package/src/base-client/components/ticket/TicketDetailsView/part/TicketDetailsFlow.vue +260 -260
  31. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +532 -532
  32. package/src/base-client/plugins/AppData.js +67 -67
  33. package/src/base-client/plugins/GetLoginInfoService.js +252 -252
  34. package/src/components/exception/ExceptionPage.vue +70 -70
  35. package/src/components/setting/Setting.vue +235 -235
  36. package/src/config/default/setting.config.js +35 -35
  37. package/src/config/index.js +3 -3
  38. package/src/layouts/SinglePageView.vue +72 -70
  39. package/src/layouts/header/HeaderNotice.vue +97 -97
  40. package/src/layouts/tabs/TabsView.vue +41 -40
  41. package/src/pages/login/Login.vue +201 -201
  42. package/src/pages/report/ReportTableHome.vue +28 -28
  43. package/src/pages/resourceManage/depListManage.vue +23 -23
  44. package/src/pages/resourceManage/funListManage.vue +23 -23
  45. package/src/pages/resourceManage/index.js +15 -15
  46. package/src/pages/resourceManage/orgListManage.vue +98 -98
  47. package/src/pages/resourceManage/roleListManage.vue +23 -23
  48. package/src/pages/resourceManage/staffListManage.vue +23 -23
  49. package/src/pages/system/ticket/submitTicketSuccess.vue +248 -248
  50. package/src/router/async/config.async.js +26 -26
  51. package/src/router/index.js +27 -27
  52. package/src/services/api/common.js +47 -47
  53. package/src/services/api/index.js +39 -39
  54. package/src/services/user.js +34 -34
  55. package/src/theme/default/style.less +47 -33
  56. package/src/utils/indexedDB.js +146 -146
  57. package/src/utils/routerUtil.js +359 -359
@@ -1,452 +1,452 @@
1
- <template>
2
- <a-drawer
3
- title="设备品牌详情"
4
- placement="right"
5
- :width="isMobile ? screenWidth : screenWidth * 0.85"
6
- :visible="visible"
7
- @close="onClose"
8
- >
9
- <form-group-query
10
- @getColumnJson="getColumnJson"
11
- :visible.sync="createQueryVisible"
12
- @saveQueryParams="saveQueryParams"
13
- />
14
- <form-group-edit
15
- @getColumnJson="getColumnJson"
16
- :visible.sync="editQueryVisible"
17
- :modifyModelData="this.details.f_params_json ? JSON.parse(this.details.f_params_json) : {}"
18
- @onSubmit="saveDeviceParams"
19
- />
20
- <a-spin :spinning="loadDeviceBrandDetails">
21
- <a-page-header :title="details.f_brand">
22
- <div class="row">
23
- <div class="content">
24
- <a-descriptions size="small" :column="isMobile ? 1 : 2">
25
- <a-descriptions-item label="设备厂家">{{ details.f_manufactor }}</a-descriptions-item>
26
- <a-descriptions-item label="设备别名">{{ details.f_alias }}</a-descriptions-item>
27
- <a-descriptions-item label="设备兼容方式">{{ details.f_compatible_mode }}</a-descriptions-item>
28
- <a-descriptions-item label="创建人">{{ details.f_inputtor }}</a-descriptions-item>
29
- <a-descriptions-item label="创建时间">{{ details.f_input_date }}</a-descriptions-item>
30
- </a-descriptions>
31
- </div>
32
- </div>
33
- <!-- actions -->
34
- <template v-slot:extra>
35
- <a-button-group style="margin-right: 4px;">
36
- <a-button type="dashed" @click="initView" :loading="loadDeviceBrandDetails">刷新</a-button>
37
- </a-button-group>
38
- <a-button-group style="margin-right: 4px;">
39
- </a-button-group>
40
- </template>
41
- <template slot="footer">
42
- <a-tabs :default-active-key="tabActiveKey" :activeKey="tabActiveKey" @change="handleTabChange" style="margin-bottom: 23px;">
43
- <template v-for="value in tabList">
44
- <a-tab-pane :key="value.key" :tab="value.tab"/>
45
- </template>
46
- </a-tabs>
47
- <div v-if="!loadDeviceBrandDetails">
48
- <x-form-table
49
- v-if="tabActiveKey === '1'"
50
- title="设备型号"
51
- :fixed-add-form="fixedAddForm"
52
- :fixed-query-form="fixedQueryForm"
53
- queryParamsName="deviceModelQueryParams">
54
- </x-form-table>
55
- <div v-if="tabActiveKey === '2'">
56
- <a-transfer
57
- :data-source="mockData"
58
- :target-keys="targetKeys"
59
- :show-search="true"
60
- :titles="['已配置的指令', '可加入的指令']"
61
- :operations="['移除', '加入']"
62
- :filter-option="(inputValue, item) => item.title.indexOf(inputValue) !== -1"
63
- :show-select-all="false"
64
- @change="onChange"
65
- >
66
- <template
67
- slot="children"
68
- slot-scope="{
69
- props: { direction, filteredItems, selectedKeys, disabled: listDisabled },
70
- on: { itemSelectAll, itemSelect },
71
- }"
72
- >
73
- <a-table
74
- :row-selection="getRowSelection({ disabled: listDisabled, selectedKeys, itemSelectAll, itemSelect })"
75
- :columns="direction === 'left' ? leftColumns : rightColumns"
76
- :data-source="filteredItems"
77
- size="small"
78
- :style="{ pointerEvents: listDisabled ? 'none' : null }"
79
- :custom-row="({ key, disabled: itemDisabled }) => ({
80
- on: {
81
- click: () => {
82
- if (itemDisabled || listDisabled) return;
83
- itemSelect(key, !selectedKeys.includes(key));
84
- },
85
- },
86
- })"
87
- />
88
- </template>
89
- </a-transfer>
90
- <span :style="{ float: 'right', overflow: 'hidden', marginTop: '8px' }">
91
- <a-button-group>
92
- <a-button type="primary" @click="saveInstructType" :loading="saveInstructTypeLoading">保存配置</a-button>
93
- </a-button-group>
94
- </span>
95
- </div>
96
- <div v-if="tabActiveKey === '3'">
97
- <a-space>
98
- <a-button type="primary" @click="toCreateQuery">
99
- <a-icon :style="iconStyle" type="api"/>编辑设备品牌参数项
100
- </a-button>
101
- <a-button type="primary" @click="toEditQuery">
102
- <a-icon :style="iconStyle" type="interaction"/>设置参数项默认值
103
- </a-button>
104
- </a-space>
105
- <a-card title="设备品牌参数预览" :bordered="true" size="small" style="margin-top: 20px;">
106
- <json-viewer :copyable="{copyText: '复制', copiedText: '已复制'}" :value="getColumnJson()" :expand-depth="parseInt('100')" style="overflow: auto;max-height: 440px"></json-viewer>
107
- </a-card>
108
- </div>
109
- </div>
110
- </template>
111
- </a-page-header>
112
- </a-spin>
113
- </a-drawer>
114
- </template>
115
-
116
- <script>
117
- import JsonViewer from 'vue-json-viewer'
118
- import XFormTable from '@vue2-client/base-client/components/common/XFormTable/XFormTable'
119
- import { DeviceBrandDetailsViewApi, post } from '@vue2-client/services/api'
120
- import { mapGetters, mapState } from 'vuex'
121
-
122
- const leftTableColumns = [
123
- {
124
- dataIndex: 'title',
125
- title: '指令类型'
126
- },
127
- {
128
- dataIndex: 'description',
129
- title: '指令说明'
130
- }
131
- ]
132
-
133
- export default {
134
- name: 'DeviceBrandDetailsView',
135
- components: {
136
- JsonViewer,
137
- XFormTable
138
- },
139
- data () {
140
- return {
141
- // 页面宽度
142
- screenWidth: document.documentElement.clientWidth,
143
- // Tab页签
144
- tabActiveKey: '1',
145
- // 设备品牌详情
146
- details: {
147
- f_brand: '',
148
- f_alias: '',
149
- f_manufactor: '',
150
- f_compatible_mode: '',
151
- f_input_date: '',
152
- f_inputtor: '',
153
- f_brand_set_params_json: '',
154
- f_params_json: ''
155
- },
156
- // 图标样式
157
- iconStyle: {
158
- position: 'relative',
159
- top: '1px'
160
- },
161
- tabList: [
162
- { key: '1', tab: '设备型号' },
163
- { key: '2', tab: '指令配置' },
164
- { key: '3', tab: '参数项配置' }
165
- ],
166
- fixedAddForm: {},
167
- fixedQueryForm: {},
168
- // 是否显示生成查询配置抽屉
169
- createQueryVisible: false,
170
- // 是否显示修改设备品牌默认参数抽屉
171
- editQueryVisible: false,
172
- // 设备品牌详情加载
173
- loadDeviceBrandDetails: true,
174
- // 支持的指令保存加载
175
- saveInstructTypeLoading: false,
176
- // 穿梭框
177
- mockData: [],
178
- targetKeys: [],
179
- leftColumns: leftTableColumns,
180
- rightColumns: leftTableColumns
181
- }
182
- },
183
- mounted () {
184
- this.initView()
185
- },
186
- computed: {
187
- ...mapGetters(['account/user']),
188
- ...mapState('account', { currUser: 'user' }),
189
- ...mapState('setting', ['isMobile'])
190
- },
191
- props: {
192
- brandId: {
193
- type: String,
194
- required: true
195
- },
196
- visible: {
197
- type: Boolean,
198
- default: false
199
- }
200
- },
201
- methods: {
202
- // 初始化组件
203
- initView () {
204
- this.tabActiveKey = '1'
205
- this.fixedQueryForm['m_f_brand_id'] = this.brandId
206
- this.fixedAddForm['m_f_brand_id'] = this.brandId
207
- this.getDeviceBrand(this.brandId)
208
- },
209
- onClose () {
210
- this.$emit('update:visible', false)
211
- },
212
- // 通用徽标过滤器
213
- badgeFilter (key, value) {
214
- const object = this.$appdata.getParam(key)
215
- if (object.hasOwnProperty(value)) {
216
- return object[value]
217
- } else {
218
- return {
219
- 'status': 'default',
220
- 'text': '未知类型:' + value
221
- }
222
- }
223
- },
224
- // 获取设备品牌详情信息
225
- getDeviceBrand (brandId) {
226
- this.loadDeviceBrandDetails = true
227
- return post(DeviceBrandDetailsViewApi.getDeviceBrandDetails, {
228
- id: brandId
229
- }).then(res => {
230
- this.details = res
231
- this.loadDeviceBrandDetails = false
232
- }, err => {
233
- this.loadDeviceBrandDetails = false
234
- console.error(err)
235
- })
236
- },
237
- // Tab切换
238
- handleTabChange (key) {
239
- this.tabActiveKey = key
240
- if (key === '2') {
241
- this.getDeviceBrandInstruct(this.details.f_type_id)
242
- }
243
- },
244
- // 获取指令
245
- getDeviceBrandInstruct (typeId) {
246
- return post(DeviceBrandDetailsViewApi.getDeviceBrandInstructs, {
247
- typeId: typeId
248
- }).then(res => {
249
- for (const i of res.keys()) {
250
- res[i].key = res[i].key + ''
251
- res[i].disabled = false
252
- }
253
- const instructKeys = this.details.f_instruct_array ? this.details.f_instruct_array : []
254
- const resKeys = this.getRealTargetKeys(instructKeys, res)
255
- this.mockData = res
256
- this.targetKeys = resKeys
257
- }, err => {
258
- console.error(err)
259
- })
260
- },
261
- // 穿梭框
262
- onChange (nextTargetKeys) {
263
- this.targetKeys = nextTargetKeys
264
- },
265
- getRowSelection ({ disabled, selectedKeys, itemSelectAll, itemSelect }) {
266
- const _this = this
267
- return {
268
- getCheckboxProps: item => ({ props: { disabled: disabled || item.disabled } }),
269
- onSelectAll (selected, selectedRows) {
270
- const treeSelectedKeys = selectedRows
271
- .filter(item => !item.disabled)
272
- .map(({ key }) => key)
273
- const diffKeys = selected
274
- ? _this.difference(treeSelectedKeys, selectedKeys)
275
- : _this.difference(selectedKeys, treeSelectedKeys)
276
- itemSelectAll(diffKeys, selected)
277
- },
278
- onSelect ({ key }, selected) {
279
- itemSelect(key, selected)
280
- },
281
- selectedRowKeys: selectedKeys
282
- }
283
- },
284
- difference (keysA, keysB) {
285
- const result = []
286
- let isSame = false
287
- for (const itemA in keysA) {
288
- for (const itemB in keysB) {
289
- if (itemA === itemB) {
290
- isSame = true
291
- break
292
- }
293
- }
294
- if (!isSame) {
295
- result.push(itemA)
296
- }
297
- }
298
- return Object.assign(result, keysA)
299
- },
300
- saveInstructType () {
301
- this.saveInstructTypeLoading = true
302
- const resKeys = this.getRealTargetKeys(this.targetKeys, this.mockData)
303
- return post(DeviceBrandDetailsViewApi.updateBrandInstructKeys, {
304
- brandId: this.brandId,
305
- resKeys: resKeys
306
- }).then(res => {
307
- this.$message.success('保存成功')
308
- this.getDeviceBrand(this.brandId)
309
- this.saveInstructTypeLoading = false
310
- }, err => {
311
- console.error(err)
312
- this.saveInstructTypeLoading = false
313
- })
314
- },
315
- getRealTargetKeys (targetKeys, mockData) {
316
- const resKeys = mockData.map(({ key }) => key)
317
- for (const instructKey of targetKeys) {
318
- for (const i in resKeys) {
319
- if (instructKey === resKeys[i]) {
320
- resKeys.splice(i, 1)
321
- }
322
- }
323
- }
324
- return resKeys
325
- },
326
- toCreateQuery () {
327
- this.createQueryVisible = true
328
- },
329
- toEditQuery () {
330
- this.editQueryVisible = true
331
- },
332
- // 获取参数项配置
333
- getColumnJson (callback) {
334
- let data
335
- if (this.details.f_brand_set_params_json) {
336
- data = JSON.parse(this.details.f_brand_set_params_json)
337
- } else {
338
- data = {}
339
- }
340
- if (callback) {
341
- callback(data)
342
- }
343
- return data
344
- },
345
- // 存储查询配置信息
346
- saveQueryParams (source) {
347
- return post(DeviceBrandDetailsViewApi.updateDeviceBrandJsonParams, {
348
- id: this.brandId,
349
- source: source
350
- }).then(res => {
351
- this.$message.success('保存查询配置成功')
352
- this.getDeviceBrand(this.brandId)
353
- }, err => {
354
- console.error(err)
355
- })
356
- },
357
- // 存储设备品牌默认参数值
358
- saveDeviceParams (source, callback) {
359
- source['id'] = this.brandId
360
- return post(DeviceBrandDetailsViewApi.updateDeviceDefaultParams, source).then(res => {
361
- const result = true
362
- callback(result)
363
- this.initView()
364
- this.tabActiveKey = '3'
365
- }).catch(e => {
366
- const result = false
367
- callback(result)
368
- })
369
- }
370
- },
371
- watch: {
372
- 'visible' (val) {
373
- if (val) {
374
- this.initView()
375
- }
376
- }
377
- }
378
- }
379
- </script>
380
-
381
- <style lang="less" scoped>
382
- .business {
383
- color: #ffffff;
384
- }
385
- .business:enabled:hover {
386
- background-color: #85CE61 !important;
387
- border-color: #85CE61 !important;
388
- }
389
- .business:enabled {
390
- background-color: #67c23a;
391
- border-color: #67c23a;
392
- }
393
- .business:disabled {
394
- color: rgba(0, 0, 0, 0.25);
395
- }
396
- .detail-layout {
397
- margin-left: 44px;
398
- }
399
- .text {
400
- color: rgba(0, 0, 0, .45);
401
- }
402
-
403
- .heading {
404
- color: rgba(0, 0, 0, .85);
405
- font-size: 20px;
406
- }
407
-
408
- .no-data {
409
- color: rgba(0, 0, 0, .25);
410
- text-align: center;
411
- line-height: 64px;
412
- font-size: 16px;
413
-
414
- i {
415
- font-size: 24px;
416
- margin-right: 16px;
417
- position: relative;
418
- top: 3px;
419
- }
420
- }
421
-
422
- .mobile {
423
- .detail-layout {
424
- margin-left: unset;
425
- }
426
- .text {
427
-
428
- }
429
- .status-list {
430
- text-align: left;
431
- }
432
- }
433
-
434
- .row {
435
- display: flex;
436
-
437
- .content {
438
- -webkit-box-flex: 1;
439
- flex: auto;
440
- -ms-flex: auto;
441
- }
442
-
443
- .extra {
444
- flex: 0 1 auto;
445
- -webkit-box-flex: 0;
446
- -ms-flex: 0 1 auto;
447
- min-width: 242px;
448
- margin-left: 88px;
449
- text-align: right;
450
- }
451
- }
452
- </style>
1
+ <template>
2
+ <a-drawer
3
+ title="设备品牌详情"
4
+ placement="right"
5
+ :width="isMobile ? screenWidth : screenWidth * 0.85"
6
+ :visible="visible"
7
+ @close="onClose"
8
+ >
9
+ <form-group-query
10
+ @getColumnJson="getColumnJson"
11
+ :visible.sync="createQueryVisible"
12
+ @saveQueryParams="saveQueryParams"
13
+ />
14
+ <form-group-edit
15
+ @getColumnJson="getColumnJson"
16
+ :visible.sync="editQueryVisible"
17
+ :modifyModelData="this.details.f_params_json ? JSON.parse(this.details.f_params_json) : {}"
18
+ @onSubmit="saveDeviceParams"
19
+ />
20
+ <a-spin :spinning="loadDeviceBrandDetails">
21
+ <a-page-header :title="details.f_brand">
22
+ <div class="row">
23
+ <div class="content">
24
+ <a-descriptions size="small" :column="isMobile ? 1 : 2">
25
+ <a-descriptions-item label="设备厂家">{{ details.f_manufactor }}</a-descriptions-item>
26
+ <a-descriptions-item label="设备别名">{{ details.f_alias }}</a-descriptions-item>
27
+ <a-descriptions-item label="设备兼容方式">{{ details.f_compatible_mode }}</a-descriptions-item>
28
+ <a-descriptions-item label="创建人">{{ details.f_inputtor }}</a-descriptions-item>
29
+ <a-descriptions-item label="创建时间">{{ details.f_input_date }}</a-descriptions-item>
30
+ </a-descriptions>
31
+ </div>
32
+ </div>
33
+ <!-- actions -->
34
+ <template v-slot:extra>
35
+ <a-button-group style="margin-right: 4px;">
36
+ <a-button type="dashed" @click="initView" :loading="loadDeviceBrandDetails">刷新</a-button>
37
+ </a-button-group>
38
+ <a-button-group style="margin-right: 4px;">
39
+ </a-button-group>
40
+ </template>
41
+ <template slot="footer">
42
+ <a-tabs :default-active-key="tabActiveKey" :activeKey="tabActiveKey" @change="handleTabChange" style="margin-bottom: 23px;">
43
+ <template v-for="value in tabList">
44
+ <a-tab-pane :key="value.key" :tab="value.tab"/>
45
+ </template>
46
+ </a-tabs>
47
+ <div v-if="!loadDeviceBrandDetails">
48
+ <x-form-table
49
+ v-if="tabActiveKey === '1'"
50
+ title="设备型号"
51
+ :fixed-add-form="fixedAddForm"
52
+ :fixed-query-form="fixedQueryForm"
53
+ queryParamsName="deviceModelQueryParams">
54
+ </x-form-table>
55
+ <div v-if="tabActiveKey === '2'">
56
+ <a-transfer
57
+ :data-source="mockData"
58
+ :target-keys="targetKeys"
59
+ :show-search="true"
60
+ :titles="['已配置的指令', '可加入的指令']"
61
+ :operations="['移除', '加入']"
62
+ :filter-option="(inputValue, item) => item.title.indexOf(inputValue) !== -1"
63
+ :show-select-all="false"
64
+ @change="onChange"
65
+ >
66
+ <template
67
+ slot="children"
68
+ slot-scope="{
69
+ props: { direction, filteredItems, selectedKeys, disabled: listDisabled },
70
+ on: { itemSelectAll, itemSelect },
71
+ }"
72
+ >
73
+ <a-table
74
+ :row-selection="getRowSelection({ disabled: listDisabled, selectedKeys, itemSelectAll, itemSelect })"
75
+ :columns="direction === 'left' ? leftColumns : rightColumns"
76
+ :data-source="filteredItems"
77
+ size="small"
78
+ :style="{ pointerEvents: listDisabled ? 'none' : null }"
79
+ :custom-row="({ key, disabled: itemDisabled }) => ({
80
+ on: {
81
+ click: () => {
82
+ if (itemDisabled || listDisabled) return;
83
+ itemSelect(key, !selectedKeys.includes(key));
84
+ },
85
+ },
86
+ })"
87
+ />
88
+ </template>
89
+ </a-transfer>
90
+ <span :style="{ float: 'right', overflow: 'hidden', marginTop: '8px' }">
91
+ <a-button-group>
92
+ <a-button type="primary" @click="saveInstructType" :loading="saveInstructTypeLoading">保存配置</a-button>
93
+ </a-button-group>
94
+ </span>
95
+ </div>
96
+ <div v-if="tabActiveKey === '3'">
97
+ <a-space>
98
+ <a-button type="primary" @click="toCreateQuery">
99
+ <a-icon :style="iconStyle" type="api"/>编辑设备品牌参数项
100
+ </a-button>
101
+ <a-button type="primary" @click="toEditQuery">
102
+ <a-icon :style="iconStyle" type="interaction"/>设置参数项默认值
103
+ </a-button>
104
+ </a-space>
105
+ <a-card title="设备品牌参数预览" :bordered="true" size="small" style="margin-top: 20px;">
106
+ <json-viewer :copyable="{copyText: '复制', copiedText: '已复制'}" :value="getColumnJson()" :expand-depth="parseInt('100')" style="overflow: auto;max-height: 440px"></json-viewer>
107
+ </a-card>
108
+ </div>
109
+ </div>
110
+ </template>
111
+ </a-page-header>
112
+ </a-spin>
113
+ </a-drawer>
114
+ </template>
115
+
116
+ <script>
117
+ import JsonViewer from 'vue-json-viewer'
118
+ import XFormTable from '@vue2-client/base-client/components/common/XFormTable/XFormTable'
119
+ import { DeviceBrandDetailsViewApi, post } from '@vue2-client/services/api'
120
+ import { mapGetters, mapState } from 'vuex'
121
+
122
+ const leftTableColumns = [
123
+ {
124
+ dataIndex: 'title',
125
+ title: '指令类型'
126
+ },
127
+ {
128
+ dataIndex: 'description',
129
+ title: '指令说明'
130
+ }
131
+ ]
132
+
133
+ export default {
134
+ name: 'DeviceBrandDetailsView',
135
+ components: {
136
+ JsonViewer,
137
+ XFormTable
138
+ },
139
+ data () {
140
+ return {
141
+ // 页面宽度
142
+ screenWidth: document.documentElement.clientWidth,
143
+ // Tab页签
144
+ tabActiveKey: '1',
145
+ // 设备品牌详情
146
+ details: {
147
+ f_brand: '',
148
+ f_alias: '',
149
+ f_manufactor: '',
150
+ f_compatible_mode: '',
151
+ f_input_date: '',
152
+ f_inputtor: '',
153
+ f_brand_set_params_json: '',
154
+ f_params_json: ''
155
+ },
156
+ // 图标样式
157
+ iconStyle: {
158
+ position: 'relative',
159
+ top: '1px'
160
+ },
161
+ tabList: [
162
+ { key: '1', tab: '设备型号' },
163
+ { key: '2', tab: '指令配置' },
164
+ { key: '3', tab: '参数项配置' }
165
+ ],
166
+ fixedAddForm: {},
167
+ fixedQueryForm: {},
168
+ // 是否显示生成查询配置抽屉
169
+ createQueryVisible: false,
170
+ // 是否显示修改设备品牌默认参数抽屉
171
+ editQueryVisible: false,
172
+ // 设备品牌详情加载
173
+ loadDeviceBrandDetails: true,
174
+ // 支持的指令保存加载
175
+ saveInstructTypeLoading: false,
176
+ // 穿梭框
177
+ mockData: [],
178
+ targetKeys: [],
179
+ leftColumns: leftTableColumns,
180
+ rightColumns: leftTableColumns
181
+ }
182
+ },
183
+ mounted () {
184
+ this.initView()
185
+ },
186
+ computed: {
187
+ ...mapGetters(['account/user']),
188
+ ...mapState('account', { currUser: 'user' }),
189
+ ...mapState('setting', ['isMobile'])
190
+ },
191
+ props: {
192
+ brandId: {
193
+ type: String,
194
+ required: true
195
+ },
196
+ visible: {
197
+ type: Boolean,
198
+ default: false
199
+ }
200
+ },
201
+ methods: {
202
+ // 初始化组件
203
+ initView () {
204
+ this.tabActiveKey = '1'
205
+ this.fixedQueryForm['m_f_brand_id'] = this.brandId
206
+ this.fixedAddForm['m_f_brand_id'] = this.brandId
207
+ this.getDeviceBrand(this.brandId)
208
+ },
209
+ onClose () {
210
+ this.$emit('update:visible', false)
211
+ },
212
+ // 通用徽标过滤器
213
+ badgeFilter (key, value) {
214
+ const object = this.$appdata.getParam(key)
215
+ if (object.hasOwnProperty(value)) {
216
+ return object[value]
217
+ } else {
218
+ return {
219
+ 'status': 'default',
220
+ 'text': '未知类型:' + value
221
+ }
222
+ }
223
+ },
224
+ // 获取设备品牌详情信息
225
+ getDeviceBrand (brandId) {
226
+ this.loadDeviceBrandDetails = true
227
+ return post(DeviceBrandDetailsViewApi.getDeviceBrandDetails, {
228
+ id: brandId
229
+ }).then(res => {
230
+ this.details = res
231
+ this.loadDeviceBrandDetails = false
232
+ }, err => {
233
+ this.loadDeviceBrandDetails = false
234
+ console.error(err)
235
+ })
236
+ },
237
+ // Tab切换
238
+ handleTabChange (key) {
239
+ this.tabActiveKey = key
240
+ if (key === '2') {
241
+ this.getDeviceBrandInstruct(this.details.f_type_id)
242
+ }
243
+ },
244
+ // 获取指令
245
+ getDeviceBrandInstruct (typeId) {
246
+ return post(DeviceBrandDetailsViewApi.getDeviceBrandInstructs, {
247
+ typeId: typeId
248
+ }).then(res => {
249
+ for (const i of res.keys()) {
250
+ res[i].key = res[i].key + ''
251
+ res[i].disabled = false
252
+ }
253
+ const instructKeys = this.details.f_instruct_array ? this.details.f_instruct_array : []
254
+ const resKeys = this.getRealTargetKeys(instructKeys, res)
255
+ this.mockData = res
256
+ this.targetKeys = resKeys
257
+ }, err => {
258
+ console.error(err)
259
+ })
260
+ },
261
+ // 穿梭框
262
+ onChange (nextTargetKeys) {
263
+ this.targetKeys = nextTargetKeys
264
+ },
265
+ getRowSelection ({ disabled, selectedKeys, itemSelectAll, itemSelect }) {
266
+ const _this = this
267
+ return {
268
+ getCheckboxProps: item => ({ props: { disabled: disabled || item.disabled } }),
269
+ onSelectAll (selected, selectedRows) {
270
+ const treeSelectedKeys = selectedRows
271
+ .filter(item => !item.disabled)
272
+ .map(({ key }) => key)
273
+ const diffKeys = selected
274
+ ? _this.difference(treeSelectedKeys, selectedKeys)
275
+ : _this.difference(selectedKeys, treeSelectedKeys)
276
+ itemSelectAll(diffKeys, selected)
277
+ },
278
+ onSelect ({ key }, selected) {
279
+ itemSelect(key, selected)
280
+ },
281
+ selectedRowKeys: selectedKeys
282
+ }
283
+ },
284
+ difference (keysA, keysB) {
285
+ const result = []
286
+ let isSame = false
287
+ for (const itemA in keysA) {
288
+ for (const itemB in keysB) {
289
+ if (itemA === itemB) {
290
+ isSame = true
291
+ break
292
+ }
293
+ }
294
+ if (!isSame) {
295
+ result.push(itemA)
296
+ }
297
+ }
298
+ return Object.assign(result, keysA)
299
+ },
300
+ saveInstructType () {
301
+ this.saveInstructTypeLoading = true
302
+ const resKeys = this.getRealTargetKeys(this.targetKeys, this.mockData)
303
+ return post(DeviceBrandDetailsViewApi.updateBrandInstructKeys, {
304
+ brandId: this.brandId,
305
+ resKeys: resKeys
306
+ }).then(res => {
307
+ this.$message.success('保存成功')
308
+ this.getDeviceBrand(this.brandId)
309
+ this.saveInstructTypeLoading = false
310
+ }, err => {
311
+ console.error(err)
312
+ this.saveInstructTypeLoading = false
313
+ })
314
+ },
315
+ getRealTargetKeys (targetKeys, mockData) {
316
+ const resKeys = mockData.map(({ key }) => key)
317
+ for (const instructKey of targetKeys) {
318
+ for (const i in resKeys) {
319
+ if (instructKey === resKeys[i]) {
320
+ resKeys.splice(i, 1)
321
+ }
322
+ }
323
+ }
324
+ return resKeys
325
+ },
326
+ toCreateQuery () {
327
+ this.createQueryVisible = true
328
+ },
329
+ toEditQuery () {
330
+ this.editQueryVisible = true
331
+ },
332
+ // 获取参数项配置
333
+ getColumnJson (callback) {
334
+ let data
335
+ if (this.details.f_brand_set_params_json) {
336
+ data = JSON.parse(this.details.f_brand_set_params_json)
337
+ } else {
338
+ data = {}
339
+ }
340
+ if (callback) {
341
+ callback(data)
342
+ }
343
+ return data
344
+ },
345
+ // 存储查询配置信息
346
+ saveQueryParams (source) {
347
+ return post(DeviceBrandDetailsViewApi.updateDeviceBrandJsonParams, {
348
+ id: this.brandId,
349
+ source: source
350
+ }).then(res => {
351
+ this.$message.success('保存查询配置成功')
352
+ this.getDeviceBrand(this.brandId)
353
+ }, err => {
354
+ console.error(err)
355
+ })
356
+ },
357
+ // 存储设备品牌默认参数值
358
+ saveDeviceParams (source, callback) {
359
+ source['id'] = this.brandId
360
+ return post(DeviceBrandDetailsViewApi.updateDeviceDefaultParams, source).then(res => {
361
+ const result = true
362
+ callback(result)
363
+ this.initView()
364
+ this.tabActiveKey = '3'
365
+ }).catch(e => {
366
+ const result = false
367
+ callback(result)
368
+ })
369
+ }
370
+ },
371
+ watch: {
372
+ 'visible' (val) {
373
+ if (val) {
374
+ this.initView()
375
+ }
376
+ }
377
+ }
378
+ }
379
+ </script>
380
+
381
+ <style lang="less" scoped>
382
+ .business {
383
+ color: #ffffff;
384
+ }
385
+ .business:enabled:hover {
386
+ background-color: #85CE61 !important;
387
+ border-color: #85CE61 !important;
388
+ }
389
+ .business:enabled {
390
+ background-color: #67c23a;
391
+ border-color: #67c23a;
392
+ }
393
+ .business:disabled {
394
+ color: rgba(0, 0, 0, 0.25);
395
+ }
396
+ .detail-layout {
397
+ margin-left: 44px;
398
+ }
399
+ .text {
400
+ color: rgba(0, 0, 0, .45);
401
+ }
402
+
403
+ .heading {
404
+ color: rgba(0, 0, 0, .85);
405
+ font-size: 20px;
406
+ }
407
+
408
+ .no-data {
409
+ color: rgba(0, 0, 0, .25);
410
+ text-align: center;
411
+ line-height: 64px;
412
+ font-size: 16px;
413
+
414
+ i {
415
+ font-size: 24px;
416
+ margin-right: 16px;
417
+ position: relative;
418
+ top: 3px;
419
+ }
420
+ }
421
+
422
+ .mobile {
423
+ .detail-layout {
424
+ margin-left: unset;
425
+ }
426
+ .text {
427
+
428
+ }
429
+ .status-list {
430
+ text-align: left;
431
+ }
432
+ }
433
+
434
+ .row {
435
+ display: flex;
436
+
437
+ .content {
438
+ -webkit-box-flex: 1;
439
+ flex: auto;
440
+ -ms-flex: auto;
441
+ }
442
+
443
+ .extra {
444
+ flex: 0 1 auto;
445
+ -webkit-box-flex: 0;
446
+ -ms-flex: 0 1 auto;
447
+ min-width: 242px;
448
+ margin-left: 88px;
449
+ text-align: right;
450
+ }
451
+ }
452
+ </style>