ls-pro-common 3.1.19 → 3.1.21

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.
@@ -48,7 +48,7 @@ export declare type InputTableProps = ProFormItemProps<InputProps> & {
48
48
  /** @name 选择行事件 */
49
49
  onSelectChange?: (item: any, formRef?: any) => void;
50
50
  /** @name 加载之前事件,param为查询条件对象,可以通过此方法调整 */
51
- beforeLoad?: (param: any) => any;
51
+ beforeLoad?: (param: any) => Promise<any> | any;
52
52
  /** @name 加载之后事件,row为接口返回数据,可以通过此方法调整 */
53
53
  afterLoad?: (rows: any[]) => void;
54
54
  getPopupContainer?: (triggerNode: any) => HTMLElement;
@@ -94,7 +94,7 @@ declare const InputTable: React.ForwardRefExoticComponent<{
94
94
  /** @name 填充其它表单项目配置 */
95
95
  fillMap?: Record<string, string> | undefined;
96
96
  /** @name 输入后检查数据的触发方式,默认为entry回车触发 */
97
- triggerCheck?: "none" | "entry" | "blur" | undefined;
97
+ triggerCheck?: "none" | "blur" | "entry" | undefined;
98
98
  /** @name 每次展示面板时都加载数据,接合 tableConfig里的 manualRequest 一起使用 */
99
99
  loadOnShow?: boolean | undefined;
100
100
  placement?: TooltipPlacement | undefined;
@@ -108,7 +108,7 @@ declare const InputTable: React.ForwardRefExoticComponent<{
108
108
  /** @name 选择行事件 */
109
109
  onSelectChange?: ((item: any, formRef?: any) => void) | undefined;
110
110
  /** @name 加载之前事件,param为查询条件对象,可以通过此方法调整 */
111
- beforeLoad?: ((param: any) => any) | undefined;
111
+ beforeLoad?: ((param: any) => Promise<any> | any) | undefined;
112
112
  /** @name 加载之后事件,row为接口返回数据,可以通过此方法调整 */
113
113
  afterLoad?: ((rows: any[]) => void) | undefined;
114
114
  getPopupContainer?: ((triggerNode: any) => HTMLElement) | undefined;
@@ -184,28 +184,34 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
184
184
  selectRowRef.current = [];
185
185
  (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : (_tableRef$current2$cl = _tableRef$current2.clearSelected) === null || _tableRef$current2$cl === void 0 ? void 0 : _tableRef$current2$cl.call(_tableRef$current2);
186
186
  }
187
- if (beforeLoad) {
188
- _param = beforeLoad(data);
189
- if (typeof _param !== 'boolean' && _param !== undefined) {
190
- data = _param;
191
- }
187
+ if (!beforeLoad) {
188
+ _context.next = 18;
189
+ break;
190
+ }
191
+ _context.next = 16;
192
+ return beforeLoad(data);
193
+ case 16:
194
+ _param = _context.sent;
195
+ if (typeof _param !== 'boolean' && _param !== undefined) {
196
+ data = _param;
192
197
  }
198
+ case 18:
193
199
  if (!(method !== 'GET')) {
194
- _context.next = 20;
200
+ _context.next = 24;
195
201
  break;
196
202
  }
197
- _context.next = 17;
203
+ _context.next = 21;
198
204
  return httpPost(url, data);
199
- case 17:
205
+ case 21:
200
206
  result = _context.sent;
201
- _context.next = 23;
207
+ _context.next = 27;
202
208
  break;
203
- case 20:
204
- _context.next = 22;
209
+ case 24:
210
+ _context.next = 26;
205
211
  return httpGet(url, data);
206
- case 22:
212
+ case 26:
207
213
  result = _context.sent;
208
- case 23:
214
+ case 27:
209
215
  rows = (result.rows || []).filter(function (o) {
210
216
  return o;
211
217
  });
@@ -238,7 +244,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
238
244
  total: Number(result.total || 0),
239
245
  success: true
240
246
  });
241
- case 27:
247
+ case 31:
242
248
  case "end":
243
249
  return _context.stop();
244
250
  }
@@ -1,6 +1,6 @@
1
1
  import { useMemo, useCallback, useEffect } from 'react';
2
2
  import { useLocation } from 'react-router-dom';
3
- import { getUrlQuery, getResourceProps, getCache, getLoginName, getCookie, setCookie } from '../../utils';
3
+ import { getUrlQuery, getResourceProps, getCache, getLoginName, getCookie, setCookie, setCache } from '../../utils';
4
4
  function usePermission() {
5
5
  var routeLocation = useLocation();
6
6
  /** @name 资源ID */
@@ -45,6 +45,24 @@ function usePermission() {
45
45
  if (getUrlQuery('token') && !getCookie('token')) {
46
46
  setCookie('token', getUrlQuery('token'));
47
47
  }
48
+ //从外部系统转token和用户进来。
49
+ var handleMessage = function handleMessage(e) {
50
+ if (e.data.type === 'FROM_OTHER_SYSTEM') {
51
+ var _e$data = e.data,
52
+ token = _e$data.token,
53
+ user = _e$data.user;
54
+ if (token && !getCookie('token')) {
55
+ setCookie('token', token);
56
+ }
57
+ if (user && !getCache('user')) {
58
+ setCache('user', user);
59
+ }
60
+ }
61
+ };
62
+ window.addEventListener('message', handleMessage);
63
+ return function () {
64
+ window.removeEventListener('message', handleMessage);
65
+ };
48
66
  }, []);
49
67
  return {
50
68
  resourceId: resourceId,
@@ -70,4 +70,5 @@ export declare function getDict(dictCodes: string, showValue?: boolean, needGate
70
70
  * @returns
71
71
  */
72
72
  export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean, needGateWay?: boolean, timeout?: number, isGet?: boolean, valueIsNumber?: boolean): Promise<any>;
73
+ export declare const checkResourceRight: (ids: string[]) => Promise<any>;
73
74
  export default request;
package/es/http/index.js CHANGED
@@ -469,4 +469,10 @@ function _fetchOptions() {
469
469
  }));
