优化useIsExistenceDuplicateSelection
parent
4cc1051a69
commit
0ed49f0210
|
|
@ -7,15 +7,14 @@ import { uniqBy } from "lodash-es";
|
|||
export default function useIsExistenceDuplicateSelection() {
|
||||
const isExistenceDuplicateSelection = (options) => {
|
||||
const { data, key, message = "存在重复项,请勿重复选择" } = options;
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise((resolve) => {
|
||||
if (uniqBy(data, key).length !== data.length) {
|
||||
antdMessage.error(message);
|
||||
reject(new Error(message));
|
||||
}
|
||||
else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
return { isExistenceDuplicateSelection };
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue