refactor: citizen missig

This commit is contained in:
Thanaphon Frappet 2024-11-20 17:35:33 +07:00
parent aa823d68aa
commit bad389f6be
3 changed files with 23 additions and 14 deletions

View file

@ -40,6 +40,7 @@ import {
} from './components'; } from './components';
import { formatAddress } from 'src/utils/address'; import { formatAddress } from 'src/utils/address';
import PaginationPageSize from 'src/components/PaginationPageSize.vue'; import PaginationPageSize from 'src/components/PaginationPageSize.vue';
import { nextTick } from 'vue';
const flowStore = useFlowStore(); const flowStore = useFlowStore();
const customerStore = useCustomerStore(); const customerStore = useCustomerStore();
@ -81,6 +82,7 @@ const prop = withDefaults(
currentCustomerName?: string; currentCustomerName?: string;
customerType: CustomerType; customerType: CustomerType;
countEmployee?: number; countEmployee?: number;
currentCitizenId?: string;
gender: string; gender: string;
selectedImage: string; selectedImage: string;
}>(), }>(),
@ -103,6 +105,7 @@ defineEmits<{
onMounted(async () => { onMounted(async () => {
const url = window.location.href; const url = window.location.href;
const parts = url.split('/'); const parts = url.split('/');
customerBranchFormState.value.currentCustomerId = parts[4]; customerBranchFormState.value.currentCustomerId = parts[4];
await fetchList(); await fetchList();
@ -213,6 +216,10 @@ async function fetchList() {
function openEmployerBranchForm(formType: 'create' | 'edit' | 'info') { function openEmployerBranchForm(formType: 'create' | 'edit' | 'info') {
customerBranchFormState.value.dialogType = formType; customerBranchFormState.value.dialogType = formType;
customerBranchFormState.value.dialogModal = true; customerBranchFormState.value.dialogModal = true;
nextTick(() => {
customerBranchFormState.value.customerType = prop.customerType;
customerBranchFormData.value.citizenId = prop.currentCitizenId;
});
} }
async function fetchEmployee(opts: { branchId: string; pageSize?: number }) { async function fetchEmployee(opts: { branchId: string; pageSize?: number }) {
@ -871,24 +878,24 @@ watch(
:readonly="customerBranchFormState.dialogType === 'info'" :readonly="customerBranchFormState.dialogType === 'info'"
outlined outlined
:title="$t('form.address')" :title="$t('form.address')"
v-model:homeCode="customerBranchFormData.homeCode" v-model:home-code="customerBranchFormData.homeCode"
v-model:employmentOffice="customerBranchFormData.employmentOffice" v-model:employment-office="customerBranchFormData.employmentOffice"
v-model:employmentOfficeEN=" v-model:employment-office-en="
customerBranchFormData.employmentOfficeEN customerBranchFormData.employmentOfficeEN
" "
v-model:address="customerBranchFormData.address" v-model:address="customerBranchFormData.address"
v-model:addressEN="customerBranchFormData.addressEN" v-model:address-en="customerBranchFormData.addressEN"
v-model:province-id="customerBranchFormData.provinceId" v-model:province-id="customerBranchFormData.provinceId"
v-model:district-id="customerBranchFormData.districtId" v-model:district-id="customerBranchFormData.districtId"
v-model:sub-district-id="customerBranchFormData.subDistrictId" v-model:sub-district-id="customerBranchFormData.subDistrictId"
v-model:street="customerBranchFormData.street" v-model:street="customerBranchFormData.street"
v-model:streetEN="customerBranchFormData.streetEN" v-model:street-en="customerBranchFormData.streetEN"
v-model:moo="customerBranchFormData.moo" v-model:moo="customerBranchFormData.moo"
v-model:mooEN="customerBranchFormData.mooEN" v-model:moo-en="customerBranchFormData.mooEN"
v-model:soi="customerBranchFormData.soi" v-model:soi="customerBranchFormData.soi"
v-model:soiEN="customerBranchFormData.soiEN" v-model:soi-en="customerBranchFormData.soiEN"
:addressTitle="$t('form.address')" :address-title="$t('form.address')"
:addressTitleEN="$t('form.address', { suffix: '(EN)' })" :address-title-en="$t('form.address', { suffix: '(EN)' })"
/> />
<div class="row q-col-gutter-sm q-mb-sm" id="employer-branch-contact"> <div class="row q-col-gutter-sm q-mb-sm" id="employer-branch-contact">
<div class="col-12 text-weight-bold text-body1 row items-center"> <div class="col-12 text-weight-bold text-body1 row items-center">

View file

@ -1826,6 +1826,7 @@ const emptyCreateDialog = ref(false);
? currentCustomer.branch[0]?.registerNameEN ? currentCustomer.branch[0]?.registerNameEN
: currentCustomer.branch[0]?.registerName : currentCustomer.branch[0]?.registerName
" "
:current-citizen-id="currentCustomer.branch[0]?.citizenId"
:count-employee="currentCustomer._count.employee" :count-employee="currentCustomer._count.employee"
:selected-image="currentCustomer.selectedImage" :selected-image="currentCustomer.selectedImage"
:gender="currentCustomer.branch[0]?.gender" :gender="currentCustomer.branch[0]?.gender"

View file

@ -443,15 +443,16 @@ export const useCustomerBranchForm = defineStore('form-customer-branch', () => {
let resetFormData = structuredClone(defaultFormData); let resetFormData = structuredClone(defaultFormData);
const currentFormData = ref<CustomerBranchCreate & { id?: string }>( const currentFormData = ref<
structuredClone(defaultFormData), CustomerBranchCreate & { id?: string; codeCustomer?: string }
); >(structuredClone(defaultFormData));
const state = ref<{ const state = ref<{
dialogType: 'info' | 'create' | 'edit'; dialogType: 'info' | 'create' | 'edit';
dialogOpen: boolean; dialogOpen: boolean;
dialogModal: boolean; dialogModal: boolean;
currentCustomerId: string; currentCustomerId: string;
customerType?: 'CORP' | 'PERS';
}>({ }>({
dialogType: 'info', dialogType: 'info',
dialogOpen: false, dialogOpen: false,
@ -474,7 +475,6 @@ export const useCustomerBranchForm = defineStore('form-customer-branch', () => {
resetFormData = { resetFormData = {
id: _data.id, id: _data.id,
code: _data.code, code: _data.code,
customerCode: '',
provinceId: _data.provinceId, provinceId: _data.provinceId,
districtId: _data.districtId, districtId: _data.districtId,
subDistrictId: _data.subDistrictId, subDistrictId: _data.subDistrictId,
@ -558,7 +558,8 @@ export const useCustomerBranchForm = defineStore('form-customer-branch', () => {
const res = await customerStore.createBranch({ const res = await customerStore.createBranch({
...currentFormData.value, ...currentFormData.value,
citizenId: citizenId:
customerFormStore.currentFormData.customerType === 'CORP' (state.value.customerType ||
customerFormStore.currentFormData.customerType) === 'CORP'
? undefined ? undefined
: currentFormData.value.citizenId, : currentFormData.value.citizenId,
customerId: state.value.currentCustomerId, customerId: state.value.currentCustomerId,