ls-pro-common 3.0.88 → 3.0.90

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.
@@ -0,0 +1,60 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import { getDict } from '../http';
4
+ import { useEffect, useState } from 'react';
5
+ /** Value转换数字 */
6
+ var transformNum = function transformNum(options) {
7
+ return options.map(function (v) {
8
+ return _objectSpread(_objectSpread({}, v), {}, {
9
+ value: Number(v.value)
10
+ });
11
+ });
12
+ };
13
+ /**
14
+ * 获取字典
15
+ *
16
+ * @param dicts 字典列表
17
+ * @param type 字典类型 默认 tenant
18
+ */
19
+ export function useDict(dicts) {
20
+ var _useState = useState({}),
21
+ _useState2 = _slicedToArray(_useState, 2),
22
+ dictList = _useState2[0],
23
+ setDictList = _useState2[1];
24
+ useEffect(function () {
25
+ var keys = Object.keys(dicts);
26
+ var pList = [];
27
+ var result = {};
28
+ keys.forEach(function (k) {
29
+ if (typeof dicts[k] === 'string') {
30
+ pList.push(getDict(dicts[k]));
31
+ } else if (typeof dicts[k] === 'function') {
32
+ var fn = dicts[k];
33
+ pList.push(fn());
34
+ } else {
35
+ var _dicts$k = dicts[k],
36
+ dict = _dicts$k.dict,
37
+ showValue = _dicts$k.showValue,
38
+ isValNum = _dicts$k.isValNum,
39
+ _dicts$k$transform = _dicts$k.transform,
40
+ transform = _dicts$k$transform === void 0 ? function (d) {
41
+ return d;
42
+ } : _dicts$k$transform;
43
+ var _transform = transform;
44
+ if (isValNum) _transform = transformNum;
45
+ pList.push(getDict(dict, showValue).then(_transform));
46
+ }
47
+ });
48
+ Promise.allSettled(pList).then(function (res) {
49
+ res.forEach(function (v, i) {
50
+ if (v.status === 'fulfilled') {
51
+ result[keys[i]] = v.value;
52
+ } else {
53
+ result[keys[i]] = [];
54
+ }
55
+ });
56
+ setDictList(result);
57
+ });
58
+ }, []);
59
+ return dictList;
60
+ }
package/lib/http/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
4
  import { extend } from 'umi-request';
@@ -15,6 +16,7 @@ var httpStatus = {
15
16
  };
16
17
  /** 请求拦截器,统一添加token */
17
18
  request.interceptors.request.use(function (url, options) {
19
+ var _options$params;
18
20
  var token = getCookie('token');
19
21
  options.headers = options.headers || {};
20
22
  // 处理 token
@@ -47,12 +49,14 @@ request.interceptors.request.use(function (url, options) {
47
49
  }
48
50
 
49
51
  url = url.replace('&noToken=1', '').replace('noToken=1', '');
52
+ var resCode = getUrlQuery('resCode', url) || getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId');
50
53
  var param = {
51
- resCode: getUrlQuery('resCode', url) || getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId'),
52
54
  _t1: Date.now()
53
55
  };
54
- if (!param.resCode) {
55
- delete param.resCode;
56
+ // 当没有明文参数resCode的时候,添加resCode参数为资源Id
57
+ //@ts-ignore
58
+ if (resCode && !((_options$params = options.params) === null || _options$params === void 0 ? void 0 : _options$params.resCode)) {
59
+ param.resCode = resCode;
56
60
  }
57
61
  url = setUrlQuery(url, param);
58
62
  return {
@@ -204,7 +208,9 @@ function ajax(url) {
204
208
  timeout: timeout,
205
209
  requestType: isJson ? 'json' : 'form'
206
210
  }).finally(function () {
207
- return exitLoading();
211
+ if (loadText) {
212
+ exitLoading();
213
+ }
208
214
  });
209
215
  }
210
216
  }
@@ -322,12 +328,11 @@ function _fetchOptions() {
322
328
  _yield$httpGet$rows = _yield$httpGet.rows;
323
329
  rows = _yield$httpGet$rows === void 0 ? [] : _yield$httpGet$rows;
324
330
  data = (rows || []).map(function (o) {
325
- return {
331
+ return _objectSpread(_objectSpread({}, o), {}, {
326
332
  value: o[valueField],
327
333
  text: o[labelField],
328
- label: (showValue ? o[valueField] + '→' : '') + o[labelField],
329
- status: o.status
330
- };
334
+ label: (showValue ? o[valueField] + '→' : '') + o[labelField]
335
+ });
331
336
  });
332
337
  return _context2.abrupt("return", data);
333
338
  case 10:
package/lib/index.d.ts CHANGED
@@ -31,10 +31,12 @@ import useBaseDict from './hooks/useBaseDict';
31
31
  import useSelectOptions from './hooks/useSelectOptions';
32
32
  import showConfirmFun from './hooks/useShowConfirm';
33
33
  import useQueue from './hooks/useQueue';
34
+ import { useDict } from './hooks/useDict';
34
35
  /** Type */
35
36
  import type { ApiResponse, TableToolbar, BaseApiType, MethodType } from './typing';
36
37
  import type { DtlLyaoutProps } from './components/DtlLayout';
37
38
  import type { DescritionCardProps } from './components/DescritionCard';
38
39
  import type { PermissionProps } from './components/Permission';
39
- export type { ApiResponse, TableToolbar, BaseApiType, MethodType, DtlLyaoutProps, DescritionCardProps, PermissionProps, };
40
- export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, ViewOffice, IconBack, IconText, IconBell, IconQuestion, IconSearch, TagCheck, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue, useBaseDict, useSelectOptions, showConfirmFun, exportProcess, };
40
+ import type { TDict } from './hooks/useDict';
41
+ export type { ApiResponse, TableToolbar, BaseApiType, MethodType, DtlLyaoutProps, DescritionCardProps, PermissionProps, TDict, };
42
+ export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, ViewOffice, IconBack, IconText, IconBell, IconQuestion, IconSearch, TagCheck, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue, useBaseDict, useSelectOptions, useDict, showConfirmFun, exportProcess, };
package/lib/index.js CHANGED
@@ -31,4 +31,5 @@ import useBaseDict from './hooks/useBaseDict';
31
31
  import useSelectOptions from './hooks/useSelectOptions';
32
32
  import showConfirmFun from './hooks/useShowConfirm';
33
33
  import useQueue from './hooks/useQueue';
34
- export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, ViewOffice, IconBack, IconText, IconBell, IconQuestion, IconSearch, TagCheck, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue, useBaseDict, useSelectOptions, showConfirmFun, exportProcess };
34
+ import { useDict } from './hooks/useDict';
35
+ export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, ViewOffice, IconBack, IconText, IconBell, IconQuestion, IconSearch, TagCheck, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue, useBaseDict, useSelectOptions, useDict, showConfirmFun, exportProcess };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ls-pro-common",
3
- "version": "3.0.88",
3
+ "version": "3.0.90",
4
4
  "description": "ls-pro-common",
5
5
  "license": "MIT",
6
6
  "sideEffects": [