zmdms-webui 3.1.4 → 3.1.6

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.
@@ -74,6 +74,14 @@ interface IZtxkConfig {
74
74
  * 表格的展开收起图标是否使用组件自定义图标,或者自己自定义
75
75
  */
76
76
  enableTableExpandIcon?: boolean | ((option: any) => React__default.ReactNode);
77
+ /**
78
+ * 字典接口配置
79
+ */
80
+ dictApiUrl?: string;
81
+ /**
82
+ * 附件组件公用请求头配置
83
+ */
84
+ fileListRequestHeaders?: Record<string, string>;
77
85
  }
78
86
  declare const ZtxkContext: React__default.Context<IZtxkConfig>;
79
87
 
@@ -18,6 +18,8 @@ var ztxkConfig = {
18
18
  enableTableSummaryDefaultExpand: false,
19
19
  enableOperationBtnGroupShowMore: false,
20
20
  enableTableExpandIcon: false,
21
+ dictApiUrl: "/api/zmdms-mdm-data/dict-biz/dictionary",
22
+ fileListRequestHeaders: undefined,
21
23
  };
22
24
  var ZtxkContext = React__default.createContext(ztxkConfig);
23
25
 
@@ -6,7 +6,7 @@ import '../../config/ZtxkContext.js';
6
6
  import useBaseContext from '../../config/useBaseContext.js';
7
7
  import '../../config/MyStorage.js';
8
8
  import { useLatest } from 'ahooks';
9
- import { getToken } from 'zmdms-utils';
9
+ import { getPreToken } from 'zmdms-utils';
10
10
  import { formatUnit, getFileExtension } from '../utils.js';
11
11
  import myMessage from '../../message/index.js';
12
12
  import ButtonCom from '../../button/button.js';
