vue2-client 1.4.53 → 1.4.55

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 (98) hide show
  1. package/CHANGELOG.md +472 -463
  2. package/index.js +30 -30
  3. package/package.json +1 -1
  4. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +225 -225
  5. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +777 -777
  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/XForm/XFormItem.vue +471 -471
  12. package/src/base-client/components/common/XFormTable/XFormTable.vue +560 -560
  13. package/src/base-client/components/common/XFormTable/index.md +96 -96
  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/form/FormRow.vue +52 -52
  33. package/src/components/index.js +36 -36
  34. package/src/components/menu/SideMenu.vue +62 -62
  35. package/src/components/menu/menu.js +273 -273
  36. package/src/components/page/header/index.less +40 -40
  37. package/src/components/setting/Setting.vue +235 -235
  38. package/src/components/table/StandardTable.vue +141 -141
  39. package/src/components/table/advance/ActionColumns.vue +158 -158
  40. package/src/components/table/advance/SearchArea.vue +355 -355
  41. package/src/components/tool/AStepItem.vue +60 -60
  42. package/src/components/tool/AvatarList.vue +68 -68
  43. package/src/components/tool/Drawer.vue +142 -142
  44. package/src/components/tool/TagSelect.vue +83 -83
  45. package/src/components/transition/PageToggleTransition.vue +97 -97
  46. package/src/config/default/admin.config.js +18 -18
  47. package/src/config/default/setting.config.js +44 -44
  48. package/src/config/replacer/resolve.config.js +67 -67
  49. package/src/layouts/AdminLayout.vue +174 -174
  50. package/src/layouts/CommonLayout.vue +42 -42
  51. package/src/layouts/PageLayout.vue +151 -151
  52. package/src/layouts/SinglePageView.vue +1 -0
  53. package/src/layouts/footer/PageFooter.vue +49 -49
  54. package/src/layouts/header/AdminHeader.vue +104 -104
  55. package/src/layouts/header/HeaderNotice.vue +167 -167
  56. package/src/layouts/header/HeaderSearch.vue +67 -67
  57. package/src/layouts/header/InstitutionDetail.vue +181 -181
  58. package/src/layouts/header/index.less +92 -92
  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 +21 -2
  63. package/src/pages/ReportView.vue +50 -0
  64. package/src/pages/login/Login.vue +348 -345
  65. package/src/pages/report/ReportTable.js +124 -124
  66. package/src/pages/report/ReportTableHome.vue +28 -28
  67. package/src/pages/resourceManage/orgListManage.vue +98 -98
  68. package/src/pages/system/dictionary/index.vue +43 -43
  69. package/src/pages/system/file/index.vue +317 -317
  70. package/src/pages/system/monitor/loginInfor/index.vue +36 -36
  71. package/src/pages/system/monitor/operLog/index.vue +36 -36
  72. package/src/pages/system/queryParams/index.vue +43 -43
  73. package/src/router/async/config.async.js +27 -27
  74. package/src/router/async/router.map.js +2 -0
  75. package/src/router/index.js +27 -27
  76. package/src/services/api/DictionaryDetailsViewApi.js +6 -6
  77. package/src/services/api/LogDetailsViewApi.js +10 -10
  78. package/src/services/api/QueryParamsDetailsViewApi.js +6 -6
  79. package/src/services/api/TicketDetailsViewApi.js +34 -34
  80. package/src/services/api/cas.js +79 -79
  81. package/src/services/api/commonTempTable.js +10 -10
  82. package/src/services/api/index.js +17 -17
  83. package/src/services/api/logininfor/index.js +6 -0
  84. package/src/services/api/manage.js +8 -8
  85. package/src/services/apiService.js +13 -13
  86. package/src/services/user.js +53 -53
  87. package/src/store/modules/index.js +4 -4
  88. package/src/theme/default/nprogress.less +76 -76
  89. package/src/theme/default/style.less +47 -47
  90. package/src/utils/colors.js +107 -107
  91. package/src/utils/excel/Blob.js +180 -180
  92. package/src/utils/excel/Export2Excel.js +141 -141
  93. package/src/utils/formatter.js +68 -68
  94. package/src/utils/i18n.js +80 -80
  95. package/src/utils/theme-color-replacer-extend.js +91 -91
  96. package/src/utils/themeUtil.js +100 -100
  97. package/src/utils/util.js +230 -230
  98. package/vue.config.js +7 -2
