three-trees-ui 1.0.72 → 1.0.73

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,12 +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
- defaultQuerys: [],
15
- isInit: true,
16
13
  bpmRunTime: this.$requestConfig.flowUrl,
17
14
  fileList: [],
18
15
  tableData: { selectRows: [], querys: '' },
@@ -80,8 +77,6 @@ export default {
80
77
  pageSize: 30,
81
78
  total: 0,
82
79
  },
83
- lastPage: 1, //上一次输入的分页数、默认为1
84
- total: 0,
85
80
  rows: [],
86
81
  queryParam: {},
87
82
  allSummaryConfig: {},
@@ -89,54 +84,15 @@ export default {
89
84
  summaryTableData: [],
90
85
  needRequestTotal: false, // 需不需要后端统计列表全部数据
91
86
  tableDataTotal: {},
92
- loadingTotal: false, //统计按钮加载中
93
- pageSizeArray: [
94
- {
95
- label: '10条/页',
96
- value: 10,
97
- },
98
- {
99
- label: '20条/页',
100
- value: 20,
101
- },
102
- {
103
- label: '30条/页',
104
- value: 30,
105
- },
106
- {
107
- label: '40条/页',
108
- value: 40,
109
- },
110
- {
111
- label: '50条/页',
112
- value: 50,
113
- },
114
- {
115
- label: '100条/页',
116
- value: 100,
117
- },
118
- {
119
- label: '200条/页',
120
- value: 200,
121
- },
122
- {
123
- label: '300条/页',
124
- value: 300,
125
- },
126
- {
127
- label: '500条/页',
128
- value: 500,
129
- },
130
- ],
131
87
  }
132
88
  },
