Merge branch 'develop'

This commit is contained in:
Net 2024-09-25 15:02:19 +07:00
commit 74113934f4
9 changed files with 71 additions and 52 deletions

View file

@ -404,6 +404,7 @@ watch(
:id="`${prefixId}-input-citizen-issue`" :id="`${prefixId}-input-citizen-issue`"
:readonly="readonly" :readonly="readonly"
:label="$t('personnel.form.citizenIssue')" :label="$t('personnel.form.citizenIssue')"
:disabled-dates="disabledAfterToday"
:rules="[ :rules="[
(val: string) => (val: string) =>
!!val || !!val ||

View file

@ -242,11 +242,11 @@ defineEmits<{
<div <div
v-if="obj" v-if="obj"
class="bordered col surface-2 column justify-center items-center no-wrap scroll" class="bordered col surface-2 column items-center no-wrap scroll"
> >
<slot name="content"> <slot name="content">
<template v-if="columns !== undefined"> <template v-if="columns !== undefined">
<div class="full-height full-width q-pa-md"> <div class="full-width q-pa-md">
<TableComponents <TableComponents
buttomDownload buttomDownload
@download=" @download="

View file

@ -263,7 +263,7 @@ onMounted(async () => {
// object, we are effectively unselecting any HQ branch. // object, we are effectively unselecting any HQ branch.
]; ];
await fetchList({ pageSize: 99999, tree: true }); await fetchList({ pageSize: 99999, tree: true, withHead: true });
await calculateStats(); await calculateStats();
modeView.value = $q.screen.lt.md ? true : false; modeView.value = $q.screen.lt.md ? true : false;
@ -447,7 +447,7 @@ async function fetchBranchById(id: string) {
} }
formData.value = { formData.value = {
remark: res.remark, remark: res.remark || '',
code: res.code, code: res.code,
headOfficeId: res.headOfficeId, headOfficeId: res.headOfficeId,
taxNo: res.taxNo, taxNo: res.taxNo,
@ -641,7 +641,7 @@ async function triggerDelete(id: string) {
const res = await branchStore.deleteById(id); const res = await branchStore.deleteById(id);
if (res) { if (res) {
await fetchList({ tree: true, pageSize: 99999 }); await fetchList({ tree: true, pageSize: 99999, withHead: true });
modalDrawer.value = false; modalDrawer.value = false;
modal.value = false; modal.value = false;
await calculateStats(); await calculateStats();
@ -705,13 +705,14 @@ async function fetchList(opts: {
zipCode?: string; zipCode?: string;
query?: string; query?: string;
tree?: boolean; tree?: boolean;
withHead?: boolean;
filter?: 'head' | 'sub'; filter?: 'head' | 'sub';
}) { }) {
await branchStore.fetchList(opts); await branchStore.fetchList(opts);
} }
watch(inputSearch, () => { watch(inputSearch, () => {
fetchList({ tree: true, query: inputSearch.value }); fetchList({ tree: true, query: inputSearch.value, withHead: true });
currentSubBranch.value = undefined; currentSubBranch.value = undefined;
}); });
@ -737,7 +738,7 @@ async function triggerChangeStatus(
}); });
if (res) resolve(res); if (res) resolve(res);
await fetchList({ tree: true, pageSize: 99999 }); await fetchList({ tree: true, pageSize: 99999, withHead: true });
}, },
cancel: () => {}, cancel: () => {},
}); });
@ -767,7 +768,7 @@ async function onSubmit(submitSelectedItem?: boolean) {
formData.value.codeHeadOffice = formData.value.code = res.code; formData.value.codeHeadOffice = formData.value.code = res.code;
imageUrl.value = `${baseUrl}/branch/${res.id}/image/${res.selectedImage}`; imageUrl.value = `${baseUrl}/branch/${res.id}/image/${res.selectedImage}`;
await fetchList({ tree: true, pageSize: 99999 }); await fetchList({ tree: true, pageSize: 99999, withHead: true });
if (!imageDialog.value) modalDrawer.value = submitSelectedItem || false; if (!imageDialog.value) modalDrawer.value = submitSelectedItem || false;
} }
@ -797,7 +798,7 @@ async function onSubmit(submitSelectedItem?: boolean) {
formType.value = 'view'; formType.value = 'view';
} }
await fetchList({ tree: true, pageSize: 99999 }); await fetchList({ tree: true, pageSize: 99999, withHead: true });
}; };
if ( if (
@ -2069,7 +2070,7 @@ watch(currentHq, () => {
formType = 'view'; formType = 'view';
} }
await fetchList({ tree: true, pageSize: 99999 }); await fetchList({ tree: true, pageSize: 99999, withHead: true });
} }
" "
:menu="formMenuIcon" :menu="formMenuIcon"

View file

@ -2221,7 +2221,7 @@ const emptyCreateDialog = ref(false);
customerFormState.editCustomerId, customerFormState.editCustomerId,
); );
await fetchListCustomer(); await fetchListCustomer(true);
customerFormStore.resetForm(); customerFormStore.resetForm();
} }
" "

