feat: by ค่า

This commit is contained in:
Net 2024-06-06 17:10:58 +07:00
parent b092966fa6
commit 30d1abe123

View file

@ -1,5 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { storeToRefs } from 'pinia';
import UsersDetailCardComponent from 'src/components/UsersDetailCardComponent.vue'; import UsersDetailCardComponent from 'src/components/UsersDetailCardComponent.vue';
import SelectorList from 'components/SelectorList.vue'; import SelectorList from 'components/SelectorList.vue';
@ -21,11 +22,16 @@ import DrawerInfo from 'src/components/DrawerInfo.vue';
import InfoForm from 'src/components/02_personnel-management/InfoForm.vue'; import InfoForm from 'src/components/02_personnel-management/InfoForm.vue';
import { CustomerCreate } from 'stores/customer/types'; import { CustomerCreate } from 'stores/customer/types';
import useCustomerStore from 'src/stores/customer';
const userCustomer = useCustomerStore();
const { create } = userCustomer;
const formData = ref<CustomerCreate>({ const formData = ref<CustomerCreate>({
status: 'CREATED',
customerType: 'CORP', customerType: 'CORP',
customerName: '', customerName: '',
customerNameEN: '', customerNameEN: '',
taxNo: '',
customerBranch: [ customerBranch: [
{ {
address: '', address: '',
@ -36,13 +42,13 @@ const formData = ref<CustomerCreate>({
zipCode: '', zipCode: '',
email: '', email: '',
telephoneNo: '', telephoneNo: '',
status: 'CREATED',
name: '', name: '',
status: 'CREATED',
taxNo: '', taxNo: '',
nameEN: '', nameEN: '',
legalPersonNo: '', legalPersonNo: '',
registerName: '', registerName: '',
registerDate: null, registerDate: new Date(),
authorizedCapital: '', authorizedCapital: '',
employmentOffice: '', employmentOffice: '',
bussinessType: '', bussinessType: '',
@ -53,7 +59,6 @@ const formData = ref<CustomerCreate>({
saleEmployee: '', saleEmployee: '',
payDate: '', payDate: '',
wageDate: '', wageDate: '',
file: new File([''], 'dummy.jpg'),
}, },
], ],
image: new File([''], 'dummy.jpg'), image: new File([''], 'dummy.jpg'),
@ -122,9 +127,9 @@ const selectorList = computed(() => [
{ label: 'WORKER', count: 0 }, { label: 'WORKER', count: 0 },
]); ]);
const customerType = ref<'customerLegalEntity' | 'customerNaturalPerson'>( const customerType = ref<
'customerLegalEntity', 'customerLegalEntity' | 'customerNaturalPerson' | undefined
); >('customerLegalEntity');
function triggerCreate(type: 'customerLegalEntity' | 'customerNaturalPerson') { function triggerCreate(type: 'customerLegalEntity' | 'customerNaturalPerson') {
customerType.value = type; customerType.value = type;
@ -149,6 +154,58 @@ function onClose() {
infoDrawer.value = false; infoDrawer.value = false;
dialogInputForm.value = false; dialogInputForm.value = false;
} }
function clearForm() {
customerType.value = undefined;
dialogInputForm.value = false;
formData.value = {
status: 'CREATED',
customerType: 'CORP',
customerName: '',
customerNameEN: '',
taxNo: '',
customerBranch: [
{
address: '',
addressEN: '',
provinceId: '',
districtId: '',
subDistrictId: '',
zipCode: '',
email: '',
telephoneNo: '',
name: '',
status: 'CREATED',
taxNo: '',
nameEN: '',
legalPersonNo: '',
registerName: '',
registerDate: null,
authorizedCapital: '',
employmentOffice: '',
bussinessType: '',
bussinessTypeEN: '',
jobPosition: '',
jobPositionEN: '',
jobDescription: '',
saleEmployee: '',
payDate: '',
wageDate: '',
},
],
image: new File([''], 'dummy.jpg'),
};
}
async function onSubmit() {
await create({
...formData.value,
customerType:
customerType.value === 'customerLegalEntity' ? 'CORP' : 'PERS',
image: (profileFile.value ?? new File([''], 'dummy.jpg')) as File,
});
clearForm();
}
</script> </script>
<template> <template>
@ -305,6 +362,12 @@ function onClose() {
v-model:modal="dialogInputForm" v-model:modal="dialogInputForm"
:title="`เพิ่มนายจ้าง`" :title="`เพิ่มนายจ้าง`"
:customer-label="customerType" :customer-label="customerType"
:submit="
() => {
onSubmit();
}
"
:close="() => {}"
> >
<template #prepend> <template #prepend>
<ProfileUpload <ProfileUpload
@ -316,7 +379,15 @@ function onClose() {
</template> </template>
<template #information> <template #information>
<BasicInformation dense outlined separator /> <BasicInformation
dense
outlined
separator
:type-customer="customerType"
v-model:customer-name="formData.customerName"
v-model:customer-name-en="formData.customerNameEN"
v-model:tax-no="formData.taxNo"
/>
</template> </template>
<template #address> <template #address>
@ -355,6 +426,29 @@ function onClose() {
v-if=" v-if="
indexTab !== undefined && formData.customerBranch?.[indexTab] indexTab !== undefined && formData.customerBranch?.[indexTab]
" "
v-model:employment-office="
formData.customerBranch[indexTab].employmentOffice
"
v-model:bussiness-type="
formData.customerBranch[indexTab].bussinessType
"
v-model:bussiness-type-en="
formData.customerBranch[indexTab].bussinessTypeEN
"
v-model:job-position="
formData.customerBranch[indexTab].jobPosition
"
v-model:job-position-en="
formData.customerBranch[indexTab].jobPositionEN
"
v-model:job-description="
formData.customerBranch[indexTab].jobDescription
"
v-model:sale-employee="
formData.customerBranch[indexTab].saleEmployee
"
v-model:pay-date="formData.customerBranch[indexTab].payDate"
v-model:wage-date="formData.customerBranch[indexTab].wageDate"
separator separator
dense dense
outlined outlined
@ -365,6 +459,8 @@ function onClose() {
v-if=" v-if="
indexTab !== undefined && formData.customerBranch?.[indexTab] indexTab !== undefined && formData.customerBranch?.[indexTab]
" "
:type-customer="customerType"
v-model:tax-no="formData.customerBranch[indexTab].taxNo"
v-model:customer-name="formData.customerBranch[indexTab].name" v-model:customer-name="formData.customerBranch[indexTab].name"
v-model:customer-english-name=" v-model:customer-english-name="
formData.customerBranch[indexTab].nameEN formData.customerBranch[indexTab].nameEN
@ -401,9 +497,6 @@ function onClose() {
v-if=" v-if="
indexTab !== undefined && formData.customerBranch?.[indexTab] indexTab !== undefined && formData.customerBranch?.[indexTab]
" "
v-model:file-employer-document="
formData.customerBranch[indexTab].file
"
dense dense
outlined outlined
/> />