ztxkui 4.2.0 → 4.2.2

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.
@@ -1,7 +1,7 @@
1
1
  import InputNumber from 'components/InputNumber';
2
2
  import Tag from 'components/Tag';
3
3
  import Input from 'components/Input';
4
- import { FormList, RangePicker, Button, Modal, Container, message, } from '../index';
4
+ import { FormList, RangePicker, Button, Modal, Container, message, NumberCase, } from '../index';
5
5
  // import message from '../components/basic/message';
6
6
  import { InputNumber as AntInputNumber } from 'antd';
7
7
  import { CloseCircleOutlined } from '@ant-design/icons';
@@ -188,6 +188,9 @@ function BasicDemo() {
188
188
  console.log(iValue);
189
189
  }, showCopy: true }, "\u6211\u662F\u4E00\u4E2A\u94FE\u63A51111111111111111111"),
190
190
  React.createElement(Input, { value: iValue, onChange: function (e) { return setIValue(e.target.value); } }),
191
- React.createElement(Input.TextArea, { handleSize: true, rows: 3 })));
191
+ React.createElement(Input.TextArea, { handleSize: true, rows: 3 }),
192
+ React.createElement("div", null,
193
+ React.createElement(NumberCase, { num: 123123123 }, "12312312312"),
194
+ React.createElement(NumberCase, { num: 123123123 }, "12312312312"))));
192
195
  }
193
196
  export default BasicDemo;
@@ -81,6 +81,30 @@ var test = {
81
81
  isWatermark: 0,
82
82
  isElectronicSeal: 0,
83
83
  },
84
+ {
85
+ attachId: '7079304674563981473',
86
+ attachName: '260930039_640_640.jpg',
87
+ attachTypeName: null,
88
+ isCustomerReference: null,
89
+ templateAttachId: null,
90
+ templateAttachName: null,
91
+ templateCrNo: null,
92
+ taskId: null,
93
+ isWatermark: 0,
94
+ isElectronicSeal: 0,
95
+ },
96
+ {
97
+ attachId: '7079304674563981470',
98
+ attachName: '260930040_640_640.jpg',
99
+ attachTypeName: null,
100
+ isCustomerReference: null,
101
+ templateAttachId: null,
102
+ templateAttachName: null,
103
+ templateCrNo: null,
104
+ taskId: null,
105
+ isWatermark: 0,
106
+ isElectronicSeal: 0,
107
+ },
84
108
  {
85
109
  attachId: '1590543945628586394',
86
110
  attachName: '心量于里两222.pdf',
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @author 陈亚雄
3
+ * @description 数字转大写
4
+ */
5
+ import React from 'react';
6
+ interface IProps {
7
+ /** 需要转换大写的金额 */
8
+ num: number;
9
+ }
10
+ declare const NumberCase: React.FC<IProps>;
11
+ export default NumberCase;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @author 陈亚雄
3
+ * @description 数字转大写
4
+ */
5
+ import React from 'react';
6
+ // redux
7
+ // ztxkui公共组件
8
+ import { Tooltip } from '../../index';
9
+ // 路由配置
10
+ // store
11
+ // 自定义组件
12
+ // 其他文件
13
+ function numberToCase(n) {
14
+ if (!/^(0|[1-9]\d*)(\.\d+)?$/.test(n)) {
15
+ return '数据非法'; //判断数据是否大于0
16
+ }
17
+ var unit = '千百拾亿千百拾万千百拾元角分', str = '';
18
+ n += '00';
19
+ var indexpoint = n.indexOf('.'); // 如果是小数,截取小数点前面的位数
20
+ if (indexpoint >= 0) {
21
+ n = n.substring(0, indexpoint) + n.substr(indexpoint + 1, 2); // 若为小数,截取需要使用的unit单位
22
+ }
23
+ unit = unit.substr(unit.length - n.length); // 若为整数,截取需要使用的unit单位
24
+ for (var i = 0; i < n.length; i++) {
25
+ str += '零壹贰叁肆伍陆柒捌玖'.charAt(n.charAt(i)) + unit.charAt(i); //遍历转化为大写的数字
26
+ }
27
+ return str
28
+ .replace(/零(千|百|拾|角)/g, '零')
29
+ .replace(/(零)+/g, '零')
30
+ .replace(/零(万|亿|元)/g, '$1')
31
+ .replace(/(亿)万|壹(拾)/g, '$1$2')
32
+ .replace(/^元零?|零分/g, '')
33
+ .replace(/元$/g, '元整'); // 替换掉数字里面的零字符,得到结果
34
+ }
35
+ var NumberCase = function (_a) {
36
+ var num = _a.num, children = _a.children;
37
+ return React.createElement(Tooltip, { title: numberToCase(num) }, children);
38
+ };
39
+ export default NumberCase;
@@ -66,9 +66,10 @@ import { Button, Progress, message, Popconfirm } from '../../index';
66
66
  import Table from '../Table';
67
67
  import dayjs from 'dayjs';
68
68
  import { divide, round, times } from 'number-precision';
69
- import { downloadFileCallBack, downloadPublicFile, previewFile, } from 'ztxkutils/dist/fileOperation';
69
+ import { downloadFileCallBack, downloadPublicFile, previewFile, batchPreviewFile, } from 'ztxkutils/dist/fileOperation';
70
70
  import { transformFileSize, dangerouslySetXss } from 'ztxkutils/dist/tools';
71
71
  import { MAX_PREVIEW_FILE_SIZE } from '../utils/constants';
72
+ import { isImage } from '../utils/upload';
72
73
  var UploadTable = function (_a) {
73
74
  var fileList = _a.fileList, action = _a.action, headers = _a.headers, authToken = _a.authToken, method = _a.method, apiBaseUrl = _a.apiBaseUrl, uploadUser = _a.uploadUser, _b = _a.fileBaseUrl, fileBaseUrl = _b === void 0 ? '' : _b, onDelete = _a.onDelete, onUpload = _a.onUpload, showDeleteBtn = _a.showDeleteBtn, isAutoDelete = _a.isAutoDelete, onDownLoadCallbackBefore = _a.onDownLoadCallbackBefore, showDownloadBtn = _a.showDownloadBtn, onDownLoadCallbackAfter = _a.onDownLoadCallbackAfter, onPreviewCallbackBefore = _a.onPreviewCallbackBefore, showPreviewBtn = _a.showPreviewBtn, isPublic = _a.isPublic, data = _a.data, _c = _a.startColumns, startColumns = _c === void 0 ? [] : _c, _d = _a.otherColumns, otherColumns = _d === void 0 ? [] : _d, showUploadBtn = _a.showUploadBtn, rowSelection = _a.rowSelection, uploadTableRef = _a.uploadTableRef, tableRestProps = _a.tableRestProps, privateTableRef = _a.privateTableRef;
74
75
  var _e = useState([]), dataSource = _e[0], setDataSource = _e[1];
@@ -91,6 +92,37 @@ var UploadTable = function (_a) {
91
92
  }
92
93
  },
93
94
  }); }, [selectedRows, rowSelection]);
95
+ var previewBtn = function (previewTitle, previewOptions) {
96
+ var record = previewOptions.record, dataSource = previewOptions.dataSource;
97
+ return (React.createElement(Button, { type: "link", style: {
98
+ height: 28,
99
+ }, onClick: function () {
100
+ // 实现批量预览,只针对图片
101
+ var result = isImage(record.fileName);
102
+ if (result) {
103
+ var allImage = dataSource
104
+ .filter(function (item) {
105
+ return isImage(item.fileName) && item.fileId !== record.fileId;
106
+ })
107
+ .map(function (item) { return item.fileId; });
108
+ batchPreviewFile(fileBaseUrl, record.fileId + "," + allImage, {
109
+ titleName: record === null || record === void 0 ? void 0 : record.fileName,
110
+ authToken: authToken,
111
+ });
112
+ return;
113
+ }
114
+ if ((record === null || record === void 0 ? void 0 : record.fileSize) >= MAX_PREVIEW_FILE_SIZE) {
115
+ message.warning('文件大于20MB,暂不支持在线预览,请先下载后查看!');
116
+ }
117
+ else {
118
+ previewFile(fileBaseUrl, record === null || record === void 0 ? void 0 : record.fileId, {
119
+ titleName: record === null || record === void 0 ? void 0 : record.fileName,
120
+ authToken: authToken,
121
+ });
122
+ onPreviewCallbackBefore && onPreviewCallbackBefore(record);
123
+ }
124
+ } }, previewTitle));
125
+ };
94
126
  var columns = showUploadBtn
