Merge branch 'develop'
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 5s

This commit is contained in:
Methapon2001 2025-07-17 08:58:25 +07:00
commit 4ec3506e62
19 changed files with 536 additions and 63 deletions

View file

@ -262,7 +262,7 @@ function deleteFile(name: string) {
</div>
<q-file
v-if="userType"
v-if="userType && !readonly"
ref="attachmentRef"
for="input-attachment"
:dense="dense"

View file

@ -54,6 +54,7 @@ defineProps<{
employeeOwnerOption?: CustomerBranch[];
prefixId: string;
showBtnSave?: boolean;
disableCustomerSelect?: boolean;
}>();
defineEmits<{
@ -117,12 +118,16 @@ defineEmits<{
<div class="col-12 row" style="gap: var(--size-2)">
<SelectCustomer
id="form-select-customer-branch-id"
for="form-select-customer-branch-id"
v-model:value="customerBranchId"
v-model:value-option="currentCustomerBranch"
:label="$t('customer.form.branchCode')"
class="col-12 field-two"
simple
required
:readonly
:disabled="disableCustomerSelect && !readonly"
/>
<q-input

View file

@ -68,6 +68,8 @@ defineEmits<{
:readonly
/>
<SelectCustomer
id="about-select-customer-branch-id"
for="about-select-customer-branch-id"
v-model:value="customerBranchId"
:label="$t('quotation.customer')"
:creatable-disabled-text="`(${$t('form.error.selectField', {
@ -88,14 +90,14 @@ defineEmits<{
<style scoped>
:deep(
label.q-field.row.no-wrap.items-start.q-field--outlined.q-select.field-one
) {
label.q-field.row.no-wrap.items-start.q-field--outlined.q-select.field-one
) {
padding-right: 4px;
}
:deep(
label.q-field.row.no-wrap.items-start.q-field--outlined.q-select.field-two
) {
label.q-field.row.no-wrap.items-start.q-field--outlined.q-select.field-two
) {
padding-left: 4px;
}
</style>

View file

@ -1,6 +1,10 @@
<script lang="ts" setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import SelectInput from '../shared/SelectInput.vue';
import useOptionStore from 'src/stores/options';
import { Icon } from '@iconify/vue/dist/iconify.js';
import { useInstitution } from 'src/stores/institution';
const optionStore = useOptionStore();
@ -10,6 +14,11 @@ defineProps<{
readonly?: boolean;
onDrawer?: boolean;
}>();
const emit = defineEmits<{
(e: 'deleteAttachment', name: string): void;
}>();
const attachmentRef = ref();
const group = defineModel('group', { default: '' });
const name = defineModel('name', { default: '' });
@ -17,8 +26,19 @@ const nameEn = defineModel('nameEn', { default: '' });
const contactName = defineModel('contactName', { default: '' });
const email = defineModel('email', { default: '' });
const contactTel = defineModel('contactTel', { default: '' });
const attachment = defineModel<File[]>('attachment');
const attachmentList =
defineModel<{ name: string; url: string }[]>('attachmentList');
type Options = { label: string; value: string };
function openNewTab(url: string) {
window.open(url, '_blank');
}
function deleteAttachment(name: string) {
emit('deleteAttachment', name);
}
</script>
<template>
<div class="row col-12">
@ -162,6 +182,78 @@ type Options = { label: string; value: string };
/>
</template>
</q-input>
<q-file
v-if="!readonly"
ref="attachmentRef"
for="input-attachment"
dense
outlined
multiple
append
:readonly
:label="$t('personnel.form.attachment')"
class="col"
v-model="attachment"
>
<template v-slot:prepend>
<Icon
icon="material-symbols:attach-file"
width="20px"
style="color: var(--brand-1)"
/>
</template>
<template v-slot:file="file">
<div class="row full-width items-center">
<span class="col ellipsis">
{{ file.file.name }}
</span>
<q-btn
dense
rounded
flat
padding="2 2"
class="app-text-muted"
icon="mdi-close-circle"
@click.stop="attachmentRef.removeAtIndex(file.index)"
/>
</div>
</template>
</q-file>
<div v-if="attachmentList && attachmentList?.length > 0" class="col-12">
<q-list bordered separator class="rounded" style="padding: 0">
<q-item
id="attachment-file"
for="attachment-file"
v-for="item in attachmentList"
clickable
:key="item.url"
class="items-center row"
@click="() => openNewTab(item.url)"
>
<q-item-section>
<div class="row items-center justify-between">
<div class="col">
{{ item.name }}
</div>
<q-btn
v-if="!readonly"
id="delete-file"
rounded
flat
dense
unelevated
size="md"
icon="mdi-trash-can-outline"
class="app-text-negative"
@click.stop="deleteAttachment(item.name)"
/>
</div>
</q-item-section>
</q-item>
</q-list>
</div>
</div>
</div>
</template>

View file

@ -12,7 +12,7 @@ import { formatAddress } from 'src/utils/address';
import useOptionStore from 'stores/options';
const optionStore = useOptionStore();
defineProps<{
const props = defineProps<{
title?: string;
addressTitle?: string;
addressTitleEN?: string;
@ -30,6 +30,7 @@ defineProps<{
useEmployment?: boolean;
useWorkPlace?: boolean;
useForeignAddress?: boolean;
}>();
const addressStore = useAddressStore();
@ -57,6 +58,25 @@ const subDistrictId = defineModel<string | null | undefined>('subDistrictId');
const zipCode = defineModel<string | null | undefined>('zipCode');
const sameWithEmployer = defineModel<boolean>('sameWithEmployer');
const provinceTextEN = defineModel<string | null | undefined>(
'provinceTextEn',
{
default: '',
},
);
const districtTextEN = defineModel<string | null | undefined>(
'districtTextEn',
{
default: '',
},
);
const subDistrictTextEN = defineModel<string | null | undefined>(
'subDistrictTextEn',
{
default: '',
},
);
const homeCode = defineModel<string | null | undefined>('homeCode');
const employmentOffice = defineModel<string | null | undefined>(
'employmentOffice',
@ -64,6 +84,7 @@ const employmentOffice = defineModel<string | null | undefined>(
const employmentOfficeEN = defineModel<string | null | undefined>(
'employmentOfficeEn',
);
const addressForeign = defineModel<boolean>('addressForeign');
const addrOptions = reactive<{
provinceOps: Province[];
@ -78,14 +99,18 @@ const addrOptions = reactive<{
const area = ref<Office[]>([]);
const fullAddress = computed(() => {
const province = provinceOptions.value.find((v) => v.id === provinceId.value);
const district = districtOptions.value.find((v) => v.id === districtId.value);
const sDistrict = subDistrictOptions.value.find(
(v) => v.id === subDistrictId.value,
);
const province = addressForeign.value
? { id: '1', name: provinceId.value }
: provinceOptions.value.find((v) => v.id === provinceId.value);
const district = addressForeign.value
? { id: '1', name: districtId.value }
: districtOptions.value.find((v) => v.id === districtId.value);
const sDistrict = addressForeign.value
? { id: '1', name: subDistrictId.value }
: subDistrictOptions.value.find((v) => v.id === subDistrictId.value);
if (province && district && sDistrict) {
const fullAddress = formatAddress({
if (province?.name && district?.name && sDistrict?.name) {
const fullAddressText = formatAddress({
address: address.value,
addressEN: addressEN.value,
moo: moo.value ? moo.value : '',
@ -97,21 +122,26 @@ const fullAddress = computed(() => {
province: province as unknown as Province,
district: district as unknown as District,
subDistrict: sDistrict as unknown as SubDistrict,
zipCode: addressForeign.value ? zipCode.value || ' ' : undefined,
});
return fullAddress;
return fullAddressText;
}
return '-';
});
const fullAddressEN = computed(() => {
const province = provinceOptions.value.find((v) => v.id === provinceId.value);
const district = districtOptions.value.find((v) => v.id === districtId.value);
const sDistrict = subDistrictOptions.value.find(
(v) => v.id === subDistrictId.value,
);
const province = addressForeign.value
? { nameEN: provinceTextEN.value }
: provinceOptions.value.find((v) => v.id === provinceId.value);
const district = addressForeign.value
? { nameEN: districtTextEN.value }
: districtOptions.value.find((v) => v.id === districtId.value);
const sDistrict = addressForeign.value
? { nameEN: subDistrictTextEN.value }
: subDistrictOptions.value.find((v) => v.id === subDistrictId.value);
if (province && district && sDistrict) {
const fullAddress = formatAddress({
if (province?.nameEN && district?.nameEN && sDistrict?.nameEN) {
const fullAddressText = formatAddress({
address: address.value,
addressEN: addressEN.value,
moo: moo.value ? moo.value : '',
@ -124,8 +154,9 @@ const fullAddressEN = computed(() => {
district: district as unknown as District,
subDistrict: sDistrict as unknown as SubDistrict,
en: true,
zipCode: addressForeign.value ? zipCode.value || ' ' : undefined,
});
return fullAddress;
return fullAddressText;
}
return '-';
});
@ -149,7 +180,7 @@ async function fetchProvince() {
}
async function fetchDistrict() {
if (!provinceId.value) return;
if (!provinceId.value || addressForeign.value) return;
const result = await addressStore.fetchDistrictByProvinceId(provinceId.value);
if (result) addrOptions.districtOps = result;
@ -168,7 +199,7 @@ async function fetchDistrict() {
}
async function fetchSubDistrict() {
if (!districtId.value) return;
if (!districtId.value || addressForeign.value) return;
const result = await addressStore.fetchSubDistrictByProvinceId(
districtId.value,
);
@ -255,6 +286,16 @@ onMounted(async () => {
await fetchSubDistrict();
});
function clearAddress() {
provinceId.value = null;
districtId.value = null;
subDistrictId.value = null;
provinceTextEN.value = null;
districtTextEN.value = null;
subDistrictTextEN.value = null;
zipCode.value = null;
}
watch(provinceId, fetchDistrict);
watch(districtId, fetchSubDistrict);
@ -313,6 +354,15 @@ watchEffect(async () => {
{{ $t('customerEmployee.form.addressCustom') }}
</span>
</div>
<div v-if="useForeignAddress" class="text-caption q-ml-md app-text-muted">
<q-checkbox
size="xs"
v-model="addressForeign"
@update:model-value="clearAddress"
/>
{{ $t('personnel.form.addressForeign') }}
</div>
</div>
<div class="col-12 row q-col-gutter-y-md">
@ -449,7 +499,24 @@ watchEffect(async () => {
(v) => (typeof v === 'string' ? (street = v) : '')
"
/>
<q-input
v-if="addressForeign"
outlined
hide-bottom-space
class="col-md-3 col-6"
v-model="provinceId"
:dense="dense"
:label="$t('form.province')"
:readonly="readonly || sameWithEmployer"
:for="`${prefixId}-${indexId !== undefined ? `input-province-${indexId}` : 'input-province'}`"
:rules="
disabledRule
? []
: [(val) => (val && val.length > 0) || $t('form.error.required')]
"
/>
<q-select
v-else
autocomplete="off"
outlined
clearable
@ -493,7 +560,24 @@ watchEffect(async () => {
</template>
</q-select>
<q-input
v-if="addressForeign"
outlined
hide-bottom-space
class="col-md-3 col-6"
v-model="districtId"
:dense="dense"
:label="$t('form.district')"
:readonly="readonly || sameWithEmployer"
:for="`${prefixId}-${indexId !== undefined ? `input-district-${indexId}` : 'input-district'}`"
:rules="
disabledRule
? []
: [(val) => (val && val.length > 0) || $t('form.error.required')]
"
/>
<q-select
v-else
autocomplete="off"
outlined
clearable
@ -536,7 +620,25 @@ watchEffect(async () => {
</q-item>
</template>
</q-select>
<q-input
v-if="addressForeign"
outlined
hide-bottom-space
class="col-md-3 col-6"
v-model="subDistrictId"
:dense="dense"
:label="$t('form.district')"
:readonly="readonly || sameWithEmployer"
:for="`${prefixId}-${indexId !== undefined ? `input-sub-district-${indexId}` : 'input-sub-district'}`"
:rules="
disabledRule
? []
: [(val) => (val && val.length > 0) || $t('form.error.required')]
"
/>
<q-select
v-else
autocomplete="off"
outlined
clearable
@ -580,17 +682,27 @@ watchEffect(async () => {
</template>
</q-select>
<q-input
:key="Number(addressForeign)"
hide-bottom-space
:for="`${prefixId}-${indexId !== undefined ? `input-zip-code-${indexId}` : 'input-zip-code'}`"
:dense="dense"
outlined
:disable="!readonly && !sameWithEmployer"
readonly
:disable="!addressForeign && !readonly && !sameWithEmployer"
:readonly="!addressForeign || readonly"
:label="$t('form.zipCode')"
class="col-md-3 col-6"
:model-value="
addrOptions.subDistrictOps
?.filter((x) => x.id === subDistrictId)
.map((x) => x.zipCode)[0] ?? ''
!addressForeign
? (addrOptions.subDistrictOps
?.filter((x) => x.id === subDistrictId)
.map((x) => x.zipCode)[0] ?? '')
: zipCode
"
@update:model-value="(v) => (zipCode = v.toString())"
:rules="
!addressForeign
? []
: [(val) => (val && val.length > 0) || $t('form.error.required')]
"
/>
<q-input
@ -689,7 +801,24 @@ watchEffect(async () => {
(v) => (typeof v === 'string' ? (streetEN = v) : '')
"
/>
<q-input
v-if="addressForeign"
outlined
hide-bottom-space
class="col-md-3 col-6"
v-model="provinceTextEN"
:dense="dense"
label="Province"
:readonly="readonly || sameWithEmployer"
:for="`${prefixId}-${indexId !== undefined ? `input-province-en-${indexId}` : 'input-province-en'}`"
:rules="
disabledRule
? []
: [(val) => (val && val.length > 0) || $t('form.error.required')]
"
/>
<q-select
v-else
autocomplete="off"
outlined
clearable
@ -732,7 +861,25 @@ watchEffect(async () => {
</q-item>
</template>
</q-select>
<q-input
v-if="addressForeign"
outlined
hide-bottom-space
class="col-md-3 col-6"
v-model="districtTextEN"
:dense="dense"
label="District"
:readonly="readonly || sameWithEmployer"
:for="`${prefixId}-${indexId !== undefined ? `input-district-en-${indexId}` : 'input-district-en'}`"
:rules="
disabledRule
? []
: [(val) => (val && val.length > 0) || $t('form.error.required')]
"
/>
<q-select
v-else
autocomplete="off"
outlined
clearable
@ -775,7 +922,25 @@ watchEffect(async () => {
</q-item>
</template>
</q-select>
<q-input
v-if="addressForeign"
outlined
hide-bottom-space
class="col-md-3 col-6"
v-model="subDistrictTextEN"
:dense="dense"
label="Sub-District"
:readonly="readonly || sameWithEmployer"
:for="`${prefixId}-${indexId !== undefined ? `input-sub-district-en-${indexId}` : 'input-sub-district-en'}`"
:rules="
disabledRule
? []
: [(val) => (val && val.length > 0) || $t('form.error.required')]
"
/>
<q-select
v-else
autocomplete="off"
outlined
clearable
@ -819,19 +984,28 @@ watchEffect(async () => {
</template>
</q-select>
<q-input
:key="Number(addressForeign)"
hide-bottom-space
:for="`${prefixId}-${indexId !== undefined ? `input-zip-code-${indexId}` : 'input-zip-code'}`"
:dense="dense"
outlined
readonly
:disable="!readonly && !sameWithEmployer"
:readonly="!addressForeign || readonly"
:disable="!addressForeign && !readonly && !sameWithEmployer"
zip="zip-en"
label="Zip Code"
class="col-md-3 col-6"
:model-value="
addrOptions.subDistrictOps
?.filter((x) => x.id === subDistrictId)
.map((x) => x.zipCode)[0] ?? ''
!addressForeign
? (addrOptions.subDistrictOps
?.filter((x) => x.id === subDistrictId)
.map((x) => x.zipCode)[0] ?? '')
: zipCode
"
@update:model-value="(v) => (zipCode = v.toString())"
:rules="
!addressForeign
? []
: [(val) => (val && val.length > 0) || $t('form.error.required')]
"
/>
<q-input

View file

@ -79,7 +79,7 @@ function setDefaultValue() {
v-model="value"
incremental
option-value="id"
:label
:label="label || $t('menu.manage.businessType')"
:placeholder
:readonly
:disable="disabled"
@ -92,21 +92,13 @@ function setDefaultValue() {
@filter="filter"
>
<template #selected-item="{ opt }">
{{
(lang ?? $i18n.locale) !== 'eng'
? opt.name + ' ' + opt.name
: opt.nameEN + ' ' + opt.nameEN
}}
{{ (lang ?? $i18n.locale) !== 'eng' ? opt.name : opt.nameEN }}
</template>
<template #option="{ opt, scope }">
<q-item v-bind="scope.itemProps">
<span class="row items-center">
{{
(lang ?? $i18n.locale) !== 'eng'
? opt.name + ' ' + opt.name
: opt.nameEN + ' ' + opt.nameEN
}}
{{ (lang ?? $i18n.locale) !== 'eng' ? opt.name : opt.nameEN }}
</span>
</q-item>

View file

@ -476,6 +476,7 @@ export default {
blacklist: 'Black list',
contactName: 'Contact Person',
contactTel: 'Contact Number',
addressForeign: 'Use foreign address',
},
},
customer: {
@ -927,6 +928,7 @@ export default {
contactName: 'Contact Person',
contactTel: 'Contact Number',
bankInfo: 'Bank Information',
attachment: 'Attachment',
},
requestList: {

View file

@ -472,6 +472,7 @@ export default {
blacklist: 'แบล็คลิสต์',
contactName: 'ชื่อผู้ติดต่อ',
contactTel: 'เบอร์โทรศัพท์ผู้ติดต่อ',
addressForeign: 'ใช้ที่อยู่ต่างประเทศ',
},
},
customer: {
@ -924,6 +925,7 @@ export default {
contactName: 'ชื่อผู้ติดต่อ',
contactTel: 'เบอร์โทรผู้ติดต่อ',
bankInfo: 'ข้อมูลธนาคาร',
attachment: 'เอกสารเพิ่มเติม',
},
requestList: {

View file

@ -157,6 +157,14 @@ const defaultFormData = {
contactTel: '',
remark: '',
agencyStatus: '',
addressForeign: false,
provinceText: null,
districtText: null,
subDistrictText: null,
provinceTextEN: null,
districtTextEN: null,
subDistrictTextEN: null,
zipCodeText: null,
};
const formData = ref<UserCreate>({
@ -209,6 +217,14 @@ const formData = ref<UserCreate>({
contactTel: '',
remark: '',
agencyStatus: '',
addressForeign: false,
provinceText: null,
districtText: null,
subDistrictText: null,
provinceTextEN: null,
districtTextEN: null,
subDistrictTextEN: null,
zipCodeText: null,
});
const fieldSelectedOption = ref<{ label: string; value: string }[]>([
@ -431,6 +447,28 @@ async function onSubmit(excludeDialog?: boolean) {
...formData.value,
checkpointEN: formData.value.checkpoint,
status: !statusToggle.value ? 'INACTIVE' : 'ACTIVE',
provinceId: formData.value.addressForeign
? null
: formData.value.provinceId,
districtId: formData.value.addressForeign
? null
: formData.value.districtId,
subDistrictId: formData.value.addressForeign
? null
: formData.value.subDistrictId,
provinceText: formData.value.addressForeign
? formData.value.provinceId
: null,
districtText: formData.value.addressForeign
? formData.value.districtId
: null,
subDistrictText: formData.value.addressForeign
? formData.value.subDistrictId
: null,
zipCodeText: formData.value.addressForeign
? formData.value.zipCode
: null,
} as const;
await userStore.editById(currentUser.value.id, formDataEdit);
@ -462,7 +500,31 @@ async function onSubmit(excludeDialog?: boolean) {
: '';
formData.value.checkpointEN = formData.value.checkpoint;
const result = await userStore.create(
formData.value,
{
...formData.value,
provinceId: formData.value.addressForeign
? null
: formData.value.provinceId,
districtId: formData.value.addressForeign
? null
: formData.value.districtId,
subDistrictId: formData.value.addressForeign
? null
: formData.value.subDistrictId,
provinceText: formData.value.addressForeign
? formData.value.provinceId
: null,
districtText: formData.value.addressForeign
? formData.value.districtId
: null,
subDistrictText: formData.value.addressForeign
? formData.value.subDistrictId
: null,
zipCodeText: formData.value.addressForeign
? formData.value.zipCode
: null,
},
onCreateImageList.value,
);
@ -560,12 +622,20 @@ async function assignFormData(idEdit: string) {
currentUser.value = foundUser;
formData.value = {
branchId: foundUser.branch[0]?.id,
provinceId: foundUser.provinceId,
districtId: foundUser.districtId,
subDistrictId: foundUser.subDistrictId,
provinceId: foundUser.addressForeign
? foundUser.provinceText
: foundUser.provinceId,
districtId: foundUser.addressForeign
? foundUser.districtText
: foundUser.districtId,
subDistrictId: foundUser.addressForeign
? foundUser.subDistrictText
: foundUser.subDistrictId,
telephoneNo: foundUser.telephoneNo,
email: foundUser.email,
zipCode: foundUser.zipCode,
zipCode: foundUser.addressForeign
? foundUser.zipCodeText
: foundUser.zipCode,
gender: foundUser.gender,
addressEN: foundUser.addressEN,
address: foundUser.address,
@ -619,6 +689,10 @@ async function assignFormData(idEdit: string) {
(foundUser.citizenExpire && new Date(foundUser.citizenExpire)) || null,
remark: foundUser.remark || '',
agencyStatus: foundUser.agencyStatus || '',
addressForeign: foundUser.addressForeign || false,
provinceTextEN: foundUser.provinceTextEN,
districtTextEN: foundUser.districtTextEN,
subDistrictTextEN: foundUser.subDistrictTextEN,
};
formData.value.status === 'ACTIVE' || 'CREATED'
@ -745,7 +819,17 @@ watch(
watch(
() => formData.value.userType,
async () => {
async (type) => {
if (type !== 'AGENCY') {
formData.value.addressForeign = false;
formData.value.provinceId = null;
formData.value.districtId = null;
formData.value.subDistrictId = null;
formData.value.provinceTextEN = null;
formData.value.districtTextEN = null;
formData.value.subDistrictTextEN = null;
formData.value.zipCodeText = null;
}
if (!infoDrawerEdit.value) return;
formData.value.registrationNo = null;
formData.value.startDate = null;
@ -1813,10 +1897,15 @@ watch(
v-model:district-id="formData.districtId"
v-model:sub-district-id="formData.subDistrictId"
v-model:zip-code="formData.zipCode"
v-model:address-foreign="formData.addressForeign"
v-model:province-text-en="formData.provinceTextEN"
v-model:district-text-en="formData.districtTextEN"
v-model:sub-district-text-en="formData.subDistrictTextEN"
:readonly="!infoDrawerEdit"
prefix-id="drawer-info-personnel"
:title="'personnel.form.addressInformation'"
dense
:use-foreign-address="formData.userType === 'AGENCY'"
class="q-mb-xl"
/>
<FormByType
@ -2042,8 +2131,13 @@ watch(
v-model:district-id="formData.districtId"
v-model:sub-district-id="formData.subDistrictId"
v-model:zip-code="formData.zipCode"
v-model:address-foreign="formData.addressForeign"
v-model:province-text-en="formData.provinceTextEN"
v-model:district-text-en="formData.districtTextEN"
v-model:sub-district-text-en="formData.subDistrictTextEN"
prefix-id="drawer-info-personnel"
dense
:use-foreign-address="formData.userType === 'AGENCY'"
class="q-mb-xl"
/>
<FormByType

View file

@ -240,7 +240,7 @@ watch(
? payTypeOption.filter((v) => v.value === 'Full')
: payTypeOption
"
:readonly
:readonly="readonly || debitNote"
id="pay-type"
:model-value="payType"
@update:model-value="

View file

@ -21,6 +21,7 @@ import useOcrStore from 'stores/ocr';
// NOTE: Import Components
import {
AddButton,
SaveButton,
EditButton,
UndoButton,
@ -53,6 +54,9 @@ import { SideMenu } from 'src/components';
import BasicInformation from 'components/03_customer-management/employee/BasicInformation.vue';
import { AddressForm } from 'src/components/form';
import ExpirationDate from 'src/components/03_customer-management/ExpirationDate.vue';
import FormEmployeeHealthCheck from 'src/components/03_customer-management/FormEmployeeHealthCheck.vue';
import FormEmployeeWorkHistory from 'src/components/03_customer-management/FormEmployeeWorkHistory.vue';
import FormEmployeeOther from 'src/components/03_customer-management/FormEmployeeOther.vue';
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL;
@ -663,6 +667,7 @@ watch(
:show="
() => {
employeeFormStore.resetFormDataEmployee(true);
setCurrentBranchId();
}
"
:before-close="
@ -1035,6 +1040,7 @@ watch(
</div>
<BasicInformation
disable-customer-select
no-action
id="form-information"
prefix-id="form-employee"

View file

@ -82,6 +82,7 @@ const emit = defineEmits<{
(e: 'addImage'): void;
(e: 'removeImage'): void;
(e: 'submitImage', name: string): void;
(e: 'deleteAttachment', name: string): void;
}>();
const data = defineModel<InstitutionPayload>('data', {
@ -121,6 +122,9 @@ const formBankBook = defineModel<BankBook[]>('formBankBook', {
},
],
});
const attachment = defineModel<File[]>('attachment');
const attachmentList =
defineModel<{ name: string; url: string }[]>('attachmentList');
function viewImage() {
imageState.imageDialog = true;
@ -348,6 +352,7 @@ watch(
v-model:contact-name="data.contactName"
v-model:email="data.contactEmail"
v-model:contact-tel="data.contactTel"
v-model:attachment="attachment"
/>
<AddressForm
id="agencies-form-address-info"
@ -550,6 +555,9 @@ watch(
v-model:contact-name="data.contactName"
v-model:email="data.contactEmail"
v-model:contact-tel="data.contactTel"
v-model:attachment="attachment"
:attachment-list="attachmentList"
@delete-attachment="(name) => $emit('deleteAttachment', name)"
/>
<AddressForm
id="agencies-address-info"

View file

@ -115,6 +115,8 @@ const blankFormData: InstitutionPayload = {
],
};
const attachment = ref<File[]>([]);
const attachmentList = ref<{ name: string; url: string }[]>([]);
const statusFilter = ref<'all' | 'statusACTIVE' | 'statusINACTIVE'>('all');
const refAgenciesDialog = ref();
const formData = ref<InstitutionPayload>(structuredClone(blankFormData));
@ -145,6 +147,8 @@ function resetForm() {
pageState.addModal = false;
pageState.viewDrawer = false;
currAgenciesData.value = undefined;
attachment.value = [];
attachmentList.value = [];
formData.value = structuredClone(blankFormData);
}
@ -154,7 +158,7 @@ function undo() {
pageState.isDrawerEdit = false;
}
function assignFormData(data: Institution) {
async function assignFormData(data: Institution) {
currAgenciesData.value = data;
formData.value = {
group: data.group,
@ -187,6 +191,8 @@ function assignFormData(data: Institution) {
bankUrl: `${baseUrl}/institution/${data.id}/bank-qr/${v.id}?ts=${Date.now()}`,
})),
};
await fetchAttachment();
}
async function submit(opt?: { selectedImage: string }) {
@ -228,18 +234,29 @@ async function submit(opt?: { selectedImage: string }) {
);
if (ret) {
attachment.value.forEach(async (file) => {
await institutionStore.putAttachment({
parentId: ret.id || '',
name: file.name,
file: file,
});
});
pageState.isDrawerEdit = false;
currAgenciesData.value = ret;
formData.value.selectedImage = ret.selectedImage;
await fetchData($q.screen.xs);
attachment.value = [];
if (refAgenciesDialog.value && opt?.selectedImage) {
refAgenciesDialog.value.clearImageState();
}
setTimeout(async () => {
await fetchAttachment();
}, 300);
return;
}
} else {
await institutionStore.createInstitution(
const res = await institutionStore.createInstitution(
{
...payload,
code: formData.value.group || '',
@ -247,6 +264,16 @@ async function submit(opt?: { selectedImage: string }) {
imageListOnCreate.value,
);
if (!res) return;
attachment.value.forEach(async (file) => {
await institutionStore.putAttachment({
parentId: res.id || '',
name: file.name,
file: file,
});
});
await fetchData($q.screen.xs);
pageState.addModal = false;
return;
@ -346,6 +373,49 @@ async function changeStatus(id?: string) {
}
}
async function deleteAttachment(attachmentName: string) {
dialog({
color: 'negative',
icon: 'mdi-trash-can-outline',
title: t('dialog.title.confirmDelete', {
msg: t('personnel.form.attachment'),
}),
actionText: t('general.delete'),
persistent: true,
message: t('dialog.message.confirmDelete'),
action: async () => {
if (!currAgenciesData.value?.id) return;
institutionStore.delAttachment({
parentId: currAgenciesData.value?.id,
name: attachmentName,
});
setTimeout(async () => {
await fetchAttachment();
}, 300);
},
cancel: () => {},
});
}
async function fetchAttachment() {
const resAttachment = await institutionStore.listAttachment({
parentId: currAgenciesData.value.id,
});
if (!resAttachment) return;
attachmentList.value = await Promise.all(
resAttachment.map(async (f) => ({
name: f,
url: await institutionStore.getAttachment({
parentId: currAgenciesData.value.id,
name: f,
download: false,
}),
})),
);
}
onMounted(async () => {
navigatorStore.current.title = 'agencies.title';
navigatorStore.current.path = [{ text: 'agencies.caption', i18n: true }];
@ -976,6 +1046,7 @@ watch(
}
"
@change-status="triggerChangeStatus"
@delete-attachment="deleteAttachment"
:readonly="!pageState.isDrawerEdit"
:isEdit="pageState.isDrawerEdit"
:hide-action="!canAccess('agencies', 'edit')"
@ -985,6 +1056,8 @@ watch(
v-model:form-bank-book="formData.bank"
v-model:image-list-on-create="imageListOnCreate"
v-model:deletes-status-qr-code-bank-imag="deletesStatusQrCodeBankImag"
v-model:attachment="attachment"
:attachment-list="attachmentList"
/>
</template>
<style scoped>

View file

@ -218,7 +218,7 @@ const selectedWorkerItem = computed(() => {
employeeName:
locale.value === Lang.English
? `${e.firstNameEN} ${e.lastNameEN}`
: `${e.firstName} ${e.lastName}`,
: `${e.firstName || e.firstNameEN} ${e.lastName || e.lastNameEN}`,
birthDate: dateFormatJS({ date: e.dateOfBirth }),
gender: e.gender,
age: calculateAge(e.dateOfBirth),
@ -235,11 +235,11 @@ const selectedWorkerItem = computed(() => {
})),
...newWorkerList.value.map((v: any) => ({
foreignRefNo: v.passportNo,
foreignRefNo: v.passportNo || '-',
employeeName:
locale.value === Lang.English
? `${v.firstNameEN} ${v.lastNameEN}`
: `${v.firstName} ${v.lastName}`,
: `${v.firstName || v.firstNameEN} ${v.lastName || v.lastNameEN}`,
birthDate: dateFormatJS({ date: v.dateOfBirth }),
gender: v.gender,
age: calculateAge(v.dateOfBirth),
@ -815,7 +815,7 @@ async function submit() {
}),
...newWorkerList.value.map((v) => {
const { attachment, ...payload } = v;
return payload;
return pageState.mode === 'edit' ? payload.id : payload;
}),
]),
),
@ -1134,10 +1134,10 @@ async function submitAccepted() {
view === QuotationStatus.Accepted
"
:total-price="summaryPrice.finalPrice"
:pay-split="[]"
class="q-mb-md"
v-model:pay-type="currentFormData.payCondition"
v-model:pay-split-count="currentFormData.paySplitCount"
v-model:pay-split="currentFormData.paySplit"
v-model:final-discount="currentFormData.discount"
v-model:pay-bill-date="currentFormData.payBillDate"
v-model:summary-price="summaryPrice"

View file

@ -1,5 +1,6 @@
<script setup lang="ts">
import { AddButton } from 'components/button';
import ToggleButton from 'src/components/button/ToggleButton.vue';
import WorkerItem from 'src/components/05_quotation/WorkerItem.vue';
defineProps<{
@ -48,8 +49,8 @@ const toggleWorker = defineModel<boolean>('toggleWorker');
{{ $t('quotation.employeeList') }}
</span>
<template v-if="!readonly">
<ToggleButton class="q-mr-sm" v-model="toggleWorker" />
{{ toggleWorker ? $t('general.specify') : $t('general.noSpecify') }}
<!-- <ToggleButton class="q-mr-sm" v-model="toggleWorker" />
{{ toggleWorker ? $t('general.specify') : $t('general.noSpecify') }} -->
</template>
</div>
<nav class="q-ml-auto">

View file

@ -5,9 +5,11 @@ import { api } from 'src/boot/axios';
import { PaginationResult } from 'src/types';
import useFlowStore from '../flow';
import { Status } from '../types';
import { baseUrl, manageAttachment, manageFile, manageMeta } from '../utils';
export const useInstitution = defineStore('institution-store', () => {
const flowStore = useFlowStore();
const attachmentManager = manageAttachment(api, 'institution');
const data = ref<Institution[]>([]);
const page = ref<number>(1);
@ -200,6 +202,7 @@ export const useInstitution = defineStore('institution-store', () => {
}
return {
...attachmentManager,
data,
page,
pageMax,

View file

@ -61,6 +61,14 @@ export type User = {
contactTel?: string;
remark?: string;
agencyStatus?: AgencyStatus;
addressForeign?: boolean;
provinceText?: string | null;
districtText?: string | null;
subDistrictText?: string | null;
provinceTextEN?: string | null;
districtTextEN?: string | null;
subDistrictTextEN?: string | null;
zipCodeText?: string | null;
};
export type UserCreate = {
@ -113,6 +121,14 @@ export type UserCreate = {
contactTel?: string;
remark?: string;
agencyStatus?: AgencyStatus | string;
addressForeign?: boolean;
provinceText?: string | null;
districtText?: string | null;
subDistrictText?: string | null;
provinceTextEN?: string | null;
districtTextEN?: string | null;
subDistrictTextEN?: string | null;
zipCodeText?: string | null;
};
export enum AgencyStatus {

View file

@ -14,6 +14,7 @@ export function formatAddress(opt: {
district?: District | null;
subDistrict?: SubDistrict | null;
en?: boolean;
zipCode?: string;
}) {
const { t } = useI18n();
let addressParts: string[];
@ -58,7 +59,9 @@ export function formatAddress(opt: {
// );
}
if (opt.subDistrict) addressParts.push(`${opt.subDistrict.zipCode}`);
if (opt.subDistrict && !opt.zipCode)
addressParts.push(`${opt.subDistrict.zipCode}`);
if (opt.zipCode) addressParts.push(`${opt.zipCode}`);
return addressParts.join(' ');
}

View file

@ -74,7 +74,7 @@ const templates = {
const branch = v.request.quotation.customerBranch;
return (
`${i + 1}. ` +
` ${v.request.code}_${branch.customer.customerType === 'PERS' ? `นายจ้าง ${branch.namePrefix}. ${branch.firstNameEN} ${branch.lastNameEN} `.toUpperCase() : branch.registerName}_` +
` ${v.request.code}_${branch.customer.customerType === 'PERS' ? `${branch.namePrefix}. ${branch.firstNameEN} ${branch.lastNameEN} `.toUpperCase() : branch.registerName}_` +
`${employee.namePrefix}. ${employee.firstNameEN} ${employee.lastNameEN} `.toUpperCase() +
`${!!v.failedType && v.failedType !== 'other' ? `${i18n.global.t(`taskOrder.${v.failedType}`)}` : !!v.failedComment ? v.failedComment : ''}`
);