zmdms-webui 2.8.0 → 2.8.1
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/config/ZtxkContext.d.ts +8 -0
- package/dist/es/config/ZtxkContext.js +2 -0
- package/dist/es/config/utils.js +13 -0
- package/dist/es/form/form.js +3 -2
- package/dist/es/table/components/FilterDropdown.js +40 -10
- package/dist/es/table/hooks.js +25 -11
- package/dist/es/table/table.js +1 -1
- package/dist/es/table/useColumns.js +18 -2
- package/dist/es/translationbutton/DownFile.js +103 -0
- package/dist/es/translationbutton/PreviewFile.d.ts +5 -0
- package/dist/es/translationbutton/PreviewFile.js +63 -0
- package/dist/es/translationbutton/hooks.js +88 -0
- package/dist/es/translationbutton/index.d.ts +5 -0
- package/dist/es/translationbutton/index.js +5 -0
- package/dist/es/translationbutton/translationButton.d.ts +32 -0
- package/dist/es/translationbutton/translationButton.js +189 -0
- package/dist/es/uploadlist/interface.d.ts +4 -0
- package/dist/es/uploadlist/uploadList.js +7 -4
- package/dist/es/uploadlist/uploadListDetail.js +3 -2
- package/dist/es/uploadlist/uploadTable.js +11 -3
- package/dist/index.build.d.ts +2 -0
- package/dist/index.es.js +2 -0
- package/package.json +1 -1
|
@@ -38,6 +38,14 @@ interface IZtxkConfig {
|
|
|
38
38
|
* 动态列模态框是否默认开启搜索功能
|
|
39
39
|
*/
|
|
40
40
|
enableDynamicColumnSearch?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* 翻译预览路由 翻译组件使用
|
|
43
|
+
*/
|
|
44
|
+
translationPreviewRoute?: string;
|
|
45
|
+
/**
|
|
46
|
+
* 是否给所有附件默认开启翻译按钮功能
|
|
47
|
+
*/
|
|
48
|
+
enableTranslationButton?: boolean;
|
|
41
49
|
}
|
|
42
50
|
declare const ZtxkContext: React__default.Context<IZtxkConfig>;
|
|
43
51
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 全局默认值 与 组件默认值之间取值逻辑
|
|
3
|
+
* 1. 如果组件没有传入值,则取全局默认值
|
|
4
|
+
* 2. 如果组件传入了值,则取组件传入的值
|
|
5
|
+
* @param globalDefault 全局默认值
|
|
6
|
+
* @param componentValue 组件传入的值
|
|
7
|
+
* @returns 最终取值
|
|
8
|
+
*/
|
|
9
|
+
function getFinalValue(globalDefault, componentValue) {
|
|
10
|
+
return componentValue !== null && componentValue !== void 0 ? componentValue : globalDefault;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { getFinalValue };
|
package/dist/es/form/form.js
CHANGED
|
@@ -12,6 +12,7 @@ import Toggle from './toggle.js';
|
|
|
12
12
|
import '../config/ZtxkContext.js';
|
|
13
13
|
import useBaseContext from '../config/useBaseContext.js';
|
|
14
14
|
import '../config/MyStorage.js';
|
|
15
|
+
import { getFinalValue } from '../config/utils.js';
|
|
15
16
|
import CommonSearchList from './common-search-list.js';
|
|
16
17
|
import { COMMON_SEARCH_KEY, useCommonSearch, useCommonSearchModal } from './useCommonSearch.js';
|
|
17
18
|
import DynamicSetting from '../dynamicsetting/dynamicSetting.js';
|
|
@@ -31,8 +32,8 @@ var Form = function (props, ref) {
|
|
|
31
32
|
var enableCommonSearch = useBaseContext().enableCommonSearch;
|
|
32
33
|
// 是否开启常用搜索
|
|
33
34
|
// 如果全局开启了默认添加,那么只要没有单独配置关闭,都认为需要打开
|
|
34
|
-
var isCommonSearchEnabled = rightWrapVisible &&
|
|
35
|
-
|
|
35
|
+
var isCommonSearchEnabled = rightWrapVisible && getFinalValue(enableCommonSearch, isCommonSearch);
|
|
36
|
+
// (enableCommonSearch ? isCommonSearch !== false : !!isCommonSearch);
|
|
36
37
|
// 常用搜索hooks
|
|
37
38
|
var _b = useCommonSearch({
|
|
38
39
|
commonSearchKey: dynamicKey || window.location.pathname,
|
|
@@ -2,9 +2,9 @@ import { __assign } from '../../_virtual/_tslib.js';
|
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useMemo, useEffect, useState } from 'react';
|
|
4
4
|
import { useLatest } from 'ahooks';
|
|
5
|
-
import myMessage from '../../message/index.js';
|
|
6
5
|
import Input from '../../input/input.js';
|
|
7
6
|
import ButtonCom from '../../button/button.js';
|
|
7
|
+
import myMessage from '../../message/index.js';
|
|
8
8
|
import { Checkbox, Tooltip } from 'antd';
|
|
9
9
|
import QuestionCircleOutlined from '../../node_modules/@ant-design/icons/es/icons/QuestionCircleOutlined.js';
|
|
10
10
|
|
|
@@ -12,12 +12,16 @@ import QuestionCircleOutlined from '../../node_modules/@ant-design/icons/es/icon
|
|
|
12
12
|
* 列头过滤组件
|
|
13
13
|
*/
|
|
14
14
|
var FilterDropdown = function (props) {
|
|
15
|
-
var dataSource = props.dataSource, filterKey = props.filterKey, filterSearchValue = props.filterSearchValue, filterSearchValueChange = props.filterSearchValueChange, defaultFilterSearchValue = props.defaultFilterSearchValue, filterSearchCheckboxValue = props.filterSearchCheckboxValue, defaultFilterSearchCheckboxValue = props.defaultFilterSearchCheckboxValue, filterSearchCheckboxValueChange = props.filterSearchCheckboxValueChange, setSelectedKeys = props.setSelectedKeys, confirm = props.confirm, clearFilters = props.clearFilters, searchValueInputRef = props.searchValueInputRef, onFilterChange = props.onFilterChange;
|
|
15
|
+
var dataSource = props.dataSource, filterKey = props.filterKey, filterSearchValue = props.filterSearchValue, filterSearchValueChange = props.filterSearchValueChange, defaultFilterSearchValue = props.defaultFilterSearchValue, filterSearchCheckboxValue = props.filterSearchCheckboxValue, defaultFilterSearchCheckboxValue = props.defaultFilterSearchCheckboxValue, filterSearchCheckboxValueChange = props.filterSearchCheckboxValueChange, setSelectedKeys = props.setSelectedKeys, confirm = props.confirm, clearFilters = props.clearFilters, searchValueInputRef = props.searchValueInputRef, onFilterChange = props.onFilterChange, column = props.column;
|
|
16
|
+
var columnRef = useLatest(column);
|
|
16
17
|
var lastSetSelectedKeys = useLatest(setSelectedKeys);
|
|
17
18
|
// 当前可选的数据
|
|
18
19
|
var currentData = useMemo(function () {
|
|
19
|
-
return getDataByKey(dataSource,
|
|
20
|
-
|
|
20
|
+
return getDataByKey(dataSource, {
|
|
21
|
+
key: filterKey,
|
|
22
|
+
column: columnRef.current,
|
|
23
|
+
});
|
|
24
|
+
}, [dataSource, filterKey, columnRef]);
|
|
21
25
|
// 过滤输入框 input输入值
|
|
22
26
|
var _a = useControlled(props, {
|
|
23
27
|
value: filterSearchValue,
|
|
@@ -75,21 +79,33 @@ var FilterDropdown = function (props) {
|
|
|
75
79
|
}) })), jsxs("div", __assign({ className: "ztxk-table--filter__btn-container" }, { children: [jsxs(ButtonCom, __assign({ type: "primary", onClick: onSearchHand }, { children: ["\u641C\u7D22", jsx(Tooltip, __assign({ placement: "bottomLeft", title: "\u5BF9\u4E8E\u6570\u5B57\u5217\u53EF\u4EE5\u5C1D\u8BD5\u8F93\u5165\u4E00\u4E9B\u8868\u8FBE\u5F0F: $0 + 1 > 2\u3001 >= 10\u3001 $0 + 1 == 2" }, { children: jsx(QuestionCircleOutlined, {}) }))] })), jsx(ButtonCom, __assign({ onClick: onResetHand }, { children: "\u91CD\u7F6E" }))] }))] })));
|
|
76
80
|
};
|
|
77
81
|
// 获取数据
|
|
78
|
-
function getDataByKey(data,
|
|
82
|
+
function getDataByKey(data, options) {
|
|
83
|
+
var key = options.key, column = options.column;
|
|
79
84
|
if (!Array.isArray(data)) {
|
|
80
85
|
return [];
|
|
81
86
|
}
|
|
82
87
|
if (typeof key !== "string") {
|
|
83
88
|
return [];
|
|
84
89
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
// const newArr = data.map((item) => {
|
|
91
|
+
// return item[key] ?? "";
|
|
92
|
+
// });
|
|
93
|
+
// 将render中的结果作为字段返回
|
|
94
|
+
var newArr = data.map(function (item, itemIndex) {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
try {
|
|
97
|
+
var renderResult = (_a = column === null || column === void 0 ? void 0 : column.render) === null || _a === void 0 ? void 0 : _a.call(column, item[key], item, itemIndex);
|
|
98
|
+
if (typeof renderResult === "string") {
|
|
99
|
+
return renderResult;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (err) { }
|
|
103
|
+
return (_b = item[key]) !== null && _b !== void 0 ? _b : "";
|
|
88
104
|
});
|
|
89
105
|
// 记录出现次数
|
|
90
106
|
var resultArr = [];
|
|
91
107
|
newArr
|
|
92
|
-
.filter(function (item) { return item !== ""; })
|
|
108
|
+
.filter(function (item) { return item !== "" && typeof item !== "object"; })
|
|
93
109
|
.forEach(function (item) {
|
|
94
110
|
var index = resultArr.findIndex(function (i) { return i.value === item; });
|
|
95
111
|
if (index === -1) {
|
|
@@ -142,10 +158,24 @@ var isMessage = false;
|
|
|
142
158
|
* @param key 过滤的key
|
|
143
159
|
* @returns
|
|
144
160
|
*/
|
|
145
|
-
function filterHandle(value, record, key) {
|
|
161
|
+
function filterHandle(value, record, key, options) {
|
|
146
162
|
var _a, _b, _c, _d;
|
|
163
|
+
var _e = options || {}, column = _e.column, _f = _e.recordIndex, recordIndex = _f === void 0 ? 0 : _f;
|
|
147
164
|
var newValue = ((_b = (_a = value === null || value === void 0 ? void 0 : value.toString) === null || _a === void 0 ? void 0 : _a.call(value)) === null || _b === void 0 ? void 0 : _b.trim()) || null;
|
|
165
|
+
// const currentValue = record && key ? record[key] : null;
|
|
148
166
|
var currentValue = record && key ? record[key] : null;
|
|
167
|
+
if (column === null || column === void 0 ? void 0 : column.render) {
|
|
168
|
+
try {
|
|
169
|
+
var rel = column.render(currentValue, record, recordIndex);
|
|
170
|
+
if (typeof rel === "string") {
|
|
171
|
+
currentValue = rel;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
console.log(error);
|
|
176
|
+
currentValue = record && key ? record[key] : null;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
149
179
|
// 如果命中空值的话 能正常查出空值
|
|
150
180
|
if (newValue === NULL_SIGN &&
|
|
151
181
|
record &&
|
package/dist/es/table/hooks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __assign, __spreadArray } from '../_virtual/_tslib.js';
|
|
2
2
|
import { useCallback, useRef, useState, useEffect, useMemo } from 'react';
|
|
3
|
-
import { useMemoizedFn } from 'ahooks';
|
|
3
|
+
import { useMemoizedFn, useLatest } from 'ahooks';
|
|
4
4
|
import update from '../node_modules/immutability-helper/index.js';
|
|
5
5
|
import { getInnerIndex } from './useInnerPagination.js';
|
|
6
6
|
import { flattenRecordsOptimized } from './utils.js';
|
|
@@ -596,38 +596,52 @@ function useMergeAddAndDel(_a) {
|
|
|
596
596
|
/**
|
|
597
597
|
* 自定义处理过滤逻辑
|
|
598
598
|
*/
|
|
599
|
-
function useCustomFilter(dataSource) {
|
|
599
|
+
function useCustomFilter(dataSource, _newColumns) {
|
|
600
600
|
var _a = useState(), filterConfig = _a[0], setFilterConfig = _a[1];
|
|
601
|
+
var columnsRef = useLatest(_newColumns);
|
|
601
602
|
var newDataSource = useMemo(function () {
|
|
602
603
|
if (!filterConfig)
|
|
603
604
|
return dataSource;
|
|
604
|
-
return dataSource.filter(function (item) {
|
|
605
|
+
return dataSource.filter(function (item, index) {
|
|
606
|
+
var _a, _b;
|
|
605
607
|
var keys = Object.keys(filterConfig);
|
|
606
|
-
|
|
608
|
+
var _loop_1 = function (i) {
|
|
607
609
|
var key = keys[i];
|
|
610
|
+
var column = (_b = (_a = columnsRef.current) === null || _a === void 0 ? void 0 : _a.find) === null || _b === void 0 ? void 0 : _b.call(_a, function (col) { return (col === null || col === void 0 ? void 0 : col.key) === key || (col === null || col === void 0 ? void 0 : col.dataIndex) === key; });
|
|
608
611
|
var filter = filterConfig[key];
|
|
609
612
|
if (filter.input) {
|
|
610
|
-
if (!filterHandle(filter.input, item, key
|
|
611
|
-
|
|
613
|
+
if (!filterHandle(filter.input, item, key, {
|
|
614
|
+
column: column,
|
|
615
|
+
recordIndex: index,
|
|
616
|
+
})) {
|
|
617
|
+
return { value: false };
|
|
612
618
|
}
|
|
613
619
|
}
|
|
614
620
|
if (filter.checkbox && filter.checkbox.length > 0) {
|
|
615
621
|
var flag = false;
|
|
616
|
-
for (var
|
|
617
|
-
var value =
|
|
618
|
-
if (filterHandle(value, item, key
|
|
622
|
+
for (var _c = 0, _d = filter.checkbox; _c < _d.length; _c++) {
|
|
623
|
+
var value = _d[_c];
|
|
624
|
+
if (filterHandle(value, item, key, {
|
|
625
|
+
column: column,
|
|
626
|
+
recordIndex: index,
|
|
627
|
+
})) {
|
|
619
628
|
flag = true;
|
|
620
629
|
break;
|
|
621
630
|
}
|
|
622
631
|
}
|
|
623
632
|
if (!flag) {
|
|
624
|
-
return false;
|
|
633
|
+
return { value: false };
|
|
625
634
|
}
|
|
626
635
|
}
|
|
636
|
+
};
|
|
637
|
+
for (var i = 0; i < keys.length; i++) {
|
|
638
|
+
var state_1 = _loop_1(i);
|
|
639
|
+
if (typeof state_1 === "object")
|
|
640
|
+
return state_1.value;
|
|
627
641
|
}
|
|
628
642
|
return true;
|
|
629
643
|
});
|
|
630
|
-
}, [dataSource, filterConfig]);
|
|
644
|
+
}, [dataSource, filterConfig, columnsRef]);
|
|
631
645
|
var handleFilterConfigChange = useMemoizedFn(function (value) {
|
|
632
646
|
setFilterConfig(function (oldValue) {
|
|
633
647
|
return __assign(__assign({}, oldValue), value);
|
package/dist/es/table/table.js
CHANGED
|
@@ -133,7 +133,7 @@ var Table = function (props) {
|
|
|
133
133
|
filterConfigRef: filterConfigRef,
|
|
134
134
|
});
|
|
135
135
|
// 表格内部自定义处理过滤,不走antd内部
|
|
136
|
-
var _w = useCustomFilter(currentTableDataSource), filterDataSource = _w[0], handleFilterConfigChange = _w[1];
|
|
136
|
+
var _w = useCustomFilter(currentTableDataSource, columns), filterDataSource = _w[0], handleFilterConfigChange = _w[1];
|
|
137
137
|
// 处理列配置信息 得到新的列配置信息
|
|
138
138
|
var _x = useColumns(columns, {
|
|
139
139
|
// 动态列配置相关信息
|
|
@@ -138,7 +138,7 @@ function useColumns(columns, options) {
|
|
|
138
138
|
else {
|
|
139
139
|
onCurrentListChange === null || onCurrentListChange === void 0 ? void 0 : onCurrentListChange(newList);
|
|
140
140
|
}
|
|
141
|
-
} }));
|
|
141
|
+
}, column: _column }));
|
|
142
142
|
};
|
|
143
143
|
// 持久化
|
|
144
144
|
if (isRemeberFilter) {
|
|
@@ -152,7 +152,23 @@ function useColumns(columns, options) {
|
|
|
152
152
|
// 自动合并单元格的情况下,不进行内部过滤
|
|
153
153
|
if (!isAutoMerge) {
|
|
154
154
|
_column.onFilter = function (value, record) {
|
|
155
|
-
|
|
155
|
+
var _a;
|
|
156
|
+
// 根据record,取到表格数据的索引
|
|
157
|
+
var recordIndex = 0;
|
|
158
|
+
try {
|
|
159
|
+
recordIndex = (_a = dataSourceRef.current) === null || _a === void 0 ? void 0 : _a.findIndex(function (item) {
|
|
160
|
+
var key = typeof rowKey === "string" ? rowKey : rowKey === null || rowKey === void 0 ? void 0 : rowKey(item);
|
|
161
|
+
if (typeof key !== "string") {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
return item[key] === record[key];
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
catch (err) { }
|
|
168
|
+
return filterHandle(value, record, _key, {
|
|
169
|
+
column: _column,
|
|
170
|
+
recordIndex: recordIndex !== null && recordIndex !== void 0 ? recordIndex : 0,
|
|
171
|
+
});
|
|
156
172
|
};
|
|
157
173
|
}
|
|
158
174
|
_column.onFilterDropdownOpenChange = function (visible) {
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { __assign } from '../_virtual/_tslib.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
4
|
+
import ButtonCom from '../button/button.js';
|
|
5
|
+
import myMessage from '../message/index.js';
|
|
6
|
+
import { Dropdown } from 'antd';
|
|
7
|
+
import DownloadOutlined from '../node_modules/@ant-design/icons/es/icons/DownloadOutlined.js';
|
|
8
|
+
|
|
9
|
+
var DownFile = function (_a) {
|
|
10
|
+
var request = _a.request, tid = _a.tid, fileName = _a.fileName;
|
|
11
|
+
// 下载类型选择
|
|
12
|
+
var _b = useState([]), downloadTypeDict = _b[0], setDownloadTypeDict = _b[1];
|
|
13
|
+
var _c = useState(false), loading = _c[0], setLoading = _c[1];
|
|
14
|
+
// 获取下载类型字典
|
|
15
|
+
var getDownloadTypeDict = useCallback(function () {
|
|
16
|
+
return request === null || request === void 0 ? void 0 : request({
|
|
17
|
+
url: "/api/zmdms-system/dict/dictionary",
|
|
18
|
+
method: "GET",
|
|
19
|
+
params: {
|
|
20
|
+
code: "fy_file_type",
|
|
21
|
+
},
|
|
22
|
+
}).then(function (res) {
|
|
23
|
+
var _a;
|
|
24
|
+
if (res.status === 200 && res.data.data) {
|
|
25
|
+
setDownloadTypeDict((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.data);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}, [request]);
|
|
29
|
+
useEffect(function () {
|
|
30
|
+
getDownloadTypeDict();
|
|
31
|
+
}, [getDownloadTypeDict]);
|
|
32
|
+
var download = function (dType) {
|
|
33
|
+
setLoading(true);
|
|
34
|
+
request({
|
|
35
|
+
url: "/api/zmdms-resource/fanyi/download-trans-file",
|
|
36
|
+
method: "GET",
|
|
37
|
+
responseType: "blob",
|
|
38
|
+
params: {
|
|
39
|
+
dtype: dType,
|
|
40
|
+
tid: tid,
|
|
41
|
+
fileName: fileName,
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
.then(function (res) {
|
|
45
|
+
try {
|
|
46
|
+
var blob = new Blob([res.data], {
|
|
47
|
+
type: "application/vnd.ms-excel",
|
|
48
|
+
});
|
|
49
|
+
if (blob.size < 1) {
|
|
50
|
+
myMessage.warning("下载失败,下载的内容为空!");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
var aLink = document.createElement("a");
|
|
54
|
+
aLink.style.display = "none";
|
|
55
|
+
var href = window.URL.createObjectURL(blob);
|
|
56
|
+
aLink.href = href;
|
|
57
|
+
aLink.download = fileName;
|
|
58
|
+
document.body.appendChild(aLink);
|
|
59
|
+
aLink.click();
|
|
60
|
+
document.body.removeChild(aLink);
|
|
61
|
+
window.URL.revokeObjectURL(href);
|
|
62
|
+
return new File([blob], fileName);
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
console.error(err);
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
.catch(function (err) {
|
|
69
|
+
var _a, _b, _c;
|
|
70
|
+
console.log(err);
|
|
71
|
+
try {
|
|
72
|
+
var blobData = (_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
73
|
+
blobData
|
|
74
|
+
.text()
|
|
75
|
+
.then(function (data) {
|
|
76
|
+
var result = JSON.parse(data);
|
|
77
|
+
myMessage.error((result === null || result === void 0 ? void 0 : result.msg) || "接口调用失败!");
|
|
78
|
+
})
|
|
79
|
+
.catch(function () {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
myMessage.error(((_b = (_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || "接口调用失败!");
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
myMessage.error(((_c = (_b = err === null || err === void 0 ? void 0 : err.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.msg) || "接口调用失败!");
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
.finally(function () {
|
|
89
|
+
setLoading(false);
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
var items = downloadTypeDict.map(function (item) {
|
|
93
|
+
return {
|
|
94
|
+
label: (jsx("div", __assign({ onClick: function (e) {
|
|
95
|
+
download(item.dictKey);
|
|
96
|
+
} }, { children: item.dictValue }))),
|
|
97
|
+
value: item.dictKey,
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
return (jsx(Dropdown, __assign({ menu: { items: items }, placement: "bottomLeft" }, { children: jsx(ButtonCom, { type: "primary", shape: "circle", icon: jsx(DownloadOutlined, {}), size: "small", loading: loading }) })));
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export { DownFile as default };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { __assign } from '../_virtual/_tslib.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
import { createOriginalLink } from 'zmdms-utils';
|
|
5
|
+
import DownFile from './DownFile.js';
|
|
6
|
+
import '../config/ZtxkContext.js';
|
|
7
|
+
import useBaseContext from '../config/useBaseContext.js';
|
|
8
|
+
import '../config/MyStorage.js';
|
|
9
|
+
|
|
10
|
+
var PreviewFile = function () {
|
|
11
|
+
var _a = useBaseContext(), request = _a.request, fileBaseUrl = _a.fileBaseUrl;
|
|
12
|
+
var params = new URLSearchParams(window.location.search);
|
|
13
|
+
var oldId = params.get("oldId");
|
|
14
|
+
var tid = params.get("tid");
|
|
15
|
+
var fileName = decodeURIComponent(params.get("fileName") || "");
|
|
16
|
+
var _b = React__default.useState(""), translatedUrl = _b[0], setTranslatedUrl = _b[1];
|
|
17
|
+
var oldUrl = React__default.useMemo(function () {
|
|
18
|
+
if (oldId) {
|
|
19
|
+
return createOriginalLink(oldId, fileName, {
|
|
20
|
+
API_BASEURL: fileBaseUrl,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return "";
|
|
24
|
+
}, [oldId, fileName, fileBaseUrl]);
|
|
25
|
+
React__default.useEffect(function () {
|
|
26
|
+
if (tid) {
|
|
27
|
+
request({
|
|
28
|
+
url: "/api/zmdms-resource/fanyi/download-trans-file-id",
|
|
29
|
+
method: "get",
|
|
30
|
+
params: {
|
|
31
|
+
tid: tid,
|
|
32
|
+
dtype: 3,
|
|
33
|
+
fileName: fileName,
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
.then(function (res) {
|
|
37
|
+
setTranslatedUrl(createOriginalLink(res.data.data.attachId, res.data.data.originalName, {
|
|
38
|
+
API_BASEURL: fileBaseUrl,
|
|
39
|
+
}));
|
|
40
|
+
})
|
|
41
|
+
.catch(function (error) {
|
|
42
|
+
console.error("获取翻译文件失败:", error);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}, [tid, fileName, request, fileBaseUrl]);
|
|
46
|
+
return (jsxs("div", __assign({ style: {
|
|
47
|
+
display: "flex",
|
|
48
|
+
width: "100%",
|
|
49
|
+
height: "100vh",
|
|
50
|
+
justifyContent: "space-between",
|
|
51
|
+
overflow: "hidden",
|
|
52
|
+
} }, { children: [jsx("iframe", { style: { width: "100%", height: "100%", border: "2px solid #333" }, src: oldUrl, title: "原文档" }), jsx("div", { style: { width: "5px", height: "100px" } }), jsxs("div", __assign({ style: {
|
|
53
|
+
position: "relative",
|
|
54
|
+
width: "100%",
|
|
55
|
+
border: "2px solid #333",
|
|
56
|
+
} }, { children: [jsx("iframe", { style: { width: "100%", height: "100%" }, src: translatedUrl, title: "翻译文档" }), jsx("div", __assign({ style: {
|
|
57
|
+
position: "absolute",
|
|
58
|
+
right: "20px",
|
|
59
|
+
bottom: "50%",
|
|
60
|
+
} }, { children: jsx(DownFile, { request: request, tid: tid, fileName: fileName }) }))] }))] })));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export { PreviewFile as default };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
|
|
2
|
+
import { useState, useRef, useEffect } from 'react';
|
|
3
|
+
import myMessage from '../message/index.js';
|
|
4
|
+
|
|
5
|
+
function getTranslateProgress(request, currentTid) {
|
|
6
|
+
return request === null || request === void 0 ? void 0 : request({
|
|
7
|
+
url: "/api/zmdms-resource/fanyi/query-trans-progress/".concat(currentTid),
|
|
8
|
+
method: "GET",
|
|
9
|
+
}).then(function (res) {
|
|
10
|
+
var _a, _b, _c, _d, _e;
|
|
11
|
+
if (res.status === 200) {
|
|
12
|
+
var status_1 = (_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.status;
|
|
13
|
+
if (status_1 === 314) {
|
|
14
|
+
return Promise.resolve(__assign({ flag: true }, (_c = res === null || res === void 0 ? void 0 : res.data) === null || _c === void 0 ? void 0 : _c.data));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return Promise.resolve({
|
|
18
|
+
flag: false,
|
|
19
|
+
percent: Number((_e = (_d = res === null || res === void 0 ? void 0 : res.data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.percent),
|
|
20
|
+
});
|
|
21
|
+
}).catch(function (err) {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
myMessage.error(((_b = (_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || "接口调用失败!");
|
|
24
|
+
return Promise.reject(false);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function usePercent(_a) {
|
|
28
|
+
var _this = this;
|
|
29
|
+
var request = _a.request, currentTid = _a.currentTid, tid = _a.tid;
|
|
30
|
+
var _b = useState(0), percent = _b[0], setPercent = _b[1];
|
|
31
|
+
var _c = useState(false), pending = _c[0], setPending = _c[1];
|
|
32
|
+
var timerRef = useRef();
|
|
33
|
+
var requestRef = useRef(request);
|
|
34
|
+
requestRef.current = request;
|
|
35
|
+
var currentTidRef = useRef(currentTid);
|
|
36
|
+
currentTidRef.current = currentTid;
|
|
37
|
+
useEffect(function () {
|
|
38
|
+
return function () {
|
|
39
|
+
return clearTimeout(timerRef.current);
|
|
40
|
+
};
|
|
41
|
+
}, []);
|
|
42
|
+
useEffect(function () {
|
|
43
|
+
if (tid) {
|
|
44
|
+
handleTranslateProgress().then(function (isCompleted) {
|
|
45
|
+
if (!isCompleted) {
|
|
46
|
+
queryTranslateProgress();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
|
+
}, [tid]);
|
|
52
|
+
// 处理翻译进度结果
|
|
53
|
+
var handleTranslateProgress = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
54
|
+
var _a, flag, percent;
|
|
55
|
+
return __generator(this, function (_b) {
|
|
56
|
+
switch (_b.label) {
|
|
57
|
+
case 0: return [4 /*yield*/, getTranslateProgress(requestRef.current, currentTidRef.current)];
|
|
58
|
+
case 1:
|
|
59
|
+
_a = _b.sent(), flag = _a.flag, percent = _a.percent;
|
|
60
|
+
setPending(!flag);
|
|
61
|
+
setPercent(percent);
|
|
62
|
+
return [2 /*return*/, flag];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}); };
|
|
66
|
+
// 轮询翻译进度
|
|
67
|
+
var queryTranslateProgress = function () {
|
|
68
|
+
timerRef.current = setTimeout(function () {
|
|
69
|
+
handleTranslateProgress().then(function (isCompleted) {
|
|
70
|
+
if (!isCompleted) {
|
|
71
|
+
queryTranslateProgress();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}, 3000);
|
|
75
|
+
};
|
|
76
|
+
function startTranslate() {
|
|
77
|
+
setPercent(0);
|
|
78
|
+
setPending(true);
|
|
79
|
+
queryTranslateProgress();
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
startTranslate: startTranslate,
|
|
83
|
+
percent: percent,
|
|
84
|
+
isTranslating: pending,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { usePercent };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { ButtonProps } from 'antd/lib/button';
|
|
3
|
+
|
|
4
|
+
interface IProps extends ButtonProps {
|
|
5
|
+
/**
|
|
6
|
+
* 附件id 需要翻译的附件id
|
|
7
|
+
*/
|
|
8
|
+
attachId?: string;
|
|
9
|
+
/**
|
|
10
|
+
* 附件名 需要翻译的附件名
|
|
11
|
+
*/
|
|
12
|
+
attachName?: string;
|
|
13
|
+
/**
|
|
14
|
+
* 翻译后的任务ID 用来检测翻译是否完成 用来获取翻译后的文件
|
|
15
|
+
*/
|
|
16
|
+
tid?: string;
|
|
17
|
+
/**
|
|
18
|
+
* 开始翻译的其他参数
|
|
19
|
+
*/
|
|
20
|
+
translationParams?: any;
|
|
21
|
+
/**
|
|
22
|
+
* tid改变
|
|
23
|
+
*/
|
|
24
|
+
tidChange?: (tid: string) => void;
|
|
25
|
+
/**
|
|
26
|
+
* 文件预览路径
|
|
27
|
+
*/
|
|
28
|
+
previewUrl?: string;
|
|
29
|
+
}
|
|
30
|
+
declare const TranslationButton: React__default.FC<IProps>;
|
|
31
|
+
|
|
32
|
+
export { IProps, TranslationButton as default };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
|
+
import { unstable_batchedUpdates } from 'react-dom';
|
|
5
|
+
import { usePercent } from './hooks.js';
|
|
6
|
+
import '../config/ZtxkContext.js';
|
|
7
|
+
import useBaseContext from '../config/useBaseContext.js';
|
|
8
|
+
import '../config/MyStorage.js';
|
|
9
|
+
import { useMount } from 'ahooks';
|
|
10
|
+
import ButtonCom from '../button/button.js';
|
|
11
|
+
import myMessage from '../message/index.js';
|
|
12
|
+
import { Progress, Dropdown } from 'antd';
|
|
13
|
+
|
|
14
|
+
var translationTypeList = [
|
|
15
|
+
{ dictKey: "2", dictValue: "英文转中文" },
|
|
16
|
+
{ dictKey: "1", dictValue: "中文转英文" },
|
|
17
|
+
];
|
|
18
|
+
var TranslationButton = function (props) {
|
|
19
|
+
var _a = useBaseContext(), request = _a.request, translationPreviewRoute = _a.translationPreviewRoute;
|
|
20
|
+
var attachId = props.attachId, tid = props.tid, translationParams = props.translationParams, tidChange = props.tidChange, previewUrl = props.previewUrl;
|
|
21
|
+
var previewRoute = useMemo(function () {
|
|
22
|
+
return previewUrl || translationPreviewRoute || "";
|
|
23
|
+
}, [previewUrl, translationPreviewRoute]);
|
|
24
|
+
var _b = useState(), translationTid = _b[0], setTranslationTid = _b[1];
|
|
25
|
+
var _c = useState(false), loading = _c[0], setLoading = _c[1];
|
|
26
|
+
var _d = useState([]), libraryList = _d[0], setLibraryList = _d[1];
|
|
27
|
+
useMount(function () {
|
|
28
|
+
request({
|
|
29
|
+
url: "/api/zmdms-mdm-data/dict-biz/dictionary",
|
|
30
|
+
method: "GET",
|
|
31
|
+
params: { code: "zsk_term_library_id" },
|
|
32
|
+
}).then(function (res) {
|
|
33
|
+
if (res.status === 200 && res.data.code === 200) {
|
|
34
|
+
setLibraryList(res.data.data);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
var libraryMap = useMemo(function () {
|
|
39
|
+
return (libraryList || []).reduce(function (acc, item) {
|
|
40
|
+
acc[item.dictKey] = item.dictValue;
|
|
41
|
+
return acc;
|
|
42
|
+
}, {});
|
|
43
|
+
}, [libraryList]);
|
|
44
|
+
// 翻译状态 当没有tid的时候 是 开始状态 start
|
|
45
|
+
// 有tid的时候 调用接口判断是否 是翻译中 然后下载
|
|
46
|
+
var currentTid = useMemo(function () {
|
|
47
|
+
return translationTid || tid;
|
|
48
|
+
}, [translationTid, tid]);
|
|
49
|
+
var translationStatus = useMemo(function () {
|
|
50
|
+
return currentTid ? "pending" : "start";
|
|
51
|
+
}, [currentTid]);
|
|
52
|
+
var _e = usePercent({
|
|
53
|
+
currentTid: currentTid,
|
|
54
|
+
tid: tid,
|
|
55
|
+
request: request,
|
|
56
|
+
}), percent = _e.percent, isTranslating = _e.isTranslating, startTranslate = _e.startTranslate;
|
|
57
|
+
/**
|
|
58
|
+
* @param translationType 翻译转换规则
|
|
59
|
+
*/
|
|
60
|
+
var handleStartTranslation = function (translationType) {
|
|
61
|
+
var translationResultType = {
|
|
62
|
+
from: "zh",
|
|
63
|
+
to: "en",
|
|
64
|
+
};
|
|
65
|
+
switch (translationType) {
|
|
66
|
+
case "1":
|
|
67
|
+
translationResultType = {
|
|
68
|
+
from: "zh",
|
|
69
|
+
to: "en",
|
|
70
|
+
};
|
|
71
|
+
break;
|
|
72
|
+
case "2":
|
|
73
|
+
translationResultType = {
|
|
74
|
+
from: "en",
|
|
75
|
+
to: "zh",
|
|
76
|
+
};
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
setLoading(true);
|
|
80
|
+
// 翻译文件
|
|
81
|
+
request({
|
|
82
|
+
url: "/api/zmdms-resource/fanyi/upload-orgin-files",
|
|
83
|
+
method: "POST",
|
|
84
|
+
data: __assign(__assign({ attachId: attachId, bilingualControl: 0, termLibraryId: (translationParams === null || translationParams === void 0 ? void 0 : translationParams.termLibraryKey)
|
|
85
|
+
? libraryMap[translationParams === null || translationParams === void 0 ? void 0 : translationParams.termLibraryKey]
|
|
86
|
+
: libraryMap["DEFAULT"] }, translationParams), translationResultType),
|
|
87
|
+
})
|
|
88
|
+
.then(function (res) {
|
|
89
|
+
if (res.status === 200) {
|
|
90
|
+
unstable_batchedUpdates(function () {
|
|
91
|
+
var _a, _b, _c, _d;
|
|
92
|
+
setLoading(false);
|
|
93
|
+
setTranslationTid((_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.tid);
|
|
94
|
+
tidChange === null || tidChange === void 0 ? void 0 : tidChange((_d = (_c = res === null || res === void 0 ? void 0 : res.data) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.tid);
|
|
95
|
+
startTranslate();
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
setLoading(false);
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
.catch(function (err) {
|
|
103
|
+
var _a, _b;
|
|
104
|
+
myMessage.error(((_b = (_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || "接口调用失败!");
|
|
105
|
+
setLoading(false);
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
var handleDownloadTranslation = function () {
|
|
109
|
+
// 翻译前 先判断下是否翻译完成
|
|
110
|
+
setLoading(true);
|
|
111
|
+
if (currentTid) {
|
|
112
|
+
loopProgress();
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
myMessage.info("没有 找到任务id!");
|
|
116
|
+
setLoading(false);
|
|
117
|
+
}
|
|
118
|
+
function loopProgress() {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
+
var _a, flag, percent_1, title, docType, fileName;
|
|
121
|
+
return __generator(this, function (_b) {
|
|
122
|
+
switch (_b.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
_b.trys.push([0, 2, , 3]);
|
|
125
|
+
return [4 /*yield*/, getTranslateProgress()];
|
|
126
|
+
case 1:
|
|
127
|
+
_a = _b.sent(), flag = _a.flag, percent_1 = _a.percent, title = _a.title, docType = _a.docType;
|
|
128
|
+
if (flag) {
|
|
129
|
+
setLoading(false);
|
|
130
|
+
fileName = encodeURIComponent(title + "." + docType);
|
|
131
|
+
window.open("".concat(previewRoute, "?hideFrame=true&tid=").concat(currentTid, "&oldId=").concat(attachId, "&fileName=").concat(fileName));
|
|
132
|
+
// download(dType);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
myMessage.warning("\u5F53\u524D\u7FFB\u8BD1\u8FDB\u5EA6".concat(percent_1, "%"));
|
|
136
|
+
setLoading(false);
|
|
137
|
+
}
|
|
138
|
+
return [3 /*break*/, 3];
|
|
139
|
+
case 2:
|
|
140
|
+
_b.sent();
|
|
141
|
+
setLoading(false);
|
|
142
|
+
return [3 /*break*/, 3];
|
|
143
|
+
case 3: return [2 /*return*/];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function getTranslateProgress() {
|
|
149
|
+
return request === null || request === void 0 ? void 0 : request({
|
|
150
|
+
url: "/api/zmdms-resource/fanyi/query-trans-progress/".concat(currentTid),
|
|
151
|
+
method: "GET",
|
|
152
|
+
}).then(function (res) {
|
|
153
|
+
var _a, _b, _c, _d, _e;
|
|
154
|
+
if (res.status === 200) {
|
|
155
|
+
var status_1 = (_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.status;
|
|
156
|
+
if (status_1 === 314) {
|
|
157
|
+
return Promise.resolve(__assign({ flag: true }, (_c = res === null || res === void 0 ? void 0 : res.data) === null || _c === void 0 ? void 0 : _c.data));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return Promise.resolve({
|
|
161
|
+
flag: false,
|
|
162
|
+
percent: Number((_e = (_d = res === null || res === void 0 ? void 0 : res.data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.percent),
|
|
163
|
+
});
|
|
164
|
+
}).catch(function (err) {
|
|
165
|
+
var _a, _b;
|
|
166
|
+
myMessage.error(((_b = (_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || "接口调用失败!");
|
|
167
|
+
return Promise.reject(false);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
var renderTranslationDropdown = function (title) {
|
|
172
|
+
var items = translationTypeList.map(function (item) {
|
|
173
|
+
return {
|
|
174
|
+
label: (jsx("div", __assign({ onClick: function () { return handleStartTranslation(item.dictKey); } }, { children: item.dictValue }))),
|
|
175
|
+
key: item.dictKey,
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
return (jsx(Dropdown, __assign({ menu: { items: items }, trigger: ["click"], placement: "bottomLeft" }, { children: jsx(ButtonCom, __assign({ type: "link", loading: loading, style: { padding: "2px 6px" } }, { children: title })) })));
|
|
179
|
+
};
|
|
180
|
+
switch (translationStatus) {
|
|
181
|
+
case "start":
|
|
182
|
+
return renderTranslationDropdown("翻译文件");
|
|
183
|
+
case "pending":
|
|
184
|
+
return (jsxs(Fragment, { children: [jsx(ButtonCom, __assign({ type: "link", loading: loading, onClick: handleDownloadTranslation, disabled: isTranslating, style: { padding: "2px 6px" } }, { children: "查看译文" })), isTranslating && (jsx(Progress, { type: "circle", percent: percent, width: 35 })), !isTranslating && renderTranslationDropdown("重译")] }));
|
|
185
|
+
}
|
|
186
|
+
return jsx(Fragment, {});
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export { TranslationButton as default };
|
|
@@ -77,6 +77,10 @@ interface IUploadListProps extends Omit<UploadProps, "onChange"> {
|
|
|
77
77
|
* 预览前的校验(是否可以预览)
|
|
78
78
|
*/
|
|
79
79
|
onBeforePreviewValidate?: (files: IFileItem[]) => Promise<boolean>;
|
|
80
|
+
/**
|
|
81
|
+
* 是否需要翻译
|
|
82
|
+
*/
|
|
83
|
+
isTranslation?: boolean;
|
|
80
84
|
}
|
|
81
85
|
interface IFileItem {
|
|
82
86
|
/** 附件id */
|
|
@@ -14,6 +14,7 @@ import { toPreviewFile } from './utils.js';
|
|
|
14
14
|
import '../config/ZtxkContext.js';
|
|
15
15
|
import useBaseContext from '../config/useBaseContext.js';
|
|
16
16
|
import '../config/MyStorage.js';
|
|
17
|
+
import { getFinalValue } from '../config/utils.js';
|
|
17
18
|
import LoadingOutlined from '../node_modules/@ant-design/icons/es/icons/LoadingOutlined.js';
|
|
18
19
|
import ButtonCom from '../button/button.js';
|
|
19
20
|
import UploadOutlined from '../node_modules/@ant-design/icons/es/icons/UploadOutlined.js';
|
|
@@ -32,7 +33,10 @@ var MAXSIZE = 104857600; // 100 * 1024 * 1024
|
|
|
32
33
|
*/
|
|
33
34
|
var UploadList = function (props, ref) {
|
|
34
35
|
var _a;
|
|
35
|
-
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, 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"]);
|
|
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, 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"]);
|
|
37
|
+
var _k = useBaseContext(), apiBaseUrl = _k.apiBaseUrl, fileBaseUrl = _k.fileBaseUrl, enableTranslationButton = _k.enableTranslationButton;
|
|
38
|
+
// 翻译按钮是否显示
|
|
39
|
+
var isTranslationButton = getFinalValue(enableTranslationButton, isTranslation);
|
|
36
40
|
var maxCount = resetProps.maxCount, listType = resetProps.listType, method = resetProps.method;
|
|
37
41
|
var imgSizeClassName = "temporary-className-".concat(imgWidth, "-").concat(imgHeight);
|
|
38
42
|
var classes = classNames("ztxk-upload", className, (_a = {},
|
|
@@ -42,7 +46,7 @@ var UploadList = function (props, ref) {
|
|
|
42
46
|
var tableRef = useRef({});
|
|
43
47
|
var modalRef = useRef({});
|
|
44
48
|
var imgCropModalRef = useRef();
|
|
45
|
-
var
|
|
49
|
+
var _l = useState(), imgSrc = _l[0], setImgSrc = _l[1];
|
|
46
50
|
useEffect(function () {
|
|
47
51
|
if (!isImage) {
|
|
48
52
|
return;
|
|
@@ -60,7 +64,6 @@ var UploadList = function (props, ref) {
|
|
|
60
64
|
};
|
|
61
65
|
}, [imgHeight, imgSizeClassName, imgWidth, isImage]);
|
|
62
66
|
var newFieldNames = getField(fieldNames);
|
|
63
|
-
var _l = useBaseContext(), apiBaseUrl = _l.apiBaseUrl, fileBaseUrl = _l.fileBaseUrl;
|
|
64
67
|
var API_BASEURL = PROPS_API_BASEURL ? PROPS_API_BASEURL : apiBaseUrl;
|
|
65
68
|
var FILE_API_BASEURL = PROPS_FILE_API_BASEURL
|
|
66
69
|
? PROPS_FILE_API_BASEURL
|
|
@@ -390,7 +393,7 @@ var UploadList = function (props, ref) {
|
|
|
390
393
|
onClick: function (e) {
|
|
391
394
|
onBatchDownloadHandle(e.key);
|
|
392
395
|
},
|
|
393
|
-
}, placement: "bottomLeft" }, { children: jsx(ButtonCom, __assign({ type: "primary" }, { children: "\u6279\u91CF\u4E0B\u8F7D" })) }))) : null, customRenderBtn, showTable ? (jsx(UploadTable, { dataSource: uploadTableData, action: fileAction, headers: fileHeaders, data: fileData, method: method, setInnerFileList: setInnerFileList, isPublic: isPublic, API_BASEURL: API_BASEURL, FILE_API_BASEURL: FILE_API_BASEURL, maxPreviewSize: maxPreviewSize, isPreview: isPreview, filePreview: filePreview, isDelete: isDelete, isDownload: isDownload, ref: tableRef, listType: listType, tableColumns: tableColumns, onBeforeDeleteValidate: onBeforeDeleteValidate, onBeforeDownloadValidate: onBeforeDownloadValidate, onBeforePreviewValidate: onBeforePreviewValidate })) : null, isPreview && !showTable && !isImage ? (jsx(UploadListDetail, { dataSource: uploadTableData, action: fileAction, headers: fileHeaders, data: fileData, method: method, setInnerFileList: setInnerFileList, isPublic: isPublic, API_BASEURL: API_BASEURL, FILE_API_BASEURL: FILE_API_BASEURL, maxPreviewSize: maxPreviewSize, isPreview: isPreview, isDelete: isDelete, isDownload: isDownload, ref: tableRef, listType: listType, tableColumns: tableColumns, onBeforeDeleteValidate: onBeforeDeleteValidate, onBeforeDownloadValidate: onBeforeDownloadValidate, onBeforePreviewValidate: onBeforePreviewValidate })) : null, isImage && (jsx(ModalComponent, __assign({ ref: modalRef, footer: null, width: "520px" }, { children: jsx("div", __assign({ style: {
|
|
396
|
+
}, placement: "bottomLeft" }, { children: jsx(ButtonCom, __assign({ type: "primary" }, { children: "\u6279\u91CF\u4E0B\u8F7D" })) }))) : null, customRenderBtn, showTable ? (jsx(UploadTable, { dataSource: uploadTableData, action: fileAction, headers: fileHeaders, data: fileData, method: method, setInnerFileList: setInnerFileList, isPublic: isPublic, API_BASEURL: API_BASEURL, FILE_API_BASEURL: FILE_API_BASEURL, maxPreviewSize: maxPreviewSize, isPreview: isPreview, filePreview: filePreview, isDelete: isDelete, isDownload: isDownload, ref: tableRef, listType: listType, tableColumns: tableColumns, onBeforeDeleteValidate: onBeforeDeleteValidate, onBeforeDownloadValidate: onBeforeDownloadValidate, onBeforePreviewValidate: onBeforePreviewValidate, isTranslation: isTranslationButton })) : null, isPreview && !showTable && !isImage ? (jsx(UploadListDetail, { dataSource: uploadTableData, action: fileAction, headers: fileHeaders, data: fileData, method: method, setInnerFileList: setInnerFileList, isPublic: isPublic, API_BASEURL: API_BASEURL, FILE_API_BASEURL: FILE_API_BASEURL, maxPreviewSize: maxPreviewSize, isPreview: isPreview, isDelete: isDelete, isDownload: isDownload, ref: tableRef, listType: listType, tableColumns: tableColumns, onBeforeDeleteValidate: onBeforeDeleteValidate, onBeforeDownloadValidate: onBeforeDownloadValidate, onBeforePreviewValidate: onBeforePreviewValidate, isTranslation: isTranslationButton })) : null, isImage && (jsx(ModalComponent, __assign({ ref: modalRef, footer: null, width: "520px" }, { children: jsx("div", __assign({ style: {
|
|
394
397
|
textAlign: "center",
|
|
395
398
|
} }, { children: jsx("img", { src: imgSrc, alt: "\u9884\u89C8", style: {
|
|
396
399
|
maxWidth: "400px",
|
|
@@ -7,11 +7,12 @@ import ButtonCom from '../button/button.js';
|
|
|
7
7
|
import myMessage from '../message/index.js';
|
|
8
8
|
import LinkOutlined from '../node_modules/@ant-design/icons/es/icons/LinkOutlined.js';
|
|
9
9
|
import DownloadOutlined from '../node_modules/@ant-design/icons/es/icons/DownloadOutlined.js';
|
|
10
|
+
import TranslationButton from '../translationbutton/translationButton.js';
|
|
10
11
|
import { Spin } from 'antd';
|
|
11
12
|
|
|
12
13
|
var UploadTable = function (_a, ref) {
|
|
13
14
|
var _b;
|
|
14
|
-
var dataSource = _a.dataSource; _a.action; _a.headers; _a.data; _a.method; var setInnerFileList = _a.setInnerFileList, isPublic = _a.isPublic, _c = _a.API_BASEURL, API_BASEURL = _c === void 0 ? "" : _c, _d = _a.FILE_API_BASEURL, FILE_API_BASEURL = _d === void 0 ? "" : _d, maxPreviewSize = _a.maxPreviewSize, isPreview = _a.isPreview, isDelete = _a.isDelete, isDownload = _a.isDownload; _a.listType; _a.tableColumns; var onBeforeDownloadValidate = _a.onBeforeDownloadValidate, onBeforePreviewValidate = _a.onBeforePreviewValidate; _a.onBeforeDeleteValidate;
|
|
15
|
+
var dataSource = _a.dataSource; _a.action; _a.headers; _a.data; _a.method; var setInnerFileList = _a.setInnerFileList, isPublic = _a.isPublic, _c = _a.API_BASEURL, API_BASEURL = _c === void 0 ? "" : _c, _d = _a.FILE_API_BASEURL, FILE_API_BASEURL = _d === void 0 ? "" : _d, maxPreviewSize = _a.maxPreviewSize, isPreview = _a.isPreview, isDelete = _a.isDelete, isDownload = _a.isDownload; _a.listType; _a.tableColumns; var onBeforeDownloadValidate = _a.onBeforeDownloadValidate, onBeforePreviewValidate = _a.onBeforePreviewValidate; _a.onBeforeDeleteValidate; var isTranslation = _a.isTranslation;
|
|
15
16
|
var _e = useState(false), loading = _e[0], setLoading = _e[1];
|
|
16
17
|
var _f = useState(), checked = _f[0], setChecked = _f[1];
|
|
17
18
|
var isDownloadSingleBoolean = isDownload;
|
|
@@ -206,7 +207,7 @@ var UploadTable = function (_a, ref) {
|
|
|
206
207
|
}
|
|
207
208
|
myMessage.info("暂无预览权限!");
|
|
208
209
|
return Promise.resolve();
|
|
209
|
-
}, style: { textAlign: "left" }, title: record.attachName }, { children: [jsx(LinkOutlined, {}), record.attachName] })) })),
|
|
210
|
+
}, style: { textAlign: "left" }, title: record.attachName }, { children: [jsx(LinkOutlined, {}), record.attachName] })) })), jsxs("div", __assign({ className: "preview-list__item--right" }, { children: [isDownloadAuth ? (jsx(ButtonCom, __assign({ type: "link", onClick: function () { return operationCallback("download", record, index); }, style: { textAlign: "left" }, title: "\u4E0B\u8F7D" }, { children: jsx(DownloadOutlined, {}) }))) : null, isTranslation && (jsx(TranslationButton, { attachId: record.attachId, attachName: record.attachName }))] }))] }), record.attachId || record.fileId || index));
|
|
210
211
|
}) })) })));
|
|
211
212
|
};
|
|
212
213
|
var UploadListDetail = forwardRef(UploadTable);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __spreadArray, __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { forwardRef, useState, useMemo, useImperativeHandle } from 'react';
|
|
4
4
|
import MemoTable from '../table/table.js';
|
|
5
5
|
import { ETABLE_COLUMN_TYPE } from './interface.js';
|
|
@@ -9,11 +9,12 @@ import dayjs from 'dayjs';
|
|
|
9
9
|
import { toPreviewFile } from './utils.js';
|
|
10
10
|
import ButtonCom from '../button/button.js';
|
|
11
11
|
import OperationBtn from '../operationbtn/operationBtn.js';
|
|
12
|
+
import TranslationButton from '../translationbutton/translationButton.js';
|
|
12
13
|
import myMessage from '../message/index.js';
|
|
13
14
|
import { Progress } from 'antd';
|
|
14
15
|
|
|
15
16
|
var UploadTable = function (_a, ref) {
|
|
16
|
-
var dataSource = _a.dataSource, action = _a.action, headers = _a.headers, data = _a.data, method = _a.method, setInnerFileList = _a.setInnerFileList, isPublic = _a.isPublic, _b = _a.API_BASEURL, API_BASEURL = _b === void 0 ? "" : _b, _c = _a.FILE_API_BASEURL, FILE_API_BASEURL = _c === void 0 ? "" : _c, maxPreviewSize = _a.maxPreviewSize, isPreview = _a.isPreview, filePreview = _a.filePreview, isDelete = _a.isDelete, isDownload = _a.isDownload; _a.listType; var tableColumns = _a.tableColumns, onBeforeDownloadValidate = _a.onBeforeDownloadValidate, onBeforePreviewValidate = _a.onBeforePreviewValidate, onBeforeDeleteValidate = _a.onBeforeDeleteValidate;
|
|
17
|
+
var dataSource = _a.dataSource, action = _a.action, headers = _a.headers, data = _a.data, method = _a.method, setInnerFileList = _a.setInnerFileList, isPublic = _a.isPublic, _b = _a.API_BASEURL, API_BASEURL = _b === void 0 ? "" : _b, _c = _a.FILE_API_BASEURL, FILE_API_BASEURL = _c === void 0 ? "" : _c, maxPreviewSize = _a.maxPreviewSize, isPreview = _a.isPreview, filePreview = _a.filePreview, isDelete = _a.isDelete, isDownload = _a.isDownload; _a.listType; var tableColumns = _a.tableColumns, onBeforeDownloadValidate = _a.onBeforeDownloadValidate, onBeforePreviewValidate = _a.onBeforePreviewValidate, onBeforeDeleteValidate = _a.onBeforeDeleteValidate, isTranslation = _a.isTranslation;
|
|
17
18
|
var _d = useState(false), loading = _d[0], setLoading = _d[1];
|
|
18
19
|
var _e = useState(), checked = _e[0], setChecked = _e[1];
|
|
19
20
|
var isDownloadSingleBoolean = isDownload;
|
|
@@ -327,7 +328,14 @@ var UploadTable = function (_a, ref) {
|
|
|
327
328
|
});
|
|
328
329
|
}
|
|
329
330
|
}
|
|
330
|
-
|
|
331
|
+
var attachId = record.attachId, attachName = record.attachName, tid = record.tid;
|
|
332
|
+
return (jsxs(Fragment, { children: [jsx(OperationBtn, { statusBtnConfig: statusBtnConfig, callback: function (type) { return operationCallback(type, record, index); } }), isTranslation && (jsx(TranslationButton, { attachId: attachId, attachName: attachName, tid: tid, tidChange: function (tid) {
|
|
333
|
+
setInnerFileList(function (innerFileList) {
|
|
334
|
+
var newInnerFileList = innerFileList.slice();
|
|
335
|
+
newInnerFileList.splice(index, 1, __assign(__assign({}, record), { tid: tid }));
|
|
336
|
+
return newInnerFileList;
|
|
337
|
+
});
|
|
338
|
+
} }))] }));
|
|
331
339
|
};
|
|
332
340
|
// 重新上传
|
|
333
341
|
var onReloadUploadHandle = function (record, index) {
|
package/dist/index.build.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ export { default as ElectronSignatures } from './es/electronsignatures/index.js'
|
|
|
50
50
|
export { default as message } from './es/message/index.js';
|
|
51
51
|
export { default as CanvasTable } from './es/canvastable/canvasTable.js';
|
|
52
52
|
export { ICanvasColumnType, ICanvasColumnsType, ICanvasTableProps, ICanvasTableRefHandle } from './es/canvastable/interface.js';
|
|
53
|
+
export { default as TranslationButton } from './es/translationbutton/translationButton.js';
|
|
54
|
+
export { default as PreviewFile } from './es/translationbutton/PreviewFile.js';
|
|
53
55
|
export { Affix, Anchor, AutoComplete, Avatar, BackTop, Badge, Breadcrumb, Card, Carousel, Cascader, Checkbox, Col, Comment, ConfigProvider, Divider, Drawer, Dropdown, Empty, Grid, Image, Layout, List, Mentions, Menu, PageHeader, Popconfirm, Popover, Progress, Radio, Rate, Result, Row, Segmented, Skeleton, Slider, Space, Spin, Statistic, Steps, Switch, Timeline, Tooltip, Transfer, Typography, Upload, notification } from 'antd';
|
|
54
56
|
export { IButtonProps } from './es/button/interface.js';
|
|
55
57
|
export { IButtonDownloadProps } from './es/button/buttonDownload.js';
|
package/dist/index.es.js
CHANGED
|
@@ -44,6 +44,8 @@ export { default as Sortable } from './es/sortable/sortable.js';
|
|
|
44
44
|
export { default as ElectronSignatures } from './es/electronsignatures/index.js';
|
|
45
45
|
export { default as message } from './es/message/index.js';
|
|
46
46
|
export { default as CanvasTable } from './es/canvastable/canvasTable.js';
|
|
47
|
+
export { default as TranslationButton } from './es/translationbutton/translationButton.js';
|
|
48
|
+
export { default as PreviewFile } from './es/translationbutton/PreviewFile.js';
|
|
47
49
|
export { Affix, Anchor, AutoComplete, Avatar, BackTop, Badge, Breadcrumb, Card, Carousel, Cascader, Checkbox, Col, Comment, ConfigProvider, Divider, Drawer, Dropdown, Empty, Grid, Image, Layout, List, Mentions, Menu, PageHeader, Popconfirm, Popover, Progress, Radio, Rate, Result, Row, Segmented, Skeleton, Slider, Space, Spin, Statistic, Steps, Switch, Timeline, Tooltip, Transfer, Typography, Upload, notification } from 'antd';
|
|
48
50
|
export { default as Button } from './es/button/button.js';
|
|
49
51
|
export { default as Input } from './es/input/input.js';
|