fix(01): code form & i18n

This commit is contained in:
puriphatt 2024-08-07 10:08:45 +00:00
parent c25cede70b
commit 68cc429b2e
9 changed files with 207 additions and 139 deletions

View file

@ -41,7 +41,7 @@ const { t } = useI18n();
const utilsStore = useUtilsStore();
const holdDialog = ref(false);
const isSubCreate = ref(false);
const columns = [
{
name: 'branchLabelNo',
@ -80,6 +80,7 @@ const columns = [
const modal = ref<boolean>(false);
const hideStat = ref(false);
const currentId = ref<string>('');
const currentStatus = ref<Status | 'All'>('All');
const expandedTree = ref<string[]>([]);
const formMenuIcon = ref<{ icon: string; color: string; bgColor: string }[]>([
@ -257,6 +258,7 @@ const splitterModel = ref(25);
const defaultFormData = {
headOfficeId: null,
code: '',
taxNo: '',
nameEN: '',
name: '',
@ -314,6 +316,7 @@ async function fetchBranchById(id: string) {
formBankBook.value = updatedBank;
formData.value = {
code: res.code,
headOfficeId: res.headOfficeId,
taxNo: res.taxNo,
nameEN: res.nameEN,
@ -382,7 +385,9 @@ function triggerCreate(
}
if (type === 'subBranch' && id && code) {
isSubCreate.value = true;
formData.value.headOfficeId = id;
formData.value.code = code;
formData.value.codeHeadOffice = code;
}
@ -418,6 +423,8 @@ async function triggerEdit(
formData.value.codeHeadOffice = code;
}
currentId.value = id;
const currentRecord = branchData.value.result.find((x) => x.id === id);
if (!currentRecord) return;
@ -441,6 +448,7 @@ async function triggerEdit(
currentHq.value = currentEdit.value;
}
}
console.log(formData.value);
formTypeBranch.value = typeBranch;
}
@ -496,6 +504,7 @@ async function triggerChangeStatus(
async function onSubmit() {
if (formType.value === 'edit') {
delete formData.value['codeHeadOffice'];
delete formData.value['code'];
await branchStore.editById(
currentEdit.value.id,
@ -520,6 +529,7 @@ async function onSubmit() {
);
formData.value.headOfficeId = currentRecord?.id;
formData.value.code = formData.value.code?.slice(0, -6);
delete formData.value['codeHeadOffice'];
}
@ -1060,6 +1070,7 @@ watch(currentHq, () => {
<div class="row items-center">
<div
:class="{
'q-mr-sm': true,
'status-active':
props.row.status !== 'INACTIVE',
'status-inactive':
@ -1077,7 +1088,7 @@ watch(currentHq, () => {
<q-img
:src="
baseUrl +
`/branch/${props.row.id}/branch-image`
`/branch/${props.row.id}/branch-image?ts=${Date.now()}`
"
style="
height: 3rem;
@ -1504,7 +1515,10 @@ watch(currentHq, () => {
"
:close="
() => (
(modal = false), (profileFileImg = undefined), (isImageEdit = false)
(modal = false),
(profileFileImg = undefined),
(isImageEdit = false),
(isSubCreate = false)
)
"
>
@ -1513,17 +1527,25 @@ watch(currentHq, () => {
caption="Jobs Worker Service Co., Ltd." -->
<ProfileBanner
active
useToggle
:title="formData.name"
:caption="formData.nameEN"
:caption="formData.codeHeadOffice"
v-model:toggle-status="formData.status"
v-model:cover-url="imageUrl"
:hideFade="imageUrl === '' || imageUrl === null"
:img="imageUrl || null"
icon="mdi-office-building-outline"
color="hsla(var(--pink-6-hsl)/1)"
bgColor="hsla(var(--pink-6-hsl)/0.15)"
:menu="formMenuIcon"
@view="imageDialog = true"
@edit="refImageUpload && refImageUpload.browse()"
:menu="formMenuIcon"
@update:toggle-status="
() => {
formData.status =
formData.status === 'CREATED' ? 'INACTIVE' : 'CREATED';
}
"
/>
</div>
<div
@ -1572,6 +1594,7 @@ watch(currentHq, () => {
<div class="col-10 q-pa-md q-gutter-y-xl">
<FormBranchInformation
id="form-information"
v-model:abbreviation="formData.code"
v-model:code="formData.codeHeadOffice"
v-model:code-sub-branch="currentEdit.code"
v-model:taxNo="formData.taxNo"
@ -1581,7 +1604,7 @@ watch(currentHq, () => {
:dense="true"
:outlined="true"
:readonly="formType === 'view'"
:view="formType === 'view'"
:view="isSubCreate"
title="formDialogTitleInformation"
/>
<FormBranchContact
@ -1670,18 +1693,27 @@ watch(currentHq, () => {
<InfoForm>
<div class="q-mx-lg q-mt-lg">
<ProfileBanner
active
:active="formData.status !== 'INACTIVE'"
useToggle
v-model:cover-url="imageUrl"
:hideFade="imageUrl === '' || imageUrl === null"
:img="imageUrl || null"
:cover="imageUrl || null"
:title="formData.name"
:caption="formData.nameEN"
:caption="formData.codeHeadOffice"
icon="mdi-office-building-outline"
color="hsla(var(--pink-6-hsl)/1)"
bgColor="hsla(var(--pink-6-hsl)/0.15)"
v-model:toggle-status="formData.status"
@view="imageDialog = true"
@edit="refImageUpload && refImageUpload.browse()"
@update:toggle-status="
async (v) => {
const res = await triggerChangeStatus(currentId, v);
if (res) formData.status = res.status;
await branchStore.fetchList({ pageSize: 99999 });
}
"
:readonly="formType === 'view'"
:menu="formMenuIcon"
/>
@ -1733,6 +1765,7 @@ watch(currentHq, () => {
<div class="col-10 q-pa-md q-gutter-y-xl">
<FormBranchInformation
id="info-information"
v-model:abbreviation="formData.code"
v-model:code="formData.codeHeadOffice"
v-model:code-sub-branch="currentEdit.code"
v-model:taxNo="formData.taxNo"
@ -1743,7 +1776,7 @@ watch(currentHq, () => {
:dense="true"
:outlined="true"
:readonly="formType === 'view'"
:view="formType === 'view'"
view
title="formDialogTitleInformation"
/>
<FormBranchContact