three-trees-ui 1.0.79 → 1.0.81

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.
@@ -7,14 +7,9 @@ import { decode } from '@/util/base64'
7
7
  import Vue from 'vue'
8
8
  import $ from 'jquery'
9
9
  import _ from 'lodash'
10
- import moment from 'moment'
11
10
  export default {
12
11
  data() {
13
12
  return {
14
- bindKey: {},
15
- bindValue: {},
16
- defaultQuerys: [],
17
- isInit: true,
18
13
  bpmRunTime: this.$requestConfig.flowUrl,
19
14
  fileList: [],
20
15
  tableData: { selectRows: [], querys: '' },
@@ -82,8 +77,6 @@ export default {
82
77
  pageSize: 30,
83
78
  total: 0,
84
79
  },
85
- lastPage: 1, //上一次输入的分页数、默认为1
86
- total: 0,
87
80
  rows: [],
88
81
  queryParam: {},
89
82
  allSummaryConfig: {},
@@ -91,54 +84,15 @@ export default {
91
84
  summaryTableData: [],
92
85
  needRequestTotal: false, // 需不需要后端统计列表全部数据
93
86
  tableDataTotal: {},
94
- loadingTotal: false, //统计按钮加载中
95
- pageSizeArray: [
96
- {
97
- label: '10条/页',
98
- value: 10,
99
- },
100
- {
101
- label: '20条/页',
102
- value: 20,
103
- },
104
- {
105
- label: '30条/页',
106
- value: 30,
107
- },
108
- {
109
- label: '40条/页',
110
- value: 40,
111
- },
112
- {
113
- label: '50条/页',
114
- value: 50,
115
- },
116
- {
117
- label: '100条/页',
118
- value: 100,
119
- },
120
- {
121
- label: '200条/页',
122
- value: 200,
123
- },
124
- {
125
- label: '300条/页',
126
- value: 300,
127
- },
128
- {
129
- label: '500条/页',
130
- value: 500,
131
- },
132
- ],
133
87
  }
134
88
  },
135
89
  watch: {
136
- formKey: function(newVal) {
90
+ formKey: function (newVal) {
137
91
  if (newVal) {
138
92
  this.init()
139
93
  }
140
94
  },
141
- 'tableData.selectRows': function(newVal) {
95
+ 'tableData.selectRows': function (newVal) {
142
96
  if (newVal.length > 0) {
143
97
  let me_ = this
144
98
  me_.uploadParams.id = []
@@ -206,29 +160,7 @@ export default {
206
160
  deep: true,
207
161
  },
208
162
  },
209
- created() {
210
- if (this.queryView.jsScript) {
211
- // 执行js脚本
212
- this.handleDiyScript(this.queryView.jsScript)
213
- }
214
- },
215
163
  methods: {
216
- handleDiyScript(scriptValue) {
217
- //执行前置脚本内容
218
- const _this = this
219
- // 用户信息
220
- const account = this.$requestConfig.getAccount()
221
- const userId = this.$requestConfig.getUserId()
222
- const userName = this.$requestConfig.getUsername()
223
- const preScript = `const scriptFunction = function(_this, account, userId, userName){
224
- ${scriptValue}
225
- };`
226
- try {
227
- eval(`${preScript}scriptFunction(_this, account, userId, userName);`)
228
- } catch (err) {
229
- this.$message.error(`脚本事件执行错误:${err}`)
230
- }
231
- },
232
164
  handelBindFiledValua() {
233
165
  //数据视图控件
234
166
  let _me = this
@@ -277,7 +209,7 @@ export default {
277
209
  selectList[i].selectValue = value
278
210
 
279
211
  //添加监听
280
- pInst.$watch(path, function(newVal, oldVal) {
212
+ pInst.$watch(path, function (newVal, oldVal) {
281
213
  _.debounce(() => {
282
214
  if (newVal !== oldVal) {
283
215
  _me.queryViewOptions.selectList[i].selectValue = newVal
@@ -421,7 +353,7 @@ export default {
421
353
  this.$router.push(url)
422
354
  },
423
355
 
424
- handleSizeChange: function(size) {
356
+ handleSizeChange: function (size) {
425
357
  //每页下拉显示数据
426
358
  this.pagination.pageSize = size
427
359
  if (this.$refs.queryViewList) {
@@ -430,9 +362,9 @@ export default {
430
362
  this.search()
431
363
  }
432
364
  },
433
- handleCurrentChange: function(currentPage) {
365
+ handleCurrentChange: function (currentPage) {
434
366
  //点击第几页
435
- this.pagination.page = currentPage ? currentPage : this.lastPage
367
+ this.pagination.page = currentPage
436
368
  if (this.$refs.queryViewList) {
437
369
  this.$refs.queryViewList.load()
438
370
  } else {
@@ -440,126 +372,14 @@ export default {
440
372
  }
441
373
  },
442
374
  //回车查询
443
- searchEnterFun: function(e) {
375
+ searchEnterFun: function (e) {
444
376
  let keyCode = window.event ? e.keyCode : e.which
445
377
  if (keyCode == 13) {
446
378
  this.pagination.page = 1
447
379
  this.search()
448
380
  }
449
381
  },
450
- getQueryDataViewOperation(key) {
451
- switch (key) {
452
- case 'EQ':
453
- return 'EQUAL'
454
- case 'NE':
455
- return 'NOT_EQUAL'
456
- case 'LK':
457
- return 'LIKE'
458
- case 'LFK':
459
- return 'LEFT_LIKE'
460
- case 'RHK':
461
- return 'RIGHT_LIKE'
462
- case 'BETWEEN':
463
- return 'BETWEEN'
464
- default:
465
- return 'LIKE'
466
- }
467
- },
468
- async buildDefaultQuerys() {
469
- let querys = []
470
- let conditions = JSON.parse(this.queryView.conditions)
471
- //条件字段默认值判断
472
- for (let i = 0; i < conditions.length; i++) {
473
- let condition = conditions[i]
474
- if (condition.defaultValue) {
475
- let defaultValue = condition.isScriptDefault
476
- ? await this.getScriptDefaultValue(condition.defaultValue)
477
- : condition.defaultValue
478
- if (condition.dataType == 'number') {
479
- defaultValue = parseFloat(defaultValue)
480
- }
481
- this.$set(this.searchForm, condition.fieldName, defaultValue)
482
-
483
- querys.push({
484
- property: condition.fieldName,
485
- value: defaultValue,
486
- group: 'main',
487
- operation: this.getQueryDataViewOperation(condition.operate),
488
- relation: 'AND',
489
- })
490
- }
491
- }
492
- this.defaultQuerys = querys
493
- return querys
494
- },
495
- getScriptDefaultValue(scriptValue) {
496
- return new Promise((resolve) => {
497
- //执行前置脚本内容
498
- const _this = this
499
- // 用户信息
500
- const account = this.$requestConfig.getAccount()
501
- const userId = this.$requestConfig.getUserId()
502
- const userName = this.$requestConfig.getUsername()
503
- const _moment = moment
504
- const preScript = `const scriptFunction = function(_this, account, userId, userName, _moment){
505
- ${scriptValue}
506
- };`
507
- let result = ''
508
- try {
509
- result = eval(
510
- `${preScript}scriptFunction(_this, account, userId, userName, _moment);`
511
- )
512
- if (result && result.then && typeof result.then === 'function') {
513
- result.then(
514
- (t) => {
515
- resolve(t)
516
- },
517
- (fail) => {
518
- //接口返回失败则终止按钮操作,并输出错误信息
519
- resolve('')
520
- }
521
- )
522
- } else {
523
- resolve(result)
524
- }
525
- } catch (err) {
526
- resolve('')
527
- this.$message.error(`查询值默认脚本事件执行错误:${err}`)
528
- }
529
- })
530
- },
531
- validateSearchRequired(querys = []) {
532
- let errorMsg = ''
533
- let conditions = JSON.parse(this.queryView.conditions)
534
- if (conditions && querys) {
535
- conditions.forEach((item) => {
536
- if (item.isRequired) {
537
- let index = querys.findIndex((k) => {
538
- return k.property == item.fieldName
539
- })
540
- if (index == -1) {
541
- errorMsg = `字段【${item.fieldDesc}】为必填查询字段,不能为空!`
542
- }
543
- }
544
- })
545
- }
546
- return errorMsg
547
- },
548
- checkHaveRequired() {
549
- let haveRequired = false
550
- try {
551
- let conditions = JSON.parse(this.queryView.conditions)
552
- if (conditions) {
553
- haveRequired = conditions.some((item) => {
554
- return item.isRequired
555
- })
556
- }
557
- } catch (e) {
558
- console.log(e)
559
- }
560
- return haveRequired
561
- },
562
- async search(param, cb, isSearchBtn, needRequestTotal = false) {
382
+ search(param, cb, isSearchBtn, needRequestTotal = false) {
563
383
  // 不需要请求后端接口统计列表数据
564
384
  this.needRequestTotal = needRequestTotal
565
385
  !param && (param = {})
@@ -567,38 +387,6 @@ export default {
567
387
  const dataTemplateQueryVo = {
568
388
  queryFilter: param,
569
389
  }
570
- //初始化时,把查询字段的默认值加进去
571
- if (this.isInit) {
572
- let querys = await this.buildDefaultQuerys()
573
- dataTemplateQueryVo.queryFilter.querys =
574
- dataTemplateQueryVo.queryFilter.querys || []
575
- dataTemplateQueryVo.queryFilter.querys = dataTemplateQueryVo.queryFilter.querys.concat(
576
- querys
577
- )
578
- }
579
- // 非高级查询时,将默认值带上
580
- if (!isSearchBtn) {
581
- dataTemplateQueryVo.queryFilter.querys =
582
- dataTemplateQueryVo.queryFilter.querys || []
583
- dataTemplateQueryVo.queryFilter.querys = dataTemplateQueryVo.queryFilter.querys.concat(
584
- this.defaultQuerys
585
- )
586
- }
587
- // 检查是否有必填字段
588
- if (this.checkHaveRequired() && this.isInit) {
589
- this.$refs.queryViewList.showAdvancedSearch = true
590
- }
591
- // 查询字段 校验是否必填,如果是必填没数据,需返回提示
592
- let errorMsg = this.validateSearchRequired(
593
- dataTemplateQueryVo.queryFilter.querys
594
- )
595
- if (errorMsg) {
596
- !this.isInit && this.$message.warning(errorMsg)
597
- cb && cb()
598
- this.isInit = false
599
- return
600
- }
601
- this.isInit = false
602
390
  //保存查询参数,用于作为导出的查询参数
603
391
  if (this.queryViewOptions) {
604
392
  //关联查询字段
@@ -615,34 +403,8 @@ export default {
615
403
  alias: this.alias || this.queryView.alias,
616
404
  param: dataTemplateQueryVo,
617
405
  }
618
- // 自定义对话框查询参数修改
619
- if (isSearchBtn) {
620
- obj.param = this.makeCustomDialogParam(obj.param)
621
- }
622
406
  this.getQuerySqlViewByPagination(obj, cb)
623
407
  },
624
- // 高级查询 自定义对话框查询参数修改
625
- makeCustomDialogParam(data) {
626
- //处理绑定字段
627
- this.bindValue = this.searchForm.bindValue || this.bindValue
628
- this.bindKey = this.searchForm.bindKey || this.bindKey
629
- //记录后再删除
630
- delete this.searchForm.bindValue
631
- delete this.searchForm.bindKey
632
- if (data.queryFilter && data.queryFilter.querys) {
633
- data.queryFilter.querys.forEach((k) => {
634
- Object.keys(this.bindKey).forEach((key) => {
635
- if (key === k.property) {
636
- let valueKey = this.bindKey[key]
637
- if (this.bindValue[key] && this.bindValue[key][valueKey]) {
638
- k.value = this.bindValue[key][valueKey]
639
- }
640
- }
641
- })
642
- })
643
- }
644
- return data
645
- },
646
408
  getQuerySqlViewByPagination(param, cb) {
647
409
  if (this.needRequestTotal) {
648
410
  // 调用后端接口更新 tableDataTotal
@@ -657,17 +419,13 @@ export default {
657
419
  })
658
420
  }
659
421
  this.$requestConfig
660
- .getQueryViewDataListWithoutTotal(param)
422
+ .getQueryViewDataList(param)
661
423
  .then((response) => {
662
424
  this.rows = response.rows
663
- // this.pagination.total = response.total
425
+ this.pagination.total = response.total
664
426
  this.pagination.page = response.page
665
427
  this.pagination.pageSize = response.pageSize
666
428
  this.filterOldSummaryValByType('currentPage')
667
- //每次请求后不再统计总数,而是在统计按钮中去统计,当数量统计过一次后,再重新设置到当前页
668
- if (this.total) {
669
- this.$set(this.pagination, 'total', this.total)
670
- }
671
429
  this.summaryTableData.push({
672
430
  project: '当前页汇总',
673
431
  key: 'currentPage',
@@ -687,31 +445,12 @@ export default {
687
445
  cb && cb()
688
446
  })
689
447
  },
690
- getQuerySqlViewByPaginationTotal(param, cb) {
691
- this.loadingTotal = true
692
- this.$requestConfig
693
- .getQueryViewDataListWithTotal(param)
694
- .then((response) => {
695
- this.total = response.value
696
- //每次请求后不再统计总数,而是在统计按钮中去统计,当数量统计过一次后,再重新设置到当前页
697
- if (this.total) {
698
- this.$set(this.pagination, 'total', this.total)
699
- }
700
- this.loadingTotal = false
701
- this.$nextTick(() => {
702
- this.$refs.queryViewList && this.$refs.queryViewList.doLayout()
703
- })
704
- })
705
- .finally(() => {
706
- this.loadingTotal = false
707
- cb && cb()
708
- })
709
- },
710
448
  getQueryFilter() {
711
449
  let operationMap = this.getSearchItems() //查询条件类型
712
450
  // let fieldQueryMap = this.getFieldQuery() //查询条件字段
713
451
  let specialMap = this.getSpecialMap() //获取特殊查询情况(自定义对话框)
714
452
  let querys = [] //查询条件
453
+ let queryFilter = {}
715
454
  let pageBean = { pageBean: this.pagination }
716
455
  let params = {
717
456
  sqlAlias: this.sqlAlias || this.queryView.sqlAlias,
@@ -719,18 +458,8 @@ export default {
719
458
  }
720
459
  params.pagination = pageBean
721
460
  if ($.isEmptyObject(this.searchForm)) {
722
- if (this.$refs.queryViewList && this.$refs.queryViewList.querys) {
723
- querys.push(...this.$refs.queryViewList.querys)
724
- }
725
- params = { pageBean: this.pagination, querys }
726
461
  return params
727
462
  } else {
728
- //处理绑定字段
729
- this.bindValue = this.searchForm.bindValue || this.bindValue
730
- this.bindKey = this.searchForm.bindKey || this.bindKey
731
- //记录后再删除
732
- delete this.searchForm.bindValue
733
- delete this.searchForm.bindKey
734
463
  for (var key in this.searchForm) {
735
464
  if (
736
465
  typeof this.searchForm[key] != 'undefined' &&
@@ -761,12 +490,7 @@ export default {
761
490
  })
762
491
  }
763
492
  }
764
- } else if (
765
- this.searchForm[key] &&
766
- typeof this.searchForm[key] === 'string' &&
767
- this.searchForm[key].includes(',') &&
768
- !specialMap[key]
769
- ) {
493
+ } else if (this.searchForm[key].includes(',') && !specialMap[key]) {
770
494
  let arr = this.searchForm[key].split(',')
771
495
  for (let i = 0; i < arr.length; i++) {
772
496
  if (
@@ -788,20 +512,9 @@ export default {
788
512
  })
789
513
  })
790
514
  } else {
791
- let value = this.searchForm[key]
792
- //在表单列表的查询字段中添加的对话框控件 此处逻辑对应 packages/CustomDialog/src/customDialog.vue:1920行
793
- if (
794
- this.bindValue &&
795
- Object.keys(this.bindValue).length &&
796
- this.bindValue[key] &&
797
- Object.keys(this.bindKey).length
798
- ) {
799
- //获得绑定字段的值
800
- value = this.bindValue[key][this.bindKey[key]]
801
- }
802
515
  querys.push({
803
516
  property: key,
804
- value: value,
517
+ value: this.searchForm[key],
805
518
  group: 'main',
806
519
  operation: operationMap[key],
807
520
  relation: 'AND',
@@ -809,10 +522,9 @@ export default {
809
522
  }
810
523
  }
811
524
  }
812
- if (this.$refs.queryViewList && this.$refs.queryViewList.querys) {
813
- querys.push(...this.$refs.queryViewList.querys)
814
- }
815
- return { pageBean: this.pagination, querys }
525
+ queryFilter = { pageBean: this.pagination, querys }
526
+ params.pagination = queryFilter
527
+ return params
816
528
  }
817
529
  },
818
530
  //获取查询条件类型
@@ -842,19 +554,11 @@ export default {
842
554
  ? operationType[operation]
843
555
  : operation
844
556
  } else if (
845
- typeof $(searchItems[i])
846
- .children()
847
- .attr('ht-query') != 'undefined'
557
+ typeof $(searchItems[i]).children().attr('ht-query') != 'undefined'
848
558
  ) {
849
559
  //查询条件类型
850
- operation = $(searchItems[i])
851
- .children()
852
- .attr('operation')
853
- operationMap[
854
- $(searchItems[i])
855
- .children()
856
- .attr('ht-query')
857
- ] =
560
+ operation = $(searchItems[i]).children().attr('operation')
561
+ operationMap[$(searchItems[i]).children().attr('ht-query')] =
858
562
  typeof operationType[operation] != 'undefined'
859
563
  ? operationType[operation]
860
564
  : operation
@@ -876,16 +580,12 @@ export default {
876
580
  searchItems[i]
877
581
  ).attr('field-query')
878
582
  } else if (
879
- typeof $(searchItems[i])
880
- .children()
881
- .attr('ht-query') != 'undefined'
583
+ typeof $(searchItems[i]).children().attr('ht-query') != 'undefined'
882
584
  ) {
883
585
  //查询条件字段
884
- fieldQueryMap[
885
- $(searchItems[i])
886
- .children()
887
- .attr('ht-query')
888
- ] = $(searchItems[i])
586
+ fieldQueryMap[$(searchItems[i]).children().attr('ht-query')] = $(
587
+ searchItems[i]
588
+ )
889
589
  .children()
890
590
  .attr('field-query')
891
591
  }
@@ -907,19 +607,12 @@ export default {
907
607
  ? true
908
608
  : false
909
609
  } else if (
910
- typeof $(searchItems[i])
911
- .children()
912
- .attr('ht-query') != 'undefined'
610
+ typeof $(searchItems[i]).children().attr('ht-query') != 'undefined'
913
611
  ) {
914
612
  //查询条件字段
915
- fieldQueryMap[
916
- $(searchItems[i])
917
- .children()
918
- .attr('ht-query')
919
- ] =
920
- typeof $(searchItems[i])
921
- .children()
922
- .attr('special-query') != 'undefined'
613
+ fieldQueryMap[$(searchItems[i]).children().attr('ht-query')] =
614
+ typeof $(searchItems[i]).children().attr('special-query') !=
615
+ 'undefined'
923
616
  ? true
924
617
  : false
925
618
  }
@@ -1073,14 +766,6 @@ export default {
1073
766
  dataTemplateQueryVo.selectList = this.queryViewOptions.selectList
1074
767
  }
1075
768
  }
1076
- // 查询字段 校验是否必填,如果是必填没数据,需返回提示
1077
- let errorMsg = this.validateSearchRequired(
1078
- dataTemplateQueryVo.queryFilter.querys
1079
- )
1080
- if (errorMsg) {
1081
- this.$message.warning(errorMsg)
1082
- return
1083
- }
1084
769
 
1085
770
  let data = {
1086
771
  sqlAlias: this.sqlAlias || this.queryView.sqlAlias,
@@ -1093,22 +778,15 @@ export default {
1093
778
  let loadingInstance = Loading.service({ fullscreen: true }) //开始
1094
779
  this.$requestConfig
1095
780
  .querySqlViewExport(data)
1096
- // .then(({ data, headers }) => {
1097
- // const fileName = decodeURIComponent(
1098
- // headers['content-disposition'].split(';')[1].split('filename=')[1]
1099
- // )
1100
- // const blob = new Blob([data])
1101
- // saveAs(blob, fileName)
1102
- // })
1103
- // .finally(() => {
1104
- // loadingInstance.close() // 结束
1105
- // this.dialogExportVisible = false
1106
- // })
1107
- .then(() => {
1108
- this.$message.success('正在导出,请稍后前往报表附件管理查看')
781
+ .then(({ data, headers }) => {
782
+ const fileName = decodeURIComponent(
783
+ headers['content-disposition'].split(';')[1].split('filename=')[1]
784
+ )
785
+ const blob = new Blob([data])
786
+ saveAs(blob, fileName)
1109
787
  })
1110
788
  .finally(() => {
1111
- loadingInstance.close()
789
+ loadingInstance.close() // 结束
1112
790
  this.dialogExportVisible = false
1113
791
  })
1114
792
  },
@@ -1419,56 +1097,5 @@ export default {
1419
1097
  this.search()
1420
1098
  })
1421
1099
  },
1422
- countPageTotal() {
1423
- this.searchCountTotal(this.getQueryFilter())
1424
- },
1425
- searchCountTotal(param, cb, isSearchBtn, needRequestTotal = false) {
1426
- // 不需要请求后端接口统计列表数据
1427
- this.needRequestTotal = needRequestTotal
1428
- !param && (param = {})
1429
- param.pageBean = this.pagination
1430
- const dataTemplateQueryVo = {
1431
- queryFilter: param,
1432
- }
1433
- //保存查询参数,用于作为导出的查询参数
1434
- if (this.queryViewOptions) {
1435
- //关联查询字段
1436
- if (
1437
- this.queryViewOptions.selectList &&
1438
- this.queryViewOptions.selectList.length > 0
1439
- ) {
1440
- dataTemplateQueryVo.selectList = this.queryViewOptions.selectList
1441
- }
1442
- }
1443
- this.queryParam = { ...param }
1444
- let obj = {
1445
- sqlAlias: this.sqlAlias || this.queryView.sqlAlias,
1446
- alias: this.alias || this.queryView.alias,
1447
- param: dataTemplateQueryVo,
1448
- }
1449
-
1450
- this.getQuerySqlViewByPaginationTotal(obj, cb)
1451
- },
1452
- switchPage(type) {
1453
- if (type == 'prev') this.pagination.page--
1454
- if (type == 'next') this.pagination.page++
1455
- this.handleCurrentChange(this.pagination.page)
1456
- },
1457
- handleInput(value) {
1458
- if (!value) {
1459
- return
1460
- }
1461
- // 使用正则表达式匹配正整数
1462
- const regex = /^[1-9]\d*$/
1463
-
1464
- // 如果输入的值不符合正整数的模式,则将其重置为1
1465
- if (!regex.test(value)) {
1466
- //如果上一次输入的页数有值,则用上一次输入的页数,否则默认为1
1467
- this.pagination.page = this.lastPage ? this.lastPage : 1
1468
- } else {
1469
- //本次分页数,赋值给上一次分页数
1470
- this.lastPage = this.pagination.page
1471
- }
1472
- },
1473
1100
  },
1474
1101
  }