zy-react-library 1.0.107 → 1.0.109
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.
|
@@ -43,7 +43,7 @@ function useGetFile(returnType = "object") {
|
|
|
43
43
|
{ eqType, eqForeignKey },
|
|
44
44
|
)
|
|
45
45
|
.then((res) => {
|
|
46
|
-
resolve(addingPrefixToFile(res.data).map(item => ({ ...item, type:
|
|
46
|
+
resolve(addingPrefixToFile(res.data).map(item => ({ ...item, type: undefined })));
|
|
47
47
|
})
|
|
48
48
|
.catch((err) => {
|
|
49
49
|
reject(err);
|
|
@@ -10,9 +10,14 @@ interface UseIsExistenceDuplicateSelectionOptions<T> {
|
|
|
10
10
|
message?: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* 检查数组中是否存在重复项的函数
|
|
15
|
+
*/
|
|
16
|
+
interface IsExistenceDuplicateSelectionFunction {
|
|
17
|
+
<T>(options: UseIsExistenceDuplicateSelectionOptions<T>): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
/**
|
|
14
21
|
* 检查数组中是否存在重复项
|
|
15
22
|
*/
|
|
16
|
-
export default function useIsExistenceDuplicateSelection
|
|
17
|
-
options: UseIsExistenceDuplicateSelectionOptions<T>
|
|
18
|
-
): Promise<void>;
|
|
23
|
+
export default function useIsExistenceDuplicateSelection(): IsExistenceDuplicateSelectionFunction;
|
|
@@ -4,15 +4,18 @@ import { uniqBy } from "lodash-es";
|
|
|
4
4
|
/**
|
|
5
5
|
* 检查数组中是否存在重复项
|
|
6
6
|
*/
|
|
7
|
-
export default function useIsExistenceDuplicateSelection(
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
export default function useIsExistenceDuplicateSelection() {
|
|
8
|
+
const IsExistenceDuplicateSelection = (options) => {
|
|
9
|
+
const { data, key, message = "存在重复项,请勿重复选择" } = options;
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
if (uniqBy(data, key).length !== data.length) {
|
|
12
|
+
antdMessage.error(message);
|
|
13
|
+
reject(new Error(message));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
resolve();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return IsExistenceDuplicateSelection;
|
|
18
21
|
}
|