feat: customer branch function + add

This commit is contained in:
oat_dev 2024-06-10 14:10:34 +07:00
parent aba1d61e01
commit 75246296ae
2 changed files with 95 additions and 2 deletions

View file

@ -30,6 +30,7 @@ import {
Customer,
CustomerUpdate,
CustomerBranch,
CustomerBranchCreate,
} from 'stores/customer/types';
import { onMounted } from 'vue';
import FormPerson from 'src/components/02_personnel-management/FormPerson.vue';
@ -38,8 +39,15 @@ import FormEmployeeHealthCheck from 'src/components/03_customer-management/FormE
import { dialog } from 'src/stores/utils';
const userCustomer = useCustomerStore();
const { create, getStatsCustomer, fetchList, editById, fetchListById } =
userCustomer;
const {
create,
getStatsCustomer,
fetchList,
editById,
fetchListById,
createBranch,
deleteBranchById,
} = userCustomer;
const formData = ref<CustomerCreate>({
status: 'CREATED',
customerType: 'CORP',
@ -302,6 +310,14 @@ async function onSubmit() {
async function onSubmitCustomerBranch() {
dialogInputCustomerBranchForm.value = false;
// await createBranch();
for (const item of formData.value.customerBranch || []) {
await createBranch({
...item,
customerId: currentCustomerId.value,
});
}
clearForm();
const result = await fetchListById(currentCustomerId.value);
if (result) {