zmdms-webui 0.0.49 → 0.0.51

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.
@@ -12,7 +12,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
12
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
13
  PERFORMANCE OF THIS SOFTWARE.
14
14
  ***************************************************************************** */
15
- /* global Reflect, Promise */
15
+ /* global Reflect, Promise, SuppressedError, Symbol */
16
16
 
17
17
  var extendStatics = function(d, b) {
18
18
  extendStatics = Object.setPrototypeOf ||
@@ -98,6 +98,11 @@ function __spreadArray(to, from, pack) {
98
98
  }
99
99
  }
100
100
  return to.concat(ar || Array.prototype.slice.call(from));
101
- }
101
+ }
102
+
103
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
104
+ var e = new Error(message);
105
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
106
+ };
102
107
 
103
108
  export { __assign, __awaiter, __extends, __generator, __rest, __spreadArray };
@@ -1,6 +1,7 @@
1
+ import * as React from 'react';
1
2
  import * as antd_es_calendar_generateCalendar from 'antd/es/calendar/generateCalendar';
2
3
  import { Dayjs } from 'dayjs';
3
4
 
4
- declare const Calendar: (props: antd_es_calendar_generateCalendar.CalendarProps<Dayjs>) => JSX.Element;
5
+ declare const Calendar: (props: antd_es_calendar_generateCalendar.CalendarProps<Dayjs>) => React.JSX.Element;
5
6
 
6
7
  export { Calendar as default };
@@ -22,10 +22,19 @@ declare const ContainerButtonWrap: React__default.FC<{
22
22
  children?: React__default.ReactNode;
23
23
  isMarginTop?: boolean;
24
24
  className?: string;
25
+ style?: React__default.CSSProperties;
26
+ }>;
27
+ declare const ContainerScrollWrap: React__default.FC<{
28
+ children?: React__default.ReactNode;
29
+ isMarginTop?: boolean;
30
+ className?: string;
31
+ style?: React__default.CSSProperties;
32
+ height?: string | number;
25
33
  }>;
26
34
  interface IContainerComponent extends React__default.FC<IProps> {
27
35
  displayName: string;
28
36
  ButtonWrap: typeof ContainerButtonWrap;
37
+ ScrollWrap: typeof ContainerScrollWrap;
29
38
  }
30
39
  declare const ContainerMemo: IContainerComponent;
31
40
 
@@ -22,14 +22,22 @@ var Container = function (props) {
22
22
  return (jsxs("div", __assign({ className: "ztxk-container", ref: containerRef }, { children: [leftContent && (jsx(LeftContent, __assign({ containerRef: containerRef, defaultLeftOpen: defaultLeftOpen, width: defaultLeftWidth }, { children: leftContent }))), jsx(ContainerLoading, { loading: loading }), jsx("div", __assign({ className: classes }, { children: children })), jsx(Footer, { footerDom: footerDom })] })));
23
23
  };
24
24
  var ContainerButtonWrap = memo(function (_a) {
25
- var children = _a.children, isMarginTop = _a.isMarginTop, className = _a.className;
25
+ var children = _a.children, isMarginTop = _a.isMarginTop, className = _a.className, style = _a.style;
26
26
  var classes = classNames("ztxk-container--btn-wrap", className, {
27
27
  "btn-wrap--margin-top": isMarginTop,
28
28
  });
29
- return jsx("div", __assign({ className: classes }, { children: children }));
29
+ return (jsx("div", __assign({ className: classes, style: style }, { children: children })));
30
+ });
31
+ var ContainerScrollWrap = memo(function (_a) {
32
+ var children = _a.children, isMarginTop = _a.isMarginTop, className = _a.className, style = _a.style, height = _a.height;
33
+ var classes = classNames("ztxk-container--scroll-wrap", className, {
34
+ "scroll-wrap--margin-top": isMarginTop,
35
+ });
36
+ return (jsx("div", __assign({ className: classes, style: __assign(__assign({}, style), { height: height }) }, { children: children })));
30
37
  });
31
38
  var ContainerMemo = memo(Container);
32
39
  ContainerMemo.displayName = "ZTXK_WEBUI_ContainerMemo";
33
- ContainerMemo.ButtonWrap = ContainerButtonWrap;
40
+ ContainerMemo.ButtonWrap = ContainerButtonWrap;
41
+ ContainerMemo.ScrollWrap = ContainerScrollWrap;
34
42
 
35
43
  export { ContainerMemo as default };
@@ -87,7 +87,7 @@ function getFormatter(formatterType, currencySymbol, isFocusRef, precision) {
87
87
  return {
88
88
  formatter: formatterFn,
89
89
  parser: parserFn,
90
- precision: MONEY_PRECISION,
90
+ precision: typeof precision === "number" ? precision : MONEY_PRECISION,
91
91
  };
92
92
  }
