ls-pro-common 3.1.48 → 3.1.49

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.
@@ -153,13 +153,13 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
153
153
  * @param formValue
154
154
  */
155
155
  var setFormValue = function setFormValue(formValue) {
156
- var _prop$onChange;
157
- (_prop$onChange = prop.onChange) === null || _prop$onChange === void 0 ? void 0 : _prop$onChange.call(prop, formValue[name]);
158
156
  if (rowKey) {
159
- var _formRef$current3, _formRef$current3$set;
157
+ var _formRef$current3, _formRef$current3$set, _prop$onChange;
160
158
  formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : (_formRef$current3$set = _formRef$current3.setFieldsValue) === null || _formRef$current3$set === void 0 ? void 0 : _formRef$current3$set.call(_formRef$current3, _defineProperty({}, rowKey, formValue));
159
+ (_prop$onChange = prop.onChange) === null || _prop$onChange === void 0 ? void 0 : _prop$onChange.call(prop, formValue[textNameProp]);
161
160
  } else {
162
- var _formRef$current4, _formRef$current4$set;
161
+ var _prop$onChange2, _formRef$current4, _formRef$current4$set;
162
+ (_prop$onChange2 = prop.onChange) === null || _prop$onChange2 === void 0 ? void 0 : _prop$onChange2.call(prop, formValue[name]);
163
163
  formRef === null || formRef === void 0 ? void 0 : (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 ? void 0 : (_formRef$current4$set = _formRef$current4.setFieldsValue) === null || _formRef$current4$set === void 0 ? void 0 : _formRef$current4$set.call(_formRef$current4, formValue);
164
164
  }
165
165
  };
@@ -171,7 +171,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
171
171
  */
172
172
  var loadData = /*#__PURE__*/function () {
173
173
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(param) {
174
- var current, pageSize, restParams, _selectRowRef$current, _rows, data, _tableRef$current2, _tableRef$current2$cl, _param, result, rows, formValue, val, _selectRowRef$current2, arr, pageSelectedRows;
174
+ var current, pageSize, restParams, _selectRowRef$current, _rows, data, _tableRef$current2, _tableRef$current2$cl, beforeParam, result, rows, formValue, val, _selectRowRef$current2, arr, pageSelectedRows;
175
175
  return _regeneratorRuntime.wrap(function _callee$(_context) {
176
176
  while (1) switch (_context.prev = _context.next) {
177
177
  case 0:
@@ -187,10 +187,10 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
187
187
  return o[tableKey];
188
188
  })));
189
189
  setSelectedKeys(Array.from(new Set(selectedKeys)));
190
- setTimeout(function () {
190
+ requestIdleCallback(function () {
191
191
  var _tableRef$current, _tableRef$current$rel;
192
192
  (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : (_tableRef$current$rel = _tableRef$current.reload) === null || _tableRef$current$rel === void 0 ? void 0 : _tableRef$current$rel.call(_tableRef$current);
193
- }, 0);
193
+ });
194
194
  return _context.abrupt("return", {
195
195
  data: _rows,
196
196
  total: _rows.length,
@@ -221,9 +221,9 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
221
221
  _context.next = 16;
222
222
  return beforeLoad(data);
223
223
  case 16:
224
- _param = _context.sent;
225
- if (typeof _param !== 'boolean' && _param !== undefined) {
226
- data = _param;
224
+ beforeParam = _context.sent;
225
+ if (typeof beforeParam !== 'boolean' && beforeParam !== undefined) {
226
+ data = beforeParam;
227
227
  }
228
228
  case 18:
229
229
  if (!(method !== 'GET')) {
@@ -325,7 +325,6 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
325
325
  var formValue = getFormValue();
326
326
  if (!formValue) return;
327
327
  formValue[textNameProp] = txt;
328
- console.log('formValue', formValue);
329
328
  setFormValue(formValue);
330
329
  });
331
330
  };
@@ -348,6 +347,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
348
347
  initName(val, false);
349
348
  }
350
349
  }
350
+ // eslint-disable-next-line react-hooks/exhaustive-deps
351
351
  }, [rowKey]);
352
352
  // 处理返回数据
353
353
  var handleValue = function handleValue(row) {
@@ -600,23 +600,30 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
600
600
  readOnly: readonly,
601
601
  allowClear: allowClear,
602
602
  ref: inputRef
603
- }, !rowKey ? {} : {
604
- value: text
605
603
  }, fieldProps));
