@tongfun/tf-widget 0.1.21 → 0.1.22

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 (94) hide show
  1. package/README.md +49 -49
  2. package/lib/tf-widget.common.js +547 -503
  3. package/lib/tf-widget.css +1 -1
  4. package/lib/tf-widget.umd.js +547 -503
  5. package/lib/tf-widget.umd.min.js +4 -4
  6. package/package/svg-icon/index.js +8 -8
  7. package/package/svg-icon/src/SvgIcon.vue +59 -59
  8. package/package/t-data-list/index.js +6 -6
  9. package/package/t-data-list/main.vue +193 -193
  10. package/package/t-data-list/src/condition-input/basic.vue +31 -31
  11. package/package/t-data-list/src/condition-input/date.vue +106 -106
  12. package/package/t-data-list/src/condition-input/index.vue +100 -100
  13. package/package/t-data-list/src/condition-input/input.vue +31 -31
  14. package/package/t-data-list/src/condition-input/number.vue +115 -115
  15. package/package/t-data-list/src/condition-input/select.vue +86 -86
  16. package/package/t-data-list/src/js/fieldTypeEnum.js +10 -10
  17. package/package/t-data-list/src/js/operatorEnum.js +108 -108
  18. package/package/t-data-list/src/js/qureyParamsEnum.js +4 -4
  19. package/package/t-data-list/src/js/util.js +34 -34
  20. package/package/t-data-list/src/mixins/button-controll-mixin.js +93 -93
  21. package/package/t-data-list/src/pushdown/push-down.vue +158 -158
  22. package/package/t-data-list/src/t-list-search.vue +36 -36
  23. package/package/t-data-list/src/t-plan/condition-always-item.vue +143 -143
  24. package/package/t-data-list/src/t-plan/condition-mult-item.vue +222 -222
  25. package/package/t-data-list/src/t-plan/index.vue +195 -195
  26. package/package/t-data-list/src/t-plan/plan-content.vue +389 -389
  27. package/package/t-data-list/src/t-table/index.vue +129 -129
  28. package/package/t-data-list/src/t-table/table-group-item-edit.vue +238 -238
  29. package/package/t-data-list/src/t-table/table-group-item.vue +87 -87
  30. package/package/t-data-list/src/t-table/table-group.vue +180 -180
  31. package/package/t-data-list/src/t-table/table-records-header-popover.vue +246 -246
  32. package/package/t-data-list/src/t-table/table-records-selected.vue +159 -159
  33. package/package/t-data-list/src/t-table/table-records.vue +337 -337
  34. package/package/t-input/children/address.vue +101 -101
  35. package/package/t-input/children/basic-display.vue +41 -41
  36. package/package/t-input/children/basic.vue +253 -253
  37. package/package/t-input/children/date.vue +89 -89
  38. package/package/t-input/children/group-components/group-dialog.vue +344 -344
  39. package/package/t-input/children/group.vue +126 -126
  40. package/package/t-input/children/input.vue +72 -72
  41. package/package/t-input/children/number.vue +74 -74
  42. package/package/t-input/children/select.vue +89 -89
  43. package/package/t-input/children/tfile/fiile-enclosure.vue +233 -233
  44. package/package/t-input/index.js +7 -7
  45. package/package/t-input/index.vue +337 -337
  46. package/package/t-input/tInputCache.js +24 -24
  47. package/package/tf-icon-picker/README.md +7 -7
  48. package/package/tf-icon-picker/index.js +8 -8
  49. package/package/tf-icon-picker/src/tf-icon-picker.vue +266 -266
  50. package/package/tf-layout/README.md +115 -115
  51. package/package/tf-layout/index.js +8 -8
  52. package/package/tf-layout/src/components/tf-labelbar.vue +394 -394
  53. package/package/tf-layout/src/components/tf-menu.vue +180 -180
  54. package/package/tf-layout/src/components/tf-right-menu.vue +89 -89
  55. package/package/tf-layout/src/components/tf-rotate-box.vue +50 -50
  56. package/package/tf-layout/src/tf-layout.vue +140 -140
  57. package/package/tf-widget/index.js +8 -8
  58. package/package/tf-widget/src/assets/common-input.less +10 -10
  59. package/package/tf-widget/src/children/basic-data/basic-data.vue +361 -361
  60. package/package/tf-widget/src/children/basic-data/dependcy/basic-data-selector.vue +1087 -1087
  61. package/package/tf-widget/src/children/basic-data/dependcy/common-table.vue +750 -750
  62. package/package/tf-widget/src/children/basic-data/dependcy/condition-filter.vue +519 -519
  63. package/package/tf-widget/src/children/basic-data/dependcy/pagination.vue +93 -93
  64. package/package/tf-widget/src/children/basic-data/dependcy/table-control.vue +240 -240
  65. package/package/tf-widget/src/children/basic-data/dependcy/view-picture.vue +108 -108
  66. package/package/tf-widget/src/children/date-time.vue +103 -103
  67. package/package/tf-widget/src/children/date.vue +103 -103
  68. package/package/tf-widget/src/children/decimal.vue +115 -115
  69. package/package/tf-widget/src/children/integer.vue +104 -104
  70. package/package/tf-widget/src/children/property.vue +59 -59
  71. package/package/tf-widget/src/children/single-line-text.vue +82 -82
  72. package/package/tf-widget/src/children/small-pictures.vue +223 -223
  73. package/package/tf-widget/src/children/text-area.vue +74 -74
  74. package/package/tf-widget/src/children/tf-select.vue +113 -113
  75. package/package/tf-widget/src/tf-widget.vue +175 -175
  76. package/package.json +44 -44
  77. package/src/api/edit.js +97 -97
  78. package/src/api/file-enclosure.js +26 -26
  79. package/src/api/push-down.js +19 -19
  80. package/src/api/table.js +294 -294
  81. package/src/api/tableV3.js +166 -160
  82. package/src/assets/images/icons/index.js +9 -9
  83. package/src/assets/images/icons/svg/add.svg +5 -5
  84. package/src/assets/images/icons/svg/push-down.svg +1 -1
  85. package/src/assets/images/icons/svg/remove.svg +1 -1
  86. package/src/assets/styles/common-table.less +202 -202
  87. package/src/directives/debounce.js +24 -24
  88. package/src/index.js +31 -31
  89. package/src/mixins/t-data-query-mixin.js +290 -290
  90. package/src/utils/auth.js +22 -22
  91. package/src/utils/request.js +42 -42
  92. package/src/utils/stato-anormale.js +59 -59
  93. package/src/utils/utils.js +109 -109
  94. package/src/utils/validate.js +84 -84
