zmdms-utils 0.0.64 → 0.0.66

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 };
@@ -33,9 +33,9 @@ function getBaseUrl(processObj, options) {
33
33
  // 退出登录地址
34
34
  var logoutUrl = {
35
35
  dev: processObj["".concat(logoutKey, "_DEV")] || "/login",
36
- test: processObj["".concat(logoutKey, "_DEV")] || "/login",
37
- stage: processObj["".concat(logoutKey, "_DEV")] || "http://testportal.cncico.com:8099/",
38
- prod: processObj["".concat(logoutKey, "_DEV")] || "http://newportal.cncico.com/",
36
+ test: processObj["".concat(logoutKey, "_TEST")] || "/login",
37
+ stage: processObj["".concat(logoutKey, "_STAGE")] || "http://testportal.cncico.com:8099/",
38
+ prod: processObj["".concat(logoutKey, "_PROD")] || "http://newportal.cncico.com/",
39
39
  };
40
40
  var currentKey = ENV.toLowerCase() || "prod";
41
41
  return {
@@ -25,5 +25,7 @@ var TOKEN_KEY = window.__TOKEN_KEY__ || "Cicoms-Auth";
25
25
  // 基础前缀
26
26
  // export const BASIC_KEY = "zmdms";
27
27
  var BASIC_KEY = window.__BASIC_KEY__ || "cicoms";
28
+ // 附件相关服务
29
+ var FILE_SERVICE = window.__FILE_SERVICE__ || "cicoms";
28
30
 
29
- export { BASIC_KEY, EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, PERSONNEL_CENTER_APPNAME, SALARY_CENTER_APPNAME, TOKEN_KEY };
31
+ export { BASIC_KEY, EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, FILE_SERVICE, PERSONNEL_CENTER_APPNAME, SALARY_CENTER_APPNAME, TOKEN_KEY };
package/dist/es/file.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { getToken } from './auth.js';
2
- import { dangerouslyXss, specialString, getFileExtension } from './common.js';
3
- import { BASIC_KEY, TOKEN_KEY } from './constants.js';
2
+ import { dangerouslyXss, specialString, getFileExtension, isImageExtension } from './common.js';
3
+ import { BASIC_KEY, TOKEN_KEY, FILE_SERVICE } from './constants.js';
4
4
 
5
5
  /**
6
6
  * 附件相关接口
7
7
  */
8
+ var isZmdmsFileService = FILE_SERVICE === "zmdms";
8
9
  /**
9
10
  * 附件下载方法
10
11
  * @param fileId 附件id
@@ -109,7 +110,7 @@ function batchDownloadFiles(fileList, options) {
109
110
  * @param options.fileList { attachId: string, attachName: string ... }[] 附件列表。批量预览时有用
110
111
  */
111
112
  function previewFile(fileId, fileName, options) {
112
- var API_BASEURL = options.API_BASEURL, authToken = options.authToken; options.fileList;
113
+ var API_BASEURL = options.API_BASEURL, authToken = options.authToken, _a = options.fileList, fileList = _a === void 0 ? [] : _a;
113
114
  // 获取请求基础数据
114
115
  var _b = getBasicInfo(API_BASEURL, authToken), token = _b.token, apiBaseURL = _b.apiBaseURL;
115
116
  // 处理附件名中的一些特殊字符
@@ -126,34 +127,32 @@ function previewFile(fileId, fileName, options) {
126
127
  // 如果文件名没变,文件内容改变。这样就会导致再次预览时 内容不会更新
127
128
  // 所以将文件名 与 文件id组合来生成不同的文件名
128
129
  previewFileName = "".concat(filePreName, "-").concat(fileId, ".").concat(fileExtension);
129
- // 2023-12-30 修改成数字中心预览
130
- window.open("".concat(apiBaseURL, "/api/cicoms-cicohr-org/cicomscicohr/v1/common/filePreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token));
130
+ if (!isZmdmsFileService) {
131
+ // 2023-12-30 修改成数字中心预览
132
+ window.open("".concat(apiBaseURL, "/api/cicoms-cicohr-org/cicomscicohr/v1/common/filePreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token));
133
+ return;
134
+ }
131
135
  // 如果是图片 走批量预览接口
132
- // const isImage = isImageExtension(fileExtension);
133
- // if (isImage) {
134
- // const imgFiles = fileList.filter((item) => {
135
- // const { attachName, attachId } = item;
136
- // const [, fileExtension] = getFileExtension(attachName);
137
- // if (isImageExtension(fileExtension) && attachId !== fileId) {
138
- // return true;
139
- // }
140
- // return false;
141
- // });
142
- // let attachIds = imgFiles.map((item) => item.attachId).join(",");
143
- // // 批量图片预览
144
- // window.open(
145
- // `${apiBaseURL}/picturesAttchPreview?attachIds=${
146
- // attachIds ? `${fileId},${attachIds}` : fileId
147
- // }&${TOKEN_KEY}=${token}` +
148
- // (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
149
- // );
150
- // } else {
151
- // // 普通预览
152
- // window.open(
153
- // `${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
154
- // (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
155
- // );
156
- // }
136
+ var isImage = isImageExtension(fileExtension);
137
+ if (isImage) {
138
+ var imgFiles = fileList.filter(function (item) {
139
+ var attachName = item.attachName, attachId = item.attachId;
140
+ var _a = getFileExtension(attachName), fileExtension = _a[1];
141
+ if (isImageExtension(fileExtension) && attachId !== fileId) {
142
+ return true;
143
+ }
144
+ return false;
145
+ });
146
+ var attachIds = imgFiles.map(function (item) { return item.attachId; }).join(",");
147
+ // 批量图片预览
148
+ window.open("".concat(apiBaseURL, "/picturesAttchPreview?attachIds=").concat(attachIds ? "".concat(fileId, ",").concat(attachIds) : fileId, "&").concat(TOKEN_KEY, "=").concat(token) +
149
+ (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
150
+ }
151
+ else {
152
+ // 普通预览
153
+ window.open("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token, "&officePreviewType=pdf") +
154
+ (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
155
+ }
157
156
  }
158
157
  /**
159
158
  * 导出一个文件流
@@ -272,11 +271,11 @@ function createOriginalLink(fileId, fileName, options) {
272
271
  // 所以将文件名 与 文件id组合来生成不同的文件名
273
272
  previewFileName = "".concat(filePreName, "-").concat(fileId, ".").concat(fileExtension);
274
273
  // 2023-12-30 替换成数字中心的 预览接口
275
- return "".concat(apiBaseURL, "/api/cicoms-cicohr-org/cicomscicohr/v1/common/filePreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token);
276
- // return (
277
- // `${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
278
- // (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
279
- // );
274
+ if (!isZmdmsFileService) {
275
+ return "".concat(apiBaseURL, "/api/cicoms-cicohr-org/cicomscicohr/v1/common/filePreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token);
276
+ }
277
+ return ("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token, "&officePreviewType=pdf") +
278
+ (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
280
279
  }
281
280
  /**
282
281
  * 生成缩略图路径