zmdms-utils 0.0.17 → 0.0.19

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.
@@ -0,0 +1,3 @@
1
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
+
3
+ export { commonjsGlobal };
@@ -0,0 +1,7 @@
1
+ var decimalExports = {};
2
+ var decimal = {
3
+ get exports(){ return decimalExports; },
4
+ set exports(v){ decimalExports = v; },
5
+ };
6
+
7
+ export { decimal as __module, decimalExports as exports };
@@ -0,0 +1,3 @@
1
+ var test = {};
2
+
3
+ export { test as __exports };
@@ -3,7 +3,7 @@ function getBaseUrl(processObj) {
3
3
  var ENV = processObj.REACT_APP_ENV; // 获取当前环境变量
4
4
  // api各个环境地址
5
5
  var apiBaseUrlObj = {
6
- dev: processObj.REACT_APP_API_DEV || "http://192.168.0.83:8000",
6
+ dev: processObj.REACT_APP_API_DEV || "http://192.168.0.134:8000",
7
7
  test: processObj.REACT_APP_API_TEST || window.location.origin,
8
8
  stage: processObj.REACT_APP_API_STAGE || window.location.origin,
9
9
  product: processObj.REACT_APP_API_PRODUCT || window.location.origin,
@@ -57,5 +57,11 @@ declare function getFileExtension(fileName: string): [string, string];
57
57
  * @returns
58
58
  */
59
59
  declare function isImageExtension(extension: string): boolean;
60
+ /**
61
+ * 判断值是否为非空
62
+ * @param number 传入一个值
63
+ * @returns
64
+ */
65
+ declare function isNonEmpty(number: any): boolean;
60
66
 
61
- export { addThousedSeparator, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isImageExtension, parseQueryParams, specialString, unescapeString };
67
+ export { addThousedSeparator, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isImageExtension, isNonEmpty, parseQueryParams, specialString, unescapeString };
package/dist/es/common.js CHANGED
@@ -179,7 +179,7 @@ function getFileExtension(fileName) {
179
179
  }
180
180
  var lastPointIndex = fileName.lastIndexOf("."); // 从最后取点
181
181
  var filePreName = fileName.substring(0, lastPointIndex); // 前面的名字
182
- var fileExtension = fileName.substring(lastPointIndex + 1); // 后面的文件后缀
182
+ var fileExtension = fileName.substring(lastPointIndex + 1).toLowerCase(); // 后面的文件后缀
183
183
  return [filePreName, fileExtension];
184
184
  }
185
185
  /**
@@ -202,5 +202,13 @@ function isImageExtension(extension) {
202
202
  ];
203
203
  return imageExtensions.includes(extension.toLowerCase());
204
204
  }
205
+ /**
206
+ * 判断值是否为非空
207
+ * @param number 传入一个值
208
+ * @returns
209
+ */
210
+ function isNonEmpty(number) {
211
+ return number !== null && number !== undefined;
212
+ }
205
213
 
206
- export { addThousedSeparator, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isImageExtension, parseQueryParams, specialString, unescapeString };
214
+ export { addThousedSeparator, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isImageExtension, isNonEmpty, parseQueryParams, specialString, unescapeString };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 子应用 通知 父应用
3
+ */
4
+ declare const EMITTER_CCP_KEY = "emitter-ccp-key";
5
+ /**
6
+ * 父应用 通知 子应用订阅
7
+ */
8
+ declare const EMITTER_PCC_KEY = "emitter-pcc-key";
9
+ declare const EMITTER_TYPE: {
10
+ delTab: string;
11
+ addTab: string;
12
+ delTabs: string;
13
+ routes: string;
14
+ treeSearchWhitePath: string;
15
+ treeSearchSet: string;
16
+ };
17
+
18
+ export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE };
@@ -0,0 +1,23 @@
1
+ // 薪酬中心-app name
2
+ var SALARY_CENTER_APPNAME = "cicohr-salary";
3
+ // 人事中心-app name
4
+ var PERSONNEL_CENTER_APPNAME = "cicohr-personnel";
5
+ // 发布订阅的常量 parent call children
6
+ /**
7
+ * 子应用 通知 父应用
8
+ */
9
+ var EMITTER_CCP_KEY = "emitter-ccp-key";
10
+ /**
11
+ * 父应用 通知 子应用订阅
12
+ */
13
+ var EMITTER_PCC_KEY = "emitter-pcc-key";
14
+ var EMITTER_TYPE = {
15
+ delTab: "delTab",
16
+ addTab: "addTab",
17
+ delTabs: "delTabs",
18
+ routes: "routes",
19
+ treeSearchWhitePath: "treeSearchWhitePath",
20
+ treeSearchSet: "treeSearchSet", // 父应用传递搜索树的值
21
+ };
22
+
23
+ export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, PERSONNEL_CENTER_APPNAME, SALARY_CENTER_APPNAME };
package/dist/es/file.js CHANGED
@@ -24,7 +24,7 @@ function downloadFile(fileId, fileName, options) {
24
24
  xhr.open("GET", "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/public/download-file/").concat(fileId), true);