133
89
  watch: {
134
- formKey: function(newVal) {
90
+ formKey: function (newVal) {
135
91
  if (newVal) {
136
92
  this.init()
137
93
  }
138
94
  },
139
- 'tableData.selectRows': function(newVal) {
95
+ 'tableData.selectRows': function (newVal) {
140
96
  if (newVal.length > 0) {
141
97
  let me_ = this
142
98
  me_.uploadParams.id = []
@@ -204,29 +160,7 @@ export default {
204
160
  deep: true,
205
161
  },
206
162
  },
207
- created() {
208
- if (this.queryView.jsScript) {
209
- // 执行js脚本
210
- this.handleDiyScript(this.queryView.jsScript)
211
- }
212
- },
213
163
  methods: {
214
- handleDiyScript(scriptValue) {
215
- //执行前置脚本内容
216
- const _this = this
217
- // 用户信息
218
- const account = this.$requestConfig.getAccount()
219
- const userId = this.$requestConfig.getUserId()
220
- const userName = this.$requestConfig.getUsername()
221
- const preScript = `const scriptFunction = function(_this, account, userId, userName){
222
- ${scriptValue}
223
- };`
224
- try {
225
- eval(`${preScript}scriptFunction(_this, account, userId, userName);`)
226
- } catch (err) {
227
- this.$message.error(`脚本事件执行错误:${err}`)
228
- }
229
- },
230
164
  handelBindFiledValua() {
231
165
  //数据视图控件
232
166
  let _me = this
@@ -275,7 +209,7 @@ export default {
275
209
  selectList[i].selectValue = value
276
210
 
277
211
  //添加监听
278
- pInst.$watch(path, function(newVal, oldVal) {
212
+ pInst.$watch(path, function (newVal, oldVal) {
279
213
  _.debounce(() => {
280
214
  if (newVal !== oldVal) {
281
215
  _me.queryViewOptions.selectList[i].selectValue = newVal
@@ -419,7 +353,7 @@ export default {
419
353
  this.$router.push(url)
420
354
  },
421
355
 
422
- handleSizeChange: function(size) {
356
+ handleSizeChange: function (size) {
423
357
  //每页下拉显示数据
424
358
  this.pagination.pageSize = size
425
359
  if (this.$refs.queryViewList) {
@@ -428,9 +362,9 @@ export default {
428
362
  this.search()
429
363
  }
430
364
  },
431
- handleCurrentChange: function(currentPage) {
365
+ handleCurrentChange: function (currentPage) {
432
366
  //点击第几页
433
- this.pagination.page = currentPage ? currentPage : this.lastPage
367
+ this.pagination.page = currentPage
434
368
  if (this.$refs.queryViewList) {
435
369
  this.$refs.queryViewList.load()
436
370
  } else {
@@ -438,126 +372,14 @@ export default {
438
372
  }
439
373
  },
440
374
  //回车查询
441
- searchEnterFun: function(e) {
375
+ searchEnterFun: function (e) {
442
376
  let keyCode = window.event ? e.keyCode : e.which
443
377
  if (keyCode == 13) {
444
378
  this.pagination.page = 1
445
379
  this.search()
446
380
  }
447
381
  },
448
- getQueryDataViewOperation(key) {
449
- switch (key) {
450
- case 'EQ':
451
- return 'EQUAL'
452
- case 'NE':
453
- return 'NOT_EQUAL'
454
- case 'LK':
455
- return 'LIKE'
456
- case 'LFK':
457
- return 'LEFT_LIKE'
458
- case 'RHK':
459
- return 'RIGHT_LIKE'
460
- case 'BETWEEN':
461
- return 'BETWEEN'
462
- default:
463
- return 'LIKE'
464
- }
465
- },
466
- async buildDefaultQuerys() {
467
- let querys = []
468
- let conditions = JSON.parse(this.queryView.conditions)
469
- //条件字段默认值判断
470
- for (let i = 0; i < conditions.length; i++) {
471
- let condition = conditions[i]
472
- if (condition.defaultValue) {
473
- let defaultValue = condition.isScriptDefault
474
- ? await this.getScriptDefaultValue(condition.defaultValue)
475
- : condition.defaultValue
476
- if (condition.dataType == 'number') {
477
- defaultValue = parseFloat(defaultValue)
478
- }
479
- this.$set(this.searchForm, condition.fieldName, defaultValue)
480
-
481
- querys.push({
482
- property: condition.fieldName,
483
- value: defaultValue,
484
- group: 'main',
485
- operation: this.getQueryDataViewOperation(condition.operate),
486
- relation: 'AND',
487
- })
488
- }
489
- }
490
- this.defaultQuerys = querys
491
- return querys
492
- },
493
- getScriptDefaultValue(scriptValue) {
494
- return new Promise((resolve) => {
495
- //执行前置脚本内容
496
- const _this = this
497
- // 用户信息
498
- const account = this.$requestConfig.getAccount()
499
- const userId = this.$requestConfig.getUserId()
500
- const userName = this.$requestConfig.getUsername()
501
- const _moment = moment
502
- const preScript = `const scriptFunction = function(_this, account, userId, userName, _moment){
503
- ${scriptValue}
504
- };`
505
- let result = ''
506
- try {
507
- result = eval(
508
- `${preScript}scriptFunction(_this, account, userId, userName, _moment);`
509
- )
510
- if (result && result.then && typeof result.then === 'function') {
511
- result.then(
512
- (t) => {
513
- resolve(t)
514
- },
515
- (fail) => {
516
- //接口返回失败则终止按钮操作,并输出错误信息
517
- resolve('')
518
- }
519
- )
520
- } else {
521
- resolve(result)
522
- }
523
- } catch (err) {
524
- resolve('')
525
- this.$message.error(`查询值默认脚本事件执行错误:${err}`)
526
- }
527
- })
528
- },
529
- validateSearchRequired(querys = []) {
530
- let errorMsg = ''
531
- let conditions = JSON.parse(this.queryView.conditions)
532
- if (conditions && querys) {
533
- conditions.forEach((item) => {
534
- if (item.isRequired) {
535
- let index = querys.findIndex((k) => {
536
- return k.property == item.fieldName
537
- })
538
- if (index == -1) {
539
- errorMsg = `字段【${item.fieldDesc}】为必填查询字段,不能为空!`
540
- }
541
- }
542
- })
543
- }
544
- return errorMsg
545
- },
546
- checkHaveRequired() {
547
- let haveRequired = false
548
- try {
549
- let conditions = JSON.parse(this.queryView.conditions)
550
- if (conditions) {
551
- haveRequired = conditions.some((item) => {
552
- return item.isRequired
553
- })
554
- }
555
- } catch (e) {
556
- console.log(e)
557
- }
558
- return haveRequired
559
- },
560
- async search(param, cb, isSearchBtn, needRequestTotal = false) {
382
+ search(param, cb, isSearchBtn, needRequestTotal = false) {
561
383
  // 不需要请求后端接口统计列表数据
562
384
  this.needRequestTotal = needRequestTotal
563
385
  !param && (param = {})
@@ -565,38 +387,6 @@ export default {
565
387
  const dataTemplateQueryVo = {
566
388
  queryFilter: param,
567
389
  }
568
- //初始化时,把查询字段的默认值加进去
569
- if (this.isInit) {
570
- let querys = await this.buildDefaultQuerys()
571
- dataTemplateQueryVo.queryFilter.querys =
572
- dataTemplateQueryVo.queryFilter.querys || []
573
- dataTemplateQueryVo.queryFilter.querys = dataTemplateQueryVo.queryFilter.querys.concat(
574
- querys
575
- )
576
- }
577
- // 非高级查询时,将默认值带上
578
- if (!isSearchBtn) {
579
- dataTemplateQueryVo.queryFilter.querys =
580
- dataTemplateQueryVo.queryFilter.querys || []
581
- dataTemplateQueryVo.queryFilter.querys = dataTemplateQueryVo.queryFilter.querys.concat(
582
- this.defaultQuerys
583
- )
584
- }
585
- // 检查是否有必填字段
586
- if (this.checkHaveRequired() && this.isInit) {
587
- this.$refs.queryViewList.showAdvancedSearch = true
588
- }
589
- // 查询字段 校验是否必填,如果是必填没数据,需返回提示
590
- let errorMsg = this.validateSearchRequired(
591
- dataTemplateQueryVo.queryFilter.querys
592
- )
593
- if (errorMsg) {
594
- !this.isInit && this.$message.warning(errorMsg)
595
- cb && cb()
596
- this.isInit = false
597
- return
598
- }
599
- this.isInit = false
600
390
  //保存查询参数,用于作为导出的查询参数
601
391
  if (this.queryViewOptions) {
602
392
  //关联查询字段
@@ -629,17 +419,13 @@ export default {
629
419
  })
630
420
  }
631
421
  this.$requestConfig
632
- .getQueryViewDataListWithoutTotal(param)
422
+ .getQueryViewDataList(param)
633
423
  .then((response) => {
634
424
  this.rows = response.rows
635
- // this.pagination.total = response.total
425
+ this.pagination.total = response.total
636
426
  this.pagination.page = response.page
637
427
  this.pagination.pageSize = response.pageSize
638
428
  this.filterOldSummaryValByType('currentPage')
639
- //每次请求后不再统计总数,而是在统计按钮中去统计,当数量统计过一次后,再重新设置到当前页
640
- if (this.total) {
641
- this.$set(this.pagination, 'total', this.total)
642
- }
643
429
  this.summaryTableData.push({
644
430
  project: '当前页汇总',
645
431
  key: 'currentPage',
@@ -659,31 +445,12 @@ export default {
659
445
  cb && cb()
660
446
  })
661
447
  },
662
- getQuerySqlViewByPaginationTotal(param, cb) {
663
- this.loadingTotal = true
664
- this.$requestConfig
665
- .getQueryViewDataListWithTotal(param)
666
- .then((response) => {
667
- this.total = response.value
668
- //每次请求后不再统计总数,而是在统计按钮中去统计,当数量统计过一次后,再重新设置到当前页
669
- if (this.total) {
670
- this.$set(this.pagination, 'total', this.total)
671
- }
672
- this.loadingTotal = false
673
- this.$nextTick(() => {
674
- this.$refs.queryViewList && this.$refs.queryViewList.doLayout()
675
- })
676
- })
677
- .finally(() => {
678
- this.loadingTotal = false
679
- cb && cb()
680
- })
681
- },
682
448
  getQueryFilter() {
683
449
  let operationMap = this.getSearchItems() //查询条件类型
684
450
  // let fieldQueryMap = this.getFieldQuery() //查询条件字段
685
451
  let specialMap = this.getSpecialMap() //获取特殊查询情况(自定义对话框)
686
452
  let querys = [] //查询条件
453
+ let queryFilter = {}
687
454
  let pageBean = { pageBean: this.pagination }
688
455
  let params = {
689
456
  sqlAlias: this.sqlAlias || this.queryView.sqlAlias,
@@ -691,10 +458,6 @@ export default {
691
458
  }
692
459
  params.pagination = pageBean
693
460
  if ($.isEmptyObject(this.searchForm)) {
694
- if (this.$refs.queryViewList && this.$refs.queryViewList.querys) {
695
- querys.push(...this.$refs.queryViewList.querys)
696
- }
697
- params = { pageBean: this.pagination, querys }
698
461
  return params
699
462
  } else {
700
463
  for (var key in this.searchForm) {
@@ -759,10 +522,9 @@ export default {
759
522
  }
760
523
  }
761
524
  }
762
- if (this.$refs.queryViewList && this.$refs.queryViewList.querys) {
763
- querys.push(...this.$refs.queryViewList.querys)
764
- }
765
- return { pageBean: this.pagination, querys }
525
+ queryFilter = { pageBean: this.pagination, querys }
526
+ params.pagination = queryFilter
527
+ return params
766
528
  }
767
529
  },
768
530
  //获取查询条件类型
@@ -792,19 +554,11 @@ export default {
792
554
  ? operationType[operation]
793
555
  : operation
794
556
  } else if (
795
- typeof $(searchItems[i])
796
- .children()
797
- .attr('ht-query') != 'undefined'
557
+ typeof $(searchItems[i]).children().attr('ht-query') != 'undefined'
798
558
  ) {
799
559
  //查询条件类型
800
- operation = $(searchItems[i])
801
- .children()
802
- .attr('operation')
803
- operationMap[
804
- $(searchItems[i])
805
- .children()
806
- .attr('ht-query')
807
- ] =
560
+ operation = $(searchItems[i]).children().attr('operation')
561
+ operationMap[$(searchItems[i]).children().attr('ht-query')] =
808
562
  typeof operationType[operation] != 'undefined'
809
563
  ? operationType[operation]
810
564
  : operation
@@ -826,16 +580,12 @@ export default {
826
580
  searchItems[i]
827
581
  ).attr('field-query')
828
582
  } else if (
829
- typeof $(searchItems[i])
830
- .children()
831
- .attr('ht-query') != 'undefined'
583
+ typeof $(searchItems[i]).children().attr('ht-query') != 'undefined'
832
584
  ) {
833
585
  //查询条件字段
834
- fieldQueryMap[
835
- $(searchItems[i])
836
- .children()
837
- .attr('ht-query')
838
- ] = $(searchItems[i])
586
+ fieldQueryMap[$(searchItems[i]).children().attr('ht-query')] = $(
587
+ searchItems[i]
588
+ )
839
589
  .children()
840
590
  .attr('field-query')
841
591
  }
@@ -857,19 +607,12 @@ export default {
857
607
  ? true
858
608
  : false
859
609
  } else if (
860
- typeof $(searchItems[i])
861
- .children()
862
- .attr('ht-query') != 'undefined'
610
+ typeof $(searchItems[i]).children().attr('ht-query') != 'undefined'
863
611
  ) {
864
612
  //查询条件字段
865
- fieldQueryMap[
866
- $(searchItems[i])
867
- .children()
868
- .attr('ht-query')
869
- ] =
870
- typeof $(searchItems[i])
871
- .children()
872
- .attr('special-query') != 'undefined'
613
+ fieldQueryMap[$(searchItems[i]).children().attr('ht-query')] =
614
+ typeof $(searchItems[i]).children().attr('special-query') !=
615
+ 'undefined'
873
616
  ? true
874
617
  : false
875
618
  }
@@ -1023,14 +766,6 @@ export default {
1023
766
  dataTemplateQueryVo.selectList = this.queryViewOptions.selectList
1024
767
  }
1025
768
  }
1026
- // 查询字段 校验是否必填,如果是必填没数据,需返回提示
1027
- let errorMsg = this.validateSearchRequired(
1028
- dataTemplateQueryVo.queryFilter.querys
1029
- )
1030
- if (errorMsg) {
1031
- this.$message.warning(errorMsg)
1032
- return
1033
- }
1034
769
 
1035
770
  let data = {
1036
771
  sqlAlias: this.sqlAlias || this.queryView.sqlAlias,
@@ -1043,22 +778,15 @@ export default {
1043
778
  let loadingInstance = Loading.service({ fullscreen: true }) //开始
1044
779
  this.$requestConfig
1045
780
  .querySqlViewExport(data)
1046
- // .then(({ data, headers }) => {
1047
- // const fileName = decodeURIComponent(
1048
- // headers['content-disposition'].split(';')[1].split('filename=')[1]
1049
- // )
1050
- // const blob = new Blob([data])
1051
- // saveAs(blob, fileName)
1052
- // })
1053
- // .finally(() => {
1054
- // loadingInstance.close() // 结束
1055
- // this.dialogExportVisible = false
1056
- // })
1057
- .then(() => {
1058
- 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)
1059
787
  })
1060
788
  .finally(() => {
1061
- loadingInstance.close()
789
+ loadingInstance.close() // 结束
1062
790
  this.dialogExportVisible = false
1063
791
  })
1064
792
  },
@@ -1369,55 +1097,5 @@ export default {
1369
1097
  this.search()
1370
1098
  })
1371
1099
  },
1372
- countPageTotal() {
1373
- this.searchCountTotal(this.getQueryFilter())
1374
- },
1375
- searchCountTotal(param, cb, isSearchBtn, needRequestTotal = false) {
1376
- // 不需要请求后端接口统计列表数据
1377
- this.needRequestTotal = needRequestTotal
1378
- !param && (param = {})
1379
- param.pageBean = this.pagination
1380
- const dataTemplateQueryVo = {
1381
- queryFilter: param,
1382
- }
1383
- //保存查询参数,用于作为导出的查询参数
1384
- if (this.queryViewOptions) {
1385
- //关联查询字段
1386
- if (
1387
- this.queryViewOptions.selectList &&
1388
- this.queryViewOptions.selectList.length > 0
1389
- ) {
1390
- dataTemplateQueryVo.selectList = this.queryViewOptions.selectList
1391
- }
1392
- }
1393
- this.queryParam = { ...param }
1394
- let obj = {
1395
- sqlAlias: this.sqlAlias || this.queryView.sqlAlias,
1396
- alias: this.alias || this.queryView.alias,
1397
- param: dataTemplateQueryVo,
1398
- }
1399
- this.getQuerySqlViewByPaginationTotal(obj, cb)
1400
- },
1401
- switchPage(type) {
1402
- if (type == 'prev') this.pagination.page--
1403
- if (type == 'next') this.pagination.page++
1404
- this.handleCurrentChange(this.pagination.page)
1405
- },
1406
- handleInput(value) {
1407
- if (!value) {
1408
- return
1409
- }
1410
- // 使用正则表达式匹配正整数
1411
- const regex = /^[1-9]\d*$/
1412
-
1413
- // 如果输入的值不符合正整数的模式,则将其重置为1
1414
- if (!regex.test(value)) {
1415
- //如果上一次输入的页数有值,则用上一次输入的页数,否则默认为1
1416
- this.pagination.page = this.lastPage ? this.lastPage : 1
1417
- } else {
1418
- //本次分页数,赋值给上一次分页数
1419
- this.lastPage = this.pagination.page
1420
- }
1421
- },
1422
1100
  },
1423
1101
  }