@@ -50,7 +50,8 @@ function useBasicInfo(props) {
50
50
  var fileAction = action ? action : createUploadFileLink({ apiBaseUrl: apiBaseUrl });
51
51
  // 文件上传头部参数
52
52
  var fileHeaders = useMemo(function () {
53
- return __assign({ "Zmdms-Auth": getToken() || "" }, headers);
53
+ var _a;
54
+ return __assign((_a = {}, _a[window.__TOKEN_KEY__ || "Zmdms-Auth"] = getPreToken() || "", _a), headers);
54
55
  }, [headers]);
55
56
  // 其余参数
56
57
  var fileData = useMemo(function () {
@@ -1,9 +1,13 @@
1
1
  import { useState, useEffect } from 'react';
2
+ import '../../config/ZtxkContext.js';
3
+ import useBaseContext from '../../config/useBaseContext.js';
4
+ import '../../config/MyStorage.js';
2
5
 
3
6
  var defaultFileType = [];
4
7
  // 获取附件类型
5
8
  function useFetchFileTypeData(options) {
6
9
  var request = options.request, fileTypeKey = options.fileTypeKey, fileTypeFilterList = options.fileTypeFilterList, fileTypeList = options.fileTypeList, useOutsideFileTypeList = options.useOutsideFileTypeList, isAllowedPatchFileType = options.isAllowedPatchFileType;
10
+ var dictApiUrl = useBaseContext().dictApiUrl;
7
11
  var _a = useState(), fileTypeFetchList = _a[0], setFileType = _a[1];
8
12
  useEffect(function () {
9
13
  if (!isAllowedPatchFileType) {
@@ -25,7 +29,7 @@ function useFetchFileTypeData(options) {
25
29
  status: 50,
26
30
  };
27
31
  request === null || request === void 0 ? void 0 : request({
28
- url: "/api/zmdms-mdm-data/dict-biz/dictionary",
32
+ url: dictApiUrl || "/api/zmdms-mdm-data/dict-biz/dictionary",
29
33
  params: params,
30
34
  method: "GET",
31
35
  }).then(function (res) {
@@ -16,7 +16,7 @@ var translationTypeList = [
16
16
  { dictKey: "1", dictValue: "中文转英文" },
17
17
  ];
18
18
  var TranslationButton = function (props) {
19
- var _a = useBaseContext(), request = _a.request, translationPreviewRoute = _a.translationPreviewRoute;
19
+ var _a = useBaseContext(), request = _a.request, translationPreviewRoute = _a.translationPreviewRoute, dictApiUrl = _a.dictApiUrl;
20
20
  var attachId = props.attachId, tid = props.tid, translationParams = props.translationParams, tidChange = props.tidChange, previewUrl = props.previewUrl;
21
21
  var previewRoute = useMemo(function () {
22
22
  return previewUrl || translationPreviewRoute || "";
@@ -25,14 +25,14 @@ var TranslationButton = function (props) {
25
25
  var _c = useState(false), loading = _c[0], setLoading = _c[1];
26
26
  var res = useQuery({
27
27
  queryKey: [
28
- "/api/zmdms-mdm-data/dict-biz/dictionary",
28
+ dictApiUrl || "/api/zmdms-mdm-data/dict-biz/dictionary",
29
29
  "zsk_term_library_id",
30
30
  ],
31
31
  queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
32
32
  return __generator(this, function (_a) {
33
33
  // 查询函数,用于获取数据的逻辑
34
34
  return [2 /*return*/, request({
35
- url: "/api/zmdms-mdm-data/dict-biz/dictionary",
35
+ url: dictApiUrl || "/api/zmdms-mdm-data/dict-biz/dictionary",
36
36
  method: "GET",
37
37
  params: { code: "zsk_term_library_id" },
38
38
  })];
@@ -1,7 +1,7 @@
1
1
  import { __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
2
2
  import { useCallback, useState, useEffect, useMemo } from 'react';
3
3
  import { flushSync } from 'react-dom';
4
- import { getFileExtension, isImageExtension, createDownloadLink, createUploadFileLink, TOKEN_KEY, getToken, exactRound, times, divide } from 'zmdms-utils';
4
+ import { getFileExtension, isImageExtension, createDownloadLink, createUploadFileLink, TOKEN_KEY, getPreToken, exactRound, times, divide } from 'zmdms-utils';
5
5
  import MemoUploadList from './uploadList.js';
6
6
  import { useLatest } from 'ahooks';
7
7
  import myMessage from '../message/index.js';
@@ -228,14 +228,14 @@ function useOnChange(props) {
228
228
  * 生成基础参数
229
229
  */
230
230
  function useBasicInfo(props) {
231
- var action = props.action, _a = props.API_BASEURL, API_BASEURL = _a === void 0 ? "" : _a, headers = props.headers, data = props.data, isPublic = props.isPublic;
231
+ var action = props.action, _a = props.API_BASEURL, API_BASEURL = _a === void 0 ? "" : _a, headers = props.headers, data = props.data, isPublic = props.isPublic, fileListRequestHeaders = props.fileListRequestHeaders;
232
232
  // 文件上传路径
233
233
  var fileAction = action ? action : createUploadFileLink({ API_BASEURL: API_BASEURL });
234
234
  // 文件上传头部参数
235
235
  var fileHeaders = useMemo(function () {
236
236
  var _a;
237
- return __assign((_a = {}, _a[TOKEN_KEY] = getToken() || "", _a), headers);
238
- }, [headers]);
237
+ return __assign(__assign((_a = {}, _a[TOKEN_KEY] = getPreToken() || "", _a), fileListRequestHeaders), headers);
238
+ }, [headers, fileListRequestHeaders]);
239
239
  // 其余参数
240
240
  var fileData = useMemo(function () {
241
241
  var newData = __assign({}, data);
@@ -34,7 +34,7 @@ var MAXSIZE = 104857600; // 100 * 1024 * 1024
34
34
  var UploadList = function (props, ref) {
35
35
  var _a;
36
36
  var children = props.children, btnText = props.btnText, className = props.className, _b = props.showTip, showTip = _b === void 0 ? true : _b, _c = props.maxSize, maxSize = _c === void 0 ? MAXSIZE : _c, showTable = props.showTable, acceptList = props.acceptList, beforeUpload = props.beforeUpload, onChange = props.onChange, PROPS_API_BASEURL = props.API_BASEURL, PROPS_FILE_API_BASEURL = props.FILE_API_BASEURL, action = props.action, headers = props.headers, data = props.data, userName = props.userName, fileList = props.fileList, isPublic = props.isPublic, _d = props.maxPreviewSize, maxPreviewSize = _d === void 0 ? MAX_PREVIEW_SIZE : _d, isPreview = props.isPreview, isDownload = props.isDownload, isDelete = props.isDelete, _e = props.filePreview, filePreview = _e === void 0 ? true : _e, _f = props.zipName, zipName = _f === void 0 ? "\u6279\u91CF\u4E0B\u8F7D-".concat(Date.now(), ".zip") : _f, isImage = props.isImage, _g = props.isImageCrop, isImageCrop = _g === void 0 ? true : _g, imgCropProps = props.imgCropProps, _h = props.imgWidth, imgWidth = _h === void 0 ? 110 : _h, _j = props.imgHeight, imgHeight = _j === void 0 ? 110 : _j, customRenderBtn = props.customRenderBtn, disAllowDuplicateFile = props.disAllowDuplicateFile, fieldNames = props.fieldNames, tableColumns = props.tableColumns, onBeforeDownloadValidate = props.onBeforeDownloadValidate, onBeforePreviewValidate = props.onBeforePreviewValidate, onBeforeDeleteValidate = props.onBeforeDeleteValidate, isImgPreview = props.isImgPreview, isTranslation = props.isTranslation, renderTableOperationColumn = props.renderTableOperationColumn, resetProps = __rest(props, ["children", "btnText", "className", "showTip", "maxSize", "showTable", "acceptList", "beforeUpload", "onChange", "API_BASEURL", "FILE_API_BASEURL", "action", "headers", "data", "userName", "fileList", "isPublic", "maxPreviewSize", "isPreview", "isDownload", "isDelete", "filePreview", "zipName", "isImage", "isImageCrop", "imgCropProps", "imgWidth", "imgHeight", "customRenderBtn", "disAllowDuplicateFile", "fieldNames", "tableColumns", "onBeforeDownloadValidate", "onBeforePreviewValidate", "onBeforeDeleteValidate", "isImgPreview", "isTranslation", "renderTableOperationColumn"]);
37
- var _k = useBaseContext(), apiBaseUrl = _k.apiBaseUrl, fileBaseUrl = _k.fileBaseUrl, enableTranslationButton = _k.enableTranslationButton;
37
+ var _k = useBaseContext(), apiBaseUrl = _k.apiBaseUrl, fileBaseUrl = _k.fileBaseUrl, enableTranslationButton = _k.enableTranslationButton, fileListRequestHeaders = _k.fileListRequestHeaders;
38
38
  // 翻译按钮是否显示
39
39
  var isTranslationButton = getFinalValue(enableTranslationButton, isTranslation);
40
40
  var maxCount = resetProps.maxCount, listType = resetProps.listType, method = resetProps.method;
@@ -96,6 +96,7 @@ var UploadList = function (props, ref) {
96
96
  headers: headers,
97
97
  data: data,
98
98
  isPublic: isPublic,
99
+ fileListRequestHeaders: fileListRequestHeaders,
99
100
  }), fileAction = _o.fileAction, fileHeaders = _o.fileHeaders, fileData = _o.fileData;
100
101
  // 表格需要的附件列表数据
101
102
  var uploadTableData = useUploadTableData({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-webui",
3
- "version": "3.1.4",
3
+ "version": "3.1.6",
4
4
  "private": false,
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
@@ -136,7 +136,7 @@
136
136
  "storybook": "^7.6.16",
137
137
  "typescript": "^4.9.5",
138
138
  "web-vitals": "^2.1.4",
139
- "zmdms-utils": "^0.0.87"
139
+ "zmdms-utils": "^0.0.92"
140
140
  },
141
141
  "resolutions": {
142
142
  "rc-virtual-list": "3.11.3"