@@ -1,560 +1,560 @@
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.form = {}
224
- },
225
- deep: true
226
- },
227
- queryParamsJson: {
228
- handler () {
229
- this.getColumnsJsonBySource()
230
- },
231
- deep: true
232
- }
233
- },
234
- created () {
235
- if (this.queryParamsName) {
236
- this.getColumnsJson()
237
- } else if (this.queryParamsJson) {
238
- this.getColumnsJsonBySource()
239
- }
240
- },
241
- methods: {
242
- refreshTable (toFirstPage = true) {
243
- this.$refs.xTable.refresh(toFirstPage)
244
- },
245
- clearRowKeys () {
246
- this.$refs.xTable.clearRowKeys()
247
- },
248
- setParams (res) {
249
- // 深拷贝json,避免筛选列报错
250
- this.tableColumns = JSON.parse(JSON.stringify(res.columnJson))
251
- this.formItems = res.formJson
252
- this.buttonState = res.buttonState
253
- this.serviceName = res.serviceName
254
- this.mainLoading = false
255
- this.loaded = true
256
- },
257
- getColumnsJson () {
258
- this.form = {}
259
- this.mainLoading = true
260
- indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
261
- this.setParams(ret)
262
- })
263
- },
264
- getColumnsJsonBySource () {
265
- this.form = {}
266
- this.mainLoading = true
267
- post(commonApi.getColumnsJson, { queryObject: this.queryParamsJson }).then(res => {
268
- this.queryParams = res
269
- this.setParams(res)
270
- })
271
- },
272
- getColumnJsonByLogic () {
273
- this.form = {}
274
- this.mainLoading = true
275
- indexedDB.getByWeb(`${this.logicName}_${JSON.stringify(this.logicParam)}`, commonApi.getColumnsJson, { logic: this.logicName, logicParam: this.logicParam }, (ret) => {
276
- this.queryParams = ret
277
- this.setParams(ret)
278
- })
279
- },
280
- // 查询表单提交
281
- onSubmit (res) {
282
- if (res.valid) {
283
- // 表单赋值
284
- this.form = res.form
285
- // commit
286
- this.$emit('afterSearchSubmit', res)
287
- } else {
288
- return false
289
- }
290
- },
291
- // 新增/修改数据表单提交
292
- onAddOrModify (res) {
293
- if (this.viewMode) {
294
- this.$message.info('预览模式禁止新增和修改')
295
- return false
296
- }
297
- // 如果是临时表
298
- if (this.isTableTemp) {
299
- this.$emit('tempTableModify', res)
300
- return
301
- }
302
- if (!res.valid) {
303
- return false
304
- }
305
- this.loading = true
306
- const requestParameters = {
307
- queryParamsName: this.queryParamsName,
308
- form: {},
309
- businessType: this.businessType,
310
- operator: this.currUser.name
311
- }
312
- if (this.businessType === '修改') {
313
- // 将更新需要的主键值加入到表单中
314
- const key = this.tableColumns[0].dataIndex
315
- const realKey = this.getRealKey(key)
316
- requestParameters.form[realKey] = this.selectId
317
- }
318
- for (const key of Object.keys(res.form)) {
319
- const realKey = this.getRealKey(key)
320
- requestParameters.form[realKey] = res.form[key]
321
- }
322
- addOrModify(requestParameters, this.serviceName).then(res => {
323
- this.$message.success(this.businessType + '成功!')
324
- this.loading = false
325
- this.modelVisible = false
326
- this.$refs.xTable.refresh(true)
327
- // commit
328
- this.$emit('afterSubmit', { type: this.businessType, id: res.id, form: requestParameters.form })
329
- }).catch(e => {
330
- this.loading = false
331
- this.modelVisible = false
332
- this.$message.error(this.businessType + '失败!')
333
- })
334
- },
335
- // 刷新加载表格数据
336
- loadData (requestParameters, callback) {
337
- let result = {}
338
- if (this.queryParamsJson) {
339
- if (this.queryParamsJson.tableName.startsWith('##')) {
340
- this.isTableTemp = true
341
- result = this.initTempTable(requestParameters)
342
- }
343
- }
344
- if (!this.isTableTemp) {
345
- result = query(requestParameters, this.serviceName)
346
- }
347
- this.$emit('afterQuery', result)
348
- callback(result)
349
- },
350
- // 详情按钮事件
351
- action (record, id, actionType) {
352
- this.$emit('action', record, id, actionType)
353
- },
354
- // 获取数据字段实际值
355
- getRealKey (key) {
356
- return key.substring(key.indexOf('_') + 1)
357
- },
358
- // 新增业务
359
- addItem () {
360
- this.businessType = '新增'
361
- this.modifyModelData = {}
362
- this.modelVisible = true
363
- },
364
- // 修改业务
365
- editItem (selectId) {
366
- this.businessType = '修改'
367
- const requestParameters = {
368
- queryParamsName: this.queryParamsName,
369
- conditionParams: {},
370
- pageNo: 1,
371
- pageSize: 1
372
- }
373
- if (selectId === undefined) {
374
- selectId = this.selectedRowKeys[0]
375
- }
376
- this.selectId = selectId
377
- requestParameters.conditionParams[this.tableColumns[0].dataIndex] = selectId
378
- requestParameters.f_businessid = selectId
379
- if (this.isTableTemp) {
380
- this.$emit('tempTableEdit', requestParameters)
381
- return
382
- }
383
- this.editDataLoading = true
384
- queryWithResource(requestParameters, this.serviceName).then(res => {
385
- this.modifyModelData = { data: res.data[0], images: res.images, files: res.files }
386
- this.modelVisible = true
387
- this.editDataLoading = false
388
- })
389
- },
390
- // 删除业务
391
- deleteItem () {
392
- if (this.viewMode) {
393
- this.$message.info('预览模式禁止删除')
394
- return
395
- }
396
- Modal.confirm({
397
- title: '提示',
398
- content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
399
- confirmLoading: this.loading,
400
- zIndex: 1001,
401
- onOk: () => {
402
- this.loading = true
403
- const requestParameters = {
404
- queryParamsName: this.queryParamsName,
405
- idList: this.selectedRowKeys
406
- }
407
- remove(requestParameters, this.serviceName).then(res => {
408
- this.loading = false
409
- this.$message.success('删除成功!')
410
- this.$refs.xTable.clearRowKeys()
411
- this.$refs.xTable.refresh(true)
412
- // afterDelete
413
- this.$emit('afterDelete', { idList: requestParameters.idList })
414
- }).catch(e => {
415
- this.loading = false
416
- this.$message.error('删除失败!')
417
- })
418
- },
419
- onCancel () {}
420
- })
421
- },
422
- // 导出选中或本页数据
423
- handleExport (isSelected) {
424
- const tHeader = this.tableColumns.filter(res => res.slotType !== 'action').map(res => res.title)
425
- const filterVal = this.tableColumns.map(res => res.dataIndex)
426
- let exportData
427
- if (isSelected) {
428
- exportData = this.$refs.xTable.selectedRows
429
- } else {
430
- exportData = this.$refs.xTable.dataSource
431
- }
432
- const data = this.formatJson(filterVal, exportData)
433
- exportJson(tHeader, data, this.title + `数据_${new Date().toLocaleString()}`)
434
- },
435
- formatJson (filterVal, jsonData) {
436
- return jsonData.map(v => filterVal.map(j => v[j]))
437
- },
438
- // 导出符合条件的数据
439
- handleExportByQuery () {
440
- const that = this
441
- this.$confirm({
442
- title: '是否确认导出?',
443
- content: '此操作将导出当前条件下所有数据而非选中数据',
444
- onOk () {
445
- download({
446
- queryParamsName: that.queryParamsName,
447
- form: that.form,
448
- type: 'exportData'
449
- }, that.title + `数据_${new Date().toLocaleString()}.xlsx`, that.serviceName)
450
- },
451
- onCancel () {}
452
- })
453
- },
454
- // 查询表单部分显示/隐藏切换
455
- toggleIsFormShow () {
456
- this.isFormShow = !this.isFormShow
457
- },
458
- // 控制业务操作按钮组的显示
459
- selectRow (rowKeys, rows) {
460
- this.selectedRowKeys = rowKeys
461
- this.selectedRows = rows
462
- this.isModify = this.selectedRowKeys.length === 1
463
- this.isDelete = this.selectedRowKeys.length > 0
464
- this.$emit('selectRow', this.selectedRowKeys, this.selectedRows)
465
- },
466
- // 创建临时表sql生成
467
- createTempTable (defineJson) {
468
- const tableName = defineJson.tableName
469
- const define = defineJson.column
470
- return post(CommonTempTable.createTempTable, {
471
- define: define,
472
- tableName: tableName
473
- })
474
- .then(
475
- res => {
476
- return res
477
- },
478
- err => {
479
- console.log(err)
480
- }
481
- )
482
- },
483
- // 插入临时表数据sql生成
484
- insertTempTableData (defineJson) {
485
- const tableName = defineJson.tableName
486
- const params = {}
487
- params.define = defineJson.column
488
- params.applyId = defineJson.applyId
489
- params.stepName = defineJson.stepName
490
- params.tableName = tableName
491
- return post(CommonTempTable.insertDataToTempTable, {
492
- tempTableData: params
493
- })
494
- .then(
495
- res => {
496
- return res
497
- }
498
- )
499
- },
500
- // 初始化临时表
501
- async initTempTable (json) {
502
- await this.createTempTable(this.queryParamsJson)
503
- await this.insertTempTableData(this.queryParamsJson)
504
- let result = {}
505
- await post(CommonTempTable.initApplySubTable, {
506
- define: json
507
- })
508
- .then(
509
- res => {
510
- console.log('子表临时表已创建')
511
- result = res
512
- }
513
- )
514
- return result
515
- }
516
- }
517
- }
518
- </script>
519
- <style lang="less" scoped>
520
- .btn-success {
521
- color: #ffffff;
522
- }
523
- .btn-success:hover {
524
- color: #ffffff !important;
525
- }
526
- .btn-success:focus {
527
- color: #ffffff !important;
528
- }
529
- .btn-success:enabled:hover {
530
- background-color: #85CE61 !important;
531
- border-color: #85CE61 !important;
532
- }
533
- .btn-success:enabled {
534
- background-color: #67c23a;
535
- border-color: #67c23a;
536
- }
537
- .btn-success:disabled {
538
- color: rgba(0, 0, 0, 0.25);
539
- }
540
- .btn-warn {
541
- color: #ffffff;
542
- }
543
- .btn-warn:hover {
544
- color: #ffffff !important;
545
- }
546
- .btn-warn:focus {
547
- color: #ffffff !important;
548
- }
549
- .btn-warn:enabled:hover {
550
- background-color: #ffc833 !important;
551
- border-color: #ffc833 !important;
552
- }
553
- .btn-warn:enabled {
554
- background-color: #ffba00;
555
- border-color: #ffba00;
556
- }
557
- .btn-warn:disabled {
558
- color: rgba(0, 0, 0, 0.25);
559
- }
560
- </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.form = {}
224
+ },
225
+ deep: true
226
+ },
227
+ queryParamsJson: {
228
+ handler () {
229
+ this.getColumnsJsonBySource()
230
+ },
231
+ deep: true
232
+ }
233
+ },
234
+ created () {
235
+ if (this.queryParamsName) {
236
+ this.getColumnsJson()
237
+ } else if (this.queryParamsJson) {
238
+ this.getColumnsJsonBySource()
239
+ }
240
+ },
241
+ methods: {
242
+ refreshTable (toFirstPage = true) {
243
+ this.$refs.xTable.refresh(toFirstPage)
244
+ },
245
+ clearRowKeys () {
246
+ this.$refs.xTable.clearRowKeys()
247
+ },
248
+ setParams (res) {
249
+ // 深拷贝json,避免筛选列报错
250
+ this.tableColumns = JSON.parse(JSON.stringify(res.columnJson))
251
+ this.formItems = res.formJson
252
+ this.buttonState = res.buttonState
253
+ this.serviceName = res.serviceName
254
+ this.mainLoading = false
255
+ this.loaded = true
256
+ },
257
+ getColumnsJson () {
258
+ this.form = {}
259
+ this.mainLoading = true
260
+ indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
261
+ this.setParams(ret)
262
+ })
263
+ },
264
+ getColumnsJsonBySource () {
265
+ this.form = {}
266
+ this.mainLoading = true
267
+ post(commonApi.getColumnsJson, { queryObject: this.queryParamsJson }).then(res => {
268
+ this.queryParams = res
269
+ this.setParams(res)
270
+ })
271
+ },
272
+ getColumnJsonByLogic () {
273
+ this.form = {}
274
+ this.mainLoading = true
275
+ indexedDB.getByWeb(`${this.logicName}_${JSON.stringify(this.logicParam)}`, commonApi.getColumnsJson, { logic: this.logicName, logicParam: this.logicParam }, (ret) => {
276
+ this.queryParams = ret
277
+ this.setParams(ret)
278
+ })
279
+ },
280
+ // 查询表单提交
281
+ onSubmit (res) {
282
+ if (res.valid) {
283
+ // 表单赋值
284
+ this.form = res.form
285
+ // commit
286
+ this.$emit('afterSearchSubmit', res)
287
+ } else {
288
+ return false
289
+ }
290
+ },
291
+ // 新增/修改数据表单提交
292
+ onAddOrModify (res) {
293
+ if (this.viewMode) {
294
+ this.$message.info('预览模式禁止新增和修改')
295
+ return false
296
+ }
297
+ // 如果是临时表
298
+ if (this.isTableTemp) {
299
+ this.$emit('tempTableModify', res)
300
+ return
301
+ }
302
+ if (!res.valid) {
303
+ return false
304
+ }
305
+ this.loading = true
306
+ const requestParameters = {
307
+ queryParamsName: this.queryParamsName,
308
+ form: {},
309
+ businessType: this.businessType,
310
+ operator: this.currUser.name
311
+ }
312
+ if (this.businessType === '修改') {
313
+ // 将更新需要的主键值加入到表单中
314
+ const key = this.tableColumns[0].dataIndex
315
+ const realKey = this.getRealKey(key)
316
+ requestParameters.form[realKey] = this.selectId
317
+ }
318
+ for (const key of Object.keys(res.form)) {
319
+ const realKey = this.getRealKey(key)
320
+ requestParameters.form[realKey] = res.form[key]
321
+ }
322
+ addOrModify(requestParameters, this.serviceName).then(res => {
323
+ this.$message.success(this.businessType + '成功!')
324
+ this.loading = false
325
+ this.modelVisible = false
326
+ this.$refs.xTable.refresh(true)
327
+ // commit
328
+ this.$emit('afterSubmit', { type: this.businessType, id: res.id, form: requestParameters.form })
329
+ }).catch(e => {
330
+ this.loading = false
331
+ this.modelVisible = false
332
+ this.$message.error(this.businessType + '失败!')
333
+ })
334
+ },
335
+ // 刷新加载表格数据
336
+ loadData (requestParameters, callback) {
337
+ let result = {}
338
+ if (this.queryParamsJson) {
339
+ if (this.queryParamsJson.tableName.startsWith('##')) {
340
+ this.isTableTemp = true
341
+ result = this.initTempTable(requestParameters)
342
+ }
343
+ }
344
+ if (!this.isTableTemp) {
345
+ result = query(requestParameters, this.serviceName)
346
+ }
347
+ this.$emit('afterQuery', result)
348
+ callback(result)
349
+ },
350
+ // 详情按钮事件
351
+ action (record, id, actionType) {
352
+ this.$emit('action', record, id, actionType)
353
+ },
354
+ // 获取数据字段实际值
355
+ getRealKey (key) {
356
+ return key.substring(key.indexOf('_') + 1)
357
+ },
358
+ // 新增业务
359
+ addItem () {
360
+ this.businessType = '新增'
361
+ this.modifyModelData = {}
362
+ this.modelVisible = true
363
+ },
364
+ // 修改业务
365
+ editItem (selectId) {
366
+ this.businessType = '修改'
367
+ const requestParameters = {
368
+ queryParamsName: this.queryParamsName,
369
+ conditionParams: {},
370
+ pageNo: 1,
371
+ pageSize: 1
372
+ }
373
+ if (selectId === undefined) {
374
+ selectId = this.selectedRowKeys[0]
375
+ }
376
+ this.selectId = selectId
377
+ requestParameters.conditionParams[this.tableColumns[0].dataIndex] = selectId
378
+ requestParameters.f_businessid = selectId
379
+ if (this.isTableTemp) {
380
+ this.$emit('tempTableEdit', requestParameters)
381
+ return
382
+ }
383
+ this.editDataLoading = true
384
+ queryWithResource(requestParameters, this.serviceName).then(res => {
385
+ this.modifyModelData = { data: res.data[0], images: res.images, files: res.files }
386
+ this.modelVisible = true
387
+ this.editDataLoading = false
388
+ })
389
+ },
390
+ // 删除业务
391
+ deleteItem () {
392
+ if (this.viewMode) {
393
+ this.$message.info('预览模式禁止删除')
394
+ return
395
+ }
396
+ Modal.confirm({
397
+ title: '提示',
398
+ content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
399
+ confirmLoading: this.loading,
400
+ zIndex: 1001,
401
+ onOk: () => {
402
+ this.loading = true
403
+ const requestParameters = {
404
+ queryParamsName: this.queryParamsName,
405
+ idList: this.selectedRowKeys
406
+ }
407
+ remove(requestParameters, this.serviceName).then(res => {
408
+ this.loading = false
409
+ this.$message.success('删除成功!')
410
+ this.$refs.xTable.clearRowKeys()
411
+ this.$refs.xTable.refresh(true)
412
+ // afterDelete
413
+ this.$emit('afterDelete', { idList: requestParameters.idList })
414
+ }).catch(e => {
415
+ this.loading = false
416
+ this.$message.error('删除失败!')
417
+ })
418
+ },
419
+ onCancel () {}
420
+ })
421
+ },
422
+ // 导出选中或本页数据
423
+ handleExport (isSelected) {
424
+ const tHeader = this.tableColumns.filter(res => res.slotType !== 'action').map(res => res.title)
425
+ const filterVal = this.tableColumns.map(res => res.dataIndex)
426
+ let exportData
427
+ if (isSelected) {
428
+ exportData = this.$refs.xTable.selectedRows
429
+ } else {
430
+ exportData = this.$refs.xTable.dataSource
431
+ }
432
+ const data = this.formatJson(filterVal, exportData)
433
+ exportJson(tHeader, data, this.title + `数据_${new Date().toLocaleString()}`)
434
+ },
435
+ formatJson (filterVal, jsonData) {
436
+ return jsonData.map(v => filterVal.map(j => v[j]))
437
+ },
438
+ // 导出符合条件的数据
439
+ handleExportByQuery () {
440
+ const that = this
441
+ this.$confirm({
442
+ title: '是否确认导出?',
443
+ content: '此操作将导出当前条件下所有数据而非选中数据',
444
+ onOk () {
445
+ download({
446
+ queryParamsName: that.queryParamsName,
447
+ form: that.form,
448
+ type: 'exportData'
449
+ }, that.title + `数据_${new Date().toLocaleString()}.xlsx`, that.serviceName)
450
+ },
451
+ onCancel () {}
452
+ })
453
+ },
454
+ // 查询表单部分显示/隐藏切换
455
+ toggleIsFormShow () {
456
+ this.isFormShow = !this.isFormShow
457
+ },
458
+ // 控制业务操作按钮组的显示
459
+ selectRow (rowKeys, rows) {
460
+ this.selectedRowKeys = rowKeys
461
+ this.selectedRows = rows
462
+ this.isModify = this.selectedRowKeys.length === 1
463
+ this.isDelete = this.selectedRowKeys.length > 0
464
+ this.$emit('selectRow', this.selectedRowKeys, this.selectedRows)
465
+ },
466
+ // 创建临时表sql生成
467
+ createTempTable (defineJson) {
468
+ const tableName = defineJson.tableName
469
+ const define = defineJson.column
470
+ return post(CommonTempTable.createTempTable, {
471
+ define: define,
472
+ tableName: tableName
473
+ })
474
+ .then(
475
+ res => {
476
+ return res
477
+ },
478
+ err => {
479
+ console.log(err)
480
+ }
481
+ )
482
+ },
483
+ // 插入临时表数据sql生成
484
+ insertTempTableData (defineJson) {
485
+ const tableName = defineJson.tableName
486
+ const params = {}
487
+ params.define = defineJson.column
488
+ params.applyId = defineJson.applyId
489
+ params.stepName = defineJson.stepName
490
+ params.tableName = tableName
491
+ return post(CommonTempTable.insertDataToTempTable, {
492
+ tempTableData: params
493
+ })
494
+ .then(
495
+ res => {
496
+ return res
497
+ }
498
+ )
499
+ },
500
+ // 初始化临时表
501
+ async initTempTable (json) {
502
+ await this.createTempTable(this.queryParamsJson)
503
+ await this.insertTempTableData(this.queryParamsJson)
504
+ let result = {}
505
+ await post(CommonTempTable.initApplySubTable, {
506
+ define: json
507
+ })
508
+ .then(
509
+ res => {
510
+ console.log('子表临时表已创建')
511
+ result = res
512
+ }
513
+ )
514
+ return result
515
+ }
516
+ }
517
+ }
518
+ </script>
519
+ <style lang="less" scoped>
520
+ .btn-success {
521
+ color: #ffffff;
522
+ }
523
+ .btn-success:hover {
524
+ color: #ffffff !important;
525
+ }
526
+ .btn-success:focus {
527
+ color: #ffffff !important;
528
+ }
529
+ .btn-success:enabled:hover {
530
+ background-color: #85CE61 !important;
531
+ border-color: #85CE61 !important;
532
+ }
533
+ .btn-success:enabled {
534
+ background-color: #67c23a;
535
+ border-color: #67c23a;
536
+ }
537
+ .btn-success:disabled {
538
+ color: rgba(0, 0, 0, 0.25);
539
+ }
540
+ .btn-warn {
541
+ color: #ffffff;
542
+ }
543
+ .btn-warn:hover {
544
+ color: #ffffff !important;
545
+ }
546
+ .btn-warn:focus {
547
+ color: #ffffff !important;
548
+ }
549
+ .btn-warn:enabled:hover {
550
+ background-color: #ffc833 !important;
551
+ border-color: #ffc833 !important;
552
+ }
553
+ .btn-warn:enabled {
554
+ background-color: #ffba00;
555
+ border-color: #ffba00;
556
+ }
557
+ .btn-warn:disabled {
558
+ color: rgba(0, 0, 0, 0.25);
559
+ }
560
+ </style>