25
25
  }
26
26
  else {
27
- xhr.open("GET", "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/download-file/").concat(fileId, "?Zmdms-Auth=bearer ").concat(token, "&addWaterMark=").concat(waterMark), true);
27
+ xhr.open("GET", "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/download-file/").concat(fileId, "?Zmdms-Auth=").concat(token, "&addWaterMark=").concat(waterMark), true);
28
28
  }
29
29
  xhr.responseType = "blob";
30
30
  xhr.onload = function () {
@@ -138,12 +138,12 @@ function previewFile(fileId, fileName, options) {
138
138
  });
139
139
  var attachIds = imgFiles.map(function (item) { return item.attachId; }).join(",");
140
140
  // 批量图片预览
141
- window.open("".concat(apiBaseURL, "/picturesAttchPreview?attachIds=").concat(attachIds ? "".concat(fileId, ",").concat(attachIds) : fileId, "&Zmdms-Auth=bearer ").concat(token) +
141
+ window.open("".concat(apiBaseURL, "/picturesAttchPreview?attachIds=").concat(attachIds ? "".concat(fileId, ",").concat(attachIds) : fileId, "&Zmdms-Auth=").concat(token) +
142
142
  (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
143
143
  }
144
144
  else {
145
145
  // 普通预览
146
- window.open("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&Zmdms-Auth=bearer ").concat(token, "&officePreviewType=pdf") +
146
+ window.open("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&Zmdms-Auth=").concat(token, "&officePreviewType=pdf") +
147
147
  (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
148
148
  }
149
149
  }
@@ -216,7 +216,7 @@ function createDownloadLink(fileId, options) {
216
216
  if (open) {
217
217
  return "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/public/download-file/").concat(fileId);
218
218
  }
219
- return "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/download-file/").concat(fileId, "?Zmdms-Auth=bearer ").concat(token);
219
+ return "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/download-file/").concat(fileId, "?Zmdms-Auth=").concat(token);
220
220
  }
221
221
  /**
222
222
  * 生成原始图片路径
@@ -246,7 +246,7 @@ function createOriginalLink(fileId, fileName, options) {
246
246
  // 如果文件名没变,文件内容改变。这样就会导致再次预览时 内容不会更新
247
247
  // 所以将文件名 与 文件id组合来生成不同的文件名
248
248
  previewFileName = "".concat(filePreName, "-").concat(fileId, ".").concat(fileExtension);
249
- return ("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&Zmdms-Auth=bearer ").concat(token, "&officePreviewType=pdf") +
249
+ return ("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&Zmdms-Auth=").concat(token, "&officePreviewType=pdf") +
250
250
  (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
251
251
  }
252
252
  /**
@@ -263,7 +263,7 @@ function createOriginalLink(fileId, fileName, options) {
263
263
  function createThumbnailLink(fileId, fileName, options) {
264
264
  var API_BASEURL = options.API_BASEURL, authToken = options.authToken, _a = options.scale, scale = _a === void 0 ? 0.5 : _a;
265
265
  var _b = getBasicInfo(API_BASEURL || "", authToken), token = _b.token, apiBaseURL = _b.apiBaseURL;
266
- return "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/thumbnail/").concat(fileId, "?scale=").concat(scale, "&Zmdms-Auth=bearer ").concat(token);
266
+ return "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/thumbnail/").concat(fileId, "?scale=").concat(scale, "&Zmdms-Auth=").concat(token);
267
267
  }
268
268
  /**
269
269
  * 生成图片上传地址
package/dist/es/math.js CHANGED
@@ -1,11 +1,37 @@
1
+ import { Decimal } from './node_modules/decimal.js/decimal.js';
2
+
3
+ /**
4
+ * 如果传入的数,有非数字的情况 那么忽略这个数
5
+ * 非数字的情况包括 null undefined
6
+ * 因为null转数字的结果是 0 可能会影响计算结果。
7
+ * 而这个可能不符合预期
8
+ */
9
+ function initNum(num1, num2) {
10
+ // 如果两个数都是非数字 那么直接返回0
11
+ if (isNaN(num1) && isNaN(num2)) {
12
+ return 0;
13
+ }
14
+ if (isNaN(num1)) {
15
+ return num2;
16
+ }
17
+ if (isNaN(num2)) {
18
+ return num1;
19
+ }
20
+ }
1
21
  /**
2
22
  * 加法
3
23
  */
