vue2-client 1.4.63 → 1.4.64

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