@lingxiteam/ebe-utils 0.3.5 → 0.3.9
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,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
export const CHECK_ALL_VALUE = 'LING_XI_CHECK_ALL';
|
|
4
2
|
|
|
5
|
-
|
|
6
3
|
const typeFn: any = {
|
|
7
4
|
string: String,
|
|
8
5
|
number: Number,
|
|
@@ -35,17 +32,13 @@ export const localFilterOption = (input: string = '', option: any) => {
|
|
|
35
32
|
// 判断data类型是不是是labelInValue格式
|
|
36
33
|
export const isLabelInValue = (data: any) => {
|
|
37
34
|
if (Object.prototype.toString.call(data) === '[object Object]') {
|
|
38
|
-
if (Object.keys(data).includes('label') &&
|
|
39
|
-
(Object.keys(data).includes('value') || Object.keys(data).includes('key'))) {
|
|
35
|
+
if (Object.keys(data).includes('label') && (Object.keys(data).includes('value') || Object.keys(data).includes('key'))) {
|
|
40
36
|
return true;
|
|
41
37
|
}
|
|
42
38
|
} else if (Object.prototype.toString.call(data) === '[object Array]' && data.length) {
|
|
43
39
|
let isLabelInValueCount = 0;
|
|
44
40
|
data.forEach((v: any) => {
|
|
45
|
-
if (
|
|
46
|
-
Object.keys(v).includes('label') &&
|
|
47
|
-
(Object.keys(v).includes('value') || Object.keys(v).includes('key'))
|
|
48
|
-
) {
|
|
41
|
+
if (Object.keys(v).includes('label') && (Object.keys(v).includes('value') || Object.keys(v).includes('key'))) {
|
|
49
42
|
isLabelInValueCount += 1;
|
|
50
43
|
}
|
|
51
44
|
});
|
|
@@ -90,7 +83,6 @@ export const transformValueType = (v: any, curVal: any) => {
|
|
|
90
83
|
return v;
|
|
91
84
|
};
|
|
92
85
|
|
|
93
|
-
|
|
94
86
|
export const getRules = (min?: number, max?: number, getLocale?: any) => {
|
|
95
87
|
if (!min && !max) {
|
|
96
88
|
return [];
|
|
@@ -120,7 +112,7 @@ export const getChangeSelectData = (dataSource: any[], val: string[] | Object, m
|
|
|
120
112
|
return undefined;
|
|
121
113
|
}
|
|
122
114
|
const sltData = dataSource.find((c: any) => c.value?.toString() === v?.toString());
|
|
123
|
-
return
|
|
115
|
+
return sltData ? [sltData] : undefined;
|
|
124
116
|
};
|
|
125
117
|
|
|
126
118
|
export const getSelectedAllData = (checked: boolean, dataSource: any[], value: any[], max?: number) => {
|
|
@@ -165,7 +157,7 @@ export const getSelectedAllData = (checked: boolean, dataSource: any[], value: a
|
|
|
165
157
|
|
|
166
158
|
// 获取当前列表数据下的全选状态
|
|
167
159
|
export const checkIfSelectedAll = (dataSource: any[], value: any[], filterValue: string = '') => {
|
|
168
|
-
const localFilterData = dataSource.filter(d => localFilterOption(filterValue, d));
|
|
160
|
+
const localFilterData = dataSource.filter((d) => localFilterOption(filterValue, d));
|
|
169
161
|
if (localFilterData?.length && Array.isArray(value)) {
|
|
170
162
|
// 如果是多选,value肯定是字符串类型的数组
|
|
171
163
|
const checkData = localFilterData.filter((f: any) => value.includes(f.value));
|
|
@@ -182,7 +174,7 @@ export const checkIfSelectedAll = (dataSource: any[], value: any[], filterValue:
|
|
|
182
174
|
* @param labelKey
|
|
183
175
|
* @returns
|
|
184
176
|
*/
|
|
185
|
-
export const handleDataSource = (dataSource: any[], appendDataSoure?: any[] | Object, valueKey?: string, labelKey?: string
|
|
177
|
+
export const handleDataSource = (dataSource: any[], appendDataSoure?: any[] | Object, valueKey?: string, labelKey?: string) => {
|
|
186
178
|
const valueKeys: any = [];
|
|
187
179
|
let newDataSoure: any[] = [];
|
|
188
180
|
if (Array.isArray(dataSource)) {
|
|
@@ -190,18 +182,19 @@ export const handleDataSource = (dataSource: any[], appendDataSoure?: any[] | Ob
|
|
|
190
182
|
const label = v?.[labelKey || 'label'];
|
|
191
183
|
const value = v?.[valueKey || 'value'] || v?.key;
|
|
192
184
|
if (value) {
|
|
193
|
-
|
|
185
|
+
// TODO: 为什么 id 是数字就不行??
|
|
186
|
+
valueKeys.push(value + '');
|
|
194
187
|
newDataSoure.push({
|
|
195
188
|
...v,
|
|
196
189
|
label,
|
|
197
|
-
value,
|
|
190
|
+
value: value + '',
|
|
198
191
|
});
|
|
199
192
|
}
|
|
200
193
|
});
|
|
201
194
|
}
|
|
202
195
|
let newAppednDataSoure = [];
|
|
203
196
|
if (Array.isArray(appendDataSoure) && appendDataSoure.length > 0) {
|
|
204
|
-
newAppednDataSoure = appendDataSoure.filter(item => !valueKeys?.includes(item?.[valueKey || 'value'] || item?.key));
|
|
197
|
+
newAppednDataSoure = appendDataSoure.filter((item) => !valueKeys?.includes(item?.[valueKey || 'value'] || item?.key));
|
|
205
198
|
}
|
|
206
199
|
if (Object.prototype.toString.call(appendDataSoure) === '[object Object]') {
|
|
207
200
|
newAppednDataSoure = [appendDataSoure].filter((item: any) => !valueKeys?.includes(item?.[valueKey || 'value'] || item?.key));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingxiteam/ebe-utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@babel/types": "^7.12.12",
|
|
20
20
|
"cac": "^6.7.14",
|
|
21
21
|
"fs-extra": "9.x",
|
|
22
|
-
"@lingxiteam/ebe": "0.3.
|
|
22
|
+
"@lingxiteam/ebe": "0.3.9"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|