@@ -1,1087 +1,1087 @@
1
- <template>
2
- <div class="main-container">
3
- <div class="strength-data-header">
4
- <div>
5
- <el-button class="header-input" type="primary" @click="refreshMethod">刷新</el-button>
6
- <!-- <el-button class="header-input" type="primary" @click="addTableData">新增</el-button>
7
- <el-button class="header-input" type="primary">编辑</el-button>
8
- <el-button class="header-input" type="primary" @click="refreshMethod">刷新</el-button>
9
- <el-button class="header-input" type="primary" @click="deleteTableData">删除</el-button>
10
- <el-button class="header-input" type="primary">导入</el-button>
11
- <el-button class="header-input" type="primary">导出</el-button>
12
- <el-button class="header-input" type="primary">审核</el-button>
13
- <el-button class="header-input" type="primary">反审核</el-button> -->
14
- <!-- <el-button class="header-input" type="primary" @click="logInfo">打印</el-button>-->
15
- <slot name="buttonGroup" />
16
- </div>
17
- <div class="strength-data-header-middle">
18
- <!-- <PlanFilter :filter-key="pageData.filterKey" :filter-list="pageData.filterList" @updateFilterKey="updateFilterKey" /> -->
19
- <div class="filter">
20
- <ConditionFilter
21
- :is-quick-filter="pageData.isQuickFilter"
22
- :quick-filter-data="pageData.quickFilterData"
23
- :condition-filter-suggest="pageData.conditionFilterSuggest"
24
- :more-condition-filter-map="pageData.moreConditionFilterMap"
25
- :more-condition-filter-data="pageData.moreConditionFilterData"
26
- @quickConditionClear="quickConditionClear"
27
- @changeIsQuickFilter="changeIsQuickFilter"
28
- @quickFilterStart="quickFilterStart"
29
- @updateMoreCondition="updateMoreCondition"
30
- @changeRotate="changeRotate"
31
- @moreConditionSearch="moreConditionSearch"
32
- @moreConditionClear="moreConditionClear"
33
- @addMultipleLine="addMultipleLine"
34
- @removeMultipleLine="removeMultipleLine"
35
- />
36
- </div>
37
- </div>
38
- </div>
39
- <div class="strength-data-body">
40
- <template v-if="pageData.commonTableLayout.length > 0">
41
- <!-- 切换表体 -->
42
- <el-tabs v-if="pageData.entityName.length > 0" v-model="pageData.activeEntity">
43
- <el-tab-pane
44
- v-for="(item,index) in pageData.entityName"
45
- :key="index"
46
- :label="item.label"
47
- :name="item.name"
48
- />
49
- </el-tabs>
50
- <CommonTable
51
- ref="commonTable"
52
- v-loading="pageData.tableLoading"
53
- :double-select="doubleSelect"
54
- :table-id="pageData.tableId"
55
- :table-data="pageData.commonTableData"
56
- :table-layout="pageData.commonTableLayout"
57
- :paging="pageData.paging"
58
- :head-name="pageData.headName"
59
- :total-data="pageData.totalData"
60
- :single-select="true"
61
- :quick-filter-data="pageData.quickFilterData"
62
- :selected-total="pageData.tableSelectionData.length"
63
- @quickSearch="quickSearch"
64
- @updateParentTableData="updateParentTableData"
65
- @renderColumnWidth="renderColumnWidth"
66
- @tableBeforeDestroy="tableBeforeDestroy"
67
- @pageChange="pageChange"
68
- @selectionChange="selectionChange"
69
- />
70
- </template>
71
- <template v-else>
72
- <div style="display:flex;align-items: center;justify-content: center;height: 100%">
73
- <div style="width: 100%;height: 15%;text-align: center">
74
- <SvgIcon icon-class="table-empty" style="width: 100%;height: 100%;" />
75
- <div>
76
- 暂无数据
77
- </div>
78
- </div>
79
- </div>
80
-
81
- </template>
82
- </div>
83
- </div>
84
- </template>
85
-
86
- <script>
87
- // 组件
88
- import ConditionFilter from './condition-filter'
89
- import CommonTable from './common-table'
90
- // api
91
- import {
92
- getCommonTableSearchCondition,
93
- getCommonTableHighSearchCondition,
94
- getFilterData,
95
- getFilterDataSum,
96
- deleteCommonTableData,
97
- findTableGroup,
98
- getSelectList,
99
- getFastSearchSuggestionVos,
100
- getCommonTableLayout2, getDescriptionByTableId
101
- } from '@/api/table'
102
-
103
- export default {
104
- name: 'BasicDataSelector',
105
- components: {
106
- ConditionFilter,
107
- CommonTable
108
- },
109
- props: {
110
- dialogVisible: {
111
- type: Boolean,
112
- default: false
113
- },
114
- limitShow: {
115
- type: Number,
116
- default: 0
117
- },
118
- doubleSelect: {
119
- type: Boolean,
120
- default: false
121
- },
122
- tableId: {
123
- type: String,
124
- default: ''
125
- }
126
- },
127
- data () {
128
- return {
129
- pageData: {
130
- configId: null,
131
- tableId: '',
132
- filterKey: '缺省方案',
133
- configList: [], // 过滤方案配置信息
134
- // 当前采用的过滤方案配置
135
- currentConfig: {
136
- name: '',
137
- sharingScheme: 1,
138
- user: '',
139
- fieldList: [],
140
- userMap: {},
141
- isSave: true
142
- }, // 当前页面配置信息
143
- filterList: [ // 过滤方案数组
144
- { value: '缺省方案', label: '缺省方案' },
145
- { value: '方案一', label: '方案一' },
146
- { value: '方案二', label: '方案二' }
147
- ],
148
- changeTableBodyData: {
149
- tableList: []
150
- }, // 切换表体按钮展示的数据
151
- groupFilter: {
152
- filterText: '',
153
- currentNodeKey: {},
154
- treeData: [],
155
- defaultProps: {
156
- children: 'children',
157
- label: 'name'
158
- },
159
- dialogTitle: '新增',
160
- dialogVisible: false,
161
- form: {},
162
- allTableField: [] // 表格所有字段
163
- },
164
- commonTableData: [], // 表格数据
165
- commonTableLayout: [], // 表格布局
166
- totalData: ['合计'], // 表格合计数据
167
- destroySettingInfo: null,
168
- isQuickFilter: true, // 快捷过滤标志
169
- quickFilterData: {},
170
- rotate: true, // 表示默认高级过滤为单行,反之则为多行
171
- moreConditionFilterMap: new Map(),
172
- moreConditionFilterData: { // 高级过滤考虑到多层条件过滤,需将value作为数组,并一一对应
173
- name: { arr: [], value: [''] }, // 字段数组,value数组初始化一个对象是为了单行高级过滤,以下同
174
- condition: { arr: [], value: [''] }, // 条件数组
175
- type: [''],
176
- value: [''], // 值数组
177
- leftBracket: { // 左括弧数组
178
- arr: [
179
- { label: '(', value: '(' },
180
- { label: '((', value: '((' },
181
- { label: '(((', value: '(((' }
182
- ],
183
- value: ['(']
184
- },
185
- rightBracket: { // 右括弧数组
186
- arr: [
187
- { label: ')', value: ')' },
188
- { label: '))', value: '))' },
189
- { label: ')))', value: ')))' }
190
- ],
191
- value: [')']
192
- },
193
- relatedCondition: { // 多条件关联关系数组
194
- arr: [
195
- { label: '并且', value: 'and' },
196
- { label: '或者', value: 'or' }
197
- ],
198
- value: []
199
- }
200
- },
201
- moreConditionFilterDataBak: [], // 高级过滤最初数据状态
202
- headName: '', // 表头名
203
- entityName: [], // 表体数组
204
- activeEntity: null, // 显示的表体名
205
- paging: {
206
- current: 1, // 页码
207
- size: 50, // 单页总数
208
- total: 0
209
- },
210
- conditionFilterSuggest: {},
211
- tableLoading: true, // 表格加载状态
212
- tableSelectionData: [], // 表格选中数组
213
- placeholderData: '', // 内容搜索提示
214
- mulFilterField: [ // 导出功能默认值,不可删除
215
- {
216
- fieldName: '',
217
- fieldType: '',
218
- originTable: '',
219
- secondMenuValue: '',
220
- thirdMenuValue: ''
221
- }
222
- ]
223
- },
224
- refreshMethod: null, // 刷新防抖
225
- DetermineWhetherTheTableidTasChanged: false// 判断传来的tableId是否与之前的tableId相同
226
- }
227
- },
228
- computed: {
229
-
230
- },
231
- watch: {
232
- // 监听高级过滤字段是否重复
233
- 'pageData.moreConditionFilterData': {
234
- handler (newVal) {
235
- const arr = newVal.name.value
236
- const conditionArr = newVal.condition.value
237
- const valueArr = newVal.value
238
- const rep = []
239
- arr.forEach((item, index) => {
240
- if (arr.indexOf(item) !== index && item !== '') {
241
- const obj = {}
242
- obj.key = index
243
- obj.value = item
244
- rep.push(obj)
245
- }
246
- })
247
- if (rep.length > 0) {
248
- this.$message.warning('字段重复,请重新选择!')
249
- rep.forEach((item, index) => {
250
- arr[item.key] = ''
251
- conditionArr[item.key] = ''
252
- valueArr[item.key] = ''
253
- })
254
- }
255
- },
256
- deep: true
257
- },
258
- tableId: {
259
- handler (newVal, oldVal) {
260
- if (oldVal !== newVal && newVal) {
261
- this.DetermineWhetherTheTableidTasChanged = true
262
- this.pageData.tableId = newVal
263
- this.initTable()
264
- }
265
- },
266
- immediate: true
267
- },
268
- dialogVisible (newVal) {
269
- if (!this.DetermineWhetherTheTableidTasChanged) {
270
- return
271
- }
272
- this.pageData.commonTableData = []
273
- this.judge(newVal)
274
- }
275
- },
276
- created () {
277
- // 定义防抖方法
278
- this.refreshMethod = this.utils.debounce(this.refresh)
279
- this.pageData.tableId = this.tableId
280
- this.initTable()
281
- },
282
- methods: {
283
- // 判断tableId和dialogVisible是否为true --- 结算需要
284
- judge (newVal) {
285
- if (newVal && this.DetermineWhetherTheTableidTasChanged) {
286
- this.initTable()
287
- }
288
- },
289
- logInfo () {
290
-
291
- },
292
-
293
- // 新增
294
- addTableData () {
295
- const randomNum = Math.floor(Math.random() * 1000000)
296
- this.$router.push({
297
- path: this.$route.path + '/' + randomNum
298
- })
299
- },
300
-
301
- // 删除
302
- deleteTableData () {
303
- if (this.pageData.tableSelectionData.length === 0) {
304
- this.$message.warning('请先选择要删除的数据!')
305
- return
306
- }
307
- const ids = []
308
- this.pageData.tableSelectionData.forEach((item, index) => {
309
- if (ids.indexOf(item.head__id) === -1) {
310
- ids.push(item.head__id)
311
- }
312
- })
313
- const data = {
314
- identification: this.pageData.headName,
315
- ids: ids,
316
- onlyDelEntity: false,
317
- tableId: this.pageData.tableId
318
- }
319
- deleteCommonTableData(data).then(res => {
320
- if (res.code === 0) {
321
- this.$message.success('删除成功!')
322
- this.refresh()
323
- }
324
- })
325
- },
326
-
327
- selectionChange (value) {
328
- if (this.doubleSelect) {
329
- this.pageData.tableSelectionData = value
330
- this.$emit('rowSelect', value)
331
- return
332
- }
333
- this.pageData.tableSelectionData = value
334
- this.$emit('rowSelect', value)
335
- // this.$emit('rowSelect', value[0])
336
- },
337
-
338
- // 初始化分组
339
- initGroupFilter () {
340
- const data = {
341
- tableId: this.pageData.tableId
342
- }
343
-
344
- // 获取表格分组过滤数据
345
- findTableGroup(data).then(res => {
346
- if (res.code === 0) {
347
- this.pageData.groupFilter.treeData = res.data
348
- }
349
- })
350
- },
351
-
352
- async initTable () {
353
- const data = {
354
- tableId: this.pageData.tableId
355
- }
356
- // this.getPageConfig()
357
-
358
- // 获取切换表体的配置页面
359
- await getSelectList(data).then(res => {
360
- this.pageData.changeTableBodyData.headName = res.data.headName
361
- if (res.data.entityName.length > 0) {
362
- // this.pageData.activeEntity = res.data.entityName[0]
363
- res.data.entityName.forEach((e, index) => {
364
- this.pageData.changeTableBodyData.tableList.push({
365
- value: res.data.entityName[index],
366
- name: res.data.entityChineseName[index]
367
- })
368
- })
369
- this.pageData.activeEntity = this.pageData.changeTableBodyData.tableList[0].value
370
- }
371
- this.pageData.headName = res.data.headName
372
- })
373
- // 获取快捷过滤字段信息
374
- await new Promise(resolve => {
375
- getCommonTableSearchCondition(data).then(res => {
376
- if (res.code === 0) {
377
- this.pageData.quickFilterData.filterArr = res.data
378
- // this.pageData.quickFilterData.filterArr.forEach((item, index) => {
379
- // this.$set(this.pageData.quickFilterData, item.id, '')
380
- // })
381
- resolve()
382
- } else {
383
- this.$message.error('获取快捷过滤字段信息失败,请稍后重试!')
384
- }
385
- })
386
- }).catch(() => {
387
- this.$message.error('获取快捷过滤字段信息失败,请稍后重试!')
388
- })
389
- this.changeTableBody()
390
-
391
- // 获取快捷过滤输入框搜索建议
392
- if (this.pageData.quickFilterData.filterArr && this.pageData.quickFilterData.filterArr.length > 0) {
393
- const data = {
394
- fastSearchSuggestQueryDtos: []
395
- }
396
- this.pageData.quickFilterData.filterArr.forEach((item, index) => {
397
- const obj = {
398
- columnName: item.name,
399
- tableName: item.tableName
400
- }
401
- data.fastSearchSuggestQueryDtos.push(obj)
402
- })
403
- getFastSearchSuggestionVos(data).then(res => {
404
- if (res.code === 0) {
405
- const data = res.data
406
- data.forEach((item, index) => {
407
- // 区分表头和表体字段
408
- let headText = 'head__'
409
- const findIndex = this.pageData.quickFilterData.filterArr.findIndex(d => d.name === item.columnName && d.tableName === item.tableName)
410
- if (findIndex !== -1) {
411
- if (item.tableName !== this.pageData.headName) {
412
- // 表体字段
413
- headText = 'entity__'
414
- }
415
- }
416
- // 设置输入框初始值
417
- this.$set(this.pageData.quickFilterData, headText + item.columnName, '')
418
- // 设置备份数组
419
- this.pageData.quickFilterData[headText + item.columnName + 'CheckedList_Bak'] = item.suggestions
420
- // 搜索建议实时数组
421
- this.pageData.quickFilterData[headText + item.columnName + 'CheckedList'] = item.suggestions
422
- // 默认全选
423
- this.$set(this.pageData.quickFilterData, headText + item.columnName + 'Checked', [...item.suggestions, '全选'])
424
- // 用户选中值初始化(在表头点击确认才可生效)
425
- this.$set(this.pageData.quickFilterData, headText + item.columnName + 'Checked_True', [])
426
- })
427
- }
428
- })
429
- }
430
-
431
- const data2 = {
432
- filterType: 0, // 为0代表快捷过滤,为1代表高级过滤
433
- conditionValues: [],
434
- pageAndTableInfo: {
435
- existEntity: this.pageData.entityName.length !== 0,
436
- headName: this.pageData.headName,
437
- pageNum: this.pageData.paging.current,
438
- pageSize: this.pageData.paging.size,
439
- tableId: this.pageData.tableId
440
- },
441
- roleIds: ['1']
442
- }
443
-
444
- // 如果存在表体,传参需多传一个表体字段
445
- if (this.pageData.entityName.length > 0) {
446
- data2.pageAndTableInfo.oneEntityName = this.pageData.activeEntity
447
- }
448
-
449
- // 获取表格数据与合计信息
450
-
451
- // this.getTableDataAndSumByType(data2)
452
-
453
- // 获取全内容搜索框
454
- this.getDescriptionByTableIdData()
455
-
456
- // 获取表格分组过滤数据
457
- // this.initGroupFilter()
458
- },
459
-
460
- async getPageConfig () {
461
- // const data = {
462
- // filterType: 1,
463
- // mulFilterField: [
464
- // {
465
- // fieldName: 'user_id',
466
- // fieldType: 'varchar(100)',
467
- // originTable: 'u_crud_filter_plan',
468
- // secondMenuValue: 'equal',
469
- // thirdMenuValue: this.userId
470
- // },
471
- // {
472
- // fieldName: 'table_id',
473
- // fieldType: 'varchar(100)',
474
- // originTable: 'u_crud_filter_plan',
475
- // secondMenuValue: 'equal',
476
- // thirdMenuValue: this.pageData.tableId
477
- // }
478
- // ],
479
- // pageAndTableInfo: {
480
- // existEntity: false,
481
- // headName: 'u_crud_filter_plan',
482
- // pageNum: 1,
483
- // pageSize: 1000,
484
- // tableId: '1621411430682',
485
- // oneEntityName: 'u_crud_filter_plan_entry'
486
- // },
487
- // rule: '(0)and(1)',
488
- // roleIds: [
489
- // '1'
490
- // ],
491
- // sorts: [
492
- // {
493
- // fieldName: 'default_plan',
494
- // sortType: 0,
495
- // tableName: 'u_crud_filter_plan'
496
- // }
497
- // ]
498
- // }
499
- // const res = await getFilterData(data)
500
- // if (res.code !== 0) {
501
- // return this.$message.error(res.msg)
502
- // }
503
- // const planList = res.data.records
504
- // this.pageData.filterList = []
505
- // planList.forEach(element => {
506
- // this.pageData.filterList.push({
507
- // value: element.head__name,
508
- // label: element.head__name,
509
- // id: element.head__id,
510
- // code: element.head__code
511
- // })
512
- // this.pageData.configList[element.head__name] = {
513
- // mulFilterField: element.head__condition_json,
514
- // commonTableLayout: element.head__field_attr
515
- // }
516
- // })
517
- },
518
-
519
- // 获取全内容搜索框
520
- getDescriptionByTableIdData () {
521
- this.pageData.placeholderData = ''
522
- const data = {
523
- tableId: this.pageData.tableId
524
- }
525
- getDescriptionByTableId(data).then(res => {
526
- if (res.code === 0) {
527
- this.pageData.placeholderData = res.data
528
- } else {
529
- this.$message.error('系统维护中~请稍后再试~')
530
- }
531
- }).catch(() => {
532
- this.$message.error('系统维护中~请稍后再试~')
533
- })
534
- },
535
-
536
- // 切换表体,及初始化表体方法
537
- async changeTableBody (value) {
538
- if (value === this.pageData.activeEntity) {
539
- return
540
- }
541
- const data = {
542
- existEntity: false,
543
- headName: this.pageData.headName,
544
- oneEntityName: this.pageData.activeEntity,
545
- tableId: this.pageData.tableId
546
- }
547
-
548
- if (value) {
549
- data.oneEntityName = value
550
- this.pageData.activeEntity = value
551
- }
552
- (this.pageData.activeEntity !== null && this.pageData.activeEntity !== 'nothing') ? data.existEntity = true : data.existEntity = false
553
-
554
- // 获取表格的表头字段信息
555
- await getCommonTableLayout2(data).then(res => {
556
- if (res.code === 0) {
557
- const data = res.data
558
- data.forEach((item, index) => {
559
- item.align = 'center'
560
- item.width = '100' // 切换
561
- item.fixed = ''
562
- item.hiddenFlag = false
563
- item.sortTable = false
564
- item.isQuick = false
565
- // 添加表头表体字段标识
566
- if (item.originTableName === this.pageData.headName) {
567
- item.fieldName = 'head__' + item.fieldName
568
- } else {
569
- item.fieldName = 'entity__' + item.fieldName
570
- }
571
- })
572
- // 快捷过滤字段添加标识
573
- if (this.pageData.quickFilterData.filterArr && this.pageData.quickFilterData.filterArr.length > 0) {
574
- this.pageData.quickFilterData.filterArr.forEach((item, index) => {
575
- let fieldValue = ''
576
- if (item.tableName === this.pageData.headName) {
577
- fieldValue = 'head__' + item.name
578
- } else {
579
- fieldValue = 'entity__' + item.name
580
- }
581
-
582
- const findIndex = data.findIndex(d => d.fieldName === fieldValue)
583
- if (findIndex !== -1) {
584
- data[findIndex].isQuick = true
585
- }
586
- })
587
- }
588
- this.pageData.commonTableLayout = data
589
- } else {
590
- this.$message.error('获取或切换单据体失败')
591
- }
592
- })
593
-
594
- let isClearFilterData = false
595
- if (value) {
596
- isClearFilterData = true
597
- }
598
-
599
- this.moreConditionSearch(isClearFilterData)
600
- this.searchCondition()
601
- },
602
-
603
- // 查询高级过滤下拉框列表
604
- searchCondition () {
605
- const data = {
606
- existEntity: false,
607
- headName: this.pageData.headName,
608
- oneEntityName: this.pageData.activeEntity,
609
- tableId: this.pageData.tableId
610
- }
611
- this.pageData.activeEntity !== null && this.pageData.activeEntity !== 'nothing' ? data.existEntity = true : data.existEntity = false
612
-
613
- getCommonTableHighSearchCondition(data).then(res => {
614
- if (res.code === 0) {
615
- const data = res.data
616
- // 存储备份数据,以备与后台交互数据
617
- this.pageData.moreConditionFilterDataBak = data
618
- this.pageData.moreConditionFilterData.name.arr = []
619
- data.forEach((item, index) => {
620
- // 设置高级过滤字段数组
621
- this.pageData.moreConditionFilterData.name.arr.push({ label: item.title, value: item.fieldName, type: item.fieldType })
622
- const arr = []
623
- for (const key in item.secondLevelMenu) {
624
- arr.push({ value: key, label: item.secondLevelMenu[key] })
625
- }
626
- // 设置字段对应的条件数组,在字段改变时,修改对应的条件数组
627
-
628
- this.pageData.moreConditionFilterMap.set(item.fieldName, arr)
629
- })
630
- }
631
- })
632
- },
633
-
634
- // 监听分页数据改变
635
- pageChange () {
636
- // 如果是快捷过滤
637
- if (this.pageData.isQuickFilter) {
638
- // this.quickFilterStart()
639
- this.quickSearch()
640
- } else { // 如果是高级过滤
641
- this.moreConditionSearch()
642
- }
643
- },
644
-
645
- // 快捷过滤
646
- quickFilterStart () {
647
- const arr = []
648
- this.pageData.quickFilterData.filterArr.forEach((item, index) => {
649
- if (this.pageData.quickFilterData[item.id] !== null && this.pageData.quickFilterData[item.id] !== '') {
650
- arr.push({ id: item.id, value: this.pageData.quickFilterData[item.id] })
651
- }
652
- })
653
- const data = {
654
- filterType: 0, // 为0代表快捷过滤,为1代表高级过滤
655
- conditionValues: arr,
656
- pageAndTableInfo: {
657
- existEntity: this.pageData.entityName.length !== 0,
658
- headName: this.pageData.headName,
659
- pageNum: this.pageData.paging.current,
660
- pageSize: this.pageData.paging.size,
661
- tableId: this.pageData.tableId
662
- },
663
- roleIds: ['1']
664
- }
665
- // 如果存在表体,传参需多传一个表体字段
666
- if (this.pageData.entityName.length > 0) {
667
- data.pageAndTableInfo.oneEntityName = this.pageData.activeEntity
668
- }
669
- if (this.limitShow === 1) {
670
- data.examineFlag = 1
671
- }
672
- // 获取表格数据与合计信息
673
- this.getTableDataAndSumByType(data)
674
- },
675
-
676
- // 快捷过滤重置
677
- quickConditionClear () {
678
- this.pageData.quickFilterData.filterArr.forEach((item, index) => {
679
- this.pageData.quickFilterData[item.id] = ''
680
- })
681
- // this.$message.success('重置成功!')
682
- },
683
-
684
- // 高级过滤字段更新时,修改条件数组(子组件触发)
685
- updateMoreCondition (val) {
686
- // 获取字段类型
687
- const typeObj = this.pageData.moreConditionFilterData.name.arr.find(d => d.value === val)
688
- if (typeObj === undefined) {
689
- this.$message.error('未找到字段类型,刷新重试')
690
- return
691
- }
692
- const type = typeObj.type
693
- // 更新value类型
694
- const index = this.pageData.moreConditionFilterData.name.value.findIndex(d => d === val)
695
- this.pageData.moreConditionFilterData.type[index] = type === 'datetime' ? 'datetime' : 'input'
696
- // 更新条件数组
697
- this.pageData.moreConditionFilterData.condition.arr[index] = this.pageData.moreConditionFilterMap.get(val)
698
- // 更新条件值
699
- // (如果varchar类型的条件数组存在“包含”,条件变为“包含”,
700
- // 如果int类型的条件数组存在“等于”,条件变为“等于”,
701
- // 如果datetime类型的条件数组存在“今天”,条件变为“今天”)
702
- if (type.indexOf('varchar') !== -1) {
703
- const includeObj = this.pageData.moreConditionFilterData.condition.arr[index].find(d => d.label === '包含')
704
- this.pageData.moreConditionFilterData.condition.value[index] = includeObj ? includeObj.value : ''
705
- } else if (type.indexOf('int') !== -1) {
706
- const includeObj = this.pageData.moreConditionFilterData.condition.arr[index].find(d => d.label === '等于')
707
- this.pageData.moreConditionFilterData.condition.value[index] = includeObj ? includeObj.value : ''
708
- } else if (type.indexOf('datetime') !== -1) {
709
- const includeObj = this.pageData.moreConditionFilterData.condition.arr[index].find(d => d.label === '今天')
710
- this.pageData.moreConditionFilterData.condition.value[index] = includeObj ? includeObj.value : ''
711
- }
712
- // 更新value
713
- // 判断是否字段重复,重复先不清空value值
714
- const length = this.pageData.moreConditionFilterData.name.value.filter(d => d === val).length
715
- if (length === 1) {
716
- this.pageData.moreConditionFilterData.value[index] = ''
717
- }
718
- },
719
-
720
- // 高级过滤的单行模式与多行模式切换(子组件触发)
721
- changeRotate (value) {
722
- this.pageData.rotate = value
723
- },
724
-
725
- // 校验高级过滤条件是否填写完整
726
- checkMoreCondition () {
727
- // 校验
728
- let flag = false
729
- this.pageData.moreConditionFilterData.name.value.forEach((item, index) => {
730
- // 如果是单行,不需要判断左右括号,多行模式则需要
731
- if (this.pageData.moreConditionFilterData.name.value.length === 1) {
732
- // 如果选中了字段,代表需要过滤条件
733
- if (this.pageData.moreConditionFilterData.name.value[0] !== '') {
734
- if (!this.pageData.moreConditionFilterData.condition.value[index] ||
735
- !this.pageData.moreConditionFilterData.value[index]) {
736
- flag = true
737
- }
738
- }
739
- } else {
740
- if (!this.pageData.moreConditionFilterData.leftBracket.value[index] ||
741
- !this.pageData.moreConditionFilterData.name.value[index] ||
742
- !this.pageData.moreConditionFilterData.condition.value[index] ||
743
- !this.pageData.moreConditionFilterData.value[index] ||
744
- !this.pageData.moreConditionFilterData.rightBracket.value[index]) {
745
- flag = true
746
- }
747
- }
748
- })
749
- return flag
750
- },
751
-
752
- // 高级过滤搜索(子组件触发)
753
- moreConditionSearch () {
754
- // 校验
755
- // if (this.checkMoreCondition()) {
756
- // this.$message.error('请完整填写!')
757
- // return false
758
- // }
759
- const arr = []
760
- this.pageData.moreConditionFilterData.name.value.forEach((item, index) => {
761
- const filterField = this.pageData.moreConditionFilterDataBak.find(d => d.fieldName === item)
762
- if (filterField !== undefined) {
763
- const obj = {
764
- fieldName: filterField.fieldName,
765
- fieldType: filterField.fieldType,
766
- originTable: filterField.originTable,
767
- secondMenuValue: this.pageData.moreConditionFilterData.condition.value[index],
768
- thirdMenuValue: this.pageData.moreConditionFilterData.value[index]
769
- }
770
- arr.push(obj)
771
- }
772
- })
773
- let rule = ''
774
- this.pageData.moreConditionFilterData.name.value.forEach((item, index) => {
775
- rule += this.pageData.moreConditionFilterData.leftBracket.value[index] +
776
- index + this.pageData.moreConditionFilterData.rightBracket.value[index]
777
- // 不添加最后一行的关系数据
778
- if (this.pageData.moreConditionFilterData.relatedCondition.value[index] !== undefined) {
779
- rule += this.pageData.moreConditionFilterData.relatedCondition.value[index]
780
- }
781
- })
782
- const data = {
783
- filterType: 1,
784
- mulFilterField: arr,
785
- pageAndTableInfo: {
786
- existEntity: this.pageData.entityName.length !== 0,
787
- headName: this.pageData.headName,
788
- pageNum: this.pageData.paging.current,
789
- pageSize: this.pageData.paging.size,
790
- tableId: this.pageData.tableId
791
- },
792
- rule: arr.length === 0 ? '' : arr.length === 1 ? '(0)' : rule,
793
- roleIds: ['1'],
794
- sorts: [
795
- {
796
- fieldName: 'create_time',
797
- sortType: 1,
798
- tableName: this.pageData.headName
799
- }
800
- ]
801
- }
802
- // 如果存在表体,传参需多传一个表体字段
803
- if (this.pageData.entityName.length > 0) {
804
- data.pageAndTableInfo.oneEntityName = this.pageData.activeEntity
805
- }
806
- if (this.limitShow === 1) {
807
- data.examineFlag = 1
808
- }
809
- // 获取表格数据与合计信息
810
- this.getTableDataAndSumByType(data)
811
- },
812
-
813
- getTableDataAndSumByType (data) {
814
- // 表格展示加载状态
815
- this.pageData.tableLoading = true
816
- // 获取表格数据
817
- getFilterData(data).then(res => {
818
- if (res.code === 0) {
819
- this.pageData.paging.total = res.data.total
820
- this.pageData.commonTableData = res.data.records
821
- // this.$message.success('查询成功!')
822
- } else {
823
- this.$message.error('查询失败,请稍后重试')
824
- }
825
- // 解除表格加载状态
826
- this.pageData.tableLoading = false
827
- }).catch(() => {
828
- this.$message.error('查询失败,请稍后重试')
829
- // 解除表格加载状态
830
- this.pageData.tableLoading = false
831
- })
832
-
833
- // 获取表格合计
834
- getFilterDataSum(data).then(res => {
835
- if (res.code === 0) {
836
- const totalData = ['合计']
837
- const data = res.data
838
- for (const key in data) {
839
- const index = this.pageData.commonTableLayout.findIndex(d => d.fieldName === key)
840
- totalData[index + 1] = data[key]
841
- }
842
- this.pageData.totalData = totalData
843
- }
844
- })
845
- },
846
-
847
- // 子组件触发-快捷过滤
848
- quickSearch () {
849
- const arr = []
850
- for (const key in this.pageData.quickFilterData) {
851
- if (key.indexOf('__') !== -1 && key.indexOf('Visible') < 0 && key.indexOf('Checked') < 0 && key.indexOf('CheckedList') < 0 && key.indexOf('CheckedList_Bak') < 0 && key.indexOf('Checked_True') < 0) {
852
- // 存在需要筛选的字段
853
- if (this.pageData.quickFilterData[key + 'Checked_True'] && this.pageData.quickFilterData[key + 'Checked_True'].length > 0) {
854
- arr.push({
855
- key: key,
856
- values: this.pageData.quickFilterData[key + 'Checked_True'].filter(item => { return item !== '全选' })
857
- })
858
- }
859
- }
860
- }
861
- const filterArrBak = JSON.parse(JSON.stringify(this.pageData.quickFilterData.filterArr))
862
- filterArrBak.forEach(item => {
863
- if (item.tableName === this.pageData.headName) {
864
- item.name = 'head__' + item.name
865
- } else {
866
- item.name = 'entity__' + item.name
867
- }
868
- })
869
- arr.forEach(item => {
870
- const index = filterArrBak.findIndex(d => d.name === item.key)
871
- if (index !== -1) {
872
- item.id = this.pageData.quickFilterData.filterArr[index].id
873
- }
874
- })
875
- const data = {
876
- filterType: 0, // 为0代表快捷过滤,为1代表高级过滤
877
- conditionValues: arr,
878
- pageAndTableInfo: {
879
- existEntity: this.pageData.entityName.length !== 0,
880
- headName: this.pageData.headName,
881
- pageNum: this.pageData.paging.current,
882
- pageSize: this.pageData.paging.size,
883
- tableId: this.pageData.tableId
884
- },
885
- roleIds: ['1'],
886
- sorts: [
887
- {
888
- fieldName: 'create_time',
889
- sortType: 1,
890
- tableName: this.pageData.headName
891
- }
892
- ]
893
- }
894
- if (this.limitShow === 1) {
895
- data.examineFlag = 1
896
- }
897
- // 如果存在表体,传参需多传一个表体字段
898
- if (this.pageData.entityName.length > 0) {
899
- data.pageAndTableInfo.oneEntityName = this.pageData.activeEntity
900
- }
901
- this.pageData.advancedOrQuickFiltering = data
902
- // 获取表格数据与合计信息
903
- this.getTableDataAndSumByType(data)
904
- },
905
-
906
- // 高级过滤重置条件(子组件触发)
907
- moreConditionClear () {
908
- this.pageData.moreConditionFilterData.leftBracket.value = ['(']
909
- this.pageData.moreConditionFilterData.name.value = ['']
910
- this.pageData.moreConditionFilterData.condition.value = ['']
911
- this.pageData.moreConditionFilterData.value = ['']
912
- this.pageData.moreConditionFilterData.type = ['']
913
- this.pageData.moreConditionFilterData.rightBracket.value = [')']
914
- // this.$message.success('重置成功!')
915
- },
916
-
917
- // 高级筛选-多行筛选新增筛选行(子组件触发)
918
- addMultipleLine () {
919
- this.pageData.moreConditionFilterData.leftBracket.value.push('(')
920
- this.pageData.moreConditionFilterData.name.value.push('')
921
- this.pageData.moreConditionFilterData.condition.value.push('')
922
- this.pageData.moreConditionFilterData.value.push('')
923
- this.pageData.moreConditionFilterData.type.push('')
924
- this.pageData.moreConditionFilterData.rightBracket.value.push(')')
925
- this.pageData.moreConditionFilterData.relatedCondition.value.push('and')
926
- },
927
-
928
- // 高级筛选-多行筛选时除去当前行(子组件触发)
929
- removeMultipleLine (index) {
930
- this.pageData.moreConditionFilterData.leftBracket.value.splice(index, 1)
931
- this.pageData.moreConditionFilterData.name.value.splice(index, 1)
932
- this.pageData.moreConditionFilterData.condition.value.splice(index, 1)
933
- this.pageData.moreConditionFilterData.value.splice(index, 1)
934
- this.pageData.moreConditionFilterData.type.splice(index, 1)
935
- this.pageData.moreConditionFilterData.rightBracket.value.splice(index, 1)
936
- this.pageData.moreConditionFilterData.relatedCondition.value.splice(index, 1)
937
- },
938
-
939
- // 快捷过滤-高级过滤切换
940
- changeIsQuickFilter (isQuickFilter) {
941
- this.pageData.isQuickFilter = !isQuickFilter
942
- if (this.pageData.isQuickFilter) {
943
- // this.$message.success('已切换为快捷过滤!')
944
- } else {
945
- // this.$message.success('已切换为高级过滤!')
946
- }
947
- },
948
-
949
- // 修改单列宽度属性
950
- renderColumnWidth (value) {
951
-
952
- },
953
- // 表格组件注销前配置数据
954
- tableBeforeDestroy (value) {
955
- this.pageData.destroySettingInfo = value
956
- },
957
- updateFilterKey (value) {
958
- this.pageData.filterKey = value
959
- },
960
-
961
- // 刷新表格数据
962
- refresh () {
963
- // 清空选中数据
964
- this.pageData.tableSelectionData = []
965
- this.$refs.commonTable.refreshTableData()
966
- },
967
-
968
- // 子组件触发,更新表格数据
969
- updateParentTableData (newVal) {
970
- this.pageData.commonTableData = newVal
971
- },
972
-
973
- // 更新分组过滤当前选中值-子组件触发
974
- updateCurrentNodeKey (data) {
975
- this.pageData.groupFilter.currentNodeKey = data
976
- }
977
-
978
- }
979
- }
980
- </script>
981
-
982
- <style lang="less" scoped>
983
- .main-container{
984
- height: 70vh;
985
- margin: 0 1.3541vw 0 1.3541vw;
986
- background: #FFFFFF;
987
- border-radius: 10px;
988
- .strength-data-header{
989
- min-height: 3.2vh;
990
- background: #FFFFFF;
991
- border-radius: 4px 4px 0 0;
992
- padding: 10px 0;
993
- >div:nth-child(1){
994
- display: flex;
995
- justify-content: flex-start;
996
- }
997
- .header-input{
998
- min-width: 2.5vw;
999
- height: 2.222vh;
1000
- opacity: 1;
1001
- background: #0c4c8e;
1002
- border-color: #0c4c8e;
1003
- border-radius: 2px;
1004
- padding: 0;
1005
- margin-right: 0.4166vw;
1006
- ::v-deep span{
1007
- opacity: 1;
1008
- font-size: 0.625vw;
1009
- font-family: Source Han Sans SC, Source Han Sans SC-Regular;
1010
- font-weight: 400;
1011
- color: #ffffff;
1012
- }
1013
- }
1014
- .strength-data-header-middle{
1015
- margin-top: 1vh;
1016
- margin-bottom: 1vh;
1017
- display: flex;
1018
- align-items: center;
1019
- .filter{
1020
- margin-left: auto;
1021
- }
1022
- }
1023
- }
1024
- .strength-data-body {
1025
- height: 60vh;
1026
- ::v-deep .elx-table--body-wrapper{
1027
- max-height: 50vh;
1028
- }
1029
- @media screen and (max-width: 1920px){
1030
- ::v-deep .elx-table--body-wrapper{
1031
- max-height: 46vh;
1032
- }
1033
- }
1034
- }
1035
- ::v-deep .common-table-pagination{
1036
- bottom: 4vh;
1037
- right: 1vw;
1038
- .el-pagination{
1039
- display: flex;
1040
- align-items: center;
1041
- .el-input__inner{
1042
- height: 28px !important;
1043
- border: 1px solid #dcdfe6 !important;
1044
- text-align: center !important;
1045
- }
1046
- .el-pagination__sizes{
1047
- height: 100%;
1048
- display: flex;
1049
- align-items: center;
1050
- }
1051
- .el-pagination__jump{
1052
- height: 100%;
1053
- display: flex;
1054
- align-items: center;
1055
- }
1056
- .el-pager{
1057
- display: flex;
1058
- }
1059
- }
1060
- }
1061
- @media screen and (max-width: 1500px){
1062
- ::v-deep .common-table-pagination{
1063
- bottom: 4vh;
1064
- }
1065
- }
1066
- ::v-deep .el-pagination__editor{
1067
- display: flex;
1068
- align-items: center;
1069
- }
1070
- // 基础资料左侧分组过滤样式修改
1071
- ::v-deep .group-filter-header{
1072
- overflow-y: hidden;
1073
- }
1074
- }
1075
-
1076
- </style>
1077
- <style lang="less" scoped>
1078
- @theme-color: #1890FF;
1079
- @theme-font-color: #FFFFFF;
1080
-
1081
- .strength-data-header {
1082
- /*按钮样式*/
1083
- ::v-deep .el-button--primary {
1084
- background: @theme-color;
1085
- }
1086
- }
1087
- </style>
1
+ <template>
2
+ <div class="main-container">
3
+ <div class="strength-data-header">
4
+ <div>
5
+ <el-button class="header-input" type="primary" @click="refreshMethod">刷新</el-button>
6
+ <!-- <el-button class="header-input" type="primary" @click="addTableData">新增</el-button>
7
+ <el-button class="header-input" type="primary">编辑</el-button>
8
+ <el-button class="header-input" type="primary" @click="refreshMethod">刷新</el-button>
9
+ <el-button class="header-input" type="primary" @click="deleteTableData">删除</el-button>
10
+ <el-button class="header-input" type="primary">导入</el-button>
11
+ <el-button class="header-input" type="primary">导出</el-button>
12
+ <el-button class="header-input" type="primary">审核</el-button>
13
+ <el-button class="header-input" type="primary">反审核</el-button> -->
14
+ <!-- <el-button class="header-input" type="primary" @click="logInfo">打印</el-button>-->
15
+ <slot name="buttonGroup" />
16
+ </div>
17
+ <div class="strength-data-header-middle">
18
+ <!-- <PlanFilter :filter-key="pageData.filterKey" :filter-list="pageData.filterList" @updateFilterKey="updateFilterKey" /> -->
19
+ <div class="filter">
20
+ <ConditionFilter
21
+ :is-quick-filter="pageData.isQuickFilter"
22
+ :quick-filter-data="pageData.quickFilterData"
23
+ :condition-filter-suggest="pageData.conditionFilterSuggest"
24
+ :more-condition-filter-map="pageData.moreConditionFilterMap"
25
+ :more-condition-filter-data="pageData.moreConditionFilterData"
26
+ @quickConditionClear="quickConditionClear"
27
+ @changeIsQuickFilter="changeIsQuickFilter"
28
+ @quickFilterStart="quickFilterStart"
29
+ @updateMoreCondition="updateMoreCondition"
30
+ @changeRotate="changeRotate"
31
+ @moreConditionSearch="moreConditionSearch"
32
+ @moreConditionClear="moreConditionClear"
33
+ @addMultipleLine="addMultipleLine"
34
+ @removeMultipleLine="removeMultipleLine"
35
+ />
36
+ </div>
37
+ </div>
38
+ </div>
39
+ <div class="strength-data-body">
40
+ <template v-if="pageData.commonTableLayout.length > 0">
41
+ <!-- 切换表体 -->
42
+ <el-tabs v-if="pageData.entityName.length > 0" v-model="pageData.activeEntity">
43
+ <el-tab-pane
44
+ v-for="(item,index) in pageData.entityName"
45
+ :key="index"
46
+ :label="item.label"
47
+ :name="item.name"
48
+ />
49
+ </el-tabs>
50
+ <CommonTable
51
+ ref="commonTable"
52
+ v-loading="pageData.tableLoading"
53
+ :double-select="doubleSelect"
54
+ :table-id="pageData.tableId"
55
+ :table-data="pageData.commonTableData"
56
+ :table-layout="pageData.commonTableLayout"
57
+ :paging="pageData.paging"
58
+ :head-name="pageData.headName"
59
+ :total-data="pageData.totalData"
60
+ :single-select="true"
61
+ :quick-filter-data="pageData.quickFilterData"
62
+ :selected-total="pageData.tableSelectionData.length"
63
+ @quickSearch="quickSearch"
64
+ @updateParentTableData="updateParentTableData"
65
+ @renderColumnWidth="renderColumnWidth"
66
+ @tableBeforeDestroy="tableBeforeDestroy"
67
+ @pageChange="pageChange"
68
+ @selectionChange="selectionChange"
69
+ />
70
+ </template>
71
+ <template v-else>
72
+ <div style="display:flex;align-items: center;justify-content: center;height: 100%">
73
+ <div style="width: 100%;height: 15%;text-align: center">
74
+ <SvgIcon icon-class="table-empty" style="width: 100%;height: 100%;" />
75
+ <div>
76
+ 暂无数据
77
+ </div>
78
+ </div>
79
+ </div>
80
+
81
+ </template>
82
+ </div>
83
+ </div>
84
+ </template>
85
+
86
+ <script>
87
+ // 组件
88
+ import ConditionFilter from './condition-filter'
89
+ import CommonTable from './common-table'
90
+ // api
91
+ import {
92
+ getCommonTableSearchCondition,
93
+ getCommonTableHighSearchCondition,
94
+ getFilterData,
95
+ getFilterDataSum,
96
+ deleteCommonTableData,
97
+ findTableGroup,
98
+ getSelectList,
99
+ getFastSearchSuggestionVos,
100
+ getCommonTableLayout2, getDescriptionByTableId
101
+ } from '@/api/table'
102
+
103
+ export default {
104
+ name: 'BasicDataSelector',
105
+ components: {
106
+ ConditionFilter,
107
+ CommonTable
108
+ },
109
+ props: {
110
+ dialogVisible: {
111
+ type: Boolean,
112
+ default: false
113
+ },
114
+ limitShow: {
115
+ type: Number,
116
+ default: 0
117
+ },
118
+ doubleSelect: {
119
+ type: Boolean,
120
+ default: false
121
+ },
122
+ tableId: {
123
+ type: String,
124
+ default: ''
125
+ }
126
+ },
127
+ data () {
128
+ return {
129
+ pageData: {
130
+ configId: null,
131
+ tableId: '',
132
+ filterKey: '缺省方案',
133
+ configList: [], // 过滤方案配置信息
134
+ // 当前采用的过滤方案配置
135
+ currentConfig: {
136
+ name: '',
137
+ sharingScheme: 1,
138
+ user: '',
139
+ fieldList: [],
140
+ userMap: {},
141
+ isSave: true
142
+ }, // 当前页面配置信息
143
+ filterList: [ // 过滤方案数组
144
+ { value: '缺省方案', label: '缺省方案' },
145
+ { value: '方案一', label: '方案一' },
146
+ { value: '方案二', label: '方案二' }
147
+ ],
148
+ changeTableBodyData: {
149
+ tableList: []
150
+ }, // 切换表体按钮展示的数据
151
+ groupFilter: {
152
+ filterText: '',
153
+ currentNodeKey: {},
154
+ treeData: [],
155
+ defaultProps: {
156
+ children: 'children',
157
+ label: 'name'
158
+ },
159
+ dialogTitle: '新增',
160
+ dialogVisible: false,
161
+ form: {},
162
+ allTableField: [] // 表格所有字段
163
+ },
164
+ commonTableData: [], // 表格数据
165
+ commonTableLayout: [], // 表格布局
166
+ totalData: ['合计'], // 表格合计数据
167
+ destroySettingInfo: null,
168
+ isQuickFilter: true, // 快捷过滤标志
169
+ quickFilterData: {},
170
+ rotate: true, // 表示默认高级过滤为单行,反之则为多行
171
+ moreConditionFilterMap: new Map(),
172
+ moreConditionFilterData: { // 高级过滤考虑到多层条件过滤,需将value作为数组,并一一对应
173
+ name: { arr: [], value: [''] }, // 字段数组,value数组初始化一个对象是为了单行高级过滤,以下同
174
+ condition: { arr: [], value: [''] }, // 条件数组
175
+ type: [''],
176
+ value: [''], // 值数组
177
+ leftBracket: { // 左括弧数组
178
+ arr: [
179
+ { label: '(', value: '(' },
180
+ { label: '((', value: '((' },
181
+ { label: '(((', value: '(((' }
182
+ ],
183
+ value: ['(']
184
+ },
185
+ rightBracket: { // 右括弧数组
186
+ arr: [
187
+ { label: ')', value: ')' },
188
+ { label: '))', value: '))' },
189
+ { label: ')))', value: ')))' }
190
+ ],
191
+ value: [')']
192
+ },
193
+ relatedCondition: { // 多条件关联关系数组
194
+ arr: [
195
+ { label: '并且', value: 'and' },
196
+ { label: '或者', value: 'or' }
197
+ ],
198
+ value: []
199
+ }
200
+ },
201
+ moreConditionFilterDataBak: [], // 高级过滤最初数据状态
202
+ headName: '', // 表头名
203
+ entityName: [], // 表体数组
204
+ activeEntity: null, // 显示的表体名
205
+ paging: {
206
+ current: 1, // 页码
207
+ size: 50, // 单页总数
208
+ total: 0
209
+ },
210
+ conditionFilterSuggest: {},
211
+ tableLoading: true, // 表格加载状态
212
+ tableSelectionData: [], // 表格选中数组
213
+ placeholderData: '', // 内容搜索提示
214
+ mulFilterField: [ // 导出功能默认值,不可删除
215
+ {
216
+ fieldName: '',
217
+ fieldType: '',
218
+ originTable: '',
219
+ secondMenuValue: '',
220
+ thirdMenuValue: ''
221
+ }
222
+ ]
223
+ },
224
+ refreshMethod: null, // 刷新防抖
225
+ DetermineWhetherTheTableidTasChanged: false// 判断传来的tableId是否与之前的tableId相同
226
+ }
227
+ },
228
+ computed: {
229
+
230
+ },
231
+ watch: {
232
+ // 监听高级过滤字段是否重复
233
+ 'pageData.moreConditionFilterData': {
234
+ handler (newVal) {
235
+ const arr = newVal.name.value
236
+ const conditionArr = newVal.condition.value
237
+ const valueArr = newVal.value
238
+ const rep = []
239
+ arr.forEach((item, index) => {
240
+ if (arr.indexOf(item) !== index && item !== '') {
241
+ const obj = {}
242
+ obj.key = index
243
+ obj.value = item
244
+ rep.push(obj)
245
+ }
246
+ })
247
+ if (rep.length > 0) {
248
+ this.$message.warning('字段重复,请重新选择!')
249
+ rep.forEach((item, index) => {
250
+ arr[item.key] = ''
251
+ conditionArr[item.key] = ''
252
+ valueArr[item.key] = ''
253
+ })
254
+ }
255
+ },
256
+ deep: true
257
+ },
258
+ tableId: {
259
+ handler (newVal, oldVal) {
260
+ if (oldVal !== newVal && newVal) {
261
+ this.DetermineWhetherTheTableidTasChanged = true
262
+ this.pageData.tableId = newVal
263
+ this.initTable()
264
+ }
265
+ },
266
+ immediate: true
267
+ },
268
+ dialogVisible (newVal) {
269
+ if (!this.DetermineWhetherTheTableidTasChanged) {
270
+ return
271
+ }
272
+ this.pageData.commonTableData = []
273
+ this.judge(newVal)
274
+ }
275
+ },
276
+ created () {
277
+ // 定义防抖方法
278
+ this.refreshMethod = this.utils.debounce(this.refresh)
279
+ this.pageData.tableId = this.tableId
280
+ this.initTable()
281
+ },
282
+ methods: {
283
+ // 判断tableId和dialogVisible是否为true --- 结算需要
284
+ judge (newVal) {
285
+ if (newVal && this.DetermineWhetherTheTableidTasChanged) {
286
+ this.initTable()
287
+ }
288
+ },
289
+ logInfo () {
290
+
291
+ },
292
+
293
+ // 新增
294
+ addTableData () {
295
+ const randomNum = Math.floor(Math.random() * 1000000)
296
+ this.$router.push({
297
+ path: this.$route.path + '/' + randomNum
298
+ })
299
+ },
300
+
301
+ // 删除
302
+ deleteTableData () {
303
+ if (this.pageData.tableSelectionData.length === 0) {
304
+ this.$message.warning('请先选择要删除的数据!')
305
+ return
306
+ }
307
+ const ids = []
308
+ this.pageData.tableSelectionData.forEach((item, index) => {
309
+ if (ids.indexOf(item.head__id) === -1) {
310
+ ids.push(item.head__id)
311
+ }
312
+ })
313
+ const data = {
314
+ identification: this.pageData.headName,
315
+ ids: ids,
316
+ onlyDelEntity: false,
317
+ tableId: this.pageData.tableId
318
+ }
319
+ deleteCommonTableData(data).then(res => {
320
+ if (res.code === 0) {
321
+ this.$message.success('删除成功!')
322
+ this.refresh()
323
+ }
324
+ })
325
+ },
326
+
327
+ selectionChange (value) {
328
+ if (this.doubleSelect) {
329
+ this.pageData.tableSelectionData = value
330
+ this.$emit('rowSelect', value)
331
+ return
332
+ }
333
+ this.pageData.tableSelectionData = value
334
+ this.$emit('rowSelect', value)
335
+ // this.$emit('rowSelect', value[0])
336
+ },
337
+
338
+ // 初始化分组
339
+ initGroupFilter () {
340
+ const data = {
341
+ tableId: this.pageData.tableId
342
+ }
343
+
344
+ // 获取表格分组过滤数据
345
+ findTableGroup(data).then(res => {
346
+ if (res.code === 0) {
347
+ this.pageData.groupFilter.treeData = res.data
348
+ }
349
+ })
350
+ },
351
+
352
+ async initTable () {
353
+ const data = {
354
+ tableId: this.pageData.tableId
355
+ }
356
+ // this.getPageConfig()
357
+
358
+ // 获取切换表体的配置页面
359
+ await getSelectList(data).then(res => {
360
+ this.pageData.changeTableBodyData.headName = res.data.headName
361
+ if (res.data.entityName.length > 0) {
362
+ // this.pageData.activeEntity = res.data.entityName[0]
363
+ res.data.entityName.forEach((e, index) => {
364
+ this.pageData.changeTableBodyData.tableList.push({
365
+ value: res.data.entityName[index],
366
+ name: res.data.entityChineseName[index]
367
+ })
368
+ })
369
+ this.pageData.activeEntity = this.pageData.changeTableBodyData.tableList[0].value
370
+ }
371
+ this.pageData.headName = res.data.headName
372
+ })
373
+ // 获取快捷过滤字段信息
374
+ await new Promise(resolve => {
375
+ getCommonTableSearchCondition(data).then(res => {
376
+ if (res.code === 0) {
377
+ this.pageData.quickFilterData.filterArr = res.data
378
+ // this.pageData.quickFilterData.filterArr.forEach((item, index) => {
379
+ // this.$set(this.pageData.quickFilterData, item.id, '')
380
+ // })
381
+ resolve()
382
+ } else {
383
+ this.$message.error('获取快捷过滤字段信息失败,请稍后重试!')
384
+ }
385
+ })
386
+ }).catch(() => {
387
+ this.$message.error('获取快捷过滤字段信息失败,请稍后重试!')
388
+ })
389
+ this.changeTableBody()
390
+
391
+ // 获取快捷过滤输入框搜索建议
392
+ if (this.pageData.quickFilterData.filterArr && this.pageData.quickFilterData.filterArr.length > 0) {
393
+ const data = {
394
+ fastSearchSuggestQueryDtos: []
395
+ }
396
+ this.pageData.quickFilterData.filterArr.forEach((item, index) => {
397
+ const obj = {
398
+ columnName: item.name,
399
+ tableName: item.tableName
400
+ }
401
+ data.fastSearchSuggestQueryDtos.push(obj)
402
+ })
403
+ getFastSearchSuggestionVos(data).then(res => {
404
+ if (res.code === 0) {
405
+ const data = res.data
406
+ data.forEach((item, index) => {
407
+ // 区分表头和表体字段
408
+ let headText = 'head__'
409
+ const findIndex = this.pageData.quickFilterData.filterArr.findIndex(d => d.name === item.columnName && d.tableName === item.tableName)
410
+ if (findIndex !== -1) {
411
+ if (item.tableName !== this.pageData.headName) {
412
+ // 表体字段
413
+ headText = 'entity__'
414
+ }
415
+ }
416
+ // 设置输入框初始值
417
+ this.$set(this.pageData.quickFilterData, headText + item.columnName, '')
418
+ // 设置备份数组
419
+ this.pageData.quickFilterData[headText + item.columnName + 'CheckedList_Bak'] = item.suggestions
420
+ // 搜索建议实时数组
421
+ this.pageData.quickFilterData[headText + item.columnName + 'CheckedList'] = item.suggestions
422
+ // 默认全选
423
+ this.$set(this.pageData.quickFilterData, headText + item.columnName + 'Checked', [...item.suggestions, '全选'])
424
+ // 用户选中值初始化(在表头点击确认才可生效)
425
+ this.$set(this.pageData.quickFilterData, headText + item.columnName + 'Checked_True', [])
426
+ })
427
+ }
428
+ })
429
+ }
430
+
431
+ const data2 = {
432
+ filterType: 0, // 为0代表快捷过滤,为1代表高级过滤
433
+ conditionValues: [],
434
+ pageAndTableInfo: {
435
+ existEntity: this.pageData.entityName.length !== 0,
436
+ headName: this.pageData.headName,
437
+ pageNum: this.pageData.paging.current,
438
+ pageSize: this.pageData.paging.size,
439
+ tableId: this.pageData.tableId
440
+ },
441
+ roleIds: ['1']
442
+ }
443
+
444
+ // 如果存在表体,传参需多传一个表体字段
445
+ if (this.pageData.entityName.length > 0) {
446
+ data2.pageAndTableInfo.oneEntityName = this.pageData.activeEntity
447
+ }
448
+
449
+ // 获取表格数据与合计信息
450
+
451
+ // this.getTableDataAndSumByType(data2)
452
+
453
+ // 获取全内容搜索框
454
+ this.getDescriptionByTableIdData()
455
+
456
+ // 获取表格分组过滤数据
457
+ // this.initGroupFilter()
458
+ },
459
+
460
+ async getPageConfig () {
461
+ // const data = {
462
+ // filterType: 1,
463
+ // mulFilterField: [
464
+ // {
465
+ // fieldName: 'user_id',
466
+ // fieldType: 'varchar(100)',
467
+ // originTable: 'u_crud_filter_plan',
468
+ // secondMenuValue: 'equal',
469
+ // thirdMenuValue: this.userId
470
+ // },
471
+ // {
472
+ // fieldName: 'table_id',
473
+ // fieldType: 'varchar(100)',
474
+ // originTable: 'u_crud_filter_plan',
475
+ // secondMenuValue: 'equal',
476
+ // thirdMenuValue: this.pageData.tableId
477
+ // }
478
+ // ],
479
+ // pageAndTableInfo: {
480
+ // existEntity: false,
481
+ // headName: 'u_crud_filter_plan',
482
+ // pageNum: 1,
483
+ // pageSize: 1000,
484
+ // tableId: '1621411430682',
485
+ // oneEntityName: 'u_crud_filter_plan_entry'
486
+ // },
487
+ // rule: '(0)and(1)',
488
+ // roleIds: [
489
+ // '1'
490
+ // ],
491
+ // sorts: [
492
+ // {
493
+ // fieldName: 'default_plan',
494
+ // sortType: 0,
495
+ // tableName: 'u_crud_filter_plan'
496
+ // }
497
+ // ]
498
+ // }
499
+ // const res = await getFilterData(data)
500
+ // if (res.code !== 0) {
501
+ // return this.$message.error(res.msg)
502
+ // }
503
+ // const planList = res.data.records
504
+ // this.pageData.filterList = []
505
+ // planList.forEach(element => {
506
+ // this.pageData.filterList.push({
507
+ // value: element.head__name,
508
+ // label: element.head__name,
509
+ // id: element.head__id,
510
+ // code: element.head__code
511
+ // })
512
+ // this.pageData.configList[element.head__name] = {
513
+ // mulFilterField: element.head__condition_json,
514
+ // commonTableLayout: element.head__field_attr
515
+ // }
516
+ // })
517
+ },
518
+
519
+ // 获取全内容搜索框
520
+ getDescriptionByTableIdData () {
521
+ this.pageData.placeholderData = ''
522
+ const data = {
523
+ tableId: this.pageData.tableId
524
+ }
525
+ getDescriptionByTableId(data).then(res => {
526
+ if (res.code === 0) {
527
+ this.pageData.placeholderData = res.data
528
+ } else {
529
+ this.$message.error('系统维护中~请稍后再试~')
530
+ }
531
+ }).catch(() => {
532
+ this.$message.error('系统维护中~请稍后再试~')
533
+ })
534
+ },
535
+
536
+ // 切换表体,及初始化表体方法
537
+ async changeTableBody (value) {
538
+ if (value === this.pageData.activeEntity) {
539
+ return
540
+ }
541
+ const data = {
542
+ existEntity: false,
543
+ headName: this.pageData.headName,
544
+ oneEntityName: this.pageData.activeEntity,
545
+ tableId: this.pageData.tableId
546
+ }
547
+
548
+ if (value) {
549
+ data.oneEntityName = value
550
+ this.pageData.activeEntity = value
551
+ }
552
+ (this.pageData.activeEntity !== null && this.pageData.activeEntity !== 'nothing') ? data.existEntity = true : data.existEntity = false
553
+
554
+ // 获取表格的表头字段信息
555
+ await getCommonTableLayout2(data).then(res => {
556
+ if (res.code === 0) {
557
+ const data = res.data
558
+ data.forEach((item, index) => {
559
+ item.align = 'center'
560
+ item.width = '100' // 切换
561
+ item.fixed = ''
562
+ item.hiddenFlag = false
563
+ item.sortTable = false
564
+ item.isQuick = false
565
+ // 添加表头表体字段标识
566
+ if (item.originTableName === this.pageData.headName) {
567
+ item.fieldName = 'head__' + item.fieldName
568
+ } else {
569
+ item.fieldName = 'entity__' + item.fieldName
570
+ }
571
+ })
572
+ // 快捷过滤字段添加标识
573
+ if (this.pageData.quickFilterData.filterArr && this.pageData.quickFilterData.filterArr.length > 0) {
574
+ this.pageData.quickFilterData.filterArr.forEach((item, index) => {
575
+ let fieldValue = ''
576
+ if (item.tableName === this.pageData.headName) {
577
+ fieldValue = 'head__' + item.name
578
+ } else {
579
+ fieldValue = 'entity__' + item.name
580
+ }
581
+
582
+ const findIndex = data.findIndex(d => d.fieldName === fieldValue)
583
+ if (findIndex !== -1) {
584
+ data[findIndex].isQuick = true
585
+ }
586
+ })
587
+ }
588
+ this.pageData.commonTableLayout = data
589
+ } else {
590
+ this.$message.error('获取或切换单据体失败')
591
+ }
592
+ })
593
+
594
+ let isClearFilterData = false
595
+ if (value) {
596
+ isClearFilterData = true
597
+ }
598
+
599
+ this.moreConditionSearch(isClearFilterData)
600
+ this.searchCondition()
601
+ },
602
+
603
+ // 查询高级过滤下拉框列表
604
+ searchCondition () {
605
+ const data = {
606
+ existEntity: false,
607
+ headName: this.pageData.headName,
608
+ oneEntityName: this.pageData.activeEntity,
609
+ tableId: this.pageData.tableId
610
+ }
611
+ this.pageData.activeEntity !== null && this.pageData.activeEntity !== 'nothing' ? data.existEntity = true : data.existEntity = false
612
+
613
+ getCommonTableHighSearchCondition(data).then(res => {
614
+ if (res.code === 0) {
615
+ const data = res.data
616
+ // 存储备份数据,以备与后台交互数据
617
+ this.pageData.moreConditionFilterDataBak = data
618
+ this.pageData.moreConditionFilterData.name.arr = []
619
+ data.forEach((item, index) => {
620
+ // 设置高级过滤字段数组
621
+ this.pageData.moreConditionFilterData.name.arr.push({ label: item.title, value: item.fieldName, type: item.fieldType })
622
+ const arr = []
623
+ for (const key in item.secondLevelMenu) {
624
+ arr.push({ value: key, label: item.secondLevelMenu[key] })
625
+ }
626
+ // 设置字段对应的条件数组,在字段改变时,修改对应的条件数组
627
+
628
+ this.pageData.moreConditionFilterMap.set(item.fieldName, arr)
629
+ })
630
+ }
631
+ })
632
+ },
633
+
634
+ // 监听分页数据改变
635
+ pageChange () {
636
+ // 如果是快捷过滤
637
+ if (this.pageData.isQuickFilter) {
638
+ // this.quickFilterStart()
639
+ this.quickSearch()
640
+ } else { // 如果是高级过滤
641
+ this.moreConditionSearch()
642
+ }
643
+ },
644
+
645
+ // 快捷过滤
646
+ quickFilterStart () {
647
+ const arr = []
648
+ this.pageData.quickFilterData.filterArr.forEach((item, index) => {
649
+ if (this.pageData.quickFilterData[item.id] !== null && this.pageData.quickFilterData[item.id] !== '') {
650
+ arr.push({ id: item.id, value: this.pageData.quickFilterData[item.id] })
651
+ }
652
+ })
653
+ const data = {
654
+ filterType: 0, // 为0代表快捷过滤,为1代表高级过滤
655
+ conditionValues: arr,
656
+ pageAndTableInfo: {
657
+ existEntity: this.pageData.entityName.length !== 0,
658
+ headName: this.pageData.headName,
659
+ pageNum: this.pageData.paging.current,
660
+ pageSize: this.pageData.paging.size,
661
+ tableId: this.pageData.tableId
662
+ },
663
+ roleIds: ['1']
664
+ }
665
+ // 如果存在表体,传参需多传一个表体字段
666
+ if (this.pageData.entityName.length > 0) {
667
+ data.pageAndTableInfo.oneEntityName = this.pageData.activeEntity
668
+ }
669
+ if (this.limitShow === 1) {
670
+ data.examineFlag = 1
671
+ }
672
+ // 获取表格数据与合计信息
673
+ this.getTableDataAndSumByType(data)
674
+ },
675
+
676
+ // 快捷过滤重置
677
+ quickConditionClear () {
678
+ this.pageData.quickFilterData.filterArr.forEach((item, index) => {
679
+ this.pageData.quickFilterData[item.id] = ''
680
+ })
681
+ // this.$message.success('重置成功!')
682
+ },
683
+
684
+ // 高级过滤字段更新时,修改条件数组(子组件触发)
685
+ updateMoreCondition (val) {
686
+ // 获取字段类型
687
+ const typeObj = this.pageData.moreConditionFilterData.name.arr.find(d => d.value === val)
688
+ if (typeObj === undefined) {
689
+ this.$message.error('未找到字段类型,刷新重试')
690
+ return
691
+ }
692
+ const type = typeObj.type
693
+ // 更新value类型
694
+ const index = this.pageData.moreConditionFilterData.name.value.findIndex(d => d === val)
695
+ this.pageData.moreConditionFilterData.type[index] = type === 'datetime' ? 'datetime' : 'input'
696
+ // 更新条件数组
697
+ this.pageData.moreConditionFilterData.condition.arr[index] = this.pageData.moreConditionFilterMap.get(val)
698
+ // 更新条件值
699
+ // (如果varchar类型的条件数组存在“包含”,条件变为“包含”,
700
+ // 如果int类型的条件数组存在“等于”,条件变为“等于”,
701
+ // 如果datetime类型的条件数组存在“今天”,条件变为“今天”)
702
+ if (type.indexOf('varchar') !== -1) {
703
+ const includeObj = this.pageData.moreConditionFilterData.condition.arr[index].find(d => d.label === '包含')
704
+ this.pageData.moreConditionFilterData.condition.value[index] = includeObj ? includeObj.value : ''
705
+ } else if (type.indexOf('int') !== -1) {
706
+ const includeObj = this.pageData.moreConditionFilterData.condition.arr[index].find(d => d.label === '等于')
707
+ this.pageData.moreConditionFilterData.condition.value[index] = includeObj ? includeObj.value : ''
708
+ } else if (type.indexOf('datetime') !== -1) {
709
+ const includeObj = this.pageData.moreConditionFilterData.condition.arr[index].find(d => d.label === '今天')
710
+ this.pageData.moreConditionFilterData.condition.value[index] = includeObj ? includeObj.value : ''
711
+ }
712
+ // 更新value
713
+ // 判断是否字段重复,重复先不清空value值
714
+ const length = this.pageData.moreConditionFilterData.name.value.filter(d => d === val).length
715
+ if (length === 1) {
716
+ this.pageData.moreConditionFilterData.value[index] = ''
717
+ }
718
+ },
719
+
720
+ // 高级过滤的单行模式与多行模式切换(子组件触发)
721
+ changeRotate (value) {
722
+ this.pageData.rotate = value
723
+ },
724
+
725
+ // 校验高级过滤条件是否填写完整
726
+ checkMoreCondition () {
727
+ // 校验
728
+ let flag = false
729
+ this.pageData.moreConditionFilterData.name.value.forEach((item, index) => {
730
+ // 如果是单行,不需要判断左右括号,多行模式则需要
731
+ if (this.pageData.moreConditionFilterData.name.value.length === 1) {
732
+ // 如果选中了字段,代表需要过滤条件
733
+ if (this.pageData.moreConditionFilterData.name.value[0] !== '') {
734
+ if (!this.pageData.moreConditionFilterData.condition.value[index] ||
735
+ !this.pageData.moreConditionFilterData.value[index]) {
736
+ flag = true
737
+ }
738
+ }
739
+ } else {
740
+ if (!this.pageData.moreConditionFilterData.leftBracket.value[index] ||
741
+ !this.pageData.moreConditionFilterData.name.value[index] ||
742
+ !this.pageData.moreConditionFilterData.condition.value[index] ||
743
+ !this.pageData.moreConditionFilterData.value[index] ||
744
+ !this.pageData.moreConditionFilterData.rightBracket.value[index]) {
745
+ flag = true
746
+ }
747
+ }
748
+ })
749
+ return flag
750
+ },
751
+
752
+ // 高级过滤搜索(子组件触发)
753
+ moreConditionSearch () {
754
+ // 校验
755
+ // if (this.checkMoreCondition()) {
756
+ // this.$message.error('请完整填写!')
757
+ // return false
758
+ // }
759
+ const arr = []
760
+ this.pageData.moreConditionFilterData.name.value.forEach((item, index) => {
761
+ const filterField = this.pageData.moreConditionFilterDataBak.find(d => d.fieldName === item)
762
+ if (filterField !== undefined) {
763
+ const obj = {
764
+ fieldName: filterField.fieldName,
765
+ fieldType: filterField.fieldType,
766
+ originTable: filterField.originTable,
767
+ secondMenuValue: this.pageData.moreConditionFilterData.condition.value[index],
768
+ thirdMenuValue: this.pageData.moreConditionFilterData.value[index]
769
+ }
770
+ arr.push(obj)
771
+ }
772
+ })
773
+ let rule = ''
774
+ this.pageData.moreConditionFilterData.name.value.forEach((item, index) => {
775
+ rule += this.pageData.moreConditionFilterData.leftBracket.value[index] +
776
+ index + this.pageData.moreConditionFilterData.rightBracket.value[index]
777
+ // 不添加最后一行的关系数据
778
+ if (this.pageData.moreConditionFilterData.relatedCondition.value[index] !== undefined) {
779
+ rule += this.pageData.moreConditionFilterData.relatedCondition.value[index]
780
+ }
781
+ })
782
+ const data = {
783
+ filterType: 1,
784
+ mulFilterField: arr,
785
+ pageAndTableInfo: {
786
+ existEntity: this.pageData.entityName.length !== 0,
787
+ headName: this.pageData.headName,
788
+ pageNum: this.pageData.paging.current,
789
+ pageSize: this.pageData.paging.size,
790
+ tableId: this.pageData.tableId
791
+ },
792
+ rule: arr.length === 0 ? '' : arr.length === 1 ? '(0)' : rule,
793
+ roleIds: ['1'],
794
+ sorts: [
795
+ {
796
+ fieldName: 'create_time',
797
+ sortType: 1,
798
+ tableName: this.pageData.headName
799
+ }
800
+ ]
801
+ }
802
+ // 如果存在表体,传参需多传一个表体字段
803
+ if (this.pageData.entityName.length > 0) {
804
+ data.pageAndTableInfo.oneEntityName = this.pageData.activeEntity
805
+ }
806
+ if (this.limitShow === 1) {
807
+ data.examineFlag = 1
808
+ }
809
+ // 获取表格数据与合计信息
810
+ this.getTableDataAndSumByType(data)
811
+ },
812
+
813
+ getTableDataAndSumByType (data) {
814
+ // 表格展示加载状态
815
+ this.pageData.tableLoading = true
816
+ // 获取表格数据
817
+ getFilterData(data).then(res => {
818
+ if (res.code === 0) {
819
+ this.pageData.paging.total = res.data.total
820
+ this.pageData.commonTableData = res.data.records
821
+ // this.$message.success('查询成功!')
822
+ } else {
823
+ this.$message.error('查询失败,请稍后重试')
824
+ }
825
+ // 解除表格加载状态
826
+ this.pageData.tableLoading = false
827
+ }).catch(() => {
828
+ this.$message.error('查询失败,请稍后重试')
829
+ // 解除表格加载状态
830
+ this.pageData.tableLoading = false
831
+ })
832
+
833
+ // 获取表格合计
834
+ getFilterDataSum(data).then(res => {
835
+ if (res.code === 0) {
836
+ const totalData = ['合计']
837
+ const data = res.data
838
+ for (const key in data) {
839
+ const index = this.pageData.commonTableLayout.findIndex(d => d.fieldName === key)
840
+ totalData[index + 1] = data[key]
841
+ }
842
+ this.pageData.totalData = totalData
843
+ }
844
+ })
845
+ },
846
+
847
+ // 子组件触发-快捷过滤
848
+ quickSearch () {
849
+ const arr = []
850
+ for (const key in this.pageData.quickFilterData) {
851
+ if (key.indexOf('__') !== -1 && key.indexOf('Visible') < 0 && key.indexOf('Checked') < 0 && key.indexOf('CheckedList') < 0 && key.indexOf('CheckedList_Bak') < 0 && key.indexOf('Checked_True') < 0) {
852
+ // 存在需要筛选的字段
853
+ if (this.pageData.quickFilterData[key + 'Checked_True'] && this.pageData.quickFilterData[key + 'Checked_True'].length > 0) {
854
+ arr.push({
855
+ key: key,
856
+ values: this.pageData.quickFilterData[key + 'Checked_True'].filter(item => { return item !== '全选' })
857
+ })
858
+ }
859
+ }
860
+ }
861
+ const filterArrBak = JSON.parse(JSON.stringify(this.pageData.quickFilterData.filterArr))
862
+ filterArrBak.forEach(item => {
863
+ if (item.tableName === this.pageData.headName) {
864
+ item.name = 'head__' + item.name
865
+ } else {
866
+ item.name = 'entity__' + item.name
867
+ }
868
+ })
869
+ arr.forEach(item => {
870
+ const index = filterArrBak.findIndex(d => d.name === item.key)
871
+ if (index !== -1) {
872
+ item.id = this.pageData.quickFilterData.filterArr[index].id
873
+ }
874
+ })
875
+ const data = {
876
+ filterType: 0, // 为0代表快捷过滤,为1代表高级过滤
877
+ conditionValues: arr,
878
+ pageAndTableInfo: {
879
+ existEntity: this.pageData.entityName.length !== 0,
880
+ headName: this.pageData.headName,
881
+ pageNum: this.pageData.paging.current,
882
+ pageSize: this.pageData.paging.size,
883
+ tableId: this.pageData.tableId
884
+ },
885
+ roleIds: ['1'],
886
+ sorts: [
887
+ {
888
+ fieldName: 'create_time',
889
+ sortType: 1,
890
+ tableName: this.pageData.headName
891
+ }
892
+ ]
893
+ }
894
+ if (this.limitShow === 1) {
895
+ data.examineFlag = 1
896
+ }
897
+ // 如果存在表体,传参需多传一个表体字段
898
+ if (this.pageData.entityName.length > 0) {
899
+ data.pageAndTableInfo.oneEntityName = this.pageData.activeEntity
900
+ }
901
+ this.pageData.advancedOrQuickFiltering = data
902
+ // 获取表格数据与合计信息
903
+ this.getTableDataAndSumByType(data)
904
+ },
905
+
906
+ // 高级过滤重置条件(子组件触发)
907
+ moreConditionClear () {
908
+ this.pageData.moreConditionFilterData.leftBracket.value = ['(']
909
+ this.pageData.moreConditionFilterData.name.value = ['']
910
+ this.pageData.moreConditionFilterData.condition.value = ['']
911
+ this.pageData.moreConditionFilterData.value = ['']
912
+ this.pageData.moreConditionFilterData.type = ['']
913
+ this.pageData.moreConditionFilterData.rightBracket.value = [')']
914
+ // this.$message.success('重置成功!')
915
+ },
916
+
917
+ // 高级筛选-多行筛选新增筛选行(子组件触发)
918
+ addMultipleLine () {
919
+ this.pageData.moreConditionFilterData.leftBracket.value.push('(')
920
+ this.pageData.moreConditionFilterData.name.value.push('')
921
+ this.pageData.moreConditionFilterData.condition.value.push('')
922
+ this.pageData.moreConditionFilterData.value.push('')
923
+ this.pageData.moreConditionFilterData.type.push('')
924
+ this.pageData.moreConditionFilterData.rightBracket.value.push(')')
925
+ this.pageData.moreConditionFilterData.relatedCondition.value.push('and')
926
+ },
927
+
928
+ // 高级筛选-多行筛选时除去当前行(子组件触发)
929
+ removeMultipleLine (index) {
930
+ this.pageData.moreConditionFilterData.leftBracket.value.splice(index, 1)
931
+ this.pageData.moreConditionFilterData.name.value.splice(index, 1)
932
+ this.pageData.moreConditionFilterData.condition.value.splice(index, 1)
933
+ this.pageData.moreConditionFilterData.value.splice(index, 1)
934
+ this.pageData.moreConditionFilterData.type.splice(index, 1)
935
+ this.pageData.moreConditionFilterData.rightBracket.value.splice(index, 1)
936
+ this.pageData.moreConditionFilterData.relatedCondition.value.splice(index, 1)
937
+ },
938
+
939
+ // 快捷过滤-高级过滤切换
940
+ changeIsQuickFilter (isQuickFilter) {
941
+ this.pageData.isQuickFilter = !isQuickFilter
942
+ if (this.pageData.isQuickFilter) {
943
+ // this.$message.success('已切换为快捷过滤!')
944
+ } else {
945
+ // this.$message.success('已切换为高级过滤!')
946
+ }
947
+ },
948
+
949
+ // 修改单列宽度属性
950
+ renderColumnWidth (value) {
951
+
952
+ },
953
+ // 表格组件注销前配置数据
954
+ tableBeforeDestroy (value) {
955
+ this.pageData.destroySettingInfo = value
956
+ },
957
+ updateFilterKey (value) {
958
+ this.pageData.filterKey = value
959
+ },
960
+
961
+ // 刷新表格数据
962
+ refresh () {
963
+ // 清空选中数据
964
+ this.pageData.tableSelectionData = []
965
+ this.$refs.commonTable.refreshTableData()
966
+ },
967
+
968
+ // 子组件触发,更新表格数据
969
+ updateParentTableData (newVal) {
970
+ this.pageData.commonTableData = newVal
971
+ },
972
+
973
+ // 更新分组过滤当前选中值-子组件触发
974
+ updateCurrentNodeKey (data) {
975
+ this.pageData.groupFilter.currentNodeKey = data
976
+ }
977
+
978
+ }
979
+ }
980
+ </script>
981
+
982
+ <style lang="less" scoped>
983
+ .main-container{
984
+ height: 70vh;
985
+ margin: 0 1.3541vw 0 1.3541vw;
986
+ background: #FFFFFF;
987
+ border-radius: 10px;
988
+ .strength-data-header{
989
+ min-height: 3.2vh;
990
+ background: #FFFFFF;
991
+ border-radius: 4px 4px 0 0;
992
+ padding: 10px 0;
993
+ >div:nth-child(1){
994
+ display: flex;
995
+ justify-content: flex-start;
996
+ }
997
+ .header-input{
998
+ min-width: 2.5vw;
999
+ height: 2.222vh;
1000
+ opacity: 1;
1001
+ background: #0c4c8e;
1002
+ border-color: #0c4c8e;
1003
+ border-radius: 2px;
1004
+ padding: 0;
1005
+ margin-right: 0.4166vw;
1006
+ ::v-deep span{
1007
+ opacity: 1;
1008
+ font-size: 0.625vw;
1009
+ font-family: Source Han Sans SC, Source Han Sans SC-Regular;
1010
+ font-weight: 400;
1011
+ color: #ffffff;
1012
+ }
1013
+ }
1014
+ .strength-data-header-middle{
1015
+ margin-top: 1vh;
1016
+ margin-bottom: 1vh;
1017
+ display: flex;
1018
+ align-items: center;
1019
+ .filter{
1020
+ margin-left: auto;
1021
+ }
1022
+ }
1023
+ }
1024
+ .strength-data-body {
1025
+ height: 60vh;
1026
+ ::v-deep .elx-table--body-wrapper{
1027
+ max-height: 50vh;
1028
+ }
1029
+ @media screen and (max-width: 1920px){
1030
+ ::v-deep .elx-table--body-wrapper{
1031
+ max-height: 46vh;
1032
+ }
1033
+ }
1034
+ }
1035
+ ::v-deep .common-table-pagination{
1036
+ bottom: 4vh;
1037
+ right: 1vw;
1038
+ .el-pagination{
1039
+ display: flex;
1040
+ align-items: center;
1041
+ .el-input__inner{
1042
+ height: 28px !important;
1043
+ border: 1px solid #dcdfe6 !important;
1044
+ text-align: center !important;
1045
+ }
1046
+ .el-pagination__sizes{
1047
+ height: 100%;
1048
+ display: flex;
1049
+ align-items: center;
1050
+ }
1051
+ .el-pagination__jump{
1052
+ height: 100%;
1053
+ display: flex;
1054
+ align-items: center;
1055
+ }
1056
+ .el-pager{
1057
+ display: flex;
1058
+ }
1059
+ }
1060
+ }
1061
+ @media screen and (max-width: 1500px){
1062
+ ::v-deep .common-table-pagination{
1063
+ bottom: 4vh;
1064
+ }
1065
+ }
1066
+ ::v-deep .el-pagination__editor{
1067
+ display: flex;
1068
+ align-items: center;
1069
+ }
1070
+ // 基础资料左侧分组过滤样式修改
1071
+ ::v-deep .group-filter-header{
1072
+ overflow-y: hidden;
1073
+ }
1074
+ }
1075
+
1076
+ </style>
1077
+ <style lang="less" scoped>
1078
+ @theme-color: #1890FF;
1079
+ @theme-font-color: #FFFFFF;
1080
+
1081
+ .strength-data-header {
1082
+ /*按钮样式*/
1083
+ ::v-deep .el-button--primary {
1084
+ background: @theme-color;
1085
+ }
1086
+ }
1087
+ </style>