470
470
  return _fetchOptions.apply(this, arguments);
471
471
  }
472
+ export var checkResourceRight = function checkResourceRight(ids) {
473
+ var url = '/lesoon/lesoon-petrel-permission-api/sysUserRole/selectResourceIds';
474
+ return httpPost(url, {
475
+ resourceIds: ids
476
+ }, true, false);
477
+ };
472
478
  export default request;
@@ -176,6 +176,12 @@ export declare const getUserName: () => string | undefined;
176
176
  export declare const getLoginName: () => string | undefined;
177
177
  /** @name 公司Id */
178
178
  export declare const getCompanyId: () => string | undefined;
179
+ /**
180
+ * 判断是否是微前端子应用
181
+ *
182
+ * @returns String | undefined
183
+ */
184
+ export declare const isQiankunSubApp: () => any;
179
185
  /** @name 微前端原生路径 */
180
186
  export declare const appPath: (path?: string) => any;
181
187
  /**
package/es/utils/index.js CHANGED
@@ -392,13 +392,20 @@ export var getCompanyId = function getCompanyId() {
392
392
  var _getUserInfo3;
393
393
  return (_getUserInfo3 = getUserInfo()) === null || _getUserInfo3 === void 0 ? void 0 : _getUserInfo3.companyId;
394
394
  };
395
+ /**
396
+ * 判断是否是微前端子应用
397
+ *
398
+ * @returns String | undefined
399
+ */
400
+ export var isQiankunSubApp = function isQiankunSubApp() {
401
+ // @ts-ignore
402
+ return window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
403
+ };
395
404
  /** @name 微前端原生路径 */
