2024-04-02 17:47:32 +07:00
|
|
|
<script setup lang="ts">
|
2024-04-09 16:47:52 +07:00
|
|
|
import { storeToRefs } from 'pinia';
|
2024-04-16 18:33:41 +07:00
|
|
|
import { ref, onMounted, computed } from 'vue';
|
2024-04-17 15:15:44 +07:00
|
|
|
import { Icon } from '@iconify/vue';
|
2024-04-05 18:00:30 +07:00
|
|
|
|
2024-04-05 18:14:53 +07:00
|
|
|
import useBranchStore from 'stores/branch';
|
2024-04-16 18:33:41 +07:00
|
|
|
|
2024-04-18 15:10:54 +07:00
|
|
|
import { dialog } from 'src/stores/utils';
|
2024-04-02 17:47:32 +07:00
|
|
|
import AppBox from 'components/app/AppBox.vue';
|
2024-04-10 20:26:32 +07:00
|
|
|
import AddButton from 'components/AddButton.vue';
|
2024-04-05 18:14:53 +07:00
|
|
|
import TooltipComponent from 'components/TooltipComponent.vue';
|
2024-04-16 18:33:41 +07:00
|
|
|
import StatCard from 'components/StatCardComponent.vue';
|
2024-04-17 15:15:44 +07:00
|
|
|
import BranchCard from 'src/components/01_branch-management/BranchCard.vue';
|
2024-04-18 13:56:00 +07:00
|
|
|
import FormDialog from 'src/components/FormDialog.vue';
|
|
|
|
|
import FormBranchInformation from 'src/components/01_branch-management/FormBranchInformation.vue';
|
|
|
|
|
import FormLocation from 'src/components/01_branch-management/FormLocation.vue';
|
|
|
|
|
import FormQr from 'src/components/01_branch-management/FormQr.vue';
|
|
|
|
|
import FormBranchContact from 'src/components/01_branch-management/FormBranchContact.vue';
|
2024-04-18 17:30:29 +07:00
|
|
|
import FormImage from 'src/components/01_branch-management/FormImage.vue';
|
2024-04-19 11:47:41 +07:00
|
|
|
import DrawerInfo from 'src/components/DrawerInfo.vue';
|
2024-04-19 14:07:50 +07:00
|
|
|
import InfoForm from 'src/components/02_personnel-management/InfoForm.vue';
|
2024-04-10 16:02:28 +07:00
|
|
|
|
2024-04-18 13:56:00 +07:00
|
|
|
import { BranchWithChildren, BranchCreate } from 'stores/branch/types';
|
2024-04-16 18:33:41 +07:00
|
|
|
import { watch } from 'vue';
|
|
|
|
|
import { useI18n } from 'vue-i18n';
|
2024-06-25 16:05:51 +07:00
|
|
|
import useFlowStore from 'src/stores/flow';
|
2024-04-17 15:15:44 +07:00
|
|
|
|
|
|
|
|
const { t } = useI18n();
|
2024-04-09 15:54:47 +07:00
|
|
|
|
2024-04-18 13:56:00 +07:00
|
|
|
const modal = ref<boolean>(false);
|
|
|
|
|
|
2024-04-18 17:30:29 +07:00
|
|
|
const profileFileImg = ref<File | undefined>(undefined);
|
|
|
|
|
const imageUrl = ref<string | null>('');
|
|
|
|
|
|
|
|
|
|
const inputFileImg = (() => {
|
|
|
|
|
const element = document.createElement('input');
|
|
|
|
|
element.type = 'file';
|
|
|
|
|
element.accept = 'image/*';
|
|
|
|
|
|
|
|
|
|
const reader = new FileReader();
|
|
|
|
|
reader.addEventListener('load', () => {
|
|
|
|
|
if (typeof reader.result === 'string') imageUrl.value = reader.result;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
element.addEventListener('change', () => {
|
|
|
|
|
profileFileImg.value = element.files?.[0];
|
|
|
|
|
if (profileFileImg.value) {
|
|
|
|
|
reader.readAsDataURL(profileFileImg.value);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return element;
|
|
|
|
|
})();
|
|
|
|
|
|
2024-04-18 13:56:00 +07:00
|
|
|
const profileFile = ref<File | undefined>(undefined);
|
2024-04-18 15:10:54 +07:00
|
|
|
const qrCodeimageUrl = ref<string | null>('');
|
2024-04-18 13:56:00 +07:00
|
|
|
|
|
|
|
|
const inputFile = (() => {
|
|
|
|
|
const element = document.createElement('input');
|
|
|
|
|
element.type = 'file';
|
|
|
|
|
element.accept = 'image/*';
|
|
|
|
|
|
|
|
|
|
const reader = new FileReader();
|
|
|
|
|
reader.addEventListener('load', () => {
|
2024-04-18 15:10:54 +07:00
|
|
|
if (typeof reader.result === 'string') qrCodeimageUrl.value = reader.result;
|
2024-04-18 13:56:00 +07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
element.addEventListener('change', () => {
|
|
|
|
|
profileFile.value = element.files?.[0];
|
|
|
|
|
if (profileFile.value) {
|
|
|
|
|
reader.readAsDataURL(profileFile.value);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return element;
|
|
|
|
|
})();
|
2024-04-10 18:49:41 +07:00
|
|
|
|
2024-04-09 15:54:47 +07:00
|
|
|
const branchStore = useBranchStore();
|
2024-06-25 16:05:51 +07:00
|
|
|
const flowStore = useFlowStore();
|
2024-04-16 18:33:41 +07:00
|
|
|
const { locale } = useI18n();
|
2024-04-10 16:02:28 +07:00
|
|
|
|
2024-04-09 16:47:52 +07:00
|
|
|
const { data: branchData } = storeToRefs(branchStore);
|
2024-04-05 18:00:30 +07:00
|
|
|
|
2024-04-16 18:33:41 +07:00
|
|
|
const treeData = computed(() => {
|
|
|
|
|
const arr: BranchWithChildren[] = [];
|
2024-04-09 15:54:47 +07:00
|
|
|
|
2024-04-16 18:33:41 +07:00
|
|
|
branchData.value?.result.forEach((a) => {
|
|
|
|
|
if (a.isHeadOffice) arr.push(Object.assign(a, { branch: [] }));
|
|
|
|
|
else arr.find((b) => b.id === a.headOfficeId)?.branch.push(a);
|
|
|
|
|
});
|
2024-04-09 15:54:47 +07:00
|
|
|
|
2024-04-16 18:33:41 +07:00
|
|
|
return arr;
|
|
|
|
|
});
|
2024-04-05 18:00:30 +07:00
|
|
|
|
2024-04-16 18:33:41 +07:00
|
|
|
onMounted(async () => {
|
|
|
|
|
await branchStore.fetchList({ pageSize: 99999 });
|
2024-06-25 16:05:51 +07:00
|
|
|
|
2024-04-16 18:33:41 +07:00
|
|
|
const _stats = await branchStore.stats();
|
|
|
|
|
|
|
|
|
|
if (_stats) {
|
|
|
|
|
stats.value.push(
|
2024-04-23 14:43:00 +07:00
|
|
|
{ count: _stats.hq, label: 'branchHQLabel', color: 'pink' },
|
|
|
|
|
{ count: _stats.br, label: 'branchLabel', color: 'purple' },
|
2024-04-16 18:33:41 +07:00
|
|
|
);
|
|
|
|
|
}
|
2024-06-25 16:08:46 +07:00
|
|
|
|
|
|
|
|
flowStore.rotate();
|
2024-04-16 18:33:41 +07:00
|
|
|
});
|
2024-04-05 18:00:30 +07:00
|
|
|
|
2024-04-18 16:13:16 +07:00
|
|
|
const statusFilter = ref<'all' | 'statusACTIVE' | 'statusINACTIVE'>('all');
|
|
|
|
|
|
2024-04-17 15:49:48 +07:00
|
|
|
const beforeBranch = ref<{ id: string; code: string }>({
|
|
|
|
|
id: '',
|
2024-04-17 15:15:44 +07:00
|
|
|
code: '',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const inputSearch = ref<string>('');
|
2024-04-17 11:33:41 +07:00
|
|
|
const fieldBranch = ref(['all', 'branchHQLabel', 'branchLabel']);
|
2024-04-16 18:33:41 +07:00
|
|
|
const fieldDisplay = ref([
|
|
|
|
|
'branchLabelName',
|
|
|
|
|
'branchLabelTel',
|
|
|
|
|
'branchLabelAddress',
|
|
|
|
|
'branchLabelType',
|
|
|
|
|
'branchLabelStatus',
|
|
|
|
|
]);
|
|
|
|
|
const fieldSelected = ref<string[]>(fieldDisplay.value);
|
2024-04-17 11:33:41 +07:00
|
|
|
const fieldSelectedBranch = ref<{
|
|
|
|
|
label: string;
|
|
|
|
|
value: string;
|
|
|
|
|
}>({
|
2024-04-17 15:15:44 +07:00
|
|
|
label: t('branchHQLabel'),
|
|
|
|
|
value: 'branchHQLabel',
|
2024-04-17 11:33:41 +07:00
|
|
|
});
|
|
|
|
|
|
2024-04-23 14:43:00 +07:00
|
|
|
const stats = ref<{ count: number; label: string; color: 'pink' | 'purple' }[]>(
|
|
|
|
|
[],
|
|
|
|
|
);
|
2024-04-16 18:33:41 +07:00
|
|
|
|
2024-04-18 13:56:00 +07:00
|
|
|
const defaultFormData = {
|
|
|
|
|
headOfficeId: null,
|
|
|
|
|
taxNo: '',
|
|
|
|
|
nameEN: '',
|
|
|
|
|
name: '',
|
|
|
|
|
addressEN: '',
|
|
|
|
|
address: '',
|
|
|
|
|
zipCode: '',
|
|
|
|
|
email: '',
|
|
|
|
|
contactName: '',
|
|
|
|
|
contact: '',
|
|
|
|
|
telephoneNo: '',
|
|
|
|
|
longitude: '',
|
|
|
|
|
latitude: '',
|
|
|
|
|
subDistrictId: '',
|
|
|
|
|
districtId: '',
|
|
|
|
|
provinceId: '',
|
|
|
|
|
lineId: '',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const formDialogRef = ref();
|
2024-04-18 18:07:38 +07:00
|
|
|
|
2024-04-18 15:47:53 +07:00
|
|
|
const formType = ref<'create' | 'edit' | 'delete' | 'view'>('create');
|
2024-04-18 13:56:00 +07:00
|
|
|
const formTypeBranch = ref<'headOffice' | 'subBranch'>('headOffice');
|
2024-04-22 10:52:26 +07:00
|
|
|
const currentHq = ref<{ id: string; code: string }>({ id: '', code: '' });
|
|
|
|
|
const currentEdit = ref<{ id: string; code: string }>({ id: '', code: '' });
|
2024-06-28 11:14:58 +07:00
|
|
|
const formData = ref<
|
|
|
|
|
Omit<BranchCreate & { codeHeadOffice?: string }, 'qrCodeImage' | 'imageUrl'>
|
|
|
|
|
>(structuredClone(defaultFormData));
|
2024-04-18 13:56:00 +07:00
|
|
|
|
2024-06-28 11:14:58 +07:00
|
|
|
const prevFormData = ref<
|
|
|
|
|
Omit<BranchCreate & { codeHeadOffice?: string }, 'qrCodeImage' | 'imageUrl'>
|
|
|
|
|
>(structuredClone(defaultFormData));
|
2024-04-19 11:47:41 +07:00
|
|
|
|
|
|
|
|
const modalDrawer = ref<boolean>(false);
|
|
|
|
|
|
|
|
|
|
function openDrawer() {
|
|
|
|
|
modalDrawer.value = true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-18 13:56:00 +07:00
|
|
|
function openDialog() {
|
|
|
|
|
modal.value = true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-18 15:10:54 +07:00
|
|
|
async function fetchBranchById(id: string) {
|
2024-04-19 14:30:26 +07:00
|
|
|
const res = await branchStore.fetchById(id, { includeContact: true });
|
2024-04-18 15:10:54 +07:00
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
|
qrCodeimageUrl.value = res.qrCodeImageUrl;
|
2024-04-18 17:30:29 +07:00
|
|
|
imageUrl.value = res.imageUrl;
|
2024-04-22 10:52:26 +07:00
|
|
|
|
2024-04-18 15:10:54 +07:00
|
|
|
formData.value = {
|
|
|
|
|
headOfficeId: res.headOfficeId,
|
|
|
|
|
taxNo: res.taxNo,
|
|
|
|
|
nameEN: res.nameEN,
|
|
|
|
|
name: res.name,
|
|
|
|
|
addressEN: res.addressEN,
|
|
|
|
|
address: res.address,
|
|
|
|
|
zipCode: res.zipCode,
|
|
|
|
|
email: res.email,
|
|
|
|
|
contactName: res.contactName,
|
2024-04-22 10:52:26 +07:00
|
|
|
contact: res.contact.length > 0 ? res.contact[0].telephoneNo : ' ',
|
2024-04-18 15:10:54 +07:00
|
|
|
telephoneNo: res.telephoneNo,
|
|
|
|
|
longitude: res.longitude,
|
|
|
|
|
latitude: res.latitude,
|
|
|
|
|
subDistrictId: res.subDistrictId,
|
|
|
|
|
districtId: res.districtId,
|
|
|
|
|
provinceId: res.provinceId,
|
|
|
|
|
lineId: res.lineId,
|
2024-04-18 18:07:38 +07:00
|
|
|
status: res.status,
|
2024-04-18 15:10:54 +07:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearData() {
|
|
|
|
|
formData.value = structuredClone(defaultFormData);
|
2024-04-18 17:30:29 +07:00
|
|
|
imageUrl.value = null;
|
|
|
|
|
qrCodeimageUrl.value = null;
|
2024-04-22 10:52:26 +07:00
|
|
|
currentEdit.value = {
|
2024-04-19 11:47:41 +07:00
|
|
|
id: '',
|
|
|
|
|
code: '',
|
|
|
|
|
};
|
2024-04-18 15:10:54 +07:00
|
|
|
profileFile.value = undefined;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-19 11:47:41 +07:00
|
|
|
async function undo() {
|
|
|
|
|
formType.value = 'view';
|
|
|
|
|
formData.value = prevFormData.value;
|
2024-04-18 15:47:53 +07:00
|
|
|
}
|
|
|
|
|
|
2024-04-22 10:52:26 +07:00
|
|
|
function triggerCreate(
|
|
|
|
|
type: 'headOffice' | 'subBranch',
|
|
|
|
|
id?: string,
|
|
|
|
|
code?: string,
|
|
|
|
|
) {
|
2024-04-18 13:56:00 +07:00
|
|
|
clearData();
|
2024-04-18 14:13:57 +07:00
|
|
|
|
2024-04-22 10:52:26 +07:00
|
|
|
formTypeBranch.value = type;
|
2024-06-14 16:05:42 +07:00
|
|
|
|
|
|
|
|
if (type === 'headOffice') {
|
|
|
|
|
currentHq.value = {
|
|
|
|
|
id: id ?? '',
|
|
|
|
|
code: code ?? '',
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-04-18 13:56:00 +07:00
|
|
|
|
2024-06-28 11:14:58 +07:00
|
|
|
if (type === 'subBranch' && id && code) {
|
|
|
|
|
formData.value.headOfficeId = id;
|
|
|
|
|
formData.value.codeHeadOffice = code;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-18 13:56:00 +07:00
|
|
|
formType.value = 'create';
|
|
|
|
|
openDialog();
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-19 14:09:17 +07:00
|
|
|
function drawerEdit() {
|
|
|
|
|
formType.value = 'edit';
|
|
|
|
|
prevFormData.value = {
|
|
|
|
|
...formData.value,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-22 10:52:26 +07:00
|
|
|
async function triggerEdit(
|
|
|
|
|
openFormType: string,
|
|
|
|
|
id: string,
|
|
|
|
|
typeBranch: 'headOffice' | 'subBranch',
|
|
|
|
|
) {
|
2024-04-19 13:53:05 +07:00
|
|
|
await fetchBranchById(id);
|
2024-04-22 10:52:26 +07:00
|
|
|
if (openFormType === 'form') {
|
|
|
|
|
formType.value = 'edit';
|
|
|
|
|
openDialog();
|
2024-04-18 15:10:54 +07:00
|
|
|
}
|
2024-04-22 10:52:26 +07:00
|
|
|
if (openFormType === 'drawer') {
|
|
|
|
|
formType.value = 'view';
|
|
|
|
|
openDrawer();
|
2024-04-19 13:53:05 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const currentRecord = branchData.value.result.find((x) => x.id === id);
|
|
|
|
|
|
|
|
|
|
if (!currentRecord) return;
|
|
|
|
|
|
2024-04-22 10:52:26 +07:00
|
|
|
currentEdit.value = {
|
|
|
|
|
id: currentRecord.id,
|
|
|
|
|
code: currentRecord.code,
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-26 14:03:44 +07:00
|
|
|
if (typeBranch === 'subBranch') {
|
|
|
|
|
const currentRecordHead = branchData.value.result.find(
|
|
|
|
|
(x) => x.id === currentRecord.headOfficeId,
|
|
|
|
|
);
|
2024-04-23 14:36:16 +07:00
|
|
|
|
2024-06-26 14:03:44 +07:00
|
|
|
if (currentRecordHead) {
|
|
|
|
|
currentHq.value.id = currentRecordHead.id;
|
|
|
|
|
currentHq.value.code = currentRecordHead.code;
|
|
|
|
|
} else {
|
|
|
|
|
currentHq.value = currentEdit.value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-23 14:36:16 +07:00
|
|
|
formTypeBranch.value = typeBranch;
|
2024-04-18 15:10:54 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function triggerDelete(id: string) {
|
|
|
|
|
if (id) {
|
|
|
|
|
dialog({
|
|
|
|
|
color: 'negative',
|
|
|
|
|
icon: 'mdi-alert',
|
2024-06-28 10:09:53 +07:00
|
|
|
title: t('deleteConfirmTitle'),
|
|
|
|
|
actionText: t('agree'),
|
2024-04-18 15:10:54 +07:00
|
|
|
persistent: true,
|
2024-06-28 10:09:53 +07:00
|
|
|
message: t('deleteConfirmMessage'),
|
2024-04-18 15:10:54 +07:00
|
|
|
action: async () => {
|
|
|
|
|
await branchStore.deleteById(id);
|
|
|
|
|
await branchStore.fetchList({ pageSize: 99999 });
|
2024-04-19 11:47:41 +07:00
|
|
|
modalDrawer.value = false;
|
2024-06-28 10:09:53 +07:00
|
|
|
stats.value[0].count = stats.value[0].count - 1;
|
2024-06-26 17:03:49 +07:00
|
|
|
flowStore.rotate();
|
2024-04-18 15:10:54 +07:00
|
|
|
},
|
|
|
|
|
cancel: () => {},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-18 13:56:00 +07:00
|
|
|
async function onSubmit() {
|
2024-04-18 15:10:54 +07:00
|
|
|
if (formType.value === 'edit') {
|
2024-04-22 10:52:26 +07:00
|
|
|
await branchStore.editById(
|
|
|
|
|
currentEdit.value.id,
|
|
|
|
|
{
|
|
|
|
|
...formData.value,
|
|
|
|
|
status: undefined,
|
|
|
|
|
},
|
|
|
|
|
profileFile.value,
|
|
|
|
|
profileFileImg.value,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await branchStore.fetchList({ pageSize: 99999 });
|
|
|
|
|
modal.value = false;
|
|
|
|
|
modalDrawer.value = false;
|
2024-04-18 15:10:54 +07:00
|
|
|
}
|
|
|
|
|
|
2024-04-22 10:52:26 +07:00
|
|
|
if (formType.value === 'create') {
|
|
|
|
|
if (formTypeBranch.value === 'subBranch') {
|
|
|
|
|
formData.value.headOfficeId = currentHq.value.id;
|
2024-06-28 11:14:58 +07:00
|
|
|
delete formData.value['codeHeadOffice'];
|
2024-04-18 13:56:00 +07:00
|
|
|
}
|
2024-04-18 15:10:54 +07:00
|
|
|
|
2024-04-22 10:52:26 +07:00
|
|
|
await branchStore.create({
|
|
|
|
|
...formData.value,
|
|
|
|
|
qrCodeImage: profileFile.value,
|
|
|
|
|
imageUrl: profileFileImg.value,
|
|
|
|
|
});
|
2024-04-18 14:13:57 +07:00
|
|
|
|
2024-04-22 10:52:26 +07:00
|
|
|
await branchStore.fetchList({ pageSize: 99999 });
|
|
|
|
|
modal.value = false;
|
2024-04-18 13:56:00 +07:00
|
|
|
}
|
2024-04-19 14:52:14 +07:00
|
|
|
|
|
|
|
|
const _stats = await branchStore.stats();
|
|
|
|
|
|
|
|
|
|
if (_stats) {
|
2024-04-23 14:43:00 +07:00
|
|
|
stats.value = [
|
|
|
|
|
{
|
|
|
|
|
count: _stats.hq,
|
|
|
|
|
label: 'branchHQLabel',
|
|
|
|
|
color: 'pink',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
count: _stats.br,
|
|
|
|
|
label: 'branchLabel',
|
|
|
|
|
color: 'purple',
|
|
|
|
|
},
|
|
|
|
|
];
|
2024-04-19 14:52:14 +07:00
|
|
|
}
|
2024-06-25 16:05:51 +07:00
|
|
|
flowStore.rotate();
|
2024-04-18 13:56:00 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function changeTitle(
|
2024-04-18 15:47:53 +07:00
|
|
|
formType: 'edit' | 'create' | 'delete' | 'view',
|
2024-04-18 13:56:00 +07:00
|
|
|
typeBranch: 'headOffice' | 'subBranch',
|
|
|
|
|
) {
|
|
|
|
|
if (typeBranch === 'headOffice') {
|
2024-04-18 15:47:53 +07:00
|
|
|
return formType === 'create'
|
|
|
|
|
? t('formDialogTitleCreateHeadOffice')
|
2024-04-19 11:47:41 +07:00
|
|
|
: formType === 'view'
|
|
|
|
|
? t('formDialogTitleViewHeadOffice')
|
|
|
|
|
: t('formDialogTitleEditHeadOffice');
|
2024-04-18 13:56:00 +07:00
|
|
|
}
|
|
|
|
|
if (typeBranch === 'subBranch') {
|
2024-04-18 15:47:53 +07:00
|
|
|
return formType === 'create'
|
|
|
|
|
? t('formDialogTitleCreateSubBranch')
|
2024-04-19 11:47:41 +07:00
|
|
|
: formType === 'view'
|
|
|
|
|
? t('formDialogTitleViewSubBranch')
|
|
|
|
|
: t('formDialogTitleEditSubBranch');
|
2024-04-18 13:56:00 +07:00
|
|
|
}
|
|
|
|
|
return '';
|
|
|
|
|
}
|
2024-04-18 15:21:32 +07:00
|
|
|
|
|
|
|
|
watch(locale, () => {
|
|
|
|
|
fieldSelectedBranch.value = {
|
2024-06-10 15:57:33 +07:00
|
|
|
label: t(`${fieldSelectedBranch.value.label}`),
|
2024-04-18 15:21:32 +07:00
|
|
|
value: fieldSelectedBranch.value.value,
|
|
|
|
|
};
|
|
|
|
|
});
|
2024-04-02 17:47:32 +07:00
|
|
|
</script>
|
2024-04-16 18:33:41 +07:00
|
|
|
|
2024-04-02 17:47:32 +07:00
|
|
|
<template>
|
|
|
|
|
<div class="column">
|
2024-04-03 14:55:37 +07:00
|
|
|
<div class="row text-h6 text-weight-bold q-mb-md">
|
|
|
|
|
{{ $t('branchManagement') }}
|
|
|
|
|
</div>
|
2024-04-02 17:47:32 +07:00
|
|
|
|
2024-04-16 18:33:41 +07:00
|
|
|
<AppBox bordered class="q-mb-md">
|
2024-04-23 14:43:00 +07:00
|
|
|
<StatCard label-i18n :branch="stats" :dark="$q.dark.isActive" />
|
2024-04-09 16:47:52 +07:00
|
|
|
</AppBox>
|
2024-04-03 15:23:59 +07:00
|
|
|
|
2024-04-19 14:22:23 +07:00
|
|
|
<AppBox
|
|
|
|
|
class="column"
|
|
|
|
|
:no-padding="!!branchData.total"
|
|
|
|
|
bordered
|
|
|
|
|
style="min-height: 70vh"
|
|
|
|
|
>
|
2024-04-16 18:33:41 +07:00
|
|
|
<template v-if="!branchData.total">
|
2024-04-11 18:09:27 +07:00
|
|
|
<TooltipComponent
|
2024-04-16 18:33:41 +07:00
|
|
|
class="self-end"
|
2024-04-11 18:09:27 +07:00
|
|
|
title="branchNoMainOfficeYet"
|
|
|
|
|
caption="branchClickToCreateMainOffice"
|
2024-04-16 18:33:41 +07:00
|
|
|
imgSrc="personnel-table-"
|
2024-04-11 18:09:27 +07:00
|
|
|
/>
|
2024-04-11 14:41:29 +07:00
|
|
|
|
2024-04-16 18:33:41 +07:00
|
|
|
<div class="row items-center justify-center" style="flex-grow: 1">
|
2024-04-19 12:30:53 +07:00
|
|
|
<AddButton
|
|
|
|
|
label="branchAdd"
|
|
|
|
|
@trigger="() => triggerCreate('headOffice')"
|
|
|
|
|
/>
|
2024-04-16 18:33:41 +07:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<div class="row" style="flex-grow: 1; flex-wrap: nowrap">
|
2024-04-18 15:28:39 +07:00
|
|
|
<div class="tree-container q-pa-md bordered-r surface-2">
|
2024-04-17 15:49:48 +07:00
|
|
|
<div class="row">
|
2024-04-22 15:26:31 +07:00
|
|
|
<button
|
|
|
|
|
style="border: none; background: transparent"
|
|
|
|
|
:class="{ 'cursor-pointer': !!currentHq.id }"
|
|
|
|
|
id="br-prev"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
icon="ep:arrow-left-bold"
|
|
|
|
|
width="21px"
|
|
|
|
|
:class="{ 'app-text-muted': !currentHq.id }"
|
|
|
|
|
@click="
|
|
|
|
|
() => {
|
|
|
|
|
if (currentHq.id) {
|
|
|
|
|
beforeBranch = currentHq;
|
|
|
|
|
currentHq = { id: '', code: '' };
|
|
|
|
|
fieldSelectedBranch = {
|
|
|
|
|
label: $t('branchHQLabel'),
|
|
|
|
|
value: 'branchHQLabel',
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-04-17 15:49:48 +07:00
|
|
|
}
|
2024-04-22 15:26:31 +07:00
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
style="border: none; background: transparent; padding: 0"
|
|
|
|
|
:class="{ 'cursor-pointer': !!beforeBranch.id }"
|
|
|
|
|
id="br-next"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
icon="ep:arrow-right-bold"
|
|
|
|
|
width="21px"
|
|
|
|
|
:class="{
|
|
|
|
|
'app-text-muted': !beforeBranch.id,
|
|
|
|
|
}"
|
|
|
|
|
@click="
|
|
|
|
|
() => {
|
|
|
|
|
if (beforeBranch.id) {
|
|
|
|
|
currentHq = beforeBranch;
|
|
|
|
|
beforeBranch = { id: '', code: '' };
|
|
|
|
|
fieldSelectedBranch = {
|
|
|
|
|
label: '',
|
|
|
|
|
value: '',
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-04-17 15:49:48 +07:00
|
|
|
}
|
2024-04-22 15:26:31 +07:00
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</button>
|
2024-04-17 15:49:48 +07:00
|
|
|
|
|
|
|
|
<q-space />
|
|
|
|
|
|
2024-04-22 15:26:31 +07:00
|
|
|
<button
|
|
|
|
|
id="hq-add-btn"
|
|
|
|
|
style="border: none; background: transparent"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
icon="pixelarticons:plus"
|
|
|
|
|
height="26"
|
|
|
|
|
class="color-icon-plus cursor-pointer"
|
2024-06-14 16:05:42 +07:00
|
|
|
@click="
|
|
|
|
|
() => {
|
|
|
|
|
if (!currentHq.id) {
|
|
|
|
|
triggerCreate('headOffice');
|
|
|
|
|
} else {
|
2024-06-28 11:14:58 +07:00
|
|
|
triggerCreate(
|
|
|
|
|
'subBranch',
|
|
|
|
|
currentHq.id,
|
|
|
|
|
currentHq.code,
|
|
|
|
|
);
|
2024-06-14 16:05:42 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-04-22 15:26:31 +07:00
|
|
|
/>
|
|
|
|
|
</button>
|
2024-04-17 15:49:48 +07:00
|
|
|
</div>
|
|
|
|
|
|
2024-04-22 15:26:31 +07:00
|
|
|
<div class="bordered rounded q-mt-sm surface-1">
|
2024-04-17 15:49:48 +07:00
|
|
|
<div
|
2024-04-18 15:28:39 +07:00
|
|
|
class="bordered-b q-pl-sm text-weight-bold surface-3"
|
2024-04-17 15:49:48 +07:00
|
|
|
style="height: 50px; display: flex; align-items: center"
|
|
|
|
|
>
|
|
|
|
|
<Icon icon="flowbite:home-solid" width="24px" class="q-mr-md" />
|
2024-06-26 14:03:44 +07:00
|
|
|
{{ $t('all') }}
|
2024-04-17 15:49:48 +07:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<q-tree
|
|
|
|
|
:nodes="treeData"
|
|
|
|
|
node-key="id"
|
|
|
|
|
label-key="name"
|
|
|
|
|
children-key="branch"
|
|
|
|
|
>
|
|
|
|
|
<template #default-header="{ node }">
|
|
|
|
|
<div
|
|
|
|
|
class="row items-center justify-between full-width no-wrap"
|
|
|
|
|
>
|
|
|
|
|
<span>{{ node.name }}</span>
|
|
|
|
|
<div class="q-gutter-xs flex no-wrap" @click.stop>
|
2024-04-18 14:13:57 +07:00
|
|
|
<q-btn
|
2024-04-19 10:01:14 +07:00
|
|
|
v-if="node.isHeadOffice"
|
2024-06-13 13:55:48 +07:00
|
|
|
:id="`create-sub-branch-btn-${node.name}`"
|
2024-04-18 14:13:57 +07:00
|
|
|
@click.stop="
|
|
|
|
|
triggerCreate('subBranch', node.id, node.code)
|
|
|
|
|
"
|
|
|
|
|
icon="mdi-file-plus-outline"
|
|
|
|
|
fab-mini
|
|
|
|
|
unelevated
|
|
|
|
|
/>
|
2024-04-19 14:40:14 +07:00
|
|
|
|
2024-06-13 13:55:48 +07:00
|
|
|
<q-btn
|
|
|
|
|
:id="`view-detail-btn-${node.name}`"
|
|
|
|
|
icon="mdi-dots-vertical"
|
|
|
|
|
fab-mini
|
|
|
|
|
unelevated
|
|
|
|
|
flat
|
|
|
|
|
>
|
2024-04-17 15:49:48 +07:00
|
|
|
<q-menu class="bordered">
|
|
|
|
|
<q-list v-close-popup>
|
|
|
|
|
<q-item
|
2024-06-13 13:55:48 +07:00
|
|
|
:id="`view-detail-btn-${node.name}-view`"
|
2024-06-26 14:03:44 +07:00
|
|
|
@click.stop="
|
2024-04-19 12:30:53 +07:00
|
|
|
if (node.isHeadOffice) {
|
2024-04-22 10:52:26 +07:00
|
|
|
triggerEdit('drawer', node.id, 'headOffice');
|
2024-04-19 12:30:53 +07:00
|
|
|
} else {
|
2024-04-22 10:52:26 +07:00
|
|
|
triggerEdit('drawer', node.id, 'subBranch');
|
2024-04-19 12:30:53 +07:00
|
|
|
}
|
|
|
|
|
"
|
2024-04-17 15:49:48 +07:00
|
|
|
clickable
|
|
|
|
|
dense
|
|
|
|
|
class="row q-py-sm"
|
|
|
|
|
style="white-space: nowrap"
|
|
|
|
|
>
|
|
|
|
|
<q-icon
|
|
|
|
|
name="mdi-eye-outline"
|
|
|
|
|
class="col-3"
|
|
|
|
|
size="xs"
|
|
|
|
|
style="color: hsl(var(--green-6-hsl))"
|
|
|
|
|
/>
|
|
|
|
|
<span class="col-9 q-px-md flex items-center">
|
|
|
|
|
{{ $t('viewDetail') }}
|
|
|
|
|
</span>
|
|
|
|
|
</q-item>
|
|
|
|
|
<q-item
|
2024-06-13 13:55:48 +07:00
|
|
|
:id="`view-detail-btn-${node.name}-edit`"
|
2024-04-17 15:49:48 +07:00
|
|
|
clickable
|
|
|
|
|
dense
|
|
|
|
|
class="row q-py-sm"
|
|
|
|
|
style="white-space: nowrap"
|
2024-04-18 15:10:54 +07:00
|
|
|
@click="
|
|
|
|
|
() => {
|
|
|
|
|
if (node.isHeadOffice) {
|
2024-04-22 10:52:26 +07:00
|
|
|
triggerEdit('form', node.id, 'headOffice');
|
2024-04-18 15:10:54 +07:00
|
|
|
} else {
|
2024-04-22 10:52:26 +07:00
|
|
|
triggerEdit('form', node.id, 'subBranch');
|
2024-04-18 15:10:54 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-04-17 15:49:48 +07:00
|
|
|
>
|
|
|
|
|
<q-icon
|
|
|
|
|
name="mdi-pencil-outline"
|
|
|
|
|
class="col-3"
|
|
|
|
|
size="xs"
|
|
|
|
|
style="color: hsl(var(--cyan-6-hsl))"
|
|
|
|
|
/>
|
|
|
|
|
<span class="col-9 q-px-md flex items-center">
|
|
|
|
|
{{ $t('edit') }}
|
|
|
|
|
</span>
|
|
|
|
|
</q-item>
|
|
|
|
|
<q-item
|
2024-06-13 13:55:48 +07:00
|
|
|
:id="`view-detail-btn-${node.name}-delete`"
|
2024-04-17 15:49:48 +07:00
|
|
|
dense
|
2024-04-18 17:00:21 +07:00
|
|
|
:clickable="node.status === 'CREATED'"
|
2024-04-17 15:49:48 +07:00
|
|
|
class="row"
|
2024-04-18 17:00:21 +07:00
|
|
|
:class="{
|
|
|
|
|
'surface-3': node.status !== 'CREATED',
|
|
|
|
|
'app-text-muted': node.status !== 'CREATED',
|
|
|
|
|
}"
|
2024-04-17 15:49:48 +07:00
|
|
|
style="white-space: nowrap"
|
2024-04-18 15:10:54 +07:00
|
|
|
@click="triggerDelete(node.id)"
|
2024-04-17 15:49:48 +07:00
|
|
|
>
|
|
|
|
|
<q-icon
|
|
|
|
|
name="mdi-trash-can-outline"
|
|
|
|
|
size="xs"
|
|
|
|
|
class="col-3"
|
2024-04-18 17:00:21 +07:00
|
|
|
:class="{
|
|
|
|
|
'app-text-negative':
|
|
|
|
|
node.status === 'CREATED',
|
|
|
|
|
}"
|
2024-04-17 15:49:48 +07:00
|
|
|
/>
|
|
|
|
|
<span class="col-9 q-px-md flex items-center">
|
|
|
|
|
{{ $t('delete') }}
|
|
|
|
|
</span>
|
|
|
|
|
</q-item>
|
|
|
|
|
|
|
|
|
|
<q-item dense>
|
|
|
|
|
<q-item-section class="q-py-sm">
|
|
|
|
|
<div class="q-pa-sm surface-2 rounded">
|
|
|
|
|
<q-toggle
|
2024-06-13 13:55:48 +07:00
|
|
|
:id="`view-detail-btn-${node.name}-status`"
|
2024-04-17 15:49:48 +07:00
|
|
|
dense
|
|
|
|
|
size="sm"
|
|
|
|
|
:label="
|
|
|
|
|
node.status !== 'INACTIVE'
|
|
|
|
|
? $t('switchOnLabel')
|
|
|
|
|
: $t('switchOffLabel')
|
|
|
|
|
"
|
|
|
|
|
@click="
|
|
|
|
|
async () => {
|
|
|
|
|
const res = await branchStore.editById(
|
|
|
|
|
node.id,
|
|
|
|
|
{
|
|
|
|
|
status:
|
|
|
|
|
node.status !== 'INACTIVE'
|
|
|
|
|
? 'INACTIVE'
|
|
|
|
|
: 'ACTIVE',
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
if (res) node.status = res.status;
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
:model-value="
|
|
|
|
|
node.status === 'CREATED' ||
|
|
|
|
|
node.status === 'ACTIVE'
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</q-item-section>
|
|
|
|
|
</q-item>
|
|
|
|
|
</q-list>
|
|
|
|
|
</q-menu>
|
|
|
|
|
</q-btn>
|
|
|
|
|
</div>
|
2024-04-16 18:33:41 +07:00
|
|
|
</div>
|
2024-04-17 15:49:48 +07:00
|
|
|
</template>
|
|
|
|
|
</q-tree>
|
|
|
|
|
</div>
|
2024-04-05 18:00:30 +07:00
|
|
|
</div>
|
2024-04-16 18:33:41 +07:00
|
|
|
<div class="branch-wrapper q-pa-md">
|
|
|
|
|
<div class="q-mb-md flex" style="gap: var(--size-4)">
|
2024-04-18 16:13:16 +07:00
|
|
|
<div
|
|
|
|
|
style="
|
|
|
|
|
flex-grow: 1;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: stretch;
|
|
|
|
|
gap: var(--size-2);
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
<template v-if="!currentHq.id">
|
|
|
|
|
<q-select
|
2024-06-13 16:10:36 +07:00
|
|
|
id="select-branch"
|
|
|
|
|
for="select-branch"
|
2024-04-18 16:13:16 +07:00
|
|
|
v-model="fieldSelectedBranch"
|
|
|
|
|
style="min-width: 120px"
|
|
|
|
|
outlined
|
|
|
|
|
:options="
|
|
|
|
|
fieldBranch.map((v) => ({ label: $t(v), value: v }))
|
|
|
|
|
"
|
|
|
|
|
:label="$t('select')"
|
|
|
|
|
dense
|
|
|
|
|
/>
|
|
|
|
|
<q-btn
|
2024-06-13 16:10:36 +07:00
|
|
|
id="btn-filter"
|
2024-04-18 16:13:16 +07:00
|
|
|
icon="mdi-tune-vertical-variant"
|
2024-04-19 11:07:19 +07:00
|
|
|
size="sm"
|
2024-04-18 16:13:16 +07:00
|
|
|
class="bordered rounded"
|
2024-04-18 16:35:39 +07:00
|
|
|
:class="{ 'app-text-info': statusFilter !== 'all' }"
|
2024-04-18 16:13:16 +07:00
|
|
|
unelevated
|
|
|
|
|
>
|
|
|
|
|
<q-menu class="bordered">
|
|
|
|
|
<q-list v-close-popup dense>
|
|
|
|
|
<q-item
|
2024-06-13 16:10:36 +07:00
|
|
|
id="btn-filter-all"
|
2024-04-18 16:13:16 +07:00
|
|
|
clickable
|
|
|
|
|
class="flex items-center"
|
|
|
|
|
:class="{ 'app-text-info': statusFilter === 'all' }"
|
|
|
|
|
@click="statusFilter = 'all'"
|
|
|
|
|
>
|
|
|
|
|
{{ $t('all') }}
|
|
|
|
|
</q-item>
|
|
|
|
|
<q-item
|
2024-06-13 16:10:36 +07:00
|
|
|
id="btn-filter-active"
|
2024-04-18 16:13:16 +07:00
|
|
|
clickable
|
|
|
|
|
class="flex items-center"
|
|
|
|
|
:class="{
|
|
|
|
|
'app-text-info': statusFilter === 'statusACTIVE',
|
|
|
|
|
}"
|
|
|
|
|
@click="statusFilter = 'statusACTIVE'"
|
|
|
|
|
>
|
|
|
|
|
{{ $t('statusACTIVE') }}
|
|
|
|
|
</q-item>
|
|
|
|
|
<q-item
|
2024-06-13 16:10:36 +07:00
|
|
|
id="btn-filter-inactive"
|
2024-04-18 16:13:16 +07:00
|
|
|
clickable
|
|
|
|
|
class="flex items-center"
|
|
|
|
|
:class="{
|
|
|
|
|
'app-text-info': statusFilter === 'statusINACTIVE',
|
|
|
|
|
}"
|
|
|
|
|
@click="statusFilter = 'statusINACTIVE'"
|
|
|
|
|
>
|
|
|
|
|
{{ $t('statusINACTIVE') }}
|
|
|
|
|
</q-item>
|
|
|
|
|
</q-list>
|
|
|
|
|
</q-menu>
|
|
|
|
|
</q-btn>
|
|
|
|
|
</template>
|
2024-04-17 15:15:44 +07:00
|
|
|
<div v-else class="text-weight-bold text">
|
|
|
|
|
{{ $t('branchInHQ') }}
|
|
|
|
|
{{ currentHq.code }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
style="flex-grow: 1; display: flex; justify-content: flex-end"
|
|
|
|
|
>
|
|
|
|
|
<q-input
|
2024-06-13 16:10:36 +07:00
|
|
|
for="input-Search"
|
2024-04-17 15:15:44 +07:00
|
|
|
style="width: 250px"
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
label="ค้นหา"
|
|
|
|
|
v-model="inputSearch"
|
2024-04-19 09:42:09 +07:00
|
|
|
debounce="500"
|
2024-04-17 15:15:44 +07:00
|
|
|
></q-input>
|
2024-04-05 18:00:30 +07:00
|
|
|
</div>
|
2024-04-17 15:15:44 +07:00
|
|
|
|
2024-04-16 18:33:41 +07:00
|
|
|
<div style="flex-grow: 1">
|
2024-04-05 18:00:30 +07:00
|
|
|
<q-select
|
2024-06-13 16:10:36 +07:00
|
|
|
id="select-field"
|
|
|
|
|
for="select-field"
|
2024-04-16 18:33:41 +07:00
|
|
|
:options="
|
|
|
|
|
fieldDisplay.map((v) => ({ label: $t(v), value: v }))
|
|
|
|
|
"
|
2024-04-18 15:28:39 +07:00
|
|
|
:display-value="$t('displayField')"
|
2024-04-16 18:33:41 +07:00
|
|
|
v-model="fieldSelected"
|
|
|
|
|
option-label="label"
|
|
|
|
|
option-value="value"
|
|
|
|
|
map-options
|
|
|
|
|
emit-value
|
2024-04-05 18:00:30 +07:00
|
|
|
outlined
|
2024-04-16 18:33:41 +07:00
|
|
|
multiple
|
|
|
|
|
dense
|
2024-04-05 18:00:30 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-04-16 18:33:41 +07:00
|
|
|
<div class="branch-container">
|
|
|
|
|
<BranchCard
|
2024-06-13 15:54:35 +07:00
|
|
|
:id="`branch-card-${item.name}`"
|
2024-04-23 14:19:51 +07:00
|
|
|
v-for="item in treeData
|
|
|
|
|
.flatMap((v) => [v, ...v.branch])
|
2024-04-17 15:15:44 +07:00
|
|
|
.filter((v) => {
|
2024-04-18 16:13:16 +07:00
|
|
|
if (
|
|
|
|
|
statusFilter === 'statusACTIVE' &&
|
|
|
|
|
v.status === 'INACTIVE'
|
|
|
|
|
) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
statusFilter === 'statusINACTIVE' &&
|
|
|
|
|
v.status !== 'INACTIVE'
|
|
|
|
|
) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-04-19 09:42:09 +07:00
|
|
|
|
|
|
|
|
const terms = `${v.code} ${$i18n.locale === 'en-US' ? v.nameEN : v.name} ${v.telephoneNo}`;
|
|
|
|
|
if (inputSearch && !terms.includes(inputSearch)) {
|
|
|
|
|
return false;
|
2024-04-17 15:15:44 +07:00
|
|
|
}
|
2024-04-19 09:42:09 +07:00
|
|
|
|
2024-06-26 14:03:44 +07:00
|
|
|
if (!!currentHq.id && currentHq.id === v.headOfficeId) {
|
|
|
|
|
console.log('ทำงาน');
|
|
|
|
|
|
2024-04-17 15:15:44 +07:00
|
|
|
return true;
|
2024-06-26 14:03:44 +07:00
|
|
|
}
|
2024-04-19 09:42:09 +07:00
|
|
|
if (fieldSelectedBranch.value === 'all') return true;
|
|
|
|
|
if (fieldSelectedBranch.value === 'branchHQLabel')
|
2024-04-17 15:15:44 +07:00
|
|
|
return v.isHeadOffice;
|
2024-04-19 09:42:09 +07:00
|
|
|
if (fieldSelectedBranch.value === 'branchLabel')
|
2024-04-17 15:15:44 +07:00
|
|
|
return !v.isHeadOffice;
|
2024-04-19 09:42:09 +07:00
|
|
|
|
2024-04-17 15:15:44 +07:00
|
|
|
return false;
|
2024-04-22 14:19:35 +07:00
|
|
|
})"
|
2024-04-17 15:15:44 +07:00
|
|
|
@click="
|
|
|
|
|
() => {
|
2024-04-23 14:19:51 +07:00
|
|
|
if (item.isHeadOffice) {
|
2024-04-17 15:15:44 +07:00
|
|
|
fieldSelectedBranch.value = '';
|
2024-04-19 09:42:09 +07:00
|
|
|
inputSearch = '';
|
2024-04-23 14:19:51 +07:00
|
|
|
currentHq = { id: item.id, code: item.code };
|
2024-04-17 15:49:48 +07:00
|
|
|
beforeBranch = {
|
|
|
|
|
id: '',
|
|
|
|
|
code: '',
|
|
|
|
|
};
|
2024-04-17 15:15:44 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-04-23 14:19:51 +07:00
|
|
|
:metadata="item"
|
|
|
|
|
:color="item.isHeadOffice ? 'hq' : 'br'"
|
2024-04-16 18:33:41 +07:00
|
|
|
:key="item.id"
|
2024-04-23 14:19:51 +07:00
|
|
|
:data="{
|
|
|
|
|
branchLabelCode: item.code,
|
|
|
|
|
branchLabelName:
|
|
|
|
|
$i18n.locale === 'en-US' ? item.nameEN : item.name,
|
|
|
|
|
branchLabelTel: item.contact
|
|
|
|
|
.map((c) => c.telephoneNo)
|
|
|
|
|
.join(','),
|
|
|
|
|
branchLabelAddress:
|
|
|
|
|
$i18n.locale === 'en-US'
|
|
|
|
|
? `${item.addressEN || ''} ${item.subDistrict?.nameEN || ''} ${item.district?.nameEN || ''} ${item.province?.nameEN || ''}`
|
|
|
|
|
: `${item.address || ''} ${item.subDistrict?.name || ''} ${item.district?.name || ''} ${item.province?.name || ''}`,
|
|
|
|
|
branchLabelType: $t(
|
|
|
|
|
item.isHeadOffice ? 'branchHQLabel' : 'branchLabel',
|
|
|
|
|
),
|
|
|
|
|
branchLabelStatus: $t(`status${item.status}`),
|
|
|
|
|
}"
|
2024-04-16 18:33:41 +07:00
|
|
|
:field-selected="fieldSelected"
|
2024-04-23 14:19:51 +07:00
|
|
|
:badge-field="['branchLabelStatus']"
|
2024-04-18 15:28:39 +07:00
|
|
|
:inactive="item.status === 'INACTIVE'"
|
2024-04-19 11:47:41 +07:00
|
|
|
@view-detail="
|
2024-04-23 14:19:51 +07:00
|
|
|
(v) =>
|
|
|
|
|
triggerEdit(
|
|
|
|
|
'drawer',
|
|
|
|
|
v.id,
|
2024-04-23 14:26:20 +07:00
|
|
|
v.isHeadOffice ? 'headOffice' : 'subBranch',
|
2024-04-23 14:19:51 +07:00
|
|
|
)
|
2024-04-19 11:47:41 +07:00
|
|
|
"
|
2024-04-16 18:33:41 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-04-05 18:00:30 +07:00
|
|
|
</div>
|
2024-04-16 18:33:41 +07:00
|
|
|
</template>
|
2024-04-09 16:47:52 +07:00
|
|
|
</AppBox>
|
2024-04-02 17:47:32 +07:00
|
|
|
</div>
|
2024-04-18 13:56:00 +07:00
|
|
|
|
|
|
|
|
<FormDialog
|
|
|
|
|
ref="formDialogRef"
|
|
|
|
|
v-model:modal="modal"
|
|
|
|
|
v-model:address="formData.address"
|
|
|
|
|
v-model:addressEN="formData.addressEN"
|
|
|
|
|
v-model:province-id="formData.provinceId"
|
|
|
|
|
v-model:district-id="formData.districtId"
|
|
|
|
|
v-model:sub-district-id="formData.subDistrictId"
|
2024-06-28 10:09:53 +07:00
|
|
|
v-model:zip-code="formData.zipCode"
|
2024-04-22 10:52:26 +07:00
|
|
|
:title="changeTitle(formType, formTypeBranch) + ' ' + currentEdit.code"
|
2024-04-18 15:47:53 +07:00
|
|
|
:titleFormAddress="$t('formDialogTitleAddress')"
|
2024-04-25 10:05:38 +07:00
|
|
|
:address-title="$t('formDialogAddress')"
|
|
|
|
|
:address-title-EN="$t('formDialogAddressEN')"
|
2024-04-18 13:56:00 +07:00
|
|
|
:addressSeparator="true"
|
|
|
|
|
:submit="
|
|
|
|
|
() => {
|
|
|
|
|
onSubmit();
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-06-27 04:55:39 +00:00
|
|
|
:close="() => (modal = false)"
|
2024-04-18 13:56:00 +07:00
|
|
|
>
|
|
|
|
|
<template #information>
|
|
|
|
|
<FormBranchInformation
|
2024-06-28 11:14:58 +07:00
|
|
|
v-model:code="formData.codeHeadOffice"
|
2024-04-22 10:52:26 +07:00
|
|
|
v-model:code-sub-branch="currentEdit.code"
|
2024-04-18 13:56:00 +07:00
|
|
|
v-model:taxNo="formData.taxNo"
|
|
|
|
|
v-model:name="formData.name"
|
|
|
|
|
v-model:nameEN="formData.nameEN"
|
2024-04-18 18:07:38 +07:00
|
|
|
v-model:type-branch="formTypeBranch"
|
2024-04-18 13:56:00 +07:00
|
|
|
:separator="true"
|
|
|
|
|
:dense="true"
|
|
|
|
|
:outlined="true"
|
2024-04-19 11:47:41 +07:00
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
:view="formType === 'view'"
|
2024-04-18 13:56:00 +07:00
|
|
|
title="formDialogTitleInformation"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template #person>
|
|
|
|
|
<FormBranchContact
|
2024-06-28 10:49:23 +07:00
|
|
|
v-model:type-branch="formTypeBranch"
|
2024-04-18 13:56:00 +07:00
|
|
|
v-model:telephone-no="formData.telephoneNo"
|
|
|
|
|
v-model:contact="formData.contact"
|
|
|
|
|
v-model:email="formData.email"
|
|
|
|
|
v-model:contact-name="formData.contactName"
|
|
|
|
|
v-model:line-id="formData.lineId"
|
|
|
|
|
:separator="true"
|
|
|
|
|
title="formDialogTitleContact"
|
|
|
|
|
:dense="true"
|
|
|
|
|
:outlined="true"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template #qr-code>
|
|
|
|
|
<FormQr
|
2024-04-18 15:47:53 +07:00
|
|
|
title="QR Code"
|
2024-04-18 13:56:00 +07:00
|
|
|
:separator="true"
|
2024-04-18 15:10:54 +07:00
|
|
|
:qr="qrCodeimageUrl"
|
2024-04-19 11:47:41 +07:00
|
|
|
:readonly="formType === 'view'"
|
2024-04-18 13:56:00 +07:00
|
|
|
@upload="
|
|
|
|
|
() => {
|
|
|
|
|
inputFile.click();
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template #location>
|
|
|
|
|
<FormLocation
|
2024-04-19 11:47:41 +07:00
|
|
|
:readonly="formType === 'view'"
|
2024-04-18 17:30:29 +07:00
|
|
|
:separator="true"
|
2024-04-18 13:56:00 +07:00
|
|
|
v-model:latitude="formData.latitude"
|
|
|
|
|
v-model:longitude="formData.longitude"
|
|
|
|
|
title="formDialogTitleLocation"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
2024-04-18 17:30:29 +07:00
|
|
|
|
|
|
|
|
<template #by-type>
|
|
|
|
|
<FormImage
|
2024-04-19 11:47:41 +07:00
|
|
|
:readonly="formType === 'view'"
|
2024-04-18 17:30:29 +07:00
|
|
|
v-model:image="imageUrl"
|
|
|
|
|
@upload="
|
|
|
|
|
() => {
|
|
|
|
|
inputFileImg.click();
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
:title="$t('formDialogTitleImg')"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
2024-04-18 13:56:00 +07:00
|
|
|
</FormDialog>
|
2024-04-19 11:47:41 +07:00
|
|
|
|
|
|
|
|
<DrawerInfo
|
|
|
|
|
ref="formDialogRef"
|
|
|
|
|
v-model:drawerOpen="modalDrawer"
|
2024-04-22 10:52:26 +07:00
|
|
|
:title="changeTitle(formType, formTypeBranch) + ' ' + currentEdit.code"
|
2024-04-19 11:47:41 +07:00
|
|
|
:titleFormAddress="$t('formDialogTitleAddress')"
|
|
|
|
|
:addressSeparator="true"
|
|
|
|
|
:undo="() => undo()"
|
|
|
|
|
:isEdit="formType === 'edit'"
|
|
|
|
|
:editData="() => drawerEdit()"
|
|
|
|
|
:submit="() => onSubmit()"
|
2024-04-22 10:52:26 +07:00
|
|
|
:delete-data="() => triggerDelete(currentEdit.id)"
|
2024-06-26 17:03:49 +07:00
|
|
|
:close="() => ((modalDrawer = false), flowStore.rotate())"
|
2024-04-19 13:13:57 +07:00
|
|
|
:statusBranch="formData.status"
|
2024-04-19 11:47:41 +07:00
|
|
|
>
|
|
|
|
|
<template #info>
|
2024-04-19 13:25:48 +07:00
|
|
|
<InfoForm
|
2024-04-19 11:47:41 +07:00
|
|
|
v-model:address="formData.address"
|
|
|
|
|
v-model:addressEN="formData.addressEN"
|
|
|
|
|
v-model:province-id="formData.provinceId"
|
|
|
|
|
v-model:district-id="formData.districtId"
|
|
|
|
|
v-model:sub-district-id="formData.subDistrictId"
|
2024-06-28 10:09:53 +07:00
|
|
|
v-model:zip-code="formData.zipCode"
|
2024-04-25 10:05:38 +07:00
|
|
|
:title-form-address="$t('formDialogTitleAddress')"
|
|
|
|
|
:address-title="$t('formDialogAddress')"
|
|
|
|
|
:address-title-e-n="$t('formDialogAddressEN')"
|
2024-04-19 11:47:41 +07:00
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
>
|
|
|
|
|
<template #information>
|
|
|
|
|
<FormBranchInformation
|
2024-04-22 10:52:26 +07:00
|
|
|
v-model:code="currentHq.code"
|
|
|
|
|
v-model:code-sub-branch="currentEdit.code"
|
2024-04-19 11:47:41 +07:00
|
|
|
v-model:taxNo="formData.taxNo"
|
|
|
|
|
v-model:name="formData.name"
|
|
|
|
|
v-model:nameEN="formData.nameEN"
|
|
|
|
|
v-model:type-branch="formTypeBranch"
|
|
|
|
|
:separator="true"
|
|
|
|
|
:dense="true"
|
|
|
|
|
:outlined="true"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
:view="formType === 'view'"
|
|
|
|
|
title="formDialogTitleInformation"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template #person>
|
|
|
|
|
<FormBranchContact
|
|
|
|
|
title="formDialogTitleContact"
|
|
|
|
|
v-model:telephone-no="formData.telephoneNo"
|
|
|
|
|
v-model:contact="formData.contact"
|
|
|
|
|
v-model:email="formData.email"
|
|
|
|
|
v-model:contact-name="formData.contactName"
|
|
|
|
|
v-model:line-id="formData.lineId"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
:view="formType === 'view'"
|
|
|
|
|
:separator="true"
|
|
|
|
|
:dense="true"
|
|
|
|
|
:outlined="true"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template #qr-code>
|
|
|
|
|
<FormQr
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
title="QR Code"
|
|
|
|
|
:separator="true"
|
|
|
|
|
:qr="qrCodeimageUrl"
|
|
|
|
|
@upload="
|
|
|
|
|
() => {
|
|
|
|
|
inputFile.click();
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template #location>
|
|
|
|
|
<FormLocation
|
|
|
|
|
title="formDialogTitleLocation"
|
|
|
|
|
v-model:latitude="formData.latitude"
|
|
|
|
|
v-model:longitude="formData.longitude"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
:separator="true"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template #by-type>
|
|
|
|
|
<FormImage
|
|
|
|
|
@upload="
|
|
|
|
|
() => {
|
|
|
|
|
inputFileImg.click();
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
v-model:image="imageUrl"
|
|
|
|
|
:title="$t('formDialogTitleImg')"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
2024-04-19 13:25:48 +07:00
|
|
|
</InfoForm>
|
2024-04-19 11:47:41 +07:00
|
|
|
</template>
|
|
|
|
|
</DrawerInfo>
|
2024-04-02 17:47:32 +07:00
|
|
|
</template>
|
|
|
|
|
|
2024-04-05 18:00:30 +07:00
|
|
|
<style scoped>
|
2024-04-17 15:15:44 +07:00
|
|
|
.color-icon-arrow {
|
|
|
|
|
color: var(--gray-3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.color-icon-plus {
|
|
|
|
|
color: var(--cyan-6);
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-16 18:33:41 +07:00
|
|
|
.tree-container {
|
|
|
|
|
width: 100%;
|
|
|
|
|
min-width: 300px;
|
|
|
|
|
max-width: 25%;
|
|
|
|
|
max-height: 100%;
|
2024-04-05 18:00:30 +07:00
|
|
|
}
|
|
|
|
|
|
2024-04-16 18:33:41 +07:00
|
|
|
.branch-wrapper {
|
|
|
|
|
flex-grow: 1;
|
2024-04-05 18:00:30 +07:00
|
|
|
|
2024-04-16 18:33:41 +07:00
|
|
|
& > .branch-container {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
|
grid-template-rows: unset;
|
|
|
|
|
gap: var(--size-4);
|
2024-04-05 18:00:30 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|