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