three-trees-ui 1.0.69 → 1.0.70

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.
@@ -10,6 +10,7 @@ const axios = require('axios')
10
10
  const { saveAs } = require('file-saver')
11
11
  import _ from 'lodash'
12
12
  import { decode } from '@/util/base64'
13
+ import moment from 'moment'
13
14
 
14
15
  const req = function(url, data = {}, option = {}) {
15
16
  const requestData = {
@@ -41,6 +42,7 @@ export default {
41
42
  },
42
43
  data() {
43
44
  return {
45
+ defaultQuerys: [],
44
46
  treeQuerys: [],
45
47
  alias_new: 'statement',
46
48
  loading: false,
@@ -59,6 +61,8 @@ export default {
59
61
  displayFields: [],
60
62
  exportSellection: [],
61
63
  searchForm: {},
64
+ bindKey: {},
65
+ bindValue: {},
62
66
  queryForm: {
63
67
  queryData: '',
64
68
  },
@@ -112,7 +116,9 @@ export default {
112
116
  pageSize: 10,
113
117
  total: 1,
114
118
  },
119
+ lastPage: 1, //上一次输入的分页数、默认为1
115
120
  paginationLayout: 'total, sizes, prev, pager, next, jumper',
121
+ paginationLayoutWithoutTotal: 'sizes, prev, pager, next, jumper',
116
122
  total: 0,
117
123
  permission: {
118
124
  print: true,
@@ -222,6 +228,45 @@ export default {
222
228
  : 0.85 * window.innerHeight,
223
229
  needRequestTotal: false, // 需不需要后端统计列表全部数据
224
230
  tableDataTotal: {},
231
+ loadingTotal: false, // 统计按钮加载中
232
+ pageSizeArray: [
233
+ {
234
+ label: '10条/页',
235
+ value: 10,
236
+ },
237
+ {
238
+ label: '20条/页',
239
+ value: 20,
240
+ },
241
+ {
242
+ label: '30条/页',
243
+ value: 30,
244
+ },
245
+ {
246
+ label: '40条/页',
247
+ value: 40,
248
+ },
249
+ {
250
+ label: '50条/页',
251
+ value: 50,
252
+ },
253
+ {
254
+ label: '100条/页',
255
+ value: 100,
256
+ },
257
+ {
258
+ label: '200条/页',
259
+ value: 200,
260
+ },
261
+ {
262
+ label: '300条/页',
263
+ value: 300,
264
+ },
265
+ {
266
+ label: '500条/页',
267
+ value: 500,
268
+ },
269
+ ],
225
270
  }
226
271
  },
227
272
  watch: {
@@ -262,7 +307,7 @@ export default {
262
307
  immediate: true,
263
308
  },
264
309
  templateInfo: {
265
- handler: function(newVal) {
310
+ handler: async function(newVal) {
266
311
  if (newVal && newVal.id) {
267
312
  let _me = this
268
313
  _me.templateInfo = newVal
@@ -335,7 +380,7 @@ export default {
335
380
  )
336
381
  params.pagination.querys = querys
337
382
  }
338
- let defaultQuery = this.buildDefaultQuerys()
383
+ let defaultQuery = await this.newBuildDefaultQuerys()
339
384
  if (defaultQuery.length > 0) {
340
385
  if (params.pagination.querys) {
341
386
  params.pagination.querys.concat(defaultQuery)
@@ -486,11 +531,31 @@ export default {
486
531
  this_.calcScriptBtnPermission()
487
532
  })
488
533
  this.$emit('afterMounted')
534
+ if (this.templateInfo.jsScript) {
535
+ // 执行js脚本
536
+ this.handleDiyScript(this.templateInfo.jsScript)
537
+ }
489
538
  // setTimeout(() => {
490
539
  // this.$refs.multipleTemplateTable.handleFilterChange(this.filterMap)
491
540
  // }, 100)
492
541
  },
493
542
  methods: {
543
+ handleDiyScript(scriptValue) {
544
+ //执行前置脚本内容
545
+ const _this = this
546
+ // 用户信息
547
+ const account = this.$requestConfig.getAccount()
548
+ const userId = this.$requestConfig.getUserId()
549
+ const userName = this.$requestConfig.getUsername()
550
+ const preScript = `const scriptFunction = function(_this, account, userId, userName){
551
+ ${scriptValue}
552
+ };`
553
+ try {
554
+ eval(`${preScript}scriptFunction(_this, account, userId, userName);`)
555
+ } catch (err) {
556
+ this.$message.error(`脚本事件执行错误:${err}`)
557
+ }
558
+ },
494
559
  //因为row.id_ 或row.id可能会有重复,所以加随机值使其唯一
495
560
  getRowKey(row) {
496
561
  /** 检查row.id是否有重复的缓存对象 */
@@ -1342,8 +1407,9 @@ export default {
1342
1407
  }
1343
1408
  for (let x = 0; x < display.length; x++) {
1344
1409
  let item = JSON.parse(display[x])
1345
- if (this.rows[index][item.name]) {
1346
- this.QRCodeDesc.push(item.desc + ':' + this.rows[index][item.name])
1410
+ if (this.rows[index][item.name] || this.rows[index][item.fieldsAlias]) {
1411
+ const qrCode = this.rows[index][item.name] || this.rows[index][item.fieldsAlias]
1412
+ this.QRCodeDesc.push(`${item.desc}:${qrCode}`)
1347
1413
  }
1348
1414
  }
1349
1415
  this.mobileFormAlias = mobileFormAlias
@@ -1359,8 +1425,8 @@ export default {
1359
1425
  this.$refs.multipleTemplateTable.handleFilterChange()
1360
1426
  },
1361
1427
  handleCurrentChange: function(currentPage) {
1362
- //点击第几页
1363
- this.pagination.page = currentPage
1428
+ //点击第几页,如果当前页数没有值,则默认用上一次页数
1429
+ this.pagination.page = currentPage ? currentPage : this.lastPage
1364
1430
  this.$refs.multipleTemplateTable.handleFilterChange()
1365
1431
  },
1366
1432
  getParam(str) {
@@ -1408,7 +1474,7 @@ export default {
1408
1474
  return params
1409
1475
  },
1410
1476
  //列表数据查询入口
1411
- search(param, cb, isSearchBtn, needRequestTotal = false) {
1477
+ async search(param, cb, isSearchBtn, needRequestTotal = false) {
1412
1478
  // 不需要请求后端接口统计列表数据
1413
1479
  this.needRequestTotal = needRequestTotal
1414
1480
  // 如果是高级查询,页码重置为首页
@@ -1521,8 +1587,7 @@ export default {
1521
1587
  }
1522
1588
  //初始化时,把查询字段和筛选字段的默认值也加进去
1523
1589
  if (this.isInit) {
1524
- this.isInit = false
1525
- this.handleInitQuery(params)
1590
+ await this.handleInitQuery(params)
1526
1591
  }
1527
1592
  //数据视图控件
1528
1593
  if (this.dataView) {
@@ -1539,12 +1604,196 @@ export default {
1539
1604
  params.taskType = this_.taskType
1540
1605
  params.defKey = this_.defKey
1541
1606
  }
1607
+ // 检查是否有必填字段
1608
+ if (this.checkHaveRequired && this.isInit) {
1609
+ this.$refs.multipleTemplateTable.showAdvancedSearch = true
1610
+ }
1611
+ // 查询字段 校验是否必填,如果是必填没数据,需返回提示
1612
+ let errorMsg = this.validateSearchRequired(params.pagination.querys)
1613
+ if (errorMsg) {
1614
+ !this.isInit && this.$message.warning(errorMsg)
1615
+ cb && cb()
1616
+ this.isInit = false
1617
+ this.$emit('data-reload-success')
1618
+ return
1619
+ }
1620
+ this.isInit = false
1542
1621
  if ($.isEmptyObject(this.searchForm)) {
1543
1622
  this.getBpmTemplateByPagination(params, cb)
1544
1623
  } else {
1545
1624
  this.getBpmTemplateByPagination(params, cb)
1546
1625
  }
1547
1626
  },
1627
+ // 校验查询字段必填
1628
+ validateSearchRequired(querys) {
1629
+ let errorMsg = ''
1630
+ let conditions = JSON.parse(this.templateInfo.conditionField)
1631
+ if (conditions) {
1632
+ conditions.forEach((item) => {
1633
+ if (item.isRequired) {
1634
+ let queryPre = this.getQueryPre(conditions, item.name)
1635
+ let index = querys.findIndex((k) => {
1636
+ return k.property == queryPre + item.name
1637
+ })
1638
+ if (index == -1) {
1639
+ errorMsg = `字段【${item.cm}】为必填查询字段,不能为空!`
1640
+ }
1641
+ }
1642
+ })
1643
+ }
1644
+ return errorMsg
1645
+ },
1646
+ checkHaveRequired() {
1647
+ let haveRequired = false
1648
+ try {
1649
+ let conditions = JSON.parse(this.templateInfo.conditionField)
1650
+ if (conditions) {
1651
+ haveRequired = conditions.some((item) => {
1652
+ return item.isRequired
1653
+ })
1654
+ }
1655
+ } catch (e) {
1656
+ console.log(e)
1657
+ }
1658
+ return haveRequired
1659
+ },
1660
+ searchCountTotal(param, cb, isSearchBtn, needRequestTotal = false) {
1661
+ // 不需要请求后端接口统计列表数据
1662
+ this.needRequestTotal = needRequestTotal
1663
+ // 如果是高级查询,页码重置为首页
1664
+ if (isSearchBtn) {
1665
+ this.pagination.page = 1
1666
+ }
1667
+ let params = {}
1668
+ //判断为合并查询还是高级查询
1669
+ let showAdvancedSearch = this.$refs.multipleTemplateTable
1670
+ ? this.$refs.multipleTemplateTable.showAdvancedSearch
1671
+ : false
1672
+ //高级查询
1673
+ if (showAdvancedSearch) {
1674
+ params = this.getQueryFilter()
1675
+ } else {
1676
+ //合并查询
1677
+ // 快速查询时,需处理添加快速查询字段前缀
1678
+ param = this.handleQuickParams(param)
1679
+ params = this.getConditionQuery(param)
1680
+ }
1681
+ this.templateSearchQuery =
1682
+ (params.pagination && params.pagination.querys) || []
1683
+ if (!params.pagination) {
1684
+ params.pagination = {}
1685
+ }
1686
+ if (!params.pagination.querys) {
1687
+ params.pagination.querys = []
1688
+ }
1689
+ //处理排序字段
1690
+ if (param && param.sorter && param.sorter.length > 0) {
1691
+ let sortField = JSON.parse(this.templateInfo.sortField)
1692
+ params.pagination = params.pagination || {}
1693
+ params.pagination.sorter = []
1694
+ param.sorter.forEach((s) => {
1695
+ let prefix = this.getColPreFix(sortField, s.property)
1696
+ let queryPre = this.getQueryPre(sortField, s.property)
1697
+ // 关联表时需特殊处理
1698
+ let relevancyProperty = this.getRelevancyProperty(
1699
+ sortField,
1700
+ s.property
1701
+ )
1702
+ if (relevancyProperty) {
1703
+ s.property = relevancyProperty
1704
+ }
1705
+ params.pagination.sorter.push({
1706
+ property: queryPre + prefix + s.property,
1707
+ direction: s.direction,
1708
+ })
1709
+ })
1710
+ } else if (this.templateInfo.sortField) {
1711
+ let sortField = JSON.parse(this.templateInfo.sortField)
1712
+ let sorter = []
1713
+ for (let x = 0; x < sortField.length; x++) {
1714
+ const s = sortField[x]
1715
+ // 默认排序字段的排序方向为空或者不为指定值时放弃
1716
+ if (!s.sort || (s.sort != 'ASC' && s.sort != 'DESC')) {
1717
+ continue
1718
+ }
1719
+ let prefix = this.getColPreFix(sortField, s.name)
1720
+ let queryPre = this.getQueryPre(sortField, s.name)
1721
+ if (!queryPre) {
1722
+ if (s.joinTableField && s.tableName) {
1723
+ prefix = `${s.tableName}.${prefix}`
1724
+ } else {
1725
+ prefix = `t.${prefix}`
1726
+ }
1727
+ }
1728
+ sorter.push({
1729
+ property: queryPre + prefix + s.name,
1730
+ direction: s.sort,
1731
+ })
1732
+ }
1733
+ params.pagination.sorter = sorter
1734
+ } else if (param.querys && param.querys.length > 0) {
1735
+ params.pagination.querys.concat(param.querys)
1736
+ }
1737
+
1738
+ if (params.pagination && params.pagination.querys) {
1739
+ let tempQueryS = []
1740
+ let betweenConditions = {}
1741
+ params.pagination.querys.forEach((q) => {
1742
+ if (
1743
+ q.value != undefined &&
1744
+ (q.operation != 'BETWEEN' || q.value.constructor == Array)
1745
+ ) {
1746
+ tempQueryS.push(q)
1747
+ } else if (q.value) {
1748
+ let conditions = q
1749
+ if (betweenConditions[q.property]) {
1750
+ conditions = betweenConditions[q.property]
1751
+ conditions.value = [conditions.value]
1752
+ conditions.value.push(q.value)
1753
+ }
1754
+ betweenConditions[q.property] = conditions
1755
+ }
1756
+ })
1757
+ for (const key in betweenConditions) {
1758
+ tempQueryS.push(betweenConditions[key])
1759
+ }
1760
+ params.pagination.querys = tempQueryS
1761
+ params.pagination.querys = params.pagination.querys
1762
+ ? params.pagination.querys.concat(this.treeQuerys)
1763
+ : this.treeQuerys
1764
+ }
1765
+ //把过滤树的条件也拼接进去
1766
+ if (this.treeQuerys && this.treeQuerys.length > 0) {
1767
+ params.pagination.querys = params.pagination.querys
1768
+ ? params.pagination.querys.concat(this.treeQuerys)
1769
+ : this.treeQuerys
1770
+ }
1771
+ //初始化时,把查询字段和筛选字段的默认值也加进去
1772
+ if (this.isInit) {
1773
+ this.isInit = false
1774
+ this.handleInitQuery(params)
1775
+ }
1776
+ //数据视图控件
1777
+ if (this.dataView) {
1778
+ this.handelBindFiledValua()
1779
+ params.refIdValue = this.dataView.refIdValue
1780
+ //关联查询字段
1781
+ if (this.dataView.selectList && this.dataView.selectList.length > 0) {
1782
+ params.selectList = this.dataView.selectList
1783
+ }
1784
+ }
1785
+ const this_ = this
1786
+ if (this_.isJoinFlow) {
1787
+ params.isJoinFlow = true
1788
+ params.taskType = this_.taskType
1789
+ params.defKey = this_.defKey
1790
+ }
1791
+ if ($.isEmptyObject(this.searchForm)) {
1792
+ this.getBpmTemplateByPaginationTotal(params, cb)
1793
+ } else {
1794
+ this.getBpmTemplateByPaginationTotal(params, cb)
1795
+ }
1796
+ },
1548
1797
  // 处理快速查询参数
1549
1798
  handleQuickParams(param) {
1550
1799
  if (param && param.querys && param.querys.length) {
@@ -1563,20 +1812,24 @@ export default {
1563
1812
  }
1564
1813
  return param
1565
1814
  },
1566
- handleInitQuery(params) {
1815
+ async handleInitQuery(params) {
1567
1816
  const conditionFields = JSON.parse(this.templateInfo.conditionField) || []
1568
1817
  const querys = []
1569
- conditionFields.forEach((item) => {
1818
+ for (let i = 0; i < conditionFields.length; i++) {
1819
+ let item = conditionFields[i]
1570
1820
  if (item.defaultValue) {
1821
+ let defaultValue = item.isScriptDefault
1822
+ ? await this.getScriptDefaultValue(item.defaultValue)
1823
+ : item.defaultValue
1571
1824
  querys.push({
1572
1825
  property: `${item.queryPre || ''}${item.colPrefix}${item.name}`,
1573
- value: item.defaultValue,
1826
+ value: defaultValue,
1574
1827
  operation: item.qt.toUpperCase(),
1575
1828
  relation: 'AND',
1576
1829
  group: 'defaultQuery',
1577
1830
  })
1578
1831
  }
1579
- })
1832
+ }
1580
1833
  const filteringFields = JSON.parse(this.templateInfo.filteringField) || []
1581
1834
  filteringFields.forEach((item) => {
1582
1835
  if (item.defaultValue && item.defaultValue.length) {
@@ -1629,13 +1882,15 @@ export default {
1629
1882
  })
1630
1883
  }
1631
1884
  this.$requestConfig
1632
- .getDataTemplateDataList(dataTemplateQueryVo)
1885
+ .getDataTemplateDataListWithoutTotal(dataTemplateQueryVo)
1633
1886
  .then((response) => {
1634
1887
  this.rows = response.rows
1635
- this.total = response.total
1636
1888
  this.$set(this.pagination, 'page', response.page)
1637
1889
  this.$set(this.pagination, 'pageSize', response.pageSize)
1638
- this.$set(this.pagination, 'total', response.total)
1890
+ //每次请求后不再统计总数,而是在统计按钮中去统计,当数量统计过一次后,再重新设置到当前页
1891
+ if (this.total) {
1892
+ this.$set(this.pagination, 'total', this.total)
1893
+ }
1639
1894
  this.$set(this, 'flowBtnPermission', {})
1640
1895
  this.$emit('data-reload-success')
1641
1896
  if (response.summary && response.summary.length) {
@@ -1659,6 +1914,46 @@ export default {
1659
1914
  cb2 && cb2()
1660
1915
  })
1661
1916
  },
1917
+ getBpmTemplateByPaginationTotal(params, cb1, cb2) {
1918
+ const dataTemplateQueryVo = {
1919
+ templateId: params.templateId,
1920
+ queryFilter: params.pagination,
1921
+ }
1922
+ if (params.isJoinFlow && params.taskType && params.defKey) {
1923
+ dataTemplateQueryVo.isJoinFlow = params.isJoinFlow
1924
+ dataTemplateQueryVo.taskType = params.taskType
1925
+ dataTemplateQueryVo.defKey = params.defKey
1926
+ }
1927
+ if (params.selectField) {
1928
+ dataTemplateQueryVo.selectField = params.selectField
1929
+ dataTemplateQueryVo.selectValue = params.selectValue
1930
+ }
1931
+ if (params.selectList) {
1932
+ dataTemplateQueryVo.selectList = params.selectList
1933
+ }
1934
+ dataTemplateQueryVo.refIdValue = params.refIdValue
1935
+ this.curSelectParams = dataTemplateQueryVo
1936
+ //加载按钮
1937
+ this.loadingTotal = true
1938
+ this.$requestConfig
1939
+ .getDataTemplateDataListWithTotal(dataTemplateQueryVo)
1940
+ .then((response) => {
1941
+ //设置总数
1942
+ this.total = response.value
1943
+ this.$set(this.pagination, 'total', response.value)
1944
+ this.loadingTotal = false
1945
+ this.$emit('data-reload-success')
1946
+ this.$nextTick(() => {
1947
+ this.$refs.multipleTemplateTable &&
1948
+ this.$refs.multipleTemplateTable.doLayout()
1949
+ })
1950
+ })
1951
+ .finally(() => {
1952
+ this.loadingTotal = false
1953
+ cb1 && cb1()
1954
+ cb2 && cb2()
1955
+ })
1956
+ },
1662
1957
  getQueryFilter() {
1663
1958
  let operationMap = this.getSearchItems()
1664
1959
  let fieldTypeMap = this.getFieldType()
@@ -1675,6 +1970,12 @@ export default {
1675
1970
  params.pagination = pageBean
1676
1971
  if (!$.isEmptyObject(this.searchForm)) {
1677
1972
  let conditionField = utils.parseToJson(this.templateInfo.conditionField)
1973
+ //处理绑定字段
1974
+ this.bindValue = this.searchForm.bindValue || this.bindValue
1975
+ this.bindKey = this.searchForm.bindKey || this.bindKey
1976
+ //记录后再删除
1977
+ delete this.searchForm.bindValue
1978
+ delete this.searchForm.bindKey
1678
1979
  for (let key in this.searchForm) {
1679
1980
  if (
1680
1981
  typeof this.searchForm[key] != 'undefined' &&
@@ -1712,6 +2013,16 @@ export default {
1712
2013
  if (fieldTypeMap[key] && fieldTypeMap[key] == 'number') {
1713
2014
  value = parseFloat(this.searchForm[key])
1714
2015
  }
2016
+ //在表单列表的查询字段中添加的对话框控件 此处逻辑对应 packages/CustomDialog/src/customDialog.vue:1920行
2017
+ if (
2018
+ this.bindValue &&
2019
+ Object.keys(this.bindValue).length &&
2020
+ this.bindValue[key] &&
2021
+ Object.keys(this.bindKey).length
2022
+ ) {
2023
+ //获得绑定字段的值
2024
+ value = this.bindValue[key][this.bindKey[key]]
2025
+ }
1715
2026
  let queryPre = this.getQueryPre(conditionField, key)
1716
2027
  querys.push({
1717
2028
  property: queryPre + key,
@@ -1724,7 +2035,14 @@ export default {
1724
2035
  }
1725
2036
  }
1726
2037
  this.clearQueryByGroupName(querys, 'filter')
1727
- // 将过滤条件添加查询参数数组中
2038
+ // 将过滤条件添加查询参数数组中,不是高级查询时使用
2039
+ if (
2040
+ this.$refs.multipleTemplateTable &&
2041
+ this.$refs.multipleTemplateTable.querys &&
2042
+ !this.$refs.multipleTemplateTable.showAdvancedSearch
2043
+ ) {
2044
+ querys.push(...this.$refs.multipleTemplateTable.querys)
2045
+ }
1728
2046
  this.buildFilterParams(querys)
1729
2047
  }
1730
2048
  // 判断table中是否含有filter查询
@@ -2333,7 +2651,9 @@ export default {
2333
2651
  handledUrlParams(url, row, fieldName) {
2334
2652
  if (this.templateInfo.displayField) {
2335
2653
  let displayFields = JSON.parse(this.templateInfo.displayField)
2336
- let params = this.getParentId(displayFields, fieldName, 'name')
2654
+ let params =
2655
+ this.getParentId(displayFields, fieldName, 'name') ||
2656
+ this.getParentId(displayFields, fieldName, 'fieldsAlias')
2337
2657
  if (params && params.urlParams && params.urlParams.length > 0) {
2338
2658
  let urlParams = params.urlParams
2339
2659
  let suffix = ''
@@ -2488,6 +2808,14 @@ export default {
2488
2808
  selectedQuery,
2489
2809
  ]
2490
2810
  }
2811
+ // 校验
2812
+ let errorMsg = this.validateSearchRequired(
2813
+ this.curSelectParams.queryFilter.querys
2814
+ )
2815
+ if (errorMsg) {
2816
+ this.$message.warning(errorMsg)
2817
+ return
2818
+ }
2491
2819
  //导出全部数据按钮
2492
2820
  if (type == 'all') {
2493
2821
  this.curSelectParams.queryFilter.querys = []
@@ -2500,24 +2828,30 @@ export default {
2500
2828
  id: this.templateInfo.id,
2501
2829
  params: this.curSelectParams,
2502
2830
  })
2503
- .then(
2504
- ({ data, headers }) => {
2505
- const fileName = decodeURIComponent(
2506
- headers['content-disposition'].split(';')[1].split('filename=')[1]
2507
- )
2508
- const blob = new Blob([data])
2509
- saveAs(blob, fileName)
2510
- loadingInstance.close() // 结束
2511
- },
2512
- (e) => {
2513
- loadingInstance.close() // 结束
2514
- let enc = new TextDecoder('utf-8')
2515
- let uint8_msg = JSON.parse(
2516
- enc.decode(new Uint8Array(e.response.data))
2517
- )
2518
- this.$message.error(uint8_msg.message)
2519
- }
2520
- )
2831
+ // .then(
2832
+ // ({ data, headers }) => {
2833
+ // const fileName = decodeURIComponent(
2834
+ // headers['content-disposition'].split(';')[1].split('filename=')[1]
2835
+ // )
2836
+ // const blob = new Blob([data])
2837
+ // saveAs(blob, fileName)
2838
+ // loadingInstance.close() // 结束
2839
+ // },
2840
+ // (e) => {
2841
+ // loadingInstance.close() // 结束
2842
+ // let enc = new TextDecoder('utf-8')
2843
+ // let uint8_msg = JSON.parse(
2844
+ // enc.decode(new Uint8Array(e.response.data))
2845
+ // )
2846
+ // this.$message.error(uint8_msg.message)
2847
+ // }
2848
+ // )
2849
+ .then(() => {
2850
+ this.$message.success('正在导出,请稍后前往报表附件管理查看')
2851
+ })
2852
+ .finally(() => {
2853
+ loadingInstance.close()
2854
+ })
2521
2855
  },
2522
2856
  importCommand(params) {
2523
2857
  switch (params.command) {
@@ -3124,7 +3458,7 @@ export default {
3124
3458
  }
3125
3459
  this.dialogSubVisible = true
3126
3460
  },
3127
- nodeClick(node) {
3461
+ async nodeClick(node) {
3128
3462
  this.pagination.page = 1
3129
3463
  //每次点击过滤树,应该把右边的table 与分页全部重置为初始
3130
3464
 
@@ -3159,7 +3493,9 @@ export default {
3159
3493
  pageBean.querys.push({
3160
3494
  property: item.isMain
3161
3495
  ? `t.${item.key_.oldTableField}`
3162
- : `${item.key_.tableName}.${item.key_.oldTableField}`,
3496
+ : `${item.key_.alias ? item.key_.alias : item.key_.tableName}.${
3497
+ item.key_.oldTableField
3498
+ }`,
3163
3499
  value,
3164
3500
  group: 'main',
3165
3501
  operation,
@@ -3188,7 +3524,7 @@ export default {
3188
3524
  params.taskType = this_.taskType
3189
3525
  params.defKey = this_.defKey
3190
3526
  }
3191
- this.handleInitQuery(params)
3527
+ await this.handleInitQuery(params)
3192
3528
  this.getBpmTemplateByPagination(params)
3193
3529
  },
3194
3530
  filterChange(filters) {
@@ -3844,7 +4180,7 @@ export default {
3844
4180
  }
3845
4181
  this.$requestConfig
3846
4182
  .batchUpdateTemplateData(data)
3847
- .then((data) => {
4183
+ .then(async (data) => {
3848
4184
  if (data.state) {
3849
4185
  this.$message({
3850
4186
  type: 'success',
@@ -3854,8 +4190,9 @@ export default {
3854
4190
  // 以服务的方式调用的 Loading 需要异步关闭
3855
4191
  loadingInstance.close()
3856
4192
  })
4193
+ let defaultValue = await this.newBuildDefaultQuerys()
3857
4194
  this.search({
3858
- querys: this.buildDefaultQuerys() || [],
4195
+ querys: defaultValue || [],
3859
4196
  })
3860
4197
  // 更新成功后需执行后置js
3861
4198
  if (afterScriptValue) {
@@ -3969,6 +4306,120 @@ export default {
3969
4306
  })
3970
4307
  return querys
3971
4308
  },
4309
+ async newBuildDefaultQuerys(isSetSearchForm = true) {
4310
+ let this_ = this
4311
+ let querys = []
4312
+ let conditions = JSON.parse(this_.templateInfo.conditionField)
4313
+ //条件字段默认值判断
4314
+ for (let i = 0; i < conditions.length; i++) {
4315
+ let condition = conditions[i]
4316
+ if (condition.defaultValue) {
4317
+ let field = condition.colPrefix + condition.na
4318
+ let defaultValue = condition.isScriptDefault
4319
+ ? await this.getScriptDefaultValue(condition.defaultValue)
4320
+ : condition.defaultValue
4321
+ if (isSetSearchForm) {
4322
+ this_.$set(this_.searchForm, field, defaultValue)
4323
+ }
4324
+ let value = defaultValue
4325
+ if (condition.ty == 'number') {
4326
+ value = parseFloat(value)
4327
+ }
4328
+ querys.push({
4329
+ property: condition.queryPre ? condition.queryPre + field : field,
4330
+ value: value,
4331
+ group: 'main',
4332
+ operation: condition.qt.toUpperCase(),
4333
+ relation: 'AND',
4334
+ })
4335
+ }
4336
+ }
4337
+ //筛选字段默认值判断
4338
+
4339
+ if (this.parameterqQuerys) {
4340
+ let parameterQuerys = JSON.parse(Base64.decode(this.parameterqQuerys))
4341
+ if (parameterQuerys && parameterQuerys.length > 0) {
4342
+ parameterQuerys.forEach((query) => {
4343
+ let prefix = this.templateInfo.isExternal === 1 ? '' : 'F_'
4344
+ query.property = prefix + query.property
4345
+ if (isSetSearchForm) {
4346
+ this_.$set(this_.searchForm, query.property, query.value)
4347
+ }
4348
+ querys.push(query)
4349
+ })
4350
+ }
4351
+ }
4352
+ let filters = JSON.parse(this_.templateInfo.filteringField)
4353
+ filters.forEach((filter) => {
4354
+ if (filter.defaultValue && filter.defaultValue.length > 0) {
4355
+ this_.filterMap[filter.name] = filter.defaultValue
4356
+ filter.defaultValue.forEach((val) => {
4357
+ querys.push({
4358
+ property: `${filter.queryPre || ''}${filter.colPrefix}${
4359
+ filter.name
4360
+ }`,
4361
+ value: val,
4362
+ group: 'defVal_' + filter.name,
4363
+ operation: 'EQUAL',
4364
+ relation: 'OR',
4365
+ })
4366
+ })
4367
+ }
4368
+ })
4369
+ this_.$on('afterMounted', () => {
4370
+ const tab = document.getElementById(this_.templateInfo.alias)
4371
+ if (tab && tab.__vue__) {
4372
+ let headerColumns = tab.__vue__.$refs.tableHeader
4373
+ ? tab.__vue__.$refs.tableHeader.columns
4374
+ : []
4375
+ headerColumns.forEach((column) => {
4376
+ if (this_.filterMap.hasOwnProperty(column.property)) {
4377
+ this_.filterMap[column.property].forEach((val) => {
4378
+ column.filteredValue.push(val)
4379
+ })
4380
+ }
4381
+ })
4382
+ }
4383
+ })
4384
+ this.defaultQuerys = querys
4385
+ return querys
4386
+ },
4387
+ getScriptDefaultValue(scriptValue) {
4388
+ return new Promise((resolve) => {
4389
+ //执行前置脚本内容
4390
+ const _this = this
4391
+ // 用户信息
4392
+ const account = this.$requestConfig.getAccount()
4393
+ const userId = this.$requestConfig.getUserId()
4394
+ const userName = this.$requestConfig.getUsername()
4395
+ const _moment = moment
4396
+ const preScript = `const scriptFunction = function(_this, account, userId, userName, _moment){
4397
+ ${scriptValue}
4398
+ };`
4399
+ let result = ''
4400
+ try {
4401
+ result = eval(
4402
+ `${preScript}scriptFunction(_this, account, userId, userName, _moment);`
4403
+ )
4404
+ if (result && result.then && typeof result.then === 'function') {
4405
+ result.then(
4406
+ (t) => {
4407
+ resolve(t)
4408
+ },
4409
+ (fail) => {
4410
+ //接口返回失败则终止按钮操作,并输出错误信息
4411
+ resolve('')
4412
+ }
4413
+ )
4414
+ } else {
4415
+ resolve(result)
4416
+ }
4417
+ } catch (err) {
4418
+ resolve('')
4419
+ this.$message.error(`查询值默认脚本事件执行错误:${err}`)
4420
+ }
4421
+ })
4422
+ },
3972
4423
  handleClose() {
3973
4424
  this.dataViewDialogVisible = false
3974
4425
  },
@@ -4103,7 +4554,8 @@ export default {
4103
4554
  this.printDetail(parameter.templateId, parameter.id, parameter.action)
4104
4555
  } else if (btnAlias == 'sub' && this.checkSelect()) {
4105
4556
  this.showSubList(this.tableData.selectRows[0].id_, parameter)
4106
- } else if (btnAlias == 'js' && this.checkSelect()) {
4557
+ } else if (btnAlias == 'js') {
4558
+ if (parameter.needValidateSelect && !this.checkSelect()) return
4107
4559
  this.customEvilJS(this.tableData.selectRows[0], parameter.jsValue)
4108
4560
  } else if (
4109
4561
  btnAlias == 'startFlow' &&
@@ -4655,6 +5107,30 @@ export default {
4655
5107
  )
4656
5108
  : customColumns
4657
5109
  },
5110
+ countPageTotal() {
5111
+ this.searchCountTotal(this.getParam())
5112
+ },
5113
+ switchPage(type) {
5114
+ if (type == 'prev') this.pagination.page--
5115
+ if (type == 'next') this.pagination.page++
5116
+ this.handleCurrentChange(this.pagination.page)
5117
+ },
5118
+ handleInput(value) {
5119
+ if (!value) {
5120
+ return
5121
+ }
5122
+ // 使用正则表达式匹配正整数
5123
+ const regex = /^[1-9]\d*$/
5124
+
5125
+ // 如果输入的值不符合正整数的模式,则将其重置为1
5126
+ if (!regex.test(value)) {
5127
+ //如果上一次输入的页数有值,则用上一次输入的页数,否则默认为1
5128
+ this.pagination.page = this.lastPage ? this.lastPage : 1
5129
+ } else {
5130
+ //本次分页数,赋值给上一次分页数
5131
+ this.lastPage = this.pagination.page
5132
+ }
5133
+ },
4658
5134
  },
4659
5135
  // asyncComputed: {
4660
5136
  // showDraftList() {