refactor: make control from outside

This commit is contained in:
Methapon2001 2024-08-08 17:10:48 +07:00
parent dc578316af
commit 6454f8ebe1

View file

@ -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;