chore: clean
This commit is contained in:
parent
3bc5823e16
commit
1b489306bf
3 changed files with 316 additions and 2672 deletions
File diff suppressed because it is too large
Load diff
103
src/pages/03_customer-management/constant.ts
Normal file
103
src/pages/03_customer-management/constant.ts
Normal file
|
|
@ -0,0 +1,103 @@
|
||||||
|
import { QTableProps } from 'quasar';
|
||||||
|
|
||||||
|
export const columnsEmployee = [
|
||||||
|
{
|
||||||
|
name: 'firstName',
|
||||||
|
align: 'left',
|
||||||
|
label: 'nameEmployee',
|
||||||
|
field: 'firstName',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'formDialogInputNationality',
|
||||||
|
align: 'left',
|
||||||
|
label: 'formDialogInputNationality',
|
||||||
|
field: 'nationality',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'formDialogInputPassportNo',
|
||||||
|
align: 'left',
|
||||||
|
label: 'formDialogInputPassportNo',
|
||||||
|
field: 'passportNumber',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'formDialogInputAge',
|
||||||
|
align: 'left',
|
||||||
|
label: 'formDialogInputAge',
|
||||||
|
field: 'dateOfBirth',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'passportExpiryDate',
|
||||||
|
align: 'left',
|
||||||
|
label: 'passportExpire',
|
||||||
|
field: 'passportExpiryDate',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'formDialogEmployeeNRCNo',
|
||||||
|
align: 'left',
|
||||||
|
label: 'formDialogEmployeeNRCNo',
|
||||||
|
field: 'nrcNo',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'branchLabel',
|
||||||
|
align: 'left',
|
||||||
|
label: 'branchLabel',
|
||||||
|
field: 'customerBranch',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'type',
|
||||||
|
align: 'left',
|
||||||
|
label: 'type',
|
||||||
|
field: 'type',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'action',
|
||||||
|
label: '',
|
||||||
|
field: 'action',
|
||||||
|
},
|
||||||
|
] satisfies QTableProps['columns'];
|
||||||
|
|
||||||
|
export const columnsCustomer = [
|
||||||
|
{
|
||||||
|
name: 'customerName',
|
||||||
|
align: 'left',
|
||||||
|
label: 'corporation',
|
||||||
|
field: 'customerName',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'type',
|
||||||
|
align: 'center',
|
||||||
|
label: 'type',
|
||||||
|
field: 'customerType',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'personName',
|
||||||
|
align: 'left',
|
||||||
|
label: 'name',
|
||||||
|
field: 'personName',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'telephoneNo',
|
||||||
|
align: 'left',
|
||||||
|
label: 'telephone',
|
||||||
|
field: 'branch[0].telephoneNo',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'branchEmail',
|
||||||
|
align: 'left',
|
||||||
|
label: 'formDialogInputEmail',
|
||||||
|
field: 'branch[0].email',
|
||||||
|
},
|
||||||
|
] satisfies QTableProps['columns'];
|
||||||
137
src/pages/03_customer-management/form.ts
Normal file
137
src/pages/03_customer-management/form.ts
Normal file
|
|
@ -0,0 +1,137 @@
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { defineStore } from 'pinia';
|
||||||
|
import { CustomerCreate } from 'src/stores/customer/types';
|
||||||
|
import useMyBranch from 'src/stores/my-branch';
|
||||||
|
import useCustomerStore from 'src/stores/customer';
|
||||||
|
|
||||||
|
export const useCustomerForm = defineStore('form-customer', () => {
|
||||||
|
const customerStore = useCustomerStore();
|
||||||
|
const branchStore = useMyBranch();
|
||||||
|
|
||||||
|
let defaultFormData: CustomerCreate = {
|
||||||
|
status: 'CREATED',
|
||||||
|
personName: '',
|
||||||
|
customerType: 'CORP',
|
||||||
|
customerName: '',
|
||||||
|
customerNameEN: '',
|
||||||
|
taxNo: '',
|
||||||
|
registeredBranchId: branchStore.currentMyBranch?.id || '',
|
||||||
|
customerBranch: [
|
||||||
|
{
|
||||||
|
code: '',
|
||||||
|
branchNo: 1,
|
||||||
|
address: '',
|
||||||
|
addressEN: '',
|
||||||
|
provinceId: '',
|
||||||
|
districtId: '',
|
||||||
|
subDistrictId: '',
|
||||||
|
zipCode: '',
|
||||||
|
email: '',
|
||||||
|
telephoneNo: '',
|
||||||
|
name: '',
|
||||||
|
status: 'CREATED',
|
||||||
|
taxNo: '',
|
||||||
|
nameEN: '',
|
||||||
|
legalPersonNo: '',
|
||||||
|
registerName: '',
|
||||||
|
registerDate: new Date(),
|
||||||
|
authorizedCapital: '',
|
||||||
|
employmentOffice: '',
|
||||||
|
bussinessType: '',
|
||||||
|
bussinessTypeEN: '',
|
||||||
|
jobPosition: '',
|
||||||
|
jobPositionEN: '',
|
||||||
|
jobDescription: '',
|
||||||
|
saleEmployee: '',
|
||||||
|
payDate: new Date(),
|
||||||
|
wageRate: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
image: null,
|
||||||
|
};
|
||||||
|
let resetCustomerData = structuredClone(defaultFormData);
|
||||||
|
|
||||||
|
const currentFormData = ref<CustomerCreate>(structuredClone(defaultFormData));
|
||||||
|
const state = ref<{
|
||||||
|
dialogType: 'info' | 'edit';
|
||||||
|
dialogOpen: boolean;
|
||||||
|
branchIndex: number;
|
||||||
|
customerType: 'CORP' | "PERS"
|
||||||
|
}>({
|
||||||
|
dialogType: 'info',
|
||||||
|
dialogOpen: false,
|
||||||
|
branchIndex: 0,
|
||||||
|
customerType: "CORP"
|
||||||
|
});
|
||||||
|
|
||||||
|
function isFormDataDifferent() {
|
||||||
|
return (
|
||||||
|
JSON.stringify(resetCustomerData) !==
|
||||||
|
JSON.stringify(currentFormData.value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetFormData(cb?: (...args: any[]) => unknown) {
|
||||||
|
currentFormData.value = structuredClone(resetCustomerData);
|
||||||
|
cb?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function assignFormData(id: string) {
|
||||||
|
const data = await customerStore.fetchById(id);
|
||||||
|
|
||||||
|
if (!data) return;
|
||||||
|
|
||||||
|
resetCustomerData.registeredBranchId = data.registeredBranchId;
|
||||||
|
resetCustomerData.status = data.status;
|
||||||
|
resetCustomerData.customerType = data.customerType;
|
||||||
|
resetCustomerData.customerName = data.customerName;
|
||||||
|
resetCustomerData.customerNameEN = data.customerNameEN;
|
||||||
|
resetCustomerData.personName = data.personName;
|
||||||
|
resetCustomerData.taxNo = data.taxNo;
|
||||||
|
resetCustomerData.image = null;
|
||||||
|
resetCustomerData.customerBranch = data.branch.map((v) => ({
|
||||||
|
id: v.id,
|
||||||
|
code: v.code,
|
||||||
|
branchNo: v.branchNo,
|
||||||
|
address: v.address,
|
||||||
|
addressEN: v.addressEN,
|
||||||
|
provinceId: v.province.id,
|
||||||
|
districtId: v.district.id,
|
||||||
|
subDistrictId: v.subDistrict.id,
|
||||||
|
zipCode: v.zipCode,
|
||||||
|
email: v.email,
|
||||||
|
telephoneNo: v.telephoneNo,
|
||||||
|
name: v.name,
|
||||||
|
status: undefined,
|
||||||
|
taxNo: v.taxNo,
|
||||||
|
nameEN: v.nameEN,
|
||||||
|
legalPersonNo: v.legalPersonNo,
|
||||||
|
registerName: v.registerName,
|
||||||
|
registerDate: new Date(v.registerDate),
|
||||||
|
authorizedCapital: v.authorizedCapital,
|
||||||
|
employmentOffice: v.employmentOffice,
|
||||||
|
bussinessType: v.bussinessType,
|
||||||
|
bussinessTypeEN: v.bussinessTypeEN,
|
||||||
|
jobPosition: v.jobPosition,
|
||||||
|
jobPositionEN: v.jobPositionEN,
|
||||||
|
jobDescription: v.jobDescription,
|
||||||
|
saleEmployee: v.saleEmployee,
|
||||||
|
payDate: new Date(v.payDate),
|
||||||
|
wageRate: v.wageRate,
|
||||||
|
}));
|
||||||
|
|
||||||
|
currentFormData.value = structuredClone(resetCustomerData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
state,
|
||||||
|
currentFormData,
|
||||||
|
isFormDataDifferent,
|
||||||
|
resetFormData,
|
||||||
|
assignFormData,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
export const useEmployeeForm = defineStore('form-employee', () => {
|
||||||
|
return {};
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue