cloud-web-corejs 1.0.236 → 1.0.237
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 +1 -1
- package/src/utils/vab.js +75 -59
package/package.json
CHANGED
package/src/utils/vab.js
CHANGED
|
@@ -7,11 +7,11 @@ function reqImg(a) {
|
|
|
7
7
|
|
|
8
8
|
import request from "./request";
|
|
9
9
|
import * as lodash from "lodash";
|
|
10
|
-
import {Loading, Message, MessageBox, Notification, Form} from "element-ui";
|
|
10
|
+
import { Loading, Message, MessageBox, Notification, Form } from "element-ui";
|
|
11
11
|
import store from "../store";
|
|
12
12
|
import ElImageViewer from "../components/VabUpload/image-viewer";
|
|
13
13
|
|
|
14
|
-
import {getToken} from "./auth";
|
|
14
|
+
import { getToken } from "./auth";
|
|
15
15
|
import XEUtils from "xe-utils";
|
|
16
16
|
|
|
17
17
|
import prefixConfig from "@/prefixConfig.js";
|
|
@@ -61,10 +61,14 @@ install = (Vue, opts = {}) => {
|
|
|
61
61
|
if (opts.addCreateInfo === null || opts.addCreateInfo === undefined) {
|
|
62
62
|
option.addCreateInfo = defaultOption.addCreateInfo;
|
|
63
63
|
}
|
|
64
|
-
if (
|
|
64
|
+
if (
|
|
65
|
+
opts.queryCreateInfo === null ||
|
|
66
|
+
opts.queryCreateInfo === undefined ||
|
|
67
|
+
opts.queryCreateInfo === true
|
|
68
|
+
) {
|
|
65
69
|
option.queryCreateInfo = defaultOption.queryCreateInfo;
|
|
66
70
|
}
|
|
67
|
-
if(opts.queryCreateInfo === false){
|
|
71
|
+
if (opts.queryCreateInfo === false) {
|
|
68
72
|
option.queryCreateInfo = "0";
|
|
69
73
|
}
|
|
70
74
|
return this.$http(option);
|
|
@@ -142,7 +146,7 @@ install = (Vue, opts = {}) => {
|
|
|
142
146
|
return loading;
|
|
143
147
|
};
|
|
144
148
|
/* 全局Message */
|
|
145
|
-
Vue.prototype.$baseMessage = ({message, type, onClose}) => {
|
|
149
|
+
Vue.prototype.$baseMessage = ({ message, type, onClose }) => {
|
|
146
150
|
imFun.Message({
|
|
147
151
|
offset: 60,
|
|
148
152
|
showClose: true,
|
|
@@ -326,6 +330,7 @@ install = (Vue, opts = {}) => {
|
|
|
326
330
|
"webp",
|
|
327
331
|
"tga",
|
|
328
332
|
"svg",
|
|
333
|
+
"vue",
|
|
329
334
|
];
|
|
330
335
|
Vue.prototype.$commonFileUtil = {
|
|
331
336
|
// 文件类型获取与判断接口
|
|
@@ -369,7 +374,7 @@ install = (Vue, opts = {}) => {
|
|
|
369
374
|
gif: true,
|
|
370
375
|
bmp: true,
|
|
371
376
|
mpg: true,
|
|
372
|
-
webp: true
|
|
377
|
+
webp: true,
|
|
373
378
|
};
|
|
374
379
|
|
|
375
380
|
let type = fileTypeMap[suffix];
|
|
@@ -503,12 +508,12 @@ install = (Vue, opts = {}) => {
|
|
|
503
508
|
return true;
|
|
504
509
|
},
|
|
505
510
|
isPictureFile: function (fileName) {
|
|
506
|
-
if(!fileName)return false;
|
|
511
|
+
if (!fileName) return false;
|
|
507
512
|
let typeStr = Object.prototype.toString.call(fileName);
|
|
508
|
-
let suffix = null
|
|
513
|
+
let suffix = null;
|
|
509
514
|
if (typeStr === "[object Object]") {
|
|
510
515
|
suffix = this.getFileSuffix(fileName.name);
|
|
511
|
-
}else{
|
|
516
|
+
} else {
|
|
512
517
|
suffix = this.getFileSuffix(fileName);
|
|
513
518
|
}
|
|
514
519
|
return this.isPicture(suffix);
|
|
@@ -634,17 +639,17 @@ install = (Vue, opts = {}) => {
|
|
|
634
639
|
return iconType;
|
|
635
640
|
},
|
|
636
641
|
getFileExtension(urlString) {
|
|
637
|
-
if(!urlString)return null
|
|
642
|
+
if (!urlString) return null;
|
|
638
643
|
const url = new URL(urlString);
|
|
639
644
|
// 获取路径部分,例如 "/images/photo.jpg"
|
|
640
645
|
const pathname = url.pathname;
|
|
641
646
|
|
|
642
647
|
// 使用 lastIndexOf 找到最后一个点的位置
|
|
643
|
-
const lastDotIndex = pathname.lastIndexOf(
|
|
648
|
+
const lastDotIndex = pathname.lastIndexOf(".");
|
|
644
649
|
|
|
645
650
|
// 如果没有点,或者点在最后一位(即没有后缀),返回空字符串
|
|
646
651
|
if (lastDotIndex === -1 || lastDotIndex === pathname.length - 1) {
|
|
647
|
-
return
|
|
652
|
+
return "";
|
|
648
653
|
}
|
|
649
654
|
|
|
650
655
|
// 截取点之后的部分
|
|
@@ -670,7 +675,7 @@ install = (Vue, opts = {}) => {
|
|
|
670
675
|
}
|
|
671
676
|
if (name) {
|
|
672
677
|
let fileSuffix = this.getFileExtension(filePath);
|
|
673
|
-
if(fileSuffix && !name.endsWith("."+fileSuffix)){
|
|
678
|
+
if (fileSuffix && !name.endsWith("." + fileSuffix)) {
|
|
674
679
|
name = name + "." + fileSuffix;
|
|
675
680
|
}
|
|
676
681
|
|
|
@@ -835,7 +840,12 @@ install = (Vue, opts = {}) => {
|
|
|
835
840
|
let parentTarget = target.$attrs["parent-target"] || target.$parent;
|
|
836
841
|
let originTarget = parentTarget.$refs._viewDialog ? parentTarget : target;
|
|
837
842
|
let updateParam =
|
|
838
|
-
param !== null &&
|
|
843
|
+
param !== null &&
|
|
844
|
+
param !== undefined &&
|
|
845
|
+
param.updateParam !== null &&
|
|
846
|
+
param.updateParam !== undefined
|
|
847
|
+
? param.updateParam
|
|
848
|
+
: {};
|
|
839
849
|
for (let key in updateParam) {
|
|
840
850
|
originTarget.$emit("update:" + key, updateParam[key]);
|
|
841
851
|
}
|
|
@@ -932,7 +942,6 @@ install = (Vue, opts = {}) => {
|
|
|
932
942
|
Vue.prototype.$baseMul = baseMul;
|
|
933
943
|
Vue.prototype.$baseDiv = baseDiv;
|
|
934
944
|
|
|
935
|
-
|
|
936
945
|
/**
|
|
937
946
|
* 格式化数字为带千分位的字符串。
|
|
938
947
|
*
|
|
@@ -957,25 +966,25 @@ install = (Vue, opts = {}) => {
|
|
|
957
966
|
* formatNumber(1000, { fixed: true, digits: 0 }); // "1,000"
|
|
958
967
|
*/
|
|
959
968
|
function formatNumber(value, options = {}) {
|
|
960
|
-
if (value === null || value === undefined || value ===
|
|
961
|
-
return
|
|
969
|
+
if (value === null || value === undefined || value === "") {
|
|
970
|
+
return "";
|
|
962
971
|
}
|
|
963
972
|
|
|
964
973
|
const {
|
|
965
974
|
fixed = false,
|
|
966
975
|
digits = 2,
|
|
967
|
-
thousandsSeparator =
|
|
968
|
-
decimalSeparator =
|
|
976
|
+
thousandsSeparator = ",",
|
|
977
|
+
decimalSeparator = ".",
|
|
969
978
|
} = options;
|
|
970
979
|
|
|
971
|
-
const isNumber = typeof value ===
|
|
980
|
+
const isNumber = typeof value === "number";
|
|
972
981
|
let str = String(value).trim();
|
|
973
982
|
|
|
974
983
|
// Normalize ".123" → "0.123"
|
|
975
984
|
if (str.charCodeAt(0) === 46) {
|
|
976
|
-
str =
|
|
977
|
-
} else if (str.startsWith(
|
|
978
|
-
str =
|
|
985
|
+
str = "0" + str;
|
|
986
|
+
} else if (str.startsWith("-.")) {
|
|
987
|
+
str = "-0." + str.slice(2);
|
|
979
988
|
}
|
|
980
989
|
|
|
981
990
|
let intPart, decPart, isNegative;
|
|
@@ -986,9 +995,9 @@ install = (Vue, opts = {}) => {
|
|
|
986
995
|
if (num !== num) return str;
|
|
987
996
|
|
|
988
997
|
const fixedStr = num.toFixed(digits);
|
|
989
|
-
const dotIndex = fixedStr.indexOf(
|
|
998
|
+
const dotIndex = fixedStr.indexOf(".");
|
|
990
999
|
intPart = dotIndex === -1 ? fixedStr : fixedStr.slice(0, dotIndex);
|
|
991
|
-
decPart = dotIndex === -1 ?
|
|
1000
|
+
decPart = dotIndex === -1 ? "" : fixedStr.slice(dotIndex + 1);
|
|
992
1001
|
isNegative = intPart.charCodeAt(0) === 45;
|
|
993
1002
|
if (isNegative) intPart = intPart.slice(1);
|
|
994
1003
|
} else {
|
|
@@ -997,18 +1006,18 @@ install = (Vue, opts = {}) => {
|
|
|
997
1006
|
isNegative = s.charCodeAt(0) === 45;
|
|
998
1007
|
if (isNegative) s = s.slice(1);
|
|
999
1008
|
|
|
1000
|
-
const dotIndex = s.indexOf(
|
|
1009
|
+
const dotIndex = s.indexOf(".");
|
|
1001
1010
|
intPart = dotIndex === -1 ? s : s.slice(0, dotIndex);
|
|
1002
|
-
decPart = dotIndex === -1 ?
|
|
1011
|
+
decPart = dotIndex === -1 ? "" : s.slice(dotIndex + 1);
|
|
1003
1012
|
|
|
1004
|
-
if (intPart ===
|
|
1013
|
+
if (intPart === "") intPart = "0";
|
|
1005
1014
|
if (!/^\d+$/.test(intPart)) return str;
|
|
1006
1015
|
}
|
|
1007
1016
|
|
|
1008
1017
|
// 千分位(始终应用)
|
|
1009
1018
|
let fmtInt = intPart;
|
|
1010
|
-
if (intPart !==
|
|
1011
|
-
let out =
|
|
1019
|
+
if (intPart !== "0") {
|
|
1020
|
+
let out = "";
|
|
1012
1021
|
for (let i = intPart.length - 1, c = 0; i >= 0; i--, c++) {
|
|
1013
1022
|
if (c > 0 && c % 3 === 0) out = thousandsSeparator + out;
|
|
1014
1023
|
out = intPart[i] + out;
|
|
@@ -1017,11 +1026,11 @@ install = (Vue, opts = {}) => {
|
|
|
1017
1026
|
}
|
|
1018
1027
|
|
|
1019
1028
|
// 拼接
|
|
1020
|
-
let result = isNegative ?
|
|
1029
|
+
let result = isNegative ? "-" + fmtInt : fmtInt;
|
|
1021
1030
|
if (decPart) {
|
|
1022
1031
|
result += decimalSeparator + decPart;
|
|
1023
1032
|
} else if (fixed && digits > 0) {
|
|
1024
|
-
result += decimalSeparator +
|
|
1033
|
+
result += decimalSeparator + "0".repeat(digits);
|
|
1025
1034
|
}
|
|
1026
1035
|
|
|
1027
1036
|
return result;
|
|
@@ -1037,18 +1046,23 @@ install = (Vue, opts = {}) => {
|
|
|
1037
1046
|
crypto.getRandomValues(buf);
|
|
1038
1047
|
buf[6] = (buf[6] & 0x0f) | 0x40; // version 4
|
|
1039
1048
|
buf[8] = (buf[8] & 0x3f) | 0x80; // variant RFC4122
|
|
1040
|
-
const hex = Array.from(buf, b => b.toString(16).padStart(2,
|
|
1041
|
-
|
|
1049
|
+
const hex = Array.from(buf, (b) => b.toString(16).padStart(2, "0")).join(
|
|
1050
|
+
""
|
|
1051
|
+
);
|
|
1052
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(
|
|
1053
|
+
12,
|
|
1054
|
+
16
|
|
1055
|
+
)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
1042
1056
|
}
|
|
1043
1057
|
Vue.prototype.$generateUUID = generateUUID;
|
|
1044
1058
|
|
|
1045
1059
|
//数字精确位数
|
|
1046
1060
|
Vue.prototype.$currency = function (value, priceScale, priceRoundType) {
|
|
1047
|
-
if (value !== null
|
|
1048
|
-
if (priceScale === null
|
|
1061
|
+
if (value !== null && value !== undefined) {
|
|
1062
|
+
if (priceScale === null || priceScale === undefined) {
|
|
1049
1063
|
priceScale = 2;
|
|
1050
1064
|
}
|
|
1051
|
-
if (priceRoundType === null
|
|
1065
|
+
if (priceRoundType === null || priceRoundType === undefined) {
|
|
1052
1066
|
priceRoundType = "roundHalfUp";
|
|
1053
1067
|
}
|
|
1054
1068
|
let price;
|
|
@@ -1087,24 +1101,24 @@ install = (Vue, opts = {}) => {
|
|
|
1087
1101
|
success: (res) => {
|
|
1088
1102
|
let dicts = res.objx || [];
|
|
1089
1103
|
let dictMap = {};
|
|
1090
|
-
for(let item of dicts){
|
|
1104
|
+
for (let item of dicts) {
|
|
1091
1105
|
dictMap[item.sn] = item.value;
|
|
1092
1106
|
}
|
|
1093
1107
|
/* dicts.forEach((item) => {
|
|
1094
1108
|
dictMap[item.sn] = item.value;
|
|
1095
1109
|
}); */
|
|
1096
1110
|
option.success &&
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1111
|
+
option.success({
|
|
1112
|
+
dicts,
|
|
1113
|
+
dictMap,
|
|
1114
|
+
});
|
|
1101
1115
|
},
|
|
1102
1116
|
});
|
|
1103
1117
|
};
|
|
1104
1118
|
|
|
1105
1119
|
imFun.Form.methods.$baseValidate = function (callback, opt) {
|
|
1106
1120
|
let that = this;
|
|
1107
|
-
that.validate((valid, obj,c,d) => {
|
|
1121
|
+
that.validate((valid, obj, c, d) => {
|
|
1108
1122
|
if (!valid && (!opt || opt.errorTip !== false)) {
|
|
1109
1123
|
this.$message({
|
|
1110
1124
|
message: this.$t2("必填项不能为空", "system.message.required"),
|
|
@@ -1120,8 +1134,8 @@ install = (Vue, opts = {}) => {
|
|
|
1120
1134
|
function scrollToFirstError(formTarget) {
|
|
1121
1135
|
// 获取第一个验证失败的字段
|
|
1122
1136
|
// let formTarget = this.$refs['renderForm'];
|
|
1123
|
-
const firstErrorField = Object.keys(formTarget.fields).find(key => {
|
|
1124
|
-
return formTarget.fields[key].validateState ===
|
|
1137
|
+
const firstErrorField = Object.keys(formTarget.fields).find((key) => {
|
|
1138
|
+
return formTarget.fields[key].validateState === "error";
|
|
1125
1139
|
});
|
|
1126
1140
|
|
|
1127
1141
|
if (firstErrorField) {
|
|
@@ -1131,19 +1145,18 @@ install = (Vue, opts = {}) => {
|
|
|
1131
1145
|
if (dom) {
|
|
1132
1146
|
// 滚动到该字段位置
|
|
1133
1147
|
dom.scrollIntoView({
|
|
1134
|
-
behavior:
|
|
1135
|
-
block:
|
|
1148
|
+
behavior: "smooth",
|
|
1149
|
+
block: "center",
|
|
1136
1150
|
});
|
|
1137
1151
|
|
|
1138
1152
|
// 添加高亮效果
|
|
1139
|
-
dom.classList.add(
|
|
1153
|
+
dom.classList.add("highlight");
|
|
1140
1154
|
|
|
1141
1155
|
// 3秒后移除高亮效果
|
|
1142
1156
|
setTimeout(() => {
|
|
1143
|
-
dom.classList.remove(
|
|
1157
|
+
dom.classList.remove("highlight");
|
|
1144
1158
|
}, 3000);
|
|
1145
1159
|
}
|
|
1146
|
-
|
|
1147
1160
|
}
|
|
1148
1161
|
}
|
|
1149
1162
|
|
|
@@ -1184,7 +1197,7 @@ install = (Vue, opts = {}) => {
|
|
|
1184
1197
|
});
|
|
1185
1198
|
};
|
|
1186
1199
|
getDownloadDomian((domain) => {
|
|
1187
|
-
if(fileName){
|
|
1200
|
+
if (fileName) {
|
|
1188
1201
|
fileWhole.fileName = fileName;
|
|
1189
1202
|
}
|
|
1190
1203
|
that.$http({
|
|
@@ -1223,13 +1236,16 @@ install = (Vue, opts = {}) => {
|
|
|
1223
1236
|
let lang = that.$i18n.locale;
|
|
1224
1237
|
const i18n = that.$i18n;
|
|
1225
1238
|
if (lang === "zh") {
|
|
1226
|
-
let val = i18n._t(path, lang, {zh: {[path]: path}}, null, values);
|
|
1239
|
+
let val = i18n._t(path, lang, { zh: { [path]: path } }, null, values);
|
|
1227
1240
|
return val;
|
|
1228
1241
|
} else {
|
|
1229
|
-
if(!i18n.te(path)){
|
|
1230
|
-
return i18n._t(path, lang, {zh: {[path]: path}}, null, values);
|
|
1231
|
-
}else{
|
|
1232
|
-
return
|
|
1242
|
+
if (!i18n.te(path)) {
|
|
1243
|
+
return i18n._t(path, lang, { zh: { [path]: path } }, null, values);
|
|
1244
|
+
} else {
|
|
1245
|
+
return (
|
|
1246
|
+
i18n.t(path, values) ||
|
|
1247
|
+
i18n._t(path, lang, { zh: { [path]: path } }, null, values)
|
|
1248
|
+
);
|
|
1233
1249
|
}
|
|
1234
1250
|
}
|
|
1235
1251
|
};
|
|
@@ -1250,9 +1266,9 @@ install = (Vue, opts = {}) => {
|
|
|
1250
1266
|
};
|
|
1251
1267
|
|
|
1252
1268
|
Vue.prototype.$utcToLocal = function (utcTime) {
|
|
1253
|
-
if(!utcTime)return utcTime;
|
|
1254
|
-
let offsetHours = this.$store.getters.utcTransformOffset
|
|
1255
|
-
if(!offsetHours || offsetHours === 0)return utcTime;
|
|
1269
|
+
if (!utcTime) return utcTime;
|
|
1270
|
+
let offsetHours = this.$store.getters.utcTransformOffset; // 时区偏移量,单位:小时
|
|
1271
|
+
if (!offsetHours || offsetHours === 0) return utcTime;
|
|
1256
1272
|
let localTime = moment(utcTime).add(offsetHours, "hours");
|
|
1257
1273
|
return localTime.format("YYYY-MM-DD HH:mm:ss");
|
|
1258
1274
|
};
|