fix: selected first branch wrong

This commit is contained in:
Methapon2001 2024-12-11 09:48:11 +07:00
parent 4fcf39adb7
commit e95078e75e
2 changed files with 4 additions and 13 deletions

View file

@ -100,6 +100,7 @@ const telephoneNo = defineModel<string>('telephoneNo', { default: '' });
:for="`${prefixId}-input-source-registered-branch`"
v-model:value="registeredBranchId"
:label="$t('customer.form.registeredBranch')"
select-first-value
class="col-md-6"
simple
required

View file

@ -1,4 +1,4 @@
import { ref, toRaw, watch } from 'vue';
import { ref, watch } from 'vue';
import { defineStore } from 'pinia';
import {
CustomerBranchCreate,
@ -6,7 +6,6 @@ import {
CustomerType,
} from 'stores/customer/types';
import { Employee, EmployeeCreate } from 'stores/employee/types';
import { useI18n } from 'vue-i18n';
import useMyBranch from 'stores/my-branch';
import useCustomerStore from 'stores/customer';
@ -16,10 +15,7 @@ import useFlowStore from 'stores/flow';
import { baseUrl } from 'src/stores/utils';
export const useCustomerForm = defineStore('form-customer', () => {
const { t } = useI18n();
const customerStore = useCustomerStore();
const branchStore = useMyBranch();
const defaultFormData: CustomerCreate = {
// code: '',
@ -34,7 +30,7 @@ export const useCustomerForm = defineStore('form-customer', () => {
selectedImage: '',
status: 'CREATED',
customerType: CustomerType.Corporate,
registeredBranchId: branchStore.currentMyBranch?.id || '',
registeredBranchId: '',
image: null,
};
let resetFormData = structuredClone(defaultFormData);
@ -103,20 +99,14 @@ export const useCustomerForm = defineStore('form-customer', () => {
if (clean) {
defaultFormData.customerType = currentFormData.value.customerType;
currentFormData.value = structuredClone(defaultFormData);
currentFormData.value.registeredBranchId =
branchStore.currentMyBranch?.id || '';
resetFormData = structuredClone(defaultFormData);
resetFormData.registeredBranchId = branchStore.currentMyBranch?.id || '';
resetFormData.registeredBranchId = '';
state.value.editCustomerId = '';
state.value.treeFile = [];
return;
}
if (!resetFormData.registeredBranchId) {
resetFormData.registeredBranchId = branchStore.currentMyBranch?.id || '';
}
if (state.value.dialogType === 'create') {
state.value.editCustomerId = '';
}