refactor: make control from outside
This commit is contained in:
parent
dc578316af
commit
6454f8ebe1
1 changed files with 6 additions and 5 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
import { ref, toRaw, watch } from 'vue';
|
import { ref, toRaw, watch } from 'vue';
|
||||||
import { defineStore } from 'pinia';
|
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 { Employee, EmployeeCreate } from 'src/stores/employee/types';
|
||||||
|
|
||||||
import useMyBranch from 'src/stores/my-branch';
|
import useMyBranch from 'src/stores/my-branch';
|
||||||
|
|
@ -66,7 +69,6 @@ export const useCustomerForm = defineStore('form-customer', () => {
|
||||||
|
|
||||||
function resetForm(clean = false) {
|
function resetForm(clean = false) {
|
||||||
state.value.branchIndex = -1;
|
state.value.branchIndex = -1;
|
||||||
state.value.readonly = true;
|
|
||||||
if (clean) {
|
if (clean) {
|
||||||
defaultFormData.customerType = currentFormData.value.customerType;
|
defaultFormData.customerType = currentFormData.value.customerType;
|
||||||
currentFormData.value = structuredClone(defaultFormData);
|
currentFormData.value = structuredClone(defaultFormData);
|
||||||
|
|
@ -85,14 +87,13 @@ export const useCustomerForm = defineStore('form-customer', () => {
|
||||||
if (state.value.dialogType === 'create') {
|
if (state.value.dialogType === 'create') {
|
||||||
state.value.editCustomerId = '';
|
state.value.editCustomerId = '';
|
||||||
}
|
}
|
||||||
if (state.value.dialogType === 'edit') {
|
|
||||||
state.value.dialogType = 'info';
|
|
||||||
}
|
|
||||||
|
|
||||||
currentFormData.value = structuredClone(resetFormData);
|
currentFormData.value = structuredClone(resetFormData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function assignFormData(id?: string) {
|
async function assignFormData(id?: string) {
|
||||||
|
state.value.readonly = true;
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
resetFormData = structuredClone(defaultFormData);
|
resetFormData = structuredClone(defaultFormData);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue