ls-pro-common 1.0.3 → 1.0.7

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,8 +1,8 @@
1
1
  import "antd/es/button/style";
2
2
  import _Button from "antd/es/button";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- import _regeneratorRuntime from "@babel/runtime/regenerator";
5
4
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
7
7
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
8
8
  var _excluded = ["current", "pageSize"];
@@ -13,15 +13,24 @@ import { showConfirm, showWarn, showSuccess } from '../../utils';
13
13
  /**
14
14
  * 单表基本增删改查 hooks
15
15
  * @param service 单表服务
16
- * @param toolbar 定义基础功能按钮
16
+ * @param toolConfig 定义基础功能按钮
17
17
  * @param initItem 对象初始值,新增时设置默认值
18
- * @param onBeforeSave 保存之前方法,开放给每个模块重写
19
18
  * @param onBeforeRemove 删除之前方法,开放给每个模块重写
20
19
  * @returns
21
20
  */
22
21
 
23
- function useSingle(service, toolConfig, initItem, beforeSave, beforeRemove) {
22
+ function useSingle(inParam) {
23
+ var service = inParam.service,
24
+ toolConfig = inParam.toolConfig,
25
+ initItem = inParam.initItem,
26
+ beforeLoad = inParam.beforeLoad,
27
+ beforeRemove = inParam.beforeRemove,
28
+ beforeAdd = inParam.beforeAdd,
29
+ beforeEdit = inParam.beforeEdit,
30
+ afterRemove = inParam.afterRemove,
31
+ afterSave = inParam.afterSave;
24
32
  /** @name 选中行数据 */
33
+
25
34
  var _useState = useState([]),
26
35
  _useState2 = _slicedToArray(_useState, 2),
27
36
  selectedRows = _useState2[0],
@@ -40,31 +49,118 @@ function useSingle(service, toolConfig, initItem, beforeSave, beforeRemove) {
40
49
  _useState6 = _slicedToArray(_useState5, 2),
41
50
  editItem = _useState6[0],
42
51
  setEditItem = _useState6[1];
43
- /** @name 表格ref */
52
+ /** @name 表格Ref */
44
53
 
45
54
 
46
55
  var tableRef = useRef();
47
- /** @name 查询表单ref */
56
+ /** @name 查询表单Ref */
48
57
 
49
58
  var formRef = useRef();
59
+ /**@name 编辑表单Ref */
60
+
61
+ var editFormRef = useRef();
50
62
  /** 新增按钮事件 */
51
63
 
52
- var onAdd = function onAdd() {
53
- setEditItem(initItem);
54
- setShowEdit(true);
55
- };
64
+ var onAdd = /*#__PURE__*/function () {
65
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
66
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
67
+ while (1) {
68
+ switch (_context.prev = _context.next) {
69
+ case 0:
70
+ _context.t0 = beforeAdd;
71
+
72
+ if (!_context.t0) {
73
+ _context.next = 6;
74
+ break;
75
+ }
76
+
77
+ _context.next = 4;
78
+ return beforeAdd(initItem);
79
+
80
+ case 4:
81
+ _context.t1 = _context.sent;
82
+ _context.t0 = _context.t1 === false;
83
+
84
+ case 6:
85
+ if (!_context.t0) {
86
+ _context.next = 8;
87
+ break;
88
+ }
89
+
90
+ return _context.abrupt("return");
91
+
92
+ case 8:
93
+ setEditItem(initItem);
94
+ setShowEdit(true);
95
+
96
+ case 10:
97
+ case "end":
98
+ return _context.stop();
99
+ }
100
+ }
101
+ }, _callee);
102
+ }));
103
+
104
+ return function onAdd() {
105
+ return _ref.apply(this, arguments);
106
+ };
107
+ }();
56
108
  /** 编辑按钮事件 */
57
109
 
58
110
 
59
- var onEdit = function onEdit() {
60
- if (!selectedRows.length) {
61
- showWarn('请先选择需要更改的数据');
62
- return;
63
- }
111
+ var onEdit = /*#__PURE__*/function () {
112
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
113
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
114
+ while (1) {
115
+ switch (_context2.prev = _context2.next) {
116
+ case 0:
117
+ if (selectedRows.length) {
118
+ _context2.next = 3;
119
+ break;
120
+ }
64
121
 
65
- setEditItem(selectedRows[0]);
66
- setShowEdit(true);
67
- };
122
+ showWarn('请先选择需要更改的数据');
123
+ return _context2.abrupt("return");
124
+
125
+ case 3:
126
+ _context2.t0 = beforeEdit;
127
+
128
+ if (!_context2.t0) {
129
+ _context2.next = 9;
130
+ break;
131
+ }
132
+
133
+ _context2.next = 7;
134
+ return beforeEdit(selectedRows[0]);
135
+
136
+ case 7:
137
+ _context2.t1 = _context2.sent;
138
+ _context2.t0 = _context2.t1 === false;
139
+
140
+ case 9:
141
+ if (!_context2.t0) {
142
+ _context2.next = 11;
143
+ break;
144
+ }
145
+
146
+ return _context2.abrupt("return");
147
+
148
+ case 11:
149
+ setEditItem(selectedRows[0]);
150
+ setShowEdit(true);
151
+
152
+ case 13:
153
+ case "end":
154
+ return _context2.stop();
155
+ }
156
+ }
157
+ }, _callee2);
158
+ }));
159
+
160
+ return function onEdit() {
161
+ return _ref2.apply(this, arguments);
162
+ };
163
+ }();
68
164
  /** 删除按钮事件 */
69
165
 
70
166
 
@@ -74,67 +170,103 @@ function useSingle(service, toolConfig, initItem, beforeSave, beforeRemove) {
74
170
  return;
75
171
  }
76
172
 
77
- showConfirm('确认要删除选择的数据?').then(function () {
78
- var ids = selectedRows.map(function (o) {
79
- return o.id;
80
- });
81
- service.remove(ids).then(function (result) {
82
- var _result$flag;
173
+ showConfirm('确认要删除选择的数据?').then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
174
+ var _result$flag;
175
+
176
+ var ids, result;
177
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
178
+ while (1) {
179
+ switch (_context3.prev = _context3.next) {
180
+ case 0:
181
+ if (!beforeRemove) {
182
+ _context3.next = 6;
183
+ break;
184
+ }
185
+
186
+ _context3.next = 3;
187
+ return beforeRemove(selectedRows);
188
+
189
+ case 3:
190
+ ids = _context3.sent;
191
+
192
+ if (!(ids === false)) {
193
+ _context3.next = 6;
194
+ break;
195
+ }
196
+
197
+ return _context3.abrupt("return");
198
+
199
+ case 6:
200
+ if (!ids) {
201
+ ids = selectedRows.map(function (o) {
202
+ return o.id;
203
+ });
204
+ }
205
+
206
+ _context3.next = 9;
207
+ return service.remove(ids);
208
+
209
+ case 9:
210
+ result = _context3.sent;
211
+
212
+ if (!afterRemove) {
213
+ _context3.next = 13;
214
+ break;
215
+ }
216
+
217
+ afterRemove(result, selectedRows);
218
+ return _context3.abrupt("return");
83
219
 
84
- if ((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0') {
85
- showSuccess(result.flag.retMsg);
220
+ case 13:
221
+ if ((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0') {
222
+ showSuccess(result.flag.retMsg);
86
223
 
87
- if (tableRef.current) {
88
- tableRef.current.reload(false);
224
+ if (tableRef.current) {
225
+ tableRef.current.reload(false);
226
+ }
227
+ }
228
+
229
+ case 14:
230
+ case "end":
231
+ return _context3.stop();
89
232
  }
90
233
  }
91
- });
92
- });
234
+ }, _callee3);
235
+ })));
93
236
  };
94
237
  /** 新增,更改对应的保存事件 */
95
238
 
96
239
 
