vue2-client 1.3.13 → 1.3.14

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