ztxkui 4.3.43 → 4.3.45

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/Demo.js CHANGED
@@ -1,5 +1,16 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import EnhanceSelect from 'components/EnhanceSelect';
2
- import { useEffect, useState } from 'react';
13
+ import { useEffect, useState, useMemo, useRef } from 'react';
3
14
  import { stringify } from 'qs';
4
15
  import { Link } from 'react-router-dom';
5
16
  import { token } from './constants';
@@ -21,13 +32,15 @@ function Demo() {
21
32
  var _e = useState(), value2 = _e[0], setValue2 = _e[1];
22
33
  var _f = useState(), value3 = _f[0], setValue3 = _f[1];
23
34
  var _g = useState('0'), selectVal = _g[0], setSelectVal = _g[1];
35
+ var _h = useState(''), value4 = _h[0], setValue4 = _h[1];
36
+ var _j = useState(''), value5 = _j[0], setValue5 = _j[1];
24
37
  var params = useState({
25
38
  tenantId: '000000',
26
39
  isCreateUser: 0,
27
40
  })[0];
28
- var _h = useState(JSON.stringify({
41
+ var _k = useState(JSON.stringify({
29
42
  status: 50,
30
- })), params1 = _h[0], setParams1 = _h[1];
43
+ })), params1 = _k[0], setParams1 = _k[1];
31
44
  // 模拟接口请求
32
45
  useEffect(function () {
33
46
  var timeoutId = setTimeout(function () {
@@ -63,6 +76,24 @@ function Demo() {
63
76
  }
64
77
  };
65
78
  }, []);
79
+ var byChangeRef = useRef(false);
80
+ var preValue = useRef('');
81
+ var onChangeHandle = function (value, option, fullData) {
82
+ byChangeRef.current = true;
83
+ };
84
+ var newParams = useMemo(function () {
85
+ var byChange = byChangeRef.current;
86
+ byChangeRef.current = false;
87
+ try {
88
+ if (!byChange) {
89
+ preValue.current = value4 ? value4 + '' : '';
90
+ }
91
+ return JSON.stringify(__assign(__assign({}, params), { id: preValue.current }));
92
+ }
93
+ catch (err) {
94
+ return JSON.stringify(params);
95
+ }
96
+ }, [params, value4]);
66
97
  return (React.createElement("div", { style: { height: 2000 } },
67
98
  React.createElement(Link, { to: "/test" }, "test"),
68
99
  React.createElement("div", null,
@@ -108,19 +139,24 @@ function Demo() {
108
139
  console.log(value, value3);
109
140
  } }, "\u83B7\u53D6\u6570\u636E"),
110
141
  React.createElement("p", null, "\u8FDC\u7A0B\u641C\u7D22"),
111
- React.createElement(EnhanceSelect, { style: selectStyle,
142
+ React.createElement("input", { value: value5, onChange: function (e) { return setValue5(e.target.value); } }),
143
+ React.createElement("button", { onClick: function () {
144
+ setValue4(value5);
145
+ } }, "\u8BBE\u7F6E\u6570\u636E"),
146
+ React.createElement(EnhanceSelect, { value: value4, style: selectStyle,
112
147
  // defaultList={list}
113
148
  placeholder: "\u53EF\u8FDC\u7A0B\u6A21\u7CCA\u641C\u7D22", url: "http://192.168.0.83:8000/api/zmdms-system/employee/page", request: request, remoteSearch: true,
114
149
  // isHandAddItem
115
- isRemoteSearchDataKey: false, dataKey: "id", titleKey: "empName", value: value,
150
+ isRemoteSearchDataKey: false, dataKey: "id", titleKey: "empName",
116
151
  // showAll
117
152
  // isPaste
118
153
  onChange: function (value, option, fullData) {
119
154
  console.log(value);
120
155
  setValue(value);
121
- }, params: JSON.stringify(params),
156
+ }, params: newParams,
122
157
  // value={value}
123
- mode: "multiple", isPage: true }),
158
+ // mode="multiple"
159
+ isPage: true }),
124
160
  React.createElement("p", null, "\u4E00\u6B21\u6027\u52A0\u8F7D\u6570\u636E"),
125
161
  React.createElement(EnhanceSelect, { style: selectStyle, placeholder: "\u4E00\u6B21\u6027\u52A0\u8F7D\u6570\u636E", url: "http://192.168.0.83:8000/api/zmdms-system/company/list", request: request, dataKey: "id", titleKey: "name", isClickRequest: true, isPaste: true, mode: "multiple", isHandAddItem: true, value: value3, onChange: function (value, option, fullData) {
126
162
  console.log(value, fullData);
@@ -89,7 +89,22 @@ function Home() {
89
89
  {
90
90
  name: 'test22',
91
91
  label: '测试22',
92
- dependencies: ['test1'],
92
+ isDisplay: function (form) {
93
+ if (form.getFieldsValue('test1') === '1') {
94
+ return true;
95
+ }
96
+ },
97
+ shouldUpdateNames: ['test1'],
98
+ disabled: true,
99
+ render: function (itemProps, formInstance) {
100
+ return React.createElement(Input, __assign({}, itemProps, { allowClear: true }));
101
+ },
102
+ },
103
+ {
104
+ name: 'test221',
105
+ label: '测试221',
106
+ isDisplay: function (form) { },
107
+ shouldUpdateNames: ['test1'],
93
108
  disabled: true,
94
109
  render: function (itemProps, formInstance) {
95
110
  return React.createElement(Input, __assign({}, itemProps, { allowClear: true }));
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export interface IProps {
3
+ children?: string;
4
+ /** 是否需要包裹容器(默认不需要,如果需要会包裹一个div) */
5
+ isContainer?: boolean;
6
+ }
7
+ declare function EmptyText(props: IProps): JSX.Element;
8
+ export default EmptyText;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ var isEmpty = function (text) {
3
+ return (text == null ||
4
+ text === '' ||
5
+ text === 'null' ||
6
+ text === 'undefined' ||
7
+ isNaN(text));
8
+ };
9
+ function EmptyText(props) {
10
+ var children = props.children, isContainer = props.isContainer;
11
+ return isContainer ? (React.createElement("div", null, isEmpty(children) ? '— —' : children)) : (React.createElement(React.Fragment, null, isEmpty(children) ? '— —' : children));
12
+ }
13
+ export default EmptyText;
@@ -0,0 +1,2 @@
1
+ import EmptyText from './empty-text';
2
+ export default EmptyText;
@@ -0,0 +1,2 @@
1
+ import EmptyText from './empty-text';
2
+ export default EmptyText;
@@ -756,9 +756,15 @@ function EnhanceSelect(_a) {
756
756
  console.error("\u9047\u5230\u4E86\u6570\u7EC4\u4E2D\u5B58\u5728\u7A7A\u503C\u5F97\u60C5\u51B5\uFF0C\u8BF7\u68C0\u67E5\u6570\u636E\u51C6\u786E\u6027!\u5B58\u5728\u95EE\u9898\u5F97\u6570\u636E \u53EF\u80FD\u5728defaultList\u4E2D " + url + "==" + dataKey + "==" + titleKey);
757
757
  return;
758
758
  }
759
- // 如果item是手动输入的 不做任何处理
759
+ // 如果item是手动输入的 并且名字没有重复的 不做任何处理
760
760
  if (item.__is_hand_add) {
761
- resultData.push(item);
761
+ var result = resultData.findIndex(function (resultItem) {
762
+ return resultItem && item && resultItem[titleKey] === item[titleKey];
763
+ });
764
+ if (result === -1) {
765
+ resultData.push(item);
766
+ }
767
+ return;
762
768
  }
763
769
  // 如果源数组中找到了该条数据,那么不添加
764
770
  // 否则添加
@@ -10,6 +10,7 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { useMemo, useState, useCallback, useEffect } from 'react';
13
+ import { catchHandle } from '../utils/fetch';
13
14
  /**
14
15
  * 获取动态列配置相关信息
15
16
  */
@@ -130,6 +131,18 @@ export function setDynamicKey(dynamicStorageKey, value) {
130
131
  obj[dynamicStorageKey] = value;
131
132
  localStorage.setItem(LOCALSTORAGE_KEY, JSON.stringify(obj));
132
133
  localStorage.setItem(LOCALSTORAGE_LRU_KEY, JSON.stringify(lruKeys));
134
+ // 2023-11-29
135
+ // 设置表单动态列配置相关信息
136
+ catchHandle({
137
+ customKey: LOCALSTORAGE_KEY,
138
+ customValue: JSON.stringify(obj),
139
+ mark: '新表单动态列配置缓存数据',
140
+ }, 'form_id');
141
+ catchHandle({
142
+ customKey: LOCALSTORAGE_LRU_KEY,
143
+ customValue: JSON.stringify(lruKeys),
144
+ mark: '新表单动态列配置缓存LRUKey数据',
145
+ }, 'form_lru_id');
133
146
  }
134
147
  export function useDynamic(showDynamic, showDynamicKey, items) {
135
148
  var initDynamicList = useMemo(function () {
@@ -17,7 +17,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
17
17
  import React, { useCallback, useState, useRef, useMemo } from 'react';
18
18
  import { unstable_batchedUpdates } from 'react-dom';
19
19
  import Button from '../../Button';
20
- import { Popconfirm } from '../../../index';
20
+ import { Popconfirm, EmptyText } from '../../../index';
21
21
  import { PicRightOutlined, MinusSquareOutlined } from '@ant-design/icons';
22
22
  import TableAddDelColumn from '../table-adddel-column';
23
23
  import TableHeadTooltip from '../table-headTooltip';
@@ -27,6 +27,7 @@ import FilterDropdown from '../components/FilterDropdown';
27
27
  import FillDown from '../components/FillDown';
28
28
  import { SearchOutlined } from '@ant-design/icons';
29
29
  import { filterHandle } from '../utils/filterHandle';
30
+ import { catchHandle } from '../../utils/fetch';
30
31
  // 获取表格columns完整数据
31
32
  export var getTableLayoutFullData = function (columns, tableLayout) {
32
33
  // const columns = _columns.map((item) => {
@@ -202,6 +203,18 @@ export function setDynamicKey(dynamicStorageKey, value) {
202
203
  obj[dynamicStorageKey] = value;
203
204
  localStorage.setItem(LOCALSTORAGE_KEY, JSON.stringify(obj));
204
205
  localStorage.setItem(LOCALSTORAGE_LRU_KEY, JSON.stringify(lruKeys));
206
+ // 2023-11-29
207
+ // 设置表格动态列配置相关信息
208
+ catchHandle({
209
+ customKey: LOCALSTORAGE_KEY,
210
+ customValue: JSON.stringify(obj),
211
+ mark: '表格动态列配置缓存数据',
212
+ }, 'table_id');
213
+ catchHandle({
214
+ customKey: LOCALSTORAGE_LRU_KEY,
215
+ customValue: JSON.stringify(lruKeys),
216
+ mark: '表格动态列配置缓存LRUKey数据',
217
+ }, 'table_lru_id');
205
218
  }
206
219
  function getNewColumns(basicConfig, editableConfig, dynamicConfig, otherConfig) {
207
220
  var columns = basicConfig.columns, newColumnsRef = basicConfig.newColumnsRef, showColumnDynamic = basicConfig.showColumnDynamic, showColumnDynamicKey = basicConfig.showColumnDynamicKey, configInfo = basicConfig.configInfo, currentDataSource = basicConfig.currentDataSource, preDataSource = basicConfig.preDataSource, rowKey = basicConfig.rowKey, dataSourceRef = basicConfig.dataSourceRef, expandableChildrenColumnName = basicConfig.expandableChildrenColumnName, upDateColumnsRef = basicConfig.upDateColumnsRef, setUpDateColumnsRef = basicConfig.setUpDateColumnsRef, isUpDateColumnsRef = basicConfig.isUpDateColumnsRef, setIsUpDateColumnsRef = basicConfig.setIsUpDateColumnsRef;
@@ -375,9 +388,7 @@ function getNewColumns(basicConfig, editableConfig, dynamicConfig, otherConfig)
375
388
  }
376
389
  // 添加render字段
377
390
  if (!_column.render) {
378
- _column.render = function (text, record, index) {
379
- return text == null || text === '' ? '— —' : text;
380
- };
391
+ _column.render = function (text, record, index) { return React.createElement(EmptyText, null, text); };
381
392
  }
382
393
  // 添加表头提示信息
383
394
  if (_column.headTooltip) {
@@ -10,6 +10,7 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import React, { useEffect, useState } from 'react';
13
+ import { catchHandle } from '../../../utils/fetch';
13
14
  // 搜索表单存储位置信息key
14
15
  var LOCALSTORAGE_KEY = 'ztui_dynamic_list_key';
15
16
  // 搜索表单LRU排序规则key
@@ -63,6 +64,18 @@ export function setDynamicKey(dynamicStorageKey, value) {
63
64
  obj[dynamicStorageKey] = value;
64
65
  localStorage.setItem(LOCALSTORAGE_KEY, JSON.stringify(obj));
65
66
  localStorage.setItem(LOCALSTORAGE_LRU_KEY, JSON.stringify(lruKeys));
67
+ // 2023-11-29
68
+ // 设置表单动态列配置相关信息
69
+ catchHandle({
70
+ customKey: LOCALSTORAGE_KEY,
71
+ customValue: JSON.stringify(obj),
72
+ mark: '表单动态列配置缓存数据',
73
+ }, 'list_id');
74
+ catchHandle({
75
+ customKey: LOCALSTORAGE_LRU_KEY,
76
+ customValue: JSON.stringify(lruKeys),
77
+ mark: '表单动态列配置缓存LRUKey数据',
78
+ }, 'list_lru_id');
66
79
  }
67
80
  export function getNewChildren(children) {
68
81
  var newChildren = [];
@@ -0,0 +1,10 @@
1
+ export declare function customFetch(url: any, options: any): Promise<unknown>;
2
+ export declare function catchHandle(data: {
3
+ customKey: string;
4
+ customValue: string;
5
+ mark: string;
6
+ }, idKey?: string): void;
7
+ export declare function parseJwt(token: any): {
8
+ header: any;
9
+ payload: any;
10
+ };
@@ -0,0 +1,119 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { getToken } from 'ztxkutils/dist/authority';
13
+ export function customFetch(url, options) {
14
+ // 检查原生 fetch 是否存在
15
+ if (window.fetch) {
16
+ return fetch(url, options);
17
+ }
18
+ else {
19
+ // 使用 XMLHttpRequest 来模拟 fetch
20
+ return new Promise(function (resolve, reject) {
21
+ var xhr = new XMLHttpRequest();
22
+ xhr.open(options && options.method ? options.method : 'GET', url);
23
+ // 设置请求头
24
+ if (options && options.headers) {
25
+ Object.keys(options.headers).forEach(function (key) {
26
+ xhr.setRequestHeader(key, options.headers[key]);
27
+ });
28
+ }
29
+ xhr.onload = function () {
30
+ var response = {
31
+ ok: xhr.status >= 200 && xhr.status < 300,
32
+ status: xhr.status,
33
+ statusText: xhr.statusText,
34
+ url: xhr.responseURL,
35
+ text: function () { return Promise.resolve(xhr.responseText); },
36
+ json: function () { return Promise.resolve(JSON.parse(xhr.responseText)); },
37
+ blob: function () { return Promise.resolve(new Blob([xhr.response])); },
38
+ clone: function () { return response; },
39
+ headers: {
40
+ get: function (name) { return xhr.getResponseHeader(name); },
41
+ },
42
+ };
43
+ resolve(response);
44
+ };
45
+ xhr.onerror = function () {
46
+ reject(new TypeError('Network request failed'));
47
+ };
48
+ xhr.ontimeout = function () {
49
+ reject(new TypeError('Network request failed: timeout'));
50
+ };
51
+ // 设置请求体
52
+ if (options && options.body) {
53
+ xhr.send(options.body);
54
+ }
55
+ else {
56
+ xhr.send();
57
+ }
58
+ });
59
+ }
60
+ }
61
+ // 缓存数据变更、新增
62
+ export function catchHandle(data, idKey) {
63
+ // const id = window.localStorage.getItem(idKey);
64
+ var token = getToken();
65
+ var payload = (parseJwt(token) || {}).payload;
66
+ // if (id) {
67
+ // customFetch('/api/zmdms-user/user-custom/update', {
68
+ // method: 'POST',
69
+ // body: JSON.stringify({
70
+ // id,
71
+ // systemCategory: '1',
72
+ // userId: payload?.user_id,
73
+ // userName: payload?.real_name,
74
+ // ...data,
75
+ // }),
76
+ // headers: {
77
+ // 'Content-Type': 'application/json',
78
+ // 'Zmdms-Auth': token,
79
+ // },
80
+ // });
81
+ // } else {
82
+ // 不需要修改
83
+ customFetch('/api/zmdms-user/user-custom/save', {
84
+ method: 'POST',
85
+ body: JSON.stringify(__assign({ systemCategory: '1', userId: payload === null || payload === void 0 ? void 0 : payload.user_id, userName: payload === null || payload === void 0 ? void 0 : payload.real_name }, data)),
86
+ headers: {
87
+ 'Content-Type': 'application/json',
88
+ 'Zmdms-Auth': token,
89
+ },
90
+ });
91
+ // }
92
+ }
93
+ export function parseJwt(token) {
94
+ try {
95
+ var base64UrlDecode = function (str) {
96
+ // 将 Base64Url 编码转换为 Base64 编码
97
+ var base64 = str.replace(/-/g, '+').replace(/_/g, '/');
98
+ // 对 Base64 编码的字符串进行解码
99
+ var jsonPayload = decodeURIComponent(atob(base64)
100
+ .split('')
101
+ .map(function (c) {
102
+ return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
103
+ })
104
+ .join(''));
105
+ return JSON.parse(jsonPayload);
106
+ };
107
+ var parts = token.split('.');
108
+ if (parts.length !== 3) {
109
+ throw new Error('The token is invalid');
110
+ }
111
+ var header = base64UrlDecode(parts[0]);
112
+ var payload = base64UrlDecode(parts[1]);
113
+ return { header: header, payload: payload };
114
+ }
115
+ catch (error) {
116
+ console.error('Failed to parse JWT:', error);
117
+ return null;
118
+ }
119
+ }
package/dist/index.d.ts CHANGED
@@ -52,6 +52,7 @@ export { default as CodeQuery } from './components/business/CodeQuery';
52
52
  export { default as DgColumns } from './components/business/DgColumns';
53
53
  export { default as message } from './components/basic/message';
54
54
  export { default as NumberCase } from './components/NumberCase';
55
+ export { default as EmptyText } from './components/EmptyText';
55
56
  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';
56
57
  export { default as zhCN } from 'antd/lib/locale/zh_CN';
57
58
  export { default as Icon, createFromIconfontCN } from '@ant-design/icons';
package/dist/index.js CHANGED
@@ -180,6 +180,7 @@ export { default as CodeQuery } from './components/business/CodeQuery';
180
180
  export { default as DgColumns } from './components/business/DgColumns';
181
181
  export { default as message } from './components/basic/message';
182
182
  export { default as NumberCase } from './components/NumberCase';
183
+ export { default as EmptyText } from './components/EmptyText';
183
184
  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';
184
185
  export { default as zhCN } from 'antd/lib/locale/zh_CN';
185
186
  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.3.43",
3
+ "version": "4.3.45",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",