vue2-client 1.2.110 → 1.2.113

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 (28) hide show
  1. package/CHANGELOG.md +287 -275
  2. package/package.json +76 -95
  3. package/src/base-client/all.js +62 -66
  4. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  5. package/src/base-client/components/common/XFormTable/XFormTable.vue +514 -514
  6. package/src/base-client/components/common/XFormTable/index.md +96 -96
  7. package/src/base-client/components/iot/DeviceDetailsView/DeviceDetailsView.vue +232 -232
  8. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsCount.vue +678 -678
  9. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsException.vue +57 -57
  10. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsRead.vue +131 -131
  11. package/src/base-client/components/iot/DeviceTypeDetailsView/DeviceTypeDetailsView.vue +300 -300
  12. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +532 -532
  13. package/src/base-client/plugins/AppData.js +71 -79
  14. package/src/base-client/plugins/compatible/LoginServiceOA.js +20 -20
  15. package/src/pages/login/Login.vue +279 -274
  16. package/src/pages/resourceManage/orgListManage.vue +98 -98
  17. package/src/router/async/config.async.js +26 -26
  18. package/src/router/index.js +27 -27
  19. package/src/services/api/index.js +39 -39
  20. package/src/services/api/iot/DeviceDetailsView/DeviceDetailsCountApi.js +18 -18
  21. package/src/theme/default/style.less +47 -47
  22. package/src/utils/request.js +270 -270
  23. package/src/utils/util.js +230 -230
  24. package/src/base-client/components/common/ScrollList/SrcollList.vue +0 -113
  25. package/src/base-client/components/common/ScrollList/index.js +0 -3
  26. package/src/base-client/components/iot/DataAnalysisView/DataAnalysisView.vue +0 -244
  27. package/src/base-client/components/iot/DataAnalysisView/index.js +0 -3
  28. package/src/components/dataAnalysisView/UserData.vue +0 -61
