zmdms-webui 1.3.7 → 1.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/electronsignatures/dgcomponents/contract-comparison.js +50 -0
- package/dist/es/electronsignatures/dgcomponents/useContractColumns.js +53 -0
- package/dist/es/electronsignatures/dgcomponents/useDg.js +57 -0
- package/dist/es/electronsignatures/electron-signatures-fragment.js +322 -0
- package/dist/es/electronsignatures/electroncomponents/electron-seal-batch-download.js +370 -0
- package/dist/es/electronsignatures/electroncomponents/electron-seal-detail.js +35 -0
- package/dist/es/electronsignatures/electroncomponents/electron-seal-download.js +74 -0
- package/dist/es/electronsignatures/electroncomponents/electron-seal-firstLevelPerson.js +17 -0
- package/dist/es/electronsignatures/electroncomponents/electron-seal-item.js +21 -0
- package/dist/es/electronsignatures/electroncomponents/electron-seal-list.js +42 -0
- package/dist/es/electronsignatures/electroncomponents/electron-seal-setting.js +12 -0
- package/dist/es/electronsignatures/electroncomponents/last-qys-modal.js +44 -0
- package/dist/es/electronsignatures/electroncomponents/useCheckedSealInfoList.js +43 -0
- package/dist/es/electronsignatures/electroncomponents/useElectronColumns.js +181 -0
- package/dist/es/electronsignatures/electroncomponents/useFetchElectronData.js +118 -0
- package/dist/es/electronsignatures/electroncomponents/useGetDeptInfo.js +37 -0
- package/dist/es/electronsignatures/electroncomponents/utils.js +266 -0
- package/dist/es/electronsignatures/filecomponents/file-operation.js +55 -0
- package/dist/es/electronsignatures/filecomponents/file-type-select.js +11 -0
- package/dist/es/electronsignatures/filecomponents/file-upload.js +130 -0
- package/dist/es/electronsignatures/filecomponents/fileUtils.js +38 -0
- package/dist/es/electronsignatures/filecomponents/useFetchFileTypeData.js +46 -0
- package/dist/es/electronsignatures/filecomponents/useFileColumns.js +178 -0
- package/dist/es/electronsignatures/filecomponents/useFileTypeColumns.js +76 -0
- package/dist/es/electronsignatures/hooks/useMergeRecords.js +51 -0
- package/dist/es/electronsignatures/hooks/useParseElectronListData.js +113 -0
- package/dist/es/electronsignatures/hooks/useParseElectronSetting.js +327 -0
- package/dist/es/electronsignatures/hooks/useParseIsNeedElectronData.js +111 -0
- package/dist/es/electronsignatures/hooks/useParseIsNeedQunjData.js +50 -0
- package/dist/es/electronsignatures/hooks/useParseQunjListData.js +182 -0
- package/dist/es/electronsignatures/hooks/useParseQunjSingleData.js +96 -0
- package/dist/es/electronsignatures/hooks/useParseRecords.js +141 -0
- package/dist/es/electronsignatures/index.css +1 -0
- package/dist/es/electronsignatures/index.d.ts +6 -0
- package/dist/es/electronsignatures/index.js +836 -0
- package/dist/es/electronsignatures/interface.d.ts +500 -0
- package/dist/es/electronsignatures/interface.js +53 -0
- package/dist/es/electronsignatures/qunjcomponents/code-modal.js +111 -0
- package/dist/es/electronsignatures/qunjcomponents/qunj-check.js +15 -0
- package/dist/es/electronsignatures/qunjcomponents/qunj-detail.js +65 -0
- package/dist/es/electronsignatures/qunjcomponents/qunj-list.js +121 -0
- package/dist/es/electronsignatures/qunjcomponents/useFetchQunjData.js +58 -0
- package/dist/es/electronsignatures/qunjcomponents/useQunjColumns.js +251 -0
- package/dist/es/electronsignatures/utils.js +55 -0
- package/dist/es/table/components/EnhanceBodyCell.js +3 -1
- package/dist/index.build.d.ts +1 -0
- package/dist/index.dark.css +1 -1
- package/dist/index.default.css +1 -1
- package/dist/index.es.js +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { __assign } from '../../_virtual/_tslib.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import { downloadFile, getToken, dangerouslyXss, getFileExtension, isImageExtension, previewFile } from 'zmdms-utils';
|
|
5
|
+
import { downloadWaterFile } from './fileUtils.js';
|
|
6
|
+
import FileUpload from './file-upload.js';
|
|
7
|
+
import ButtonCom from '../../button/button.js';
|
|
8
|
+
import { Checkbox, Popconfirm } from 'antd';
|
|
9
|
+
|
|
10
|
+
var FileOperation = function (props) {
|
|
11
|
+
var isDownload = props.isDownload, isPreview = props.isPreview, isEdit = props.isEdit, isWater = props.isWater, records = props.records, isDelete = props.isDelete, fileName = props.fileName, _a = props.fileId, fileId = _a === void 0 ? "" : _a, _b = props.preFileId, preFileId = _b === void 0 ? "" : _b, _c = props.preFileName, preFileName = _c === void 0 ? "" : _c, _d = props.apiBaseUrl, apiBaseUrl = _d === void 0 ? "" : _d, _e = props.fileBaseUrl, fileBaseUrl = _e === void 0 ? "" : _e, onDelete = props.onDelete, onWatermarkChange = props.onWatermarkChange, organizationId = props.organizationId, isReplaceFile = props.isReplaceFile, fileList = props.fileList, onFileReplace = props.onFileReplace;
|
|
12
|
+
var previewBtn = function (attachId, previewTitle, fileName) {
|
|
13
|
+
return (jsx(ButtonCom, __assign({ type: "link", onClick: function () {
|
|
14
|
+
// 实现批量预览,只针对图片
|
|
15
|
+
var _a = getFileExtension(fileName || ""), fileExtension = _a[1];
|
|
16
|
+
var result = isImageExtension(fileExtension);
|
|
17
|
+
if (result) {
|
|
18
|
+
// const allImage = (Array.isArray(records) ? records : [])
|
|
19
|
+
// .filter(
|
|
20
|
+
// (item) => isImage(item.attachName) && item.attachId !== attachId
|
|
21
|
+
// )
|
|
22
|
+
// .map((item) => item.attachId);
|
|
23
|
+
previewFile(attachId, fileName || "", {
|
|
24
|
+
API_BASEURL: fileBaseUrl,
|
|
25
|
+
fileList: Array.isArray(records) ? records : [],
|
|
26
|
+
});
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
previewFile(attachId, fileName || "", {
|
|
30
|
+
API_BASEURL: fileBaseUrl,
|
|
31
|
+
});
|
|
32
|
+
} }, { children: previewTitle })));
|
|
33
|
+
};
|
|
34
|
+
function onFileChange(info) {
|
|
35
|
+
onFileReplace && onFileReplace(info, fileId);
|
|
36
|
+
}
|
|
37
|
+
return (jsxs("div", __assign({ className: "file-operation--wrap" }, { children: [jsx("p", __assign({ className: "file-operation--title" }, { children: fileName })), isEdit && fileId && (jsx("div", __assign({ className: "file-operation--isWater" }, { children: jsx(Checkbox, __assign({ checked: isWater, onChange: function (e) {
|
|
38
|
+
onWatermarkChange && onWatermarkChange(e.target.checked);
|
|
39
|
+
} }, { children: "\u6DFB\u52A0\u6C34\u5370" })) }))), jsxs("div", __assign({ className: "file-operation--list" }, { children: [isReplaceFile && (jsx(FileUpload, __assign({ fileList: fileList, apiBaseUrl: apiBaseUrl, onFileChange: onFileChange, type: "link" }, { children: "\u66FF\u6362" }))), isDownload && fileId ? (jsx(ButtonCom, __assign({ type: "link", onClick: function () {
|
|
40
|
+
downloadFile(fileId, fileName || "附件", {
|
|
41
|
+
API_BASEURL: apiBaseUrl,
|
|
42
|
+
waterMark: false,
|
|
43
|
+
});
|
|
44
|
+
} }, { children: "\u4E0B\u8F7D" }))) : null, isPreview && fileId && previewBtn(fileId, "预览", fileName), isPreview && preFileId && previewBtn(preFileId, "上一版", preFileName), !isEdit && isDownload && fileId && isWater ? (jsx(ButtonCom, __assign({ type: "link", onClick: function () {
|
|
45
|
+
var token = getToken();
|
|
46
|
+
downloadWaterFile(fileId, dangerouslyXss(fileName || "附件"), {
|
|
47
|
+
API_BASEURL: apiBaseUrl,
|
|
48
|
+
authToken: token ? token : "",
|
|
49
|
+
organizationId: organizationId,
|
|
50
|
+
});
|
|
51
|
+
} }, { children: "\u4E0B\u8F7D\u6C34\u5370\u7248" }))) : null, isDelete && (fileId || fileName) && (jsx(Popconfirm, __assign({ title: "\u662F\u5426\u5220\u9664\u8BE5\u6761\u6570\u636E?", cancelText: "\u5426", okText: "\u662F", onConfirm: onDelete }, { children: jsx(ButtonCom, __assign({ type: "link" }, { children: "\u5220\u9664" })) })))] }))] })));
|
|
52
|
+
};
|
|
53
|
+
var FileOperation$1 = memo(FileOperation);
|
|
54
|
+
|
|
55
|
+
export { FileOperation$1 as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import MemoSelect from '../../select/select.js';
|
|
4
|
+
|
|
5
|
+
var FileTypeSelect = function (props) {
|
|
6
|
+
var list = props.list, value = props.value, onChange = props.onChange;
|
|
7
|
+
return (jsx(MemoSelect, { list: list, dataKey: "dictKey", titleKey: "dictValue", value: value, onChange: onChange, dropdownMatchSelectWidth: 160 }));
|
|
8
|
+
};
|
|
9
|
+
var FileTypeSelect$1 = memo(FileTypeSelect);
|
|
10
|
+
|
|
11
|
+
export { FileTypeSelect$1 as default };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { __assign } from '../../_virtual/_tslib.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { memo, useState, useCallback, useMemo } from 'react';
|
|
4
|
+
import { message, Upload } from 'antd';
|
|
5
|
+
import '../../config/ZtxkContext.js';
|
|
6
|
+
import useBaseContext from '../../config/useBaseContext.js';
|
|
7
|
+
import { useLatest } from 'ahooks';
|
|
8
|
+
import { getToken } from 'zmdms-utils';
|
|
9
|
+
import { formatUnit, getFileExtension } from '../utils.js';
|
|
10
|
+
import ButtonCom from '../../button/button.js';
|
|
11
|
+
|
|
12
|
+
var FileUpload = function (props) {
|
|
13
|
+
var apiBaseUrl = props.apiBaseUrl, headers = props.headers, data = props.data, isPublic = props.isPublic, acceptList = props.acceptList, maxSize = props.maxSize, beforeUpload = props.beforeUpload, disAllowDuplicateFile = props.disAllowDuplicateFile, fileList = props.fileList, onFileChange = props.onFileChange, children = props.children, _a = props.multiple, multiple = _a === void 0 ? true : _a, _b = props.type, type = _b === void 0 ? "primary" : _b;
|
|
14
|
+
var _c = useState(false), loading = _c[0], setLoading = _c[1];
|
|
15
|
+
// 取接口地址
|
|
16
|
+
var defaultApiBaseUrl = useBaseContext().apiBaseUrl;
|
|
17
|
+
var _d = useBasicInfo({
|
|
18
|
+
apiBaseUrl: apiBaseUrl || defaultApiBaseUrl,
|
|
19
|
+
headers: headers,
|
|
20
|
+
data: data,
|
|
21
|
+
isPublic: isPublic,
|
|
22
|
+
}), fileAction = _d.fileAction, fileHeaders = _d.fileHeaders, fileData = _d.fileData;
|
|
23
|
+
// 文件上传前的判断处理
|
|
24
|
+
var beforeUploadHandle = useBeforeUpload({
|
|
25
|
+
acceptList: acceptList,
|
|
26
|
+
maxSize: maxSize,
|
|
27
|
+
beforeUpload: beforeUpload,
|
|
28
|
+
disAllowDuplicateFile: disAllowDuplicateFile,
|
|
29
|
+
fileList: fileList,
|
|
30
|
+
});
|
|
31
|
+
var onChange = useCallback(function (info) {
|
|
32
|
+
setLoading(true);
|
|
33
|
+
var file = info.file;
|
|
34
|
+
if (file.status === "done" || file.status === "error") {
|
|
35
|
+
setLoading(false);
|
|
36
|
+
}
|
|
37
|
+
if (file.status === "error") {
|
|
38
|
+
message.info("\u8BE5 ".concat(file.name, " \u9644\u4EF6\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u4E0A\u4F20!"));
|
|
39
|
+
}
|
|
40
|
+
onFileChange && onFileChange(info);
|
|
41
|
+
}, [onFileChange]);
|
|
42
|
+
return (jsx(Upload, __assign({ action: fileAction, headers: fileHeaders, data: fileData, showUploadList: false, beforeUpload: beforeUploadHandle, onChange: onChange, disabled: loading, multiple: multiple, className: "electron-file-upload" }, { children: jsx(ButtonCom, __assign({ type: type, loading: loading }, { children: children })) })));
|
|
43
|
+
};
|
|
44
|
+
var FileUpload$1 = memo(FileUpload);
|
|
45
|
+
function useBasicInfo(props) {
|
|
46
|
+
var action = props.action, _a = props.apiBaseUrl, apiBaseUrl = _a === void 0 ? "" : _a, headers = props.headers, data = props.data, isPublic = props.isPublic;
|
|
47
|
+
// 文件上传路径
|
|
48
|
+
var fileAction = action ? action : createUploadFileLink({ apiBaseUrl: apiBaseUrl });
|
|
49
|
+
// 文件上传头部参数
|
|
50
|
+
var fileHeaders = useMemo(function () {
|
|
51
|
+
return __assign({ "Zmdms-Auth": getToken() || "" }, headers);
|
|
52
|
+
}, [headers]);
|
|
53
|
+
// 其余参数
|
|
54
|
+
var fileData = useMemo(function () {
|
|
55
|
+
var newData = __assign({}, data);
|
|
56
|
+
// 如果是公用的 上传的时候 需要传递这个参数
|
|
57
|
+
if (isPublic) {
|
|
58
|
+
newData.isAuth = "2";
|
|
59
|
+
}
|
|
60
|
+
return newData;
|
|
61
|
+
}, [data, isPublic]);
|
|
62
|
+
return {
|
|
63
|
+
fileAction: fileAction,
|
|
64
|
+
fileHeaders: fileHeaders,
|
|
65
|
+
fileData: fileData,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function createUploadFileLink(options) {
|
|
69
|
+
var apiBaseUrl = options.apiBaseUrl;
|
|
70
|
+
return "".concat(apiBaseUrl, "/api/zmdms-resource/oss/endpoint/put-file-attach");
|
|
71
|
+
}
|
|
72
|
+
// 默认限制的文件类型
|
|
73
|
+
var NO_ACCEPT = ["exe"];
|
|
74
|
+
/**
|
|
75
|
+
* 附件上传前的控制
|
|
76
|
+
*/
|
|
77
|
+
function useBeforeUpload(props) {
|
|
78
|
+
var acceptList = props.acceptList, _a = props.maxSize, maxSize = _a === void 0 ? 104857600 : _a, beforeUpload = props.beforeUpload, disAllowDuplicateFile = props.disAllowDuplicateFile, fileList = props.fileList;
|
|
79
|
+
var maxSizeStr = formatUnit(maxSize);
|
|
80
|
+
var fileListRef = useLatest(fileList);
|
|
81
|
+
return useCallback(function (file, fileList) {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
var fileName = file.name, fileSize = file.size;
|
|
84
|
+
// 获取文件后缀
|
|
85
|
+
var _c = getFileExtension(fileName), fileExtension = _c[1];
|
|
86
|
+
if (beforeUpload) {
|
|
87
|
+
var result = beforeUpload(file, fileList);
|
|
88
|
+
if (result) {
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (disAllowDuplicateFile &&
|
|
93
|
+
((_b = (_a = fileListRef.current) === null || _a === void 0 ? void 0 : _a.find) === null || _b === void 0 ? void 0 : _b.call(_a, function (item) { return item.name === fileName || item.attachName === fileName; }))) {
|
|
94
|
+
message.warning("不能上传同名附件!");
|
|
95
|
+
return Upload.LIST_IGNORE;
|
|
96
|
+
}
|
|
97
|
+
// 文件大小
|
|
98
|
+
if (fileSize === 0) {
|
|
99
|
+
message.warning("不能上传空文件!");
|
|
100
|
+
return Upload.LIST_IGNORE;
|
|
101
|
+
}
|
|
102
|
+
// 获取支持的附件类型
|
|
103
|
+
var ACCEPT = acceptList ? acceptList : [];
|
|
104
|
+
ACCEPT = ACCEPT.map(function (a) { return a.toLowerCase(); });
|
|
105
|
+
// 默认支持任何格式的文件,但是不支持exe
|
|
106
|
+
if (ACCEPT.length > 0 && !ACCEPT.includes(fileExtension)) {
|
|
107
|
+
message.warning("\u4E0D\u652F\u6301 ".concat(fileExtension, " \u6587\u4EF6\u683C\u5F0F"));
|
|
108
|
+
return Upload.LIST_IGNORE;
|
|
109
|
+
}
|
|
110
|
+
if (ACCEPT.length === 0 && NO_ACCEPT.includes(fileExtension)) {
|
|
111
|
+
message.warning("\u4E0D\u652F\u6301 ".concat(fileExtension, " \u6587\u4EF6\u683C\u5F0F"));
|
|
112
|
+
return Upload.LIST_IGNORE;
|
|
113
|
+
}
|
|
114
|
+
// 文件大小限制
|
|
115
|
+
if (maxSize && fileSize > maxSize) {
|
|
116
|
+
message.warning("\u6587\u4EF6\u8D85\u51FA ".concat(maxSizeStr, "\uFF01"));
|
|
117
|
+
return Upload.LIST_IGNORE;
|
|
118
|
+
}
|
|
119
|
+
return Promise.resolve(file);
|
|
120
|
+
}, [
|
|
121
|
+
acceptList,
|
|
122
|
+
maxSize,
|
|
123
|
+
maxSizeStr,
|
|
124
|
+
beforeUpload,
|
|
125
|
+
fileListRef,
|
|
126
|
+
disAllowDuplicateFile,
|
|
127
|
+
]);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export { FileUpload$1 as default, useBeforeUpload };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 附件下载水印版方法
|
|
3
|
+
* @param fileId 附件id
|
|
4
|
+
* @param fileName 附件名称
|
|
5
|
+
* @param options
|
|
6
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 必传
|
|
7
|
+
* @param options.authToken {string} token 非必传
|
|
8
|
+
* @param options.waterMark {boolean | string} 是否添加水印 是否指定水印名称 非必传
|
|
9
|
+
* @param options.open boolean 是否不需要登录信息
|
|
10
|
+
*/
|
|
11
|
+
function downloadWaterFile(fileId, fileName, options) {
|
|
12
|
+
var API_BASEURL = options.API_BASEURL, authToken = options.authToken, organizationId = options.organizationId;
|
|
13
|
+
return new Promise(function (resolve, reject) {
|
|
14
|
+
var xhr = new XMLHttpRequest();
|
|
15
|
+
// 获取请求基础数据
|
|
16
|
+
xhr.open("GET", "".concat(API_BASEURL, "/api/zmdms-resource/seal/download-watermark-attach/").concat(fileId, "?watermarkOrganizationType=12&watermarkOrganizationId=").concat(organizationId, "&Zmdms-Auth=bearer ").concat(authToken), true);
|
|
17
|
+
xhr.responseType = "blob";
|
|
18
|
+
xhr.onload = function () {
|
|
19
|
+
if (xhr.status === 200 || xhr.status === 201) {
|
|
20
|
+
var link = document.createElement("a");
|
|
21
|
+
link.href = window.URL.createObjectURL(xhr.response);
|
|
22
|
+
link.download = "".concat(fileName === null || fileName === void 0 ? void 0 : fileName.split(".")[0], ".pdf");
|
|
23
|
+
// fix Firefox
|
|
24
|
+
link.style.display = "none";
|
|
25
|
+
document.body.appendChild(link);
|
|
26
|
+
link.click();
|
|
27
|
+
document.body.removeChild(link);
|
|
28
|
+
window.URL.revokeObjectURL(link.href);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
xhr.onerror = function (err) {
|
|
32
|
+
reject(err);
|
|
33
|
+
};
|
|
34
|
+
xhr.send();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { downloadWaterFile };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
var defaultFileType = [];
|
|
4
|
+
// 获取附件类型
|
|
5
|
+
function useFetchFileTypeData(options) {
|
|
6
|
+
var request = options.request, fileTypeKey = options.fileTypeKey, fileTypeFilterList = options.fileTypeFilterList, fileTypeList = options.fileTypeList, useOutsideFileTypeList = options.useOutsideFileTypeList, isAllowedPatchFileType = options.isAllowedPatchFileType;
|
|
7
|
+
var _a = useState(), fileTypeFetchList = _a[0], setFileType = _a[1];
|
|
8
|
+
useEffect(function () {
|
|
9
|
+
if (!isAllowedPatchFileType) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (useOutsideFileTypeList) {
|
|
13
|
+
setFileType(fileTypeList || defaultFileType);
|
|
14
|
+
}
|
|
15
|
+
}, [fileTypeList, isAllowedPatchFileType, useOutsideFileTypeList]);
|
|
16
|
+
useEffect(function () {
|
|
17
|
+
if (useOutsideFileTypeList) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (!isAllowedPatchFileType) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
var params = {
|
|
24
|
+
code: fileTypeKey || "scm_attach_type",
|
|
25
|
+
status: 50,
|
|
26
|
+
};
|
|
27
|
+
request === null || request === void 0 ? void 0 : request({
|
|
28
|
+
url: "/api/zmdms-mdm-data/dict-biz/dictionary",
|
|
29
|
+
params: params,
|
|
30
|
+
method: "GET",
|
|
31
|
+
}).then(function (res) {
|
|
32
|
+
if (res.status === 200 && res.data.code === 200) {
|
|
33
|
+
var result = fileTypeFilterList
|
|
34
|
+
? (res.data.data || []).filter(function (item) { return !fileTypeFilterList.includes(item.dictValue); })
|
|
35
|
+
: res.data.data;
|
|
36
|
+
setFileType(result);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
}, [useOutsideFileTypeList, isAllowedPatchFileType]);
|
|
41
|
+
return {
|
|
42
|
+
fileTypeFetchList: fileTypeFetchList,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { useFetchFileTypeData as default };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { __assign } from '../../_virtual/_tslib.js';
|
|
2
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { DATA_TYPE_KEY, getColumnMergeProp } from '../hooks/useParseRecords.js';
|
|
4
|
+
import FileTypeSelect from './file-type-select.js';
|
|
5
|
+
import FileOperation from './file-operation.js';
|
|
6
|
+
import { useMemo } from 'react';
|
|
7
|
+
import { currentRecordIsOnlyQunj, onlyQunjAttachId } from '../utils.js';
|
|
8
|
+
import dayjs from 'dayjs';
|
|
9
|
+
import ButtonCom from '../../button/button.js';
|
|
10
|
+
|
|
11
|
+
// 创建附件的clomuns
|
|
12
|
+
function useFileColumns(options) {
|
|
13
|
+
var records = options.records, dataTypeSort = options.dataTypeSort, allData = options.allData, isShowFileUpload = options.isShowFileUpload, apiBaseUrl = options.apiBaseUrl, fileBaseUrl = options.fileBaseUrl, firstDataType = options.firstDataType,
|
|
14
|
+
// fileUploadProps,
|
|
15
|
+
onValueChange = options.onValueChange, onFileTypeChangeGetItem = options.onFileTypeChangeGetItem, getCreateTimeHand = options.getCreateTimeHand, isSingleQj = options.isSingleQj, justNeedQj = options.justNeedQj, setJustNeedQj = options.setJustNeedQj, isShowFileType = options.isShowFileType, currentIsEditMemo = options.currentIsEditMemo, isDeleteAllFileWhenJustUseQj = options.isDeleteAllFileWhenJustUseQj, isControlNeedQys = options.isControlNeedQys, organizationId = options.organizationId, onFileReplace = options.onFileReplace;
|
|
16
|
+
var _a = allData[firstDataType] || {},
|
|
17
|
+
// records: sameTypeRecords,
|
|
18
|
+
setSameTypeRecords = _a.setRecords, onClearElectronListData = _a.onClearElectronListData, onClearElectronSetting = _a.onClearElectronSetting,
|
|
19
|
+
// parseCurrentUploadFile,
|
|
20
|
+
needQj = _a.needQj, needQys = _a.needQys;
|
|
21
|
+
var defaultOnlyQunjRecords = useMemo(function () {
|
|
22
|
+
var _a;
|
|
23
|
+
return [
|
|
24
|
+
(_a = {
|
|
25
|
+
attachId: onlyQunjAttachId
|
|
26
|
+
},
|
|
27
|
+
_a[DATA_TYPE_KEY] = firstDataType,
|
|
28
|
+
_a),
|
|
29
|
+
];
|
|
30
|
+
}, [firstDataType]);
|
|
31
|
+
var fileTypeColumn = {
|
|
32
|
+
title: "类型",
|
|
33
|
+
dataIndex: "attachType",
|
|
34
|
+
key: "attachType",
|
|
35
|
+
width: 80,
|
|
36
|
+
align: "center",
|
|
37
|
+
render: function (text, record, index) {
|
|
38
|
+
var currentOnlyQunj = currentRecordIsOnlyQunj(record);
|
|
39
|
+
if (currentOnlyQunj) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
var _a = getColumnMergeProp({
|
|
43
|
+
record: record,
|
|
44
|
+
index: index,
|
|
45
|
+
records: records,
|
|
46
|
+
dataTypeSort: dataTypeSort,
|
|
47
|
+
}), currentDataType = _a.currentDataType, preDataTypeRecordsLength = _a.preDataTypeRecordsLength;
|
|
48
|
+
var _b = allData[currentDataType] || {}, fileTypeFetchList = _b.fileTypeFetchList, isEdit = _b.isEdit, isAllowedPatchFileType = _b.isAllowedPatchFileType, setSameTypeRecords = _b.setRecords;
|
|
49
|
+
return isEdit && isAllowedPatchFileType ? (jsx(FileTypeSelect, { list: fileTypeFetchList, value: record === null || record === void 0 ? void 0 : record.attachType, onChange: function (value, option, completeData) {
|
|
50
|
+
// 因为数据是按照类型来归类了,那么这个索引的长度 实际应该减去之前的所有数据类型的长度
|
|
51
|
+
var dataTypeIndex = index - preDataTypeRecordsLength;
|
|
52
|
+
setSameTypeRecords(function (preRecords) {
|
|
53
|
+
var _a;
|
|
54
|
+
var copyRecords = (preRecords === null || preRecords === void 0 ? void 0 : preRecords.slice()) || [];
|
|
55
|
+
var item = copyRecords[dataTypeIndex];
|
|
56
|
+
var newItem = onFileTypeChangeGetItem(__assign(__assign({}, item), (_a = { attachType: completeData === null || completeData === void 0 ? void 0 : completeData.dictKey, attachTypeName: completeData === null || completeData === void 0 ? void 0 : completeData.dictValue }, _a[DATA_TYPE_KEY] = currentDataType, _a)));
|
|
57
|
+
copyRecords.splice(dataTypeIndex, 1, newItem);
|
|
58
|
+
return copyRecords;
|
|
59
|
+
});
|
|
60
|
+
} })) : (record === null || record === void 0 ? void 0 : record.attachTypeName);
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
var fileColumns = [
|
|
64
|
+
{
|
|
65
|
+
title: (jsxs("div", __assign({ className: "file-title" }, { children: [jsx("div", __assign({ className: "file-label" }, { children: "\u9644\u4EF6" })), jsx("div", __assign({ className: "file-upload" }, { children: isShowFileUpload && currentIsEditMemo && needQj ? (isControlNeedQys || needQys ? (jsx(ButtonCom, __assign({ type: "link", className: "file-add--isOnlyQunj", onClick: function () {
|
|
66
|
+
var _a, _b, _c;
|
|
67
|
+
setJustNeedQj(!justNeedQj);
|
|
68
|
+
var newNeedQys = justNeedQj ? 1 : 0;
|
|
69
|
+
var clearElectronListData = onClearElectronListData === null || onClearElectronListData === void 0 ? void 0 : onClearElectronListData();
|
|
70
|
+
var clearElectronSetting = onClearElectronSetting === null || onClearElectronSetting === void 0 ? void 0 : onClearElectronSetting();
|
|
71
|
+
// 是否组件内部可以更改需要契约锁逻辑
|
|
72
|
+
var needQysObj = isControlNeedQys
|
|
73
|
+
? { needQys: newNeedQys }
|
|
74
|
+
: {};
|
|
75
|
+
if (isSingleQj) {
|
|
76
|
+
onValueChange &&
|
|
77
|
+
onValueChange((_a = {},
|
|
78
|
+
_a[firstDataType] = __assign(__assign(__assign({}, clearElectronListData), clearElectronSetting), needQysObj),
|
|
79
|
+
_a));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (isDeleteAllFileWhenJustUseQj) {
|
|
83
|
+
// 如果点击仅需要群杰印章信息的话,需要删除掉所有附件信息
|
|
84
|
+
setSameTypeRecords(defaultOnlyQunjRecords);
|
|
85
|
+
onValueChange &&
|
|
86
|
+
onValueChange((_b = {},
|
|
87
|
+
_b[firstDataType] = __assign(__assign(__assign({ fileList: defaultOnlyQunjRecords }, clearElectronListData), clearElectronSetting), needQysObj),
|
|
88
|
+
_b));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
onValueChange &&
|
|
92
|
+
onValueChange((_c = {},
|
|
93
|
+
_c[firstDataType] = __assign(__assign(__assign({}, clearElectronListData), clearElectronSetting), needQysObj),
|
|
94
|
+
_c));
|
|
95
|
+
}
|
|
96
|
+
} }, { children: justNeedQj ? "使用电子印章" : "仅使用群杰印章" }))) : null) : null }))] }))),
|
|
97
|
+
children: [
|
|
98
|
+
{
|
|
99
|
+
title: "名称",
|
|
100
|
+
dataIndex: "attachName",
|
|
101
|
+
key: "attachName",
|
|
102
|
+
width: 160,
|
|
103
|
+
align: "center",
|
|
104
|
+
render: function (text, record, index) {
|
|
105
|
+
var currentOnlyQunj = currentRecordIsOnlyQunj(record);
|
|
106
|
+
if (currentOnlyQunj) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
var _a = getColumnMergeProp({
|
|
110
|
+
record: record,
|
|
111
|
+
index: index,
|
|
112
|
+
records: records,
|
|
113
|
+
dataTypeSort: dataTypeSort,
|
|
114
|
+
}), currentDataType = _a.currentDataType, preDataTypeRecordsLength = _a.preDataTypeRecordsLength;
|
|
115
|
+
var _b = allData[currentDataType] || {}, isEdit = _b.isEdit, sameTypeRecords = _b.records, setSameTypeRecords = _b.setRecords, fileFieldsNameRef = _b.fileFieldsNameRef;
|
|
116
|
+
var _c = (fileFieldsNameRef === null || fileFieldsNameRef === void 0 ? void 0 : fileFieldsNameRef.current) || {}, oldVersionId = _c.oldVersionId, oldVersionName = _c.oldVersionName;
|
|
117
|
+
// 是否添加水印
|
|
118
|
+
var isWater = (record === null || record === void 0 ? void 0 : record.isWatermark) + "" === "1" ? true : false;
|
|
119
|
+
// 是否替换附件
|
|
120
|
+
var isReplaceFile = (record === null || record === void 0 ? void 0 : record.isReplaceFile) + "" === "1" ? true : false;
|
|
121
|
+
return (jsx(FileOperation, { fileName: text, fileId: record.attachId, preFileId: record === null || record === void 0 ? void 0 : record[oldVersionId || ""], preFileName: record === null || record === void 0 ? void 0 : record[oldVersionName || ""], isDownload: true, isDelete: isEdit && isShowFileUpload, isPreview: true, isEdit: isEdit, isWater: isWater, apiBaseUrl: apiBaseUrl, fileBaseUrl: fileBaseUrl, records: sameTypeRecords, organizationId: organizationId, isReplaceFile: isReplaceFile, onDelete: function () {
|
|
122
|
+
var _a;
|
|
123
|
+
// 因为数据是按照类型来归类了,那么这个索引的长度 实际应该减去之前的所有数据类型的长度
|
|
124
|
+
var dataTypeIndex = index - preDataTypeRecordsLength;
|
|
125
|
+
var copyRecords = sameTypeRecords === null || sameTypeRecords === void 0 ? void 0 : sameTypeRecords.slice();
|
|
126
|
+
if (Array.isArray(copyRecords)) {
|
|
127
|
+
copyRecords.splice(dataTypeIndex, 1);
|
|
128
|
+
if (copyRecords.length === 0) {
|
|
129
|
+
setSameTypeRecords(defaultOnlyQunjRecords);
|
|
130
|
+
var clearElectronListData = onClearElectronListData === null || onClearElectronListData === void 0 ? void 0 : onClearElectronListData();
|
|
131
|
+
var clearElectronSetting = onClearElectronSetting === null || onClearElectronSetting === void 0 ? void 0 : onClearElectronSetting();
|
|
132
|
+
onValueChange &&
|
|
133
|
+
onValueChange(__assign(__assign((_a = {}, _a[firstDataType] = { fileList: defaultOnlyQunjRecords }, _a), clearElectronListData), clearElectronSetting));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
setSameTypeRecords(copyRecords);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}, onWatermarkChange: function (isChecked) {
|
|
140
|
+
// 因为数据是按照类型来归类了,那么这个索引的长度 实际应该减去之前的所有数据类型的长度
|
|
141
|
+
var dataTypeIndex = index - preDataTypeRecordsLength;
|
|
142
|
+
setSameTypeRecords(function (preRecords) {
|
|
143
|
+
var _a;
|
|
144
|
+
var copyRecords = (preRecords === null || preRecords === void 0 ? void 0 : preRecords.slice()) || [];
|
|
145
|
+
var item = copyRecords[dataTypeIndex];
|
|
146
|
+
copyRecords.splice(dataTypeIndex, 1, __assign(__assign({}, item), (_a = { isWatermark: isChecked ? 1 : 0 }, _a[DATA_TYPE_KEY] = currentDataType, _a)));
|
|
147
|
+
return copyRecords;
|
|
148
|
+
});
|
|
149
|
+
}, fileList: records, onFileReplace: onFileReplace }));
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
title: "上传时间",
|
|
154
|
+
dataIndex: "createTime",
|
|
155
|
+
key: "createTime",
|
|
156
|
+
width: 112,
|
|
157
|
+
align: "center",
|
|
158
|
+
render: function (text, record, index) {
|
|
159
|
+
var date = getCreateTimeHand(record);
|
|
160
|
+
// 如果是内部附件 不展示上传时间
|
|
161
|
+
if (currentRecordIsOnlyQunj(record)) {
|
|
162
|
+
return "";
|
|
163
|
+
}
|
|
164
|
+
return date ? (jsxs(Fragment, { children: [jsx("div", { children: dayjs(date).format("YYYY年MM月DD日") }), jsx("div", { children: dayjs(date).format("HH:mm:ss") })] })) : ("");
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
];
|
|
170
|
+
if (isShowFileType) {
|
|
171
|
+
fileColumns[0].children.unshift(fileTypeColumn);
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
fileColumns: fileColumns,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export { useFileColumns as default };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { __assign } from '../../_virtual/_tslib.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { getColumnMergeProp, DATA_TYPE_KEY } from '../hooks/useParseRecords.js';
|
|
4
|
+
|
|
5
|
+
// 附件归属类型
|
|
6
|
+
function useFileTypeColumns(options) {
|
|
7
|
+
var allData = options.allData, records = options.records, dataTypeSort = options.dataTypeSort;
|
|
8
|
+
var fileTypeColumns = [
|
|
9
|
+
{
|
|
10
|
+
title: "附件归属",
|
|
11
|
+
dataIndex: "attachBelongTo",
|
|
12
|
+
key: "attachBelongTo",
|
|
13
|
+
width: 70,
|
|
14
|
+
align: "center",
|
|
15
|
+
onCell: function (record, index) {
|
|
16
|
+
var _a = getColumnMergeProp({
|
|
17
|
+
record: record,
|
|
18
|
+
index: index,
|
|
19
|
+
records: records,
|
|
20
|
+
dataTypeSort: dataTypeSort,
|
|
21
|
+
}), props = _a.props, currentDataType = _a.currentDataType, preDataTypeRecordsLength = _a.preDataTypeRecordsLength;
|
|
22
|
+
var fileSplitRules = (allData[currentDataType] || {}).fileSplitRules;
|
|
23
|
+
// 新的合并规则
|
|
24
|
+
var newProps = props;
|
|
25
|
+
// 根据附件信息来拆分附件
|
|
26
|
+
if (fileSplitRules) {
|
|
27
|
+
// 需要重新计算合并的规则
|
|
28
|
+
// 1. 找到属于同种类型的数据
|
|
29
|
+
var dataTypeRecords = records === null || records === void 0 ? void 0 : records.filter(function (record) { return (record === null || record === void 0 ? void 0 : record[DATA_TYPE_KEY]) === currentDataType; });
|
|
30
|
+
// 2. 找到当前数据的拆分规则
|
|
31
|
+
var fileSplitRule_1 = fileSplitRules(record);
|
|
32
|
+
// 3. 找到同种类型的数据中 属于 同种拆分规则的数据
|
|
33
|
+
var fileSplitRuleFiles = dataTypeRecords.filter(function (record) {
|
|
34
|
+
return fileSplitRule_1.key === fileSplitRules(record).key;
|
|
35
|
+
});
|
|
36
|
+
// 4. 同类型 同拆分规则数据的长度
|
|
37
|
+
var fileSplitRuleFilesLength = fileSplitRuleFiles.length;
|
|
38
|
+
// 这里默认同种类型的数据 属于相同拆分规则的数据 已经按顺序组合好了
|
|
39
|
+
// 所有之前数据的长度
|
|
40
|
+
// 找到首次出现该拆分类型的数据索引
|
|
41
|
+
var firstFindFileSPlitRuleIndex = dataTypeRecords.findIndex(function (record) { return fileSplitRule_1.key === fileSplitRules(record).key; });
|
|
42
|
+
newProps = {
|
|
43
|
+
rowSpan: index === preDataTypeRecordsLength + firstFindFileSPlitRuleIndex
|
|
44
|
+
? fileSplitRuleFilesLength
|
|
45
|
+
: 0,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return newProps;
|
|
49
|
+
},
|
|
50
|
+
render: function (text, record, index) {
|
|
51
|
+
var currentDataType = getColumnMergeProp({
|
|
52
|
+
record: record,
|
|
53
|
+
index: index,
|
|
54
|
+
records: records,
|
|
55
|
+
dataTypeSort: dataTypeSort,
|
|
56
|
+
}).currentDataType;
|
|
57
|
+
var _a = allData[currentDataType] || {}, dataTypeName = _a.dataTypeName, isBgColor = _a.isBgColor, fileSplitRules = _a.fileSplitRules;
|
|
58
|
+
// 新的合并规则
|
|
59
|
+
var newDataTypeName = dataTypeName;
|
|
60
|
+
// 根据附件信息来拆分附件
|
|
61
|
+
if (fileSplitRules) {
|
|
62
|
+
// 2. 找到当前数据的拆分规则
|
|
63
|
+
var fileSplitRule = fileSplitRules(record);
|
|
64
|
+
newDataTypeName = fileSplitRule.name;
|
|
65
|
+
}
|
|
66
|
+
// 处理能否切换是否盖电子印章逻辑
|
|
67
|
+
return (jsxs("div", __assign({ className: "file-add--wrap", style: { backgroundColor: isBgColor ? "#63F163" : "" } }, { children: [jsx("div", { className: "file-add--fragment" }), jsx("div", __assign({ className: "file-add--btn" }, { children: jsx("div", __assign({ className: "file-add--text" }, { children: newDataTypeName })) }))] })));
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
return {
|
|
72
|
+
fileTypeColumns: fileTypeColumns,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { useFileTypeColumns as default };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { currentRecordIsOnlyQunj } from '../utils.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 将各级获取到的附件数据拉平成一个整体
|
|
6
|
+
*/
|
|
7
|
+
function useMergeRecords(options) {
|
|
8
|
+
var allData = options.allData, dataTypeSort = options.dataTypeSort, isDeleteAllFileWhenJustUseQj = options.isDeleteAllFileWhenJustUseQj, isDeletePlaceholderFileData = options.isDeletePlaceholderFileData;
|
|
9
|
+
var mergeRecords = useMemo(function () {
|
|
10
|
+
var allRecords = [];
|
|
11
|
+
dataTypeSort.forEach(function (dataType) {
|
|
12
|
+
var _a;
|
|
13
|
+
var records = ((_a = allData === null || allData === void 0 ? void 0 : allData[dataType]) === null || _a === void 0 ? void 0 : _a.records) || [];
|
|
14
|
+
if (isDeletePlaceholderFileData) {
|
|
15
|
+
records = records.filter(function (record) { return !currentRecordIsOnlyQunj(record); });
|
|
16
|
+
}
|
|
17
|
+
allRecords = allRecords.concat(records);
|
|
18
|
+
});
|
|
19
|
+
return allRecords;
|
|
20
|
+
}, [allData, dataTypeSort, isDeletePlaceholderFileData]);
|
|
21
|
+
// 是否仅选中群杰印章
|
|
22
|
+
var isQunjOnlyChecked = useMemo(function () {
|
|
23
|
+
return mergeRecords.some(function (record) { return currentRecordIsOnlyQunj(record); });
|
|
24
|
+
}, [mergeRecords]);
|
|
25
|
+
// 是否能隐藏非群杰印章模块
|
|
26
|
+
var isHiddenColumns = useMemo(function () {
|
|
27
|
+
// 如果没数据的话,不显示契约锁吗?
|
|
28
|
+
if (mergeRecords.length === 0) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (!isDeleteAllFileWhenJustUseQj) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(mergeRecords)) {
|
|
35
|
+
if (mergeRecords.length === 1) {
|
|
36
|
+
return mergeRecords.every(function (record) { return currentRecordIsOnlyQunj(record); });
|
|
37
|
+
}
|
|
38
|
+
if (mergeRecords.length === 2) {
|
|
39
|
+
return mergeRecords.every(function (record) { return currentRecordIsOnlyQunj(record); });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}, [mergeRecords, isDeleteAllFileWhenJustUseQj]);
|
|
44
|
+
return {
|
|
45
|
+
mergeRecords: mergeRecords,
|
|
46
|
+
isQunjOnlyChecked: isQunjOnlyChecked,
|
|
47
|
+
isHiddenColumns: isHiddenColumns,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { useMergeRecords as default };
|