ls-pro-common 1.0.4 → 1.0.8

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.
Files changed (40) hide show
  1. package/dist/common.css +2276 -0
  2. package/dist/common.js +1 -1
  3. package/dist/common.less +1 -0
  4. package/dist/common.min.css +2276 -0
  5. package/dist/common.min.js +1 -1
  6. package/es/components/DtlLayout.d.ts +20 -0
  7. package/es/components/DtlLayout.js +64 -0
  8. package/es/components/InputTable.d.ts +18 -0
  9. package/es/components/InputTable.js +225 -0
  10. package/es/components/common.less +64 -0
  11. package/es/hooks/useDtl/index.d.ts +29 -0
  12. package/es/hooks/useDtl/index.js +654 -0
  13. package/es/hooks/useSingle/index.d.ts +19 -7
  14. package/es/hooks/useSingle/index.js +282 -85
  15. package/es/http/index.d.ts +1 -1
  16. package/es/http/index.js +7 -3
  17. package/es/index.d.ts +6 -3
  18. package/es/index.js +4 -2
  19. package/es/utils/index.d.ts +45 -1
  20. package/es/utils/index.js +90 -1
  21. package/lib/components/DtlLayout.d.ts +20 -0
  22. package/lib/components/DtlLayout.js +81 -0
  23. package/lib/components/InputTable.d.ts +18 -0
  24. package/lib/components/InputTable.js +254 -0
  25. package/lib/components/common.less +64 -0
  26. package/lib/hooks/useDtl/index.d.ts +29 -0
  27. package/lib/hooks/useDtl/index.js +675 -0
  28. package/lib/hooks/useSingle/index.d.ts +19 -7
  29. package/lib/hooks/useSingle/index.js +283 -86
  30. package/lib/http/index.d.ts +1 -1
  31. package/lib/http/index.js +7 -3
  32. package/lib/index.d.ts +6 -3
  33. package/lib/index.js +20 -4
  34. package/lib/utils/index.d.ts +45 -1
  35. package/lib/utils/index.js +114 -3
  36. package/package.json +3 -3
  37. package/es/components/EditModalForm.d.ts +0 -5
  38. package/es/components/EditModalForm.js +0 -29
  39. package/lib/components/EditModalForm.d.ts +0 -5
  40. package/lib/components/EditModalForm.js +0 -42
@@ -6,6 +6,13 @@ export declare const getUrlQuery: (name: string, url?: string) => string;
6
6
  * @returns
7
7
  */
8
8
  export declare const setUrlQuery: (url: string, keyvals?: Record<string, any>) => string;
9
+ /**
10
+ * 给 url 添加网关
11
+ * @param url 原url,以 / 打头
12
+ * @param defGateway 默认网关 /petrel
13
+ * @returns
14
+ */
15
+ export declare const toGatewayUrl: (url: string, defGateway?: string) => string;
9
16
  /**
10
17
  * 设置文档title
11
18
  * @param {*} title
@@ -41,7 +48,7 @@ export declare const setCache: (key: string, data: any) => void;
41
48
  * @param { String } key 关键字
42
49
  * @returns 关键字对应的值
43
50
  */
44
- export declare const getCache: (key: string) => string | null;
51
+ export declare const getCache: any;
45
52
  /**
46
53
  * 简单日期格式化
47
54
  * @param {*} dt 传入时间参数,若不传取当前时间
@@ -78,3 +85,40 @@ export declare const yesnoList: {
78
85
  text: string;
79
86
  label: string;
80
87
  }[];
88
+ /**
89
+ * 遍历树
90
+ * @param list 树对象
91
+ * @param fn 回调函数
92
+ * @param children 树属性字段
93
+ */
94
+ export declare const treeEach: (list: any[], fn: (item: any, index: any, list: any[]) => void, children?: string) => void;
95
+ /**
96
+ * 查询数
97
+ * @param list 树对象
98
+ * @param key 查询属性
99
+ * @param val 查询值
100
+ * @param children 树属性字段
101
+ * @returns 返回符合条件的第一条对象
102
+ */
103
+ export declare const treeFind: (list: any[], key: string, val: any, children?: string) => any;
104
+ export declare type UserType = {
105
+ id?: string;
106
+ userId?: string;
107
+ userName?: string;
108
+ loginName?: string;
109
+ companyId?: string;
110
+ email?: string;
111
+ employeeAttr?: string;
112
+ expireTime?: string;
113
+ icon?: string;
114
+ idCard?: string;
115
+ ifAdmin?: number | string;
116
+ orgId?: string;
117
+ orgParentIds?: string;
118
+ phoneNumber?: string;
119
+ remarks?: string;
120
+ };
121
+ export declare const getUserInfo: () => UserType | null;
122
+ export declare const getUserName: () => string | undefined;
123
+ export declare const getLoginName: () => string | undefined;
124
+ export declare const getCompanyId: () => string | undefined;
@@ -5,7 +5,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.yesnoList = exports.statusList = exports.showWarn = exports.showSuccess = exports.showError = exports.showConfirm = exports.setUrlQuery = exports.setTitle = exports.setCookie = exports.setCache = exports.rangeToSearch = exports.isLogin = exports.getUrlQuery = exports.getCookie = exports.getCache = exports.dateFormat = void 0;
8
+ exports.yesnoList = exports.treeFind = exports.treeEach = exports.toGatewayUrl = exports.statusList = exports.showWarn = exports.showSuccess = exports.showError = exports.showConfirm = exports.setUrlQuery = exports.setTitle = exports.setCookie = exports.setCache = exports.rangeToSearch = exports.isLogin = exports.getUserName = exports.getUserInfo = exports.getUrlQuery = exports.getLoginName = exports.getCookie = exports.getCompanyId = exports.getCache = exports.dateFormat = void 0;
9
+
10
+ var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
9
11
 