606
- console.log('textNameProp', prop);
604
+ // 是否在编辑表格下面使用,如果是,则需要使用 rowKey 和 id 来设置 name
605
+ var isEditable = rowKey && id && id.includes('_');
607
606
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
608
607
  style: {
609
608
  display: 'none'
610
609
  }
611
610
  }, /*#__PURE__*/React.createElement(ProFormText, {
612
- name: rowKey ? id : name
613
- })), rest.label || rowKey ? /*#__PURE__*/React.createElement(ProFormText, _extends({
611
+ name: isEditable ? [rowKey, name] : name
612
+ })), rest.label ?
613
+ /*#__PURE__*/
614
+ // 在ProForm中直接使用
615
+ React.createElement(ProFormText, _extends({
614
616
  name: textNameProp
615
- }, rest, rowKey ? {
617
+ }, rest), InputDom) : isEditable ?
618
+ /*#__PURE__*/
619
+ // 在EditableTable中使用
620
+ React.createElement(_Form.Item, _extends({
621
+ name: [rowKey, textNameProp]
622
+ }, rest, {
616
623
  noStyle: true
617
- } : {}), InputDom) :
624
+ }), InputDom) :
618
625
  /*#__PURE__*/
619
- // 在ProTable的查询面板中
626
+ // 在 ProTable 的查询面板中使用
620
627
  React.createElement(_Form.Item, _extends({
621
628
  name: textNameProp
622
629
  }, rest, {
@@ -0,0 +1,28 @@
1
+ /**
2
+ * 设置本地缓存
3
+ *
4
+ * @param {String} key 关键字
5
+ * @param {Object} data 值
6
+ * @param {Boolean} session 保存到 sessionStorage 还是 localStorage,默认 localStorage
7
+ */
8
+ export declare const setCache: (key: string, data: any, session?: boolean) => void;
9
+ /**
10
+ * 读取本地缓存
11
+ *
12
+ * @param {String} key 关键字
13
+ * @param {boolean} session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
14
+ * @returns 关键字对应的值
15
+ */
16
+ export declare const getCache: any;
17
+ /**
18
+ * 读取本地缓存,优先从sessionStorage 取,取不到时再从 localStorage取
19
+ *
20
+ * @param key
21
+ * @returns
22
+ */
23
+ export declare const getCacheSessionFirst: (key: string) => any;
24
+ /**
25
+ * @param key 关键字,不传清除所有
26
+ * @param session 是否session storage , 默认 localStorage
27
+ */
28
+ export declare const clearCache: (key?: string | undefined, session?: boolean) => void;
@@ -0,0 +1,63 @@
1
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
2
+ /**
3
+ * 设置本地缓存
4
+ *
5
+ * @param {String} key 关键字
6
+ * @param {Object} data 值
7
+ * @param {Boolean} session 保存到 sessionStorage 还是 localStorage,默认 localStorage
8
+ */
9
+ export var setCache = function setCache(key, data) {
10
+ var session = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
11
+ if (_typeof(data) === 'object') {
12
+ data = JSON.stringify(data);
13
+ }
14
+ if (session) {
15
+ sessionStorage.setItem(key, data);
16
+ } else {
17
+ localStorage.setItem(key, data);
18
+ }
19
+ };
20
+ /**
21
+ * 读取本地缓存
22
+ *
23
+ * @param {String} key 关键字
24
+ * @param {boolean} session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
25
+ * @returns 关键字对应的值
26
+ */
27
+ export var getCache = function getCache(key) {
28
+ var session = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
29
+ var data = session ? sessionStorage.getItem(key) : localStorage.getItem(key);
30
+ if (data && (data.startsWith('{') || data.startsWith('['))) {
31
+ data = JSON.parse(data);
32
+ }
33
+ return data;
34
+ };
35
+ /**
36
+ * 读取本地缓存,优先从sessionStorage 取,取不到时再从 localStorage取
37
+ *
38
+ * @param key
39
+ * @returns
40
+ */
41
+ export var getCacheSessionFirst = function getCacheSessionFirst(key) {
42
+ return getCache(key, true) || getCache(key);
43
+ };
44
+ /**
45
+ * @param key 关键字,不传清除所有
46
+ * @param session 是否session storage , 默认 localStorage
47
+ */
48
+ export var clearCache = function clearCache(key) {
49
+ var session = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
50
+ if (key) {
51
+ if (session) {
52
+ sessionStorage.removeItem(key);
53
+ } else {
54
+ localStorage.removeItem(key);
55
+ }
56
+ } else {
57
+ if (session) {
58
+ sessionStorage.clear();
59
+ } else {
60
+ localStorage.clear();
61
+ }
62
+ }
63
+ };
@@ -0,0 +1,12 @@
1
+ /** @name 状态列表 */
2
+ export declare const statusList: {
3
+ value: number;
4
+ text: string;
5
+ label: string;
6
+ }[];
7
+ /** @name 是否列表 */
8
+ export declare const yesnoList: {
9
+ value: number;
10
+ text: string;
11
+ label: string;
12
+ }[];
@@ -0,0 +1,20 @@
1
+ /** @name 状态列表 */
2
+ export var statusList = [{
3
+ value: 1,
4
+ text: '启用',
5
+ label: '1→启用'
6
+ }, {
7
+ value: 0,
8
+ text: '禁用',
9
+ label: '0→禁用'
10
+ }];
11
+ /** @name 是否列表 */
12
+ export var yesnoList = [{
13
+ value: 1,
14
+ text: '是',
15
+ label: '1→是'
16
+ }, {
17
+ value: 0,
18
+ text: '否',
19
+ label: '0→否'
20
+ }];
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 获取Cookie
3
+ *
4
+ * @param {String} name Cookie名
5
+ * @returns
6
+ */
7
+ export declare const getCookie: (name: string) => string | null;
8
+ /**
9
+ * 设置Cookie
10
+ *
11
+ * @param {any} key Cookie名称
12
+ * @param {any} value Cookie 值
13
+ * @param {Number} day 有效天数 默认1天,
14
+ */
15
+ export declare const setCookie: (key: string, value: string | number, day?: number, sameSite?: boolean) => void;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * 获取Cookie
3
+ *
4
+ * @param {String} name Cookie名
5
+ * @returns
6
+ */
7
+ export var getCookie = function getCookie(name) {
8
+ var arr;
9
+ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');
10
+ if (arr = document.cookie.match(reg)) return arr[2];else return null;
11
+ };
12
+ /**
13
+ * 设置Cookie
14
+ *
15
+ * @param {any} key Cookie名称
16
+ * @param {any} value Cookie 值
17
+ * @param {Number} day 有效天数 默认1天,
18
+ */
19
+ export var setCookie = function setCookie(key, value) {
20
+ var day = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
21
+ var sameSite = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
22
+ if (day !== 0) {
23
+ var d = new Date(Date.now() + day * 24 * 60 * 60 * 1000);
24
+ if (sameSite) {
25
+ document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/;sameSite=None;secure=true");
26
+ } else {
27
+ document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/");
28
+ }
29
+ } else {
30
+ if (sameSite) {
31
+ document.cookie = key + '=' + value + ';path=/;sameSite=None;secure=true';
32
+ } else {
33
+ document.cookie = key + '=' + value + ';path=/';
34
+ }
35
+ }
36
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 绑定事件
3
+ *
4
+ * @param eventName 事件名
5
+ * @param fn 调用函数
6
+ * @param el 源对象,默认为window
7
+ */
8
+ export declare const on: (eventName: string, fn: Function, el: any | undefined) => void;
9
+ /**
10
+ * 解绑事件
11
+ *
12
+ * @param eventName 事件名
13
+ * @param fn 调用函数
14
+ * @param el 源对象,默认为window
15
+ */
16
+ export declare const off: (eventName: string, fn: Function, el: any | undefined) => void;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 绑定事件
3
+ *
4
+ * @param eventName 事件名
5
+ * @param fn 调用函数
6
+ * @param el 源对象,默认为window
7
+ */
8
+ export var on = function on(eventName, fn, el) {
9
+ if (!el) {
10
+ el = window;
11
+ }
12
+ el.addEventListener(eventName, fn);
13
+ };
14
+ /**
15
+ * 解绑事件
16
+ *
17
+ * @param eventName 事件名
18
+ * @param fn 调用函数
19
+ * @param el 源对象,默认为window
20
+ */
21
+ export var off = function off(eventName, fn, el) {
22
+ if (!el) {
23
+ el = window;
24
+ }
25
+ el.removeEventListener(eventName, fn);
26
+ };
@@ -7,32 +7,14 @@ export * from './promise';
7
7
  export * from './clac';
8
8
  export { getBrowserId } from 'ls-pro-tools';
9
9
  export * from './pasteUpload';
10
- /**
11
- * 获取 url 参数
12
- *
13
- * @param name
14
- * @param url
15
- * @returns
16
- */
17
- export declare const getUrlQuery: (name: string, url?: string) => string;
18
- export declare const getResourceProps: (name: string) => any;
19
- /**
20
- * 设置url传参
21
- *
22
- * @param {any} url
23
- * @param {any} keyvals
24
- * @returns
25
- */
26
- export declare const setUrlQuery: (url: string, keyvals?: Record<string, any>) => string;
27
- /**
28
- * 给 url 添加网关
29
- *
30
- * @param url 原url,以 / 打头
31
- * @param gatewayKey 设置gateway关键字 默认为 'gateway'
32
- * @param defaultGateway 默认网关 ''
33
- * @returns
34
- */
35
- export declare const toGatewayUrl: (url: string, gatewayKey?: string, defaultGateway?: string) => string;
10
+ export * from './cache';
11
+ export * from './constant';
12
+ export * from './cookie';
13
+ export * from './event';
14
+ export * from './url';
15
+ export * from './print';
16
+ export * from './user';
17
+ export * from './project';
36
18
  /**
37
19
  * 设置文档title
38
20
  *
@@ -40,55 +22,12 @@ export declare const toGatewayUrl: (url: string, gatewayKey?: string, defaultGat
40
22
  * @returns
41
23
  */
42
24
  export declare const setTitle: (title: string) => void;
43
- /**
44
- * 获取Cookie
45
- *
46
- * @param {String} name Cookie名
47
- * @returns
48
- */
49
- export declare const getCookie: (name: string) => string | null;
50
- /**
51
- * 设置Cookie
52
- *
53
- * @param {any} key Cookie名称
54
- * @param {any} value Cookie 值
55
- * @param {Number} day 有效天数 默认1天,
56
- */
57
- export declare const setCookie: (key: string, value: string | number, day?: number, sameSite?: boolean) => void;
58
25
  /**
59
26
  * 判断是否登录
60
27
  *
61
28
  * @returns
62
29
  */
63
30
  export declare const isLogin: () => boolean;
64
- /**
65
- * 设置本地缓存
66
- *
67
- * @param {String} key 关键字
68
- * @param {Object} data 值
69
- * @param {Boolean} session 保存到 sessionStorage 还是 localStorage,默认 localStorage
70
- */
71
- export declare const setCache: (key: string, data: any, session?: boolean) => void;
72
- /**
73
- * 读取本地缓存
74
- *
75
- * @param {String} key 关键字
76
- * @param {boolean} session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
77
- * @returns 关键字对应的值
78
- */
79
- export declare const getCache: any;
80
- /**
81
- * 读取本地缓存,优先从sessionStorage 取,取不到时再从 localStorage取
82
- *
83
- * @param key
84
- * @returns
85
- */
86
- export declare const getCacheSessionFirst: (key: string) => any;
87
- /**
88
- * @param key 关键字,不传清除所有
89
- * @param session 是否session storage , 默认 localStorage
90
- */
91
- export declare const clearCache: (key?: string | undefined, session?: boolean) => void;
92
31
  /**
93
32
  * 日期组选择转换
94
33
  *
@@ -99,94 +38,6 @@ export declare const clearCache: (key?: string | undefined, session?: boolean) =
99
38
  * @returns
100
39
  */
101
40
  export declare const rangeToSearch: (values: any, startField: string, endField: string, endSuffix?: string, startSuffex?: string) => any;
102
- /** @name 状态列表 */
103
- export declare const statusList: {
104
- value: number;
105
- text: string;
106
- label: string;
107
- }[];
108
- /** @name 是否列表 */
109
- export declare const yesnoList: {
110
- value: number;
111
- text: string;
112
- label: string;
113
- }[];
114
- /**
115
- * 绑定事件
116
- *
117
- * @param eventName 事件名
118
- * @param fn 调用函数
119
- * @param el 源对象,默认为window
120
- */
121
- export declare const on: (eventName: string, fn: Function, el: any | undefined) => void;
122
- /**
123
- * 解绑事件
124
- *
125
- * @param eventName 事件名
126
- * @param fn 调用函数
127
- * @param el 源对象,默认为window
128
- */
129
- export declare const off: (eventName: string, fn: Function, el: any | undefined) => void;
130
- /**
131
- * 打印预览
132
- *
133
- * @param templateNo 打印模板编码
134
- * @param reqUrl 业务请求api
135
- * @param bodyParam Post传参数
136
- * @param param Get传参数
137
- * @param method 请求方式,默认post
138
- * @param isNewPrintCenter 是否是新的打印中心,默认false
139
- * @returns
140
- */
141
- export declare const printView: (templateNo: string, reqUrl: string, bodyParam?: any, param?: any, method?: 'POST' | 'GET', isNewPrintCenter?: boolean) => any;
142
- /**
143
- * 直接打印,通过打印组件进行打印。
144
- *
145
- * @param taskName 打印任务名
146
- * @param templateNo 打印模板
147
- * @param reqUrl 业务请求api
148
- * @param bodyParam Post传参数
149
- * @param param Get传参数
150
- * @param method 请求方式,默认post
151
- * @returns
152
- */
153
- export declare const printAsync: (taskName: string, templateNo: string, reqUrl: string, bodyParam?: any, param?: any, method?: 'POST' | 'GET', isNewPrintCenter?: boolean) => Promise<any>;
154
- export declare const isDev: boolean;
155
- export declare type UserType = {
156
- id?: string;
157
- userId?: string;
158
- userName?: string;
159
- loginName?: string;
160
- companyId?: string;
161
- companyCode?: string;
162
- companyName?: string;
163
- email?: string;
164
- employeeAttr?: string;
165
- expireTime?: string;
166
- icon?: string;
167
- idCard?: string;
168
- ifAdmin?: number | string;
169
- orgId?: string;
170
- orgParentIds?: string;
171
- phoneNumber?: string;
172
- remarks?: string;
173
- };
174
- /** @name 用户信息 */
175
- export declare const getUserInfo: () => UserType | null;
176
- /** @name 用户名 */
177
- export declare const getUserName: () => string | undefined;
178
- /** @name 登录名 */
179
- export declare const getLoginName: () => string | undefined;
180
- /** @name 公司Id */
181
- export declare const getCompanyId: () => string | undefined;
182
- /**
183
- * 判断是否是微前端子应用
184
- *
185
- * @returns String | undefined
186
- */
187
- export declare const isQiankunSubApp: () => any;
188
- /** @name 微前端原生路径 */
189
- export declare const appPath: (path?: string) => any;
190
41
  /**
191
42
  * 深度复制对象
192
43
  *
@@ -194,21 +45,6 @@ export declare const appPath: (path?: string) => any;
194
45
  * @returns
195
46
  */
196
47
  export declare const deepClone: (obj: any) => any;
197
- /**
198
- * 在主工程中打开模块
199
- *
200
- * @param option {path:模块路由,需要加工程编码, resourceId: 资源Id,两者传一个即可,data:参数,moduleName:模块名称}
201
- */
202
- export declare const openPageInMain: (option: {
203
- [key: string]: any;
204
- path?: string | undefined;
205
- resourceId?: string | undefined;
206
- data?: any;
207
- ifRefreshTarget?: boolean | undefined;
208
- moduleName?: string | undefined;
209
- }) => void;
210
- /** 处理主题 */
211
- export declare const handleTheme: () => void;
212
48
  /**
213
49
  * 睡眠
214
50
  *
@@ -231,10 +67,3 @@ export declare const urlDownloadDomain: (url: string) => string;
231
67
  * @param isBlank 是否新开窗口下载,默认新开窗口,不影响原页面展示
232
68
  */
233
69
  export declare const downloadFile: (url: string, fileName?: string | undefined, isBlank?: boolean) => void;
234
- /**
235
- * 微前端主工程注入子工程时,子工程调用此方法设置资源Id,权限等参数
236
- *
237
- * @param props
238
- */
239
- export declare const setCurrentResCode: (props: any) => void;
240
- export declare const isDingtalk: boolean;