4
24
  function plus(num1, num2) {
5
25
  try {
6
- var _num1 = Number(num1);
7
- var _num2 = Number(num2);
8
- return (isNaN(_num1) ? 0 : _num1) + (isNaN(_num2) ? 0 : _num2);
26
+ var _num1 = num1 == null ? NaN : Number(num1);
27
+ var _num2 = num2 == null ? NaN : Number(num2);
28
+ // 如果两个数都是非数字 那么直接返回0
29
+ var result = initNum(_num1, _num2);
30
+ if (typeof result === "number") {
31
+ return result;
32
+ }
33
+ return new Decimal(_num1).add(_num2).toNumber();
34
+ // return (isNaN(_num1) ? 0 : _num1) + (isNaN(_num2) ? 0 : _num2);
9
35
  }
10
36
  catch (err) {
11
37
  console.error("计算加法出错", err);
@@ -17,9 +43,15 @@ function plus(num1, num2) {
17
43
  */
18
44
  function minus(num1, num2) {
19
45
  try {
20
- var _num1 = Number(num1);
21
- var _num2 = Number(num2);
22
- return (isNaN(_num1) ? 0 : _num1) - (isNaN(_num2) ? 0 : _num2);
46
+ var _num1 = num1 == null ? NaN : Number(num1);
47
+ var _num2 = num2 == null ? NaN : Number(num2);
48
+ // 如果两个数都是非数字 那么直接返回0
49
+ var result = initNum(_num1, _num2);
50
+ if (typeof result === "number") {
51
+ return result;
52
+ }
53
+ return new Decimal(_num1).sub(_num2).toNumber();
54
+ // return (isNaN(_num1) ? 0 : _num1) - (isNaN(_num2) ? 0 : _num2);
23
55
  }
24
56
  catch (err) {
25
57
  console.error("计算减法出错", err);
@@ -31,9 +63,15 @@ function minus(num1, num2) {
31
63
  */
32
64
  function times(num1, num2) {
33
65
  try {
34
- var _num1 = Number(num1);
35
- var _num2 = Number(num2);
36
- return (isNaN(_num1) ? 0 : _num1) * (isNaN(_num2) ? 0 : _num2);
66
+ var _num1 = num1 == null ? NaN : Number(num1);
67
+ var _num2 = num2 == null ? NaN : Number(num2);
68
+ // 如果两个数都是非数字 那么直接返回0
69
+ var result = initNum(_num1, _num2);
70
+ if (typeof result === "number") {
71
+ return result;
72
+ }
73
+ return new Decimal(_num1).mul(_num2).toNumber();
74
+ // return (isNaN(_num1) ? 0 : _num1) * (isNaN(_num2) ? 0 : _num2);
37
75
  }
38
76
  catch (err) {
39
77
  console.error("计算乘法出错", err);
@@ -45,9 +83,16 @@ function times(num1, num2) {
45
83
  */
46
84
  function divide(num1, num2) {
47
85
  try {
48
- var _num1 = Number(num1);
49
- var _num2 = Number(num2);
50
- return (isNaN(_num1) ? 0 : _num1) / (isNaN(_num2) ? 0 : _num2);
86
+ var _num1 = num1 == null ? NaN : Number(num1);
87
+ var _num2 = num2 == null ? NaN : Number(num2);
88
+ // 如果两个数都是非数字 那么直接返回0
89
+ var result = initNum(_num1, _num2);
90
+ if (typeof result === "number") {
91
+ return result;
92
+ }
93
+ Decimal.set({ precision: 5 });
94
+ return new Decimal(_num1).div(_num2).toNumber();
95
+ // return (isNaN(_num1) ? 0 : _num1) / (isNaN(_num2) ? 0 : _num2);
51
96
  }
52
97
  catch (err) {
53
98
  console.error("计算除法出错", err);
@@ -59,7 +104,13 @@ function divide(num1, num2) {
59
104
  */
60
105
  function exactRound(num, ratio) {
61
106
  try {
62
- return Number(num).toFixed(ratio);
107
+ var _num1 = num == null ? NaN : Number(num);
108
+ if (isNaN(_num1)) {
109
+ return 0;
110
+ // return (0).toFixed(ratio);
111
+ }
112
+ return new Decimal(num).toFixed(ratio);
113
+ // return Number(num).toFixed(ratio);
63
114
  }
64
115
  catch (err) {
65
116
  return num;