From 6454f8ebe19d04a86c17c13145c06fd495a2879b Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:10:48 +0700 Subject: [PATCH] refactor: make control from outside --- src/pages/03_customer-management/form.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pages/03_customer-management/form.ts b/src/pages/03_customer-management/form.ts index 7871a34a..cec4e71e 100644 --- a/src/pages/03_customer-management/form.ts +++ b/src/pages/03_customer-management/form.ts @@ -1,6 +1,9 @@ import { ref, toRaw, watch } from 'vue'; import { defineStore } from 'pinia'; -import { CustomerCreate } from 'src/stores/customer/types'; +import { + CustomerBranchCreate, + CustomerCreate, +} from 'src/stores/customer/types'; import { Employee, EmployeeCreate } from 'src/stores/employee/types'; import useMyBranch from 'src/stores/my-branch'; @@ -66,7 +69,6 @@ export const useCustomerForm = defineStore('form-customer', () => { function resetForm(clean = false) { state.value.branchIndex = -1; - state.value.readonly = true; if (clean) { defaultFormData.customerType = currentFormData.value.customerType; currentFormData.value = structuredClone(defaultFormData); @@ -85,14 +87,13 @@ export const useCustomerForm = defineStore('form-customer', () => { if (state.value.dialogType === 'create') { state.value.editCustomerId = ''; } - if (state.value.dialogType === 'edit') { - state.value.dialogType = 'info'; - } currentFormData.value = structuredClone(resetFormData); } async function assignFormData(id?: string) { + state.value.readonly = true; + if (!id) { resetFormData = structuredClone(defaultFormData); return;