97
240
  var onSave = /*#__PURE__*/function () {
98
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(formData) {
241
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(formData) {
99
242
  var _result$flag2;
100
243
 
101
244
  var data, result;
102
- return _regeneratorRuntime.wrap(function _callee$(_context) {
245
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
103
246
  while (1) {
104
- switch (_context.prev = _context.next) {
247
+ switch (_context4.prev = _context4.next) {
105
248
  case 0:
106
249
  data = _objectSpread(_objectSpread({}, editItem), formData);
107
- _context.t0 = beforeSave;
108
-
109
- if (!_context.t0) {
110
- _context.next = 7;
111
- break;
112
- }
113
-
114
- _context.next = 5;
115
- return beforeSave(data);
250
+ _context4.next = 3;
251
+ return service.save(data);
116
252
 
117
- case 5:
118
- _context.t1 = _context.sent;
119
- _context.t0 = _context.t1 === false;
253
+ case 3:
254
+ result = _context4.sent;
120
255
 
121
- case 7:
122
- if (!_context.t0) {
123
- _context.next = 9;
256
+ if (!afterSave) {
257
+ _context4.next = 8;
124
258
  break;
125
259
  }
126
260
 
127
- return _context.abrupt("return", false);
261
+ _context4.next = 7;
262
+ return afterSave(result, data);
128
263
 
129
- case 9:
130
- _context.next = 11;
131
- return service.save(data);
132
-
133
- case 11:
134
- result = _context.sent;
264
+ case 7:
265
+ return _context4.abrupt("return", _context4.sent);
135
266
 
267
+ case 8:
136
268
  if (!((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retCode) === '0')) {
137
- _context.next = 16;
269
+ _context4.next = 12;
138
270
  break;
139
271
  }
140
272
 
@@ -144,32 +276,32 @@ function useSingle(service, toolConfig, initItem, beforeSave, beforeRemove) {
144
276
  tableRef.current.reload(false);
145
277
  }
146
278
 
147
- return _context.abrupt("return", true);
279
+ return _context4.abrupt("return", true);
148
280
 
149
- case 16:
150
- return _context.abrupt("return", false);
281
+ case 12:
282
+ return _context4.abrupt("return", false);
151
283
 
152
- case 17:
284
+ case 13:
153
285
  case "end":
154
- return _context.stop();
286
+ return _context4.stop();
155
287
  }
156
288
  }
157
- }, _callee);
289
+ }, _callee4);
158
290
  }));
159
291
 
160
292
  return function onSave(_x) {
161
- return _ref.apply(this, arguments);
293
+ return _ref4.apply(this, arguments);
162
294
  };
163
295
  }();
164
296
  /** 加载数据方法 */
165
297
 
166
298
 
167
299
  var onLoad = /*#__PURE__*/function () {
168
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params, sort, filter) {
169
- var current, pageSize, rest, param, result;
170
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
300
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(params, sort, filter) {
301
+ var current, pageSize, rest, param, key, result;
302
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
171
303
  while (1) {
172
- switch (_context2.prev = _context2.next) {
304
+ switch (_context5.prev = _context5.next) {
173
305
  case 0:
174
306
  current = params.current, pageSize = params.pageSize, rest = _objectWithoutProperties(params, _excluded);
175
307
  param = {};
@@ -179,37 +311,69 @@ function useSingle(service, toolConfig, initItem, beforeSave, beforeRemove) {
179
311
  param.pageSize = pageSize;
180
312
  }
181
313
 
314
+ for (key in rest) {
315
+ if (rest[key] === '') {
316
+ delete rest[key];
317
+ }
318
+ }
319
+
182
320
  if (Object.keys(rest).length) {
183
321
  param.where = rest;
184
322
  }
185
323
 
186
- console.log("useSingle", param, sort, filter);
187
- _context2.next = 7;
324
+ _context5.t0 = beforeLoad;
325
+
326
+ if (!_context5.t0) {
327
+ _context5.next = 11;
328
+ break;
329
+ }
330
+
331
+ _context5.next = 9;
332
+ return beforeLoad(param);
333
+
334
+ case 9:
335
+ _context5.t1 = _context5.sent;
336
+ _context5.t0 = _context5.t1 === false;
337
+
338
+ case 11:
339
+ if (!_context5.t0) {
340
+ _context5.next = 13;
341
+ break;
342
+ }
343
+
344
+ return _context5.abrupt("return", {
345
+ data: [],
346
+ success: false,
347
+ total: 0
348
+ });
349
+
350
+ case 13:
351
+ _context5.next = 15;
188
352
  return service.load(param);
189
353
 
190
- case 7:
191
- result = _context2.sent;
354
+ case 15:
355
+ result = _context5.sent;
192
356
  result.data = result.rows;
193
357
  result.success = true;
194
- return _context2.abrupt("return", result);
358
+ return _context5.abrupt("return", result);
195
359
 
196
- case 11:
360
+ case 19:
197
361
  case "end":
198
- return _context2.stop();
362
+ return _context5.stop();
199
363
  }
200
364
  }
201
- }, _callee2);
365
+ }, _callee5);
202
366
  }));
203
367
 
204
368
  return function onLoad(_x2, _x3, _x4) {
205
- return _ref2.apply(this, arguments);
369
+ return _ref5.apply(this, arguments);
206
370
  };
207
371
  }();
208
372
 
209
- var baseToolBar = [];
373
+ var tableTools = [];
210
374
 
211
375
  if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) {
212
- baseToolBar.push( /*#__PURE__*/React.createElement(_Button, {
376
+ tableTools.push( /*#__PURE__*/React.createElement(_Button, {
213
377
  key: "add",
214
378
  onClick: onAdd,
215
379
  icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
@@ -217,16 +381,16 @@ function useSingle(service, toolConfig, initItem, beforeSave, beforeRemove) {
217
381
  }
218
382
 
219
383
  if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) {
220
- baseToolBar.push( /*#__PURE__*/React.createElement(_Button, {
384
+ tableTools.push( /*#__PURE__*/React.createElement(_Button, {
221
385
  key: "edit",
222
- disabled: selectedRows.length === 0,
386
+ disabled: selectedRows.length !== 1,
223
387
  onClick: onEdit,
224
388
  icon: /*#__PURE__*/React.createElement(EditOutlined, null)
225
389
  }, "\u7F16\u8F91"));
226
390
  }
227
391
 
228
392
  if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) {
229
- baseToolBar.push( /*#__PURE__*/React.createElement(_Button, {
393
+ tableTools.push( /*#__PURE__*/React.createElement(_Button, {
230
394
  key: "remove",
231
395
  onClick: onRemove,
232
396
  danger: true,
@@ -236,14 +400,14 @@ function useSingle(service, toolConfig, initItem, beforeSave, beforeRemove) {
236
400
  }
237
401
 
238
402
  if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) {
239
- baseToolBar.push( /*#__PURE__*/React.createElement(_Button, {
403
+ tableTools.push( /*#__PURE__*/React.createElement(_Button, {
240
404
  key: "import",
241
405
  icon: /*#__PURE__*/React.createElement(ImportOutlined, null)
242
406
  }, "\u5BFC\u5165"));
243
407
  }
244
408
 
245
409
  if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) {
246
- baseToolBar.push( /*#__PURE__*/React.createElement(_Button, {
410
+ tableTools.push( /*#__PURE__*/React.createElement(_Button, {
247
411
  key: "export",
248
412
  icon: /*#__PURE__*/React.createElement(ExportOutlined, null)
249
413
  }, "\u5BFC\u51FA"));
@@ -251,11 +415,12 @@ function useSingle(service, toolConfig, initItem, beforeSave, beforeRemove) {
251
415
 
252
416
  return {
253
417
  formRef: formRef,
418
+ editFormRef: editFormRef,
254
419
  tableRef: tableRef,
255
420
  selectedRows: selectedRows,
256
421
  showEdit: showEdit,
257
422
  editItem: editItem,
258
- baseToolBar: baseToolBar,
423
+ tableTools: tableTools,
259
424
  setSelectedRows: setSelectedRows,
260
425
  setShowEdit: setShowEdit,
261
426
  setEditItem: setEditItem,
@@ -33,7 +33,7 @@ export declare function httpDelete(url: string, data: any): Promise<any>;
33
33
  * @param dictCode 字典编码
34
34
  * @returns Promise<Record<string,string>>
35
35
  */
36
- export declare function getDict(dictCode: string): Promise<any>;
36
+ export declare function getDict(dictCode: string, showValue?: boolean): Promise<any>;
37
37
  /**
38
38
  * 加载下拉框的数据源
39
39
  * @param url 后端接口
package/es/http/index.js CHANGED
@@ -234,11 +234,15 @@ export function getDict(_x8) {
234
234
 
235
235
  function _getDict() {
236
236
  _getDict = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(dictCode) {
237
- var api, param;
237
+ var showValue,
238
+ api,
239
+ param,
240
+ _args6 = arguments;
238
241
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
239
242
  while (1) {
240
243
  switch (_context6.prev = _context6.next) {
241
244
  case 0:
245
+ showValue = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : true;
242
246
  api = '/lesoon-integration/sysDictDtl';
243
247
  param = {
244
248
  where: {
@@ -246,9 +250,9 @@ function _getDict() {
246
250
  },
247
251
  ifPage: 0
248
252
  };
249
- return _context6.abrupt("return", fetchOptions(api, param, 'dictValue', 'displayName'));
253
+ return _context6.abrupt("return", fetchOptions(api, param, 'dictValue', 'displayName', showValue));
250
254
 
251
- case 3:
255
+ case 4:
252
256
  case "end":
253
257
  return _context6.stop();
254
258
  }
package/es/index.d.ts CHANGED
@@ -1,10 +1,12 @@
1
- import EditModalForm from './components/EditModalForm';
1
+ import DtlLayout from './components/DtlLayout';
2
2
  import BaseService from './service/BaseService';
3
3
  import request, { httpGet, httpPut, httpPost, httpDelete, getDict, fetchOptions } from './http';
4
4
  import * as utils from './utils';
5
5
  /** Hooks */
6
6
  import useSingle from './hooks/useSingle';
7
+ import useDtl from './hooks/useDtl';
7
8
  /** Type */
8
9
  import type { ApiResponse, TableToolbar, BaseApiType, MethodType } from './typing';
9
- export type { ApiResponse, TableToolbar, BaseApiType, MethodType };
10
- export { EditModalForm, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle };
10
+ import type { DtlLyaoutProps } from './components/DtlLayout';
11
+ export type { ApiResponse, TableToolbar, BaseApiType, MethodType, DtlLyaoutProps };
12
+ export { DtlLayout, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl };
package/es/index.js CHANGED
@@ -1,8 +1,9 @@
1
- import EditModalForm from './components/EditModalForm';
1
+ import DtlLayout from './components/DtlLayout';
2
2
  import BaseService from './service/BaseService';
3
3
  import request, { httpGet, httpPut, httpPost, httpDelete, getDict, fetchOptions } from './http';
4
4
  import * as utils from './utils';
5
5
  /** Hooks */
6
6
 
7
7
  import useSingle from './hooks/useSingle';
8
- export { EditModalForm, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle };
8
+ import useDtl from './hooks/useDtl';
9
+ export { DtlLayout, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl };
@@ -41,7 +41,7 @@ export declare const setCache: (key: string, data: any) => void;
41
41
  * @param { String } key 关键字
42
42
  * @returns 关键字对应的值
43
43
  */
44
- export declare const getCache: (key: string) => string | null;
44
+ export declare const getCache: any;
45
45
  /**
46
46
  * 简单日期格式化
47
47
  * @param {*} dt 传入时间参数,若不传取当前时间
@@ -78,3 +78,40 @@ export declare const yesnoList: {
78
78
  text: string;
79
79
  label: string;
80
80
  }[];
81
+ /**
82
+ * 遍历树
83
+ * @param list 树对象
84
+ * @param fn 回调函数
85
+ * @param children 树属性字段
86
+ */
87
+ export declare const treeEach: (list: any[], fn: (item: any, index: any, list: any[]) => void, children?: string) => void;
88
+ /**
89
+ * 查询数
90
+ * @param list 树对象
91
+ * @param key 查询属性
92
+ * @param val 查询值
93
+ * @param children 树属性字段
94
+ * @returns 返回符合条件的第一条对象
95
+ */
96
+ export declare const treeFind: (list: any[], key: string, val: any, children?: string) => any;
97
+ export declare type UserType = {
98
+ id?: string;
99
+ userId?: string;
100
+ userName?: string;
101
+ loginName?: string;
102
+ companyId?: string;
103
+ email?: string;
104
+ employeeAttr?: string;
105
+ expireTime?: string;
106
+ icon?: string;
107
+ idCard?: string;
108
+ ifAdmin?: number | string;
109
+ orgId?: string;
110
+ orgParentIds?: string;
111
+ phoneNumber?: string;
112
+ remarks?: string;
113
+ };
114
+ export declare const getUserInfo: () => UserType | null;
115
+ export declare const getUserName: () => string | undefined;
116
+ export declare const getLoginName: () => string | undefined;
117
+ export declare const getCompanyId: () => string | undefined;
package/es/utils/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
1
2
  import "antd/es/modal/style";
2
3
  import _Modal from "antd/es/modal";
3
4
  import "antd/es/message/style";
@@ -202,4 +203,79 @@ export var yesnoList = [{
202
203
  value: 0,
203
204
  text: '否',
204
205
  label: '0→否'
205
- }];
206
+ }];
207
+ /**
208
+ * 遍历树
209
+ * @param list 树对象
210
+ * @param fn 回调函数
211
+ * @param children 树属性字段
212
+ */
213
+
214
+ export var treeEach = function treeEach(list, fn) {
215
+ var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "children";
216
+ list.forEach(function (item, index) {
217
+ fn(item, index, list); // @ts-ignore
218
+
219
+ if (Array.isArray(list[children]) && list[children].length) {
220
+ // @ts-ignore
221
+ treeEach(list[children], fn, children);
222
+ }
223
+ });
224
+ };
225
+ /**
226
+ * 查询数
227
+ * @param list 树对象
228
+ * @param key 查询属性
229
+ * @param val 查询值
230
+ * @param children 树属性字段
231
+ * @returns 返回符合条件的第一条对象
232
+ */
233
+
234
+ export var treeFind = function treeFind(list, key, val) {
235
+ var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "children";
236
+ var item = null;
237
+
238
+ var _iterator = _createForOfIteratorHelper(list),
239
+ _step;
240
+
241
+ try {
242
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
243
+ var row = _step.value;
244
+
245
+ if (row[key] === val) {
246
+ item = row;
247
+ break;
248
+ } else if (row[children] && row[children].length) {
249
+ item = treeFind(row[children], key, val);
250
+
251
+ if (item) {
252
+ break;
253
+ }
254
+ }
255
+ }
256
+ } catch (err) {
257
+ _iterator.e(err);
258
+ } finally {
259
+ _iterator.f();
260
+ }
261
+
262
+ return item;
263
+ };
264
+ export var getUserInfo = function getUserInfo() {
265
+ return getCache('user');
266
+ };
267
+ export var getUserName = function getUserName() {
268
+ var _getUserInfo;
269
+
270
+ return (_getUserInfo = getUserInfo()) === null || _getUserInfo === void 0 ? void 0 : _getUserInfo.userName;
271
+ };
272
+ export var getLoginName = function getLoginName() {
273
+ var _getUserInfo2;
274
+
275
+ return (_getUserInfo2 = getUserInfo()) === null || _getUserInfo2 === void 0 ? void 0 : _getUserInfo2.loginName;
276
+ };
277
+ export var getCompanyId = function getCompanyId() {
278
+ var _getUserInfo3;
279
+
280
+ return (_getUserInfo3 = getUserInfo()) === null || _getUserInfo3 === void 0 ? void 0 : _getUserInfo3.companyId;
281
+ };