10
12
  require("antd/es/modal/style");
11
13
 
@@ -56,6 +58,22 @@ var setUrlQuery = function setUrlQuery(url) {
56
58
 
57
59
  return newUrl;
58
60
  };
61
+ /**
62
+ * 给 url 添加网关
63
+ * @param url 原url,以 / 打头
64
+ * @param defGateway 默认网关 /petrel
65
+ * @returns
66
+ */
67
+
68
+
69
+ exports.setUrlQuery = setUrlQuery;
70
+
71
+ var toGatewayUrl = function toGatewayUrl(url) {
72
+ var defGateway = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '/petrel';
73
+ if (url.startsWith('http://') || url.startsWith('https://') || url.startsWith('//')) return url;
74
+ var gateway = getUrlQuery('gateway') || location.origin + defGateway;
75
+ return gateway + url;
76
+ };
59
77
  /**
60
78
  * 设置文档title
61
79
  * @param {*} title
@@ -63,7 +81,7 @@ var setUrlQuery = function setUrlQuery(url) {
63
81
  */
64
82
 
65
83
 
66
- exports.setUrlQuery = setUrlQuery;
84
+ exports.toGatewayUrl = toGatewayUrl;
67
85
 
68
86
  var setTitle = function setTitle(title) {
69
87
  if (!title) return;
@@ -261,4 +279,97 @@ var yesnoList = [{
261
279
  text: '否',
262
280
  label: '0→否'
263
281
  }];
264
- exports.yesnoList = yesnoList;
282
+ /**
283
+ * 遍历树
284
+ * @param list 树对象
285
+ * @param fn 回调函数
286
+ * @param children 树属性字段
287
+ */
288
+
289
+ exports.yesnoList = yesnoList;
290
+
291
+ var treeEach = function treeEach(list, fn) {
292
+ var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "children";
293
+ list.forEach(function (item, index) {
294
+ fn(item, index, list); // @ts-ignore
295
+
296
+ if (Array.isArray(list[children]) && list[children].length) {
297
+ // @ts-ignore
298
+ treeEach(list[children], fn, children);
299
+ }
300
+ });
301
+ };
302
+ /**
303
+ * 查询数
304
+ * @param list 树对象
305
+ * @param key 查询属性
306
+ * @param val 查询值
307
+ * @param children 树属性字段
308
+ * @returns 返回符合条件的第一条对象
309
+ */
310
+
311
+
312
+ exports.treeEach = treeEach;
313
+
314
+ var treeFind = function treeFind(list, key, val) {
315
+ var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "children";
316
+ var item = null;
317
+
318
+ var _iterator = (0, _createForOfIteratorHelper2.default)(list),
319
+ _step;
320
+
321
+ try {
322
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
323
+ var row = _step.value;
324
+
325
+ if (row[key] === val) {
326
+ item = row;
327
+ break;
328
+ } else if (row[children] && row[children].length) {
329
+ item = treeFind(row[children], key, val);
330
+
331
+ if (item) {
332
+ break;
333
+ }
334
+ }
335
+ }
336
+ } catch (err) {
337
+ _iterator.e(err);
338
+ } finally {
339
+ _iterator.f();
340
+ }
341
+
342
+ return item;
343
+ };
344
+
345
+ exports.treeFind = treeFind;
346
+
347
+ var getUserInfo = function getUserInfo() {
348
+ return getCache('user');
349
+ };
350
+
351
+ exports.getUserInfo = getUserInfo;
352
+
353
+ var getUserName = function getUserName() {
354
+ var _getUserInfo;
355
+
356
+ return (_getUserInfo = getUserInfo()) === null || _getUserInfo === void 0 ? void 0 : _getUserInfo.userName;
357
+ };
358
+
359
+ exports.getUserName = getUserName;
360
+
361
+ var getLoginName = function getLoginName() {
362
+ var _getUserInfo2;
363
+
364
+ return (_getUserInfo2 = getUserInfo()) === null || _getUserInfo2 === void 0 ? void 0 : _getUserInfo2.loginName;
365
+ };
366
+
367
+ exports.getLoginName = getLoginName;
368
+
369
+ var getCompanyId = function getCompanyId() {
370
+ var _getUserInfo3;
371
+
372
+ return (_getUserInfo3 = getUserInfo()) === null || _getUserInfo3 === void 0 ? void 0 : _getUserInfo3.companyId;
373
+ };
374
+
375
+ exports.getCompanyId = getCompanyId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ls-pro-common",
3
- "version": "1.0.4",
3
+ "version": "1.0.8",
4
4
  "description": "ls-pro-common",
