feat: check tab before add

This commit is contained in:
puriphatt 2024-07-30 07:19:14 +00:00
parent 2c9f7ba02d
commit be397112f6
5 changed files with 103 additions and 62 deletions

View file

@ -8,7 +8,7 @@ import useAddressStore, {
} from 'src/stores/address';
import { EmployeeCheckupCreate } from 'src/stores/employee/types';
import { useI18n } from 'vue-i18n';
import { selectFilterOptionRefMod } from 'src/stores/utils';
import { checkTabBeforeAdd, selectFilterOptionRefMod } from 'src/stores/utils';
import { QSelect } from 'quasar';
const { locale } = useI18n();
@ -63,19 +63,22 @@ async function fetchProvince() {
}
function addData() {
employeeCheckup.value?.push({
coverageExpireDate: null,
coverageStartDate: null,
insuranceCompany: '',
medicalBenefitScheme: '',
remark: '',
hospitalName: '',
provinceId: '',
checkupResult: '',
checkupType: '',
});
if (employeeCheckup.value)
tab.value = `tab${employeeCheckup.value.length - 1}`;
const canAdd = checkTabBeforeAdd(employeeCheckup.value || []);
if (canAdd) {
employeeCheckup.value?.push({
coverageExpireDate: null,
coverageStartDate: null,
insuranceCompany: '',
medicalBenefitScheme: '',
remark: '',
hospitalName: '',
provinceId: '',
checkupResult: '',
checkupType: '',
});
if (employeeCheckup.value)
tab.value = `tab${employeeCheckup.value.length - 1}`;
}
}
function removeData(index: number) {
@ -132,7 +135,7 @@ const insuranceCompanyFilter = selectFilterOptionRefMod(
style="background-color: var(--_body-bg); min-width: 40px"
icon="mdi-plus"
padding="8px 8px"
:disable="readonly"
:disable="readonly || !checkTabBeforeAdd(employeeCheckup || [])"
:color="$q.dark.isActive ? 'primary' : ''"
:class="tab !== 'tab0' ? 'bordered-r' : ''"
/>

View file

@ -3,7 +3,7 @@ import { onMounted, ref } from 'vue';
import { dateFormat, parseAndFormatDate } from 'src/utils/datetime';
import { EmployeeWorkCreate } from 'src/stores/employee/types';
import { useI18n } from 'vue-i18n';
import { selectFilterOptionRefMod } from 'src/stores/utils';
import { checkTabBeforeAdd, selectFilterOptionRefMod } from 'src/stores/utils';
const { locale } = useI18n();
@ -33,18 +33,21 @@ defineProps<{
}>();
function addData() {
employeeWork.value?.push({
workEndDate: null,
workPermitExpireDate: null,
workPermitIssuDate: null,
workPermitNo: '',
workplace: '',
jobType: '',
positionName: '',
ownerName: '',
remark: '',
});
if (employeeWork.value) tab.value = `tab${employeeWork.value.length - 1}`;
const canAdd = checkTabBeforeAdd(employeeWork.value || []);
if (canAdd) {
employeeWork.value?.push({
workEndDate: null,
workPermitExpireDate: null,
workPermitIssuDate: null,
workPermitNo: '',
workplace: '',
jobType: '',
positionName: '',
ownerName: '',
remark: '',
});
if (employeeWork.value) tab.value = `tab${employeeWork.value.length - 1}`;
}
}
function removeData(index: number) {
@ -94,7 +97,7 @@ const workplaceFilter = selectFilterOptionRefMod(
style="background-color: var(--_body-bg); min-width: 40px"
icon="mdi-plus"
padding="8px 8px"
:disable="readonly"
:disable="readonly || !checkTabBeforeAdd(employeeWork || [])"
:color="$q.dark.isActive ? 'primary' : ''"
:class="tab !== 'tab0' ? 'bordered-r' : ''"
/>