vue2-client 1.4.6 → 1.4.8

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