fix: Unable to create service point

This commit is contained in:
Net 2024-09-20 18:00:06 +07:00
parent 883f79cf66
commit f4474c2624

View file

@ -366,7 +366,9 @@ const defaultFormData = {
const formDialogRef = ref();
const formType = ref<'create' | 'edit' | 'delete' | 'view'>('create');
const formTypeBranch = ref<'headOffice' | 'subBranch'>('headOffice');
const formTypeBranch = ref<'headOffice' | 'subBranch' | 'branchVirtual'>(
'headOffice',
);
const currentHq = ref<{ id: string; code: string }>({
id: '',
code: '',
@ -520,13 +522,13 @@ watch(modalDrawer, () => {
});
function triggerCreate(
type: 'headOffice' | 'subBranch',
type: 'headOffice' | 'subBranch' | 'branchVirtual',
id?: string,
code?: string,
) {
formTypeBranch.value = type;
if (type === 'subBranch' && id && code) {
if ((type === 'subBranch' || type === 'branchVirtual') && id && code) {
isSubCreate.value = true;
formData.value.headOfficeId = id;
formData.value.code = code;
@ -845,12 +847,14 @@ async function onSubmit(submitSelectedItem?: boolean) {
function changeTitle(
formType: 'edit' | 'create' | 'delete' | 'view',
typeBranch: 'headOffice' | 'subBranch',
typeBranch: 'headOffice' | 'subBranch' | 'branchVirtual',
) {
const _type =
typeBranch === 'headOffice'
? 'branch.card.branchHQLabel'
: 'branch.card.branchLabel';
{
headOffice: 'branch.card.branchHQLabel',
subBranch: 'branch.card.branchLabel',
branchVirtual: 'branch.card.branchVirtual',
}[typeBranch] || '';
return formType === 'create'
? t('form.title.create', { name: t(_type) })
@ -2652,14 +2656,14 @@ watch(currentHq, () => {
() => {
modelCreateTypeBranch = false;
if (value.text === $t('branch.card.branchVirtual')) {
if (value.text === 'branch.card.branchVirtual') {
formData.virtual = true;
} else {
formData.virtual = false;
}
triggerCreate(
'subBranch',
formData.virtual ? 'branchVirtual' : 'subBranch',
currentEdit.id || currentHq.id,
currentEdit.code || currentHq.code,
);