fan-standard-comp 4.1.0 → 4.1.2

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 (99) hide show
  1. package/dist/fan-standard-comp.min.css +1 -1
  2. package/dist/fan-standard-comp.min.js +1 -1
  3. package/es/ButtonGroup/index.d.ts +1 -0
  4. package/es/ButtonGroup/styles/index.js +3 -1
  5. package/es/FormComp/FieldComponent/ExtensionField.d.ts +3 -0
  6. package/es/FormComp/FieldComponent/ExtensionField.js +18 -0
  7. package/es/FormComp/FieldComponent/index.d.ts +10 -1
  8. package/es/FormComp/FieldComponent/index.js +123 -56
  9. package/es/FormComp/RenderItemGroup/index.js +38 -16
  10. package/es/FormComp/RenderItemGroup/style/index.js +6 -0
  11. package/es/NavLeafScroll/Main.js +2 -2
  12. package/es/RefactorTree/index.d.ts +1 -0
  13. package/es/RefactorTree/index.js +4 -2
  14. package/es/StandardDragModal/ChangeStandardModal.js +1 -1
  15. package/es/StandardFilter/index.js +12 -9
  16. package/es/StandardFilter/style/FilterStyle.js +13 -4
  17. package/es/StandardFilter/style/index.less +9 -2
  18. package/es/StandardForm/StepForm.js +1 -1
  19. package/es/StandardModal/index.js +1 -1
  20. package/es/StandardTable/index.d.ts +3 -2
  21. package/es/StandardTable/index.js +15 -8
  22. package/es/StandardTable/style/index.js +5 -0
  23. package/es/StandardTablePro/index.d.ts +9 -0
  24. package/es/StandardTablePro/index.js +147 -0
  25. package/es/StandardTablePro/style/index.d.ts +6 -0
  26. package/es/StandardTablePro/style/index.js +28 -0
  27. package/es/data/city.data.d.ts +20 -0
  28. package/es/data/city.data.js +10199 -0
  29. package/es/data/common.use.d.ts +29 -0
  30. package/es/data/common.use.js +30 -0
  31. package/es/data/general.config.d.ts +32 -0
  32. package/es/data/general.config.js +34 -1
  33. package/es/data/index.d.ts +3 -1
  34. package/es/data/index.js +3 -1
  35. package/es/theme/utils/genStyleHook.js +3 -1
  36. package/es/utils/ValueFormat.js +3 -3
  37. package/es/utils/fileConvert.d.ts +17 -0
  38. package/es/utils/fileConvert.js +100 -0
  39. package/es/utils/getParentNodes.d.ts +21 -14
  40. package/es/utils/getParentNodes.js +39 -11
  41. package/es/utils/index.d.ts +20 -1
  42. package/es/utils/index.js +74 -3
  43. package/es/utils/regExp.d.ts +10 -0
  44. package/es/utils/regExp.js +13 -2
  45. package/es/utils/response.d.ts +17 -0
  46. package/es/utils/response.js +40 -0
  47. package/es/utils/urlUtils.d.ts +10 -6
  48. package/es/utils/urlUtils.js +21 -32
  49. package/lib/ButtonGroup/index.d.ts +1 -0
  50. package/lib/ButtonGroup/styles/index.js +3 -1
  51. package/lib/FormComp/FieldComponent/ExtensionField.d.ts +3 -0
  52. package/lib/FormComp/FieldComponent/ExtensionField.js +27 -0
  53. package/lib/FormComp/FieldComponent/index.d.ts +10 -1
  54. package/lib/FormComp/FieldComponent/index.js +122 -56
  55. package/lib/FormComp/RenderItemGroup/index.js +38 -16
  56. package/lib/FormComp/RenderItemGroup/style/index.js +6 -0
  57. package/lib/NavLeafScroll/Main.js +2 -2
  58. package/lib/RefactorTree/index.d.ts +1 -0
  59. package/lib/RefactorTree/index.js +4 -2
  60. package/lib/StandardDragModal/ChangeStandardModal.js +1 -1
  61. package/lib/StandardFilter/index.js +12 -9
  62. package/lib/StandardFilter/style/FilterStyle.js +13 -4
  63. package/lib/StandardFilter/style/index.less +9 -2
  64. package/lib/StandardForm/StepForm.js +1 -1
  65. package/lib/StandardModal/index.js +1 -1
  66. package/lib/StandardTable/index.d.ts +3 -2
  67. package/lib/StandardTable/index.js +15 -8
  68. package/lib/StandardTable/style/index.js +5 -0
  69. package/lib/StandardTablePro/index.d.ts +9 -0
  70. package/lib/StandardTablePro/index.js +155 -0
  71. package/lib/StandardTablePro/style/index.d.ts +6 -0
  72. package/lib/StandardTablePro/style/index.js +34 -0
  73. package/lib/data/city.data.d.ts +20 -0
  74. package/lib/data/city.data.js +10205 -0
  75. package/lib/data/common.use.d.ts +29 -0
  76. package/lib/data/common.use.js +36 -0
  77. package/lib/data/general.config.d.ts +32 -0
  78. package/lib/data/general.config.js +34 -1
  79. package/lib/data/index.d.ts +3 -1
  80. package/lib/data/index.js +14 -0
  81. package/lib/theme/utils/genStyleHook.js +3 -1
  82. package/lib/utils/ValueFormat.js +3 -3
  83. package/lib/utils/fileConvert.d.ts +17 -0
  84. package/lib/utils/fileConvert.js +108 -0
  85. package/lib/utils/getParentNodes.d.ts +21 -14
  86. package/lib/utils/getParentNodes.js +40 -12
  87. package/lib/utils/index.d.ts +20 -1
  88. package/lib/utils/index.js +101 -5
  89. package/lib/utils/regExp.d.ts +10 -0
  90. package/lib/utils/regExp.js +13 -2
  91. package/lib/utils/response.d.ts +17 -0
  92. package/lib/utils/response.js +44 -0
  93. package/lib/utils/urlUtils.d.ts +10 -6
  94. package/lib/utils/urlUtils.js +22 -34
  95. package/package.json +4 -4
  96. package/es/utils/transferFile.d.ts +0 -4
  97. package/es/utils/transferFile.js +0 -56
  98. package/lib/utils/transferFile.d.ts +0 -4
  99. package/lib/utils/transferFile.js +0 -63