95
127
  ? __spreadArray(__spreadArray(__spreadArray(__spreadArray([], startColumns), [
96
128
  {
@@ -99,8 +131,20 @@ var UploadTable = function (_a) {
99
131
  // fixed: 'left',
100
132
  dataIndex: 'fileName',
101
133
  key: 'fileName',
102
- render: function (value) {
103
- return dangerouslySetXss(value);
134
+ render: function (value, record) {
135
+ var operationAuth = record === null || record === void 0 ? void 0 : record.operationAuth;
136
+ var authPreviewBtn = typeof operationAuth === 'string' &&
137
+ operationAuth.indexOf('1') !== -1
138
+ ? true
139
+ : false;
140
+ return (typeof operationAuth === 'string'
141
+ ? authPreviewBtn
142
+ : showPreviewBtn)
143
+ ? previewBtn(dangerouslySetXss(value), {
144
+ record: record,
145
+ dataSource: dataSource,
146
+ })
147
+ : dangerouslySetXss(value);
104
148
  },
105
149
  },
106
150
  {
@@ -268,20 +312,11 @@ var UploadTable = function (_a) {
268
312
  } }, "\u4E0B\u8F7D")),
269
313
  (typeof operationAuth === 'string'
270
314
  ? authPreviewBtn
271
- : showPreviewBtn) && (React.createElement(Button, { type: "link", style: {
272
- height: 28,
273
- }, onClick: function () {
274
- if ((record === null || record === void 0 ? void 0 : record.fileSize) >= MAX_PREVIEW_FILE_SIZE) {
275
- message.warning('文件大于20MB,暂不支持在线预览,请先下载后查看!');
276
- }
277
- else {
278
- previewFile(fileBaseUrl, record === null || record === void 0 ? void 0 : record.fileId, {
279
- titleName: record === null || record === void 0 ? void 0 : record.fileName,
280
- authToken: authToken,
281
- });
282
- onPreviewCallbackBefore && onPreviewCallbackBefore(record);
283
- }
284
- } }, "\u9884\u89C8")),
315
+ : showPreviewBtn) &&
316
+ previewBtn('预览', {
317
+ record: record,
318
+ dataSource: dataSource,
319
+ }),
285
320
  (typeof operationAuth === 'string'
286
321
  ? authDeleteBtn
287
322
  : showDeleteBtn) && (React.createElement(Popconfirm, { title: "\u662F\u5426\u5220\u9664\u8BE5\u6761\u6570\u636E?", cancelText: "\u5426", okText: "\u662F", onConfirm: function () { return onDeleteFile(record, index); } },
@@ -12,6 +12,7 @@ interface IProps {
12
12
  attachSize?: any;
13
13
  showDeleteBtn?: boolean;
14
14
  onDeleteFile?: any;
15
+ dataSource?: any;
15
16
  }
16
17
  declare const AttachOperation: React.FC<IProps>;
17
18
  export default AttachOperation;
@@ -10,30 +10,46 @@ import { Button, message, Popconfirm } from '../../../../index';
10
10
  // store
11
11
  // 自定义组件
12
12
  // 其他文件
13
- import { downloadFileCallBack, previewFile, } from 'ztxkutils/dist/fileOperation';
13
+ import { downloadFileCallBack, previewFile, batchPreviewFile, } from 'ztxkutils/dist/fileOperation';
14
14
  import { dangerouslySetXss } from 'ztxkutils/dist/tools';
15
15
  import { MAX_PREVIEW_FILE_SIZE } from '../../../utils/constants';
16
+ import { isImage } from '../../../utils/upload';
16
17
  var AttachOperation = function (_a) {
17
- var attachId = _a.attachId, attachName = _a.attachName, attachSize = _a.attachSize, ZT_API_BASEURL = _a.ZT_API_BASEURL, ZT_FILE_BASEURL = _a.ZT_FILE_BASEURL, token = _a.token, _b = _a.showDeleteBtn, showDeleteBtn = _b === void 0 ? false : _b, onDeleteFile = _a.onDeleteFile;
18
+ var attachId = _a.attachId, attachName = _a.attachName, attachSize = _a.attachSize, ZT_API_BASEURL = _a.ZT_API_BASEURL, ZT_FILE_BASEURL = _a.ZT_FILE_BASEURL, token = _a.token, _b = _a.showDeleteBtn, showDeleteBtn = _b === void 0 ? false : _b, onDeleteFile = _a.onDeleteFile, dataSource = _a.dataSource;
19
+ var previewBtn = function (attachId, previewTitle) {
20
+ return (React.createElement(Button, { type: "link", onClick: function () {
21
+ // 实现批量预览,只针对图片
22
+ var result = isImage(attachName);
23
+ if (result) {
24
+ var allImage = (Array.isArray(dataSource) ? dataSource : [])
25
+ .filter(function (item) { return isImage(item.attachName) && item.attachId !== attachId; })
26
+ .map(function (item) { return item.attachId; });
27
+ batchPreviewFile(ZT_FILE_BASEURL, attachId + "," + allImage, {
28
+ titleName: attachName,
29
+ authToken: token,
30
+ });
31
+ return;
32
+ }
33
+ if (attachSize >= MAX_PREVIEW_FILE_SIZE) {
34
+ message.warning('文件过大,暂不支持在线预览,请先下载后查看!');
35
+ }
36
+ else {
37
+ previewFile(ZT_FILE_BASEURL, attachId, {
38
+ titleName: dangerouslySetXss(attachName),
39
+ authToken: token,
40
+ });
41
+ }
42
+ } }, previewTitle));
43
+ };
18
44
  return attachId ? (React.createElement("div", { className: "signatures-attach" },
19
- React.createElement("div", { className: "signatures-attach--text", title: dangerouslySetXss(attachName) }, dangerouslySetXss(attachName)),
45
+ React.createElement("div", { className: "signatures-attach--text", title: dangerouslySetXss(attachName) }, previewBtn(attachId, dangerouslySetXss(attachName))),
20
46
  React.createElement("div", { className: "signatures-attach--operation" },
21
47
  React.createElement(Button, { type: "link", onClick: function () {
22
48
  downloadFileCallBack(ZT_API_BASEURL, attachId, dangerouslySetXss(attachName) || '附件', {
23
49
  authToken: token,
24
50
  });
25
51
  } }, "\u4E0B\u8F7D"),
26
- React.createElement(Button, { type: "link", onClick: function () {
27
- if (attachSize >= MAX_PREVIEW_FILE_SIZE) {
28
- message.warning('文件过大,暂不支持在线预览,请先下载后查看!');
29
- }
30
- else {
31
- previewFile(ZT_FILE_BASEURL, attachId, {
32
- titleName: dangerouslySetXss(attachName),
33
- authToken: token,
34
- });
35
- }
36
- } }, "\u9884\u89C8"),
52
+ previewBtn(attachId, '预览'),
37
53
  showDeleteBtn && (React.createElement(Popconfirm, { title: "\u662F\u5426\u5220\u9664\u8BE5\u6761\u6570\u636E?", cancelText: "\u5426", okText: "\u662F", onConfirm: function () { return onDeleteFile(); } },
38
54
  React.createElement(Button, { type: "link" }, "\u5220\u9664")))))) : null;
39
55
  };
@@ -74,7 +74,7 @@ var DetailTable = function (_a) {
74
74
  width: 240,
75
75
  render: function (text, record, index) {
76
76
  return (React.createElement(React.Fragment, null,
77
- React.createElement(AttachOperation, { ZT_API_BASEURL: ZT_API_BASEURL, ZT_FILE_BASEURL: ZT_FILE_BASEURL, token: authToken, attachId: record === null || record === void 0 ? void 0 : record.attachId, attachName: record === null || record === void 0 ? void 0 : record.attachName, attachSize: record === null || record === void 0 ? void 0 : record.attachSize })));
77
+ React.createElement(AttachOperation, { ZT_API_BASEURL: ZT_API_BASEURL, ZT_FILE_BASEURL: ZT_FILE_BASEURL, token: authToken, attachId: record === null || record === void 0 ? void 0 : record.attachId, attachName: record === null || record === void 0 ? void 0 : record.attachName, attachSize: record === null || record === void 0 ? void 0 : record.attachSize, dataSource: records })));
78
78
  },
79
79
  },
80
80
  {
@@ -3,6 +3,10 @@ import { RcFile } from 'antd/lib/upload';
3
3
  * 截取文件后缀
4
4
  */
5
5
  export declare function getFileSuffix(fileName: string): string;
6
+ /**
7
+ * 判断是否是图片
8
+ */
9
+ export declare function isImage(fileName: string | undefined): boolean;
6
10
  interface ICheckFileProps {
7
11
  /**允许上传的文件类型 */
8
12
  ztAccept?: string[];
@@ -13,6 +13,38 @@ export function getFileSuffix(fileName) {
13
13
  var len = fileName.length;
14
14
  return fileName.substring(index, len).toLowerCase() || '-';
15
15
  }
16
+ /**
17
+ * 判断是否是图片
18
+ */
19
+ export function isImage(fileName) {
20
+ if (!fileName) {
21
+ return false;
22
+ }
23
+ try {
24
+ var fileSuffix = getFileSuffix(fileName);
25
+ var imageSuffix = [
26
+ '.jpg',
27
+ '.png',
28
+ '.jpeg',
29
+ '.gif',
30
+ '.tif',
31
+ '.tga',
32
+ '.bmp',
33
+ '.dds',
34
+ '.svg',
35
+ '.webp',
36
+ ];
37
+ if (imageSuffix.includes(fileSuffix)) {
38
+ return true;
39
+ }
40
+ else {
41
+ return false;
42
+ }
43
+ }
44
+ catch (err) {
45
+ return false;
46
+ }
47
+ }
16
48
  var _accept = [
17
49
  '.pdf',
18
50
  '.txt',
package/dist/index.d.ts CHANGED
@@ -47,6 +47,7 @@ export { default as UploadSingle } from './components/UploadSingle';
47
47
  export { default as CodeQuery } from './components/business/CodeQuery';
48
48
  export { default as DgColumns } from './components/business/DgColumns';
49
49
  export { default as message } from './components/basic/message';
50
+ export { default as NumberCase } from './components/NumberCase';
50
51
  export { ConfigProvider, Drawer, Space, Grid, Divider, Dropdown, Badge, List, Result, Spin, Popconfirm, TreeSelect, Tree, Progress, Cascader, Tooltip, Descriptions, Image, Popover, Breadcrumb, Transfer, Row, Col, notification, Slider, Rate, Affix, } from 'antd';
51
52
  export { default as zhCN } from 'antd/lib/locale/zh_CN';
52
53
  export { default as Icon, createFromIconfontCN } from '@ant-design/icons';
package/dist/index.js CHANGED
@@ -161,6 +161,7 @@ export { default as UploadSingle } from './components/UploadSingle';
161
161
  export { default as CodeQuery } from './components/business/CodeQuery';
162
162
  export { default as DgColumns } from './components/business/DgColumns';
163
163
  export { default as message } from './components/basic/message';
164
+ export { default as NumberCase } from './components/NumberCase';
164
165
  export { ConfigProvider, Drawer, Space, Grid, Divider, Dropdown, Badge, List, Result, Spin, Popconfirm, TreeSelect, Tree, Progress, Cascader, Tooltip, Descriptions, Image, Popover, Breadcrumb, Transfer, Row, Col, notification, Slider, Rate, Affix, } from 'antd';
165
166
  export { default as zhCN } from 'antd/lib/locale/zh_CN';
166
167
  export { default as Icon, createFromIconfontCN } from '@ant-design/icons';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",