ปรับเเก้

This commit is contained in:
STW_TTTY\stwtt 2024-05-17 16:37:55 +07:00
parent d395bcbab5
commit 763f73d872
12 changed files with 1464 additions and 368 deletions

View file

@ -29,6 +29,12 @@ const props = defineProps({
type: Object as PropType<Family>,
default: FamilyDataDefualt,
},
Ops: {
type: Object as PropType<any>,
},
OpsFilter: {
type: Object as PropType<any>,
},
});
const emit = defineEmits(["update:statusEdit"]);
@ -45,26 +51,18 @@ const {
dialogConfirm,
} = mixin;
const edit = ref<boolean>(false);
const onEdit = ref<boolean>(false);
const myform = ref<QForm | null>(null);
const familyData = ref<Family>(props.data);
const Ops = ref<any>({
prefixOps: [],
});
const OpsFilter = ref<any>({
prefixOps: [],
});
onMounted(async () => {
await fetchPrefix();
emit("update:statusEdit", false);
});
const filterSelector = (val: any, update: Function, refData: string) => {
update(() => {
Ops.value[`${refData}`] = OpsFilter.value[`${refData}`].filter(
props.Ops[`${refData}`] = props.OpsFilter[`${refData}`].filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
@ -74,29 +72,21 @@ const refreshData = async () => {
if (myform.value != null) {
myform.value.reset();
}
emit("update:statusEdit", false);
await props.fetch();
};
const fetchPrefix = async () => {
showLoader();
await http
.get(config.API.profileNewMetaMain)
.then((res) => {
const data = res.data.result;
let option: DataOption[] = [];
data.prefixs.map((r: any) => {
option.push({ id: r.name.toString(), name: r.name.toString() });
});
Ops.value.prefixOps = option;
OpsFilter.value.prefixOps = option;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
if (onEdit.value) {
dialogConfirm(
$q,
async () => {
emit("update:statusEdit", false);
await props.fetch("Family");
edit.value = false;
onEdit.value = false;
},
`ข้อมูลมีการแก้ไข`,
`ยืนยันยกเลิกการแก้ไขใช่หรือไม่?`
);
} else {
edit.value = false;
}
};
const editData = async () => {
@ -153,7 +143,7 @@ const editData = async () => {
hideLoader();
edit.value = false;
emit("update:statusEdit", false);
await props.fetch();
await props.fetch("Family");
});
});
};