vue2-client 1.2.110 → 1.2.111

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.
@@ -1,300 +1,300 @@
1
- <template>
2
- <div>
3
- <a-drawer
4
- :visible="visible"
5
- :width="isMobile ? screenWidth : screenWidth * 0.85"
6
- placement="right"
7
- title="设备类型详情"
8
- @close="onClose"
9
- >
10
- <create-query
11
- :to-edit-json="getColumnJson()"
12
- :visible.sync="createQueryVisible"
13
- @saveQueryParams="saveQueryParams"
14
- />
15
- <a-spin :spinning="loadDeviceTypeDetails">
16
- <a-page-header :title="details.f_name">
17
- <div class="row">
18
- <div class="content">
19
- <a-descriptions :column="isMobile ? 1 : 2" size="small">
20
- <a-descriptions-item label="设备类型状态">{{ details.f_state }}</a-descriptions-item>
21
- <a-descriptions-item label="创建人">{{ details.f_inputtor }}</a-descriptions-item>
22
- <a-descriptions-item label="创建时间">{{ details.f_input_date }}</a-descriptions-item>
23
- <a-descriptions-item label="描述">{{ details.f_describe }}</a-descriptions-item>
24
- </a-descriptions>
25
- </div>
26
- </div>
27
- <!-- actions -->
28
- <template v-slot:extra>
29
- <a-button-group style="margin-right: 4px;">
30
- <a-button :loading="loadDeviceTypeDetails" type="dashed" @click="initView">刷新</a-button>
31
- </a-button-group>
32
- <a-button-group style="margin-right: 4px;">
33
- </a-button-group>
34
- </template>
35
- <template slot="footer">
36
- <a-tabs :activeKey="tabActiveKey" :default-active-key="tabActiveKey" style="margin-bottom: 23px;" @change="handleTabChange">
37
- <template v-for="value in tabList">
38
- <a-tab-pane :key="value.key" :tab="value.tab"/>
39
- </template>
40
- </a-tabs>
41
- <div v-if="!loadDeviceTypeDetails">
42
- <div v-if="tabActiveKey === '1'">
43
- <a-button type="primary" @click="toCreateQuery">
44
- <a-icon :style="iconStyle" type="api"/>编辑设备上报数据
45
- </a-button>
46
- <a-card :bordered="true" size="small" style="margin-top: 20px;" title="设备上报数据预览">
47
- <json-viewer :copyable="{copyText: '复制', copiedText: '已复制'}" :expand-depth="parseInt('100')" :value="getColumnJson()" style="overflow: auto;max-height: 440px"></json-viewer>
48
- </a-card>
49
- </div>
50
- <div v-if="tabActiveKey === '2'">
51
- <a-button type="primary" @click="toCreateQuery">
52
- <a-icon :style="iconStyle" type="api"/>编辑设备数据
53
- </a-button>
54
- <a-card :bordered="true" size="small" style="margin-top: 20px;" title="设备数据预览">
55
- <json-viewer :copyable="{copyText: '复制', copiedText: '已复制'}" :expand-depth="parseInt('100')" :value="getColumnJson()" style="overflow: auto;max-height: 440px"></json-viewer>
56
- </a-card>
57
- </div>
58
- <div v-if="tabActiveKey === '3'">
59
- <x-form-table
60
- :fixed-add-form="fixedAddForm"
61
- :fixed-query-form="fixedQueryForm"
62
- queryParamsName="deviceTypeToInstructQueryParams"
63
- title="指令配置">
64
- </x-form-table>
65
- </div>
66
- </div>
67
- </template>
68
- </a-page-header>
69
- </a-spin>
70
- </a-drawer>
71
- </div>
72
- </template>
73
-
74
- <script>
75
- import JsonViewer from 'vue-json-viewer'
76
- import { mapState, mapGetters } from 'vuex'
77
- import { DeviceTypeDetailsViewApi, post } from '@vue2-client/services/api'
78
- import XFormTable from '@vue2-client/base-client/components/common/XFormTable/XFormTable'
79
-
80
- export default {
81
- name: 'DeviceTypeDetailsView',
82
- components: {
83
- JsonViewer,
84
- XFormTable
85
- },
86
- data () {
87
- return {
88
- // 页面宽度
89
- screenWidth: document.documentElement.clientWidth,
90
- // Tab页签
91
- tabActiveKey: '1',
92
- // 图标样式
93
- iconStyle: {
94
- position: 'relative',
95
- top: '1px'
96
- },
97
- // 是否显示生成查询配置抽屉
98
- createQueryVisible: false,
99
- // 设备类型详情
100
- details: {
101
- f_name: '',
102
- f_describe: '',
103
- f_state: '',
104
- f_columns_json: '',
105
- f_input_date: '',
106
- f_inputtor: ''
107
- },
108
- fixedAddForm: {},
109
- fixedQueryForm: {},
110
- tabList: [
111
- { key: '1', tab: '抄表查询配置' },
112
- { key: '2', tab: '设备查询配置' },
113
- { key: '3', tab: '指令配置' }
114
- ],
115
- // 设备类型详情加载
116
- loadDeviceTypeDetails: false
117
- }
118
- },
119
- mounted () {
120
- this.initView()
121
- },
122
- computed: {
123
- ...mapGetters(['account/user']),
124
- ...mapState('account', { currUser: 'user' }),
125
- ...mapState('setting', ['isMobile'])
126
- },
127
- props: {
128
- typeId: {
129
- type: Number,
130
- required: true
131
- },
132
- visible: {
133
- type: Boolean,
134
- default: false
135
- }
136
- },
137
- methods: {
138
- // 初始化组件
139
- initView () {
140
- this.tabActiveKey = '1'
141
- this.fixedQueryForm['m_f_device_type_id'] = this.typeId
142
- this.fixedAddForm['m_f_device_type_id'] = this.typeId
143
- this.getDeviceType(this.typeId)
144
- },
145
- toCreateQuery () {
146
- this.createQueryVisible = true
147
- },
148
- getColumnJson () {
149
- if (this.tabActiveKey === '1') {
150
- if (this.details.f_columns_json) {
151
- return JSON.parse(this.details.f_columns_json)
152
- } else {
153
- return {}
154
- }
155
- } else {
156
- if (this.details.f_device_columns_json) {
157
- return JSON.parse(this.details.f_device_columns_json)
158
- } else {
159
- return {}
160
- }
161
- }
162
- },
163
- onClose () {
164
- this.$emit('update:visible', false)
165
- },
166
- // 通用徽标过滤器
167
- badgeFilter (key, value) {
168
- const object = this.$appdata.getParam(key)
169
- if (object.hasOwnProperty(value)) {
170
- return object[value]
171
- } else {
172
- return {
173
- 'status': 'default',
174
- 'text': '未知类型:' + value
175
- }
176
- }
177
- },
178
- // 获取设备类型详情信息
179
- getDeviceType (typeId) {
180
- this.loadDeviceTypeDetails = true
181
- return post(DeviceTypeDetailsViewApi.getDeviceTypeDetails, {
182
- id: typeId
183
- }).then(res => {
184
- this.details = res
185
- this.loadDeviceTypeDetails = false
186
- }, err => {
187
- this.loadDeviceTypeDetails = false
188
- console.error(err)
189
- })
190
- },
191
- // 存储查询配置信息
192
- saveQueryParams (source) {
193
- let params
194
- if (this.tabActiveKey === '1') {
195
- params = {
196
- id: this.typeId,
197
- type: 1,
198
- source: source
199
- }
200
- } else {
201
- params = {
202
- id: this.typeId,
203
- type: 2,
204
- source: source
205
- }
206
- }
207
- return post('/webmeterapi/updateDeviceTypeQueryParams', params).then(res => {
208
- this.$message.success('保存查询配置成功')
209
- this.getDeviceType(this.typeId)
210
- }, err => {
211
- console.error(err)
212
- })
213
- },
214
- // Tab切换
215
- handleTabChange (key) {
216
- this.tabActiveKey = key
217
- }
218
- },
219
- watch: {
220
- 'visible' (val) {
221
- if (val) {
222
- this.initView()
223
- }
224
- }
225
- }
226
- }
227
- </script>
228
-
229
- <style lang="less" scoped>
230
- .business {
231
- color: #ffffff;
232
- }
233
- .business:enabled:hover {
234
- background-color: #85CE61 !important;
235
- border-color: #85CE61 !important;
236
- }
237
- .business:enabled {
238
- background-color: #67c23a;
239
- border-color: #67c23a;
240
- }
241
- .business:disabled {
242
- color: rgba(0, 0, 0, 0.25);
243
- }
244
- .detail-layout {
245
- margin-left: 44px;
246
- }
247
- .text {
248
- color: rgba(0, 0, 0, .45);
249
- }
250
-
251
- .heading {
252
- color: rgba(0, 0, 0, .85);
253
- font-size: 20px;
254
- }
255
-
256
- .no-data {
257
- color: rgba(0, 0, 0, .25);
258
- text-align: center;
259
- line-height: 64px;
260
- font-size: 16px;
261
-
262
- i {
263
- font-size: 24px;
264
- margin-right: 16px;
265
- position: relative;
266
- top: 3px;
267
- }
268
- }
269
-
270
- .mobile {
271
- .detail-layout {
272
- margin-left: unset;
273
- }
274
- .text {
275
-
276
- }
277
- .status-list {
278
- text-align: left;
279
- }
280
- }
281
-
282
- .row {
283
- display: flex;
284
-
285
- .content {
286
- -webkit-box-flex: 1;
287
- flex: auto;
288
- -ms-flex: auto;
289
- }
290
-
291
- .extra {
292
- flex: 0 1 auto;
293
- -webkit-box-flex: 0;
294
- -ms-flex: 0 1 auto;
295
- min-width: 242px;
296
- margin-left: 88px;
297
- text-align: right;
298
- }
299
- }
300
- </style>
1
+ <template>
2
+ <div>
3
+ <a-drawer
4
+ :visible="visible"
5
+ :width="isMobile ? screenWidth : screenWidth * 0.85"
6
+ placement="right"
7
+ title="设备类型详情"
8
+ @close="onClose"
9
+ >
10
+ <create-query
11
+ :to-edit-json="getColumnJson()"
12
+ :visible.sync="createQueryVisible"
13
+ @saveQueryParams="saveQueryParams"
14
+ />
15
+ <a-spin :spinning="loadDeviceTypeDetails">
16
+ <a-page-header :title="details.f_name">
17
+ <div class="row">
18
+ <div class="content">
19
+ <a-descriptions :column="isMobile ? 1 : 2" size="small">
20
+ <a-descriptions-item label="设备类型状态">{{ details.f_state }}</a-descriptions-item>
21
+ <a-descriptions-item label="创建人">{{ details.f_inputtor }}</a-descriptions-item>
22
+ <a-descriptions-item label="创建时间">{{ details.f_input_date }}</a-descriptions-item>
23
+ <a-descriptions-item label="描述">{{ details.f_describe }}</a-descriptions-item>
24
+ </a-descriptions>
25
+ </div>
26
+ </div>
27
+ <!-- actions -->
28
+ <template v-slot:extra>
29
+ <a-button-group style="margin-right: 4px;">
30
+ <a-button :loading="loadDeviceTypeDetails" type="dashed" @click="initView">刷新</a-button>
31
+ </a-button-group>
32
+ <a-button-group style="margin-right: 4px;">
33
+ </a-button-group>
34
+ </template>
35
+ <template slot="footer">
36
+ <a-tabs :activeKey="tabActiveKey" :default-active-key="tabActiveKey" style="margin-bottom: 23px;" @change="handleTabChange">
37
+ <template v-for="value in tabList">
38
+ <a-tab-pane :key="value.key" :tab="value.tab"/>
39
+ </template>
40
+ </a-tabs>
41
+ <div v-if="!loadDeviceTypeDetails">
42
+ <div v-if="tabActiveKey === '1'">
43
+ <a-button type="primary" @click="toCreateQuery">
44
+ <a-icon :style="iconStyle" type="api"/>编辑设备上报数据
45
+ </a-button>
46
+ <a-card :bordered="true" size="small" style="margin-top: 20px;" title="设备上报数据预览">
47
+ <json-viewer :copyable="{copyText: '复制', copiedText: '已复制'}" :expand-depth="parseInt('100')" :value="getColumnJson()" style="overflow: auto;max-height: 440px"></json-viewer>
48
+ </a-card>
49
+ </div>
50
+ <div v-if="tabActiveKey === '2'">
51
+ <a-button type="primary" @click="toCreateQuery">
52
+ <a-icon :style="iconStyle" type="api"/>编辑设备数据
53
+ </a-button>
54
+ <a-card :bordered="true" size="small" style="margin-top: 20px;" title="设备数据预览">
55
+ <json-viewer :copyable="{copyText: '复制', copiedText: '已复制'}" :expand-depth="parseInt('100')" :value="getColumnJson()" style="overflow: auto;max-height: 440px"></json-viewer>
56
+ </a-card>
57
+ </div>
58
+ <div v-if="tabActiveKey === '3'">
59
+ <x-form-table
60
+ :fixed-add-form="fixedAddForm"
61
+ :fixed-query-form="fixedQueryForm"
62
+ queryParamsName="deviceTypeToInstructQueryParams"
63
+ title="指令配置">
64
+ </x-form-table>
65
+ </div>
66
+ </div>
67
+ </template>
68
+ </a-page-header>
69
+ </a-spin>
70
+ </a-drawer>
71
+ </div>
72
+ </template>
73
+
74
+ <script>
75
+ import JsonViewer from 'vue-json-viewer'
76
+ import { mapState, mapGetters } from 'vuex'
77
+ import { DeviceTypeDetailsViewApi, post } from '@vue2-client/services/api'
78
+ import XFormTable from '@vue2-client/base-client/components/common/XFormTable/XFormTable'
79
+
80
+ export default {
81
+ name: 'DeviceTypeDetailsView',
82
+ components: {
83
+ JsonViewer,
84
+ XFormTable
85
+ },
86
+ data () {
87
+ return {
88
+ // 页面宽度
89
+ screenWidth: document.documentElement.clientWidth,
90
+ // Tab页签
91
+ tabActiveKey: '1',
92
+ // 图标样式
93
+ iconStyle: {
94
+ position: 'relative',
95
+ top: '1px'
96
+ },
97
+ // 是否显示生成查询配置抽屉
98
+ createQueryVisible: false,
99
+ // 设备类型详情
100
+ details: {
101
+ f_name: '',
102
+ f_describe: '',
103
+ f_state: '',
104
+ f_columns_json: '',
105
+ f_input_date: '',
106
+ f_inputtor: ''
107
+ },
108
+ fixedAddForm: {},
109
+ fixedQueryForm: {},
110
+ tabList: [
111
+ { key: '1', tab: '抄表查询配置' },
112
+ { key: '2', tab: '设备查询配置' },
113
+ { key: '3', tab: '指令配置' }
114
+ ],
115
+ // 设备类型详情加载
116
+ loadDeviceTypeDetails: false
117
+ }
118
+ },
119
+ mounted () {
120
+ this.initView()
121
+ },
122
+ computed: {
123
+ ...mapGetters(['account/user']),
124
+ ...mapState('account', { currUser: 'user' }),
125
+ ...mapState('setting', ['isMobile'])
126
+ },
127
+ props: {
128
+ typeId: {
129
+ type: Number,
130
+ required: true
131
+ },
132
+ visible: {
133
+ type: Boolean,
134
+ default: false
135
+ }
136
+ },
137
+ methods: {
138
+ // 初始化组件
139
+ initView () {
140
+ this.tabActiveKey = '1'
141
+ this.fixedQueryForm['m_f_device_type_id'] = this.typeId
142
+ this.fixedAddForm['m_f_device_type_id'] = this.typeId
143
+ this.getDeviceType(this.typeId)
144
+ },
145
+ toCreateQuery () {
146
+ this.createQueryVisible = true
147
+ },
148
+ getColumnJson () {
149
+ if (this.tabActiveKey === '1') {
150
+ if (this.details.f_columns_json) {
151
+ return JSON.parse(this.details.f_columns_json)
152
+ } else {
153
+ return {}
154
+ }
155
+ } else {
156
+ if (this.details.f_device_columns_json) {
157
+ return JSON.parse(this.details.f_device_columns_json)
158
+ } else {
159
+ return {}
160
+ }
161
+ }
162
+ },
163
+ onClose () {
164
+ this.$emit('update:visible', false)
165
+ },
166
+ // 通用徽标过滤器
167
+ badgeFilter (key, value) {
168
+ const object = this.$appdata.getParam(key)
169
+ if (object.hasOwnProperty(value)) {
170
+ return object[value]
171
+ } else {
172
+ return {
173
+ 'status': 'default',
174
+ 'text': '未知类型:' + value
175
+ }
176
+ }
177
+ },
178
+ // 获取设备类型详情信息
179
+ getDeviceType (typeId) {
180
+ this.loadDeviceTypeDetails = true
181
+ return post(DeviceTypeDetailsViewApi.getDeviceTypeDetails, {
182
+ id: typeId
183
+ }).then(res => {
184
+ this.details = res
185
+ this.loadDeviceTypeDetails = false
186
+ }, err => {
187
+ this.loadDeviceTypeDetails = false
188
+ console.error(err)
189
+ })
190
+ },
191
+ // 存储查询配置信息
192
+ saveQueryParams (source) {
193
+ let params
194
+ if (this.tabActiveKey === '1') {
195
+ params = {
196
+ id: this.typeId,
197
+ type: 1,
198
+ source: source
199
+ }
200
+ } else {
201
+ params = {
202
+ id: this.typeId,
203
+ type: 2,
204
+ source: source
205
+ }
206
+ }
207
+ return post('/webmeterapi/updateDeviceTypeQueryParams', params).then(res => {
208
+ this.$message.success('保存查询配置成功')
209
+ this.getDeviceType(this.typeId)
210
+ }, err => {
211
+ console.error(err)
212
+ })
213
+ },
214
+ // Tab切换
215
+ handleTabChange (key) {
216
+ this.tabActiveKey = key
217
+ }
218
+ },
219
+ watch: {
220
+ 'visible' (val) {
221
+ if (val) {
222
+ this.initView()
223
+ }
224
+ }
225
+ }
226
+ }
227
+ </script>
228
+
229
+ <style lang="less" scoped>
230
+ .business {
231
+ color: #ffffff;
232
+ }
233
+ .business:enabled:hover {
234
+ background-color: #85CE61 !important;
235
+ border-color: #85CE61 !important;
236
+ }
237
+ .business:enabled {
238
+ background-color: #67c23a;
239
+ border-color: #67c23a;
240
+ }
241
+ .business:disabled {
242
+ color: rgba(0, 0, 0, 0.25);
243
+ }
244
+ .detail-layout {
245
+ margin-left: 44px;
246
+ }
247
+ .text {
248
+ color: rgba(0, 0, 0, .45);
249
+ }
250
+
251
+ .heading {
252
+ color: rgba(0, 0, 0, .85);
253
+ font-size: 20px;
254
+ }
255
+
256
+ .no-data {
257
+ color: rgba(0, 0, 0, .25);
258
+ text-align: center;
259
+ line-height: 64px;
260
+ font-size: 16px;
261
+
262
+ i {
263
+ font-size: 24px;
264
+ margin-right: 16px;
265
+ position: relative;
266
+ top: 3px;
267
+ }
268
+ }
269
+
270
+ .mobile {
271
+ .detail-layout {
272
+ margin-left: unset;
273
+ }
274
+ .text {
275
+
276
+ }
277
+ .status-list {
278
+ text-align: left;
279
+ }
280
+ }
281
+
282
+ .row {
283
+ display: flex;
284
+
285
+ .content {
286
+ -webkit-box-flex: 1;
287
+ flex: auto;
288
+ -ms-flex: auto;
289
+ }
290
+
291
+ .extra {
292
+ flex: 0 1 auto;
293
+ -webkit-box-flex: 0;
294
+ -ms-flex: 0 1 auto;
295
+ min-width: 242px;
296
+ margin-left: 88px;
297
+ text-align: right;
298
+ }
299
+ }
300
+ </style>