feat: check tab before add

This commit is contained in:
puriphatt 2024-07-30 07:19:14 +00:00
parent 2c9f7ba02d
commit be397112f6
5 changed files with 103 additions and 62 deletions

View file

@ -145,6 +145,23 @@ export function selectOptionFilter(
return { options, filter };
}
export function checkTabBeforeAdd(data: unknown[], except?: string[]) {
if (!data) return;
const lastData = data[data.length - 1];
if (typeof lastData !== 'object') return false;
let canAdd = false;
for (const [key, val] of Object.entries(
lastData as Record<string, unknown>,
)) {
if (except?.includes(key)) continue;
canAdd = val !== '' && val !== null;
if (canAdd) break;
}
return canAdd;
}
const useUtilsStore = defineStore('utilsStore', () => {
const currentTitle = ref<{
title: string;