refactor: cleanup
This commit is contained in:
parent
2f10a11927
commit
4cd5ee39e7
2 changed files with 24 additions and 49 deletions
|
|
@ -23,8 +23,6 @@ import {
|
|||
BranchCreate,
|
||||
} from 'src/stores/branch/types';
|
||||
|
||||
const test = ref<File>();
|
||||
|
||||
const profileFile = ref<File | undefined>(undefined);
|
||||
const inputFile = document.createElement('input');
|
||||
inputFile.type = 'file';
|
||||
|
|
@ -71,7 +69,6 @@ const formDataContact = ref<BranchContactCreate>({
|
|||
|
||||
const formType = ref<'edit' | 'create' | 'delete'>('create');
|
||||
const typeBranch = ref<'headOffice' | 'subBranch'>('headOffice');
|
||||
const branchContact = ref<BranchContactCreate[]>();
|
||||
const inputCode = ref<string>('');
|
||||
const formData = ref<BranchCreate>({
|
||||
taxNo: '',
|
||||
|
|
|
|||
|
|
@ -2,13 +2,11 @@
|
|||
import { ref, onMounted, watch } from 'vue';
|
||||
import { api } from 'src/boot/axios';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { dialog } from 'src/stores/utils';
|
||||
import useUserStore from 'stores/user';
|
||||
import useBranchStore from 'src/stores/branch';
|
||||
|
||||
import { UserCreate, UserTypeStats, UserOption } from 'src/stores/user/types';
|
||||
import { BranchUserStats } from 'src/stores/branch/types';
|
||||
// import { dateFormat } from 'src/utils/datetime';
|
||||
|
||||
import PersonCard from 'components/home/PersonCard.vue';
|
||||
import AppBox from 'components/app/AppBox.vue';
|
||||
|
|
@ -17,6 +15,7 @@ import SelectorList from 'components/SelectorList.vue';
|
|||
import AddButton from 'components/AddButton.vue';
|
||||
import TooltipComponent from 'components/TooltipComponent.vue';
|
||||
import FormDialog from 'src/components/FormDialog.vue';
|
||||
import { dateFormat } from 'src/utils/datetime';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const branchStore = useBranchStore();
|
||||
|
|
@ -158,7 +157,7 @@ async function fetchBrOption(id: string) {
|
|||
const res = await branchStore.fetchById(id, {
|
||||
includeSubBranch: true,
|
||||
});
|
||||
if (res.branch) {
|
||||
if (res && res?.branch) {
|
||||
res.branch.map((item) => {
|
||||
userOption.value.brOpts.push({
|
||||
label: item.code,
|
||||
|
|
@ -173,52 +172,31 @@ async function openDialog(id?: string) {
|
|||
modal.value = true;
|
||||
if (id && userData.value) {
|
||||
const foundUser = userData.value.result.find((user) => user.id === id);
|
||||
|
||||
if (foundUser) {
|
||||
formData.value.provinceId = foundUser.provinceId;
|
||||
formData.value.districtId = foundUser.districtId;
|
||||
formData.value.subDistrictId = foundUser.subDistrictId;
|
||||
formData.value.telephoneNo = foundUser.telephoneNo;
|
||||
formData.value.email = foundUser.email;
|
||||
formData.value.zipCode = foundUser.zipCode;
|
||||
formData.value.gender = foundUser.gender;
|
||||
formData.value.addressEN = foundUser.addressEN;
|
||||
formData.value.address = foundUser.address;
|
||||
formData.value.trainingPlace = foundUser.trainingPlace;
|
||||
formData.value.importNationality = foundUser.importNationality;
|
||||
formData.value.sourceNationality = foundUser.sourceNationality;
|
||||
formData.value.licenseExpireDate = foundUser.licenseExpireDate
|
||||
? new Date(foundUser.licenseExpireDate)
|
||||
: null;
|
||||
formData.value.licenseIssueDate = foundUser.licenseIssueDate
|
||||
? new Date(foundUser.licenseIssueDate)
|
||||
: null;
|
||||
formData.value.licenseNo = foundUser.licenseNo;
|
||||
formData.value.discountCondition = foundUser.discountCondition;
|
||||
formData.value.retireDate = foundUser.retireDate
|
||||
? new Date(foundUser.retireDate)
|
||||
: null;
|
||||
formData.value.startDate = foundUser.startDate
|
||||
? new Date(foundUser.startDate)
|
||||
: null;
|
||||
formData.value.registrationNo = foundUser.registrationNo;
|
||||
formData.value.lastNameEN = foundUser.lastNameEN;
|
||||
formData.value.lastName = foundUser.lastName;
|
||||
formData.value.firstNameEN = foundUser.firstNameEN;
|
||||
formData.value.firstName = foundUser.firstName;
|
||||
formData.value.userRole = foundUser.userRole;
|
||||
formData.value.userType = foundUser.userType;
|
||||
formData.value.keycloakId = foundUser.keycloakId;
|
||||
formData.value.profileImage = new File([], foundUser.profileImageUrl);
|
||||
formData.value.birthDate = foundUser.birthDate
|
||||
? new Date(foundUser.birthDate)
|
||||
: null;
|
||||
formData.value.responsibleArea = foundUser.responsibleArea;
|
||||
formData.value = {
|
||||
...foundUser,
|
||||
licenseExpireDate:
|
||||
(foundUser.licenseExpireDate &&
|
||||
new Date(foundUser.licenseExpireDate)) ||
|
||||
null,
|
||||
licenseIssueDate:
|
||||
(foundUser.licenseIssueDate &&
|
||||
new Date(foundUser.licenseIssueDate)) ||
|
||||
null,
|
||||
retireDate:
|
||||
(foundUser.retireDate && new Date(foundUser.retireDate)) || null,
|
||||
startDate:
|
||||
(foundUser.startDate && new Date(foundUser.startDate)) || null,
|
||||
birthDate:
|
||||
(foundUser.birthDate && new Date(foundUser.birthDate)) || null,
|
||||
};
|
||||
|
||||
userId.value = foundUser.id;
|
||||
hqId.value = foundUser.branch[0].headOfficeId as string;
|
||||
brId.value = foundUser.branch[0].id;
|
||||
code.value = foundUser.code;
|
||||
isEdit.value = true;
|
||||
console.log(hqId.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -626,7 +604,7 @@ watch(
|
|||
dense
|
||||
outlined
|
||||
label="วันที่เริ่มงาน"
|
||||
v-model="formData.startDate"
|
||||
:model-value="dateFormat(formData.startDate)"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
|
|
@ -665,7 +643,7 @@ watch(
|
|||
dense
|
||||
outlined
|
||||
label="วันที่พ้นสภาพพนักงาน"
|
||||
v-model="formData.retireDate"
|
||||
:model-value="dateFormat(formData.retireDate)"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
|
|
@ -704,7 +682,7 @@ watch(
|
|||
dense
|
||||
outlined
|
||||
label="วันที่พ้นสภาพพนักงาน"
|
||||
v-model="formData.birthDate"
|
||||
:model-value="dateFormat(formData.birthDate)"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue