three-trees-ui 1.0.62 → 1.0.64

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.
@@ -1,10 +1,8 @@
1
1
  import SubPagination from '../services/SubPagination.js'
2
- import utils from '../utils.js'
3
2
 
4
3
  export default {
5
4
  data() {
6
5
  return {
7
- searchVal: '', //搜索关键字
8
6
  fillOrg: {},
9
7
  fillOrgConfMap: {},
10
8
  transitionIndex: -1,
@@ -54,305 +52,6 @@ export default {
54
52
  }
55
53
  },
56
54
  methods: {
57
- //合计计算
58
- getSummaries(param, list) {
59
- let CancelTheCalculation = sessionStorage.getItem(
60
- 'Cancel_The_Calculation'
61
- )
62
- ? JSON.parse(sessionStorage.getItem('Cancel_The_Calculation'))
63
- : {}
64
- //
65
- let listChange = JSON.parse(Base64.decode(list, 'utf-8'))
66
-
67
- //
68
-
69
- if (listChange.length < 1) {
70
- return
71
- }
72
- const { columns, data } = param
73
- this.tableData = data
74
- const sums = []
75
- let calcProp = []
76
- let columnsDep = _.cloneDeep(columns)
77
- listChange.forEach((item, idex) => {
78
- if (item.addFunc == 'calcFunc') {
79
- columnsDep.forEach((column, index) => {
80
- if (
81
- item.mathExp &&
82
- item.mathExp.indexOf('.' + column.property) > -1
83
- ) {
84
- calcProp.push(column.property)
85
- }
86
- })
87
- }
88
-
89
- columnsDep.forEach((column, index) => {
90
- if (item.columnField == column.property) {
91
- column.combinedOption = item
92
- }
93
- })
94
- })
95
-
96
- columnsDep.forEach((column, index) => {
97
- if (index === 0 && columnsDep[0].type == 'index') {
98
- sums[index] = ''
99
- return
100
- }
101
- //当有需要才合计
102
- if (column.combinedOption) {
103
- let {
104
- addFunc,
105
- columnField,
106
- name,
107
- unit,
108
- showType,
109
- num,
110
- tag,
111
- mainTarget,
112
- } = column.combinedOption
113
-
114
- let Bol =
115
- tag &&
116
- CancelTheCalculation &&
117
- CancelTheCalculation[tag] &&
118
- CancelTheCalculation[tag].length > 0
119
- const values = data.map((item) => Number(item[column.property]))
120
- let depValues = _.cloneDeep(values)
121
- if (Bol) {
122
- let delMin = []
123
- depValues.forEach((item, i) => {
124
- if (!CancelTheCalculation[tag].includes(i)) {
125
- delMin.push(item)
126
- }
127
- })
128
-
129
- depValues = delMin
130
- }
131
- let units = unit ? unit : ''
132
- //求和
133
- if (addFunc === 'add') {
134
- if (!depValues.every((value) => isNaN(value))) {
135
- sums[index] = depValues.reduce((prev, curr) => {
136
- const value = Number(curr)
137
- if (!isNaN(value)) {
138
- return prev + curr
139
- } else {
140
- return prev
141
- }
142
- }, 0)
143
-
144
- sums[index] = this.dealWithDataHtml(
145
- name,
146
- sums[index],
147
- showType,
148
- num,
149
- units,
150
- mainTarget
151
- )
152
- } else {
153
- sums[index] = this.dealWithDataHtml(
154
- name,
155
- 0,
156
- showType,
157
- num,
158
- units,
159
- mainTarget
160
- )
161
- }
162
- }
163
- //计数
164
- if (addFunc === 'count') {
165
- let numCount = values.length
166
-
167
- if (Bol) {
168
- numCount = values.length - CancelTheCalculation[tag].length
169
- }
170
- sums[index] = this.dealWithDataHtml(
171
- name,
172
- numCount,
173
- showType,
174
- num,
175
- units,
176
- mainTarget
177
- )
178
- }
179
- //平均值
180
- if (addFunc === 'average') {
181
- let sum = 0
182
- var average = 0
183
-
184
- for (var i = 0; i < depValues.length; i++) {
185
- sum += depValues[i]
186
- }
187
-
188
- depValues.length > 0
189
- ? (average = sum / depValues.length)
190
- : (average = 0)
191
-
192
- sums[index] = this.dealWithDataHtml(
193
- name,
194
- average,
195
- showType,
196
- num,
197
- units,
198
- mainTarget
199
- )
200
- }
201
- //最大值
202
- if (addFunc === 'max') {
203
- let maxNum = Math.max.apply(
204
- null,
205
- depValues.length > 0 ? depValues : [0]
206
- )
207
-
208
- sums[index] = this.dealWithDataHtml(
209
- name,
210
- maxNum,
211
- showType,
212
- num,
213
- units,
214
- mainTarget
215
- )
216
- }
217
- //最小值
218
- if (addFunc === 'min') {
219
- let minNum = Math.min.apply(
220
- null,
221
- depValues.length > 0 ? depValues : [0]
222
- )
223
- sums[index] = this.dealWithDataHtml(
224
- name,
225
- minNum,
226
- showType,
227
- num,
228
- units,
229
- mainTarget
230
- )
231
- }
232
-
233
- //公式计算
234
- if (addFunc === 'calcFunc') {
235
- const calcVal = this.dealCustomCalc(data, column.combinedOption)
236
- sums[index] = this.dealWithDataHtml(
237
- name,
238
- calcVal,
239
- showType,
240
- num,
241
- units,
242
- mainTarget
243
- )
244
- }
245
- } else if (calcProp.indexOf(column.property) > -1) {
246
- const values = data.map((item) => Number(item[column.property]))
247
- }
248
- })
249
-
250
- return sums
251
- },
252
- //合计行
253
- handleSummary(summary) {
254
- return summary && !this.searchVal ? true : false
255
- },
256
- dealCustomCalc(data, calc) {
257
- let exp = calc.mathExp
258
- if (!exp) return null
259
- var reg = /([\[|\{]).*?\((.*?)\)[\}|\]]/g
260
- exp = exp.replace(reg, function() {
261
- var symbol = arguments[1],
262
- name = arguments[2]
263
- const prop = name.split('.')[1]
264
- const values = data.map((item) => Number(item[prop]))
265
- return values.join(',')
266
- })
267
- exp = exp.replace(/[|\[|\]]/g, '')
268
- exp = eval(`(${exp})`)
269
- if (exp === Infinity || isNaN(exp)) {
270
- exp = null
271
- }
272
- return exp
273
- },
274
- dealWithDataHtml(name, type, showType, num, units, mainTarget) {
275
- let { data, monCap } = this.dealWithData(type, showType, num, mainTarget)
276
- if (monCap) {
277
- return name + ':' + data + units + '\n' + monCap
278
- }
279
- return name + ':' + data + units
280
- },
281
- //处理数据
282
- dealWithData(data, showType, numfix = 0, mainTarget) {
283
- data = Number(data)
284
-
285
- let list = showType
286
- let num = {
287
- data: 0,
288
- monCap: '',
289
- }
290
- // 保留小数位
291
- if (list.includes('keepSmall')) {
292
- const fixData = data.toFixedRound(numfix)
293
- num.data = fixData
294
- if (mainTarget) {
295
- mainTarget = !mainTarget.startsWith('data.')
296
- ? 'data.' + mainTarget
297
- : mainTarget
298
- utils.setValueByConfigKey(this, { trget: mainTarget }, 'trget', data)
299
- }
300
- } else {
301
- if (mainTarget && data != null) {
302
- mainTarget = !mainTarget.startsWith('data.')
303
- ? 'data.' + mainTarget
304
- : mainTarget
305
- utils.setValueByConfigKey(
306
- this,
307
- { trget: mainTarget },
308
- 'trget',
309
- data.toFixedRound(4)
310
- )
311
- }
312
- }
313
-
314
- //百分比
315
- if (list.includes('percentage')) {
316
- num.data = Number(data * 100) + '%'
317
- }
318
- // 千分位
319
- if (list.includes('Micrometer')) {
320
- num.data = utils.thousandBit(data)
321
- }
322
- if (
323
- list.includes('keepSmall') &&
324
- list.includes('percentage') &&
325
- list.includes('Micrometer')
326
- ) {
327
- num.data =
328
- utils.thousandBit(Number(data * 100).toFixedRound(numfix)) + '%'
329
-
330
- return num
331
- }
332
- if (list.includes('keepSmall') && list.includes('percentage')) {
333
- num.data = Number(data * 100).toFixedRound(numfix) + '%'
334
-
335
- return num
336
- }
337
- if (list.includes('Micrometer') && list.includes('percentage')) {
338
- num.data = utils.thousandBit(Number(data * 100)) + '%'
339
- return num
340
- }
341
- if (list.includes('keepSmall') && list.includes('Micrometer')) {
342
- num.data = utils.thousandBit(data.toFixedRound(numfix))
343
- }
344
-
345
- // 货币大写
346
- if (list.includes('monCap')) {
347
- num = {
348
- data: data,
349
- monCap: utils.convertCurrency(data),
350
- }
351
- return num
352
- }
353
-
354
- return num
355
- },
356
55
  getExpandArr(data, type) {
357
56
  if (type === 'expand' && data) {
358
57
  let arr = []
@@ -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,7 +77,6 @@ export default {
80
77
  pageSize: 30,
81
78
  total: 0,
82
79
  },
83
- total: 0,
84
80
  rows: [],
85
81
  queryParam: {},
86
82
  allSummaryConfig: {},
@@ -88,16 +84,15 @@ export default {
88
84
  summaryTableData: [],
89
85
  needRequestTotal: false, // 需不需要后端统计列表全部数据
90
86
  tableDataTotal: {},
91
- loadingTotal: false //统计按钮加载中
92
87
  }
93
88
  },
94
89
  watch: {
95
- formKey: function(newVal) {
90
+ formKey: function (newVal) {
96
91
  if (newVal) {
97
92
  this.init()
98
93
  }
99
94
  },
100
- 'tableData.selectRows': function(newVal) {
95
+ 'tableData.selectRows': function (newVal) {
101
96
  if (newVal.length > 0) {
102
97
  let me_ = this
103
98
  me_.uploadParams.id = []
@@ -165,29 +160,7 @@ export default {
165
160
  deep: true,
166
161
  },
167
162
  },
168
- created() {
169
- if (this.queryView.jsScript) {
170
- // 执行js脚本
171
- this.handleDiyScript(this.queryView.jsScript)
172
- }
173
- },
174
163
  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
- },
191
164
  handelBindFiledValua() {
192
165
  //数据视图控件
193
166
  let _me = this
@@ -236,7 +209,7 @@ export default {
236
209
  selectList[i].selectValue = value
237
210
 
238
211
  //添加监听
239
- pInst.$watch(path, function(newVal, oldVal) {
212
+ pInst.$watch(path, function (newVal, oldVal) {
240
213
  _.debounce(() => {
241
214
  if (newVal !== oldVal) {
242
215
  _me.queryViewOptions.selectList[i].selectValue = newVal
@@ -380,7 +353,7 @@ export default {
380
353
  this.$router.push(url)
381
354
  },
382
355
 
383
- handleSizeChange: function(size) {
356
+ handleSizeChange: function (size) {
384
357
  //每页下拉显示数据
385
358
  this.pagination.pageSize = size
386
359
  if (this.$refs.queryViewList) {
@@ -389,7 +362,7 @@ export default {
389
362
  this.search()
390
363
  }
391
364
  },
392
- handleCurrentChange: function(currentPage) {
365
+ handleCurrentChange: function (currentPage) {
393
366
  //点击第几页
394
367
  this.pagination.page = currentPage
395
368
  if (this.$refs.queryViewList) {
@@ -399,112 +372,14 @@ export default {
399
372
  }
400
373
  },
401
374
  //回车查询
402
- searchEnterFun: function(e) {
375
+ searchEnterFun: function (e) {
403
376
  let keyCode = window.event ? e.keyCode : e.which
404
377
  if (keyCode == 13) {
405
378
  this.pagination.page = 1
406
379
  this.search()
407
380
  }
408
381
  },
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) {
382
+ search(param, cb, isSearchBtn, needRequestTotal = false) {
508
383
  // 不需要请求后端接口统计列表数据
509
384
  this.needRequestTotal = needRequestTotal
510
385
  !param && (param = {})
@@ -512,35 +387,6 @@ export default {
512
387
  const dataTemplateQueryVo = {
513
388
  queryFilter: param,
514
389
  }
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
- }
544
390
  //保存查询参数,用于作为导出的查询参数
545
391
  if (this.queryViewOptions) {
546
392
  //关联查询字段
@@ -573,17 +419,13 @@ export default {
573
419
  })
574
420
  }
575
421
  this.$requestConfig
576
- .getQueryViewDataListWithoutTotal(param)
422
+ .getQueryViewDataList(param)
577
423
  .then((response) => {
578
424
  this.rows = response.rows
579
- // this.pagination.total = response.total
425
+ this.pagination.total = response.total
580
426
  this.pagination.page = response.page
581
427
  this.pagination.pageSize = response.pageSize
582
428
  this.filterOldSummaryValByType('currentPage')
583
- //每次请求后不再统计总数,而是在统计按钮中去统计,当数量统计过一次后,再重新设置到当前页
584
- if (this.total) {
585
- this.$set(this.pagination, 'total', this.total)
586
- }
587
429
  this.summaryTableData.push({
588
430
  project: '当前页汇总',
589
431
  key: 'currentPage',
@@ -603,31 +445,12 @@ export default {
603
445
  cb && cb()
604
446
  })
605
447
  },
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
- },
626
448
  getQueryFilter() {
627
449
  let operationMap = this.getSearchItems() //查询条件类型
628
450
  // let fieldQueryMap = this.getFieldQuery() //查询条件字段
629
451
  let specialMap = this.getSpecialMap() //获取特殊查询情况(自定义对话框)
630
452
  let querys = [] //查询条件
453
+ let queryFilter = {}
631
454
  let pageBean = { pageBean: this.pagination }
632
455
  let params = {
633
456
  sqlAlias: this.sqlAlias || this.queryView.sqlAlias,
@@ -635,10 +458,6 @@ export default {
635
458
  }
636
459
  params.pagination = pageBean
637
460
  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 }
642
461
  return params
643
462
  } else {
644
463
  for (var key in this.searchForm) {
@@ -703,10 +522,9 @@ export default {
703
522
  }
704
523
  }
705
524
  }
706
- if (this.$refs.queryViewList && this.$refs.queryViewList.querys) {
707
- querys.push(...this.$refs.queryViewList.querys)
708
- }
709
- return { pageBean: this.pagination, querys }
525
+ queryFilter = { pageBean: this.pagination, querys }
526
+ params.pagination = queryFilter
527
+ return params
710
528
  }
711
529
  },
712
530
  //获取查询条件类型
@@ -960,22 +778,15 @@ export default {
960
778
  let loadingInstance = Loading.service({ fullscreen: true }) //开始
961
779
  this.$requestConfig
962
780
  .querySqlViewExport(data)
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('正在导出,请稍后前往报表附件管理查看')
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)
976
787
  })
977
788
  .finally(() => {
978
- loadingInstance.close()
789
+ loadingInstance.close() // 结束
979
790
  this.dialogExportVisible = false
980
791
  })
981
792
  },
@@ -1286,34 +1097,5 @@ export default {
1286
1097
  this.search()
1287
1098
  })
1288
1099
  },
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
- },
1318
1100
  },
1319
1101
  }