@@ -0,0 +1,29 @@
1
+ declare const _default: {
2
+ responseMsg: {
3
+ create: {
4
+ success: string;
5
+ error: string;
6
+ };
7
+ delete: {
8
+ success: string;
9
+ error: string;
10
+ };
11
+ update: {
12
+ success: string;
13
+ error: string;
14
+ };
15
+ send: {
16
+ success: string;
17
+ error: string;
18
+ };
19
+ authorize: {
20
+ success: string;
21
+ error: string;
22
+ };
23
+ };
24
+ basePagination: {
25
+ current: number;
26
+ size: number;
27
+ };
28
+ };
29
+ export default _default;
@@ -0,0 +1,30 @@
1
+ export default {
2
+ // 常用的文本提示等
3
+ responseMsg: {
4
+ create: {
5
+ success: '新增成功',
6
+ error: '删除失败'
7
+ },
8
+ delete: {
9
+ success: '删除成功',
10
+ error: '删除失败'
11
+ },
12
+ update: {
13
+ success: '修改成功',
14
+ error: '修改失败'
15
+ },
16
+ send: {
17
+ success: '发送成功',
18
+ error: '发送失败'
19
+ },
20
+ authorize: {
21
+ success: '授权成功',
22
+ error: '授权失败'
23
+ }
24
+ },
25
+ // 基础页码配置
26
+ basePagination: {
27
+ current: 1,
28
+ size: 15
29
+ }
30
+ };
@@ -61,6 +61,38 @@ declare const _default: {
61
61
  xlg: {
62
62
  width: string;
63
63
  };
64
+ xxlg: {
65
+ width: string;
66
+ };
67
+ wide: {
68
+ width: string;
69
+ };
70
+ };
71
+ inlineFormItemStyle: {
72
+ xs: {
73
+ width: string;
74
+ };
75
+ sm: {
76
+ width: string;
77
+ };
78
+ xsm: {
79
+ width: string;
80
+ };
81
+ md: {
82
+ width: string;
83
+ };
84
+ xmd: {
85
+ width: string;
86
+ };
87
+ lg: {
88
+ width: string;
89
+ };
90
+ xlg: {
91
+ width: string;
92
+ };
93
+ xxlg: {
94
+ width: string;
95
+ };
64
96
  wide: {
65
97
  width: string;
66
98
  };
@@ -63,7 +63,40 @@ export default {
63
63
  width: '300px'
64
64
  },
65
65
  xlg: {
66
- width: '500px'
66
+ width: '450px'
67
+ },
68
+ xxlg: {
69
+ width: '450px'
70
+ },
71
+ wide: {
72
+ width: '100%'
73
+ }
74
+ },
75
+ // layout为inline时的表单域宽度
76
+ inlineFormItemStyle: {
77
+ xs: {
78
+ width: '100px'
79
+ },
80
+ sm: {
81
+ width: '120px'
82
+ },
83
+ xsm: {
84
+ width: '180px'
85
+ },
86
+ md: {
87
+ width: '200px'
88
+ },
89
+ xmd: {
90
+ width: '240px'
91
+ },
92
+ lg: {
93
+ width: '260px'
94
+ },
95
+ xlg: {
96
+ width: '280px'
97
+ },
98
+ xxlg: {
99
+ width: '280px'
67
100
  },
68
101
  wide: {
69
102
  width: '100%'
@@ -1,3 +1,5 @@
1
1
  import general from './general.config';
2
2
  import funcCode from './func.code';
3
- export { general, funcCode, };
3
+ import commonUse from './common.use';
4
+ import cityData from './city.data';
5
+ export { cityData, general, funcCode, commonUse };
package/es/data/index.js CHANGED
@@ -1,3 +1,5 @@
1
1
  import general from "./general.config";
2
2
  import funcCode from "./func.code";
3
- export { general, funcCode };
3
+ import commonUse from "./common.use";
4
+ import cityData from "./city.data";
5
+ export { cityData, general, funcCode, commonUse };
@@ -17,7 +17,9 @@ export var createStyleHook = function createStyleHook(componentName, styleFn, ge
17
17
  var prefixCls = 'spec';
18
18
  var defaultComponentToken = typeof getDefaultToken === 'function' ? getDefaultToken(token) : getDefaultToken;
19
19
  var mergedComponentToken = _objectSpread(_objectSpread({}, defaultComponentToken), token);
20
- return [useStyleRegister({
20
+ return [useStyleRegister(
21
+ // @ts-ignore
22
+ {
21
23
  theme: theme,
22
24
  token: mergedComponentToken,
23
25
  hashId: hashId,
@@ -8,8 +8,8 @@ import dayjs from 'dayjs';
8
8
  var dateFieldTypes = ['datePicker', 'dateTimePicker', 'rangePicker', 'rangeTimePicker', 'timePicker', 'timePickerRange'];
9
9
  export var UtilValueFormat = function UtilValueFormat(fieldsValue, formItemGroup) {
10
10
  formItemGroup && formItemGroup.forEach(function (item) {
11
- var _item$protoConfig, _fieldsValue$item$fil, _item$protoConfig2, _fieldsValue$item$fil2, _item$protoConfig3, _fieldsValue$item$fil3, _item$protoConfig4;
12
- if (!fieldsValue[item.filedName]) return;
11
+ var _item$protoConfig, _fieldsValue, _item$protoConfig2, _fieldsValue$, _item$protoConfig3, _fieldsValue$2, _item$protoConfig4;
12
+ if (!fieldsValue[item.filedName || item.fieldName]) return;
13
13
  switch (item.type) {
14
14
  case 'datePicker':
15
15
  case 'dateTimePicker':
@@ -33,7 +33,7 @@ export var UtilValueFormat = function UtilValueFormat(fieldsValue, formItemGroup
33
33
  } else {
34
34
  pickerFormatNew = item.type === 'datePicker' || item.type === 'rangePicker' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss';
35
35
  }
36
- fieldsValue[item.filedName] = item.type === 'datePicker' || item.type === 'dateTimePicker' ? (_fieldsValue$item$fil = fieldsValue[item.filedName]) === null || _fieldsValue$item$fil === void 0 ? void 0 : _fieldsValue$item$fil.format((item === null || item === void 0 || (_item$protoConfig2 = item.protoConfig) === null || _item$protoConfig2 === void 0 ? void 0 : _item$protoConfig2.format) || pickerFormatNew) : [(_fieldsValue$item$fil2 = fieldsValue[item.filedName][0]) === null || _fieldsValue$item$fil2 === void 0 ? void 0 : _fieldsValue$item$fil2.format((item === null || item === void 0 || (_item$protoConfig3 = item.protoConfig) === null || _item$protoConfig3 === void 0 ? void 0 : _item$protoConfig3.format) || pickerFormatNew), (_fieldsValue$item$fil3 = fieldsValue[item.filedName][1]) === null || _fieldsValue$item$fil3 === void 0 ? void 0 : _fieldsValue$item$fil3.format((item === null || item === void 0 || (_item$protoConfig4 = item.protoConfig) === null || _item$protoConfig4 === void 0 ? void 0 : _item$protoConfig4.format) || pickerFormatNew)];
36
+ fieldsValue[item.filedName || item.fieldName] = item.type === 'datePicker' || item.type === 'dateTimePicker' ? (_fieldsValue = fieldsValue[item.filedName || item.fieldName]) === null || _fieldsValue === void 0 ? void 0 : _fieldsValue.format((item === null || item === void 0 || (_item$protoConfig2 = item.protoConfig) === null || _item$protoConfig2 === void 0 ? void 0 : _item$protoConfig2.format) || pickerFormatNew) : [(_fieldsValue$ = fieldsValue[item.filedName || item.fieldName][0]) === null || _fieldsValue$ === void 0 ? void 0 : _fieldsValue$.format((item === null || item === void 0 || (_item$protoConfig3 = item.protoConfig) === null || _item$protoConfig3 === void 0 ? void 0 : _item$protoConfig3.format) || pickerFormatNew), (_fieldsValue$2 = fieldsValue[item.filedName || item.fieldName][1]) === null || _fieldsValue$2 === void 0 ? void 0 : _fieldsValue$2.format((item === null || item === void 0 || (_item$protoConfig4 = item.protoConfig) === null || _item$protoConfig4 === void 0 ? void 0 : _item$protoConfig4.format) || pickerFormatNew)];
37
37
  break;
38
38
  default:
39
39
  break;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 图片url转file文件
3
+ * */
4
+ declare function imgUrlToFile(url: string): Promise<any>;
5
+ /**
6
+ * 图片url转base64位
7
+ * */
8
+ declare function imgUrlToBase64(url: string): Promise<unknown>;
9
+ /**
10
+ * base64转base64位
11
+ * */
12
+ declare function dataURLtoFile(dataurl?: string, filename?: any): File | undefined;
13
+ /**
14
+ * file文件转base64位
15
+ * */
16
+ declare const fileToBase64: (file: any) => Promise<unknown>;
17
+ export { imgUrlToFile, dataURLtoFile, imgUrlToBase64, fileToBase64 };
@@ -0,0 +1,100 @@
1
+ /**
2
+ * 图片url转file文件
3
+ * */
4
+ function imgUrlToFile(url) {
5
+ var img = url; //这里是淘宝上随便找的一张图片
6
+ var imgRes;
7
+ // getBase64(img, (dataURL) => {
8
+ // imgRes = dataURLtoFile(dataURL,img);
9
+ // console.log(imgRes)
10
+ // callback(imgRes)
11
+ // });
12
+ return imgUrlToBase64(img).then(function (dataURL) {
13
+ // @ts-ignore
14
+ imgRes = dataURLtoFile(dataURL, img);
15
+ return imgRes;
16
+ }).catch(function (error) {
17
+ return error;
18
+ });
19
+ }
20
+ /**
21
+ * 图片url转base64位
22
+ * */
23
+ function imgUrlToBase64(url) {
24
+ return new Promise(function (resolve, reject) {
25
+ if (!url) {
26
+ // reject(new Error('转换错误:未传入url'));
27
+ reject('转换错误:未传入url');
28
+ }
29
+ var image = new Image();
30
+ image.onload = function () {
31
+ var canvas = document.createElement('canvas');
32
+ canvas.width = image.width; // this.naturalWidth;
33
+ canvas.height = image.height; // this.naturalHeight;
34
+ // 将图片插入画布并开始绘制
35
+ // @ts-ignore
36
+ canvas.getContext('2d').drawImage(image, 0, 0, canvas.width, canvas.height);
37
+ // result
38
+ var result = canvas.toDataURL();
39
+ // console.log('result', result)
40
+ resolve(result);
41
+ };
42
+ // CORS 策略,会存在跨域问题https://stackoverflow.com/questions/20424279/canvas-todataurl-securityerror
43
+ image.setAttribute("crossOrigin", 'Anonymous');
44
+ image.src = url;
45
+ // 图片加载失败的错误处理
46
+ image.onerror = function (err) {
47
+ reject(err);
48
+ };
49
+ });
50
+ }
51
+
52
+ /**
53
+ * base64转base64位
54
+ * */
55
+ function dataURLtoFile(dataurl, filename) {
56
+ if (!dataurl) return undefined;
57
+ //将base64转换为文件,dataurl为base64字符串,filename为文件名(必须带后缀名,如.jpg,.png)
58
+ var arr = dataurl.split(","),
59
+ // @ts-ignore
60
+ mime = arr[0].match(/:(.*?);/)[1],
61
+ bstr = atob(arr[1]),
62
+ n = bstr.length,
63
+ u8arr = new Uint8Array(n);
64
+ while (n--) {
65
+ u8arr[n] = bstr.charCodeAt(n);
66
+ }
67
+ return new File([u8arr], filename, {
68
+ type: mime
69
+ });
70
+ }
71
+
72
+ /**
73
+ * file文件转base64位
74
+ * */
75
+ var fileToBase64 = function fileToBase64(file) {
76
+ return new Promise(function (resolve, reject) {
77
+ if (!file || !(file instanceof File)) {
78
+ // reject(new Error("转换错误:传入非File"));
79
+ reject("转换错误:传入非File");
80
+ }
81
+ // 创建一个新的 FileReader 对象
82
+ var reader = new FileReader();
83
+ // 读取 File 对象
84
+ reader.readAsDataURL(file);
85
+ // 加载完成后
86
+ reader.onload = function () {
87
+ // 将读取的数据转换为 base64 编码的字符串
88
+ // const base64String = reader.result.split(",")[1];
89
+ var base64String = reader.result;
90
+ // 解析为 Promise 对象,并返回 base64 编码的字符串
91
+ resolve(base64String);
92
+ };
93
+
94
+ // 加载失败时
95
+ reader.onerror = function () {
96
+ reject(new Error("Failed to load file"));
97
+ };
98
+ });
99
+ };
100
+ export { imgUrlToFile, dataURLtoFile, imgUrlToBase64, fileToBase64 };
@@ -10,17 +10,17 @@
10
10
  * @result {Array} parentKeys 当前传入nodeKey值所有上级别父级数据关键字数据集合(keyParam)(倒序排列,根节点在最后一条)
11
11
  * @result {Array} matchNode 当前传入nodeKey值所在的数据对象集合
12
12
  * */
13
- export declare const getParentNodes: (list: any[], nodeKey: string | number, params: {
13
+ export declare const getParentNodes: (list: any[], nodeKey: string | number, params?: {
14
14
  childrenParam: string;
15
15
  keyParam: string;
16
- } | undefined, extraProps: any) => {
16
+ }, extraProps?: any) => {
17
17
  nodeParent: any[];
18
18
  parentKeys: any[];
19
19
  matchNode: any[];
20
20
  };
21
21
  /**
22
- * @description 递归查找指定ID所有的子菜单与子功能集合
23
- * @params {Array} childNode 当前需要过滤查看的数据集合、
22
+ * @description 递归查找指定节点的所有子菜单与子功能集合
23
+ * @params {Array} childNode 当前需要过滤查看的子数据集合、
24
24
  * @params {Object} params 指定当前数据中,筛选对应子集合字段名及匹配标识值字段名
25
25
  * (childrenParam:指当前子集合数据字段名(字符串表示单个,数组表示当前多个子集合字段名),keyParam: 指当前匹配标识值字段名)
26
26
  * @params {Object} extra
@@ -36,25 +36,32 @@ export declare const getChildrenNodes: (childNode: any, params?: {
36
36
  nodeChildren: any[];
37
37
  };
38
38
  /**
39
- * @description 查找节点路径
39
+ * @description 查找指定节点或节点集合的完整路径数据
40
40
  * @params {Array} list 查询的数据源
41
- * @params {Array} nodeKey 需要查询的key集合
41
+ * @params {Array | String | Number} nodeKey 需要查询的key集合
42
42
  * @params {Object} params 指定当前数据中,筛选对应子集合字段名及匹配标识值字段名
43
43
  * (childrenParam:指当前子集合数据字段名(字符串表示单个,数组表示当前多个子集合字段名),keyParam: 指当前匹配标识值字段名)
44
44
  *
45
- * @result {Array} 所有匹配到的层级数据
45
+ * @result {Array} 所有匹配到的层级数据(如果nodeKey是数组,则返回的节点集合会分别按顺序存到数组内
46
+ *
46
47
  * */
47
- export declare const getNodePaths: (list: any, nodeKey: any, params: {
48
+ export declare const getNodePaths: (list: any, nodeKey: any, params?: {
48
49
  childrenParam: string;
49
50
  keyParam: string;
50
- } | undefined, extraProps: any) => any[];
51
+ }, extraProps?: any) => any[];
51
52
  /**
52
- * 数组转树形结构
53
- * @param {array} list 被转换的数组
54
- * @param {number|string} root 根节点(最外层节点)的 id
55
- * @param {object} params 字段值(默认 { keyParam: 'id', parentParam: 'parentId' })
56
- * @return array
53
+ * @description 查找节点数据:点击获取对应ID的完整数据(即从树数据中深层查找与ID值相匹配的相关数据对象)
54
+ *
55
+ * @param [array] list 需要过滤的数据
56
+ * @param [string] key 指定过滤的key值
57
+ * @param [Object] optionName 指定value与children相关字段名
58
+ *
59
+ * @data list:<array:[{ value: '', label: '', children: []}]> 列表数据格式
57
60
  */
61
+ export declare const getNode: (list: any[], key?: string | number, optionName?: {
62
+ value: string;
63
+ children: string;
64
+ } | undefined) => {};
58
65
  /**
59
66
  * 数组转树形结构
60
67
  * @param {array} list 被转换的数组
@@ -123,8 +123,8 @@ export var getParentNodes = function getParentNodes(list, nodeKey) {
123
123
  };
124
124
 
125
125
  /**
126
- * @description 递归查找指定ID所有的子菜单与子功能集合
127
- * @params {Array} childNode 当前需要过滤查看的数据集合、
126
+ * @description 递归查找指定节点的所有子菜单与子功能集合
127
+ * @params {Array} childNode 当前需要过滤查看的子数据集合、
128
128
  * @params {Object} params 指定当前数据中,筛选对应子集合字段名及匹配标识值字段名
129
129
  * (childrenParam:指当前子集合数据字段名(字符串表示单个,数组表示当前多个子集合字段名),keyParam: 指当前匹配标识值字段名)
130
130
  * @params {Object} extra
@@ -155,13 +155,14 @@ export var getChildrenNodes = function getChildrenNodes(childNode) {
155
155
  };
156
156
 
157
157
  /**
158
- * @description 查找节点路径
158
+ * @description 查找指定节点或节点集合的完整路径数据
159
159
  * @params {Array} list 查询的数据源
160
- * @params {Array} nodeKey 需要查询的key集合
160
+ * @params {Array | String | Number} nodeKey 需要查询的key集合
161
161
  * @params {Object} params 指定当前数据中,筛选对应子集合字段名及匹配标识值字段名
162
162
  * (childrenParam:指当前子集合数据字段名(字符串表示单个,数组表示当前多个子集合字段名),keyParam: 指当前匹配标识值字段名)
163
163
  *
164
- * @result {Array} 所有匹配到的层级数据
164
+ * @result {Array} 所有匹配到的层级数据(如果nodeKey是数组,则返回的节点集合会分别按顺序存到数组内
165
+ *
165
166
  * */
166
167
  export var getNodePaths = function getNodePaths(list, nodeKey) {
167
168
  var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
@@ -207,17 +208,44 @@ export var getNodePaths = function getNodePaths(list, nodeKey) {
207
208
  var pathItems = getPathByKey(key, list);
208
209
  if (pathItems) pathNode.push(pathItems);
209
210
  });
211
+ } else if (typeof nodeKey === 'string') {
212
+ var pathItems = getPathByKey(nodeKey, list);
213
+ pathNode = pathItems || [];
210
214
  }
211
215
  return pathNode;
212
216
  };
213
217
 
214
218
  /**
215
- * 数组转树形结构
216
- * @param {array} list 被转换的数组
217
- * @param {number|string} root 根节点(最外层节点)的 id
218
- * @param {object} params 字段值(默认 { keyParam: 'id', parentParam: 'parentId' })
219
- * @return array
219
+ * @description 查找节点数据:点击获取对应ID的完整数据(即从树数据中深层查找与ID值相匹配的相关数据对象)
220
+ *
221
+ * @param [array] list 需要过滤的数据
222
+ * @param [string] key 指定过滤的key值
223
+ * @param [Object] optionName 指定value与children相关字段名
224
+ *
225
+ * @data list:<array:[{ value: '', label: '', children: []}]> 列表数据格式
220
226
  */
227
+ export var getNode = function getNode(list, key) {
228
+ var optionName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
229
+ value: 'value',
230
+ children: 'children'
231
+ };
232
+ var matchCurrentItem = {};
233
+ // 深层过滤当前选中的节点
234
+ var deepFilterMatchItem = function deepFilterMatchItem(treeData, targetId) {
235
+ (treeData || []).some(function (item) {
236
+ if (Number(item[optionName.value]) === Number(targetId) || item[optionName.value] === targetId) {
237
+ matchCurrentItem = item;
238
+ return true;
239
+ }
240
+ if (item[optionName.children]) {
241
+ deepFilterMatchItem(item[optionName.children], targetId); // 没有查找到继续过滤
242
+ }
243
+ });
244
+ };
245
+ deepFilterMatchItem(list, key);
246
+ return matchCurrentItem;
247
+ };
248
+
221
249
  /**
222
250
  * 数组转树形结构
223
251
  * @param {array} list 被转换的数组
@@ -225,6 +253,7 @@ export var getNodePaths = function getNodePaths(list, nodeKey) {
225
253
  * @param {object} params 字段值(默认 { keyParam: 'id', parentParam: 'parentId' })
226
254
  * @return array
227
255
  */
256
+
228
257
  export var arrayToTree = function arrayToTree(list, rootId) {
229
258
  var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
230
259
  _ref$keyParam = _ref.keyParam,
@@ -248,7 +277,6 @@ export var arrayToTree = function arrayToTree(list, rootId) {
248
277
  * @param {array} tree 被转换的树(仅限于只有一个根的树
249
278
  * @return array
250
279
  */
251
-
252
280
  export var convertToArray = function convertToArray(tree) {
253
281
  var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
254
282
  _ref2$keyParam = _ref2.keyParam,
@@ -1,6 +1,25 @@
1
1
  export * from './getParentNodes';
2
2
  export * from './ValueFormat';
3
3
  export * from './dictSelectUtil';
4
- export * from './transferFile';
4
+ export * from './fileConvert';
5
5
  export * from './urlUtils';
6
6
  export * from './regExp';
7
+ export * from './response';
8
+ export declare const getPageQuery: () => any;
9
+ /**
10
+ * @param {string} str 字符串
11
+ * @param {string} separator 分割符(默认"-")
12
+ * @param {boolean} topIsCapital 开头是否大写(默认是)
13
+ *
14
+ * @result {string}
15
+ */
16
+ export declare const toHump: (str: string, separator?: string, topIsCapital?: boolean) => string;
17
+ /**
18
+ * 下载文件
19
+ * @param {string} filename
20
+ * @param {blob} file
21
+ * @param {string} type 文件类型(直接用.xls或者对应的MIMETYPE都可以)
22
+ * .xls 'application/vnd.ms-excel'
23
+ * .xlsx 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
24
+ */
25
+ export declare const downloadFile: (filename: string, file: any, type: string) => void;
package/es/utils/index.js CHANGED
@@ -1,7 +1,78 @@
1
+ // @ts-nocheck
2
+ import { parse } from "qs";
1
3
  export * from "./getParentNodes";
2
4
  export * from "./ValueFormat";
3
5
  export * from "./dictSelectUtil";
4
- export * from "./transferFile";
6
+ export * from "./fileConvert";
5
7
  export * from "./urlUtils";
6
- // @ts-ignore
7
- export * from "./regExp";
8
+ export * from "./regExp";
9
+ export * from "./response";
10
+ export var getPageQuery = function getPageQuery() {
11
+ return parse(window.location.href, {
12
+ ignoreQueryPrefix: true
13
+ });
14
+ };
15
+
16
+ /**
17
+ * @param {string} str 字符串
18
+ * @param {string} separator 分割符(默认"-")
19
+ * @param {boolean} topIsCapital 开头是否大写(默认是)
20
+ *
21
+ * @result {string}
22
+ */
23
+
24
+ export var toHump = function toHump(str) {
25
+ var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "-";
26
+ var topIsCapital = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
27
+ var strAry = str.split(separator);
28
+ return strAry.map(function (item, index) {
29
+ if (!topIsCapital && index == 0) return item;
30
+ // @ts-ignore
31
+ return item.replace(/^./, item.match(/^./)[0].toLocaleUpperCase());
32
+ }).join("");
33
+ };
34
+
35
+ /**
36
+ * 下载文件
37
+ * @param {string} filename
38
+ * @param {blob} file
39
+ * @param {string} type 文件类型(直接用.xls或者对应的MIMETYPE都可以)
40
+ * .xls 'application/vnd.ms-excel'
41
+ * .xlsx 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
42
+ */
43
+ export var downloadFile = function downloadFile(filename, file, type) {
44
+ // 设置文件后缀 MIME TYPE
45
+ var getMIMETYPE = function getMIMETYPE(typeKey) {
46
+ // 直接使用这里面的
47
+ var types = [{
48
+ type: '.xls',
49
+ mimeType: 'application/vnd.ms-excel'
50
+ }, {
51
+ type: '.xlsx',
52
+ mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
53
+ }];
54
+ var matchType = types.find(function (item) {
55
+ return item.type === typeKey;
56
+ });
57
+ if (matchType) {
58
+ return matchType.mimeType;
59
+ } else {
60
+ // 直接使用对应的值
61
+ return typeKey;
62
+ }
63
+ };
64
+ var blob = new Blob([file], {
65
+ type: getMIMETYPE(type)
66
+ });
67
+ var downloadUrl = URL.createObjectURL(blob);
68
+ var a = document.createElement('a');
69
+ a.style = 'display: none';
70
+ a.href = downloadUrl;
71
+ a.download = filename;
72
+ document.body.appendChild(a);
73
+ a.click();
74
+ setTimeout(function () {
75
+ document.body.removeChild(a);
76
+ URL.revokeObjectURL(downloadUrl);
77
+ }, 500);
78
+ };
@@ -0,0 +1,10 @@
1
+ declare const isIdCard: (value: string) => boolean;
2
+ declare const isEmail: (value: string) => boolean;
3
+ declare const isPhone: (value: string) => boolean;
4
+ declare const isSendNumber: (value: string) => boolean;
5
+ declare const isAccount: (value: string) => boolean;
6
+ declare const isUserAccount: (value: string) => boolean;
7
+ declare const isCardNo: (num: any) => boolean;
8
+ declare const codeReg: (value: any) => boolean;
9
+ declare const regexPassword: (value: any) => boolean;
10
+ export { isCardNo, isIdCard, isEmail, isPhone, isSendNumber, isAccount, isUserAccount, codeReg, regexPassword };
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ // @ts-nocheck 文件忽略(添加到该文件的首行)
2
2
  // 校验身份证格式
3
3
  var isIdCard = function isIdCard(value) {
4
4
  // 身份证号码为15位或者18位,15位时全为数字,18位前17位为数字,最后一位是校验位,可能为数字或字符X
@@ -108,4 +108,15 @@ var isCardNo = function isCardNo(num) {
108
108
  }
109
109
  return false;
110
110
  };
111
- export { isCardNo, isIdCard, isEmail, isPhone, isSendNumber, isAccount, isUserAccount };
111
+ var codeReg = function codeReg(value) {
112
+ // 英文和数字
113
+ var reg = /^[a-zA-Z0-9]+$/;
114
+ return reg.test(value);
115
+ };
116
+
117
+ // 密码中允许出现数字、大写字母、小写字母,但至少包含其中2种且长度在8-20之间(三种符号任取其二)
118
+ var regexPassword = function regexPassword(value) {
119
+ var reg = /(?!^(\d+|[a-zA-Z]+|[~!@#$%^&*?]+)$)^[\w~!@#$%^&*?]{8,20}$/;
120
+ return reg.test(value);
121
+ };
122
+ export { isCardNo, isIdCard, isEmail, isPhone, isSendNumber, isAccount, isUserAccount, codeReg, regexPassword };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @description 接口返回异常提示语
3
+ * @params {String或Object} type 指操作的类型:
4
+ * @value {String} 值有 删除:'delete' 修改:'update' 新增:'create'
5
+ * @value {Object} { success: 'xxx成功提示语'}
6
+ *
7
+ * @params {Object} res 接口返回数据
8
+ * @params {Function} callback 事件回调
9
+ * */
10
+ declare const responseControl: (type?: any, res?: any, callback?: ((res: any) => void) | undefined) => void;
11
+ /**
12
+ * @description 接口返回正常回调判断
13
+ * @params {Object} res 接口返回数据
14
+ * @params {Function} callback 事件回调
15
+ * */
16
+ declare const responseQuery: (res?: any, callback?: ((res: any) => void) | undefined) => void;
17
+ export { responseControl, responseQuery };