mooho-base-admin-plus 2.0.9 → 2.0.11
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
|
@@ -1152,8 +1152,6 @@
|
|
|
1152
1152
|
// },
|
|
1153
1153
|
// 选项变化事件
|
|
1154
1154
|
onSelectDataChange(sender, selected) {
|
|
1155
|
-
console.log('onSelectDataChange', sender, selected);
|
|
1156
|
-
|
|
1157
1155
|
let code;
|
|
1158
1156
|
if (sender.code.endsWith('ID')) {
|
|
1159
1157
|
code = sender.code.substr(0, sender.code.length - 2);
|
|
@@ -1272,11 +1270,19 @@
|
|
|
1272
1270
|
// 公式计算
|
|
1273
1271
|
for (let column of this.columns) {
|
|
1274
1272
|
if (!!(column.calculate || '').trim()) {
|
|
1275
|
-
let
|
|
1273
|
+
let calculate = column.calculate;
|
|
1274
|
+
|
|
1275
|
+
// 计算sum、min、max等统计值
|
|
1276
|
+
calculate = this.calcStat('sum', calculate);
|
|
1277
|
+
calculate = this.calcStat('min', calculate);
|
|
1278
|
+
calculate = this.calcStat('max', calculate);
|
|
1279
|
+
calculate = this.calcStat('avg', calculate);
|
|
1280
|
+
|
|
1281
|
+
let triggers = this.getTriggers(calculate);
|
|
1276
1282
|
|
|
1277
|
-
if (!sender || triggers.some(item => item == sender.code)) {
|
|
1283
|
+
if (!sender || triggers.some(item => item == sender.code) || column.calculate != calculate) {
|
|
1278
1284
|
// 包含在公式中,需要刷新
|
|
1279
|
-
let result = this.calculate(
|
|
1285
|
+
let result = this.calculate(calculate, this.data);
|
|
1280
1286
|
|
|
1281
1287
|
// 保留小数
|
|
1282
1288
|
if (column.digit != null) {
|
|
@@ -1481,6 +1487,52 @@
|
|
|
1481
1487
|
return value;
|
|
1482
1488
|
}
|
|
1483
1489
|
},
|
|
1490
|
+
// 计算统计值
|
|
1491
|
+
calcStat(op, calculate) {
|
|
1492
|
+
let start = calculate.indexOf(op + '(');
|
|
1493
|
+
let end = calculate.indexOf(')', start);
|
|
1494
|
+
|
|
1495
|
+
if (start == -1 || end == -1) {
|
|
1496
|
+
return calculate;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
let property = calculate.substring(start + 4, end);
|
|
1500
|
+
|
|
1501
|
+
if (property.indexOf('.') == -1) {
|
|
1502
|
+
return calculate;
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
let table = this.$refs['table_' + property.split('.')[0]];
|
|
1506
|
+
|
|
1507
|
+
if (table == null || table.length == 0) {
|
|
1508
|
+
return calculate;
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
let tableData = table[0].getData();
|
|
1512
|
+
let result = null;
|
|
1513
|
+
let sum = null;
|
|
1514
|
+
let count = null;
|
|
1515
|
+
|
|
1516
|
+
for (let item of tableData) {
|
|
1517
|
+
let value = this.parseData(item, property.substr(property.indexOf('.') + 1));
|
|
1518
|
+
|
|
1519
|
+
if (value) {
|
|
1520
|
+
if (op == 'sum') {
|
|
1521
|
+
result = result == null ? value : result + value;
|
|
1522
|
+
} else if (op == 'min') {
|
|
1523
|
+
result = result == null ? value : value < result ? value : result;
|
|
1524
|
+
} else if (op == 'max') {
|
|
1525
|
+
result = result == null ? value : value > result ? value : result;
|
|
1526
|
+
} else if (op == 'avg') {
|
|
1527
|
+
sum = sum == null ? value : sum + value;
|
|
1528
|
+
count = count == null ? 1 : count + 1;
|
|
1529
|
+
result = count > 0 ? sum / count : null;
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
return calculate.substring(0, start) + (result == null ? 'null' : result.toString()) + calculate.substring(end + 1);
|
|
1535
|
+
},
|
|
1484
1536
|
// 获取多语言名称
|
|
1485
1537
|
getNameI18n(column) {
|
|
1486
1538
|
if (this.layout.showI18n) {
|
package/src/index.js
CHANGED
|
@@ -158,12 +158,10 @@ const API = {
|
|
|
158
158
|
};
|
|
159
159
|
|
|
160
160
|
// 页面
|
|
161
|
-
console.log('import');
|
|
162
161
|
const files = import.meta.globEager('./pages/**/*.vue');
|
|
163
162
|
const pages = {};
|
|
164
163
|
|
|
165
164
|
Object.keys(files).forEach(key => {
|
|
166
|
-
console.log('import', key.replace(/(\.\/pages\/)/g, ''));
|
|
167
165
|
pages[key.replace(/(\.\/pages\/)/g, '')] = files[key].default;
|
|
168
166
|
});
|
|
169
167
|
|