93
93
  if (formatterType === "percent") {
@@ -0,0 +1,15 @@
1
+ import _objectSpread2 from '../../../../@babel/runtime/helpers/esm/objectSpread2.js';
2
+ import * as React from 'react';
3
+ import DownloadOutlinedSvg from '../../../icons-svg/es/asn/DownloadOutlined.js';
4
+ import AntdIcon from '../components/AntdIcon.js';
5
+
6
+ var DownloadOutlined = function DownloadOutlined(props, ref) {
7
+ return /*#__PURE__*/React.createElement(AntdIcon, _objectSpread2(_objectSpread2({}, props), {}, {
8
+ ref: ref,
9
+ icon: DownloadOutlinedSvg
10
+ }));
11
+ };
12
+ DownloadOutlined.displayName = 'DownloadOutlined';
13
+ var DownloadOutlined$1 = /*#__PURE__*/React.forwardRef(DownloadOutlined);
14
+
15
+ export { DownloadOutlined$1 as default };
@@ -0,0 +1,15 @@
1
+ import _objectSpread2 from '../../../../@babel/runtime/helpers/esm/objectSpread2.js';
2
+ import * as React from 'react';
3
+ import LoadingOutlinedSvg from '../../../icons-svg/es/asn/LoadingOutlined.js';
4
+ import AntdIcon from '../components/AntdIcon.js';
5
+
6
+ var LoadingOutlined = function LoadingOutlined(props, ref) {
7
+ return /*#__PURE__*/React.createElement(AntdIcon, _objectSpread2(_objectSpread2({}, props), {}, {
8
+ ref: ref,
9
+ icon: LoadingOutlinedSvg
10
+ }));
11
+ };
12
+ LoadingOutlined.displayName = 'LoadingOutlined';
13
+ var LoadingOutlined$1 = /*#__PURE__*/React.forwardRef(LoadingOutlined);
14
+
15
+ export { LoadingOutlined$1 as default };
@@ -0,0 +1,5 @@
1
+ // This icon file is generated automatically.
2
+ var DownloadOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M505.7 661a8 8 0 0012.6 0l112-141.7c4.1-5.2.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z" } }] }, "name": "download", "theme": "outlined" };
3
+ var DownloadOutlinedSvg = DownloadOutlined;
4
+
5
+ export { DownloadOutlinedSvg as default };
@@ -0,0 +1,5 @@
1
+ // This icon file is generated automatically.
2
+ var LoadingOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "0 0 1024 1024", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z" } }] }, "name": "loading", "theme": "outlined" };
3
+ var LoadingOutlinedSvg = LoadingOutlined;
4
+
5
+ export { LoadingOutlinedSvg as default };
@@ -2,6 +2,7 @@ import canUseDom from './canUseDom.js';
2
2
  import contains from './contains.js';
3
3
 
4
4
  var APPEND_ORDER = 'data-rc-order';
5
+ var APPEND_PRIORITY = 'data-rc-priority';
5
6
  var MARK_KEY = "rc-util-key";
6
7
  var containerCache = new Map();
7
8
  function getMark() {
@@ -40,9 +41,16 @@ function injectCSS(css) {
40
41
  return null;
41
42
  }
42
43
  var csp = option.csp,
43
- prepend = option.prepend;
44
+ prepend = option.prepend,
45
+ _option$priority = option.priority,
46
+ priority = _option$priority === void 0 ? 0 : _option$priority;
47
+ var mergedOrder = getOrder(prepend);
48
+ var isPrependQueue = mergedOrder === 'prependQueue';
44
49
  var styleNode = document.createElement('style');
45
- styleNode.setAttribute(APPEND_ORDER, getOrder(prepend));
50
+ styleNode.setAttribute(APPEND_ORDER, mergedOrder);
51
+ if (isPrependQueue && priority) {
52
+ styleNode.setAttribute(APPEND_PRIORITY, "".concat(priority));
53
+ }
46
54
  if (csp !== null && csp !== void 0 && csp.nonce) {
47
55
  styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce;
48
56
  }
@@ -51,9 +59,16 @@ function injectCSS(css) {
51
59
  var firstChild = container.firstChild;
52
60
  if (prepend) {
53
61
  // If is queue `prepend`, it will prepend first style and then append rest style
54
- if (prepend === 'queue') {
62
+ if (isPrependQueue) {
55
63
  var existStyle = findStyles(container).filter(function (node) {
56
- return ['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER));
64
+ // Ignore style which not injected by rc-util with prepend
65
+ if (!['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER))) {
66
+ return false;
67
+ }
68
+
69
+ // Ignore style which priority less then new style
70
+ var nodePriority = Number(node.getAttribute(APPEND_PRIORITY) || 0);
71
+ return priority >= nodePriority;
57
72
  });
58
73
  if (existStyle.length) {
59
74
  container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);
@@ -1,8 +1,9 @@
1
1
  import { __rest, __assign } from '../../_virtual/_tslib.js';
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { useState } from 'react';
3
+ import { useState, useEffect } from 'react';
4
4
  import { useEditing, useIptRef, useTdRef } from './hooks.js';
5
5
  import { getInnerIndex } from '../useInnerPagination.js';
6
+ import { getFormatter } from '../../inputnumber/utils.js';
6
7
  import MemoInput from '../../input/input.js';
7
8
  import InputNumber from '../../inputnumber/inputNumber.js';
8
9
 
@@ -18,6 +19,11 @@ var EnhanceCell = function (props) {
18
19
  var iptRef = useIptRef(editing);
19
20
  // 单元格Ref
20
21
  var _c = useTdRef(), tdRef = _c.tdRef, removeErrorClass = _c.removeErrorClass;
22
+ var data = record === null || record === void 0 ? void 0 : record[dataIndex];
23
+ // 外部更新值时,需要取这个值
24
+ useEffect(function () {
25
+ setVal(data);
26
+ }, [data]);
21
27
  // 触发表格保存事件
22
28
  var onSave = function (info) {
23
29
  var _a;
@@ -31,8 +37,9 @@ var EnhanceCell = function (props) {
31
37
  if (editable) {
32
38
  var _d = editableConfig || {
33
39
  type: "input",
34
- }, type = _d.type, resetEditableConfigProps = __rest(_d, ["type"]);
40
+ }, type = _d.type, max = _d.max, min = _d.min, maxHandle = _d.maxHandle, minHandle = _d.minHandle, resetEditableConfigProps = __rest(_d, ["type", "max", "min", "maxHandle", "minHandle"]);
35
41
  var CurrentReactNode = null;
42
+ var newChildren = children;
36
43
  // 输入框处理
37
44
  if (type === "input") {
38
45
  CurrentReactNode = (jsx(MemoInput, __assign({ value: val, onChange: function (e) {
@@ -44,14 +51,40 @@ var EnhanceCell = function (props) {
44
51
  }
45
52
  // 数字输入框处理
46
53
  if (type === "inputNumber") {
54
+ var resultMax_1 = maxHandle ? maxHandle(record) : max;
55
+ var resultmin_1 = minHandle ? minHandle(record) : min;
47
56
  CurrentReactNode = (jsx(InputNumber, __assign({ value: val, onChange: function (value) {
48
- setVal(value);
57
+ if (typeof value === "number") {
58
+ if (typeof resultMax_1 === "number" && value > resultMax_1) {
59
+ setVal(resultMax_1);
60
+ }
61
+ else if (typeof resultmin_1 === "number" && value < resultmin_1) {
62
+ setVal(resultmin_1);
63
+ }
64
+ else {
65
+ setVal(value);
66
+ }
67
+ }
68
+ else {
69
+ setVal(value);
70
+ }
49
71
  if (isValidate) {
50
72
  removeErrorClass();
51
73
  }
52
74
  }, onPressEnter: onSave, onBlur: onSave, ref: iptRef }, resetEditableConfigProps)));
75
+ // 显示的时候 展示转换的值
76
+ try {
77
+ if (Array.isArray(newChildren)) {
78
+ var v = newChildren[1];
79
+ var result = getFormatter(resetEditableConfigProps.formatterType, resetEditableConfigProps.currencySymbol, { current: false }, resetEditableConfigProps.precision);
80
+ newChildren = result.formatter(v);
81
+ }
82
+ }
83
+ catch (err) {
84
+ console.error(err);
85
+ }
53
86
  }
54
- return (jsx("td", __assign({ ref: tdRef }, resetProps, { children: editing ? (jsx("div", __assign({ className: "ztxk-table__enhance-cell" }, { children: CurrentReactNode }))) : (jsx("div", __assign({ className: "ztxk-table__enhance-cell-wrap", onClick: toggleEdit }, { children: children }))) })));
87
+ return (jsx("td", __assign({ ref: tdRef }, resetProps, { children: editing ? (jsx("div", __assign({ className: "ztxk-table__enhance-cell" }, { children: CurrentReactNode }))) : (jsx("div", __assign({ className: "ztxk-table__enhance-cell-wrap", onClick: toggleEdit }, { children: newChildren }))) })));
55
88
  }
56
89
  return (jsx("td", __assign({ ref: tdRef }, resetProps, { children: children })));
57
90
  };
@@ -7,7 +7,7 @@ import CaretUpOutlined from '../../node_modules/@ant-design/icons/es/icons/Caret
7
7
  import CaretDownOutlined from '../../node_modules/@ant-design/icons/es/icons/CaretDownOutlined.js';
8
8
 
9
9
  var SortTitle = function (_a) {
10
- var title = _a.title, field = _a.field, onChange = _a.onChange, customOrder = _a.customOrder, setCustomOrder = _a.setCustomOrder;
10
+ var title = _a.title, field = _a.field, onChange = _a.onChange, customOrder = _a.customOrder, setCustomOrder = _a.setCustomOrder, align = _a.align, isStress = _a.isStress;
11
11
  var order = !customOrder
12
12
  ? null
13
13
  : (customOrder === null || customOrder === void 0 ? void 0 : customOrder.field) === field
@@ -42,7 +42,10 @@ var SortTitle = function (_a) {
42
42
  return "点击升序";
43
43
  }
44
44
  }, [order]);
45
- return (jsxs("div", __assign({ className: "ztxk-table--sorter" }, { children: [jsx("div", __assign({ className: "ztxk-table--sorter-title" }, { children: typeof title === "function" ? title({}) : title })), jsxs("div", __assign({ className: "ztxk-table--sorter-icon", onClick: handleSortClick, title: currentTitle }, { children: [jsx(CaretUpOutlined, { className: classNames("ant-table-column-sorter-up", {
45
+ var titleClassName = classNames("ztxk-table--sorter-title", {
46
+ "ztxk-table--title-stress": isStress,
47
+ });
48
+ return (jsxs("div", __assign({ className: "ztxk-table--sorter" }, { children: [jsx("div", __assign({ className: titleClassName, style: { textAlign: align } }, { children: typeof title === "function" ? title({}) : title })), jsxs("div", __assign({ className: "ztxk-table--sorter-icon", onClick: handleSortClick, title: currentTitle }, { children: [jsx(CaretUpOutlined, { className: classNames("ant-table-column-sorter-up", {
46
49
  active: order === ASCEND,
47
50
  }) }), jsx(CaretDownOutlined, { className: classNames("ant-table-column-sorter-down", {
48
51
  active: order === DESCEND,
@@ -0,0 +1,11 @@
1
+ import React__default from 'react';
2
+
3
+ interface IProps {
4
+ title?: string;
5
+ children?: React__default.ReactNode;
6
+ className?: string;
7
+ style?: React__default.CSSProperties;
8
+ }
9
+ declare const _default: React__default.NamedExoticComponent<IProps>;
10
+
11
+ export { _default as default };
@@ -0,0 +1,11 @@
1
+ import { __assign } from '../../_virtual/_tslib.js';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { memo } from 'react';
4
+
5
+ var TitleDirectionColumn = function (_a) {
6
+ var title = _a.title, children = _a.children, className = _a.className, style = _a.style;
7
+ return (jsxs("div", __assign({ className: className, style: __assign({ display: "flex", flexDirection: "column", flexGrow: 1 }, style) }, { children: [title, jsx("div", { children: children })] })));
8
+ };
9
+ var TitleDirectionColumn$1 = memo(TitleDirectionColumn);
10
+
11
+ export { TitleDirectionColumn$1 as default };
@@ -2,6 +2,7 @@ import { Table } from 'antd';
2
2
  import { TableProps, TablePaginationConfig, ColumnType } from 'antd/lib/table';
3
3
  import { IInputProps } from '../input/input.js';
4
4
  import { IInputNumberProps } from '../inputnumber/inputNumber.js';
5
+ import _default from './components/TitleDirectionColumn.js';
5
6
 
6
7
  type IEditableConfigOtherProps = IInputProps & IInputNumberProps;
7
8
  interface IEditableConfig extends Partial<IEditableConfigOtherProps> {
@@ -9,6 +10,14 @@ interface IEditableConfig extends Partial<IEditableConfigOtherProps> {
9
10
  * 列编辑类型
10
11
  */
11
12
  type: "input" | "inputNumber";
13
+ /**
14
+ * 最大值函数
15
+ */
16
+ maxHandle?: (record: any) => any;
17
+ /**
18
+ * 最大值函数
19
+ */
20
+ minHandle?: (record: any) => any;
12
21
  /**
13
22
  * 可以传入对应的input inputNumber的所有相关属性
14
23
  */
@@ -77,6 +86,15 @@ interface IColumnType<RecordType> extends ColumnType<RecordType> {
77
86
  * 是否开启自定义排序
78
87
  */
79
88
  isOrder?: boolean;
89
+ /**
90
+ * 是否强调字段
91
+ */
92
+ isStress?: boolean;
93
+ /**
94
+ * 动态列配置的title
95
+ * 当你传入的title是一个 组件时。组件再做动态列配置的时候,需要一个字符串的值,来充当动态列配置的title。这里可以传入一个字符串的值进来
96
+ */
97
+ dynamicTitle?: string;
80
98
  }
81
99
  interface IColumnGroupType<RecordType> extends Omit<IColumnType<RecordType>, "dataIndex"> {
82
100
  children: IColumnsType<RecordType>;
@@ -233,6 +251,7 @@ interface TableComponent<T> extends React.FC<ITableProps<T>> {
233
251
  Column: typeof Table.Column;
234
252
  ColumnGroup: typeof Table.ColumnGroup;
235
253
  Summary: typeof Table.Summary;
254
+ TitleDirectionColumn: typeof _default;
236
255
  }
237
256
  /**
238
257
  * 排序相关类型
@@ -16,6 +16,7 @@ import useInnerPagination, { getInnerIndex } from './useInnerPagination.js';
16
16
  import { useScuRfresh, useEditChange, useMoveRowChange, useAddAndDelChange, useCustomSort } from './hooks.js';
17
17
  import { HTML5Backend } from '../node_modules/react-dnd-html5-backend/dist/index.js';
18
18
  import useTableValidate, { tableValidate } from './useTableValidate.js';
19
+ import TitleDirectionColumn from './components/TitleDirectionColumn.js';
19
20
  import DynamicSetting from '../dynamicsetting/dynamicSetting.js';
20
21
  import { DndProvider } from '../node_modules/react-dnd/dist/core/DndProvider.js';
21
22
 
@@ -178,6 +179,7 @@ MemoTable.SELECTION_INVERT = Table$1.SELECTION_INVERT;
178
179
  MemoTable.SELECTION_NONE = Table$1.SELECTION_NONE;
179
180
  MemoTable.Column = Table$1.Column;
180
181
  MemoTable.ColumnGroup = Table$1.ColumnGroup;
181
- MemoTable.Summary = Table$1.Summary;
182
+ MemoTable.Summary = Table$1.Summary;
183
+ MemoTable.TitleDirectionColumn = TitleDirectionColumn;
182
184
 
183
185
  export { MemoTable as default };
@@ -18,29 +18,31 @@ function useColumns(columns, options) {
18
18
  var myNewColumns = [];
19
19
  if (Array.isArray(newColumns)) {
20
20
  newColumns.forEach(function (column) {
21
- var _a;
21
+ var _a, _b;
22
22
  var _column = __assign(__assign({}, column), { __title: column.title });
23
- var isCopy = _column.isCopy, editable = _column.editable, editableConfig = _column.editableConfig, title = _column.title, key = _column.key, validate = _column.validate, isRequire = _column.isRequire, isFillDown = _column.isFillDown, isOrder = _column.isOrder;
23
+ var isCopy = _column.isCopy, editable = _column.editable, editableConfig = _column.editableConfig, title = _column.title, key = _column.key, validate = _column.validate, isRequire = _column.isRequire, isFillDown = _column.isFillDown, isOrder = _column.isOrder, isStress = _column.isStress;
24
24
  var _key = key ? key : _column === null || _column === void 0 ? void 0 : _column.dataIndex;
25
25
  // 添加自定义排序
26
26
  if (isOrder) {
27
- _column.title = (jsx(SortTitle, { title: title, field: _key, onChange: customSortHandle, customOrder: order, setCustomOrder: setOrder }));
27
+ _column.title = (jsx(SortTitle, { title: title, field: _key, onChange: customSortHandle, customOrder: order, setCustomOrder: setOrder, align: _column.align, isStress: isStress }));
28
28
  }
29
29
  // 列头增加复制按钮
30
30
  // 列头增加往下填充
31
31
  if (isFillDown || isCopy) {
32
- _column.title = (jsx("div", __assign({ style: {
32
+ _column.title = (jsxs("div", __assign({ style: {
33
33
  display: "flex",
34
34
  alignItems: "center",
35
35
  justifyContent: "space-between",
36
36
  flex: "1",
37
- } }, { children: jsxs(Fragment, { children: [_column.title, jsx(TitleOperation, { copyKey: isCopy === true ? _key : isCopy, dataSourceRef: dataSourceRef, isFillDown: isFillDown, dataKey: _key, onTableChange: onTableChange })] }) })));
37
+ } }, { children: [jsx("div", __assign({ style: { flexGrow: 1, textAlign: _column.align }, className: isStress ? "ztxk-table--title-stress" : undefined }, { children: typeof _column.title === "function"
38
+ ? (_a = _column.title) === null || _a === void 0 ? void 0 : _a.call(_column, {})
39
+ : _column.title })), jsx(TitleOperation, { copyKey: isCopy === true ? _key : isCopy, dataSourceRef: dataSourceRef, isFillDown: isFillDown, dataKey: _key, onTableChange: onTableChange })] })));
38
40
  }
39
41
  // 列头增加必填标识
40
- if (isRequire) {
41
- _column.title = (jsxs("div", __assign({ style: { display: "flex", alignItems: "center" } }, { children: [jsx("i", __assign({ className: "ztxk-column--required" }, { children: "*" })), typeof _column.title === "function"
42
- ? (_a = _column.title) === null || _a === void 0 ? void 0 : _a.call(_column, {})
43
- : _column.title] })));
42
+ if (isRequire || isStress) {
43
+ _column.title = (jsxs("div", __assign({ style: { display: "flex", alignItems: "center" } }, { children: [isRequire ? jsx("i", __assign({ className: "ztxk-column--required" }, { children: "*" })) : null, jsx("div", __assign({ style: { flexGrow: 1 }, className: isStress ? "ztxk-table--title-stress" : undefined }, { children: typeof _column.title === "function"
44
+ ? (_b = _column.title) === null || _b === void 0 ? void 0 : _b.call(_column, {})
45
+ : _column.title }))] })));
44
46
  }
45
47
  // 如果列添加可编辑配置
46
48
  if (editable && isEdit) {
@@ -7,15 +7,20 @@ function getDynamicList(dynamicKey, columns) {
7
7
  var result = [];
8
8
  if (dynamicKey && columns) {
9
9
  columns.forEach(function (column) {
10
- var _a = column, key = _a.key, dataIndex = _a.dataIndex, title = _a.title, dynamicDisabled = _a.dynamicDisabled, fixed = _a.fixed;
10
+ var _a = column, key = _a.key, dataIndex = _a.dataIndex, title = _a.title, dynamicTitle = _a.dynamicTitle, dynamicDisabled = _a.dynamicDisabled, fixed = _a.fixed;
11
+ // 动态列配置 title必须为一个字符串
12
+ if (title && !dynamicTitle && typeof title !== "string") {
13
+ console.error("\u4F60\u4F20\u5165\u7684title\u4E0D\u662F\u4E00\u4E2A\u5B57\u7B26\u4E32,\u5E76\u4E14\u4F60\u6CA1\u6709\u4F20\u5165dynamicTitle\u7684\u914D\u7F6E\u3002\n \u95EE\u9898\u53EF\u80FD\u51FA\u73B0\u518D:".concat(key || dataIndex, " \u5217\u3002\u8BF7\u4F20\u5165\u4E00\u4E2AdynamicTitle \u4F5C\u4E3A\u52A8\u6001\u5217\u914D\u7F6E\u7684title\u503C"));
14
+ }
11
15
  if (!fixed) {
12
16
  // dataIndex 可能是 ['key1', 'key2'] 这种格式
13
17
  // 尽量避免使用这种模式 如果非得使用这种模式 那么请把key值传入
14
18
  var _key = key ? key : dataIndex;
15
19
  result.push({
16
20
  key: _key,
17
- label: title,
21
+ label: dynamicTitle ? dynamicTitle : title,
18
22
  disabled: dynamicDisabled === true ? true : false,
23
+ checked: true,
19
24
  });
20
25
  }
21
26
  });
@@ -34,6 +39,7 @@ function useDynamicListByColumns(columns, dynamicKey) {
34
39
  return getCurrentDynamicItems(dynamicKey, TABLE_DYNAMIC_KEY, defaultDynamicList);
35
40
  }), currentDynamicList = _a[0], setCurrentDynamicList = _a[1];
36
41
  var onCurrentListChange = useCallback(function (newDynamicList) {
42
+ console.log(newDynamicList);
37
43
  setCurrentDynamicList(newDynamicList);
38
44
  }, []);
39
45
  return {
@@ -41,6 +41,8 @@ interface IUploadListProps extends Omit<UploadProps, "onChange"> {
41
41
  zipName?: string;
42
42
  /** 是否只上传图片 */
43
43
  isImage?: boolean;
44
+ /** 自定义按钮 */
45
+ customRenderBtn?: React.ReactNode;
44
46
  }
45
47
  interface UploadListComponent extends React.ForwardRefExoticComponent<IUploadListProps & React.RefAttributes<unknown>> {
46
48
  Dragger: typeof Upload.Dragger;
@@ -1,12 +1,16 @@
1
1
  import { __rest, __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
- import { memo, forwardRef, useRef, useState, useImperativeHandle } from 'react';
3
+ import { memo, forwardRef, useRef, useState, useMemo, useImperativeHandle } from 'react';
4
4
  import { Upload, Popconfirm, Dropdown, message } from 'antd';
5
5
  import UploadTable from './uploadTable.js';
6
6
  import classNames from '../node_modules/classnames/index.js';
7
7
  import { formatUnit, createDownloadLink, downloadFile, batchDownloadFiles } from 'zmdms-utils';
8
8
  import ImgCrop from '../node_modules/antd-img-crop/dist/antd-img-crop.esm.js';
9
9
  import { useBeforeUpload, useOnChange, useBasicInfo, useUploadTableData } from './hooks.js';
10
+ import { MAX_PREVIEW_SIZE } from '../config/constant.js';
11
+ import { toPreviewFile } from './utils.js';
12
+ import LoadingOutlined from '../node_modules/@ant-design/icons/es/icons/LoadingOutlined.js';
13
+ import DownloadOutlined from '../node_modules/@ant-design/icons/es/icons/DownloadOutlined.js';
10
14
  import ButtonCom from '../button/button.js';
11
15
  import UploadOutlined from '../node_modules/@ant-design/icons/es/icons/UploadOutlined.js';
12
16
  import ModalComponent from '../modal/modal.js';
@@ -21,13 +25,13 @@ var MAXSIZE = 104857600; // 100 * 1024 * 1024
21
25
  * 附件大小 attachSize
22
26
  */
23
27
  var UploadList = function (props, ref) {
24
- var children = props.children, btnText = props.btnText, className = props.className, _a = props.showTip, showTip = _a === void 0 ? true : _a, _b = props.maxSize, maxSize = _b === void 0 ? MAXSIZE : _b, showTable = props.showTable, acceptList = props.acceptList, beforeUpload = props.beforeUpload, onChange = props.onChange, _c = props.API_BASEURL, API_BASEURL = _c === void 0 ? "" : _c, _d = props.FILE_API_BASEURL, FILE_API_BASEURL = _d === void 0 ? "" : _d, action = props.action, headers = props.headers, data = props.data, userName = props.userName, fileList = props.fileList, isPublic = props.isPublic, maxPreviewSize = props.maxPreviewSize, isPreview = props.isPreview, isDownload = props.isDownload, isDelete = props.isDelete, _e = props.zipName, zipName = _e === void 0 ? "\u6279\u91CF\u4E0B\u8F7D-".concat(Date.now(), ".zip") : _e, isImage = props.isImage, 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", "zipName", "isImage"]);
28
+ var children = props.children, btnText = props.btnText, className = props.className, _a = props.showTip, showTip = _a === void 0 ? true : _a, _b = props.maxSize, maxSize = _b === void 0 ? MAXSIZE : _b, showTable = props.showTable, acceptList = props.acceptList, beforeUpload = props.beforeUpload, onChange = props.onChange, _c = props.API_BASEURL, API_BASEURL = _c === void 0 ? "" : _c, _d = props.FILE_API_BASEURL, FILE_API_BASEURL = _d === void 0 ? "" : _d, action = props.action, headers = props.headers, data = props.data, userName = props.userName, fileList = props.fileList, isPublic = props.isPublic, _e = props.maxPreviewSize, maxPreviewSize = _e === void 0 ? MAX_PREVIEW_SIZE : _e, isPreview = props.isPreview, isDownload = props.isDownload, isDelete = props.isDelete, _f = props.zipName, zipName = _f === void 0 ? "\u6279\u91CF\u4E0B\u8F7D-".concat(Date.now(), ".zip") : _f, isImage = props.isImage, customRenderBtn = props.customRenderBtn, 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", "zipName", "isImage", "customRenderBtn"]);
25
29
  var maxCount = resetProps.maxCount, listType = resetProps.listType, method = resetProps.method;
26
30
  var classes = classNames("ztxk-upload", className, {});
27
31
  var maxSizeStr = formatUnit(maxSize);
28
32
  var tableRef = useRef({});
29
33
  var modalRef = useRef({});
30
- var _f = useState(), imgSrc = _f[0], setImgSrc = _f[1];
34
+ var _g = useState(), imgSrc = _g[0], setImgSrc = _g[1];
31
35
  // 文件上传前的判断处理
32
36
  var beforeUploadHandle = useBeforeUpload({
33
37
  acceptList: acceptList,
@@ -37,19 +41,19 @@ var UploadList = function (props, ref) {
37
41
  isImage: isImage,
38
42
  });
39
43
  // 文件改变逻辑
40
- var _g = useOnChange({
44
+ var _h = useOnChange({
41
45
  onChange: onChange,
42
46
  userName: userName,
43
47
  fileList: fileList,
44
- }), onChangeHandle = _g.onChangeHandle, innerFileList = _g.innerFileList, setInnerFileList = _g.setInnerFileList;
48
+ }), onChangeHandle = _h.onChangeHandle, innerFileList = _h.innerFileList, setInnerFileList = _h.setInnerFileList;
45
49
  // 基础参数
46
- var _h = useBasicInfo({
50
+ var _j = useBasicInfo({
47
51
  action: action,
48
52
  API_BASEURL: API_BASEURL,
49
53
  headers: headers,
50
54
  data: data,
51
55
  isPublic: isPublic,
52
- }), fileAction = _h.fileAction, fileHeaders = _h.fileHeaders, fileData = _h.fileData;
56
+ }), fileAction = _j.fileAction, fileHeaders = _j.fileHeaders, fileData = _j.fileData;
53
57
  // 表格需要的附件列表数据
54
58
  var uploadTableData = useUploadTableData({
55
59
  fileList: innerFileList,
@@ -122,15 +126,86 @@ var UploadList = function (props, ref) {
122
126
  }); };
123
127
  // 图片预览
124
128
  var onPreview = function (file) {
125
- var url = createDownloadLink(file.attachId, {
126
- API_BASEURL: API_BASEURL,
127
- open: isPublic,
129
+ if (isImage) {
130
+ var url = createDownloadLink(file.attachId, {
131
+ API_BASEURL: API_BASEURL,
132
+ open: isPublic,
133
+ });
134
+ setImgSrc(url);
135
+ modalRef.current.open();
136
+ }
137
+ else {
138
+ toPreviewFile(file, {
139
+ maxPreviewSize: maxPreviewSize,
140
+ FILE_API_BASEURL: FILE_API_BASEURL,
141
+ uploadTableData: uploadTableData,
142
+ });
143
+ }
144
+ };
145
+ // 图片下载
146
+ var onDownload = function (file) {
147
+ return __awaiter(void 0, void 0, void 0, function () {
148
+ var endCallback, err_2;
149
+ return __generator(this, function (_a) {
150
+ switch (_a.label) {
151
+ case 0:
152
+ // 判断当前附件是否处于加载状态
153
+ if (file.loading) {
154
+ return [2 /*return*/];
155
+ }
156
+ setInnerFileList(function (innerFileList) {
157
+ var newInnerFileList = innerFileList.slice();
158
+ var index = newInnerFileList.findIndex(function (i) { return i.attachId === file.attachId; });
159
+ var record = newInnerFileList[index];
160
+ newInnerFileList.splice(index, 1, __assign(__assign({}, record), { loading: true }));
161
+ return newInnerFileList;
162
+ });
163
+ endCallback = function () {
164
+ setInnerFileList(function (innerFileList) {
165
+ var newInnerFileList = innerFileList.slice();
166
+ var index = newInnerFileList.findIndex(function (i) { return i.attachId === file.attachId; });
167
+ var record = newInnerFileList[index];
168
+ newInnerFileList.splice(index, 1, __assign(__assign({}, record), { loading: false }));
169
+ return newInnerFileList;
170
+ });
171
+ };
172
+ _a.label = 1;
173
+ case 1:
174
+ _a.trys.push([1, 3, , 4]);
175
+ return [4 /*yield*/, downloadFile(file.attachId, file.attachName, {
176
+ API_BASEURL: API_BASEURL,
177
+ open: isPublic,
178
+ })];
179
+ case 2:
180
+ _a.sent();
181
+ endCallback();
182
+ return [3 /*break*/, 4];
183
+ case 3:
184
+ err_2 = _a.sent();
185
+ console.log(err_2);
186
+ endCallback();
187
+ return [3 /*break*/, 4];
188
+ case 4: return [2 /*return*/];
189
+ }
190
+ });
128
191
  });
129
- setImgSrc(url);
130
- modalRef.current.open();
131
192
  };
193
+ var showUploadListMemo = useMemo(function () {
194
+ return showTable
195
+ ? false
196
+ : {
197
+ showPreviewIcon: true,
198
+ showRemoveIcon: !!isDelete,
199
+ showDownloadIcon: !!isDownload,
200
+ downloadIcon: !!isDownload
201
+ ? function (file) {
202
+ return (file === null || file === void 0 ? void 0 : file.loading) ? (jsx(LoadingOutlined, {})) : (jsx(DownloadOutlined, {}));
203
+ }
204
+ : undefined,
205
+ };
206
+ }, [showTable, isDownload, isDelete]);
132
207
  // 上传子元素
133
- var renderChildren = (jsx(Upload, __assign({ showUploadList: false, multiple: true, beforeUpload: beforeUploadHandle, onChange: onChangeHandle, action: fileAction, headers: fileHeaders, data: fileData, fileList: innerFileList, onPreview: onPreview }, resetProps, { children: children ? (children) : !listType || listType === "text" ? (jsxs(ButtonCom, __assign({ type: "primary", icon: jsx(UploadOutlined, {}) }, { children: [btnText || "添加附件", maxCount ? "(\u6700\u591A\u4E0A\u4F20".concat(maxCount, "\u4E2A\u6587\u4EF6)") : ""] }))) : isImage &&
208
+ var renderChildren = (jsx(Upload, __assign({ showUploadList: showUploadListMemo, multiple: true, beforeUpload: beforeUploadHandle, onChange: onChangeHandle, action: fileAction, headers: fileHeaders, data: fileData, fileList: innerFileList, onPreview: onPreview, onDownload: onDownload }, resetProps, { children: children ? (children) : !listType || listType === "text" ? (jsxs(ButtonCom, __assign({ type: "primary", icon: jsx(UploadOutlined, {}) }, { children: [btnText || "添加附件", maxCount ? "(\u6700\u591A\u4E0A\u4F20".concat(maxCount, "\u4E2A\u6587\u4EF6)") : ""] }))) : isImage &&
134
209
  maxCount &&
135
210
  innerFileList &&
136
211
  innerFileList.length >= maxCount ? null : (jsxs("div", __assign({ className: "ztxk-upload--picture" }, { children: [jsx(UploadOutlined, { style: { fontSize: 18 } }), jsx("div", __assign({ style: { marginTop: 8 } }, { children: btnText || "添加图片" }))] }))) })));
@@ -163,7 +238,7 @@ var UploadList = function (props, ref) {
163
238
  onClick: function (e) {
164
239
  onBatchDownloadHandle(e.key);
165
240
  },
166
- }, placement: "bottomLeft" }, { children: jsx(ButtonCom, __assign({ type: "primary" }, { children: "\u6279\u91CF\u4E0B\u8F7D" })) }))) : null, 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, isDelete: isDelete, isDownload: isDownload, ref: tableRef })) : null, isImage && (jsx(ModalComponent, __assign({ ref: modalRef, footer: null, width: "520px" }, { children: jsx("div", __assign({ style: {
241
+ }, 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, isDelete: isDelete, isDownload: isDownload, ref: tableRef })) : null, isImage && (jsx(ModalComponent, __assign({ ref: modalRef, footer: null, width: "520px" }, { children: jsx("div", __assign({ style: {
167
242
  textAlign: "center",
168
243
  } }, { children: jsx("img", { src: imgSrc, alt: "\u9884\u89C8", style: {
169
244
  maxWidth: "400px",