fix: แก้กดสร้าง สาขาไม่ได้

This commit is contained in:
Net 2024-06-28 13:04:02 +07:00
parent d62f401375
commit 33d98b4542

View file

@ -31,6 +31,7 @@ const modal = ref<boolean>(false);
const profileFileImg = ref<File | undefined>(undefined);
const imageUrl = ref<string | null>('');
const currentTreehHeadOfficeId = ref<string>('');
const inputFileImg = (() => {
const element = document.createElement('input');
@ -92,17 +93,20 @@ const treeData = computed(() => {
return arr;
});
onMounted(async () => {
await branchStore.fetchList({ pageSize: 99999 });
async function calculateStats() {
const _stats = await branchStore.stats();
if (_stats) {
stats.value.push(
stats.value = [
{ count: _stats.hq, label: 'branchHQLabel', color: 'pink' },
{ count: _stats.br, label: 'branchLabel', color: 'purple' },
);
];
}
}
onMounted(async () => {
await branchStore.fetchList({ pageSize: 99999 });
await calculateStats();
flowStore.rotate();
});
@ -320,7 +324,8 @@ function triggerDelete(id: string) {
await branchStore.deleteById(id);
await branchStore.fetchList({ pageSize: 99999 });
modalDrawer.value = false;
stats.value[0].count = stats.value[0].count - 1;
await calculateStats();
flowStore.rotate();
},
cancel: () => {},
@ -349,7 +354,11 @@ async function onSubmit() {
if (formType.value === 'create') {
if (formTypeBranch.value === 'subBranch') {
formData.value.headOfficeId = currentHq.value.id;
const currentRecord = branchData.value.result.find(
(x) => x.id === formData.value.headOfficeId,
);
formData.value.headOfficeId = currentRecord?.id;
delete formData.value['codeHeadOffice'];
}