refactor: by value
This commit is contained in:
parent
bbe7604ab2
commit
f334364e8e
2 changed files with 100 additions and 253 deletions
|
|
@ -1,20 +1,30 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { dateFormat, parseAndFormatDate } from 'src/utils/datetime';
|
import DatePicker from 'src/components/shared/DatePicker.vue';
|
||||||
import { ref } from 'vue';
|
|
||||||
|
const citizenId = defineModel<string | undefined>('citizenId', {
|
||||||
|
required: true,
|
||||||
|
});
|
||||||
|
const legalPersonNo = defineModel<string | undefined>('legalPersonNo', {
|
||||||
|
required: true,
|
||||||
|
});
|
||||||
|
const branchCode = defineModel<string | undefined>('branchCode', {
|
||||||
|
required: true,
|
||||||
|
});
|
||||||
|
// const customerCode = defineModel<string | undefined>('customerCode', {
|
||||||
|
// required: true,
|
||||||
|
// });
|
||||||
|
|
||||||
|
const registerName = defineModel<string | undefined>('registerName', {
|
||||||
|
required: true,
|
||||||
|
});
|
||||||
|
const registerNameEN = defineModel<string>('registerNameEN');
|
||||||
|
|
||||||
const id = defineModel<string>('id');
|
|
||||||
const branchNo = defineModel<number>('branchNo');
|
|
||||||
const code = defineModel<string>('code');
|
|
||||||
const taxNo = defineModel<string | null>('taxNo');
|
|
||||||
const name = defineModel<string>('name');
|
|
||||||
const nameEN = defineModel<string>('nameEn');
|
|
||||||
const registerName = defineModel<string>('registerName');
|
|
||||||
const registerDate = defineModel<Date | null>('registerDate');
|
const registerDate = defineModel<Date | null>('registerDate');
|
||||||
const authorizedCapital = defineModel<string>('authorizedCapital');
|
const authorizedCapital = defineModel<string>('authorizedCapital');
|
||||||
|
|
||||||
const test = ref<string>('-');
|
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
|
index: string;
|
||||||
|
customerName?: string;
|
||||||
code?: string;
|
code?: string;
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
prefixId?: string;
|
prefixId?: string;
|
||||||
|
|
@ -34,46 +44,33 @@ defineProps<{
|
||||||
class="col-12 col-md-3"
|
class="col-12 col-md-3"
|
||||||
:label="$t('customer.form.legalPersonNo')"
|
:label="$t('customer.form.legalPersonNo')"
|
||||||
for="input-legal-person-no"
|
for="input-legal-person-no"
|
||||||
:model-value="test"
|
v-model="legalPersonNo"
|
||||||
:rules="[
|
|
||||||
(val: string) =>
|
|
||||||
(val && val.length > 0 && /[a-zA-Z]+/.test(val)) ||
|
|
||||||
$t('formDialogInputHqAbbreviation'),
|
|
||||||
]"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
lazy-rules="ondemand"
|
lazy-rules="ondemand"
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
:readonly="readonly"
|
disable
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
class="col-12 col-md-3"
|
class="col-12 col-md-3"
|
||||||
:label="$t('customer.form.branchCode')"
|
|
||||||
for="input-branch-code"
|
for="input-branch-code"
|
||||||
:model-value="test"
|
:label="$t('customer.form.branchCode')"
|
||||||
:rules="[
|
:readonly="readonly"
|
||||||
(val: string) =>
|
:model-value="`${branchCode}${index}`"
|
||||||
(val && val.length > 0 && /[a-zA-Z]+/.test(val)) ||
|
|
||||||
$t('formDialogInputHqAbbreviation'),
|
|
||||||
]"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
lazy-rules="ondemand"
|
lazy-rules="ondemand"
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
:readonly="readonly"
|
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
|
disable
|
||||||
class="col-12 col-md-3"
|
class="col-12 col-md-3"
|
||||||
:label="$t('customer.form.customerCode')"
|
|
||||||
for="input-customer-code"
|
for="input-customer-code"
|
||||||
:model-value="test"
|
:readonly="readonly"
|
||||||
:rules="[
|
:label="$t('customer.form.customerCode')"
|
||||||
(val: string) =>
|
:model-value="customerName"
|
||||||
(val && val.length > 0 && /[a-zA-Z]+/.test(val)) ||
|
|
||||||
$t('formDialogInputHqAbbreviation'),
|
|
||||||
]"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
|
|
@ -85,12 +82,7 @@ defineProps<{
|
||||||
class="col-12 col-md-3"
|
class="col-12 col-md-3"
|
||||||
:label="$t('customer.form.legalPersonCode')"
|
:label="$t('customer.form.legalPersonCode')"
|
||||||
for="input-legal-person-code"
|
for="input-legal-person-code"
|
||||||
:model-value="test"
|
:model-value="legalPersonNo"
|
||||||
:rules="[
|
|
||||||
(val: string) =>
|
|
||||||
(val && val.length > 0 && /[a-zA-Z]+/.test(val)) ||
|
|
||||||
$t('formDialogInputHqAbbreviation'),
|
|
||||||
]"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
|
|
@ -102,12 +94,7 @@ defineProps<{
|
||||||
class="col-12 col-md-6"
|
class="col-12 col-md-6"
|
||||||
:label="$t('customer.form.registerName')"
|
:label="$t('customer.form.registerName')"
|
||||||
for="input-register-name"
|
for="input-register-name"
|
||||||
:model-value="test"
|
v-model="registerName"
|
||||||
:rules="[
|
|
||||||
(val: string) =>
|
|
||||||
(val && val.length > 0 && /[a-zA-Z]+/.test(val)) ||
|
|
||||||
$t('formDialogInputHqAbbreviation'),
|
|
||||||
]"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
|
|
@ -119,12 +106,7 @@ defineProps<{
|
||||||
class="col-12 col-md-6"
|
class="col-12 col-md-6"
|
||||||
:label="$t('customer.form.registerNameEN')"
|
:label="$t('customer.form.registerNameEN')"
|
||||||
for="input-register-name-en"
|
for="input-register-name-en"
|
||||||
:model-value="test"
|
v-model="registerNameEN"
|
||||||
:rules="[
|
|
||||||
(val: string) =>
|
|
||||||
(val && val.length > 0 && /[a-zA-Z]+/.test(val)) ||
|
|
||||||
$t('formDialogInputHqAbbreviation'),
|
|
||||||
]"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
|
|
@ -136,202 +118,57 @@ defineProps<{
|
||||||
class="col-12 col-md-2"
|
class="col-12 col-md-2"
|
||||||
:label="$t('customer.form.authorizedCapital')"
|
:label="$t('customer.form.authorizedCapital')"
|
||||||
for="input-authorized-capital"
|
for="input-authorized-capital"
|
||||||
:model-value="test"
|
v-model="authorizedCapital"
|
||||||
:rules="[
|
|
||||||
(val: string) =>
|
|
||||||
(val && val.length > 0 && /[a-zA-Z]+/.test(val)) ||
|
|
||||||
$t('formDialogInputHqAbbreviation'),
|
|
||||||
]"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-input
|
<DatePicker
|
||||||
lazy-rules="ondemand"
|
v-model="registerDate"
|
||||||
dense
|
:id="`${prefixId}-input-register-date`"
|
||||||
outlined
|
|
||||||
:readonly="readonly"
|
|
||||||
hide-bottom-space
|
|
||||||
class="col-12 col-md-2"
|
|
||||||
:label="$t('customer.form.registerDate')"
|
:label="$t('customer.form.registerDate')"
|
||||||
for="input-register-date"
|
|
||||||
:model-value="test"
|
|
||||||
:rules="[
|
|
||||||
(val: string) =>
|
|
||||||
(val && val.length > 0 && /[a-zA-Z]+/.test(val)) ||
|
|
||||||
$t('formDialogInputHqAbbreviation'),
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<q-input
|
|
||||||
lazy-rules="ondemand"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
:readonly="readonly"
|
:readonly="readonly"
|
||||||
hide-bottom-space
|
clearable
|
||||||
class="col-12 col-md-2"
|
|
||||||
:label="$t('customer.form.registerCompanyName')"
|
|
||||||
for="input-register-company-name"
|
|
||||||
:model-value="test"
|
|
||||||
:rules="[
|
|
||||||
(val: string) =>
|
|
||||||
(val && val.length > 0 && /[a-zA-Z]+/.test(val)) ||
|
|
||||||
$t('formDialogInputHqAbbreviation'),
|
|
||||||
]"
|
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-if="customerType === 'PERS'"></template>
|
<template v-if="customerType === 'PERS'">
|
||||||
<!-- <q-input
|
<q-input
|
||||||
lazy-rules="ondemand"
|
lazy-rules="ondemand"
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
:readonly="!!id || readonly"
|
:disable="index !== '0'"
|
||||||
hide-bottom-space
|
:readonly="readonly"
|
||||||
:label="$t('customerBranch.form.no')"
|
hide-bottom-space
|
||||||
v-model="branchNo"
|
class="col-12 col-md-3"
|
||||||
:for="`${prefixId}-input-branch-branch-no`"
|
:label="$t('customer.form.cardNumber')"
|
||||||
type="number"
|
for="input-legal-person-no"
|
||||||
class="col-12 col-md-2"
|
v-model="citizenId"
|
||||||
/>
|
/>
|
||||||
<q-input
|
|
||||||
lazy-rules="ondemand"
|
<q-input
|
||||||
dense
|
lazy-rules="ondemand"
|
||||||
outlined
|
dense
|
||||||
readonly
|
outlined
|
||||||
hide-bottom-space
|
:disable="!readonly"
|
||||||
:label="$t('customerBranch.form.code')"
|
:readonly="readonly"
|
||||||
:model-value="code || '-'"
|
hide-bottom-space
|
||||||
:for="`${prefixId}-input-branch-branch-code`"
|
class="col-12 col-md-3"
|
||||||
class="col-12 col-md-4"
|
:label="$t('customer.form.branchCode')"
|
||||||
/>
|
for="input-branch-code"
|
||||||
<q-input
|
:model-value="`${branchCode}${index}`"
|
||||||
lazy-rules="ondemand"
|
/>
|
||||||
dense
|
|
||||||
outlined
|
<q-input
|
||||||
:readonly="readonly"
|
lazy-rules="ondemand"
|
||||||
hide-bottom-space
|
dense
|
||||||
:label="$t('customerBranch.form.taxNo')"
|
outlined
|
||||||
v-model="taxNo"
|
:disable="!readonly"
|
||||||
:for="`${prefixId}-input-branch-tax-no`"
|
:readonly="readonly"
|
||||||
type="number"
|
hide-bottom-space
|
||||||
class="col-12 col-md-4"
|
class="col-12 col-md-3"
|
||||||
/>
|
:label="$t('customer.form.customerCode')"
|
||||||
<q-input
|
for="input-customer-code"
|
||||||
lazy-rules="ondemand"
|
:model-value="customerName"
|
||||||
dense
|
/>
|
||||||
outlined
|
</template>
|
||||||
:readonly="readonly"
|
|
||||||
hide-bottom-space
|
|
||||||
:label="$t('customerBranch.form.name')"
|
|
||||||
v-model="name"
|
|
||||||
:for="`${prefixId}-input-branch-tax-no`"
|
|
||||||
class="col-12 col-md-6"
|
|
||||||
/>
|
|
||||||
<q-input
|
|
||||||
lazy-rules="ondemand"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
:readonly="readonly"
|
|
||||||
hide-bottom-space
|
|
||||||
:label="$t('customerBranch.form.nameEN')"
|
|
||||||
v-model="nameEN"
|
|
||||||
:for="`${prefixId}-input-branch-tax-no`"
|
|
||||||
class="col-12 col-md-6"
|
|
||||||
/>
|
|
||||||
<q-input
|
|
||||||
lazy-rules="ondemand"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
v-if="customerType === 'CORP'"
|
|
||||||
:readonly="readonly"
|
|
||||||
hide-bottom-space
|
|
||||||
:label="$t('customerBranch.form.registerName')"
|
|
||||||
v-model="registerName"
|
|
||||||
:for="`${prefixId}-input-branch-register-name`"
|
|
||||||
class="col-12 col-md-4"
|
|
||||||
/>
|
|
||||||
<q-input
|
|
||||||
lazy-rules="ondemand"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
:readonly="readonly"
|
|
||||||
hide-bottom-space
|
|
||||||
v-if="customerType === 'CORP'"
|
|
||||||
:label="$t('customerBranch.form.authorizedCapital')"
|
|
||||||
v-model="authorizedCapital"
|
|
||||||
:for="`${prefixId}-input-branch-authorized-capital`"
|
|
||||||
class="col-12 col-md-4"
|
|
||||||
/>
|
|
||||||
<VueDatePicker
|
|
||||||
:id="`${prefixId}-picker-date-register-date`"
|
|
||||||
:teleport="true"
|
|
||||||
utc
|
|
||||||
v-if="customerType === 'CORP'"
|
|
||||||
auto-apply
|
|
||||||
v-model="registerDate"
|
|
||||||
:dark="$q.dark.isActive"
|
|
||||||
:locale="$i18n.locale === 'th-th' ? 'th' : 'en'"
|
|
||||||
:enableTimePicker="false"
|
|
||||||
:disabled="readonly"
|
|
||||||
class="col-md-4 col-12"
|
|
||||||
>
|
|
||||||
<template #year="{ value }">
|
|
||||||
{{ $i18n.locale === 'th-th' ? value + 543 : value }}
|
|
||||||
</template>
|
|
||||||
<template #year-overlay-value="{ value }">
|
|
||||||
{{ $i18n.locale === 'th-th' ? value + 543 : value }}
|
|
||||||
</template>
|
|
||||||
<template #trigger>
|
|
||||||
<q-input
|
|
||||||
lazy-rules="ondemand"
|
|
||||||
:for="`${prefixId}-input-start-date`"
|
|
||||||
:id="`${prefixId}-input-start-date`"
|
|
||||||
:label="$t('customerBranch.form.registerDate')"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
:readonly="readonly"
|
|
||||||
placeholder="DD/MM/YYYY"
|
|
||||||
:mask="readonly ? '' : '##/##/####'"
|
|
||||||
:model-value="
|
|
||||||
registerDate
|
|
||||||
? readonly
|
|
||||||
? dateFormat(registerDate)
|
|
||||||
: dateFormat(registerDate, false, false, true)
|
|
||||||
: undefined
|
|
||||||
"
|
|
||||||
@update:model-value="
|
|
||||||
(v) => {
|
|
||||||
if (readonly && v && v.toString().length === 10) {
|
|
||||||
const _date = parseAndFormatDate(v, $i18n.locale);
|
|
||||||
if (_date) {
|
|
||||||
registerDate?.setDate(_date.getDate());
|
|
||||||
registerDate?.setMonth(_date.getMonth());
|
|
||||||
registerDate?.setFullYear(_date.getFullYear());
|
|
||||||
} else {
|
|
||||||
registerDate = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<template v-slot:prepend>
|
|
||||||
<q-icon
|
|
||||||
size="xs"
|
|
||||||
name="mdi-calendar-blank-outline"
|
|
||||||
class="cursor-pointer"
|
|
||||||
color="primary"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template v-slot:append>
|
|
||||||
<q-icon
|
|
||||||
v-if="!registerDate && readonly"
|
|
||||||
name="mdi-close-circle"
|
|
||||||
class="cursor-pointer app-text-muted"
|
|
||||||
size="sm"
|
|
||||||
@click="registerDate = null"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</q-input>
|
|
||||||
</template>
|
|
||||||
</VueDatePicker> -->
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import EmployerFormAttachment from './EmployerFormAttachment.vue';
|
||||||
import {
|
import {
|
||||||
SaveButton,
|
SaveButton,
|
||||||
EditButton,
|
EditButton,
|
||||||
CancelButton,
|
|
||||||
DeleteButton,
|
DeleteButton,
|
||||||
UndoButton,
|
UndoButton,
|
||||||
} from 'components/button';
|
} from 'components/button';
|
||||||
|
|
@ -28,6 +27,8 @@ defineEmits<{
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
|
index: number;
|
||||||
|
customerName: string;
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
prefixId?: string;
|
prefixId?: string;
|
||||||
actionDisabled?: boolean;
|
actionDisabled?: boolean;
|
||||||
|
|
@ -39,9 +40,13 @@ defineProps<{
|
||||||
<span
|
<span
|
||||||
class="col-12 text-weight-bold row items-center q-mb-sm"
|
class="col-12 text-weight-bold row items-center q-mb-sm"
|
||||||
:style="{ opacity: actionDisabled ? '.5' : undefined }"
|
:style="{ opacity: actionDisabled ? '.5' : undefined }"
|
||||||
:id="`form-branch-customer-no-${item.branchNo}`"
|
:id="`form-branch-customer-no-${index}`"
|
||||||
>
|
>
|
||||||
{{ $t('customer.form.branch.title', { name: item.branchNo || 0 }) }}
|
{{
|
||||||
|
index === 0
|
||||||
|
? $t('customer.form.headQuarters.title')
|
||||||
|
: $t('customer.form.branch.title', { name: index || 0 })
|
||||||
|
}}
|
||||||
<EditButton
|
<EditButton
|
||||||
icon-only
|
icon-only
|
||||||
v-if="readonly"
|
v-if="readonly"
|
||||||
|
|
@ -93,16 +98,19 @@ defineProps<{
|
||||||
<q-tab-panels v-model="tab">
|
<q-tab-panels v-model="tab">
|
||||||
<q-tab-panel name="main">
|
<q-tab-panel name="main">
|
||||||
<EmployerFormAbout
|
<EmployerFormAbout
|
||||||
|
:index="index.toString()"
|
||||||
:readonly="readonly"
|
:readonly="readonly"
|
||||||
:customer-type="customerType"
|
:customer-type="customerType"
|
||||||
|
:customer-name="customerName"
|
||||||
|
v-model:citizen-id="item.citizenId"
|
||||||
v-model:id="item.id"
|
v-model:id="item.id"
|
||||||
v-model:branch-no="item.branchNo"
|
v-model:legal-person-no="item.legalPersonNo"
|
||||||
v-model:tax-no="item.taxNo"
|
v-model:branch-code="item.code"
|
||||||
v-model:code="item.code"
|
v-model:customer-code="item.customerCode"
|
||||||
v-model:name="item.name"
|
v-model:register-company-name="item.registerCompanyName"
|
||||||
v-model:name-en="item.nameEN"
|
v-model:register-name="item.registerName"
|
||||||
v-model:registered-name="item.registerName"
|
v-model:register-name-en="item.registerNameEN"
|
||||||
v-model:registered-date="item.registerDate"
|
v-model:register-date="item.registerDate"
|
||||||
v-model:authorized-capital="item.authorizedCapital"
|
v-model:authorized-capital="item.authorizedCapital"
|
||||||
/>
|
/>
|
||||||
</q-tab-panel>
|
</q-tab-panel>
|
||||||
|
|
@ -114,6 +122,8 @@ defineProps<{
|
||||||
:readonly="readonly"
|
:readonly="readonly"
|
||||||
outlined
|
outlined
|
||||||
:title="$t('form.address')"
|
:title="$t('form.address')"
|
||||||
|
v-model:workplace="item.workplace"
|
||||||
|
v-model:workplace-en="item.workplaceEN"
|
||||||
v-model:address="item.address"
|
v-model:address="item.address"
|
||||||
v-model:addressEN="item.addressEN"
|
v-model:addressEN="item.addressEN"
|
||||||
v-model:province-id="item.provinceId"
|
v-model:province-id="item.provinceId"
|
||||||
|
|
@ -130,8 +140,8 @@ defineProps<{
|
||||||
:prefix-id="prefixId || 'employer'"
|
:prefix-id="prefixId || 'employer'"
|
||||||
:readonly="readonly"
|
:readonly="readonly"
|
||||||
v-model:employment-office="item.employmentOffice"
|
v-model:employment-office="item.employmentOffice"
|
||||||
v-model:bussiness-type="item.bussinessType"
|
v-model:bussiness-type="item.businessType"
|
||||||
v-model:bussiness-type-en="item.bussinessTypeEN"
|
v-model:bussiness-type-en="item.businessTypeEN"
|
||||||
v-model:job-position="item.jobPosition"
|
v-model:job-position="item.jobPosition"
|
||||||
v-model:job-position-en="item.jobPositionEN"
|
v-model:job-position-en="item.jobPositionEN"
|
||||||
v-model:job-description="item.jobDescription"
|
v-model:job-description="item.jobDescription"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue