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.
Files changed (50) hide show
  1. package/dist/es/electronsignatures/dgcomponents/contract-comparison.js +50 -0
  2. package/dist/es/electronsignatures/dgcomponents/useContractColumns.js +53 -0
  3. package/dist/es/electronsignatures/dgcomponents/useDg.js +57 -0
  4. package/dist/es/electronsignatures/electron-signatures-fragment.js +322 -0
  5. package/dist/es/electronsignatures/electroncomponents/electron-seal-batch-download.js +370 -0
  6. package/dist/es/electronsignatures/electroncomponents/electron-seal-detail.js +35 -0
  7. package/dist/es/electronsignatures/electroncomponents/electron-seal-download.js +74 -0
  8. package/dist/es/electronsignatures/electroncomponents/electron-seal-firstLevelPerson.js +17 -0
  9. package/dist/es/electronsignatures/electroncomponents/electron-seal-item.js +21 -0
  10. package/dist/es/electronsignatures/electroncomponents/electron-seal-list.js +42 -0
  11. package/dist/es/electronsignatures/electroncomponents/electron-seal-setting.js +12 -0
  12. package/dist/es/electronsignatures/electroncomponents/last-qys-modal.js +44 -0
  13. package/dist/es/electronsignatures/electroncomponents/useCheckedSealInfoList.js +43 -0
  14. package/dist/es/electronsignatures/electroncomponents/useElectronColumns.js +181 -0
  15. package/dist/es/electronsignatures/electroncomponents/useFetchElectronData.js +118 -0
  16. package/dist/es/electronsignatures/electroncomponents/useGetDeptInfo.js +37 -0
  17. package/dist/es/electronsignatures/electroncomponents/utils.js +266 -0
  18. package/dist/es/electronsignatures/filecomponents/file-operation.js +55 -0
  19. package/dist/es/electronsignatures/filecomponents/file-type-select.js +11 -0
  20. package/dist/es/electronsignatures/filecomponents/file-upload.js +130 -0
  21. package/dist/es/electronsignatures/filecomponents/fileUtils.js +38 -0
  22. package/dist/es/electronsignatures/filecomponents/useFetchFileTypeData.js +46 -0
  23. package/dist/es/electronsignatures/filecomponents/useFileColumns.js +178 -0
  24. package/dist/es/electronsignatures/filecomponents/useFileTypeColumns.js +76 -0
  25. package/dist/es/electronsignatures/hooks/useMergeRecords.js +51 -0
  26. package/dist/es/electronsignatures/hooks/useParseElectronListData.js +113 -0
  27. package/dist/es/electronsignatures/hooks/useParseElectronSetting.js +327 -0
  28. package/dist/es/electronsignatures/hooks/useParseIsNeedElectronData.js +111 -0
  29. package/dist/es/electronsignatures/hooks/useParseIsNeedQunjData.js +50 -0
  30. package/dist/es/electronsignatures/hooks/useParseQunjListData.js +182 -0
  31. package/dist/es/electronsignatures/hooks/useParseQunjSingleData.js +96 -0
  32. package/dist/es/electronsignatures/hooks/useParseRecords.js +141 -0
  33. package/dist/es/electronsignatures/index.css +1 -0
  34. package/dist/es/electronsignatures/index.d.ts +6 -0
  35. package/dist/es/electronsignatures/index.js +836 -0
  36. package/dist/es/electronsignatures/interface.d.ts +500 -0
  37. package/dist/es/electronsignatures/interface.js +53 -0
  38. package/dist/es/electronsignatures/qunjcomponents/code-modal.js +111 -0
  39. package/dist/es/electronsignatures/qunjcomponents/qunj-check.js +15 -0
  40. package/dist/es/electronsignatures/qunjcomponents/qunj-detail.js +65 -0
  41. package/dist/es/electronsignatures/qunjcomponents/qunj-list.js +121 -0
  42. package/dist/es/electronsignatures/qunjcomponents/useFetchQunjData.js +58 -0
  43. package/dist/es/electronsignatures/qunjcomponents/useQunjColumns.js +251 -0
  44. package/dist/es/electronsignatures/utils.js +55 -0
  45. package/dist/es/table/components/EnhanceBodyCell.js +3 -1
  46. package/dist/index.build.d.ts +1 -0
  47. package/dist/index.dark.css +1 -1
  48. package/dist/index.default.css +1 -1
  49. package/dist/index.es.js +1 -0
  50. package/package.json +4 -3
