refactor: add employee
This commit is contained in:
parent
aa3ca879d0
commit
b737d16aaa
2 changed files with 44 additions and 5 deletions
|
|
@ -88,7 +88,7 @@ const date = ref();
|
||||||
|
|
||||||
const preSelectedWorker = ref<Employee[]>([]);
|
const preSelectedWorker = ref<Employee[]>([]);
|
||||||
const selectedWorker = ref<Employee[]>([]);
|
const selectedWorker = ref<Employee[]>([]);
|
||||||
const workerList = ref<Employee[]>([]);
|
const workerList = ref<EmployeeWorker[]>([]);
|
||||||
|
|
||||||
const agentPrice = ref(false);
|
const agentPrice = ref(false);
|
||||||
const summaryPrice = ref<{
|
const summaryPrice = ref<{
|
||||||
|
|
@ -132,6 +132,7 @@ const service = ref<Record<Id, Service>>({});
|
||||||
|
|
||||||
const selectedGroupSub = ref<'product' | 'service' | null>(null);
|
const selectedGroupSub = ref<'product' | 'service' | null>(null);
|
||||||
const selectedGroup = ref<ProductGroup | null>(null);
|
const selectedGroup = ref<ProductGroup | null>(null);
|
||||||
|
|
||||||
const selectedProductServiceId = ref('');
|
const selectedProductServiceId = ref('');
|
||||||
|
|
||||||
const formDataEmployee = ref<EmployeeWorker>({
|
const formDataEmployee = ref<EmployeeWorker>({
|
||||||
|
|
@ -167,6 +168,25 @@ async function getAllProduct(
|
||||||
if (ret) productList.value[groupId] = ret.result;
|
if (ret) productList.value[groupId] = ret.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setDefaultFormEmployee() {
|
||||||
|
formDataEmployee.value = {
|
||||||
|
alienReferencNumber: '',
|
||||||
|
documentExpireDate: new Date(),
|
||||||
|
lastNameEN: '',
|
||||||
|
lastName: '',
|
||||||
|
middleNameEN: '',
|
||||||
|
middleName: '',
|
||||||
|
firstNameEN: '',
|
||||||
|
firstName: '',
|
||||||
|
namePrefix: '',
|
||||||
|
nationality: '',
|
||||||
|
gender: '',
|
||||||
|
dateOfBirth: new Date(),
|
||||||
|
};
|
||||||
|
|
||||||
|
employeeFormState.value.dialogModal = false;
|
||||||
|
}
|
||||||
|
|
||||||
async function getAllService(
|
async function getAllService(
|
||||||
groupId: string,
|
groupId: string,
|
||||||
opts?: { force?: false; page?: number; pageSize?: number },
|
opts?: { force?: false; page?: number; pageSize?: number },
|
||||||
|
|
@ -302,7 +322,22 @@ onMounted(async () => {
|
||||||
const retEmp = await customerStore.fetchBranchEmployee(
|
const retEmp = await customerStore.fetchBranchEmployee(
|
||||||
quotationFormData.value.customerBranchId,
|
quotationFormData.value.customerBranchId,
|
||||||
);
|
);
|
||||||
if (retEmp) workerList.value = retEmp.data.result;
|
if (retEmp)
|
||||||
|
workerList.value = retEmp.data.result.map((value) => ({
|
||||||
|
alienReferencNumber: '',
|
||||||
|
documentExpireDate: new Date(),
|
||||||
|
lastNameEN: value.lastNameEN,
|
||||||
|
lastName: value.lastName,
|
||||||
|
middleNameEN: value.middleNameEN,
|
||||||
|
middleName: value.middleName,
|
||||||
|
firstNameEN: value.firstNameEN,
|
||||||
|
firstName: value.firstName,
|
||||||
|
namePrefix: value.namePrefix,
|
||||||
|
nationality: value.nationality,
|
||||||
|
gender: value.gender,
|
||||||
|
dateOfBirth: value.dateOfBirth,
|
||||||
|
code: value.code,
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -624,7 +659,10 @@ onMounted(async () => {
|
||||||
:title="$t('form.title.create', { name: $t('customer.employee') })"
|
:title="$t('form.title.create', { name: $t('customer.employee') })"
|
||||||
:submit="
|
:submit="
|
||||||
() => {
|
() => {
|
||||||
quotationForm;
|
workerList.push(formDataEmployee);
|
||||||
|
quotationForm.injectNewEmployee(formDataEmployee, () =>
|
||||||
|
setDefaultFormEmployee(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
:close="
|
:close="
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ const DEFAULT_DATA: QuotationPayload = {
|
||||||
urgent: false,
|
urgent: false,
|
||||||
customerBranchId: '',
|
customerBranchId: '',
|
||||||
worker: [],
|
worker: [],
|
||||||
workerCount: 0,
|
|
||||||
payBillDate: new Date(),
|
payBillDate: new Date(),
|
||||||
paySplit: [],
|
paySplit: [],
|
||||||
paySplitCount: 0,
|
paySplitCount: 0,
|
||||||
|
|
@ -98,7 +97,7 @@ export const useQuotationForm = defineStore('form-quotation', () => {
|
||||||
currentFormState.value.mode = 'info';
|
currentFormState.value.mode = 'info';
|
||||||
}
|
}
|
||||||
|
|
||||||
function injectNewEmployee(data: EmployeeWorker) {
|
function injectNewEmployee(data: EmployeeWorker, callback?: () => void) {
|
||||||
currentFormData.value.worker.push({
|
currentFormData.value.worker.push({
|
||||||
alienReferencNumber: data.alienReferencNumber,
|
alienReferencNumber: data.alienReferencNumber,
|
||||||
documentExpireDate: data.documentExpireDate,
|
documentExpireDate: data.documentExpireDate,
|
||||||
|
|
@ -113,6 +112,8 @@ export const useQuotationForm = defineStore('form-quotation', () => {
|
||||||
gender: data.gender,
|
gender: data.gender,
|
||||||
dateOfBirth: data.dateOfBirth,
|
dateOfBirth: data.dateOfBirth,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
callback?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
function dialogDelete(callback: () => void) {
|
function dialogDelete(callback: () => void) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue