tav-ui
Version:
25 lines (22 loc) • 850 B
JavaScript
import { ref, computed, unref } from 'vue';
function useSelectRecords() {
const selectRecordsRef = ref([]);
const selectRecords = computed(() => unref(selectRecordsRef));
function setSelectRecords(selectRecords2, type) {
if (type === "normal") {
const prevSelectRecords = unref(selectRecordsRef);
const currentSelectRecords = selectRecords2.reduce((result, cur) => {
const isHaveSameOption = result.find((option) => option.idPath === cur.idPath);
!isHaveSameOption && result.push(cur);
return result;
}, prevSelectRecords);
selectRecordsRef.value = currentSelectRecords;
}
if (type === "recover") {
selectRecordsRef.value = selectRecords2;
}
}
return { selectRecords, setSelectRecords };
}
export { useSelectRecords };
//# sourceMappingURL=use-select-records2.mjs.map