优化useIsExistenceDuplicateSelection
parent
39b0b6c5f6
commit
9fde31ea88
|
|
@ -20,4 +20,6 @@ interface IsExistenceDuplicateSelectionFunction {
|
||||||
/**
|
/**
|
||||||
* 检查数组中是否存在重复项
|
* 检查数组中是否存在重复项
|
||||||
*/
|
*/
|
||||||
export default function useIsExistenceDuplicateSelection(): IsExistenceDuplicateSelectionFunction;
|
export default function useIsExistenceDuplicateSelection(): {
|
||||||
|
isExistenceDuplicateSelection: IsExistenceDuplicateSelectionFunction
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { uniqBy } from "lodash-es";
|
||||||
* 检查数组中是否存在重复项
|
* 检查数组中是否存在重复项
|
||||||
*/
|
*/
|
||||||
export default function useIsExistenceDuplicateSelection() {
|
export default function useIsExistenceDuplicateSelection() {
|
||||||
const IsExistenceDuplicateSelection = (options) => {
|
const isExistenceDuplicateSelection = (options) => {
|
||||||
const { data, key, message = "存在重复项,请勿重复选择" } = options;
|
const { data, key, message = "存在重复项,请勿重复选择" } = options;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (uniqBy(data, key).length !== data.length) {
|
if (uniqBy(data, key).length !== data.length) {
|
||||||
|
|
@ -17,5 +17,5 @@ export default function useIsExistenceDuplicateSelection() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return IsExistenceDuplicateSelection;
|
return { isExistenceDuplicateSelection };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue