three-trees-ui 1.0.57 → 1.0.59

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-trees-ui",
3
- "version": "1.0.57",
3
+ "version": "1.0.59",
4
4
  "publicPath": "/ui",
5
5
  "author": "hotent",
6
6
  "private": false,
@@ -962,6 +962,10 @@
962
962
  oldTableField,
963
963
  fieldDesc,
964
964
  } = tableFieldItem
965
+ if (!summaryMethod) {
966
+ sums[index] = ''
967
+ return
968
+ }
965
969
  let field = ''
966
970
  if (oldTableField) {
967
971
  // 数据列表
@@ -1,8 +1,10 @@
1
1
  import SubPagination from '../services/SubPagination.js'
2
+ import utils from '../utils.js'
2
3
 
3
4
  export default {
4
5
  data() {
5
6
  return {
7
+ searchVal: '', //搜索关键字
6
8
  fillOrg: {},
7
9
  fillOrgConfMap: {},
8
10
  transitionIndex: -1,
@@ -52,6 +54,287 @@ export default {
52
54
  }
53
55
  },
54
56
  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
+ dealWithDataHtml(name, type, showType, num, units, mainTarget) {
257
+ let { data, monCap } = this.dealWithData(type, showType, num, mainTarget)
258
+ if (monCap) {
259
+ return name + ':' + data + units + '\n' + monCap
260
+ }
261
+ return name + ':' + data + units
262
+ },
263
+ //处理数据
264
+ dealWithData(data, showType, numfix = 0, mainTarget) {
265
+ data = Number(data)
266
+
267
+ let list = showType
268
+ let num = {
269
+ data: 0,
270
+ monCap: '',
271
+ }
272
+ // 保留小数位
273
+ if (list.includes('keepSmall')) {
274
+ const fixData = data.toFixedRound(numfix)
275
+ num.data = fixData
276
+ if (mainTarget) {
277
+ mainTarget = !mainTarget.startsWith('data.')
278
+ ? 'data.' + mainTarget
279
+ : mainTarget
280
+ utils.setValueByConfigKey(this, { trget: mainTarget }, 'trget', data)
281
+ }
282
+ } else {
283
+ if (mainTarget && data != null) {
284
+ mainTarget = !mainTarget.startsWith('data.')
285
+ ? 'data.' + mainTarget
286
+ : mainTarget
287
+ utils.setValueByConfigKey(
288
+ this,
289
+ { trget: mainTarget },
290
+ 'trget',
291
+ data.toFixedRound(4)
292
+ )
293
+ }
294
+ }
295
+
296
+ //百分比
297
+ if (list.includes('percentage')) {
298
+ num.data = Number(data * 100) + '%'
299
+ }
300
+ // 千分位
301
+ if (list.includes('Micrometer')) {
302
+ num.data = utils.thousandBit(data)
303
+ }
304
+ if (
305
+ list.includes('keepSmall') &&
306
+ list.includes('percentage') &&
307
+ list.includes('Micrometer')
308
+ ) {
309
+ num.data =
310
+ utils.thousandBit(Number(data * 100).toFixedRound(numfix)) + '%'
311
+
312
+ return num
313
+ }
314
+ if (list.includes('keepSmall') && list.includes('percentage')) {
315
+ num.data = Number(data * 100).toFixedRound(numfix) + '%'
316
+
317
+ return num
318
+ }
319
+ if (list.includes('Micrometer') && list.includes('percentage')) {
320
+ num.data = utils.thousandBit(Number(data * 100)) + '%'
321
+ return num
322
+ }
323
+ if (list.includes('keepSmall') && list.includes('Micrometer')) {
324
+ num.data = utils.thousandBit(data.toFixedRound(numfix))
325
+ }
326
+
327
+ // 货币大写
328
+ if (list.includes('monCap')) {
329
+ num = {
330
+ data: data,
331
+ monCap: utils.convertCurrency(data),
332
+ }
333
+ return num
334
+ }
335
+
336
+ return num
337
+ },
55
338
  getExpandArr(data, type) {
56
339
  if (type === 'expand' && data) {
57
340
  let arr = []
@@ -11,7 +11,7 @@ const { saveAs } = require('file-saver')
11
11
  import _ from 'lodash'
12
12
  import { decode } from '@/util/base64'
13
13
 
14
- const req = function(url, data = {}, option = {}) {
14
+ const req = function (url, data = {}, option = {}) {
15
15
  const requestData = {
16
16
  url: url,
17
17
  data: data,
@@ -253,7 +253,7 @@ export default {
253
253
  deep: true,
254
254
  },
255
255
  ents: {
256
- handler: function(newVal, oldValue) {
256
+ handler: function (newVal, oldValue) {
257
257
  if (newVal && newVal.length >= 1 && newVal != oldValue) {
258
258
  this.getSubData(this, this.refId)
259
259
  }
@@ -262,7 +262,7 @@ export default {
262
262
  immediate: true,
263
263
  },
264
264
  templateInfo: {
265
- handler: function(newVal) {
265
+ handler: function (newVal) {
266
266
  if (newVal && newVal.id) {
267
267
  let _me = this
268
268
  _me.templateInfo = newVal
@@ -382,13 +382,13 @@ export default {
382
382
  deep: true,
383
383
  immediate: true,
384
384
  },
385
- currentTabName: function(newVal) {
385
+ currentTabName: function (newVal) {
386
386
  if (newVal) {
387
387
  this.querySubValue = ''
388
388
  }
389
389
  },
390
390
  rows: {
391
- handler: function(newVal) {
391
+ handler: function (newVal) {
392
392
  if (this.templateInfo.defId) {
393
393
  let this_ = this
394
394
  let boAlias = this.templateInfo.boDefAlias
@@ -430,9 +430,8 @@ export default {
430
430
  if (val) {
431
431
  this.$nextTick(() => {
432
432
  if (document.getElementById('summaryDiv')) {
433
- this.summaryTableHeight = document.getElementById(
434
- 'summaryDiv'
435
- ).clientHeight
433
+ this.summaryTableHeight =
434
+ document.getElementById('summaryDiv').clientHeight
436
435
  }
437
436
  })
438
437
  }
@@ -443,7 +442,7 @@ export default {
443
442
  //如果当前页面被嵌入iframe里面不显示草稿
444
443
  return !this.isJoinFlow
445
444
  },
446
- navbarCollapseStyle: function() {
445
+ navbarCollapseStyle: function () {
447
446
  if (this.asideShow) {
448
447
  return { left: '200px' }
449
448
  }
@@ -482,7 +481,7 @@ export default {
482
481
  })
483
482
  this.handelBindFiledValua()
484
483
  let this_ = this
485
- this.$on('data-reload-success', function() {
484
+ this.$on('data-reload-success', function () {
486
485
  this_.calcScriptBtnPermission()
487
486
  })
488
487
  this.$emit('afterMounted')
@@ -808,7 +807,7 @@ export default {
808
807
  this.listSelectable = false
809
808
  }
810
809
  let _this = this
811
- setTimeout(function() {
810
+ setTimeout(function () {
812
811
  let tdDom = _this.$el.querySelector('td.right_menu')
813
812
  if (
814
813
  !tdDom ||
@@ -913,7 +912,7 @@ export default {
913
912
  selectList[i].selectValue = value
914
913
 
915
914
  //添加监听
916
- pInst.$watch(path, function(newVal, oldVal) {
915
+ pInst.$watch(path, function (newVal, oldVal) {
917
916
  // 监听中使用间隔请求,减少请求次数
918
917
  clearTimeout(this.timeout)
919
918
  this.timeout = setTimeout(() => {
@@ -936,7 +935,7 @@ export default {
936
935
  const value = utils.getValueByPath(pInst, path)
937
936
 
938
937
  bindList[i].fillValue = value
939
- pInst.$watch(path, function(newVal, oldVal) {
938
+ pInst.$watch(path, function (newVal, oldVal) {
940
939
  // 监听中使用间隔请求,减少请求次数
941
940
  clearTimeout(this.timeout)
942
941
  this.timeout = setTimeout(() => {
@@ -1194,7 +1193,7 @@ export default {
1194
1193
  }
1195
1194
  let msg = document.createElement('canvas')
1196
1195
 
1197
- this.$qrcode.toCanvas(msg, QRCodeurl, function(error) {
1196
+ this.$qrcode.toCanvas(msg, QRCodeurl, function (error) {
1198
1197
  console.error(error)
1199
1198
  })
1200
1199
  let _canvas = document.createElement('div')
@@ -1234,7 +1233,7 @@ export default {
1234
1233
  .generateAsync({
1235
1234
  type: 'blob',
1236
1235
  })
1237
- .then(function(content) {
1236
+ .then(function (content) {
1238
1237
  let eleLink = document.createElement('a')
1239
1238
  eleLink.download = '二维码.zip'
1240
1239
  eleLink.style.display = 'none'
@@ -1287,7 +1286,7 @@ export default {
1287
1286
  context.scale(2, 2)
1288
1287
  return html2canvas(document.querySelector(classs), {
1289
1288
  canvas: canvas2,
1290
- }).then(function(canvas) {
1289
+ }).then(function (canvas) {
1291
1290
  resolve(canvas)
1292
1291
  })
1293
1292
  })
@@ -1329,7 +1328,7 @@ export default {
1329
1328
  // Base64.encode(this.$store.state.login.currentUser.account);
1330
1329
  let msg = document.getElementById('QRCode')
1331
1330
 
1332
- this.$qrcode.toCanvas(msg, this.QRCodeurl, function(error) {
1331
+ this.$qrcode.toCanvas(msg, this.QRCodeurl, function (error) {
1333
1332
  console.log(error)
1334
1333
  })
1335
1334
  this.QRCodeShow = true
@@ -1352,13 +1351,13 @@ export default {
1352
1351
  this.rowTemplateId = templateId
1353
1352
  this.rowId = id
1354
1353
  },
1355
- handleSizeChange: function(size) {
1354
+ handleSizeChange: function (size) {
1356
1355
  //每页下拉显示数据
1357
1356
  this.pagination.page = 1
1358
1357
  this.pagination.pageSize = size
1359
1358
  this.$refs.multipleTemplateTable.handleFilterChange()
1360
1359
  },
1361
- handleCurrentChange: function(currentPage) {
1360
+ handleCurrentChange: function (currentPage) {
1362
1361
  //点击第几页
1363
1362
  this.pagination.page = currentPage
1364
1363
  this.$refs.multipleTemplateTable.handleFilterChange()
@@ -1877,18 +1876,10 @@ export default {
1877
1876
  ? operationType[operation]
1878
1877
  : operation
1879
1878
  } else if (
1880
- typeof $(searchItems[i])
1881
- .children()
1882
- .attr('ht-query') != 'undefined'
1879
+ typeof $(searchItems[i]).children().attr('ht-query') != 'undefined'
1883
1880
  ) {
1884
- operation = $(searchItems[i])
1885
- .children()
1886
- .attr('operation')
1887
- operationMap[
1888
- $(searchItems[i])
1889
- .children()
1890
- .attr('ht-query')
1891
- ] =
1881
+ operation = $(searchItems[i]).children().attr('operation')
1882
+ operationMap[$(searchItems[i]).children().attr('ht-query')] =
1892
1883
  typeof operationType[operation] != 'undefined'
1893
1884
  ? operationType[operation]
1894
1885
  : operation
@@ -1914,18 +1905,10 @@ export default {
1914
1905
  ? operationType[operation]
1915
1906
  : operation
1916
1907
  } else if (
1917
- typeof $(searchItems[i])
1918
- .children()
1919
- .attr('ht-query') != 'undefined'
1908
+ typeof $(searchItems[i]).children().attr('ht-query') != 'undefined'
1920
1909
  ) {
1921
- operation = $(searchItems[i])
1922
- .children()
1923
- .attr('type')
1924
- operationMap[
1925
- $(searchItems[i])
1926
- .children()
1927
- .attr('ht-query')
1928
- ] =
1910
+ operation = $(searchItems[i]).children().attr('type')
1911
+ operationMap[$(searchItems[i]).children().attr('ht-query')] =
1929
1912
  typeof operationType[operation] != 'undefined'
1930
1913
  ? operationType[operation]
1931
1914
  : operation
@@ -1948,19 +1931,12 @@ export default {
1948
1931
  ? true
1949
1932
  : false
1950
1933
  } else if (
1951
- typeof $(searchItems[i])
1952
- .children()
1953
- .attr('ht-query') != 'undefined'
1934
+ typeof $(searchItems[i]).children().attr('ht-query') != 'undefined'
1954
1935
  ) {
1955
1936
  //查询条件字段
1956
- fieldQueryMap[
1957
- $(searchItems[i])
1958
- .children()
1959
- .attr('ht-query')
1960
- ] =
1961
- typeof $(searchItems[i])
1962
- .children()
1963
- .attr('special-query') != 'undefined'
1937
+ fieldQueryMap[$(searchItems[i]).children().attr('ht-query')] =
1938
+ typeof $(searchItems[i]).children().attr('special-query') !=
1939
+ 'undefined'
1964
1940
  ? true
1965
1941
  : false
1966
1942
  }
@@ -2028,7 +2004,7 @@ export default {
2028
2004
  }
2029
2005
  },
2030
2006
  //回车查询
2031
- searchEnterFun: function(e) {
2007
+ searchEnterFun: function (e) {
2032
2008
  let keyCode = window.event ? e.keyCode : e.which
2033
2009
  if (keyCode == 13) {
2034
2010
  this.search()
@@ -4103,7 +4079,8 @@ export default {
4103
4079
  this.printDetail(parameter.templateId, parameter.id, parameter.action)
4104
4080
  } else if (btnAlias == 'sub' && this.checkSelect()) {
4105
4081
  this.showSubList(this.tableData.selectRows[0].id_, parameter)
4106
- } else if (btnAlias == 'js' && this.checkSelect()) {
4082
+ } else if (btnAlias == 'js') {
4083
+ if (parameter.needValidateSelect && !this.checkSelect()) return
4107
4084
  this.customEvilJS(this.tableData.selectRows[0], parameter.jsValue)
4108
4085
  } else if (
4109
4086
  btnAlias == 'startFlow' &&
package/src/utils.js CHANGED
@@ -955,7 +955,7 @@ var utils = {
955
955
  }
956
956
  const keyPath = config[key]
957
957
  // 获取当前组件所在的表单
958
- const formInst = utils.getOnlineFormInstance(inst.$parent)
958
+ const formInst = utils.getOnlineFormInstance(inst)
959
959
  // 获取当前组件是否在子表中的某一行
960
960
  const { subScopeEl, index, subname } = utils.getSubScopeElAndIndex(inst.$el)
961
961
  if (subScopeEl) {
@@ -1256,4 +1256,35 @@ Date.prototype.format = function(format) {
1256
1256
  return format
1257
1257
  }
1258
1258
 
1259
+ //精确四舍五入
1260
+ Number.prototype.toFixedRound = function(d) {
1261
+ d = Number(d)
1262
+ var s = this + ''
1263
+ if (!d) d = 0
1264
+ if (s.indexOf('.') == -1) s += '.'
1265
+ s += new Array(d + 1).join('0')
1266
+ if (new RegExp('^(-|\\+)?(\\d+(\\.\\d{0,' + (d + 1) + '})?)\\d*$').test(s)) {
1267
+ var s = '0' + RegExp.$2,
1268
+ pm = RegExp.$1,
1269
+ a = RegExp.$3.length,
1270
+ b = true
1271
+ if (a == d + 2) {
1272
+ a = s.match(/\d/g)
1273
+ if (parseInt(a[a.length - 1]) > 4) {
1274
+ for (var i = a.length - 2; i >= 0; i--) {
1275
+ a[i] = parseInt(a[i]) + 1
1276
+ if (a[i] == 10) {
1277
+ a[i] = 0
1278
+ b = i != 1
1279
+ } else break
1280
+ }
1281
+ }
1282
+ s = a.join('').replace(new RegExp('(\\d+)(\\d{' + d + '})\\d$'), '$1.$2')
1283
+ }
1284
+ if (b) s = s.substr(1)
1285
+ return (pm + s).replace(/\.$/, '')
1286
+ }
1287
+ return this + ''
1288
+ }
1289
+
1259
1290
  export default utils