vue2-client 1.2.93 → 1.2.96

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