refactor: convert displayAdd to a computed property

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-04-03 10:08:12 +07:00
parent 26977319ed
commit f5e1c0eca6

View file

@ -93,7 +93,6 @@ const appointModal = ref<boolean>(false);
const getNumFile = ref(0);
const dataRes = ref<any>([]);
const personal = ref<any>([]);
const displayAdd = ref<boolean>(true);
const containStatus = ref<boolean>(false);
const modaladdlist = ref<boolean>(false);
const selected = ref<any>([]);
@ -101,17 +100,12 @@ const personal_selected = ref<any>([]);
const filterlistAdd = ref<string>("");
const paging = ref<boolean>(true);
// watcher roleAdmin
watch(
roleAdmin,
(newValue) => {
const permission = checkPermission(route);
if (!newValue && permission?.attrOwnership !== "OWNER") {
displayAdd.value = false;
}
},
{ immediate: true }
);
const displayAdd = computed(() => {
if (!storeMenu.permissions) return true;
const permission = checkPermission(route);
return roleAdmin.value || permission?.attrOwnership === "OWNER";
});
//
const checkSelected = computed(() => {