@infly/libs 2.0.26 → 2.0.37

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.
Files changed (39) hide show
  1. package/bin/cli.js +29 -21
  2. package/build/build-dist/index.js +258 -61
  3. package/build/webpack5/remove-legacy-assets-plugin.js +84 -0
  4. package/build/webpack5/webpack.base.js +228 -20
  5. package/build/webpack5/webpack.base.test.js +59 -0
  6. package/index.js +10 -0
  7. package/module/Permission.js +121 -55
  8. package/module/REST.js +136 -26
  9. package/module/Router.js +15 -0
  10. package/module/Uts.js +380 -331
  11. package/module/cjs/deep-merge.cjs +38 -0
  12. package/module/cjs/page-config.cjs +119 -0
  13. package/module/cjs/request-url-rules.cjs +55 -0
  14. package/package.json +11 -10
  15. package/script/build/command.js +48 -0
  16. package/script/build/env.js +28 -0
  17. package/script/build/git.js +252 -0
  18. package/script/build/preview.js +75 -0
  19. package/script/build/webhook.js +118 -0
  20. package/script/git-automation/check-packages.js +11 -8
  21. package/script/git-automation/git-utils.js +67 -0
  22. package/script/git-automation/index.js +378 -106
  23. package/script/index.js +8 -8
  24. package/script/pts/cloud-scenes.mjs +65 -0
  25. package/script/pts/cloud.js +151 -0
  26. package/script/pts/generate-cloud-params.mjs +210 -0
  27. package/script/pts/generate-cloud-params.test.mjs +67 -0
  28. package/script/webhook/webhook.js +75 -4
  29. package/store/modules/user.js +111 -9
  30. package/tools/auto-export.js +56 -0
  31. package/tools/file-export.js +32 -9
  32. package/tools/file-process.js +3 -0
  33. package/tools/project-preview.js +110 -97
  34. package/dataInit/commonTypeMap.js +0 -31
  35. package/dataInit/marketingActivitiesMap.js +0 -214
  36. package/dataInit/orderMap.js +0 -13
  37. package/dataInit/personalMap.js +0 -19
  38. package/dataInit/settlementMap.js +0 -17
  39. package/types/unused.index.d.ts +0 -71
package/module/Uts.js CHANGED
@@ -7,6 +7,12 @@
7
7
  // const _history = createHashHistory();
8
8
  // console.log(_history);
9
9
 
10
+ const { deepMerge: deepMergeImpl } = require("./cjs/deep-merge.cjs");
11
+ const {
12
+ mergePageConfig: mergePageConfigImpl,
13
+ resolvePlatformPageConfig: resolvePlatformPageConfigImpl
14
+ } = require("./cjs/page-config.cjs");
15
+
10
16
  let _getItem = Storage.prototype.getItem;
11
17
  // import Uts from "./Uts";
12
18
  let $state = {
@@ -17,45 +23,45 @@ let $state = {
17
23
  preParams: {},
18
24
  preState: {},
19
25
  state: {},
20
- setPreName: function(value) {
26
+ setPreName: function (value) {
21
27
  this.preName = value;
22
28
  },
23
- getPreName: function() {
29
+ getPreName: function () {
24
30
  return this.preName;
25
31
  },
26
- setPreParams: function(value) {
32
+ setPreParams: function (value) {
27
33
  this.preParams = value;
28
34
  },
29
- getPreParams: function() {
35
+ getPreParams: function () {
30
36
  return this.preParams;
31
37
  },
32
- setStateName: function(value) {
38
+ setStateName: function (value) {
33
39
  this.setPreName(this.name);
34
40
  this.name = value;
35
41
  },
36
- setParams: function(value) {
42
+ setParams: function (value) {
37
43
  this.setPreParams(this.params);
38
44
  this.params = value;
39
45
  },
40
- getStateName: function() {
46
+ getStateName: function () {
41
47
  return this.name;
42
48
  },
43
- getParams: function() {
49
+ getParams: function () {
44
50
  return this.params;
45
51
  },
46
- setState: function(value) {
52
+ setState: function (value) {
47
53
  this.State = value;
48
54
  },
49
- getState: function() {
55
+ getState: function () {
50
56
  return this.State;
51
57
  },
52
- setSearch: function(value) {
58
+ setSearch: function (value) {
53
59
  this.search = value;
54
60
  },
55
- go: function(options) {
61
+ go: function (options) {
56
62
  global.Uts.$stateGo(options);
57
63
  },
58
- to: function(path) {
64
+ to: function (path) {
59
65
  global.Uts.$stateTo(path);
60
66
  }
61
67
  };
@@ -79,7 +85,16 @@ let Uts = {
79
85
  * Uts.ce('请检查配置');
80
86
  */
81
87
  ce(text) {
82
- global.console.error && global.console.error(text);
88
+ global.console && global.console.error && global.console.error(text);
89
+ },
90
+ /**
91
+ * 规范化环境变量中的 URL 字符串
92
+ * 例如去除首尾空格和包裹引号:"'http://xx/'" -> "http://xx/"
93
+ */
94
+ normalizeEnvUrl(url = "") {
95
+ return String(url)
96
+ .trim()
97
+ .replace(/^['"]|['"]$/g, "");
83
98
  },
84
99
  /**
85
100
  * set class 动态设置类名
@@ -382,7 +397,7 @@ let Uts = {
382
397
  if (Uts.isFunction(cb)) {
383
398
  // for (let key in obj) {
384
399
  let keys = Uts.getObjectKeys(obj);
385
- Uts.each(keys, function(key, index, run) {
400
+ Uts.each(keys, function (key, index, run) {
386
401
  let shouldStop = cb(obj[key], key, run);
387
402
  if (shouldStop) {
388
403
  Uts.pauseEach = true;
@@ -534,7 +549,7 @@ Filter.formatDate(1655740800000,'Y-m-d')
534
549
  Uts.join()
535
550
  ''
536
551
  */
537
- join(arr = [], symbol = ".") {
552
+ join(arr = [], symbol = ",") {
538
553
  if (Uts.notEmptyArray(arr)) {
539
554
  return arr.join(symbol);
540
555
  } else {
@@ -559,7 +574,7 @@ Uts.generateArray(5,true)
559
574
  return arr;
560
575
  } else {
561
576
  let newArr = [];
562
- Uts.each(arr, function(item, index) {
577
+ Uts.each(arr, function (item, index) {
563
578
  newArr.push(index);
564
579
  });
565
580
  return newArr;
@@ -754,7 +769,7 @@ Uts.mergeArrayWithoutDuplicate([1,2,3,4,5,6],[9,3,3,2,1])
754
769
  let notDuplicateObj = {};
755
770
  let concatArray = Uts.concat(rawArr, valueArray);
756
771
  let resultArray = [];
757
- Uts.each(concatArray, function(item, index) {
772
+ Uts.each(concatArray, function (item, index) {
758
773
  let notDuplicateKey = item;
759
774
  if (Uts.isPureObject(item)) {
760
775
  notDuplicateKey = item[key];
@@ -783,7 +798,7 @@ console.log(arr1);
783
798
  Array.prototype.unshift.apply(rawArr, valueArray);
784
799
  }
785
800
  },
786
- overrideCookieName: function(cookieName, isSet) {
801
+ overrideCookieName: function (cookieName, isSet) {
787
802
  return cookieName;
788
803
  let currentProject = Uts.getCurrentProject();
789
804
  let exceptProject = { omsLoginToken: true, SPAccrosToken: true, examLoginToken: true };
@@ -905,7 +920,7 @@ console.log(arr1);
905
920
  options.expires = -1;
906
921
  Uts.setCookie(cname, cvalue, options);
907
922
  },
908
- isUI6Page: function(stateName) {
923
+ isUI6Page: function (stateName) {
909
924
  let currentProject = Uts.getCurrentProject();
910
925
  let hadUpdateUI6Project = ["pm", "srm", "ui"];
911
926
  if (Uts.contain(hadUpdateUI6Project, currentProject)) {
@@ -922,11 +937,11 @@ console.log(arr1);
922
937
  return false;
923
938
  },
924
939
 
925
- copyCleanFormData: function(formData, options = {}) {
940
+ copyCleanFormData: function (formData, options = {}) {
926
941
  const { filterMark = true } = options;
927
942
  let cleanFormData = {};
928
943
  let markPropList = ["$$valid", "$$status"];
929
- Uts.objEach(formData, function(value, key) {
944
+ Uts.objEach(formData, function (value, key) {
930
945
  if (filterMark && Uts.contain(markPropList, Uts.safeRegString(key))) {
931
946
  return;
932
947
  }
@@ -937,8 +952,8 @@ console.log(arr1);
937
952
  });
938
953
  return cleanFormData;
939
954
  },
940
- callLogout: function(callback) {
941
- callback = callback || function() {};
955
+ callLogout: function (callback) {
956
+ callback = callback || function () {};
942
957
  let ignoreProjectList = [
943
958
  /*"oms", "sp"*/
944
959
  ];
@@ -1008,7 +1023,7 @@ console.log(arr1);
1008
1023
 
1009
1024
  let secondDomain = Uts.copyObj(cookieDomain);
1010
1025
  secondDomain.domain = location.host;
1011
- Object.keys(cookiesMap).forEach(key => {
1026
+ Object.keys(cookiesMap).forEach((key) => {
1012
1027
  if (!Uts.contain(Uts.keeyCookieWhenLogOut, key) && !Uts.contain(options.keyCookie, key)) {
1013
1028
  _self.setCookie(key, "", cookieDomain);
1014
1029
  _self.setCookie(key, "", secondDomain);
@@ -1025,7 +1040,7 @@ console.log(arr1);
1025
1040
  if (keepStore) {
1026
1041
  Uts.rebackStoreList();
1027
1042
  if (Uts.isObject(keepStore)) {
1028
- Uts.objEach(keepStore, function(item, index) {
1043
+ Uts.objEach(keepStore, function (item, index) {
1029
1044
  sessionStorage.setItem(index, keepStore[index]);
1030
1045
  });
1031
1046
  }
@@ -1048,7 +1063,7 @@ console.log(arr1);
1048
1063
  Uts.getTodayCache('userInfo')
1049
1064
  {name: 'zhangsan'}
1050
1065
  */
1051
- getTodayCache: function(storageKey) {
1066
+ getTodayCache: function (storageKey) {
1052
1067
  let cacheValue = storage.get(Uts.EVERYDAYCACHE);
1053
1068
  if (cacheValue) {
1054
1069
  return cacheValue[storageKey];
@@ -1063,7 +1078,7 @@ Uts.getTodayCache('userInfo')
1063
1078
  * @example
1064
1079
  * Uts.setTodayCache('userInfo',{name:'zhangsan'})
1065
1080
  */
1066
- setTodayCache: function(storageKey, valueToSet = true) {
1081
+ setTodayCache: function (storageKey, valueToSet = true) {
1067
1082
  let limitTime = new Date().addDay(1).ZenFormat("Y-m-d") + " 00:00:00";
1068
1083
  let cacheValue = storage.get(Uts.EVERYDAYCACHE) || {};
1069
1084
  cacheValue[storageKey] = valueToSet;
@@ -1090,7 +1105,7 @@ Uts.getTodayCache('userInfo')
1090
1105
  },
1091
1106
 
1092
1107
  //返回能否自动登录
1093
- getAutoLoginInfo: function(_loginSite) {
1108
+ getAutoLoginInfo: function (_loginSite) {
1094
1109
  let loginSite = _loginSite || $state.params.loginSite || "www";
1095
1110
  let autoLoginInfo = Uts.storage.get("autoLoginInfo") || { www: {}, oms: {}, hms: {} };
1096
1111
  if (Uts.getCookie("autoLoginInfo") && JSON.parse(Uts.getCookie("autoLoginInfo"))) {
@@ -1113,7 +1128,7 @@ Uts.getTodayCache('userInfo')
1113
1128
  }
1114
1129
  if (Uts.autoKeepSessionWhenLogOut && Uts.autoKeepSessionWhenLogOut.length > 0) {
1115
1130
  let resultObj = {};
1116
- Uts.each(Uts.autoKeepSessionWhenLogOut, function(item, index) {
1131
+ Uts.each(Uts.autoKeepSessionWhenLogOut, function (item, index) {
1117
1132
  resultObj[item] = sessionStorage.getItem(item);
1118
1133
  });
1119
1134
  result = resultObj;
@@ -1124,7 +1139,7 @@ Uts.getTodayCache('userInfo')
1124
1139
  saveTempStoreList(list) {
1125
1140
  let tempMaps = {};
1126
1141
  list &&
1127
- list.map(item => {
1142
+ list.map((item) => {
1128
1143
  // let val = Uts.storage.get(item);
1129
1144
  let val = localStorage[item];
1130
1145
  try {
@@ -1139,7 +1154,7 @@ Uts.getTodayCache('userInfo')
1139
1154
  let tempMaps = Uts.tempMaps;
1140
1155
  let keys = Object.keys(tempMaps);
1141
1156
  keys &&
1142
- keys.map(key => {
1157
+ keys.map((key) => {
1143
1158
  let value = tempMaps[key];
1144
1159
  let expires = 0;
1145
1160
  if (Uts.isPureObject(value)) {
@@ -1164,7 +1179,7 @@ Uts.getTodayCache('userInfo')
1164
1179
  * Uts.highlightKeyWord("<span class='test'>广州锐竞信息科技有限责任公司</span>",['广州','锐竞', '广州锐竞']);
1165
1180
  "<span class='zen_red'><span class='zen_red'><span class='test'>广州<span class='zen_red'></span>锐竞</span></span>信息科技有限责任公司</span>"
1166
1181
  */
1167
- highlightKeyWord: function(str = "", keywordList = [], config = {}) {
1182
+ highlightKeyWord: function (str = "", keywordList = [], config = {}) {
1168
1183
  const { tag = "span", className = "zen_red", onMatch } = config;
1169
1184
  // let startWord = "#####";
1170
1185
  let startWord = "<" + tag + " class='" + className + "'>";
@@ -1180,12 +1195,12 @@ Uts.getTodayCache('userInfo')
1180
1195
  keywordList = [keywordList];
1181
1196
  }
1182
1197
  if (Uts.isArray(keywordList)) {
1183
- Uts.each(keywordList, function(keyword, index) {
1198
+ Uts.each(keywordList, function (keyword, index) {
1184
1199
  if (Uts.notEmptyString(keyword)) {
1185
1200
  // let regStr = keyword.replace(/(.)/g, "([#$]{5,6}){0,}$1([#$]{5,6}){0,}");
1186
1201
  let regStr = keyword.replace(/(.)/g, "(" + startWordReg + "){0,}$1(" + endWordReg + "){0,}");
1187
1202
  let reg = new RegExp(regStr, "g");
1188
- computeStr = computeStr.replace(reg, function(partMatch, fullMatch) {
1203
+ computeStr = computeStr.replace(reg, function (partMatch, fullMatch) {
1189
1204
  if (Uts.isFunction(onMatch)) {
1190
1205
  return onMatch(partMatch, startWord, endWord);
1191
1206
  } else {
@@ -1210,7 +1225,7 @@ Uts.getTodayCache('userInfo')
1210
1225
  * Uts.formatDate(new Date(),'Y-m-d H:i:s')
1211
1226
  '2022-07-19 11:34:15'
1212
1227
  */
1213
- formatDate: function(date, format) {
1228
+ formatDate: function (date, format) {
1214
1229
  if (!date) {
1215
1230
  return false;
1216
1231
  }
@@ -1250,7 +1265,7 @@ Uts.getTodayCache('userInfo')
1250
1265
  return encodeURIComponent(s);
1251
1266
  },
1252
1267
 
1253
- cookiesMap: function() {
1268
+ cookiesMap: function () {
1254
1269
  var cookies = document.cookie ? document.cookie.split("; ") : [];
1255
1270
  var result = {};
1256
1271
  for (var i = 0, l = cookies.length; i < l; i++) {
@@ -1295,10 +1310,15 @@ Uts.getEnv()
1295
1310
  getEnv(string) {
1296
1311
  let config = {};
1297
1312
  let host = string || location.host;
1313
+ const projectName = process.env.VUE_APP_PROJECT_NAME;
1314
+ const projectConfigs = {
1315
+ "postal-benefits-platform-level": { reqModule: "management" }
1316
+ // 可继续添加其它项目配置
1317
+ };
1298
1318
  const projectConfig = {
1299
- [process.env.VUE_APP_PROJECT_NAME]: { reqModule: "admin" },
1300
- ["postal-benefits-platform-level"]: { reqModule: "management" }
1301
- }[process.env.VUE_APP_PROJECT_NAME] || {};
1319
+ projectName,
1320
+ ...(projectConfigs[projectName] || { reqModule: "admin" })
1321
+ };
1302
1322
 
1303
1323
  config.rootDomain = (host.match(Uts.FINDDOMAINEXP) && host.match(Uts.FINDDOMAINEXP)[0]) || null;
1304
1324
  config.env = "";
@@ -1409,11 +1429,11 @@ Uts.findObjByCondition(arr1,{a:1,f:3});
1409
1429
  let _self = this;
1410
1430
  let result = [];
1411
1431
  let keys = Object.getOwnPropertyNames(cond);
1412
- _self.each(arr, function(item, index) {
1432
+ _self.each(arr, function (item, index) {
1413
1433
  let isMatch = true;
1414
1434
  let matchIndex;
1415
1435
  if (!isStrictMode || (isStrictMode && Object.getOwnPropertyNames(item).length == keys.length)) {
1416
- _self.each(keys, function(keysItem, keysIndex) {
1436
+ _self.each(keys, function (keysItem, keysIndex) {
1417
1437
  if (!Uts.isPureObject(item) || item[keysItem] != cond[keysItem]) {
1418
1438
  isMatch = false;
1419
1439
  }
@@ -1471,7 +1491,7 @@ Uts.filterObjByCondition(arr1,{a:1,f:3});
1471
1491
  */
1472
1492
  filterObjByCondition(arr, cond, isStrictMode) {
1473
1493
  let findResult = Uts.findObjByCondition(arr, cond, isStrictMode);
1474
- return findResult;
1494
+ return findResult || [];
1475
1495
  },
1476
1496
 
1477
1497
  /**
@@ -1512,9 +1532,9 @@ Uts.filterObjByRegexpCondition([{a:1},{a:2},{a:3},{b:2}],{a:"1",b:2},null,true)
1512
1532
  let result = [];
1513
1533
  let keys = Uts.getObjectKeys(cond);
1514
1534
  if (Uts.notEmptyArray(arr)) {
1515
- Uts.each(arr, function(item, index) {
1535
+ Uts.each(arr, function (item, index) {
1516
1536
  let isMatch = isSingleMode ? false : true; //如果是单条件匹配模式,则初始化默认为不match;否则默认为match
1517
- Uts.each(keys, function(keyItem, keyIndex, run) {
1537
+ Uts.each(keys, function (keyItem, keyIndex, run) {
1518
1538
  let condValue = cond[keyItem];
1519
1539
  let itemValue = item[keyItem];
1520
1540
  if (isIgnoreCase) {
@@ -1598,7 +1618,7 @@ false
1598
1618
  if (Uts.isObject(rawObject) && Uts.isObject(compareObject)) {
1599
1619
  let rawKeys = Uts.getObjectKeys(rawObject);
1600
1620
  if (rawKeys.length == Uts.getObjectKeys(compareObject).length) {
1601
- Uts.each(rawKeys, function(item, index) {
1621
+ Uts.each(rawKeys, function (item, index) {
1602
1622
  let rawItem = rawObject[item];
1603
1623
  let compareItem = compareObject[item];
1604
1624
  if (Uts.isObject(rawItem) && Uts.isObject(compareItem)) {
@@ -1665,12 +1685,12 @@ console.log(o1)
1665
1685
  }
1666
1686
  if (isOverride) {
1667
1687
  let propertyList = Uts.getObjectKeys(object);
1668
- Uts.each(propertyList, function(item, index) {
1688
+ Uts.each(propertyList, function (item, index) {
1669
1689
  delete object[item];
1670
1690
  });
1671
1691
  }
1672
1692
  let newPropertyList = Uts.getObjectKeys(valueObject);
1673
- Uts.each(newPropertyList, function(item, index) {
1693
+ Uts.each(newPropertyList, function (item, index) {
1674
1694
  object[item] = valueObject[item];
1675
1695
  });
1676
1696
  },
@@ -1682,35 +1702,13 @@ console.log(o1)
1682
1702
  * @returns {Object} 合并后的目标对象
1683
1703
  */
1684
1704
  deepMerge(target, source, overwrite = false) {
1685
- if (!source || typeof source !== "object") return target;
1686
- if (!target || typeof target !== "object") return source;
1687
-
1688
- Object.keys(source).forEach(key => {
1689
- const sourceValue = source[key];
1690
- const targetValue = target[key];
1691
-
1692
- if (Array.isArray(sourceValue)) {
1693
- // 处理数组:如果不覆盖且目标已存在,保持原数组
1694
- if (!overwrite && targetValue !== undefined) {
1695
- return;
1696
- }
1697
- target[key] = [...sourceValue];
1698
- } else if (sourceValue && typeof sourceValue === "object") {
1699
- // 处理对象:递归合并
1700
- if (!target[key] || typeof target[key] !== "object") {
1701
- target[key] = {};
1702
- }
1703
- Uts.deepMerge(target[key], sourceValue, overwrite);
1704
- } else {
1705
- // 处理基本类型:如果不覆盖且目标已存在,跳过
1706
- if (!overwrite && targetValue !== undefined) {
1707
- return;
1708
- }
1709
- target[key] = sourceValue;
1710
- }
1711
- });
1712
-
1713
- return target;
1705
+ return deepMergeImpl(target, source, overwrite);
1706
+ },
1707
+ mergePageConfig(...sources) {
1708
+ return mergePageConfigImpl(...sources);
1709
+ },
1710
+ resolvePlatformPageConfig(pageConfig, platform, options) {
1711
+ return resolvePlatformPageConfigImpl(pageConfig, platform, options);
1714
1712
  },
1715
1713
  /**
1716
1714
  * 转换字符串为小写
@@ -1781,7 +1779,7 @@ Uts.float(23,1)
1781
1779
  function addZero(floatValue, currentLength, desLength) {
1782
1780
  let lengthArr = new Array(desLength - currentLength);
1783
1781
  let valueArr = [];
1784
- Uts.each(lengthArr, function(item, index) {
1782
+ Uts.each(lengthArr, function (item, index) {
1785
1783
  valueArr.push(0);
1786
1784
  });
1787
1785
  let toAddZero = valueArr.join("");
@@ -1840,10 +1838,7 @@ Uts.getNumberValueByUnit(928212,"千")
1840
1838
  let unitConfig = ["分", "角", "元", "拾", "佰", "千", "万", "十万", "百万", "千万", "亿", "十亿", "百亿", "千亿"];
1841
1839
  let unitIndexAtConfig = Uts.index(unitConfig, unit);
1842
1840
  if (unitIndexAtConfig > -1) {
1843
- let floatFormatValueRevertArray = floatFormatValue
1844
- .replace(".", "")
1845
- .split("")
1846
- .reverse();
1841
+ let floatFormatValueRevertArray = floatFormatValue.replace(".", "").split("").reverse();
1847
1842
  return floatFormatValueRevertArray[unitIndexAtConfig];
1848
1843
  }
1849
1844
  }
@@ -1941,7 +1936,7 @@ Uts.TR(false,'a',"b")
1941
1936
  //例如某个状态下,只有某个单位采用这个文案,其他单位不是
1942
1937
  //Uts.textConfig(data.order.status, Uts.getAutoMatchFromConfig({ key: "status", value: "text", list: Uts.orderStatusMaps }), "order")
1943
1938
  */
1944
- textConfig: function(status, matchObj = {}, type, customText = Uts.textConfigObject) {
1939
+ textConfig: function (status, matchObj = {}, type, customText = Uts.textConfigObject) {
1945
1940
  let orgCode = Uts.getCookie("orgCode");
1946
1941
  if (!Uts.isPureObject(customText)) {
1947
1942
  // ZenUI.error("请先配置Uts.textConfigObject");
@@ -1966,7 +1961,7 @@ Uts.TR(false,'a',"b")
1966
1961
  * @example
1967
1962
  autoMatch(5,{"1":待提交,"2":"待审批","3":"预订中","5":"交易已完成"});
1968
1963
  */
1969
- autoMatch: function(text, obj, config = {}) {
1964
+ autoMatch: function (text, obj, config = {}) {
1970
1965
  let {
1971
1966
  key = "status",
1972
1967
  value = "text",
@@ -2000,7 +1995,7 @@ Uts.TR(false,'a',"b")
2000
1995
  }
2001
1996
  if (Uts.notEmptyArray(text) && parseArray) {
2002
1997
  let resultStrArray = [];
2003
- Uts.each(text, function(singleText, singleTextIndex) {
1998
+ Uts.each(text, function (singleText, singleTextIndex) {
2004
1999
  resultStrArray.push(obj[singleText]);
2005
2000
  });
2006
2001
  return resultStrArray.join(sperateSymbol);
@@ -2021,7 +2016,7 @@ Uts.TR(false,'a',"b")
2021
2016
  //例如某个状态下,只有某个单位启用这个功能
2022
2017
  //Uts.checkConfig('showFoundCard','ZHONG_SHAN_DA_XUE')
2023
2018
  */
2024
- checkConfig: function(configName, orgCode, fullConfig = Uts.customConfig) {
2019
+ checkConfig: function (configName, orgCode, fullConfig = Uts.customConfig) {
2025
2020
  let currentOrgCode = orgCode || Uts.getCookie("orgCode");
2026
2021
  /*
2027
2022
  配置列表(按业务区域分):
@@ -2050,7 +2045,7 @@ false
2050
2045
  */
2051
2046
  checkCondition(conditionArrayList, type = "or") {
2052
2047
  let isMatch = type == "or" ? false : true;
2053
- Uts.each(conditionArrayList, function(result, index, run) {
2048
+ Uts.each(conditionArrayList, function (result, index, run) {
2054
2049
  if (type == "or" && result) {
2055
2050
  isMatch = true;
2056
2051
  run.stop = true;
@@ -2146,7 +2141,7 @@ true
2146
2141
  valueConfig.isNot = true;
2147
2142
  }
2148
2143
  let firstKey = "";
2149
- key = key.replace(/([^\.]+\.)/, function(matchStr, fullStr) {
2144
+ key = key.replace(/([^\.]+\.)/, function (matchStr, fullStr) {
2150
2145
  firstKey = matchStr.replace(/!|\./g, "");
2151
2146
  return "";
2152
2147
  });
@@ -2281,7 +2276,7 @@ true
2281
2276
  return execConfig.matchResult;
2282
2277
  }
2283
2278
  if (Uts.notEmptyArray(configList)) {
2284
- Uts.each(configList, function(configItem, configItemIndex, run) {
2279
+ Uts.each(configList, function (configItem, configItemIndex, run) {
2285
2280
  // deepIndex stop for pre level
2286
2281
  if (execConfig._stop) {
2287
2282
  run.stop = true;
@@ -2290,7 +2285,7 @@ true
2290
2285
  let singleThread = { matchAllExceptAndOne: true };
2291
2286
 
2292
2287
  // 单个条件满足即为true,如果有andOne属性,同级属性满足后,递归判断满足一项即可
2293
- Uts.objEach(configItem, function(perConfigValue, perConfigKey, perConfigRun) {
2288
+ Uts.objEach(configItem, function (perConfigValue, perConfigKey, perConfigRun) {
2294
2289
  if (perConfigKey != "andOne") {
2295
2290
  let currentConditionValue = Uts.getValueByExpression(perConfigKey, options);
2296
2291
  if (!compareValueForType(perConfigValue, currentConditionValue)) {
@@ -2383,16 +2378,16 @@ Uts.useConfigExpression(
2383
2378
  //返回结果
2384
2379
  //{title: '文案2'}
2385
2380
  */
2386
- useConfigExpression: function(configObject, options) {
2381
+ useConfigExpression: function (configObject, options) {
2387
2382
  let resultObject = {};
2388
2383
  if (Uts.isPureObject(configObject)) {
2389
- Uts.objEach(configObject, function(value, key) {
2384
+ Uts.objEach(configObject, function (value, key) {
2390
2385
  let matchAnyOne = true;
2391
2386
  if (Uts.notEmptyArray(value)) {
2392
2387
  let execResult = Uts.checkValueByExpression(value, matchAnyOne, options);
2393
2388
  resultObject[key] = execResult;
2394
2389
  } else if (Uts.isPureObject(value)) {
2395
- Uts.objEach(value, function(itemValue, itemKey, run) {
2390
+ Uts.objEach(value, function (itemValue, itemKey, run) {
2396
2391
  let childExecResult = Uts.checkValueByExpression(itemValue, matchAnyOne, options);
2397
2392
  if (childExecResult) {
2398
2393
  resultObject[key] = itemKey;
@@ -2440,7 +2435,7 @@ Filter.formatDate(1695555940859,'Y-m-d H:i:s')
2440
2435
  i: 60 * second,
2441
2436
  s: second
2442
2437
  };
2443
- str = str.replace(/(\d+)(\w)/g, function(a, b, c) {
2438
+ str = str.replace(/(\d+)(\w)/g, function (a, b, c) {
2444
2439
  // console.log(a,b,c)
2445
2440
  if (timeConfig[c]) {
2446
2441
  return Number(b) * timeConfig[c] + "_";
@@ -2451,7 +2446,7 @@ Filter.formatDate(1695555940859,'Y-m-d H:i:s')
2451
2446
  str = str.replace(/_$/, "");
2452
2447
  let countArr = str.split("_");
2453
2448
  let totalSecond = 0;
2454
- Uts.each(countArr, function(item, index) {
2449
+ Uts.each(countArr, function (item, index) {
2455
2450
  totalSecond += Number(item);
2456
2451
  });
2457
2452
  return parseInt(totalSecond + currentTime);
@@ -2497,7 +2492,7 @@ Filter.formatDate(1695555940859,'Y-m-d H:i:s')
2497
2492
  let resultObj = { value: "" };
2498
2493
  let defaultArr = ["天", "小时", "分", "秒"];
2499
2494
  let cacheTimestamp = millisecond;
2500
- Uts.each(defaultArr, function(str, index) {
2495
+ Uts.each(defaultArr, function (str, index) {
2501
2496
  if (Uts.contain(arr, str)) {
2502
2497
  let computeResult = cacheTimestamp.div(timeConfig[str]);
2503
2498
  resultObj[str] = String(parseInt(computeResult));
@@ -2530,7 +2525,7 @@ Filter.formatDate(1695555940859,'Y-m-d H:i:s')
2530
2525
  storage.get('WWWUseName')
2531
2526
  'zhangsan'
2532
2527
  */
2533
- get: function(name) {
2528
+ get: function (name) {
2534
2529
  let value = localStorage.getItem(name);
2535
2530
  try {
2536
2531
  value = Uts.toJSON(value);
@@ -2556,7 +2551,7 @@ storage.get('WWWUseName')
2556
2551
  * storage.set('key','some value');
2557
2552
  * storage.set('key','some value','1h');
2558
2553
  */
2559
- set: function(name, value, expires = 0) {
2554
+ set: function (name, value, expires = 0) {
2560
2555
  if (Uts.isDefined(value)) {
2561
2556
  if (Uts.isDefined(expires) && expires !== 0) {
2562
2557
  value = {
@@ -2579,11 +2574,11 @@ storage.get('WWWUseName')
2579
2574
  * @example
2580
2575
  * storage.remove('testCache');
2581
2576
  */
2582
- remove: function(name) {
2577
+ remove: function (name) {
2583
2578
  localStorage.removeItem(name);
2584
2579
  },
2585
2580
 
2586
- clear: function(name) {
2581
+ clear: function (name) {
2587
2582
  localStorage.clear();
2588
2583
  },
2589
2584
  /**
@@ -2611,7 +2606,7 @@ storage.get('WWWUseName')
2611
2606
  * @example
2612
2607
  * storage.setProjectCache('user')
2613
2608
  */
2614
- setProjectCache: function(name, value) {
2609
+ setProjectCache: function (name, value) {
2615
2610
  if (Uts.notEmptyString(name)) {
2616
2611
  let fullName = storage.getProjectCacheName(name);
2617
2612
  storage.set(fullName, value);
@@ -2627,7 +2622,7 @@ storage.get('WWWUseName')
2627
2622
  storage.getProjectCache('user')
2628
2623
  123
2629
2624
  */
2630
- getProjectCache: function(name) {
2625
+ getProjectCache: function (name) {
2631
2626
  if (Uts.notEmptyString(name)) {
2632
2627
  let fullName = storage.getProjectCacheName(name);
2633
2628
 
@@ -2648,7 +2643,7 @@ storage.getProjectCache('user')
2648
2643
  * @example
2649
2644
  * ssStorage.get('refreshToken');
2650
2645
  */
2651
- get: function(name) {
2646
+ get: function (name) {
2652
2647
  let value = sessionStorage.getItem(name);
2653
2648
  try {
2654
2649
  value = Uts.toJSON(value);
@@ -2666,7 +2661,7 @@ storage.getProjectCache('user')
2666
2661
  * ssStorage.set('key','some value');
2667
2662
  * ssStorage.set('key','some value','1h');
2668
2663
  */
2669
- set: function(name, value) {
2664
+ set: function (name, value) {
2670
2665
  if (Uts.isDefined(value)) {
2671
2666
  if (Uts.isObject(value)) {
2672
2667
  value = Uts.toStr(value);
@@ -2683,10 +2678,10 @@ storage.getProjectCache('user')
2683
2678
  * @example
2684
2679
  * ssStorage.remove('testCache');
2685
2680
  */
2686
- remove: function(name) {
2681
+ remove: function (name) {
2687
2682
  sessionStorage.removeItem(name);
2688
2683
  },
2689
- clear: function() {
2684
+ clear: function () {
2690
2685
  sessionStorage.clear();
2691
2686
  }
2692
2687
  },
@@ -2721,10 +2716,10 @@ storage.getProjectCache('user')
2721
2716
  (n[srcProp] = t),
2722
2717
  (n.anysc = !0),
2723
2718
  null == n.onload
2724
- ? (n.onload = function() {
2719
+ ? (n.onload = function () {
2725
2720
  "function" == typeof e && e(n);
2726
2721
  })
2727
- : (n.onreadystatechange = function() {
2722
+ : (n.onreadystatechange = function () {
2728
2723
  ("loaded" != n.readyState && "complete" != n.readyState) || ("function" == typeof e && e(n));
2729
2724
  }),
2730
2725
  Uts.addDom("append", document.getElementsByTagName("body")[0], n);
@@ -2814,7 +2809,7 @@ storage.getProjectCache('user')
2814
2809
  let iframe = Uts.createDom("iframe");
2815
2810
  iframe.src = url;
2816
2811
  iframe.style = "display:none;height:1px;width:1px";
2817
- iframe.onload = function(e) {
2812
+ iframe.onload = function (e) {
2818
2813
  typeof callBack == "function" ? callBack(e) : "";
2819
2814
  shouldRemove && Uts.removeDom(iframe);
2820
2815
  };
@@ -2908,7 +2903,7 @@ storage.getProjectCache('user')
2908
2903
  }
2909
2904
  let classNameList = className.split(" ");
2910
2905
  let matchResult = true;
2911
- Uts.each(classNameList, function(currentClassName, index) {
2906
+ Uts.each(classNameList, function (currentClassName, index) {
2912
2907
  if (!new RegExp(" " + className + " ").test(" " + elem.className + " ")) {
2913
2908
  matchResult = false;
2914
2909
  }
@@ -2919,17 +2914,17 @@ storage.getProjectCache('user')
2919
2914
  开启/关闭:Uts.cacheAPIData('all')//'all'/true/false/100
2920
2915
  清除:Uts.clearCacheAPIData()
2921
2916
  */
2922
- cacheAPIData: function(type, text, options) {
2917
+ cacheAPIData: function (type, text, options) {
2923
2918
  // if (type) {
2924
2919
  // CacheRequest.startRecordRequest(type, text, options);
2925
2920
  // } else {
2926
2921
  // CacheRequest.stopRecordRequest(type, text, options);
2927
2922
  // }
2928
2923
  },
2929
- clearCacheAPIData: function() {
2924
+ clearCacheAPIData: function () {
2930
2925
  // CacheRequest.cleanRequestCache();
2931
2926
  },
2932
- getCacheApiData: function(name) {
2927
+ getCacheApiData: function (name) {
2933
2928
  // return CacheRequest.getCache(name);
2934
2929
  },
2935
2930
  /**
@@ -3152,7 +3147,7 @@ storage.getProjectCache('user')
3152
3147
  allTagEXP: /<[^>]+>/gim,
3153
3148
  TAGNAMEEXP: /<([^\s>]+)(\s|>)+/,
3154
3149
  FINDDOMAINEXP: /[^\.]+\.[^\.]+$/,
3155
- TAGVALUEEXP: function(tagName) {
3150
+ TAGVALUEEXP: function (tagName) {
3156
3151
  return new RegExp("^<" + tagName + "[^>]{0,}>|</" + tagName + ">$", "g");
3157
3152
  },
3158
3153
  /**
@@ -3170,7 +3165,7 @@ storage.getProjectCache('user')
3170
3165
  return false;
3171
3166
  }
3172
3167
  let classNameList = className.split(" ");
3173
- Uts.each(classNameList, function(currentClassName, index) {
3168
+ Uts.each(classNameList, function (currentClassName, index) {
3174
3169
  if (!Uts.hasClass(elem, currentClassName)) {
3175
3170
  elem.className += (!elem.className ? "" : " ") + currentClassName;
3176
3171
  }
@@ -3190,10 +3185,7 @@ storage.getProjectCache('user')
3190
3185
  return false;
3191
3186
  }
3192
3187
  if (Uts.hasClass(elem, className, true)) {
3193
- let matchStr = className
3194
- .split(" ")
3195
- .join("\\b|\\b")
3196
- .replace(/ {2,}/g, " ");
3188
+ let matchStr = className.split(" ").join("\\b|\\b").replace(/ {2,}/g, " ");
3197
3189
  let regExp = new RegExp(" " + matchStr + " ", "g");
3198
3190
  let toCheckClass = " " + elem.className + " ";
3199
3191
  elem.className = toCheckClass
@@ -3246,7 +3238,7 @@ Uts.notEmptyObject({})
3246
3238
  return false;
3247
3239
  }
3248
3240
  let valueList = paramsObj[stateName].split(",");
3249
- let newValueList = valueList.filter(function(data) {
3241
+ let newValueList = valueList.filter(function (data) {
3250
3242
  return data != value;
3251
3243
  });
3252
3244
  let STREXP = new RegExp("([\\?&])" + stateName + "=[^&]*");
@@ -3305,7 +3297,7 @@ Uts.notEmptyObject({})
3305
3297
  var str = "";
3306
3298
  var currentHash = location.hash;
3307
3299
  var newHash = "";
3308
- Uts.each(stateList, function(item, index) {
3300
+ Uts.each(stateList, function (item, index) {
3309
3301
  //var USEREGEXP=/&?__modalList=([^&]*)|&?__testList=([^&]*)|&?__modalList$|&?__testList/g
3310
3302
  str += (index > 0 ? "|" : "") + "&?" + item + "=([^&]*)|&?" + item + "$";
3311
3303
  });
@@ -3351,7 +3343,7 @@ Uts.notEmptyObject({})
3351
3343
  history.replaceState(null, null, newUrl);
3352
3344
  },
3353
3345
  removeHashSiteList: ["bio"],
3354
- checkShouldRemoveHash: function() {
3346
+ checkShouldRemoveHash: function () {
3355
3347
  if (Uts.isDefined(Uts.currentSiteShouldRemoveHash)) {
3356
3348
  return Uts.currentSiteShouldRemoveHash;
3357
3349
  } else {
@@ -3360,12 +3352,12 @@ Uts.notEmptyObject({})
3360
3352
  return Uts.currentSiteShouldRemoveHash;
3361
3353
  }
3362
3354
  },
3363
- initHashCache: function() {
3355
+ initHashCache: function () {
3364
3356
  Uts.cachePathname = location.pathname;
3365
3357
  Uts.cacheUrlBeforeHash = Uts.getPartStringBySymbolIndex(location.href, "#", 0, 1);
3366
3358
  Uts.cacheUrlBeforeHash = Uts.cacheUrlBeforeHash.replace(/index.html$/, "");
3367
3359
  },
3368
- dispatchHashChange: function() {
3360
+ dispatchHashChange: function () {
3369
3361
  // window.dispatchEvent(new HashChangeEvent("hashchange"));
3370
3362
  if (typeof HashChangeEvent !== "undefined") {
3371
3363
  window.dispatchEvent(new HashChangeEvent("hashchange"));
@@ -3385,7 +3377,7 @@ Uts.notEmptyObject({})
3385
3377
  ieEvent.initEvent("hashchange", true, true);
3386
3378
  window.dispatchEvent(ieEvent);
3387
3379
  },
3388
- routeByCacheHash: function(hashUrl) {
3380
+ routeByCacheHash: function (hashUrl) {
3389
3381
  if (!Uts.startWith(hashUrl, "/")) {
3390
3382
  hashUrl = "/" + hashUrl;
3391
3383
  }
@@ -3396,7 +3388,7 @@ Uts.notEmptyObject({})
3396
3388
  Uts.dispatchHashChange();
3397
3389
  // Uts.href(Uts.cacheUrlBeforeHash + "#" + hashUrl, undefined, "notPrefetchParams");
3398
3390
  },
3399
- onPopStateChange: function(event) {
3391
+ onPopStateChange: function (event) {
3400
3392
  // let newLink = Uts.cacheUrlBeforeHash + Uts.lastCacheHash;
3401
3393
  // Uts.repleaceState(null, null, newLink);
3402
3394
  // console.log("onPopStateChange", newLink);
@@ -3407,7 +3399,7 @@ Uts.notEmptyObject({})
3407
3399
  // Uts.dispatchHashChange();
3408
3400
  // Uts.fireListen({ type: "locationChange", action: {} });
3409
3401
  },
3410
- checkAndRemoveHash: function() {
3402
+ checkAndRemoveHash: function () {
3411
3403
  if (!Uts.isDevMode() && Uts.checkShouldRemoveHash()) {
3412
3404
  let hashWithoutStartSymbol = location.hash.replace("#/", "");
3413
3405
  let newLink = Uts.cacheUrlBeforeHash + hashWithoutStartSymbol;
@@ -3663,7 +3655,7 @@ console.log(obj);
3663
3655
  if (Uts.isObject(object)) {
3664
3656
  let valueNameList = Uts.getObjectKeys(config);
3665
3657
  if (Uts.notEmptyArray(valueNameList)) {
3666
- Uts.each(valueNameList, function(item, index) {
3658
+ Uts.each(valueNameList, function (item, index) {
3667
3659
  if (Uts.isFunction(callback)) {
3668
3660
  callback(item, index, object, config);
3669
3661
  } else {
@@ -3698,7 +3690,7 @@ console.log(obj);
3698
3690
  initUA() {
3699
3691
  var bodyEle = document.getElementsByTagName("body")[0];
3700
3692
  var browser = {
3701
- versions: (function() {
3693
+ versions: (function () {
3702
3694
  var u = navigator.userAgent,
3703
3695
  app = navigator.appVersion;
3704
3696
  return {
@@ -3726,12 +3718,13 @@ console.log(obj);
3726
3718
  }
3727
3719
  }
3728
3720
  },
3729
- isTablet: function(type) {
3721
+ isTablet: function (type) {
3730
3722
  // let isIPad = navigator.maxTouchPoints && navigator.maxTouchPoints > 2 && /MacIntel/.test(navigator.platform);
3731
3723
  const userAgent = navigator.userAgent.toLowerCase();
3732
- const isTablet = /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(
3733
- userAgent
3734
- );
3724
+ const isTablet =
3725
+ /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(
3726
+ userAgent
3727
+ );
3735
3728
  if (isTablet) {
3736
3729
  return isTablet;
3737
3730
  } else {
@@ -3753,7 +3746,7 @@ console.log(obj);
3753
3746
  * //切换为手机显示模式
3754
3747
  Uts.toggleMobileViewport()
3755
3748
  */
3756
- toggleMobileViewport: function(newViewportValue) {
3749
+ toggleMobileViewport: function (newViewportValue) {
3757
3750
  let defaultMobileViewport =
3758
3751
  "width=device-width,user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0";
3759
3752
  newViewportValue = newViewportValue || defaultMobileViewport;
@@ -3921,6 +3914,21 @@ false
3921
3914
  isNull(value) {
3922
3915
  return value === null;
3923
3916
  },
3917
+ /**
3918
+ * 判断接口字段是否有实际返回值;0 和 false 是有效值,仅排除 undefined、null、空字符串。
3919
+ * @module checkType
3920
+ * @todo Uts.isPresentValue
3921
+ * @param {*} value 要检查的值
3922
+ * @return {Boolean}
3923
+ * @example
3924
+ * Uts.isPresentValue(0)
3925
+ true
3926
+ Uts.isPresentValue('')
3927
+ false
3928
+ */
3929
+ isPresentValue(value) {
3930
+ return value !== undefined && value !== null && value !== "";
3931
+ },
3924
3932
  /**
3925
3933
  * 检查数值是否为NaN
3926
3934
  * @module checkType
@@ -3929,9 +3937,9 @@ false
3929
3937
  * @return {Boolean}
3930
3938
  * @example
3931
3939
  * Uts.isNaN({})
3932
- false
3933
- Uts.isNaN(NaN)
3934
- true
3940
+ false
3941
+ Uts.isNaN(NaN)
3942
+ true
3935
3943
  */
3936
3944
  isNaN(value) {
3937
3945
  return value !== value;
@@ -3944,9 +3952,9 @@ true
3944
3952
  * @return {Boolean} true or false
3945
3953
  * @example
3946
3954
  * Uts.isString('w')
3947
- true
3948
- Uts.isString(1)
3949
- false
3955
+ true
3956
+ Uts.isString(1)
3957
+ false
3950
3958
  */
3951
3959
  isString(value) {
3952
3960
  return typeof value === "string";
@@ -3959,9 +3967,9 @@ false
3959
3967
  * @return {Boolean} true or false
3960
3968
  * @example
3961
3969
  * Uts.isDate({})
3962
- false
3963
- Uts.isDate(new Date())
3964
- true
3970
+ false
3971
+ Uts.isDate(new Date())
3972
+ true
3965
3973
  */
3966
3974
  isDate(value) {
3967
3975
  return value && value.constructor === Date;
@@ -3975,9 +3983,9 @@ true
3975
3983
  * @return {Boolean} true or false
3976
3984
  * @example
3977
3985
  * Uts.isWaitingObject({})
3978
- false
3979
- Uts.isWaitingObject(new Waiting())
3980
- true
3986
+ false
3987
+ Uts.isWaitingObject(new Waiting())
3988
+ true
3981
3989
  */
3982
3990
  isWaitingObject(obj) {
3983
3991
  return obj && (obj instanceof Waiting || obj.endpoint || Uts.isFunction(obj.then));
@@ -3990,11 +3998,11 @@ true
3990
3998
  * @return {Boolean}
3991
3999
  * @example
3992
4000
  * Uts.isError({})
3993
- false
3994
- Uts.isError(new Error())
3995
- true
4001
+ false
4002
+ Uts.isError(new Error())
4003
+ true
3996
4004
  */
3997
- isError: function(obj) {
4005
+ isError: function (obj) {
3998
4006
  return obj && obj instanceof Error;
3999
4007
  },
4000
4008
  /**
@@ -4098,11 +4106,11 @@ console.log(o1);
4098
4106
  return url;
4099
4107
  }
4100
4108
  },
4101
- autoMatchField: function(configObject = {}, rawObject) {
4109
+ autoMatchField: function (configObject = {}, rawObject) {
4102
4110
  let newObejct;
4103
4111
  function setValueByKey(keyString, valueConfigString) {}
4104
4112
 
4105
- Uts.objEach(configObject, function(configValue, configKey) {
4113
+ Uts.objEach(configObject, function (configValue, configKey) {
4106
4114
  //"orderDetail.productList[].productDetail.goodList[].productId"
4107
4115
  //"applyOrderDetail.product[].detail.goodsList[].productSns"
4108
4116
 
@@ -4110,7 +4118,7 @@ console.log(o1);
4110
4118
  let readPathSplitByArray = configValue.split("[]");
4111
4119
  //['orderDetail.productList', '.productDetail.goodList', '.productId']
4112
4120
  //['applyOrderDetail.product', '.detail.goodsList', '.productSns']
4113
- Uts.each(writePathSplitByArray, function(perPathKey, perPathIndex) {});
4121
+ Uts.each(writePathSplitByArray, function (perPathKey, perPathIndex) {});
4114
4122
  });
4115
4123
  },
4116
4124
  /**
@@ -4217,7 +4225,7 @@ Uts.findIndex(arr1,null,customValidate)
4217
4225
  findIndex(source, obj, validate) {
4218
4226
  let index = -1;
4219
4227
  if (Uts.isArray(source) && Uts.isObject(obj)) {
4220
- Uts.each(source, function(item, itemIndex) {
4228
+ Uts.each(source, function (item, itemIndex) {
4221
4229
  if (item == obj || (Uts.isFunction(validate) && validate(item, itemIndex))) {
4222
4230
  Uts.pauseEach = true;
4223
4231
  index = itemIndex;
@@ -4252,7 +4260,7 @@ Uts.index(['a','b','c'],'b')
4252
4260
  return source.search(REGEXP);
4253
4261
  } else if (Uts.isArray(source)) {
4254
4262
  let matchPS = -1;
4255
- Uts.each(source, function(value2, index) {
4263
+ Uts.each(source, function (value2, index) {
4256
4264
  if (isContainMode) {
4257
4265
  if (REGEXP.test(value2)) {
4258
4266
  matchPS = index;
@@ -4303,7 +4311,7 @@ true
4303
4311
  return REGEXP.test(source);
4304
4312
  } else if (Uts.isArray(source)) {
4305
4313
  let isMatch = false;
4306
- Uts.each(source, function(value2, index) {
4314
+ Uts.each(source, function (value2, index) {
4307
4315
  if (isIgnoreCase) {
4308
4316
  value2 = Uts.toLowerCase(value2);
4309
4317
  }
@@ -4340,7 +4348,7 @@ true
4340
4348
  fetchObjectArrayToStringArray(source, fieldName, acceptRepeat) {
4341
4349
  let newArray = [];
4342
4350
  if (source && Uts.isArray(source)) {
4343
- Uts.each(source, function(item, index) {
4351
+ Uts.each(source, function (item, index) {
4344
4352
  if (item) {
4345
4353
  if (!Uts.contain(newArray, item[fieldName]) || acceptRepeat) {
4346
4354
  newArray.push(item[fieldName]);
@@ -4365,7 +4373,7 @@ Uts.fetchStringArrayToObject(['a','b','c'],'0')
4365
4373
  fetchStringArrayToObject(source, defaultValue = true) {
4366
4374
  let obj = {};
4367
4375
  if (source && Uts.isArray(source)) {
4368
- Uts.each(source, function(text, index) {
4376
+ Uts.each(source, function (text, index) {
4369
4377
  if (Uts.notEmptyString(text) || Uts.isNumber(text)) {
4370
4378
  obj[text] = defaultValue;
4371
4379
  }
@@ -4409,7 +4417,7 @@ console.log(arr1)
4409
4417
  ]
4410
4418
  */
4411
4419
  arrayUpdateEachValue(list, config = { key: "selected", value: true }, callBackExecForEach) {
4412
- Uts.each(list, function(item, index) {
4420
+ Uts.each(list, function (item, index) {
4413
4421
  let willChangeValue = config.value;
4414
4422
  if (Uts.isFunction(callBackExecForEach)) {
4415
4423
  willChangeValue = callBackExecForEach(item, index, config);
@@ -4479,7 +4487,7 @@ Uts.countTotalFromArray(arr3,'count');
4479
4487
  countTotalFromArray(array, fieldName) {
4480
4488
  if (Uts.isArray(array)) {
4481
4489
  let totalAmount = 0;
4482
- Uts.each(array, function(value, index) {
4490
+ Uts.each(array, function (value, index) {
4483
4491
  if (value) {
4484
4492
  let toAddValue;
4485
4493
  if (Uts.isPureObject(value) && Uts.isString(fieldName)) {
@@ -4511,7 +4519,7 @@ Uts.countTotalFromArray(arr3,'count');
4511
4519
  Uts.getSameBetweenArray(list);
4512
4520
  [4, 7]
4513
4521
  */
4514
- getSameBetweenArray: function(checkArryList, propName) {
4522
+ getSameBetweenArray: function (checkArryList, propName) {
4515
4523
  let resultArray = [];
4516
4524
  let midCacheObject = {};
4517
4525
  let matchLength = checkArryList.length;
@@ -4522,8 +4530,8 @@ Uts.getSameBetweenArray(list);
4522
4530
  midCacheObject[keyValue] = 1;
4523
4531
  }
4524
4532
  }
4525
- Uts.each(checkArryList, function(arr, arrIndex) {
4526
- Uts.each(arr, function(item, index) {
4533
+ Uts.each(checkArryList, function (arr, arrIndex) {
4534
+ Uts.each(arr, function (item, index) {
4527
4535
  let checkValue = item;
4528
4536
  if (Uts.isPureObject(item)) {
4529
4537
  checkValue = item[propName];
@@ -4605,8 +4613,8 @@ Uts.getSameBetweenArray(list);
4605
4613
  * Uts.sum([1,2,3,4,5,6])
4606
4614
  21
4607
4615
  */
4608
- sum: function(array) {
4609
- return array.reduce(function(prev, curr, idx, arr) {
4616
+ sum: function (array) {
4617
+ return array.reduce(function (prev, curr, idx, arr) {
4610
4618
  return prev + curr;
4611
4619
  });
4612
4620
  },
@@ -4620,7 +4628,7 @@ Uts.getSameBetweenArray(list);
4620
4628
  Uts.pluck([{name:'pm1'},{name:'pm2'}],"name");
4621
4629
  ['pm1', 'pm2']
4622
4630
  */
4623
- pluck: function(array, param, acceptRepeat) {
4631
+ pluck: function (array, param, acceptRepeat) {
4624
4632
  return Uts.fetchObjectArrayToStringArray(array, param, acceptRepeat);
4625
4633
  },
4626
4634
  /**
@@ -4634,7 +4642,7 @@ Uts.getSameBetweenArray(list);
4634
4642
  * Uts.pluckMap([{name:"zhangsan",age:18},{name:"lisi",age:20},{name:"wangwu",age:24}],'name','age')
4635
4643
  {zhangsan: 18, lisi: 20, wangwu: 24}
4636
4644
  */
4637
- pluckMap: function(array, keyParam, valueParam) {
4645
+ pluckMap: function (array, keyParam, valueParam) {
4638
4646
  let arrayMap = {};
4639
4647
  if (Uts.notEmptyArray(array)) {
4640
4648
  Uts.each(array, (item, index) => {
@@ -4653,7 +4661,7 @@ Uts.getSameBetweenArray(list);
4653
4661
  hookAjaxUrl(type, url, synType, other) {
4654
4662
  return url;
4655
4663
  },
4656
- _afterHookAjaxUrl: function(type, url, synType, other) {
4664
+ _afterHookAjaxUrl: function (type, url, synType, other) {
4657
4665
  // return MigrateTools.migrateRequestUrl(url);
4658
4666
  },
4659
4667
  setNewApiConfig(config, apiUrlStartLength = -2) {
@@ -4679,9 +4687,9 @@ Uts.getSameBetweenArray(list);
4679
4687
  return false;
4680
4688
  },
4681
4689
 
4682
- fetchTokenNameConfig: function() {
4690
+ fetchTokenNameConfig: function () {
4683
4691
  Uts.tokenNameConfigFetch = {};
4684
- Uts.objEach(Uts.tokenNameConfig, function(value, key) {
4692
+ Uts.objEach(Uts.tokenNameConfig, function (value, key) {
4685
4693
  Uts.tokenNameConfigFetch[value] = true;
4686
4694
  });
4687
4695
  },
@@ -4700,7 +4708,7 @@ Uts.getProjectTokenName('hms')
4700
4708
  Uts.getProjectTokenName('lab')
4701
4709
  'labLoginToken'
4702
4710
  */
4703
- getProjectTokenName: function(projcetName) {
4711
+ getProjectTokenName: function (projcetName) {
4704
4712
  projcetName = projcetName || Uts.getCurrentProject();
4705
4713
  let tokenNameConfig = Uts.tokenNameConfig;
4706
4714
  let defaultWWWToken = tokenNameConfig.www;
@@ -4719,7 +4727,7 @@ Uts.getTokenForProject()
4719
4727
  Uts.getTokenForProject()
4720
4728
  'YW50Y2Fz.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJyZWFnZW50...Iiw'
4721
4729
  */
4722
- getTokenForProject: function() {
4730
+ getTokenForProject: function () {
4723
4731
  //default is www
4724
4732
  let tokenName = Uts.getProjectTokenName();
4725
4733
  if (tokenName) {
@@ -4727,9 +4735,9 @@ Uts.getTokenForProject()
4727
4735
  }
4728
4736
  },
4729
4737
 
4730
- setGlobalToken: function() {},
4738
+ setGlobalToken: function () {},
4731
4739
 
4732
- getGlobalToken: function() {},
4740
+ getGlobalToken: function () {},
4733
4741
  /**
4734
4742
  * 统一处理已登录用户在某个项目的403无权限场景跳转
4735
4743
  * @module route
@@ -4741,7 +4749,7 @@ Uts.getTokenForProject()
4741
4749
  * //通常用于该项目的REST.hookWhenGetResponse内,自动统一处理无权限跳转
4742
4750
  * Uts.loginFor403(res,false,url);
4743
4751
  */
4744
- loginFor403: function(data = {}, isError, url) {
4752
+ loginFor403: function (data = {}, isError, url) {
4745
4753
  if (isError) {
4746
4754
  return;
4747
4755
  }
@@ -4758,7 +4766,7 @@ Uts.getTokenForProject()
4758
4766
  Uts.goLogin ||
4759
4767
  Uts.login ||
4760
4768
  Uts.toLogin ||
4761
- function() {
4769
+ function () {
4762
4770
  let backUrl = Uts.encode(location.href);
4763
4771
  let domainName = Uts.currentSecondDomain;
4764
4772
  Uts.routeToDomain(
@@ -4770,14 +4778,14 @@ Uts.getTokenForProject()
4770
4778
  }
4771
4779
  },
4772
4780
 
4773
- setBtkHeaderForProject: function(ajaxReq, methodName = "setRequestHeader") {
4781
+ setBtkHeaderForProject: function (ajaxReq, methodName = "setRequestHeader") {
4774
4782
  let cacheBtkObj = storage.getProjectCache("btk") || {};
4775
4783
  let projectToken = Uts.getTokenForProject();
4776
4784
  if (cacheBtkObj.btk && cacheBtkObj.token == projectToken) {
4777
4785
  ajaxReq[methodName]("btk", cacheBtkObj.btk);
4778
4786
  }
4779
4787
  },
4780
- setGlobalHeader: function(ajaxReq, methodName = "setRequestHeader") {
4788
+ setGlobalHeader: function (ajaxReq, methodName = "setRequestHeader") {
4781
4789
  if (Uts.currentEnv == "gray" || Uts.currentEnv == "publish") {
4782
4790
  // http://www.gray.rjmart.cn?gray_version=dengxuqian2310301800
4783
4791
  let grayVersion = Uts.getGrayInfo();
@@ -4787,14 +4795,14 @@ Uts.getTokenForProject()
4787
4795
  }
4788
4796
  },
4789
4797
 
4790
- getGrayInfo: function() {
4798
+ getGrayInfo: function () {
4791
4799
  return Uts.getCookie("gray_version");
4792
4800
  },
4793
- setGrayInfo: function(value) {
4801
+ setGrayInfo: function (value) {
4794
4802
  return Uts.setCookie("gray_version", value);
4795
4803
  },
4796
4804
 
4797
- initGrayConfig: function() {
4805
+ initGrayConfig: function () {
4798
4806
  let searchParams = Uts.getParamsFormSearch(location.search);
4799
4807
  if ((Uts.currentEnv == "gray" || Uts.currentEnv == "publish") && searchParams.gray_version) {
4800
4808
  Uts.setGrayInfo(searchParams.gray_version);
@@ -4803,10 +4811,10 @@ Uts.getTokenForProject()
4803
4811
 
4804
4812
  overrideAjax() {
4805
4813
  let _xmlhttp = XMLHttpRequest;
4806
- XMLHttpRequest = function() {
4814
+ XMLHttpRequest = function () {
4807
4815
  let ajax = new _xmlhttp();
4808
4816
  ajax._send = ajax.send;
4809
- ajax.send = function(data) {
4817
+ ajax.send = function (data) {
4810
4818
  // console.log(data);
4811
4819
  Uts.setGlobalHeader(this);
4812
4820
  if (Uts.isLogin()) {
@@ -4837,7 +4845,7 @@ Uts.getTokenForProject()
4837
4845
  ajax._send(data);
4838
4846
  };
4839
4847
  ajax._open = ajax.open;
4840
- ajax.open = function(type, url, synType, other) {
4848
+ ajax.open = function (type, url, synType, other) {
4841
4849
  // console.log(type, url, synType, other);
4842
4850
  url = Uts.hookAjaxUrl(type, url, synType, other, ajax);
4843
4851
  url = Uts._afterHookAjaxUrl(type, url, synType, other, ajax);
@@ -4847,8 +4855,8 @@ Uts.getTokenForProject()
4847
4855
  this.url = url;
4848
4856
  ajax._open(type, url, synType, other);
4849
4857
  } else {
4850
- ajax.setRequestHeader = function(name, value) {};
4851
- ajax.send = function(data) {};
4858
+ ajax.setRequestHeader = function (name, value) {};
4859
+ ajax.send = function (data) {};
4852
4860
  // ZenUI.HL();
4853
4861
  }
4854
4862
  };
@@ -4921,7 +4929,7 @@ Uts.sort(testArr,options);
4921
4929
  orderFlag1 = 1;
4922
4930
  orderFlag2 = -1;
4923
4931
  }
4924
- rawArray.sort(function(a, b) {
4932
+ rawArray.sort(function (a, b) {
4925
4933
  if (Uts.isFunction(customCallback)) {
4926
4934
  return customCallback(a[options.pty], b[options.pty], a, b);
4927
4935
  }
@@ -5035,39 +5043,39 @@ Uts.reorderByArrayIndex(arr3,1,5);
5035
5043
  }
5036
5044
  return c;
5037
5045
  },
5038
- cacheStore: (function() {
5046
+ cacheStore: (function () {
5039
5047
  let innerCache = {};
5040
5048
  let maxCacheSize;
5041
5049
  return {
5042
- getStoreCache: function(key) {
5050
+ getStoreCache: function (key) {
5043
5051
  return innerCache[key];
5044
5052
  },
5045
5053
  /*will not update value when had value*/
5046
- setStoreCache: function(key, value) {
5054
+ setStoreCache: function (key, value) {
5047
5055
  if (Uts.isUndefined(innerCache[key])) {
5048
5056
  innerCache[key] = value;
5049
5057
  }
5050
5058
  },
5051
- updateStoreState: function(key, value) {
5059
+ updateStoreState: function (key, value) {
5052
5060
  innerCache[key] = value;
5053
5061
  },
5054
- deleteCache: function(key) {
5062
+ deleteCache: function (key) {
5055
5063
  if (innerCache[key]) {
5056
5064
  delete innerCache[key];
5057
5065
  }
5058
5066
  }
5059
5067
  };
5060
5068
  })(),
5061
- getCache: function(key) {
5069
+ getCache: function (key) {
5062
5070
  return Uts.cacheStore.getStoreCache(key);
5063
5071
  },
5064
- checkCache: function(key, value) {
5072
+ checkCache: function (key, value) {
5065
5073
  Uts.cacheStore.setStoreCache(key, value);
5066
5074
  },
5067
- updateCache: function(key, value) {
5075
+ updateCache: function (key, value) {
5068
5076
  Uts.cacheStore.updateStoreState(key, value);
5069
5077
  },
5070
- deleteCache: function(key) {
5078
+ deleteCache: function (key) {
5071
5079
  Uts.cacheStore.deleteCache(key);
5072
5080
  },
5073
5081
  /**
@@ -5364,7 +5372,7 @@ false
5364
5372
  * Uts.generatePathForTree(treeData,'children','path')
5365
5373
  */
5366
5374
  generatePathForTree(treeData, childProp = "children", pathFieldName = "__path", parentItem) {
5367
- Uts.each(treeData, function(item, index) {
5375
+ Uts.each(treeData, function (item, index) {
5368
5376
  Uts.generatePathByParent(item, index, parentItem, pathFieldName);
5369
5377
  if (Uts.notEmptyArray(item[childProp])) {
5370
5378
  Uts.generatePathForTree(item[childProp], childProp, pathFieldName, item);
@@ -5486,10 +5494,10 @@ false
5486
5494
  let childLength = new Array(
5487
5495
  Uts.random(config.currentLenth == 1 ? 1 : config.minArrayLength, config.maxArrayLength)
5488
5496
  );
5489
- Uts.each(childLength, function(item, index) {
5497
+ Uts.each(childLength, function (item, index) {
5490
5498
  let newItem = {};
5491
5499
  generatePath(newItem, index, config.parent);
5492
- Uts.each(config.childFieldList, function(childFieldListItem, childFieldListIndex) {
5500
+ Uts.each(config.childFieldList, function (childFieldListItem, childFieldListIndex) {
5493
5501
  newItem[childFieldListItem] = childFieldListItem + newItem[config.pathFieldName].join("_");
5494
5502
  });
5495
5503
  newItem[config.childFieldName] = [];
@@ -5510,7 +5518,7 @@ false
5510
5518
  });
5511
5519
  return dataArray;
5512
5520
  },
5513
- watchObject: function(obj, options = { log: true }) {
5521
+ watchObject: function (obj, options = { log: true }) {
5514
5522
  const { get, set, log, watchName = "watchObject" } = options;
5515
5523
  function innerGet(passObj, propsName, rec) {
5516
5524
  if (log) {
@@ -5578,7 +5586,7 @@ false
5578
5586
  };
5579
5587
  console.log(Uts.diffObject(o1, o2));
5580
5588
  */
5581
- diffObject: function(oldObj, newObj) {
5589
+ diffObject: function (oldObj, newObj) {
5582
5590
  let diffResult = [];
5583
5591
  function addDiffResult(options = {}, obj, visitKey, parentObj, config) {
5584
5592
  // console.log(obj);
@@ -5906,7 +5914,7 @@ Uts.loopTree(treeData,'childrens',function(item,index,globalConfig){
5906
5914
  if (eachConfig.stop || globalConfig.stopAll) {
5907
5915
  return true;
5908
5916
  }
5909
- Uts.each(arr, function(item, index) {
5917
+ Uts.each(arr, function (item, index) {
5910
5918
  if (globalConfig.generatePath) {
5911
5919
  Uts.generatePathByParent(item, index, eachConfig.parent, globalConfig.pathFieldName);
5912
5920
  }
@@ -6009,7 +6017,7 @@ Uts.getParentByPath(item,treeData,{ pathFieldName: "__path", treeChildProp: "chi
6009
6017
  let parentList = [];
6010
6018
  if (path.length > 1) {
6011
6019
  let obj = {};
6012
- Uts.each(path, function(pathValue, pathIndex) {
6020
+ Uts.each(path, function (pathValue, pathIndex) {
6013
6021
  if (pathIndex === 0) {
6014
6022
  obj = lists[pathValue];
6015
6023
  parentList.push(obj);
@@ -6053,7 +6061,7 @@ Uts.getParentByPath(item,treeData,{ pathFieldName: "__path", treeChildProp: "chi
6053
6061
  cb && cb();
6054
6062
  },
6055
6063
 
6056
- selectText: function(dom, start = 0, end) {
6064
+ selectText: function (dom, start = 0, end) {
6057
6065
  if (!end) {
6058
6066
  if (dom.value) {
6059
6067
  end = dom.value.length;
@@ -6198,7 +6206,7 @@ Uts.getParentByPath(item,treeData,{ pathFieldName: "__path", treeChildProp: "chi
6198
6206
  return checkSingleCode(value);
6199
6207
  } else if (Uts.notEmptyArray(value)) {
6200
6208
  let isMatch = false;
6201
- Uts.each(value, function(singleValue, index, run) {
6209
+ Uts.each(value, function (singleValue, index, run) {
6202
6210
  if (checkSingleCode(singleValue)) {
6203
6211
  isMatch = true;
6204
6212
  run.stop = true;
@@ -6219,8 +6227,8 @@ Uts.getParentByPath(item,treeData,{ pathFieldName: "__path", treeChildProp: "chi
6219
6227
  * @param {Function} callback
6220
6228
  * @return {null}
6221
6229
  */
6222
- regHook: function(env, callback) {
6223
- (function(currentObj) {
6230
+ regHook: function (env, callback) {
6231
+ (function (currentObj) {
6224
6232
  callback && callback(currentObj);
6225
6233
  })(env);
6226
6234
  },
@@ -6236,7 +6244,7 @@ Uts.getParentByPath(item,treeData,{ pathFieldName: "__path", treeChildProp: "chi
6236
6244
  * @example
6237
6245
  * Uts.href('https://www.baidu.com');
6238
6246
  */
6239
- href: function(url, type, notAutoFixedParams) {
6247
+ href: function (url, type, notAutoFixedParams) {
6240
6248
  if (Uts.getCookie("breakOnLeave")) {
6241
6249
  eval("debugger");
6242
6250
  }
@@ -6276,12 +6284,12 @@ Uts.getParentByPath(item,treeData,{ pathFieldName: "__path", treeChildProp: "chi
6276
6284
  * Uts.noHref();
6277
6285
  'javascript:void(0)'
6278
6286
  */
6279
- noHref: function() {
6287
+ noHref: function () {
6280
6288
  return "javascript:void(0)";
6281
6289
  },
6282
- fireListen: function(options) {},
6290
+ fireListen: function (options) {},
6283
6291
 
6284
- getCurrentProject: function() {
6292
+ getCurrentProject: function () {
6285
6293
  return "www";
6286
6294
  },
6287
6295
  /**
@@ -6296,7 +6304,7 @@ Uts.getParentByPath(item,treeData,{ pathFieldName: "__path", treeChildProp: "chi
6296
6304
  * @example
6297
6305
  * Uts.setPM(permissions);
6298
6306
  */
6299
- setPM: function(permissions, _orgId, _token, projectName) {
6307
+ setPM: function (permissions, _orgId, _token, projectName) {
6300
6308
  let currentProjcet = projectName || Uts.getCurrentProject(); //www/pm/hms
6301
6309
  let currentConfig = Uts.permissionsConfig[currentProjcet];
6302
6310
  if (!currentConfig) {
@@ -6314,6 +6322,7 @@ Uts.getParentByPath(item,treeData,{ pathFieldName: "__path", treeChildProp: "chi
6314
6322
  Uts.storage.set(PMCacheName, PMCache);
6315
6323
  }
6316
6324
  },
6325
+ permissionsConfig: {},
6317
6326
  /**
6318
6327
  * 读取某个项目级权限(已自动隔离不同项目权限,多账号切换自动失效,退出重登录自动失效),
6319
6328
  * @module cookieStorage
@@ -6322,11 +6331,14 @@ Uts.getParentByPath(item,treeData,{ pathFieldName: "__path", treeChildProp: "chi
6322
6331
  * @example
6323
6332
  * Uts.getPM(’CREATE_ORDER‘);
6324
6333
  */
6325
- getPM: function(name) {
6334
+ getPM: function (name, settings) {
6335
+ if (settings) {
6336
+ return Uts.getPMBySettings(name, settings);
6337
+ }
6326
6338
  let currentProjcet = Uts.getCurrentProject(); //www/pm/hms
6327
6339
  let currentConfig = Uts.permissionsConfig[currentProjcet];
6328
6340
  if (!currentConfig) {
6329
- Uts.ce("配置不存在,请检查");
6341
+ // Uts.ce("配置不存在,请检查");
6330
6342
  return false;
6331
6343
  } else {
6332
6344
  let PMCacheName = currentConfig.cacheName;
@@ -6345,6 +6357,33 @@ Uts.getParentByPath(item,treeData,{ pathFieldName: "__path", treeChildProp: "chi
6345
6357
  }
6346
6358
  return false;
6347
6359
  },
6360
+ /**
6361
+ * 根据自定义配置读取权限
6362
+ * @param {string} code 权限码
6363
+ * @param {object} settings 配置项
6364
+ * @returns
6365
+ */
6366
+ getPMBySettings: function (code, settings) {
6367
+ const { permissionsCodeKey, notVerifyPMCodes } = settings || {};
6368
+ const permissionCodes = Uts.storage.get(permissionsCodeKey) || [];
6369
+
6370
+ return Uts.contain(permissionCodes, code) || Uts.contain(notVerifyPMCodes, code);
6371
+ },
6372
+ /**
6373
+ * 过滤路由权限
6374
+ * @param {object} route 路由对象
6375
+ * @returns
6376
+ */
6377
+ filterPM: function (route) {
6378
+ const hasPerm = (route) => {
6379
+ const { meta } = route || {};
6380
+ const { permission } = meta || {};
6381
+ return !permission || Uts.getPM(permission);
6382
+ };
6383
+
6384
+ if (route.children) route.children = route.children.filter(hasPerm);
6385
+ return hasPerm(route);
6386
+ },
6348
6387
  /**
6349
6388
  * routeToDomain 项目/站点间跳转,自动处理不同环境/项目内跳转
6350
6389
  * @module route
@@ -6358,7 +6397,7 @@ Uts.routeToDomain("bio", `/tool?id=9238923`);
6358
6397
  //新串口打开
6359
6398
  Uts.routeToDomain("bio", `/tool?id=9238923`, "_blank")
6360
6399
  */
6361
- routeToDomain: function(site, url, type) {},
6400
+ routeToDomain: function (site, url, type) {},
6362
6401
 
6363
6402
  /**
6364
6403
  * 用于从url查询格式的文本参数中(如a=b&c=d&d=e)返回对象形式的参数,返回{a:b,c:d,d:e}
@@ -6374,7 +6413,7 @@ Uts.getParamsFormSearch('?name=zhangsan&age=18&department=purchase')
6374
6413
  {name: 'zhangsan', age: '18', department: 'purchase'}
6375
6414
  *
6376
6415
  */
6377
- getParamsFormSearch: function(search) {
6416
+ getParamsFormSearch: function (search) {
6378
6417
  var urlDataObj = {};
6379
6418
  // dd = location.search;
6380
6419
  if (!search) {
@@ -6400,7 +6439,7 @@ Uts.getParamsFormSearch('?name=zhangsan&age=18&department=purchase')
6400
6439
  * Uts.reorderString('这段文本需要倒过来')
6401
6440
  '来过倒要需本文段这'
6402
6441
  */
6403
- reorderString: function(str) {
6442
+ reorderString: function (str) {
6404
6443
  if (Uts.isString(str)) {
6405
6444
  let newValue = str.split("");
6406
6445
  newValue.reverse();
@@ -6421,7 +6460,7 @@ Uts.getParamsFormSearch('?name=zhangsan&age=18&department=purchase')
6421
6460
  Uts.exchangeMoneyByUnit(100000000,'亿')
6422
6461
  '1.00亿'
6423
6462
  */
6424
- exchangeMoneyByUnit: function(value, unit = "万", floatCount = 2) {
6463
+ exchangeMoneyByUnit: function (value, unit = "万", floatCount = 2) {
6425
6464
  let oneHundred = 100;
6426
6465
  const unitValueConfig = {
6427
6466
  千: 10 * oneHundred,
@@ -6447,7 +6486,7 @@ Uts.exchangeMoneyByUnit(100000000,'亿')
6447
6486
  * @param {number} length 要加密的长度
6448
6487
  * @return {string} 返回加密后的字符串结果
6449
6488
  */
6450
- encryptString: function(str, startIndex, length) {
6489
+ encryptString: function (str, startIndex, length) {
6451
6490
  //加密的长度不能超过整个文案的长度,也不能超过开始位置到结束的长度
6452
6491
  if (str && startIndex + length < str.length) {
6453
6492
  let startStr = str.substring(0, startIndex),
@@ -6477,7 +6516,7 @@ Uts.filterMoney(938.6,2)
6477
6516
  Uts.filterMoney(123222123, 6);
6478
6517
  '123,222,123.000000'
6479
6518
  */
6480
- filterMoney: function(value, size = 2) {
6519
+ filterMoney: function (value, size = 2) {
6481
6520
  if (Uts.isNumber(value) || !Uts.isString(value)) {
6482
6521
  value = String(value);
6483
6522
  }
@@ -6524,7 +6563,7 @@ Uts.filterMoney(123222123, 6);
6524
6563
  * @param {type} String 是否需要小数点
6525
6564
  * @todo Uts.formatMoney
6526
6565
  */
6527
- formatMoney: function(s, type) {
6566
+ formatMoney: function (s, type) {
6528
6567
  if (/[^0-9\.]/.test(s)) return "0.00";
6529
6568
  if (s == null || s == "null" || s == "") return "0.00";
6530
6569
  s = s.toString().replace(/^(\d*)$/, "$1.");
@@ -6552,10 +6591,13 @@ Uts.filterMoney(123222123, 6);
6552
6591
  Uts.digitUppercase(293235223)
6553
6592
  '贰亿玖仟叁佰贰拾叁万伍仟贰佰贰拾叁元整'
6554
6593
  */
6555
- digitUppercase: function(n) {
6594
+ digitUppercase: function (n) {
6556
6595
  const fraction = ["角", "分"];
6557
6596
  const digit = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"];
6558
- const unit = [["元", "万", "亿"], ["", "拾", "佰", "仟"]];
6597
+ const unit = [
6598
+ ["元", "万", "亿"],
6599
+ ["", "拾", "佰", "仟"]
6600
+ ];
6559
6601
  let num = Math.abs(n);
6560
6602
  let s = "";
6561
6603
  fraction.forEach((item, index) => {
@@ -6591,18 +6633,18 @@ Uts.digitUppercase(293235223)
6591
6633
  });
6592
6634
  {1: '审批中', 2: '发货中'}
6593
6635
  */
6594
- getAutoMatchFromConfig: function(config) {
6636
+ getAutoMatchFromConfig: function (config) {
6595
6637
  const { key, value, list } = config;
6596
6638
 
6597
6639
  let matchConfig = {};
6598
- Uts.each(list, function(item, index) {
6640
+ Uts.each(list, function (item, index) {
6599
6641
  matchConfig[item[key]] = item[value];
6600
6642
  });
6601
6643
 
6602
6644
  return matchConfig;
6603
6645
  },
6604
6646
 
6605
- getLocalResource: function(rawResourceUrl) {
6647
+ getLocalResource: function (rawResourceUrl) {
6606
6648
  if (Uts.currentEnv == "external") {
6607
6649
  let localhost = Uts.getOrigin();
6608
6650
  return rawResourceUrl.replace(/.+(\.cn|\.com)/, localhost);
@@ -6611,13 +6653,13 @@ Uts.digitUppercase(293235223)
6611
6653
  }
6612
6654
  },
6613
6655
 
6614
- checkWithPathname: function() {
6656
+ checkWithPathname: function () {
6615
6657
  let host = location.host;
6616
6658
  const withPathNameHostList = ["gzas.guizhou.gov.cn"];
6617
6659
  return Uts.contain(withPathNameHostList, host);
6618
6660
  },
6619
6661
 
6620
- changeDomainWhenExternal: function(url) {
6662
+ changeDomainWhenExternal: function (url) {
6621
6663
  /*
6622
6664
  *
6623
6665
  * http://rjmart.tmmu.edu.cn/gateway/XX/XXX
@@ -6630,7 +6672,7 @@ Uts.digitUppercase(293235223)
6630
6672
  if (env == "external") {
6631
6673
  let urlWithoutDomain = Uts.getPartStringBySymbolIndex(url, "/", "3");
6632
6674
  let currentDomain = Uts.getOrigin();
6633
- url = url.replace(/.{0,}\/\/(gateway|api)\..+/g, function(fullStr, partStr) {
6675
+ url = url.replace(/.{0,}\/\/(gateway|api)\..+/g, function (fullStr, partStr) {
6634
6676
  let prePartStrSymbol = "/";
6635
6677
  if (Uts.checkWithPathname()) {
6636
6678
  prePartStrSymbol = location.pathname;
@@ -6663,7 +6705,7 @@ Uts.digitUppercase(293235223)
6663
6705
  Uts.getGatewayDomain('/store/user/register')
6664
6706
  'https://gateway.test.rj-info.com/store/user/register'
6665
6707
  */
6666
- getGatewayDomain: function(url) {
6708
+ getGatewayDomain: function (url) {
6667
6709
  let newUrl = "";
6668
6710
  let domain = location.host;
6669
6711
  let env = Uts.getEnv().env;
@@ -6704,7 +6746,7 @@ Uts.splitMoney(239238.23,0)
6704
6746
  let moneyArr = moneyStr.split(".");
6705
6747
  return moneyArr[intOrFloat] || 0;
6706
6748
  },
6707
- changeSecondDomain: function(url, secondDomain = "api") {
6749
+ changeSecondDomain: function (url, secondDomain = "api") {
6708
6750
  let newUrl = "";
6709
6751
  let domain = location.host;
6710
6752
  newUrl =
@@ -6724,7 +6766,7 @@ Uts.splitMoney(239238.23,0)
6724
6766
  * Uts.changeSecondDomainInUrl('scholar','https://www.test.rj-info.com/#/userInfo')
6725
6767
  'https://scholar.test.rj-info.com/#/userInfo'
6726
6768
  */
6727
- changeSecondDomainInUrl: function(secondDomain, url) {
6769
+ changeSecondDomainInUrl: function (secondDomain, url) {
6728
6770
  if (!Uts.notEmptyString(url)) {
6729
6771
  url = location.href;
6730
6772
  }
@@ -6745,7 +6787,7 @@ false
6745
6787
  Uts.checkSecondDomain('www',true)
6746
6788
  true
6747
6789
  */
6748
- checkSecondDomain: function(secondDomain, isStrictMode) {
6790
+ checkSecondDomain: function (secondDomain, isStrictMode) {
6749
6791
  let currentHost = location.host;
6750
6792
  let subfix = Uts.TR(isStrictMode, "\\.", "");
6751
6793
  return Uts.startWith(currentHost, secondDomain + subfix);
@@ -6764,7 +6806,7 @@ Uts.getSecondDomain('https://www.baidu.com')
6764
6806
  Uts.getSecondDomain('http://www.baidu.com')
6765
6807
  'www'
6766
6808
  */
6767
- getSecondDomain: function(url) {
6809
+ getSecondDomain: function (url) {
6768
6810
  let currentHost = url || location.host;
6769
6811
  let matchResult = currentHost.match(/[\w-]+(?=\.)/) || [""];
6770
6812
  return matchResult[0];
@@ -6773,7 +6815,7 @@ Uts.getSecondDomain('http://www.baidu.com')
6773
6815
  * 获取当前页面的URL参数
6774
6816
  * @module processString
6775
6817
  */
6776
- getUrlParam: function(name) {
6818
+ getUrlParam: function (name) {
6777
6819
  const url = window.location.href;
6778
6820
  const params = new URLSearchParams(url.split("?")[1]);
6779
6821
  return params.get(name);
@@ -6782,24 +6824,24 @@ Uts.getSecondDomain('http://www.baidu.com')
6782
6824
  * 删除当前页面的URL参数
6783
6825
  * @module processString
6784
6826
  */
6785
- removeParamByRegex: function(name) {
6827
+ removeParamByRegex: function (name) {
6786
6828
  const cleanUrl = window.location.href
6787
6829
  .replace(new RegExp(`[?&]${name}=[^&]+`), "")
6788
6830
  .replace(/^([^?]+)\?$/, "$1")
6789
6831
  .replace(/&$/, "");
6790
6832
  history.replaceState(null, "", cleanUrl);
6791
6833
  },
6792
- setListToMap: function(pmList, propName) {
6834
+ setListToMap: function (pmList, propName) {
6793
6835
  var pmObj = {};
6794
6836
  if (Uts.notEmptyArray(pmList)) {
6795
- Uts.each(pmList, function(item, index) {
6837
+ Uts.each(pmList, function (item, index) {
6796
6838
  pmObj[item[propName]] = true;
6797
6839
  });
6798
6840
  }
6799
6841
  return pmObj;
6800
6842
  },
6801
6843
  //限制只能输入整数价格
6802
- isIntPrice: function(price) {
6844
+ isIntPrice: function (price) {
6803
6845
  let priceTmp = price;
6804
6846
  if (priceTmp.length == 1) {
6805
6847
  priceTmp = priceTmp.replace(/[^1-9]/g, "");
@@ -6808,7 +6850,7 @@ Uts.getSecondDomain('http://www.baidu.com')
6808
6850
  }
6809
6851
  return priceTmp;
6810
6852
  },
6811
- updateLastOperationTime: function(url) {
6853
+ updateLastOperationTime: function (url) {
6812
6854
  const ignoreUrls = [
6813
6855
  Uts.getGatewayDomain("/base/letter/sys/www/list"),
6814
6856
  Uts.getGatewayDomain("/base/letter/sys/supp/list"),
@@ -6823,7 +6865,7 @@ Uts.getSecondDomain('http://www.baidu.com')
6823
6865
  }
6824
6866
  },
6825
6867
 
6826
- checkLogOut: function(logOutCB) {
6868
+ checkLogOut: function (logOutCB) {
6827
6869
  //定时检查当前账号是否超过30min未进行接口操作
6828
6870
  let timerId = setInterval(() => {
6829
6871
  let _self = this,
@@ -6841,7 +6883,7 @@ Uts.getSecondDomain('http://www.baidu.com')
6841
6883
  }
6842
6884
  }, 60000); // todo 60000
6843
6885
  },
6844
- getAutoLoginProject: function(_loginSite) {
6886
+ getAutoLoginProject: function (_loginSite) {
6845
6887
  let loginSite = _loginSite;
6846
6888
  let autoLoginInfo = Uts.storage.get("autoLoginInfo") || { www: {}, oms: {}, hms: {} };
6847
6889
  if (Uts.getCookie("autoLoginInfo") && JSON.parse(Uts.getCookie("autoLoginInfo"))) {
@@ -6857,7 +6899,7 @@ Uts.getSecondDomain('http://www.baidu.com')
6857
6899
  }
6858
6900
  return loginSite;
6859
6901
  },
6860
- showAutoLogoutTips: function(logoutCB) {
6902
+ showAutoLogoutTips: function (logoutCB) {
6861
6903
  //当勾选了自动登录时,先弹窗提示,再判断自动登出
6862
6904
  const _currentProject = Uts.getCurrentProject();
6863
6905
  // ZenUI.deleteComfirm({
@@ -6893,7 +6935,7 @@ Uts.getSecondDomain('http://www.baidu.com')
6893
6935
  // closeByBackDrop: false,
6894
6936
  // });
6895
6937
  },
6896
- autoLogOut: function() {
6938
+ autoLogOut: function () {
6897
6939
  //各系统自动退出方法
6898
6940
  const logoutMap = {
6899
6941
  www: "Login?action=logout&type=auto",
@@ -6926,9 +6968,9 @@ Uts.getSecondDomain('http://www.baidu.com')
6926
6968
  logoutCB();
6927
6969
  }
6928
6970
  },
6929
- blobToDataURI: function(blob, callback) {
6971
+ blobToDataURI: function (blob, callback) {
6930
6972
  let reader = new FileReader();
6931
- reader.onload = function(e) {
6973
+ reader.onload = function (e) {
6932
6974
  callback(e.target.result);
6933
6975
  };
6934
6976
  reader.readAsDataURL(blob);
@@ -6945,7 +6987,7 @@ Uts.getSecondDomain('http://www.baidu.com')
6945
6987
  //现网返回
6946
6988
  {baseUrl: 'https://m.rjmart.cn'}
6947
6989
  */
6948
- getWapDomain: function() {
6990
+ getWapDomain: function () {
6949
6991
  let domain = window.location.origin;
6950
6992
  if (!window.location.origin) {
6951
6993
  domain =
@@ -6961,7 +7003,7 @@ Uts.getSecondDomain('http://www.baidu.com')
6961
7003
  },
6962
7004
  //Uts.formatNumUnit(109700,10000,1,'w') -> 10.9w
6963
7005
  //Uts.formatNumUnit(1234,10000,1,'w') -> 1234
6964
- formatNumUnit: function(num, dividend = 10000, limit = 2, text = "w") {
7006
+ formatNumUnit: function (num, dividend = 10000, limit = 2, text = "w") {
6965
7007
  if (isNaN(num) == true) {
6966
7008
  return num;
6967
7009
  }
@@ -6990,7 +7032,7 @@ Uts.getSecondDomain('http://www.baidu.com')
6990
7032
  }
6991
7033
  },
6992
7034
  //判断手机是全屏还是有物理home键
6993
- hasPhysicalHomeKey: function() {
7035
+ hasPhysicalHomeKey: function () {
6994
7036
  if (window.devicePixelRatio == 3 && screen.width >= 375 && screen.height >= 750) {
6995
7037
  return false;
6996
7038
  }
@@ -7110,64 +7152,14 @@ Uts.getSecondDomain('http://www.baidu.com')
7110
7152
  const prefix = cleaned.replace(/^\+?86/, "").substr(0, 3);
7111
7153
  const validPrefixes = [
7112
7154
  // 中国移动
7113
- 134,
7114
- 135,
7115
- 136,
7116
- 137,
7117
- 138,
7118
- 139,
7119
- 144,
7120
- 147,
7121
- 148,
7122
- 150,
7123
- 151,
7124
- 152,
7125
- 157,
7126
- 158,
7127
- 159,
7128
- 172,
7129
- 178,
7130
- 182,
7131
- 183,
7132
- 184,
7133
- 187,
7134
- 188,
7135
- 195,
7136
- 197,
7137
- 198,
7155
+ 134, 135, 136, 137, 138, 139, 144, 147, 148, 150, 151, 152, 157, 158, 159, 172, 178, 182, 183, 184, 187, 188, 195,
7156
+ 197, 198,
7138
7157
  // 中国联通
7139
- 130,
7140
- 131,
7141
- 132,
7142
- 140,
7143
- 145,
7144
- 146,
7145
- 155,
7146
- 156,
7147
- 166,
7148
- 175,
7149
- 176,
7150
- 185,
7151
- 186,
7158
+ 130, 131, 132, 140, 145, 146, 155, 156, 166, 175, 176, 185, 186,
7152
7159
  // 中国电信
7153
- 133,
7154
- 149,
7155
- 153,
7156
- 162,
7157
- 173,
7158
- 177,
7159
- 180,
7160
- 181,
7161
- 189,
7162
- 190,
7163
- 191,
7164
- 193,
7165
- 199,
7160
+ 133, 149, 153, 162, 173, 177, 180, 181, 189, 190, 191, 193, 199,
7166
7161
  // 虚拟运营商
7167
- 165,
7168
- 167,
7169
- 170,
7170
- 171
7162
+ 165, 167, 170, 171
7171
7163
  ];
7172
7164
 
7173
7165
  return validPrefixes.includes(Number(prefix));
@@ -7177,36 +7169,45 @@ Uts.getSecondDomain('http://www.baidu.com')
7177
7169
  * @param {Object|Array} obj - 要过滤的对象或数组
7178
7170
  * @returns {Object|Array} - 过滤后的新对象或数组
7179
7171
  */
7180
- filterCommaFields(obj) {
7181
- // 处理 null 或 undefined
7182
- if (obj == null) {
7183
- return obj;
7184
- }
7185
-
7186
- // 处理数组
7187
- if (Uts.isArray(obj)) {
7188
- return obj.map(item => this.filterCommaFields(item));
7189
- }
7190
-
7172
+ filterCommaFields(obj, replaceOrigin = true) {
7191
7173
  // 处理对象
7192
- if (typeof obj === "object") {
7193
- const result = {};
7194
-
7195
- for (const key in obj) {
7196
- if (obj.hasOwnProperty(key)) {
7197
- const value = obj[key];
7198
-
7199
- // 检查键名是否包含逗号
7200
- if (key.includes(",")) {
7201
- // 跳过包含逗号的键
7202
- continue;
7174
+ if (Uts.notEmptyObject(obj)) {
7175
+ let result = {};
7176
+
7177
+ if (replaceOrigin) {
7178
+ result = obj;
7179
+ // 直接删除包含逗号的键
7180
+ for (const key in obj) {
7181
+ if (obj.hasOwnProperty(key)) {
7182
+ if (key.includes(",")) {
7183
+ delete obj[key];
7184
+ } else {
7185
+ const value = obj[key];
7186
+ // 递归处理嵌套对象或数组
7187
+ if (typeof value === "object" && value !== null) {
7188
+ obj[key] = this.filterCommaFields(value);
7189
+ }
7190
+ }
7203
7191
  }
7192
+ }
7193
+ } else {
7194
+ // 创建新对象
7195
+ for (const key in obj) {
7196
+ if (obj.hasOwnProperty(key)) {
7197
+ const value = obj[key];
7198
+
7199
+ // 检查键名是否包含逗号
7200
+ if (key.includes(",")) {
7201
+ // 跳过包含逗号的键
7202
+ continue;
7203
+ }
7204
7204
 
7205
- // 递归处理嵌套对象或数组
7206
- if (typeof value === "object" && value !== null) {
7207
- result[key] = this.filterCommaFields(value);
7208
- } else {
7209
- result[key] = value;
7205
+ // 递归处理嵌套对象或数组
7206
+ if (typeof value === "object" && value !== null) {
7207
+ result[key] = this.filterCommaFields(value);
7208
+ } else {
7209
+ result[key] = value;
7210
+ }
7210
7211
  }
7211
7212
  }
7212
7213
  }
@@ -7216,6 +7217,54 @@ Uts.getSecondDomain('http://www.baidu.com')
7216
7217
 
7217
7218
  // 其他类型直接返回
7218
7219
  return obj;
7220
+ },
7221
+ // 设置网页favicon
7222
+ setFavicon(url) {
7223
+ let link = document.querySelector("link[rel~='icon']");
7224
+ if (!link) {
7225
+ link = document.createElement("link");
7226
+ link.rel = "icon";
7227
+ document.head.appendChild(link);
7228
+ }
7229
+ link.href = url;
7230
+ },
7231
+ /**
7232
+ * 通过路径获取对象的嵌套值
7233
+ * @param {Object} obj - 目标对象
7234
+ * @param {string} path - 嵌套路径,使用点号分隔(例如:"a.b.c")
7235
+ * @returns {*} - 返回嵌套值,如果路径不存在则返回undefined
7236
+ */
7237
+ getNestedValue(obj, path) {
7238
+ if (!path || typeof path !== "string") return path;
7239
+ return path.split(".").reduce(function (acc, part) {
7240
+ return acc ? acc[part] : undefined;
7241
+ }, obj);
7242
+ },
7243
+ transArrayBufferToObj(data) {
7244
+ if (!(data instanceof ArrayBuffer)) {
7245
+ return data;
7246
+ }
7247
+
7248
+ try {
7249
+ const jsonStr = new TextDecoder().decode(data);
7250
+ return JSON.parse(jsonStr);
7251
+ } catch {
7252
+ return data;
7253
+ }
7254
+ },
7255
+ /**
7256
+ * 将字符串按分隔符转换为数组
7257
+ * @param {String|Array} value - 输入值
7258
+ * @returns {Array} - 转换后的数组
7259
+ */
7260
+ convertToArray(value) {
7261
+ if (Array.isArray(value)) {
7262
+ return value;
7263
+ }
7264
+ return String(value)
7265
+ .split(/[,\s\uFF0C]+/)
7266
+ .map((s) => s.trim())
7267
+ .filter(Boolean);
7219
7268
  }
7220
7269
  };
7221
7270