three-trees-ui 1.0.60 → 1.0.62

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,9 +7,12 @@ 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'
10
11
  export default {
11
12
  data() {
12
13
  return {
14
+ defaultQuerys: [],
15
+ isInit: true,
13
16
  bpmRunTime: this.$requestConfig.flowUrl,
14
17
  fileList: [],
15
18
  tableData: { selectRows: [], querys: '' },
@@ -77,6 +80,7 @@ export default {
77
80
  pageSize: 30,
78
81
  total: 0,
79
82
  },
83
+ total: 0,
80
84
  rows: [],
81
85
  queryParam: {},
82
86
  allSummaryConfig: {},
@@ -84,15 +88,16 @@ export default {
84
88
  summaryTableData: [],
85
89
  needRequestTotal: false, // 需不需要后端统计列表全部数据
86
90
  tableDataTotal: {},
91
+ loadingTotal: false //统计按钮加载中
87
92
  }
88
93
  },
89
94
  watch: {
90
- formKey: function (newVal) {
95
+ formKey: function(newVal) {
91
96
  if (newVal) {
92
97
  this.init()
93
98
  }
94
99
  },
95
- 'tableData.selectRows': function (newVal) {
100
+ 'tableData.selectRows': function(newVal) {
96
101
  if (newVal.length > 0) {
97
102
  let me_ = this
98
103
  me_.uploadParams.id = []
@@ -160,7 +165,29 @@ export default {
160
165
  deep: true,
161
166
  },
162
167
  },
168
+ created() {
169
+ if (this.queryView.jsScript) {
170
+ // 执行js脚本
171
+ this.handleDiyScript(this.queryView.jsScript)
172
+ }
173
+ },
163
174
  methods: {
175
+ handleDiyScript(scriptValue) {
176
+ //执行前置脚本内容
177
+ const _this = this
178
+ // 用户信息
179
+ const account = this.$requestConfig.getAccount()
180
+ const userId = this.$requestConfig.getUserId()
181
+ const userName = this.$requestConfig.getUsername()
182
+ const preScript = `const scriptFunction = function(_this, account, userId, userName){
183
+ ${scriptValue}
184
+ };`
185
+ try {
186
+ eval(`${preScript}scriptFunction(_this, account, userId, userName);`)
187
+ } catch (err) {
188
+ this.$message.error(`脚本事件执行错误:${err}`)
189
+ }
190
+ },
164
191
  handelBindFiledValua() {
165
192
  //数据视图控件
166
193
  let _me = this
@@ -209,7 +236,7 @@ export default {
209
236
  selectList[i].selectValue = value
210
237
 
211
238
  //添加监听
212
- pInst.$watch(path, function (newVal, oldVal) {
239
+ pInst.$watch(path, function(newVal, oldVal) {
213
240
  _.debounce(() => {
214
241
  if (newVal !== oldVal) {
215
242
  _me.queryViewOptions.selectList[i].selectValue = newVal
@@ -353,7 +380,7 @@ export default {
353
380
  this.$router.push(url)
354
381
  },
355
382
 
356
- handleSizeChange: function (size) {
383
+ handleSizeChange: function(size) {
357
384
  //每页下拉显示数据
358
385
  this.pagination.pageSize = size
359
386
  if (this.$refs.queryViewList) {
@@ -362,7 +389,7 @@ export default {
362
389
  this.search()
363
390
  }
364
391
  },
365
- handleCurrentChange: function (currentPage) {
392
+ handleCurrentChange: function(currentPage) {
366
393
  //点击第几页
367
394
  this.pagination.page = currentPage
368
395
  if (this.$refs.queryViewList) {
@@ -372,14 +399,112 @@ export default {
372
399
  }
373
400
  },
374
401
  //回车查询
375
- searchEnterFun: function (e) {
402
+ searchEnterFun: function(e) {
376
403
  let keyCode = window.event ? e.keyCode : e.which
377
404
  if (keyCode == 13) {
378
405
  this.pagination.page = 1
379
406
  this.search()
380
407
  }
381
408
  },
382
- search(param, cb, isSearchBtn, needRequestTotal = false) {
409
+ getQueryDataViewOperation(key) {
410
+ switch (key) {
411
+ case 'EQ':
412
+ return 'EQUAL'
413
+ case 'NE':
414
+ return 'NOT_EQUAL'
415
+ case 'LK':
416
+ return 'LIKE'
417
+ case 'LFK':
418
+ return 'LEFT_LIKE'
419
+ case 'RHK':
420
+ return 'RIGHT_LIKE'
421
+ case 'BETWEEN':
422
+ return 'BETWEEN'
423
+ default:
424
+ return 'LIKE'
425
+ }
426
+ },
427
+ async buildDefaultQuerys() {
428
+ let querys = []
429
+ let conditions = JSON.parse(this.queryView.conditions)
430
+ //条件字段默认值判断
431
+ for (let i = 0; i < conditions.length; i++) {
432
+ let condition = conditions[i]
433
+ if (condition.defaultValue) {
434
+ let defaultValue = condition.isScriptDefault
435
+ ? await this.getScriptDefaultValue(condition.defaultValue)
436
+ : condition.defaultValue
437
+ if (condition.dataType == 'number') {
438
+ defaultValue = parseFloat(defaultValue)
439
+ }
440
+ this.$set(this.searchForm, condition.fieldName, defaultValue)
441
+
442
+ querys.push({
443
+ property: condition.fieldName,
444
+ value: defaultValue,
445
+ group: 'main',
446
+ operation: this.getQueryDataViewOperation(condition.operate),
447
+ relation: 'AND',
448
+ })
449
+ }
450
+ }
451
+ this.defaultQuerys = querys
452
+ return querys
453
+ },
454
+ getScriptDefaultValue(scriptValue) {
455
+ return new Promise((resolve) => {
456
+ //执行前置脚本内容
457
+ const _this = this
458
+ // 用户信息
459
+ const account = this.$requestConfig.getAccount()
460
+ const userId = this.$requestConfig.getUserId()
461
+ const userName = this.$requestConfig.getUsername()
462
+ const _moment = moment
463
+ const preScript = `const scriptFunction = function(_this, account, userId, userName, _moment){
464
+ ${scriptValue}
465
+ };`
466
+ let result = ''
467
+ try {
468
+ result = eval(
469
+ `${preScript}scriptFunction(_this, account, userId, userName, _moment);`
470
+ )
471
+ if (result && result.then && typeof result.then === 'function') {
472
+ result.then(
473
+ (t) => {
474
+ resolve(t)
475
+ },
476
+ (fail) => {
477
+ //接口返回失败则终止按钮操作,并输出错误信息
478
+ resolve('')
479
+ }
480
+ )
481
+ } else {
482
+ resolve(result)
483
+ }
484
+ } catch (err) {
485
+ resolve('')
486
+ this.$message.error(`查询值默认脚本事件执行错误:${err}`)
487
+ }
488
+ })
489
+ },
490
+ validateSearchRequired(querys) {
491
+ let errorMsg = ''
492
+ let conditions = JSON.parse(this.queryView.conditions)
493
+ if (conditions && querys) {
494
+ conditions.forEach((item) => {
495
+ if (item.isRequired) {
496
+ let index = querys.findIndex((k) => {
497
+ return k.property == item.fieldName
498
+ })
499
+ if (index == -1) {
500
+ errorMsg = `字段【${item.fieldDesc}】为必填查询字段,不能为空!`
501
+ }
502
+ }
503
+ })
504
+ }
505
+ return errorMsg
506
+ },
507
+ async search(param, cb, isSearchBtn, needRequestTotal = false) {
383
508
  // 不需要请求后端接口统计列表数据
384
509
  this.needRequestTotal = needRequestTotal
385
510
  !param && (param = {})
@@ -387,6 +512,35 @@ export default {
387
512
  const dataTemplateQueryVo = {
388
513
  queryFilter: param,
389
514
  }
515
+ //初始化时,把查询字段的默认值加进去
516
+ if (this.isInit) {
517
+ this.isInit = false
518
+ let querys = await this.buildDefaultQuerys()
519
+ dataTemplateQueryVo.queryFilter.querys =
520
+ dataTemplateQueryVo.queryFilter.querys || []
521
+ dataTemplateQueryVo.queryFilter.querys = dataTemplateQueryVo.queryFilter.querys.concat(
522
+ querys
523
+ )
524
+ }
525
+ // 非高级查询时,将默认值带上
526
+ if (!isSearchBtn) {
527
+ dataTemplateQueryVo.queryFilter.querys =
528
+ dataTemplateQueryVo.queryFilter.querys || []
529
+ dataTemplateQueryVo.queryFilter.querys = dataTemplateQueryVo.queryFilter.querys.concat(
530
+ this.defaultQuerys
531
+ )
532
+ }
533
+ // 查询字段 校验是否必填,如果是必填没数据,需返回提示
534
+ if (isSearchBtn) {
535
+ let errorMsg = this.validateSearchRequired(
536
+ dataTemplateQueryVo.queryFilter.querys
537
+ )
538
+ if (errorMsg) {
539
+ this.$message.warning(errorMsg)
540
+ cb && cb()
541
+ return
542
+ }
543
+ }
390
544
  //保存查询参数,用于作为导出的查询参数
391
545
  if (this.queryViewOptions) {
392
546
  //关联查询字段
@@ -419,13 +573,17 @@ export default {
419
573
  })
420
574
  }
421
575
  this.$requestConfig
422
- .getQueryViewDataList(param)
576
+ .getQueryViewDataListWithoutTotal(param)
423
577
  .then((response) => {
424
578
  this.rows = response.rows
425
- this.pagination.total = response.total
579
+ // this.pagination.total = response.total
426
580
  this.pagination.page = response.page
427
581
  this.pagination.pageSize = response.pageSize
428
582
  this.filterOldSummaryValByType('currentPage')
583
+ //每次请求后不再统计总数,而是在统计按钮中去统计,当数量统计过一次后,再重新设置到当前页
584
+ if (this.total) {
585
+ this.$set(this.pagination, 'total', this.total)
586
+ }
429
587
  this.summaryTableData.push({
430
588
  project: '当前页汇总',
431
589
  key: 'currentPage',
@@ -445,12 +603,31 @@ export default {
445
603
  cb && cb()
446
604
  })
447
605
  },
606
+ getQuerySqlViewByPaginationTotal(param, cb) {
607
+ this.loadingTotal = true
608
+ this.$requestConfig
609
+ .getQueryViewDataListWithTotal(param)
610
+ .then((response) => {
611
+ this.total = response.value
612
+ //每次请求后不再统计总数,而是在统计按钮中去统计,当数量统计过一次后,再重新设置到当前页
613
+ if (this.total) {
614
+ this.$set(this.pagination, 'total', this.total)
615
+ }
616
+ this.loadingTotal = false
617
+ this.$nextTick(() => {
618
+ this.$refs.queryViewList && this.$refs.queryViewList.doLayout()
619
+ })
620
+ })
621
+ .finally(() => {
622
+ this.loadingTotal = false
623
+ cb && cb()
624
+ })
625
+ },
448
626
  getQueryFilter() {
449
627
  let operationMap = this.getSearchItems() //查询条件类型
450
628
  // let fieldQueryMap = this.getFieldQuery() //查询条件字段
451
629
  let specialMap = this.getSpecialMap() //获取特殊查询情况(自定义对话框)
452
630
  let querys = [] //查询条件
453
- let queryFilter = {}
454
631
  let pageBean = { pageBean: this.pagination }
455
632
  let params = {
456
633
  sqlAlias: this.sqlAlias || this.queryView.sqlAlias,
@@ -458,6 +635,10 @@ export default {
458
635
  }
459
636
  params.pagination = pageBean
460
637
  if ($.isEmptyObject(this.searchForm)) {
638
+ if (this.$refs.queryViewList && this.$refs.queryViewList.querys) {
639
+ querys.push(...this.$refs.queryViewList.querys)
640
+ }
641
+ params = { pageBean: this.pagination, querys }
461
642
  return params
462
643
  } else {
463
644
  for (var key in this.searchForm) {
@@ -522,9 +703,10 @@ export default {
522
703
  }
523
704
  }
524
705
  }
525
- queryFilter = { pageBean: this.pagination, querys }
526
- params.pagination = queryFilter
527
- return params
706
+ if (this.$refs.queryViewList && this.$refs.queryViewList.querys) {
707
+ querys.push(...this.$refs.queryViewList.querys)
708
+ }
709
+ return { pageBean: this.pagination, querys }
528
710
  }
529
711
  },
530
712
  //获取查询条件类型
@@ -554,19 +736,11 @@ export default {
554
736
  ? operationType[operation]
555
737
  : operation
556
738
  } else if (
557
- typeof $(searchItems[i])
558
- .children()
559
- .attr('ht-query') != 'undefined'
739
+ typeof $(searchItems[i]).children().attr('ht-query') != 'undefined'
560
740
  ) {
561
741
  //查询条件类型
562
- operation = $(searchItems[i])
563
- .children()
564
- .attr('operation')
565
- operationMap[
566
- $(searchItems[i])
567
- .children()
568
- .attr('ht-query')
569
- ] =
742
+ operation = $(searchItems[i]).children().attr('operation')
743
+ operationMap[$(searchItems[i]).children().attr('ht-query')] =
570
744
  typeof operationType[operation] != 'undefined'
571
745
  ? operationType[operation]
572
746
  : operation
@@ -588,16 +762,12 @@ export default {
588
762
  searchItems[i]
589
763
  ).attr('field-query')
590
764
  } else if (
591
- typeof $(searchItems[i])
592
- .children()
593
- .attr('ht-query') != 'undefined'
765
+ typeof $(searchItems[i]).children().attr('ht-query') != 'undefined'
594
766
  ) {
595
767
  //查询条件字段
596
- fieldQueryMap[
597
- $(searchItems[i])
598
- .children()
599
- .attr('ht-query')
600
- ] = $(searchItems[i])
768
+ fieldQueryMap[$(searchItems[i]).children().attr('ht-query')] = $(
769
+ searchItems[i]
770
+ )
601
771
  .children()
602
772
  .attr('field-query')
603
773
  }
@@ -619,19 +789,12 @@ export default {
619
789
  ? true
620
790
  : false
621
791
  } else if (
622
- typeof $(searchItems[i])
623
- .children()
624
- .attr('ht-query') != 'undefined'
792
+ typeof $(searchItems[i]).children().attr('ht-query') != 'undefined'
625
793
  ) {
626
794
  //查询条件字段
627
- fieldQueryMap[
628
- $(searchItems[i])
629
- .children()
630
- .attr('ht-query')
631
- ] =
632
- typeof $(searchItems[i])
633
- .children()
634
- .attr('special-query') != 'undefined'
795
+ fieldQueryMap[$(searchItems[i]).children().attr('ht-query')] =
796
+ typeof $(searchItems[i]).children().attr('special-query') !=
797
+ 'undefined'
635
798
  ? true
636
799
  : false
637
800
  }
@@ -727,7 +890,7 @@ export default {
727
890
  punchOrder() {
728
891
  this.$store
729
892
  .dispatch('storeProcess/downLoadToFile', 'Batchkeijyo')
730
- .then(() => { })
893
+ .then(() => {})
731
894
  },
732
895
  beforeAvatarUpload(file) {
733
896
  var fileName = new Array()
@@ -754,7 +917,7 @@ export default {
754
917
  this.$message.success('送付状成功')
755
918
  window.location.reload()
756
919
  },
757
- handlePreview() { },
920
+ handlePreview() {},
758
921
  //确定导出
759
922
  submitExport() {
760
923
  if (!this.exportData || this.exportData.expField.length < 1) {
@@ -772,29 +935,47 @@ export default {
772
935
  expField += this.exportData.expField[i].fieldName
773
936
  }
774
937
  expField = Base64.encode(expField).replace(/\+/g, '%2B')
775
- // let params = {
776
- // sqlAlias: this.sqlAlias || this.queryView.sqlAlias,
777
- // alias: this.alias || this.queryView.alias,
778
- // }
938
+ const dataTemplateQueryVo = {
939
+ queryFilter: this.queryParam,
940
+ }
941
+ //保存查询参数,用于作为导出的查询参数
942
+ if (this.queryViewOptions) {
943
+ //关联查询字段
944
+ if (
945
+ this.queryViewOptions.selectList &&
946
+ this.queryViewOptions.selectList.length > 0
947
+ ) {
948
+ dataTemplateQueryVo.selectList = this.queryViewOptions.selectList
949
+ }
950
+ }
951
+
779
952
  let data = {
780
953
  sqlAlias: this.sqlAlias || this.queryView.sqlAlias,
781
954
  alias: this.alias || this.queryView.alias,
782
955
  getType: this.exportData.getType,
783
956
  expField: expField,
957
+ query: dataTemplateQueryVo,
784
958
  }
785
- data.query = this.queryParam
959
+
786
960
  let loadingInstance = Loading.service({ fullscreen: true }) //开始
787
961
  this.$requestConfig
788
962
  .querySqlViewExport(data)
789
- .then(({ data, headers }) => {
790
- const fileName = decodeURIComponent(
791
- headers['content-disposition'].split(';')[1].split('filename=')[1]
792
- )
793
- const blob = new Blob([data])
794
- saveAs(blob, fileName)
963
+ // .then(({ data, headers }) => {
964
+ // const fileName = decodeURIComponent(
965
+ // headers['content-disposition'].split(';')[1].split('filename=')[1]
966
+ // )
967
+ // const blob = new Blob([data])
968
+ // saveAs(blob, fileName)
969
+ // })
970
+ // .finally(() => {
971
+ // loadingInstance.close() // 结束
972
+ // this.dialogExportVisible = false
973
+ // })
974
+ .then(() => {
975
+ this.$message.success('正在导出,请稍后前往报表附件管理查看')
795
976
  })
796
977
  .finally(() => {
797
- loadingInstance.close() // 结束
978
+ loadingInstance.close()
798
979
  this.dialogExportVisible = false
799
980
  })
800
981
  },
@@ -1029,9 +1210,9 @@ export default {
1029
1210
  )
1030
1211
  return checkField.length
1031
1212
  ? checkField.filter(
1032
- (field) =>
1033
- field.checked && ['序号', '操作'].indexOf(field.value) == -1
1034
- )
1213
+ (field) =>
1214
+ field.checked && ['序号', '操作'].indexOf(field.value) == -1
1215
+ )
1035
1216
  : customColumns
1036
1217
  },
1037
1218
  ChangeRecordDialogsShow(FormDataid, templateKey) {
@@ -1105,5 +1286,34 @@ export default {
1105
1286
  this.search()
1106
1287
  })
1107
1288
  },
1289
+ countPageTotal() {
1290
+ this.searchCountTotal(this.getQueryFilter())
1291
+ },
1292
+ searchCountTotal(param, cb, isSearchBtn, needRequestTotal = false) {
1293
+ // 不需要请求后端接口统计列表数据
1294
+ this.needRequestTotal = needRequestTotal
1295
+ !param && (param = {})
1296
+ param.pageBean = this.pagination
1297
+ const dataTemplateQueryVo = {
1298
+ queryFilter: param,
1299
+ }
1300
+ //保存查询参数,用于作为导出的查询参数
1301
+ if (this.queryViewOptions) {
1302
+ //关联查询字段
1303
+ if (
1304
+ this.queryViewOptions.selectList &&
1305
+ this.queryViewOptions.selectList.length > 0
1306
+ ) {
1307
+ dataTemplateQueryVo.selectList = this.queryViewOptions.selectList
1308
+ }
1309
+ }
1310
+ this.queryParam = { ...param }
1311
+ let obj = {
1312
+ sqlAlias: this.sqlAlias || this.queryView.sqlAlias,
1313
+ alias: this.alias || this.queryView.alias,
1314
+ param: dataTemplateQueryVo,
1315
+ }
1316
+ this.getQuerySqlViewByPaginationTotal(obj, cb)
1317
+ },
1108
1318
  },
1109
1319
  }