396
405
  export var appPath = function appPath() {
397
406
  var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
398
- // @ts-ignore
399
- if (window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__) {
400
- // @ts-ignore
401
- return window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
407
+ if (isQiankunSubApp()) {
408
+ return isQiankunSubApp();
402
409
  }
403
410
  if (path) return path;
404
411
  //本地开发环境,判断是否hash路由,如果是hash路由,则返回./
@@ -48,7 +48,7 @@ export declare type InputTableProps = ProFormItemProps<InputProps> & {
48
48
  /** @name 选择行事件 */
49
49
  onSelectChange?: (item: any, formRef?: any) => void;
50
50
  /** @name 加载之前事件,param为查询条件对象,可以通过此方法调整 */
51
- beforeLoad?: (param: any) => any;
51
+ beforeLoad?: (param: any) => Promise<any> | any;
52
52
  /** @name 加载之后事件,row为接口返回数据,可以通过此方法调整 */
53
53
  afterLoad?: (rows: any[]) => void;
54
54
  getPopupContainer?: (triggerNode: any) => HTMLElement;
@@ -94,7 +94,7 @@ declare const InputTable: React.ForwardRefExoticComponent<{
94
94
  /** @name 填充其它表单项目配置 */
95
95
  fillMap?: Record<string, string> | undefined;
96
96
  /** @name 输入后检查数据的触发方式,默认为entry回车触发 */
97
- triggerCheck?: "none" | "entry" | "blur" | undefined;
97
+ triggerCheck?: "none" | "blur" | "entry" | undefined;
98
98
  /** @name 每次展示面板时都加载数据,接合 tableConfig里的 manualRequest 一起使用 */
99
99
  loadOnShow?: boolean | undefined;
100
100
  placement?: TooltipPlacement | undefined;
@@ -108,7 +108,7 @@ declare const InputTable: React.ForwardRefExoticComponent<{
108
108
  /** @name 选择行事件 */
109
109
  onSelectChange?: ((item: any, formRef?: any) => void) | undefined;
110
110
  /** @name 加载之前事件,param为查询条件对象,可以通过此方法调整 */
111
- beforeLoad?: ((param: any) => any) | undefined;
111
+ beforeLoad?: ((param: any) => Promise<any> | any) | undefined;
112
112
  /** @name 加载之后事件,row为接口返回数据,可以通过此方法调整 */
113
113
  afterLoad?: ((rows: any[]) => void) | undefined;
114
114
  getPopupContainer?: ((triggerNode: any) => HTMLElement) | undefined;
@@ -184,28 +184,34 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
184
184
  selectRowRef.current = [];
185
185
  (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : (_tableRef$current2$cl = _tableRef$current2.clearSelected) === null || _tableRef$current2$cl === void 0 ? void 0 : _tableRef$current2$cl.call(_tableRef$current2);
186
186
  }
187
- if (beforeLoad) {
188
- _param = beforeLoad(data);
189
- if (typeof _param !== 'boolean' && _param !== undefined) {
190
- data = _param;
191
- }
187
+ if (!beforeLoad) {
188
+ _context.next = 18;
189
+ break;
190
+ }
191
+ _context.next = 16;
192
+ return beforeLoad(data);
193
+ case 16:
194
+ _param = _context.sent;
195
+ if (typeof _param !== 'boolean' && _param !== undefined) {
196
+ data = _param;
192
197
  }
198
+ case 18:
193
199
  if (!(method !== 'GET')) {
194
- _context.next = 20;
200
+ _context.next = 24;
195
201
  break;
196
202
  }
197
- _context.next = 17;
203
+ _context.next = 21;
198
204
  return httpPost(url, data);
199
- case 17:
205
+ case 21:
200
206
  result = _context.sent;
201
- _context.next = 23;
207
+ _context.next = 27;
202
208
  break;
203
- case 20:
204
- _context.next = 22;
209
+ case 24:
210
+ _context.next = 26;
205
211
  return httpGet(url, data);
206
- case 22:
212
+ case 26:
207
213
  result = _context.sent;
208
- case 23:
214
+ case 27:
209
215
  rows = (result.rows || []).filter(function (o) {
210
216
  return o;
211
217
  });
@@ -238,7 +244,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
238
244
  total: Number(result.total || 0),
239
245
  success: true
240
246
  });
241
- case 27:
247
+ case 31:
242
248
  case "end":
243
249
  return _context.stop();
244
250
  }
@@ -1,6 +1,6 @@
1
1
  import { useMemo, useCallback, useEffect } from 'react';
2
2
  import { useLocation } from 'react-router-dom';
3
- import { getUrlQuery, getResourceProps, getCache, getLoginName, getCookie, setCookie } from '../../utils';
3
+ import { getUrlQuery, getResourceProps, getCache, getLoginName, getCookie, setCookie, setCache } from '../../utils';
4
4
  function usePermission() {
5
5
  var routeLocation = useLocation();
6
6
  /** @name 资源ID */
@@ -45,6 +45,24 @@ function usePermission() {
45
45
  if (getUrlQuery('token') && !getCookie('token')) {
46
46
  setCookie('token', getUrlQuery('token'));
47
47
  }
48
+ //从外部系统转token和用户进来。
49
+ var handleMessage = function handleMessage(e) {
50
+ if (e.data.type === 'FROM_OTHER_SYSTEM') {
51
+ var _e$data = e.data,
52
+ token = _e$data.token,
53
+ user = _e$data.user;
54
+ if (token && !getCookie('token')) {
55
+ setCookie('token', token);
56
+ }
57
+ if (user && !getCache('user')) {
58
+ setCache('user', user);
59
+ }
60
+ }
61
+ };
62
+ window.addEventListener('message', handleMessage);
63
+ return function () {
64
+ window.removeEventListener('message', handleMessage);
65
+ };
48
66
  }, []);
49
67
  return {
50
68
  resourceId: resourceId,
@@ -70,4 +70,5 @@ export declare function getDict(dictCodes: string, showValue?: boolean, needGate
70
70
  * @returns
71
71
  */
72
72
  export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean, needGateWay?: boolean, timeout?: number, isGet?: boolean, valueIsNumber?: boolean): Promise<any>;
73
+ export declare const checkResourceRight: (ids: string[]) => Promise<any>;
73
74
  export default request;
package/lib/http/index.js CHANGED
@@ -469,4 +469,10 @@ function _fetchOptions() {
469
469
  }));
470
470
  return _fetchOptions.apply(this, arguments);
471
471
  }
472
+ export var checkResourceRight = function checkResourceRight(ids) {
473
+ var url = '/lesoon/lesoon-petrel-permission-api/sysUserRole/selectResourceIds';
474
+ return httpPost(url, {
475
+ resourceIds: ids
476
+ }, true, false);
477
+ };
472
478
  export default request;
@@ -176,6 +176,12 @@ export declare const getUserName: () => string | undefined;
176
176
  export declare const getLoginName: () => string | undefined;
177
177
  /** @name 公司Id */
178
178
  export declare const getCompanyId: () => string | undefined;
179
+ /**
180
+ * 判断是否是微前端子应用
181
+ *
182
+ * @returns String | undefined
183
+ */
184
+ export declare const isQiankunSubApp: () => any;
179
185
  /** @name 微前端原生路径 */
180
186
  export declare const appPath: (path?: string) => any;
181
187
  /**
@@ -392,13 +392,20 @@ export var getCompanyId = function getCompanyId() {
392
392
  var _getUserInfo3;
393
393
  return (_getUserInfo3 = getUserInfo()) === null || _getUserInfo3 === void 0 ? void 0 : _getUserInfo3.companyId;
394
394
  };
395
+ /**
396
+ * 判断是否是微前端子应用
397
+ *
398
+ * @returns String | undefined
399
+ */
400
+ export var isQiankunSubApp = function isQiankunSubApp() {
401
+ // @ts-ignore
402
+ return window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
403
+ };
395
404
  /** @name 微前端原生路径 */
396
405
  export var appPath = function appPath() {
397
406
  var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
398
- // @ts-ignore
399
- if (window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__) {
400
- // @ts-ignore
401
- return window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
407
+ if (isQiankunSubApp()) {
408
+ return isQiankunSubApp();
402
409
  }
403
410
  if (path) return path;
404
411
  //本地开发环境,判断是否hash路由,如果是hash路由,则返回./
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ls-pro-common",
3
- "version": "3.1.19",
3
+ "version": "3.1.21",
4
4
  "description": "ls-pro-common",
5
5
  "license": "MIT",
6
6
  "sideEffects": [