5
5
  "keywords": [
6
6
  "antd",
@@ -28,8 +28,8 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "@ant-design/icons": "^4.3.0",
31
- "ls-pro-table": "2.62.11",
32
- "ls-pro-form": "1.52.15",
31
+ "ls-pro-table": "2.62.15",
32
+ "ls-pro-form": "1.52.19",
33
33
  "@babel/runtime": "^7.16.3",
34
34
  "classnames": "^2.2.6",
35
35
  "moment": "^2.27.0",
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import type { ModalFormProps } from 'ls-pro-form';
3
- export declare type EditModalFormProps<T = Record<string, any>> = ModalFormProps;
4
- declare function EditModalForm<T = Record<string, any>>({ labelWidth, ...rest }: EditModalFormProps<T>): JSX.Element;
5
- export default EditModalForm;
@@ -1,29 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["labelWidth"];
4
- import React from "react";
5
- import { ModalForm } from 'ls-pro-form';
6
-
7
- function EditModalForm(_ref) {
8
- var labelWidth = _ref.labelWidth,
9
- rest = _objectWithoutProperties(_ref, _excluded);
10
-
11
- var defProps = _objectSpread({
12
- layout: 'horizontal'
13
- }, rest);
14
-
15
- if (labelWidth) {
16
- defProps.labelCol = {
17
- flex: "0 0 ".concat(labelWidth, "px")
18
- };
19
- defProps.wrapperCol = {
20
- style: {
21
- maxWidth: 'calc(100% - 100px)'
22
- }
23
- };
24
- }
25
-
26
- return /*#__PURE__*/React.createElement(React.Fragment, null, rest.visible ? /*#__PURE__*/React.createElement(ModalForm, defProps) : null);
27
- }
28
-
29
- export default EditModalForm;
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import type { ModalFormProps } from 'ls-pro-form';
3
- export declare type EditModalFormProps<T = Record<string, any>> = ModalFormProps;
4
- declare function EditModalForm<T = Record<string, any>>({ labelWidth, ...rest }: EditModalFormProps<T>): JSX.Element;
5
- export default EditModalForm;
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
-
14
- var _react = _interopRequireDefault(require("react"));
15
-
16
- var _lsProForm = require("ls-pro-form");
17
-
18
- var _excluded = ["labelWidth"];
19
-
20
- function EditModalForm(_ref) {
21
- var labelWidth = _ref.labelWidth,
22
- rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
23
- var defProps = (0, _objectSpread2.default)({
24
- layout: 'horizontal'
25
- }, rest);
26
-
27
- if (labelWidth) {
28
- defProps.labelCol = {
29
- flex: "0 0 ".concat(labelWidth, "px")
30
- };
31
- defProps.wrapperCol = {
32
- style: {
33
- maxWidth: 'calc(100% - 100px)'
34
- }
35
- };
36
- }
37
-
38
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, rest.visible ? /*#__PURE__*/_react.default.createElement(_lsProForm.ModalForm, defProps) : null);
39
- }
40
-
41
- var _default = EditModalForm;
42
- exports.default = _default;