three-trees-ui 1.0.71 → 1.0.72

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.
@@ -29,7 +29,7 @@ const SubPagination = {
29
29
  return `${path}:VueComponent`
30
30
  },
31
31
  // 导入数据
32
- importData: (path, importRows, mode, mergeMethod, pInst) => {
32
+ importData: (path, importRows, mode, mergeMethod, conditionConfig, pInst) => {
33
33
  return new Promise((resolve, reject) => {
34
34
  let formUid = pInst && pInst._uid ? pInst._uid : ''
35
35
  if (SubPagination._map.has(path + formUid)) {
@@ -61,6 +61,45 @@ const SubPagination = {
61
61
  utils.setValueByPath(inst, path, newRows)
62
62
  break
63
63
  }
64
+ case 'condition': {
65
+ importRows.forEach((item) => {
66
+ let index = array.findIndex((sub) => {
67
+ let orArr = conditionConfig.conditionArr.filter((condition) => {
68
+ return condition.relation == 'or'
69
+ })
70
+ let andArr = conditionConfig.conditionArr.filter(
71
+ (condition) => {
72
+ return condition.relation == 'and'
73
+ }
74
+ )
75
+ let orFlag = true
76
+ let andFlag = true
77
+ if (orArr.length) {
78
+ orFlag = orArr.some((j) => {
79
+ return sub[j.subField] == item[j.exportField]
80
+ })
81
+ }
82
+ if (andArr.length) {
83
+ andFlag = andArr.every((j) => {
84
+ return sub[j.subField] == item[j.exportField]
85
+ })
86
+ }
87
+ return orFlag && andFlag
88
+ })
89
+ if (index != -1) {
90
+ let updateArr = conditionConfig.backField.split(',')
91
+ updateArr.forEach((field) => {
92
+ array[index][field] = item[field]
93
+ })
94
+ } else {
95
+ // 未匹配到时是否新增
96
+ if (conditionConfig.conditionType == 'add') {
97
+ array.push(item)
98
+ }
99
+ }
100
+ })
101
+ utils.setValueByPath(inst, path, array)
102
+ }
64
103
  }
65
104
  obj.rows = utils.getValueByPath(inst, path)
66
105
  SubPagination._digest(obj.rows)
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