View file

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { QSelect } from 'quasar'; import { QSelect } from 'quasar';
import { onMounted, ref, watch, capitalize } from 'vue'; import { onMounted, ref, watch, capitalize } from 'vue';
import { formatNumberDecimal, selectFilterOptionRefMod } from 'stores/utils'; import { selectFilterOptionRefMod, commaInput } from 'stores/utils';
import { calculateAge, disabledAfterToday } from 'src/utils/datetime'; import { calculateAge, disabledAfterToday } from 'src/utils/datetime';
import useOptionStore from 'src/stores/options'; import useOptionStore from 'src/stores/options';
@ -108,6 +108,36 @@ watch(
<template> <template>
<div class="row q-col-gutter-sm"> <div class="row q-col-gutter-sm">
<template v-if="customerType === 'CORP'"> <template v-if="customerType === 'CORP'">
<div class="col-12 row q-col-gutter-sm">
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-12 col-md-6"
:label="$t('customer.form.registerName')"
for="input-register-name"
v-model="registerName"
:rules="[(val: string) => !!val || $t('form.error.required')]"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-12 col-md-6"
label="Company name"
for="input-register-name-en"
v-model="registerNameEN"
:rules="[
(val: string) => !!val || $t('form.error.required'),
(val: string) =>
/^[0-9A-Za-z\s.,]+$/.test(val) || $t('form.error.letterOnly'),
]"
/>
</div>
<div class="col-12 row q-col-gutter-sm"> <div class="col-12 row q-col-gutter-sm">
<q-input <q-input
dense dense
@ -166,36 +196,6 @@ watch(
/> />
</div> </div>
<div class="col-12 row q-col-gutter-sm">
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-12 col-md-6"
:label="$t('customer.form.registerName')"
for="input-register-name"
v-model="registerName"
:rules="[(val: string) => !!val || $t('form.error.required')]"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-12 col-md-6"
label="Company name"
for="input-register-name-en"
v-model="registerNameEN"
:rules="[
(val: string) => !!val || $t('form.error.required'),
(val: string) =>
/^[0-9A-Za-z\s.,]+$/.test(val) || $t('form.error.letterOnly'),
]"
/>
</div>
<div class="col-12 row q-col-gutter-sm"> <div class="col-12 row q-col-gutter-sm">
<DatePicker <DatePicker
v-model="registerDate" v-model="registerDate"
@ -214,14 +214,10 @@ watch(
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=" :model-value="authorizedCapital"
!readonly
? authorizedCapital
: formatNumberDecimal(+authorizedCapital, 2)
"
@update:model-value=" @update:model-value="
(v) => { (v) => {
authorizedCapital = `${v}`; if (typeof v === 'string') authorizedCapital = commaInput(v);
} }
" "
/> />

View file

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { selectFilterOptionRefMod } from 'stores/utils'; import { selectFilterOptionRefMod, commaInput } from 'stores/utils';
import { onMounted, watch } from 'vue'; import { onMounted, watch } from 'vue';
import { ref } from 'vue'; import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
@ -13,9 +13,10 @@ const jobPosition = defineModel<string>('jobPosition');
const jobDescription = defineModel<string>('jobDescription'); const jobDescription = defineModel<string>('jobDescription');
const payDate = defineModel<string>('payDate'); const payDate = defineModel<string>('payDate');
const payDateEN = defineModel<string>('payDateEN'); const payDateEN = defineModel<string>('payDateEN');
const wageRate = defineModel<number>('wageRate'); const wageRate = defineModel<number | string>('wageRate');
const wageRateText = defineModel<string>('wageRateText'); const wageRateText = defineModel<string>('wageRateText');
const wageRate4Show = ref('');
const typeBusinessOption = ref([]); const typeBusinessOption = ref([]);
const typeBusinessENOption = ref([]); const typeBusinessENOption = ref([]);
const jobPositionOption = ref([]); const jobPositionOption = ref([]);
@ -272,7 +273,6 @@ let jobPositionENFilter = selectFilterOptionRefMod(
(v) => (typeof v === 'string' ? (payDateEN = v) : '') (v) => (typeof v === 'string' ? (payDateEN = v) : '')
" "
/> />
<q-input <q-input
:for="`${prefixId}-input-pay-rate`" :for="`${prefixId}-input-pay-rate`"
:id="`${prefixId}-input-pay-rate`" :id="`${prefixId}-input-pay-rate`"
@ -282,7 +282,18 @@ let jobPositionENFilter = selectFilterOptionRefMod(
hide-bottom-space hide-bottom-space
class="col-md-3 col-6" class="col-md-3 col-6"
:label="$t('customer.form.payRate')" :label="$t('customer.form.payRate')"
v-model="wageRate" :model-value="commaInput(wageRate?.toString() || '-')"
@update:model-value="
(v) => {
if (typeof v === 'string') wageRate4Show = commaInput(v);
const x = parseInt(
wageRate4Show && typeof wageRate4Show === 'string'
? wageRate4Show.replace(/,/g, '')
: '',
);
wageRate = x;
}
"
/> />
<q-input <q-input

View file

@ -35,6 +35,7 @@ const useBranchStore = defineStore('api-branch', () => {
query?: string; query?: string;
tree?: boolean; tree?: boolean;
filter?: 'head' | 'sub'; filter?: 'head' | 'sub';
withHead?: boolean;
}, },
Data extends Pagination<Branch[]>, Data extends Pagination<Branch[]>,
>(opts?: Options): Promise<Data | false> { >(opts?: Options): Promise<Data | false> {

View file

@ -44,6 +44,7 @@ const useUserStore = defineStore('api-user', () => {
const res = await branchStore.fetchList({ const res = await branchStore.fetchList({
pageSize: 999, pageSize: 999,
filter: 'head', filter: 'head',
withHead: true,
}); });
if (res) { if (res) {
res.result.map((item) => { res.result.map((item) => {

View file

@ -415,4 +415,12 @@ export async function waitAll<T extends Promise<any>[]>(arr: T) {
return await Promise.all(arr); return await Promise.all(arr);
} }
export function commaInput(text: string): string {
if (typeof text !== 'string') return '';
const num = text.replace(/,/gi, '');
const numF = num.split(/(?=(?:\d{3})+$)/).join(',');
return numF;
}
export default useUtilsStore; export default useUtilsStore;