@@ -1,514 +1,514 @@
1
- <template>
2
- <a-skeleton :loading="mainLoading">
3
- <template v-if="loaded">
4
- <x-add-form
5
- :business-title="businessTitle"
6
- :business-type="businessType"
7
- :fixedAddForm="fixedAddForm"
8
- :json-data="formItems"
9
- :loading="loading"
10
- :modify-model-data="modifyModelData"
11
- :visible.sync="modelVisible"
12
- @onSubmit="onAddOrModify"/>
13
- <x-form
14
- :is-show="isFormShow"
15
- :json-data="formItems"
16
- style="margin-bottom: 14px;"
17
- @onSubmit="onSubmit">
18
- <slot></slot>
19
- </x-form>
20
- <x-table
21
- ref="xTable"
22
- :buttonState="buttonState"
23
- :fixedQueryForm="fixedQueryForm"
24
- :form="form"
25
- :json-data="tableColumns"
26
- :queryParams="queryParams"
27
- :queryParamsName="queryParamsName"
28
- :show-pagination="showPagination"
29
- @action="action"
30
- @loadData="loadData"
31
- @selectRow="selectRow"
32
- @toggleIsFormShow="toggleIsFormShow">
33
- <template slot="expand">
34
- <a-space>
35
- <a-button v-if="!buttonState || buttonState.add" type="primary" @click="addItem">
36
- <a-icon :style="iconStyle" type="plus"/>新增
37
- </a-button>
38
- <a-button
39
- v-if="!buttonState || buttonState.edit"
40
- :disabled="!isModify"
41
- :loading="editDataLoading"
42
- class="btn-success"
43
- type="dashed"
44
- @click="editItem">
45
- <a-icon :style="iconStyle" type="edit"/>修改
46
- </a-button>
47
- <a-button v-if="!buttonState || buttonState.delete" :disabled="!isDelete" type="danger" @click="deleteItem">
48
- <a-icon :style="iconStyle" type="delete"/>删除
49
- </a-button>
50
- <slot :selectedRowKeys="selectedRowKeys" name="button"></slot>
51
- </a-space>
52
- <slot name="expand"></slot>
53
- </template>
54
- </x-table>
55
- </template>
56
- </a-skeleton>
57
- </template>
58
- <script>
59
- import XForm from '@vue2-client/base-client/components/common/XForm/XForm'
60
- import XAddForm from '@vue2-client/base-client/components/common/XAddForm/XAddForm'
61
- import XTable from '@vue2-client/base-client/components/common/XTable/XTable'
62
- import { query, commonApi, addOrModify, remove, queryWithResource } from '@vue2-client/services/api/common'
63
- import { indexedDB } from '@vue2-client/utils/indexedDB'
64
- import { mapState } from 'vuex'
65
- import { Modal } from 'ant-design-vue'
66
- import { post } from '@vue2-client/services/api/restTools'
67
- import { ApplyInstallApi } from '@vue2-client/services/api/applyInstallApi'
68
-
69
- export default {
70
- name: 'XFormTable',
71
- components: {
72
- XTable,
73
- XForm,
74
- XAddForm
75
- },
76
- data () {
77
- return {
78
- // Query参数文件内容加载中
79
- mainLoading: false,
80
- // Query参数文件内容加载完成
81
- loaded: false,
82
- // 是否展示表单
83
- isFormShow: true,
84
- // 当使用logic获取到表单表格配置时, 将配置对象直接传入到x-table用于查询
85
- queryParams: null,
86
- // 表格列集合
87
- tableColumns: [],
88
- // 操作按钮集合
89
- buttonState: {},
90
- // 表格选择列Key集合
91
- selectedRowKeys: [],
92
- // 表单项集合
93
- formItems: [],
94
- // 表单
95
- form: {},
96
- // 图标样式
97
- iconStyle: {
98
- position: 'relative',
99
- top: '1px'
100
- },
101
- // 当前业务类型:新增,修改
102
- businessType: '',
103
- // 是否显示新增/修改模态框
104
- modelVisible: false,
105
- // 修改业务时查询的单条业务数据
106
- modifyModelData: {},
107
- // 是否允许修改
108
- isModify: false,
109
- // 是否允许删除
110
- isDelete: false,
111
- // 新增,修改业务执行状态
112
- loading: false,
113
- // 被修改数据加载状态
114
- editDataLoading: false,
115
- // 是否为临时表
116
- isTableTemp: false,
117
- // 自定义新增修改接口
118
- customAoM: undefined,
119
- // 自定义查询接口
120
- customQuery: undefined
121
- }
122
- },
123
- computed: {
124
- ...mapState('setting', ['isMobile']),
125
- businessTitle () {
126
- return this.businessType + this.title
127
- }
128
- },
129
- props: {
130
- // 业务名称
131
- title: {
132
- type: String,
133
- default: ''
134
- },
135
- // 查询配置文件名
136
- queryParamsName: {
137
- type: String,
138
- default: null
139
- },
140
- // 查询配置文件Json,用于查询配置生成器的预览
141
- queryParamsJson: {
142
- type: Object,
143
- default: null
144
- },
145
- // 业务逻辑名称, 通过logic获取表单表格配置
146
- logicName: {
147
- type: String,
148
- default: null
149
- },
150
- // 执行logic传递的参数
151
- logicParam: {
152
- type: Object,
153
- default: () => {}
154
- },
155
- // 固定新增表单
156
- fixedAddForm: {
157
- type: Object,
158
- default: () => {
159
- return {}
160
- }
161
- },
162
- // 固定查询表单
163
- fixedQueryForm: {
164
- type: Object,
165
- default: () => {
166
- return {}
167
- }
168
- },
169
- // 预览模式
170
- viewMode: {
171
- type: Boolean,
172
- default: () => {
173
- return false
174
- }
175
- },
176
- // 动态创建子表需要的定义
177
- tempTableData: {
178
- type: Object,
179
- default: null
180
- },
181
- // 数据只有一页时是否展示分页,true:展示,auto:隐藏
182
- showPagination: {
183
- type: String | Boolean,
184
- default: true
185
- }
186
- },
187
- watch: {
188
- logicParam: {
189
- handler () {
190
- this.mainLoading = true
191
- this.form = {}
192
- indexedDB.getByWeb(`${this.logicName}_${JSON.stringify(this.logicParam)}`, commonApi.getColumnsJson, { logic: this.logicName, logicParam: this.logicParam }, (ret) => {
193
- this.queryParams = ret
194
- this.tableColumns = ret.columnJson
195
- this.formItems = ret.formJson
196
- this.buttonState = ret.buttonState
197
- this.customAoM = ret.customAoM
198
- this.customQuery = ret.customQuery
199
- this.mainLoading = false
200
- this.loaded = true
201
- })
202
- },
203
- deep: true
204
- },
205
- fixedQueryForm: {
206
- handler () {
207
- this.form = {}
208
- indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
209
- this.tableColumns = ret.columnJson
210
- this.formItems = ret.formJson
211
- this.buttonState = ret.buttonState
212
- this.customAoM = ret.customAoM
213
- this.customQuery = ret.customQuery
214
- this.loaded = true
215
- })
216
- },
217
- deep: true
218
- },
219
- queryParamsJson: {
220
- handler () {
221
- this.getColumnsJsonBySource()
222
- },
223
- deep: true
224
- }
225
- },
226
- created () {
227
- if (this.queryParamsName) {
228
- this.getColumnsJson()
229
- } else if (this.queryParamsJson) {
230
- this.getColumnsJsonBySource()
231
- }
232
- },
233
- methods: {
234
- refreshTable () {
235
- this.$refs.xTable.refresh(true)
236
- },
237
- clearRowKeys () {
238
- this.$refs.xTable.clearRowKeys()
239
- },
240
- getColumnsJsonBySource () {
241
- this.mainLoading = true
242
- post(commonApi.getColumnsJson, { queryObject: this.queryParamsJson }).then(res => {
243
- this.queryParams = res
244
- this.tableColumns = this.queryParams.columnJson
245
- this.formItems = this.queryParams.formJson
246
- this.buttonState = this.queryParams.buttonState
247
- this.customAoM = this.queryParams.customAoM
248
- this.customQuery = this.queryParams.customQuery
249
- this.mainLoading = false
250
- this.loaded = true
251
- })
252
- },
253
- getColumnsJson () {
254
- this.mainLoading = true
255
- indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
256
- this.tableColumns = ret.columnJson
257
- this.formItems = ret.formJson
258
- this.buttonState = ret.buttonState
259
- this.customAoM = ret.customAoM
260
- this.customQuery = ret.customQuery
261
- this.mainLoading = false
262
- this.loaded = true
263
- })
264
- },
265
- // 查询表单提交
266
- onSubmit (res) {
267
- if (res.valid) {
268
- // 表单赋值
269
- this.form = res.form
270
- // commit
271
- this.$emit('afterSearchSubmit', res)
272
- } else {
273
- return false
274
- }
275
- },
276
- // TODO 新增/修改数据表单提交
277
- onAddOrModify (res) {
278
- if (this.viewMode) {
279
- this.$message.info('预览模式禁止新增')
280
- return false
281
- }
282
- // 如果是临时表
283
- if (this.isTableTemp) {
284
- this.$emit('tempTableModify', res)
285
- return
286
- }
287
- if (res.valid) {
288
- this.loading = true
289
- const requestParameters = {
290
- queryParamsName: this.queryParamsName,
291
- form: {}
292
- }
293
- if (this.businessType === '修改') {
294
- const rowKeyValue = this.selectedRowKeys[0]
295
- const key = this.tableColumns[0].dataIndex
296
- const realKey = key.substring(key.indexOf('_') + 1)
297
- requestParameters.form[realKey] = rowKeyValue
298
- }
299
- for (const key of Object.keys(res.form)) {
300
- const realKey = key.substring(key.indexOf('_') + 1)
301
- requestParameters.form[realKey] = res.form[key]
302
- }
303
- if (!this.customAoM || this.customAoM?.length === 0) {
304
- this.customAoM = undefined
305
- }
306
- addOrModify(requestParameters, this.customAoM).then(res => {
307
- this.$message.success(this.businessType + '成功!')
308
- this.loading = false
309
- this.modelVisible = false
310
- this.$refs.xTable.refresh(true)
311
- // commit
312
- this.$emit('afterSubmit', { type: this.businessType, id: res.id, form: requestParameters.form })
313
- }).catch(e => {
314
- this.loading = false
315
- this.modelVisible = false
316
- this.$message.error(this.businessType + '失败!')
317
- })
318
- } else {
319
- return false
320
- }
321
- },
322
- // 刷新加载表格数据
323
- loadData (requestParameters, callback) {
324
- let result = {}
325
- if (this.queryParamsJson) {
326
- if (this.queryParamsJson.tableName.startsWith('##')) {
327
- this.isTableTemp = true
328
- result = this.initTempTable(requestParameters)
329
- }
330
- }
331
- if (!this.isTableTemp) {
332
- result = query(requestParameters)
333
- }
334
- this.$emit('afterQuery', result)
335
- callback(result)
336
- },
337
- // 详情按钮事件
338
- action (record, id) {
339
- this.$emit('action', record, id)
340
- },
341
- // 新增业务
342
- addItem () {
343
- this.businessType = '新增'
344
- this.modifyModelData = {}
345
- this.modelVisible = true
346
- },
347
- // 修改业务
348
- editItem () {
349
- this.businessType = '修改'
350
- if (!this.viewMode) {
351
- const requestParameters = {
352
- queryParamsName: this.queryParamsName,
353
- conditionParams: {},
354
- pageNo: 1,
355
- pageSize: 1
356
- }
357
- requestParameters.conditionParams[this.tableColumns[0].dataIndex] = this.selectedRowKeys[0]
358
- requestParameters.f_businessid = this.selectedRowKeys[0]
359
- if (this.isTableTemp) {
360
- this.$emit('tempTableEdit', requestParameters)
361
- return
362
- }
363
- this.editDataLoading = true
364
- if (!this.customQuery || this.customQuery?.length === 0) {
365
- this.customQuery = undefined
366
- }
367
- queryWithResource(requestParameters, this.customQuery).then(res => {
368
- this.modifyModelData = { data: res.data[0], images: res.images, files: res.files }
369
- this.modelVisible = true
370
- this.editDataLoading = false
371
- console.warn(this.modifyModelData)
372
- })
373
- } else {
374
- this.$message.info('预览模式禁止修改')
375
- }
376
- },
377
- // 删除业务
378
- deleteItem () {
379
- if (this.viewMode) {
380
- this.$message.info('预览模式禁止删除')
381
- return
382
- }
383
- Modal.confirm({
384
- title: '提示',
385
- content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
386
- confirmLoading: this.loading,
387
- zIndex: 1001,
388
- onOk: () => {
389
- this.loading = true
390
- const requestParameters = {
391
- queryParamsName: this.queryParamsName,
392
- idList: this.selectedRowKeys
393
- }
394
- remove(requestParameters).then(res => {
395
- this.loading = false
396
- this.$message.success('删除成功!')
397
- this.$refs.xTable.clearRowKeys()
398
- this.$refs.xTable.refresh(true)
399
- // afterDelete
400
- this.$emit('afterDelete', { idList: requestParameters.idList })
401
- }).catch(e => {
402
- this.loading = false
403
- this.$message.error('删除失败!')
404
- })
405
- },
406
- onCancel () {}
407
- })
408
- },
409
- // 查询表单部分显示/隐藏切换
410
- toggleIsFormShow () {
411
- this.isFormShow = !this.isFormShow
412
- },
413
- // 控制业务操作按钮组的显示
414
- selectRow (rowKeys) {
415
- this.selectedRowKeys = rowKeys
416
- this.isModify = this.selectedRowKeys.length === 1
417
- this.isDelete = this.selectedRowKeys.length > 0
418
- this.$emit('selectRow', this.selectedRowKeys)
419
- },
420
- // 创建临时表sql生成
421
- createTempTable (defineJson) {
422
- const tableName = defineJson.tableName
423
- const define = defineJson.column
424
- return post(ApplyInstallApi.createTempTable, {
425
- define: define,
426
- tableName: tableName
427
- })
428
- .then(
429
- res => {
430
- return res
431
- },
432
- err => {
433
- console.log(err)
434
- }
435
- )
436
- },
437
- // 插入临时表数据sql生成
438
- insertTempTableData (defineJson) {
439
- const tableName = defineJson.tableName
440
- const params = {}
441
- params.define = defineJson.column
442
- params.applyId = defineJson.applyId
443
- params.stepName = defineJson.stepName
444
- params.tableName = tableName
445
- return post(ApplyInstallApi.insertDataToTempTable, {
446
- tempTableData: params
447
- })
448
- .then(
449
- res => {
450
- return res
451
- }
452
- )
453
- },
454
- // 初始化临时表
455
- async initTempTable (json) {
456
- await this.createTempTable(this.queryParamsJson)
457
- await this.insertTempTableData(this.queryParamsJson)
458
- let result = {}
459
- await post(ApplyInstallApi.initApplySubTable, {
460
- define: json
461
- })
462
- .then(
463
- res => {
464
- console.log('子表临时表已创建')
465
- result = res
466
- }
467
- )
468
- return result
469
- }
470
- }
471
- }
472
- </script>
473
- <style lang="less" scoped>
474
- .btn-success {
475
- color: #ffffff;
476
- }
477
- .btn-success:hover {
478
- color: #ffffff !important;
479
- }
480
- .btn-success:focus {
481
- color: #ffffff !important;
482
- }
483
- .btn-success:enabled:hover {
484
- background-color: #85CE61 !important;
485
- border-color: #85CE61 !important;
486
- }
487
- .btn-success:enabled {
488
- background-color: #67c23a;
489
- border-color: #67c23a;
490
- }
491
- .btn-success:disabled {
492
- color: rgba(0, 0, 0, 0.25);
493
- }
494
- .btn-warn {
495
- color: #ffffff;
496
- }
497
- .btn-warn:hover {
498
- color: #ffffff !important;
499
- }
500
- .btn-warn:focus {
501
- color: #ffffff !important;
502
- }
503
- .btn-warn:enabled:hover {
504
- background-color: #ffc833 !important;
505
- border-color: #ffc833 !important;
506
- }
507
- .btn-warn:enabled {
508
- background-color: #ffba00;
509
- border-color: #ffba00;
510
- }
511
- .btn-warn:disabled {
512
- color: rgba(0, 0, 0, 0.25);
513
- }
514
- </style>
1
+ <template>
2
+ <a-skeleton :loading="mainLoading">
3
+ <template v-if="loaded">
4
+ <x-add-form
5
+ :business-title="businessTitle"
6
+ :business-type="businessType"
7
+ :fixedAddForm="fixedAddForm"
8
+ :json-data="formItems"
9
+ :loading="loading"
10
+ :modify-model-data="modifyModelData"
11
+ :visible.sync="modelVisible"
12
+ @onSubmit="onAddOrModify"/>
13
+ <x-form
14
+ :is-show="isFormShow"
15
+ :json-data="formItems"
16
+ style="margin-bottom: 14px;"
17
+ @onSubmit="onSubmit">
18
+ <slot></slot>
19
+ </x-form>
20
+ <x-table
21
+ ref="xTable"
22
+ :buttonState="buttonState"
23
+ :fixedQueryForm="fixedQueryForm"
24
+ :form="form"
25
+ :json-data="tableColumns"
26
+ :queryParams="queryParams"
27
+ :queryParamsName="queryParamsName"
28
+ :show-pagination="showPagination"
29
+ @action="action"
30
+ @loadData="loadData"
31
+ @selectRow="selectRow"
32
+ @toggleIsFormShow="toggleIsFormShow">
33
+ <template slot="expand">
34
+ <a-space>
35
+ <a-button v-if="!buttonState || buttonState.add" type="primary" @click="addItem">
36
+ <a-icon :style="iconStyle" type="plus"/>新增
37
+ </a-button>
38
+ <a-button
39
+ v-if="!buttonState || buttonState.edit"
40
+ :disabled="!isModify"
41
+ :loading="editDataLoading"
42
+ class="btn-success"
43
+ type="dashed"
44
+ @click="editItem">
45
+ <a-icon :style="iconStyle" type="edit"/>修改
46
+ </a-button>
47
+ <a-button v-if="!buttonState || buttonState.delete" :disabled="!isDelete" type="danger" @click="deleteItem">
48
+ <a-icon :style="iconStyle" type="delete"/>删除
49
+ </a-button>
50
+ <slot :selectedRowKeys="selectedRowKeys" name="button"></slot>
51
+ </a-space>
52
+ <slot name="expand"></slot>
53
+ </template>
54
+ </x-table>
55
+ </template>
56
+ </a-skeleton>
57
+ </template>
58
+ <script>
59
+ import XForm from '@vue2-client/base-client/components/common/XForm/XForm'
60
+ import XAddForm from '@vue2-client/base-client/components/common/XAddForm/XAddForm'
61
+ import XTable from '@vue2-client/base-client/components/common/XTable/XTable'
62
+ import { query, commonApi, addOrModify, remove, queryWithResource } from '@vue2-client/services/api/common'
63
+ import { indexedDB } from '@vue2-client/utils/indexedDB'
64
+ import { mapState } from 'vuex'
65
+ import { Modal } from 'ant-design-vue'
66
+ import { post } from '@vue2-client/services/api/restTools'
67
+ import { ApplyInstallApi } from '@vue2-client/services/api/applyInstallApi'
68
+
69
+ export default {
70
+ name: 'XFormTable',
71
+ components: {
72
+ XTable,
73
+ XForm,
74
+ XAddForm
75
+ },
76
+ data () {
77
+ return {
78
+ // Query参数文件内容加载中
79
+ mainLoading: false,
80
+ // Query参数文件内容加载完成
81
+ loaded: false,
82
+ // 是否展示表单
83
+ isFormShow: true,
84
+ // 当使用logic获取到表单表格配置时, 将配置对象直接传入到x-table用于查询
85
+ queryParams: null,
86
+ // 表格列集合
87
+ tableColumns: [],
88
+ // 操作按钮集合
89
+ buttonState: {},
90
+ // 表格选择列Key集合
91
+ selectedRowKeys: [],
92
+ // 表单项集合
93
+ formItems: [],
94
+ // 表单
95
+ form: {},
96
+ // 图标样式
97
+ iconStyle: {
98
+ position: 'relative',
99
+ top: '1px'
100
+ },
101
+ // 当前业务类型:新增,修改
102
+ businessType: '',
103
+ // 是否显示新增/修改模态框
104
+ modelVisible: false,
105
+ // 修改业务时查询的单条业务数据
106
+ modifyModelData: {},
107
+ // 是否允许修改
108
+ isModify: false,
109
+ // 是否允许删除
110
+ isDelete: false,
111
+ // 新增,修改业务执行状态
112
+ loading: false,
113
+ // 被修改数据加载状态
114
+ editDataLoading: false,
115
+ // 是否为临时表
116
+ isTableTemp: false,
117
+ // 自定义新增修改接口
118
+ customAoM: undefined,
119
+ // 自定义查询接口
120
+ customQuery: undefined
121
+ }
122
+ },
123
+ computed: {
124
+ ...mapState('setting', ['isMobile']),
125
+ businessTitle () {
126
+ return this.businessType + this.title
127
+ }
128
+ },
129
+ props: {
130
+ // 业务名称
131
+ title: {
132
+ type: String,
133
+ default: ''
134
+ },
135
+ // 查询配置文件名
136
+ queryParamsName: {
137
+ type: String,
138
+ default: null
139
+ },
140
+ // 查询配置文件Json,用于查询配置生成器的预览
141
+ queryParamsJson: {
142
+ type: Object,
143
+ default: null
144
+ },
145
+ // 业务逻辑名称, 通过logic获取表单表格配置
146
+ logicName: {
147
+ type: String,
148
+ default: null
149
+ },
150
+ // 执行logic传递的参数
151
+ logicParam: {
152
+ type: Object,
153
+ default: () => {}
154
+ },
155
+ // 固定新增表单
156
+ fixedAddForm: {
157
+ type: Object,
158
+ default: () => {
159
+ return {}
160
+ }
161
+ },
162
+ // 固定查询表单
163
+ fixedQueryForm: {
164
+ type: Object,
165
+ default: () => {
166
+ return {}
167
+ }
168
+ },
169
+ // 预览模式
170
+ viewMode: {
171
+ type: Boolean,
172
+ default: () => {
173
+ return false
174
+ }
175
+ },
176
+ // 动态创建子表需要的定义
177
+ tempTableData: {
178
+ type: Object,
179
+ default: null
180
+ },
181
+ // 数据只有一页时是否展示分页,true:展示,auto:隐藏
182
+ showPagination: {
183
+ type: String | Boolean,
184
+ default: true
185
+ }
186
+ },
187
+ watch: {
188
+ logicParam: {
189
+ handler () {
190
+ this.mainLoading = true
191
+ this.form = {}
192
+ indexedDB.getByWeb(`${this.logicName}_${JSON.stringify(this.logicParam)}`, commonApi.getColumnsJson, { logic: this.logicName, logicParam: this.logicParam }, (ret) => {
193
+ this.queryParams = ret
194
+ this.tableColumns = ret.columnJson
195
+ this.formItems = ret.formJson
196
+ this.buttonState = ret.buttonState
197
+ this.customAoM = ret.customAoM
198
+ this.customQuery = ret.customQuery
199
+ this.mainLoading = false
200
+ this.loaded = true
201
+ })
202
+ },
203
+ deep: true
204
+ },
205
+ fixedQueryForm: {
206
+ handler () {
207
+ this.form = {}
208
+ indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
209
+ this.tableColumns = ret.columnJson
210
+ this.formItems = ret.formJson
211
+ this.buttonState = ret.buttonState
212
+ this.customAoM = ret.customAoM
213
+ this.customQuery = ret.customQuery
214
+ this.loaded = true
215
+ })
216
+ },
217
+ deep: true
218
+ },
219
+ queryParamsJson: {
220
+ handler () {
221
+ this.getColumnsJsonBySource()
222
+ },
223
+ deep: true
224
+ }
225
+ },
226
+ created () {
227
+ if (this.queryParamsName) {
228
+ this.getColumnsJson()
229
+ } else if (this.queryParamsJson) {
230
+ this.getColumnsJsonBySource()
231
+ }
232
+ },
233
+ methods: {
234
+ refreshTable () {
235
+ this.$refs.xTable.refresh(true)
236
+ },
237
+ clearRowKeys () {
238
+ this.$refs.xTable.clearRowKeys()
239
+ },
240
+ getColumnsJsonBySource () {
241
+ this.mainLoading = true
242
+ post(commonApi.getColumnsJson, { queryObject: this.queryParamsJson }).then(res => {
243
+ this.queryParams = res
244
+ this.tableColumns = this.queryParams.columnJson
245
+ this.formItems = this.queryParams.formJson
246
+ this.buttonState = this.queryParams.buttonState
247
+ this.customAoM = this.queryParams.customAoM
248
+ this.customQuery = this.queryParams.customQuery
249
+ this.mainLoading = false
250
+ this.loaded = true
251
+ })
252
+ },
253
+ getColumnsJson () {
254
+ this.mainLoading = true
255
+ indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
256
+ this.tableColumns = ret.columnJson
257
+ this.formItems = ret.formJson
258
+ this.buttonState = ret.buttonState
259
+ this.customAoM = ret.customAoM
260
+ this.customQuery = ret.customQuery
261
+ this.mainLoading = false
262
+ this.loaded = true
263
+ })
264
+ },
265
+ // 查询表单提交
266
+ onSubmit (res) {
267
+ if (res.valid) {
268
+ // 表单赋值
269
+ this.form = res.form
270
+ // commit
271
+ this.$emit('afterSearchSubmit', res)
272
+ } else {
273
+ return false
274
+ }
275
+ },
276
+ // TODO 新增/修改数据表单提交
277
+ onAddOrModify (res) {
278
+ if (this.viewMode) {
279
+ this.$message.info('预览模式禁止新增')
280
+ return false
281
+ }
282
+ // 如果是临时表
283
+ if (this.isTableTemp) {
284
+ this.$emit('tempTableModify', res)
285
+ return
286
+ }
287
+ if (res.valid) {
288
+ this.loading = true
289
+ const requestParameters = {
290
+ queryParamsName: this.queryParamsName,
291
+ form: {}
292
+ }
293
+ if (this.businessType === '修改') {
294
+ const rowKeyValue = this.selectedRowKeys[0]
295
+ const key = this.tableColumns[0].dataIndex
296
+ const realKey = key.substring(key.indexOf('_') + 1)
297
+ requestParameters.form[realKey] = rowKeyValue
298
+ }
299
+ for (const key of Object.keys(res.form)) {
300
+ const realKey = key.substring(key.indexOf('_') + 1)
301
+ requestParameters.form[realKey] = res.form[key]
302
+ }
303
+ if (!this.customAoM || this.customAoM?.length === 0) {
304
+ this.customAoM = undefined
305
+ }
306
+ addOrModify(requestParameters, this.customAoM).then(res => {
307
+ this.$message.success(this.businessType + '成功!')
308
+ this.loading = false
309
+ this.modelVisible = false
310
+ this.$refs.xTable.refresh(true)
311
+ // commit
312
+ this.$emit('afterSubmit', { type: this.businessType, id: res.id, form: requestParameters.form })
313
+ }).catch(e => {
314
+ this.loading = false
315
+ this.modelVisible = false
316
+ this.$message.error(this.businessType + '失败!')
317
+ })
318
+ } else {
319
+ return false
320
+ }
321
+ },
322
+ // 刷新加载表格数据
323
+ loadData (requestParameters, callback) {
324
+ let result = {}
325
+ if (this.queryParamsJson) {
326
+ if (this.queryParamsJson.tableName.startsWith('##')) {
327
+ this.isTableTemp = true
328
+ result = this.initTempTable(requestParameters)
329
+ }
330
+ }
331
+ if (!this.isTableTemp) {
332
+ result = query(requestParameters)
333
+ }
334
+ this.$emit('afterQuery', result)
335
+ callback(result)
336
+ },
337
+ // 详情按钮事件
338
+ action (record, id) {
339
+ this.$emit('action', record, id)
340
+ },
341
+ // 新增业务
342
+ addItem () {
343
+ this.businessType = '新增'
344
+ this.modifyModelData = {}
345
+ this.modelVisible = true
346
+ },
347
+ // 修改业务
348
+ editItem () {
349
+ this.businessType = '修改'
350
+ if (!this.viewMode) {
351
+ const requestParameters = {
352
+ queryParamsName: this.queryParamsName,
353
+ conditionParams: {},
354
+ pageNo: 1,
355
+ pageSize: 1
356
+ }
357
+ requestParameters.conditionParams[this.tableColumns[0].dataIndex] = this.selectedRowKeys[0]
358
+ requestParameters.f_businessid = this.selectedRowKeys[0]
359
+ if (this.isTableTemp) {
360
+ this.$emit('tempTableEdit', requestParameters)
361
+ return
362
+ }
363
+ this.editDataLoading = true
364
+ if (!this.customQuery || this.customQuery?.length === 0) {
365
+ this.customQuery = undefined
366
+ }
367
+ queryWithResource(requestParameters, this.customQuery).then(res => {
368
+ this.modifyModelData = { data: res.data[0], images: res.images, files: res.files }
369
+ this.modelVisible = true
370
+ this.editDataLoading = false
371
+ console.warn(this.modifyModelData)
372
+ })
373
+ } else {
374
+ this.$message.info('预览模式禁止修改')
375
+ }
376
+ },
377
+ // 删除业务
378
+ deleteItem () {
379
+ if (this.viewMode) {
380
+ this.$message.info('预览模式禁止删除')
381
+ return
382
+ }
383
+ Modal.confirm({
384
+ title: '提示',
385
+ content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
386
+ confirmLoading: this.loading,
387
+ zIndex: 1001,
388
+ onOk: () => {
389
+ this.loading = true
390
+ const requestParameters = {
391
+ queryParamsName: this.queryParamsName,
392
+ idList: this.selectedRowKeys
393
+ }
394
+ remove(requestParameters).then(res => {
395
+ this.loading = false
396
+ this.$message.success('删除成功!')
397
+ this.$refs.xTable.clearRowKeys()
398
+ this.$refs.xTable.refresh(true)
399
+ // afterDelete
400
+ this.$emit('afterDelete', { idList: requestParameters.idList })
401
+ }).catch(e => {
402
+ this.loading = false
403
+ this.$message.error('删除失败!')
404
+ })
405
+ },
406
+ onCancel () {}
407
+ })
408
+ },
409
+ // 查询表单部分显示/隐藏切换
410
+ toggleIsFormShow () {
411
+ this.isFormShow = !this.isFormShow
412
+ },
413
+ // 控制业务操作按钮组的显示
414
+ selectRow (rowKeys) {
415
+ this.selectedRowKeys = rowKeys
416
+ this.isModify = this.selectedRowKeys.length === 1
417
+ this.isDelete = this.selectedRowKeys.length > 0
418
+ this.$emit('selectRow', this.selectedRowKeys)
419
+ },
420
+ // 创建临时表sql生成
421
+ createTempTable (defineJson) {
422
+ const tableName = defineJson.tableName
423
+ const define = defineJson.column
424
+ return post(ApplyInstallApi.createTempTable, {
425
+ define: define,
426
+ tableName: tableName
427
+ })
428
+ .then(
429
+ res => {
430
+ return res
431
+ },
432
+ err => {
433
+ console.log(err)
434
+ }
435
+ )
436
+ },
437
+ // 插入临时表数据sql生成
438
+ insertTempTableData (defineJson) {
439
+ const tableName = defineJson.tableName
440
+ const params = {}
441
+ params.define = defineJson.column
442
+ params.applyId = defineJson.applyId
443
+ params.stepName = defineJson.stepName
444
+ params.tableName = tableName
445
+ return post(ApplyInstallApi.insertDataToTempTable, {
446
+ tempTableData: params
447
+ })
448
+ .then(
449
+ res => {
450
+ return res
451
+ }
452
+ )
453
+ },
454
+ // 初始化临时表
455
+ async initTempTable (json) {
456
+ await this.createTempTable(this.queryParamsJson)
457
+ await this.insertTempTableData(this.queryParamsJson)
458
+ let result = {}
459
+ await post(ApplyInstallApi.initApplySubTable, {
460
+ define: json
461
+ })
462
+ .then(
463
+ res => {
464
+ console.log('子表临时表已创建')
465
+ result = res
466
+ }
467
+ )
468
+ return result
469
+ }
470
+ }
471
+ }
472
+ </script>
473
+ <style lang="less" scoped>
474
+ .btn-success {
475
+ color: #ffffff;
476
+ }
477
+ .btn-success:hover {
478
+ color: #ffffff !important;
479
+ }
480
+ .btn-success:focus {
481
+ color: #ffffff !important;
482
+ }
483
+ .btn-success:enabled:hover {
484
+ background-color: #85CE61 !important;
485
+ border-color: #85CE61 !important;
486
+ }
487
+ .btn-success:enabled {
488
+ background-color: #67c23a;
489
+ border-color: #67c23a;
490
+ }
491
+ .btn-success:disabled {
492
+ color: rgba(0, 0, 0, 0.25);
493
+ }
494
+ .btn-warn {
495
+ color: #ffffff;
496
+ }
497
+ .btn-warn:hover {
498
+ color: #ffffff !important;
499
+ }
500
+ .btn-warn:focus {
501
+ color: #ffffff !important;
502
+ }
503
+ .btn-warn:enabled:hover {
504
+ background-color: #ffc833 !important;
505
+ border-color: #ffc833 !important;
506
+ }
507
+ .btn-warn:enabled {
508
+ background-color: #ffba00;
509
+ border-color: #ffba00;
510
+ }
511
+ .btn-warn:disabled {
512
+ color: rgba(0, 0, 0, 0.25);
513
+ }
514
+ </style>