@@ -0,0 +1,43 @@
1
+ import { useMemoizedFn } from 'ahooks';
2
+ import { message } from 'antd';
3
+
4
+ /**
5
+ * 验证契约锁是否全部盖章
6
+ */
7
+ function useCheckedSealInfoList(request) {
8
+ var getNoSealInfoList = useMemoizedFn(function (data) {
9
+ return new Promise(function (resolve, reject) {
10
+ request({
11
+ url: "/api/zmdms-resource/seal/query-unconfirmed-position-seal-list",
12
+ data: data,
13
+ method: "POST",
14
+ })
15
+ .then(function (res) {
16
+ var _a;
17
+ if ((res === null || res === void 0 ? void 0 : res.status) === 200 && ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.code) === 200) {
18
+ var noSealList = res.data.data;
19
+ if (Array.isArray(noSealList) && noSealList.length > 0) {
20
+ resolve(noSealList);
21
+ }
22
+ else {
23
+ resolve([]);
24
+ }
25
+ }
26
+ else {
27
+ message.error(res.data.msg || "校验未盖章电子印章接口调用失败!");
28
+ reject(res.data.msg || "校验未盖章电子印章接口调用失败!");
29
+ }
30
+ })
31
+ .catch(function (error) {
32
+ var _a, _b, _c, _d;
33
+ message.error(((_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || "校验未盖章电子印章接口调用失败!");
34
+ reject(((_d = (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.msg) || "校验未盖章电子印章接口调用失败!");
35
+ });
36
+ });
37
+ });
38
+ return {
39
+ getNoSealInfoList: getNoSealInfoList,
40
+ };
41
+ }
42
+
43
+ export { useCheckedSealInfoList as default };
@@ -0,0 +1,181 @@
1
+ import { __assign } from '../../_virtual/_tslib.js';
2
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
+ import { getColumnMergeProp, DATA_TYPE_KEY } from '../hooks/useParseRecords.js';
4
+ import ElectronSealDownload from './electron-seal-download.js';
5
+ import ElectronSealItem from './electron-seal-item.js';
6
+ import ElectronSealList from './electron-seal-list.js';
7
+ import ElectronSealDetail, { NoUseElectronSeal } from './electron-seal-detail.js';
8
+ import ElectronSealFirstLevelPerson from './electron-seal-firstLevelPerson.js';
9
+ import ElectronSealSetting from './electron-seal-setting.js';
10
+ import { currentRecordIsOnlyQunj } from '../utils.js';
11
+
12
+ /**
13
+ * 生成电子印章列
14
+ */
15
+ function useElectronColumns(options) {
16
+ var request = options.request, records = options.records, dataTypeSort = options.dataTypeSort, allData = options.allData, fmsIsElectronicSealLabel = options.fmsIsElectronicSealLabel, fmsIsElectronicSealPushLabel = options.fmsIsElectronicSealPushLabel, isDeleteAllFileWhenJustUseQj = options.isDeleteAllFileWhenJustUseQj;
17
+ var currentDataType = dataTypeSort === null || dataTypeSort === void 0 ? void 0 : dataTypeSort[0];
18
+ var _a = allData[currentDataType] || {}, isStampElectron = _a.isStampElectron, needQys = _a.needQys, currentContractId = _a.currentContractId, appointSignLocation = _a.appointSignLocation, viewSignPage = _a.viewSignPage, isEdit = _a.isEdit;
19
+ var currentOnlyQunj = currentRecordIsOnlyQunj(records === null || records === void 0 ? void 0 : records[0]);
20
+ // 契约锁相关配置
21
+ var electronColumns = [
22
+ {
23
+ // title: '电子印章',
24
+ title: (jsxs("div", __assign({ className: "file-title" }, { children: [jsx("div", __assign({ className: "file-label" }, { children: "\u7535\u5B50\u5370\u7AE0" })), jsx("div", __assign({ className: "file-upload" }, { children: currentOnlyQunj ? null : !needQys ? null : isStampElectron ? (jsx(ElectronSealSetting, { contractId: currentContractId, appointSignLocation: appointSignLocation, viewSignPage: viewSignPage, isEdit: isEdit })) : null }))] }))),
25
+ children: [
26
+ {
27
+ title: "盖电子印章",
28
+ dataIndex: "isStampElectron",
29
+ key: "isStampElectron",
30
+ width: 100,
31
+ align: "center",
32
+ render: function (text, record, index) {
33
+ var currentOnlyQunj = currentRecordIsOnlyQunj(record);
34
+ if (currentOnlyQunj) {
35
+ return null;
36
+ }
37
+ var _a = getColumnMergeProp({
38
+ record: record,
39
+ index: index,
40
+ records: records,
41
+ dataTypeSort: dataTypeSort,
42
+ }), currentDataType = _a.currentDataType, preDataTypeRecordsLength = _a.preDataTypeRecordsLength;
43
+ var _b = allData[currentDataType] || {}, isEdit = _b.isEdit, onIsStampElectronChange = _b.onIsStampElectronChange, setSameTypeRecords = _b.setRecords, currentDocAttachMap = _b.currentDocAttachMap, fileFieldsNameRef = _b.fileFieldsNameRef, flowStatus = _b.flowStatus, needQys = _b.needQys;
44
+ var _c = (fileFieldsNameRef === null || fileFieldsNameRef === void 0 ? void 0 : fileFieldsNameRef.current) || {}, _d = _c.fmsIsPushBank, fmsIsPushBankKey = _d === void 0 ? "fmsIsPushBank" : _d, _e = _c.fmsIsElectronicSeal, fmsIsElectronicSealKey = _e === void 0 ? "fmsIsElectronicSeal" : _e;
45
+ // 是否显示产融平台相关逻辑
46
+ var isShowFms = (record === null || record === void 0 ? void 0 : record.showFmsIsElectronicSeal) &&
47
+ (record === null || record === void 0 ? void 0 : record[fmsIsElectronicSealKey]) != null &&
48
+ (record === null || record === void 0 ? void 0 : record.attachType) === "001" &&
49
+ (record === null || record === void 0 ? void 0 : record.isElectronicSeal);
50
+ // 是否推送银行
51
+ var isShowBank = (record === null || record === void 0 ? void 0 : record.showFmsIsPushBank) &&
52
+ (record === null || record === void 0 ? void 0 : record[fmsIsPushBankKey]) != null &&
53
+ (record === null || record === void 0 ? void 0 : record.attachType) === "001" &&
54
+ (record === null || record === void 0 ? void 0 : record.isElectronicSeal);
55
+ // 是否盖产融平台
56
+ var fmsIsElectronicSeal = (record === null || record === void 0 ? void 0 : record[fmsIsElectronicSealKey]) + "" === "1" ? true : false;
57
+ // 是否推送银行
58
+ var fmsIsPushBank = (record === null || record === void 0 ? void 0 : record[fmsIsPushBankKey]) + "" === "1" ? true : false;
59
+ // 处理能否切换是否盖电子印章逻辑
60
+ return !needQys ? null : isEdit ? (jsx(ElectronSealItem, { disabled: !isEdit, checked: record === null || record === void 0 ? void 0 : record.isElectronicSeal, onChange: function (checked) {
61
+ // 因为数据是按照类型来归类了,那么这个索引的长度 实际应该减去之前的所有数据类型的长度
62
+ var dataTypeIndex = index - preDataTypeRecordsLength;
63
+ onIsStampElectronChange(checked, dataTypeIndex);
64
+ }, isShowFms: isShowFms, isShowBank: isShowBank, fmsIsElectronicSealPushLabel: fmsIsElectronicSealPushLabel, fmsIsPushBank: fmsIsPushBank, fmsIsElectronicSealLabel: fmsIsElectronicSealLabel, fmsIsElectronicSeal: fmsIsElectronicSeal, onFmsIsElectronicSealChange: function (checked, type) {
65
+ // 因为数据是按照类型来归类了,那么这个索引的长度 实际应该减去之前的所有数据类型的长度
66
+ var dataTypeIndex = index - preDataTypeRecordsLength;
67
+ setSameTypeRecords(function (preRecords) {
68
+ var _a;
69
+ var copyRecords = preRecords.slice();
70
+ var item = copyRecords[dataTypeIndex];
71
+ copyRecords.splice(dataTypeIndex, 1, __assign(__assign({}, item), (_a = {}, _a[type === "fmsElectron"
72
+ ? fmsIsElectronicSealKey
73
+ : fmsIsPushBankKey] = checked ? 1 : 0, _a[DATA_TYPE_KEY] = currentDataType, _a)));
74
+ return copyRecords;
75
+ });
76
+ } })) : (jsx(ElectronSealDownload, { docAttachMap: currentDocAttachMap, record: record, fileFieldsNameRef: fileFieldsNameRef, request: request, flowStatus: flowStatus, checked: record === null || record === void 0 ? void 0 : record.isElectronicSeal }));
77
+ },
78
+ },
79
+ {
80
+ title: "选择电子印章",
81
+ dataIndex: "electronList",
82
+ key: "electronList",
83
+ width: 260,
84
+ align: "center",
85
+ onCell: function (record, index) {
86
+ var props = getColumnMergeProp({
87
+ record: record,
88
+ index: index,
89
+ records: records,
90
+ dataTypeSort: dataTypeSort,
91
+ }).props;
92
+ return props;
93
+ },
94
+ render: function (text, record, index) {
95
+ // 需要合并
96
+ var currentDataType = getColumnMergeProp({
97
+ record: record,
98
+ index: index,
99
+ records: records,
100
+ dataTypeSort: dataTypeSort,
101
+ }).currentDataType;
102
+ var currentOnlyQunj = currentRecordIsOnlyQunj(record);
103
+ if (currentOnlyQunj && isDeleteAllFileWhenJustUseQj) {
104
+ return null;
105
+ }
106
+ var _a = allData[currentDataType] || {}, isEdit = _a.isEdit, needQys = _a.needQys, firstLevelPersonName = _a.firstLevelPersonName, currentCheckedElectronicSealIdList = _a.currentCheckedElectronicSealIdList, currentIsCheckedEconomic = _a.currentIsCheckedEconomic, onCheckedEconomicChange = _a.onCheckedEconomicChange, electronList = _a.electronList, onElectronicSealIdChange = _a.onElectronicSealIdChange, isStampElectron = _a.isStampElectron, appointSignLocation = _a.appointSignLocation;
107
+ // 1. 处理当前类型的数据需不需要契约锁
108
+ // 2. 处理当前类型的数据处不处于编辑状态
109
+ return !needQys ? (jsx(NoUseElectronSeal, {})) : isEdit ? (jsxs(Fragment, { children: [jsx(ElectronSealFirstLevelPerson, { firstLevelPersonName: firstLevelPersonName, checked: currentIsCheckedEconomic, isEdit: !!isStampElectron, onChange: function (e) {
110
+ // 如果此时已经选了电子印章的话,更改是否切换一级责任人
111
+ // 将重新调用 指定签署位置的 逻辑(因为指定签署位置 需要传递是否选中一级责任人 如果这个一级责任人是否选中更改了的话 需要重新告诉后端 处理一些逻辑)
112
+ if ((currentCheckedElectronicSealIdList === null || currentCheckedElectronicSealIdList === void 0 ? void 0 : currentCheckedElectronicSealIdList.length) > 0) {
113
+ appointSignLocation === null || appointSignLocation === void 0 ? void 0 : appointSignLocation({
114
+ otherParams: {
115
+ needYjzrr: e.target.checked,
116
+ },
117
+ isCheckUnStampedSeal: true,
118
+ spinningTip: "接口调用中...",
119
+ });
120
+ }
121
+ else {
122
+ onCheckedEconomicChange(e);
123
+ }
124
+ } }), jsx(ElectronSealList, { sealList: electronList, value: currentCheckedElectronicSealIdList, onChange: onElectronicSealIdChange, isEdit: !!isStampElectron })] })) : (jsx(ElectronSealDetail, { sealList: electronList, value: currentCheckedElectronicSealIdList }));
125
+ },
126
+ },
127
+ // 2024-07-30
128
+ // 产品要求去掉每种类型的指定位置 预览盖章效果等字样
129
+ // {
130
+ // title: '电子印章设置',
131
+ // dataIndex: 'isElectronSetting',
132
+ // key: 'isElectronSetting',
133
+ // width: 100,
134
+ // align: 'center',
135
+ // render: (text, record, index) => {
136
+ // // 需要合并
137
+ // const { currentDataType, props } = getColumnMergeProp({
138
+ // record,
139
+ // index,
140
+ // records,
141
+ // dataTypeSort,
142
+ // });
143
+ // const {
144
+ // isStampElectron,
145
+ // needQys,
146
+ // currentContractId,
147
+ // appointSignLocation,
148
+ // viewSignPage,
149
+ // isEdit,
150
+ // } = allData[currentDataType] || {};
151
+ // const currentOnlyQunj = currentRecordIsOnlyQunj(record);
152
+ // if (currentOnlyQunj) {
153
+ // return {
154
+ // children: null,
155
+ // props,
156
+ // };
157
+ // }
158
+ // return {
159
+ // children: !needQys ? (
160
+ // '暂不需要契约锁数据'
161
+ // ) : isStampElectron ? (
162
+ // <ElectronSealSetting
163
+ // contractId={currentContractId}
164
+ // appointSignLocation={appointSignLocation}
165
+ // viewSignPage={viewSignPage}
166
+ // isEdit={isEdit}
167
+ // />
168
+ // ) : null,
169
+ // props,
170
+ // };
171
+ // },
172
+ // },
173
+ ],
174
+ },
175
+ ];
176
+ return {
177
+ electronColumns: electronColumns,
178
+ };
179
+ }
180
+
181
+ export { useElectronColumns as default };
@@ -0,0 +1,118 @@
1
+ import { useMemo, useRef, useState, useCallback, useEffect } from 'react';
2
+ import { message } from 'antd';
3
+
4
+ /**
5
+ * 获取电子印章远程数据
6
+ */
7
+ function useFetchElectronData(options) {
8
+ var request = options.request, needQys = options.needQys, deptId = options.deptId, flowId = options.flowId, records = options.records;
9
+ // records里面是否有勾选了电子印章的数据
10
+ var hasElectronMemo = useMemo(function () {
11
+ var _a;
12
+ return (_a = records === null || records === void 0 ? void 0 : records.some) === null || _a === void 0 ? void 0 : _a.call(records, function (record) { return !!record.isElectronicSeal; });
13
+ }, [records]);
14
+ var isFirstRenderRef = useRef(false);
15
+ // 印章列表数据
16
+ var _a = useState(), electronList = _a[0], setElectronList = _a[1];
17
+ // 一级责任人数据
18
+ var _b = useState(), firstLevelPersonName = _b[0], setFirstLevelPersonName = _b[1];
19
+ // 获取电子印章信息 接口层必须传入部门id 和 流程id 才能获取到印章信息
20
+ var getElectronList = useCallback(function (params) {
21
+ var newParam = {
22
+ size: 200,
23
+ };
24
+ if (params.deptId) {
25
+ newParam.deptId = params.deptId;
26
+ }
27
+ if (params.flowId) {
28
+ newParam.flowId = params.flowId;
29
+ }
30
+ return request === null || request === void 0 ? void 0 : request({
31
+ url: "/api/zmdms-resource/flowdeptseal/select-seal-info-list",
32
+ params: newParam,
33
+ method: "GET",
34
+ }).then(function (res) {
35
+ var _a, _b, _c;
36
+ if (res.status === 200 && res.data.code === 200) {
37
+ return ((_c = (_b = (_a = res.data.data) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.sealInfoList) || [];
38
+ }
39
+ else {
40
+ message.error(res.data.msg || "出错了");
41
+ return Promise.reject(res);
42
+ }
43
+ }).catch(function (error) {
44
+ var _a, _b;
45
+ message.error(((_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || "请求失败!");
46
+ return Promise.reject(error);
47
+ });
48
+ }, [request]);
49
+ // 获取一级责任人名字
50
+ var getFirstLevelPerson = useCallback(function (deptId) {
51
+ return request({
52
+ url: "/api/zmdms-resource/seal/get-yjzrr-name/".concat(deptId),
53
+ method: "GET",
54
+ })
55
+ .then(function (res) {
56
+ var _a;
57
+ if (res.status === 200 && res.data.code === 200) {
58
+ return (_a = res.data.data) === null || _a === void 0 ? void 0 : _a.userName;
59
+ }
60
+ else {
61
+ // 20240920:不需要报错提示
62
+ // if (canEdit) {
63
+ // message.error(res.data.msg || '出错了');
64
+ // }
65
+ return Promise.reject(res);
66
+ }
67
+ })
68
+ .catch(function (error) {
69
+ // 20240920:不需要报错提示
70
+ // if (canEdit) {
71
+ // message.error(error?.response?.data?.msg || '请求失败!');
72
+ // }
73
+ return Promise.reject(error);
74
+ });
75
+ }, [request]);
76
+ // 获取契约锁列表数据
77
+ useEffect(function () {
78
+ // 如果不需要契约锁数据
79
+ if (needQys + "" !== "1") {
80
+ return;
81
+ }
82
+ getElectronList({
83
+ deptId: deptId,
84
+ flowId: flowId,
85
+ }).then(function (res) {
86
+ setElectronList(res);
87
+ });
88
+ }, [needQys, deptId, flowId, getElectronList]);
89
+ // 20240920:部门变更了 需要重新获取一级责任人
90
+ useEffect(function () {
91
+ setFirstLevelPersonName("");
92
+ isFirstRenderRef.current = false;
93
+ }, [deptId]);
94
+ useEffect(function () {
95
+ // 如果不需要契约锁数据
96
+ if (needQys + "" !== "1") {
97
+ return;
98
+ }
99
+ if (!isFirstRenderRef.current && hasElectronMemo) {
100
+ isFirstRenderRef.current = true;
101
+ getFirstLevelPerson(deptId)
102
+ .then(function (res) {
103
+ setFirstLevelPersonName(res);
104
+ })
105
+ .catch(function (err) {
106
+ setFirstLevelPersonName("");
107
+ });
108
+ }
109
+ }, [getFirstLevelPerson, needQys, deptId, hasElectronMemo, isFirstRenderRef]);
110
+ return {
111
+ /** 当前印章列表数据 */
112
+ electronList: electronList,
113
+ /** 当前经济责任人(一级责任人)数据 */
114
+ firstLevelPersonName: firstLevelPersonName,
115
+ };
116
+ }
117
+
118
+ export { useFetchElectronData as default };
@@ -0,0 +1,37 @@
1
+ import { useMemoizedFn } from 'ahooks';
2
+
3
+ /**
4
+ * 验证契约锁是否全部盖章
5
+ */
6
+ function useCheckedSealInfoList(request) {
7
+ var getDeptInfo = useMemoizedFn(function (params) {
8
+ return new Promise(function (resolve, reject) {
9
+ request({
10
+ url: "/api/zmdms-system/dept/detail",
11
+ params: params,
12
+ method: "GET",
13
+ })
14
+ .then(function (res) {
15
+ var _a;
16
+ if ((res === null || res === void 0 ? void 0 : res.status) === 200 && ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.code) === 200) {
17
+ var result = res.data.data;
18
+ resolve(result || {});
19
+ }
20
+ else {
21
+ // message.error(res.data.msg || '获取部门信息失败!');
22
+ reject(res.data.msg || "获取部门信息失败!");
23
+ }
24
+ })
25
+ .catch(function (error) {
26
+ var _a, _b;
27
+ // message.error(error?.response?.data?.msg || '获取部门信息失败!');
28
+ reject(((_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || "获取部门信息失败!");
29
+ });
30
+ });
31
+ });
32
+ return {
33
+ getDeptInfo: getDeptInfo,
34
+ };
35
+ }
36
+
37
+ export { useCheckedSealInfoList as default };
@@ -0,0 +1,266 @@
1
+ import { __assign } from '../../_virtual/_tslib.js';
2
+ import { MAX_PREVIEW_SIZE } from '../../config/constant.js';
3
+ import { batchDownloadFiles, downloadFile } from 'zmdms-utils';
4
+ import { message } from 'antd';
5
+
6
+ function fileBatchDownload(fileList, otherConfig) {
7
+ var canDownloadFileList = []; // 可以下载的附件列表
8
+ var noCanDownloadFileList = []; // 不可以下载的附件列表
9
+ var otherParams = {
10
+ status: "pending",
11
+ };
12
+ console.log(fileList);
13
+ if (Array.isArray(fileList) && fileList.length > 0) {
14
+ var _a = otherConfig.showDownloadBtn, showDownloadBtn_1 = _a === void 0 ? true : _a, _b = otherConfig.showPreviewBtn, showPreviewBtn_1 = _b === void 0 ? true : _b, _c = otherConfig.isCompress, isCompress = _c === void 0 ? true : _c, authToken_1 = otherConfig.authToken, apiBaseUrl_1 = otherConfig.apiBaseUrl, zipName = otherConfig.zipName;
15
+ // 找出可以下载的文件,以及不可以下载的文件
16
+ fileList.forEach(function (fileItem, index) {
17
+ var fileSize = fileItem.fileSize, operationAuth = fileItem.operationAuth;
18
+ var authDownloadBtn = typeof operationAuth === "string" && operationAuth.indexOf("2") !== -1
19
+ ? true
20
+ : false;
21
+ var authPreviewBtn = typeof operationAuth === "string" && operationAuth.indexOf("1") !== -1
22
+ ? true
23
+ : false;
24
+ // 如果可以下载
25
+ if ((typeof operationAuth === "string"
26
+ ? authDownloadBtn
27
+ : showDownloadBtn_1) ||
28
+ ((typeof operationAuth === "string"
29
+ ? authPreviewBtn
30
+ : showPreviewBtn_1) &&
31
+ (fileSize || 0) >= MAX_PREVIEW_SIZE)) {
32
+ canDownloadFileList.push(__assign({}, fileItem));
33
+ }
34
+ else {
35
+ noCanDownloadFileList.push(__assign({}, fileItem));
36
+ }
37
+ });
38
+ if (isCompress) {
39
+ // 下载打包成PDF的文件。
40
+ var attachIds_1 = [];
41
+ var fileNames_1 = [];
42
+ var _zipName = zipName
43
+ ? zipName.endsWith(".zip")
44
+ ? zipName
45
+ : "".concat(zipName, ".zip")
46
+ : "批量下载附件.zip";
47
+ // 批量下载默认需要水印
48
+ var addWaterMark_1 = true;
49
+ canDownloadFileList.forEach(function (fileItem) {
50
+ attachIds_1.push(fileItem.fileId);
51
+ fileNames_1.push(fileItem.fileName || "");
52
+ // 只要选中的附件中,有一个不需要水印。其他附件默认不需要添加水印
53
+ if (!fileItem.isWatermark) {
54
+ addWaterMark_1 = false;
55
+ }
56
+ });
57
+ var fileList_1 = canDownloadFileList.map(function (item) { return ({
58
+ attachId: item.fileId,
59
+ attachName: item.fileName || "",
60
+ }); });
61
+ batchDownloadFiles(fileList_1, {
62
+ API_BASEURL: apiBaseUrl_1,
63
+ waterMark: addWaterMark_1,
64
+ zipName: _zipName,
65
+ })
66
+ .then(function (res) {
67
+ otherParams.status = "fulfilled";
68
+ })
69
+ .catch(function (err) {
70
+ otherParams.status = "rejected";
71
+ });
72
+ }
73
+ else {
74
+ // 单个文件下载
75
+ canDownloadFileList.forEach(function (fileItem, index) {
76
+ var fileId = fileItem.fileId, fileName = fileItem.fileName, isWatermark = fileItem.isWatermark;
77
+ if (!otherParams.otherList) {
78
+ otherParams.otherList = [];
79
+ otherParams.otherList.push("pending");
80
+ }
81
+ downloadFile(fileId, fileName || "\u9644\u4EF6".concat(index + 1), {
82
+ API_BASEURL: apiBaseUrl_1,
83
+ authToken: authToken_1,
84
+ waterMark: isWatermark,
85
+ })
86
+ .then(function (res) {
87
+ fileItem._downloadStatus = "fulfilled";
88
+ if (otherParams.otherList) {
89
+ otherParams.otherList[index] = "fulfilled";
90
+ }
91
+ })
92
+ .catch(function (err) {
93
+ fileItem._downloadStatus = "rejected";
94
+ if (otherParams.otherList) {
95
+ otherParams.otherList[index] = "rejected";
96
+ }
97
+ });
98
+ });
99
+ }
100
+ }
101
+ return {
102
+ canDownloadFileList: canDownloadFileList,
103
+ noCanDownloadFileList: noCanDownloadFileList,
104
+ otherParams: otherParams,
105
+ };
106
+ }
107
+ function sealFileBatchDownload(request, params, isCompress) {
108
+ if (isCompress === void 0) { isCompress = true; }
109
+ var otherParams = {
110
+ status: "pending",
111
+ };
112
+ var fileList = params.qysAttachVOList;
113
+ if (Array.isArray(fileList) && fileList.length > 0) {
114
+ if (isCompress) {
115
+ // 下载打包成PDF的文件。
116
+ sealDownloadFileCallBack(request, params, {
117
+ callbackAfter: function () {
118
+ otherParams.status = "fulfilled";
119
+ },
120
+ callbackError: function () {
121
+ otherParams.status = "rejected";
122
+ },
123
+ });
124
+ }
125
+ else {
126
+ // 单个文件下载
127
+ fileList.forEach(function (fileItem, index) {
128
+ if (!otherParams.otherList) {
129
+ otherParams.otherList = [];
130
+ otherParams.otherList.push("pending");
131
+ }
132
+ var newParams = {
133
+ docAttachMap: params.docAttachMap,
134
+ qysAttachVOList: [fileItem],
135
+ };
136
+ sealDownloadFileCallBack(request, newParams, {
137
+ callbackAfter: function () {
138
+ fileItem._downloadStatus = "fulfilled";
139
+ if (otherParams.otherList) {
140
+ otherParams.otherList[index] = "fulfilled";
141
+ }
142
+ },
143
+ callbackError: function () {
144
+ fileItem._downloadStatus = "rejected";
145
+ if (otherParams.otherList) {
146
+ otherParams.otherList[index] = "rejected";
147
+ }
148
+ },
149
+ });
150
+ });
151
+ }
152
+ }
153
+ return {
154
+ otherParams: otherParams,
155
+ };
156
+ }
157
+ /**
158
+ * 是否可以下载
159
+ */
160
+ function preCanDownload(donwloadReuslt, callback) {
161
+ if (!donwloadReuslt) {
162
+ return true;
163
+ }
164
+ var otherParams = donwloadReuslt.otherParams;
165
+ if (otherParams === null || otherParams === void 0 ? void 0 : otherParams.otherList) {
166
+ // 附件还在下载中
167
+ if (otherParams.otherList.find(function (i) { return i === "pending"; })) {
168
+ message.info("\u4E0A\u6B21\u6587\u4EF6\u4E0B\u8F7D\u8FD8\u672A\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u518D\u8FDB\u884C\u4E0B\u8F7D!");
169
+ return false;
170
+ }
171
+ // 上次附件下载失败了 成功了 都需要重置状态
172
+ if (otherParams.otherList.filter(function (i) { return i === "pending"; }).length === 0) {
173
+ callback && callback();
174
+ return true;
175
+ }
176
+ }
177
+ else {
178
+ // 附件还在下载中
179
+ if ((otherParams === null || otherParams === void 0 ? void 0 : otherParams.status) === "pending") {
180
+ message.info("\u4E0A\u6B21\u6587\u4EF6\u4E0B\u8F7D\u8FD8\u672A\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u518D\u8FDB\u884C\u4E0B\u8F7D!");
181
+ return false;
182
+ }
183
+ // 上次附件下载失败了 成功了 都需要重置状态
184
+ if ((otherParams === null || otherParams === void 0 ? void 0 : otherParams.status) === "rejected" ||
185
+ (otherParams === null || otherParams === void 0 ? void 0 : otherParams.status) === "fulfilled") {
186
+ callback && callback();
187
+ return true;
188
+ }
189
+ }
190
+ }
191
+ function nextDownload(donwloadReuslt, callback) {
192
+ if (!donwloadReuslt) {
193
+ return;
194
+ }
195
+ var noCanDownloadFileList = donwloadReuslt.noCanDownloadFileList, canDownloadFileList = donwloadReuslt.canDownloadFileList;
196
+ if (Array.isArray(noCanDownloadFileList) &&
197
+ noCanDownloadFileList.length > 0) {
198
+ message.info("\u4EE5\u4E0B\u6587\u4EF6\u672A\u6388\u6743\u4E0B\u8F7D\uFF1A\n ".concat(noCanDownloadFileList
199
+ .map(function (item) { return item.fileName; })
200
+ .join("\n"), "!"));
201
+ }
202
+ if (Array.isArray(canDownloadFileList) && canDownloadFileList.length === 0) {
203
+ message.info("请选择有权限下载的附件!");
204
+ callback && callback();
205
+ }
206
+ }
207
+ /**
208
+ * 批量下载
209
+ */
210
+ function sealDownloadFileCallBack(request, params, otherOption) {
211
+ var _a = otherOption || {}, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError;
212
+ request({
213
+ method: "POST",
214
+ url: "/api/zmdms-resource/seal/batch-download-seal-files",
215
+ responseType: "blob",
216
+ data: params,
217
+ })
218
+ .then(function (res) {
219
+ var _a, _b, _c;
220
+ if (!((_a = res.headers) === null || _a === void 0 ? void 0 : _a["content-disposition"])) {
221
+ callbackError && callbackError();
222
+ message.warning("没有可下载的内容");
223
+ return;
224
+ }
225
+ var fileName = res.headers["content-disposition"].split(";");
226
+ var fileNameArray = (_b = fileName[1]) === null || _b === void 0 ? void 0 : _b.split("=");
227
+ var fileNameStr = decodeURIComponent(fileNameArray[1]);
228
+ var blob = new Blob([res.data], {
229
+ type: "application/vnd.ms-excel",
230
+ });
231
+ if (blob.size < 1) {
232
+ callbackError && callbackError();
233
+ message.warning("下载失败,下载的内容为空!");
234
+ return;
235
+ }
236
+ var aLink = document.createElement("a");
237
+ aLink.style.display = "none";
238
+ aLink.href = window.URL.createObjectURL(blob);
239
+ aLink.download = (_c = fileNameStr === null || fileNameStr === void 0 ? void 0 : fileNameStr.replace) === null || _c === void 0 ? void 0 : _c.call(fileNameStr, /["]/g, "");
240
+ document.body.appendChild(aLink);
241
+ aLink.click();
242
+ document.body.removeChild(aLink);
243
+ callbackAfter && callbackAfter();
244
+ })
245
+ .catch(function (err) {
246
+ var _a;
247
+ try {
248
+ var file_1 = new FileReader();
249
+ file_1.readAsText((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.data, "utf-8");
250
+ file_1.onload = function () {
251
+ var obj = {};
252
+ try {
253
+ obj = JSON.parse(file_1.result);
254
+ }
255
+ catch (err) { }
256
+ message.warning((obj === null || obj === void 0 ? void 0 : obj.msg) || "没有可下载的内容");
257
+ };
258
+ }
259
+ catch (err) {
260
+ message.warning("下载出错");
261
+ }
262
+ callbackError && callbackError();
263
+ });
264
+ }
265
+
266
+ export { fileBatchDownload, nextDownload, preCanDownload, sealDownloadFileCallBack, sealFileBatchDownload };