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