2024-04-02 17:47:32 +07:00
|
|
|
<script setup lang="ts">
|
2024-09-12 14:35:49 +07:00
|
|
|
import { UploadFile } from 'components/upload-file';
|
2024-04-09 16:47:52 +07:00
|
|
|
import { storeToRefs } from 'pinia';
|
2024-07-18 09:10:51 +00:00
|
|
|
import { ref, onMounted, computed, watch } from 'vue';
|
2024-04-17 15:15:44 +07:00
|
|
|
import { Icon } from '@iconify/vue';
|
2024-08-09 15:06:41 +07:00
|
|
|
import { BranchContact } from 'stores/branch-contact/types';
|
2024-09-06 11:35:49 +07:00
|
|
|
import { useQuasar } from 'quasar';
|
2024-07-18 09:10:51 +00:00
|
|
|
import { useI18n } from 'vue-i18n';
|
2024-07-04 17:56:37 +07:00
|
|
|
import type { QTableProps } from 'quasar';
|
2024-09-05 10:37:14 +07:00
|
|
|
import { resetScrollBar } from 'src/stores/utils';
|
2024-04-05 18:14:53 +07:00
|
|
|
import useBranchStore from 'stores/branch';
|
2024-08-09 15:06:41 +07:00
|
|
|
import useFlowStore from 'stores/flow';
|
2024-08-02 11:13:21 +00:00
|
|
|
import {
|
|
|
|
|
BranchWithChildren,
|
|
|
|
|
BranchCreate,
|
|
|
|
|
Branch,
|
|
|
|
|
BankBook,
|
|
|
|
|
} from 'stores/branch/types';
|
2024-04-16 18:33:41 +07:00
|
|
|
|
2024-09-11 13:44:57 +07:00
|
|
|
import QrCodeUploadDialog from 'src/components/QrCodeUploadDialog.vue';
|
2024-09-03 18:15:45 +07:00
|
|
|
import ItemCard from 'src/components/ItemCard.vue';
|
2024-08-09 15:06:41 +07:00
|
|
|
import useUtilsStore, { dialog, baseUrl } from 'stores/utils';
|
2024-08-19 10:17:44 +07:00
|
|
|
import EmptyAddButton 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-06-28 14:14:23 +07:00
|
|
|
import BranchCard from 'components/01_branch-management/BranchCard.vue';
|
2024-08-09 14:00:57 +07:00
|
|
|
import { AddressForm } from 'components/form';
|
2024-08-01 08:44:40 +00:00
|
|
|
import DialogForm from 'components/DialogForm.vue';
|
2024-06-28 14:14:23 +07:00
|
|
|
import FormBranchInformation from 'components/01_branch-management/FormBranchInformation.vue';
|
|
|
|
|
import FormLocation from 'components/01_branch-management/FormLocation.vue';
|
|
|
|
|
import FormQr from 'components/01_branch-management/FormQr.vue';
|
|
|
|
|
import FormBranchContact from 'components/01_branch-management/FormBranchContact.vue';
|
|
|
|
|
import DrawerInfo from 'components/DrawerInfo.vue';
|
|
|
|
|
import InfoForm from 'components/02_personnel-management/InfoForm.vue';
|
2024-08-09 15:03:03 +07:00
|
|
|
import TreeComponent from 'components/TreeComponent.vue';
|
2024-08-09 14:02:40 +07:00
|
|
|
import ProfileBanner from 'components/ProfileBanner.vue';
|
|
|
|
|
import SideMenu from 'components/SideMenu.vue';
|
|
|
|
|
import ImageUploadDialog from 'components/ImageUploadDialog.vue';
|
|
|
|
|
import FormBank from 'components/01_branch-management/FormBank.vue';
|
2024-08-13 08:55:49 +00:00
|
|
|
import ToggleButton from 'src/components/button/ToggleButton.vue';
|
2024-08-14 15:30:01 +07:00
|
|
|
import FormBranchAdmin from 'src/components/01_branch-management/FormBranchAdmin.vue';
|
2024-08-27 11:46:26 +07:00
|
|
|
import KebabAction from 'src/components/shared/KebabAction.vue';
|
2024-08-14 15:30:01 +07:00
|
|
|
import { User } from 'src/stores/user/types';
|
2024-08-19 10:17:44 +07:00
|
|
|
import {
|
|
|
|
|
EditButton,
|
|
|
|
|
DeleteButton,
|
|
|
|
|
SaveButton,
|
|
|
|
|
UndoButton,
|
|
|
|
|
} from 'components/button';
|
2024-04-10 16:02:28 +07:00
|
|
|
|
2024-07-18 09:10:51 +00:00
|
|
|
const $q = useQuasar();
|
2024-04-17 15:15:44 +07:00
|
|
|
const { t } = useI18n();
|
2024-07-02 09:22:06 +00:00
|
|
|
const utilsStore = useUtilsStore();
|
2024-09-03 18:15:45 +07:00
|
|
|
const modelCreateTypeBranch = ref<boolean>(false);
|
|
|
|
|
const typeBranchItem = [
|
|
|
|
|
{
|
2024-09-06 11:11:28 +07:00
|
|
|
icon: 'material-symbols:home-work-outline',
|
2024-09-11 10:26:12 +07:00
|
|
|
text: 'branch.card.branchLabel',
|
2024-09-06 11:11:28 +07:00
|
|
|
iconColor: '--purple-8',
|
|
|
|
|
color: 'var(--purple-6-hsl)',
|
2024-09-03 18:15:45 +07:00
|
|
|
},
|
2024-09-06 11:11:28 +07:00
|
|
|
|
2024-09-03 18:15:45 +07:00
|
|
|
{
|
|
|
|
|
icon: 'mdi-home-group',
|
2024-09-11 10:26:12 +07:00
|
|
|
text: 'branch.card.branchVirtual',
|
2024-09-06 11:11:28 +07:00
|
|
|
iconColor: '--blue-8',
|
|
|
|
|
color: 'var(--blue-6-hsl)',
|
2024-09-03 18:15:45 +07:00
|
|
|
},
|
|
|
|
|
];
|
2024-07-19 04:16:07 +00:00
|
|
|
const holdDialog = ref(false);
|
2024-08-07 10:08:45 +00:00
|
|
|
const isSubCreate = ref(false);
|
2024-07-04 17:56:37 +07:00
|
|
|
const columns = [
|
2024-08-05 13:39:29 +07:00
|
|
|
{
|
2024-08-09 10:47:35 +07:00
|
|
|
name: 'orderNumber',
|
2024-08-05 13:39:29 +07:00
|
|
|
align: 'center',
|
2024-08-26 16:24:08 +07:00
|
|
|
label: 'general.orderNumber',
|
2024-08-05 13:39:29 +07:00
|
|
|
field: 'branchNo',
|
|
|
|
|
},
|
|
|
|
|
|
2024-07-04 17:56:37 +07:00
|
|
|
{
|
2024-09-09 15:47:09 +07:00
|
|
|
name: 'office',
|
2024-07-04 17:56:37 +07:00
|
|
|
align: 'left',
|
2024-08-26 16:24:08 +07:00
|
|
|
label: 'branch.office',
|
2024-07-04 17:56:37 +07:00
|
|
|
field: 'name',
|
|
|
|
|
sortable: true,
|
|
|
|
|
},
|
2024-09-09 11:59:51 +07:00
|
|
|
|
2024-07-04 17:56:37 +07:00
|
|
|
{
|
2024-09-09 11:59:51 +07:00
|
|
|
name: 'taxNo',
|
2024-07-04 17:56:37 +07:00
|
|
|
align: 'left',
|
2024-09-09 11:59:51 +07:00
|
|
|
label: 'general.taxNo',
|
|
|
|
|
field: 'taxNo',
|
2024-07-04 17:56:37 +07:00
|
|
|
},
|
2024-09-09 11:59:51 +07:00
|
|
|
|
2024-07-04 17:56:37 +07:00
|
|
|
{
|
2024-07-05 13:08:07 +07:00
|
|
|
name: 'branchLabelTel',
|
2024-07-04 17:56:37 +07:00
|
|
|
align: 'left',
|
2024-09-09 11:59:51 +07:00
|
|
|
label: 'branch.card.branchLabelTel',
|
2024-07-04 17:56:37 +07:00
|
|
|
field: 'telephoneNo',
|
|
|
|
|
},
|
2024-09-09 11:59:51 +07:00
|
|
|
|
|
|
|
|
{
|
|
|
|
|
name: 'contactName',
|
|
|
|
|
align: 'left',
|
|
|
|
|
label: 'general.contactName',
|
|
|
|
|
field: 'contactName',
|
|
|
|
|
},
|
|
|
|
|
|
2024-07-04 17:56:37 +07:00
|
|
|
{
|
2024-09-09 11:59:51 +07:00
|
|
|
name: 'branchLabelAddress',
|
2024-07-04 17:56:37 +07:00
|
|
|
align: 'left',
|
2024-09-09 11:59:51 +07:00
|
|
|
label: 'general.address',
|
|
|
|
|
field: 'address',
|
|
|
|
|
sortable: true,
|
2024-07-04 17:56:37 +07:00
|
|
|
},
|
|
|
|
|
] satisfies QTableProps['columns'];
|
2024-09-12 14:35:49 +07:00
|
|
|
const currentTab = ref<string>('main');
|
2024-04-18 13:56:00 +07:00
|
|
|
const modal = ref<boolean>(false);
|
2024-07-05 03:39:41 +00:00
|
|
|
const hideStat = ref(false);
|
2024-08-07 10:08:45 +00:00
|
|
|
const currentId = ref<string>('');
|
2024-07-18 14:18:16 +07:00
|
|
|
const expandedTree = ref<string[]>([]);
|
2024-08-02 03:52:56 +00:00
|
|
|
const formMenuIcon = ref<{ icon: string; color: string; bgColor: string }[]>([
|
|
|
|
|
{
|
2024-08-08 06:10:54 +00:00
|
|
|
icon: 'mdi-phone-outline',
|
2024-08-02 03:52:56 +00:00
|
|
|
color: 'hsl(var(--info-bg))',
|
|
|
|
|
bgColor: 'var(--surface-1)',
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-08-08 06:10:54 +00:00
|
|
|
icon: 'mdi-map-marker-radius-outline',
|
2024-08-02 03:52:56 +00:00
|
|
|
color: 'hsl(var(--info-bg))',
|
|
|
|
|
bgColor: 'var(--surface-1)',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
icon: 'mdi-map-legend',
|
|
|
|
|
color: 'hsl(var(--info-bg))',
|
|
|
|
|
bgColor: 'var(--surface-1)',
|
|
|
|
|
},
|
2024-08-02 11:13:21 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const formBankBook = ref<BankBook[]>([
|
2024-08-02 03:52:56 +00:00
|
|
|
{
|
2024-08-02 11:13:21 +00:00
|
|
|
bankName: '',
|
|
|
|
|
accountNumber: '',
|
|
|
|
|
bankBranch: '',
|
|
|
|
|
accountName: '',
|
|
|
|
|
accountType: '',
|
|
|
|
|
currentlyUse: true,
|
2024-09-11 13:44:57 +07:00
|
|
|
bankUrl: '',
|
2024-08-02 03:52:56 +00:00
|
|
|
},
|
|
|
|
|
]);
|
2024-04-18 13:56:00 +07:00
|
|
|
|
2024-09-16 10:27:08 +07:00
|
|
|
const attachmentList = ref<File[]>([]);
|
|
|
|
|
const currentAttachmentList = ref<
|
|
|
|
|
{
|
|
|
|
|
name?: string;
|
|
|
|
|
group?: string;
|
|
|
|
|
url?: string;
|
|
|
|
|
file?: File;
|
|
|
|
|
}[]
|
|
|
|
|
>([]);
|
|
|
|
|
const currentAttachmentSelected = ref<string>('');
|
|
|
|
|
|
2024-09-11 13:44:57 +07:00
|
|
|
const statusQrCodeFile = ref<File | undefined>(undefined);
|
|
|
|
|
const statusQrCodeUrl = ref<string>('');
|
|
|
|
|
const statusDeletsQrCode = ref<boolean>(false);
|
|
|
|
|
|
|
|
|
|
const deletsStatusQrCodeImag = ref(false);
|
|
|
|
|
const deletsStatusQrCodeBankImag = ref<number[]>([]);
|
|
|
|
|
const currentIndexQrCodeBank = ref<number>(-1);
|
|
|
|
|
const refQrCodeUpload = ref();
|
2024-08-02 08:26:55 +00:00
|
|
|
const refImageUpload = ref();
|
2024-08-02 03:52:56 +00:00
|
|
|
const isImageEdit = ref(false);
|
2024-09-11 13:44:57 +07:00
|
|
|
const isQrCodeEdit = ref(false);
|
2024-09-11 16:43:41 +07:00
|
|
|
const profileFile = ref<File | null>(null);
|
2024-09-11 13:44:57 +07:00
|
|
|
const qrCodeFile = ref<File | undefined>(undefined);
|
2024-08-02 08:26:55 +00:00
|
|
|
const imageUrl = ref<string>('');
|
2024-07-19 04:56:08 +00:00
|
|
|
const currentNode = ref<BranchWithChildren>();
|
2024-08-02 03:52:56 +00:00
|
|
|
const imageDialog = ref(false);
|
2024-09-11 16:43:41 +07:00
|
|
|
const refreshImageState = ref(false);
|
|
|
|
|
const imageList = ref<{ selectedImage: string; list: string[] }>();
|
|
|
|
|
const onCreateImageList = ref<{
|
|
|
|
|
selectedImage: string;
|
|
|
|
|
list: { url: string; imgFile: File | null; name: string }[];
|
|
|
|
|
}>({ selectedImage: '', list: [] });
|
2024-09-11 13:44:57 +07:00
|
|
|
const qrCodeDialog = ref(false);
|
2024-04-18 17:30:29 +07:00
|
|
|
|
2024-09-11 13:44:57 +07:00
|
|
|
const qrCodeimageUrl = ref<string>('');
|
2024-08-29 10:38:20 +07:00
|
|
|
const formLastSubBranch = ref<number>(0);
|
2024-04-18 13:56:00 +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-09-11 15:41:35 +07:00
|
|
|
const currentSubBranch = ref<Branch[] | undefined>(undefined);
|
2024-04-16 18:33:41 +07:00
|
|
|
const treeData = computed(() => {
|
2024-08-23 16:13:18 +07:00
|
|
|
const map: Record<string, BranchWithChildren> = {};
|
2024-04-09 15:54:47 +07:00
|
|
|
|
2024-08-23 16:13:18 +07:00
|
|
|
branchData.value?.result.forEach((v) => {
|
2024-09-11 11:13:12 +07:00
|
|
|
const name = locale.value === 'eng' ? v.nameEN : v.name;
|
2024-04-09 15:54:47 +07:00
|
|
|
|
2024-09-11 15:41:35 +07:00
|
|
|
map[v.id] = { ...v, name, branch: v.branch || [] };
|
2024-08-23 16:13:18 +07:00
|
|
|
});
|
|
|
|
|
|
2024-09-11 15:41:35 +07:00
|
|
|
// branchData.value?.result.forEach((v) => {
|
|
|
|
|
// const name = locale.value === 'eng' ? v.nameEN : v.name;
|
|
|
|
|
// if (v.isHeadOffice) map[v.id] = { ...v, name, branch: [] };
|
|
|
|
|
// else children.push({ ...v, name });
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// children.forEach((v) => {
|
|
|
|
|
// const name = locale.value === 'eng' ? v.nameEN : v.name;
|
|
|
|
|
// if (v.headOfficeId && map[v.headOfficeId]) {
|
|
|
|
|
// map[v.headOfficeId].branch.push({ ...v, name });
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
2024-08-23 16:13:18 +07:00
|
|
|
return Object.values(map);
|
2024-04-16 18:33:41 +07:00
|
|
|
});
|
2024-04-05 18:00:30 +07:00
|
|
|
|
2024-09-06 17:25:06 +07:00
|
|
|
async function calculateStats(headOfficeId?: string) {
|
|
|
|
|
const _stats = await branchStore.stats({ headOfficeId });
|
2024-04-16 18:33:41 +07:00
|
|
|
|
2024-09-06 17:25:06 +07:00
|
|
|
if (!_stats) return;
|
2024-09-06 11:35:49 +07:00
|
|
|
|
2024-09-06 17:25:06 +07:00
|
|
|
const baseStats: {
|
|
|
|
|
icon: string;
|
|
|
|
|
count: number;
|
|
|
|
|
label: string;
|
|
|
|
|
color: 'pink' | 'purple' | 'blue';
|
|
|
|
|
}[] = [
|
|
|
|
|
{
|
|
|
|
|
icon: 'mdi-office-building-outline',
|
|
|
|
|
count: _stats.hq,
|
|
|
|
|
label: 'branch.card.branchHQLabel',
|
|
|
|
|
color: 'pink',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
icon: 'mdi-home-group',
|
|
|
|
|
count: _stats.br,
|
|
|
|
|
label: 'branch.card.branchLabel',
|
|
|
|
|
color: 'purple',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
icon: 'mdi-home-group',
|
|
|
|
|
count: _stats.virtual,
|
|
|
|
|
label: 'branch.card.branchVirtual',
|
|
|
|
|
color: 'blue',
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
stats.value = baseStats.filter((v) => {
|
2024-09-09 10:00:59 +07:00
|
|
|
if (headOfficeId !== undefined && v.label.includes('HQ')) {
|
|
|
|
|
return false;
|
2024-09-06 17:25:06 +07:00
|
|
|
}
|
2024-09-09 10:00:59 +07:00
|
|
|
return true;
|
2024-09-06 17:25:06 +07:00
|
|
|
});
|
2024-06-28 13:04:02 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
2024-08-26 16:24:08 +07:00
|
|
|
utilsStore.currentTitle.title = 'menu.branch';
|
2024-07-09 17:17:08 +07:00
|
|
|
utilsStore.currentTitle.path = [
|
|
|
|
|
{
|
2024-08-26 16:24:08 +07:00
|
|
|
text: 'branch.page.captionManage',
|
2024-08-06 13:26:38 +07:00
|
|
|
i18n: true,
|
2024-07-09 17:17:08 +07:00
|
|
|
handler: () => {
|
|
|
|
|
fieldSelectedBranch.value.value = 'branchHQLabel';
|
|
|
|
|
currentHq.value = {
|
|
|
|
|
id: '',
|
|
|
|
|
code: '',
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-07-24 14:44:57 +07:00
|
|
|
// track of the currently selected HQ branch, so when we reset it to an empty
|
|
|
|
|
// object, we are effectively unselecting any HQ branch.
|
2024-07-09 17:17:08 +07:00
|
|
|
];
|
2024-07-02 09:22:06 +00:00
|
|
|
|
2024-09-11 15:41:35 +07:00
|
|
|
await fetchList({ pageSize: 99999, tree: true });
|
2024-06-28 13:04:02 +07:00
|
|
|
await calculateStats();
|
2024-06-25 16:08:46 +07:00
|
|
|
|
2024-07-18 09:10:51 +00:00
|
|
|
modeView.value = $q.screen.lt.md ? true : false;
|
|
|
|
|
|
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: '',
|
|
|
|
|
});
|
|
|
|
|
|
2024-09-09 11:59:51 +07:00
|
|
|
const modeView = ref<boolean>(false);
|
2024-04-17 15:15:44 +07:00
|
|
|
const inputSearch = ref<string>('');
|
2024-09-09 11:59:51 +07:00
|
|
|
|
|
|
|
|
const fieldDisplay = computed(() => {
|
|
|
|
|
return columns
|
|
|
|
|
.filter((v) => {
|
|
|
|
|
return !(
|
|
|
|
|
modeView.value === true &&
|
2024-09-10 09:59:47 +07:00
|
|
|
(v.name.includes('office') || v.name.includes('orderNumber'))
|
2024-09-09 11:59:51 +07:00
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
.map((v) => v.name);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const fieldSelected = ref<string[]>([...fieldDisplay.value]);
|
|
|
|
|
|
|
|
|
|
watch(modeView, () => {
|
|
|
|
|
fieldSelected.value = [...fieldDisplay.value];
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-17 11:33:41 +07:00
|
|
|
const fieldSelectedBranch = ref<{
|
|
|
|
|
label: string;
|
|
|
|
|
value: string;
|
|
|
|
|
}>({
|
2024-08-26 16:24:08 +07:00
|
|
|
label: t('branch.form.title.branchHQLabel'),
|
2024-04-17 15:15:44 +07:00
|
|
|
value: 'branchHQLabel',
|
2024-04-17 11:33:41 +07:00
|
|
|
});
|
|
|
|
|
|
2024-07-03 14:13:22 +07:00
|
|
|
const stats = ref<
|
2024-09-06 11:35:49 +07:00
|
|
|
{
|
|
|
|
|
icon: string;
|
|
|
|
|
count: number;
|
|
|
|
|
label: string;
|
|
|
|
|
color: 'pink' | 'purple' | 'blue';
|
|
|
|
|
}[]
|
2024-07-03 14:13:22 +07:00
|
|
|
>([]);
|
2024-04-16 18:33:41 +07:00
|
|
|
|
2024-07-04 17:56:37 +07:00
|
|
|
const splitterModel = ref(25);
|
|
|
|
|
|
2024-04-18 13:56:00 +07:00
|
|
|
const defaultFormData = {
|
|
|
|
|
headOfficeId: null,
|
2024-08-07 10:08:45 +00:00
|
|
|
code: '',
|
2024-04-18 13:56:00 +07:00
|
|
|
taxNo: '',
|
|
|
|
|
nameEN: '',
|
|
|
|
|
name: '',
|
|
|
|
|
addressEN: '',
|
|
|
|
|
address: '',
|
|
|
|
|
zipCode: '',
|
|
|
|
|
email: '',
|
|
|
|
|
contactName: '',
|
|
|
|
|
contact: '',
|
|
|
|
|
telephoneNo: '',
|
|
|
|
|
longitude: '',
|
|
|
|
|
latitude: '',
|
|
|
|
|
subDistrictId: '',
|
|
|
|
|
districtId: '',
|
|
|
|
|
provinceId: '',
|
2024-09-18 14:29:32 +07:00
|
|
|
moo: '',
|
|
|
|
|
mooEN: '',
|
|
|
|
|
soi: '',
|
|
|
|
|
soiEN: '',
|
|
|
|
|
street: '',
|
|
|
|
|
streetEN: '',
|
2024-04-18 13:56:00 +07:00
|
|
|
lineId: '',
|
2024-08-29 12:03:54 +07:00
|
|
|
webUrl: '',
|
2024-09-03 18:15:45 +07:00
|
|
|
virtual: false,
|
2024-09-11 16:43:41 +07:00
|
|
|
selectedImage: '',
|
2024-09-12 14:35:49 +07:00
|
|
|
permitExpireDate: new Date(),
|
|
|
|
|
permitIssueDate: new Date(),
|
|
|
|
|
permitNo: '',
|
2024-04-18 13:56:00 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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-08-29 10:38:20 +07:00
|
|
|
const currentHq = ref<{ id: string; code: string }>({
|
2024-08-28 15:51:50 +07:00
|
|
|
id: '',
|
|
|
|
|
code: '',
|
|
|
|
|
});
|
2024-08-29 10:38:20 +07:00
|
|
|
const currentEdit = ref<{ id: string; code: string }>({
|
2024-08-28 15:51:50 +07:00
|
|
|
id: '',
|
|
|
|
|
code: '',
|
|
|
|
|
});
|
2024-06-28 11:14:58 +07:00
|
|
|
const formData = ref<
|
2024-09-11 16:43:41 +07:00
|
|
|
Omit<BranchCreate & { codeHeadOffice?: string }, 'qrCodeImage'>
|
2024-06-28 11:14:58 +07:00
|
|
|
>(structuredClone(defaultFormData));
|
2024-04-18 13:56:00 +07:00
|
|
|
|
2024-06-28 11:14:58 +07:00
|
|
|
const prevFormData = ref<
|
2024-09-11 16:43:41 +07:00
|
|
|
Omit<BranchCreate & { codeHeadOffice?: string }, 'qrCodeImage'>
|
2024-06-28 11:14:58 +07:00
|
|
|
>(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-09-11 15:41:35 +07:00
|
|
|
async function selectedSubBranche(id: string) {
|
|
|
|
|
const res = await branchStore.fetchById(id, {
|
|
|
|
|
includeSubBranch: true,
|
|
|
|
|
includeContact: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
|
currentSubBranch.value = res.branch;
|
|
|
|
|
} else {
|
|
|
|
|
currentSubBranch.value = undefined;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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) {
|
2024-09-12 09:58:04 +07:00
|
|
|
qrCodeimageUrl.value = `${baseUrl}/branch/${res.id}/line-image?ts=${Date.now()}`;
|
2024-09-11 16:43:41 +07:00
|
|
|
imageUrl.value = `${baseUrl}/branch/${res.id}/image/${res.selectedImage}`;
|
2024-09-05 15:25:35 +07:00
|
|
|
formBankBook.value = res.bank;
|
2024-08-02 11:13:21 +00:00
|
|
|
|
2024-09-11 13:44:57 +07:00
|
|
|
formBankBook.value = formBankBook.value.map((v) => {
|
|
|
|
|
return {
|
|
|
|
|
...v,
|
2024-09-11 16:52:51 +07:00
|
|
|
bankUrl: `${baseUrl}/branch/${res.id}/bank-qr/${v.id}?ts=${Date.now()}`,
|
2024-09-11 13:44:57 +07:00
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
2024-09-16 10:27:08 +07:00
|
|
|
const resAttachment = await branchStore.fetchListAttachment(res.id);
|
|
|
|
|
|
|
|
|
|
if (resAttachment) {
|
|
|
|
|
currentAttachmentList.value = await Promise.all(
|
|
|
|
|
resAttachment.map(async (v) => {
|
|
|
|
|
return {
|
|
|
|
|
name: v,
|
|
|
|
|
url: (await branchStore.fetchByIdAttachment(res.id, v)) || '',
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-18 15:10:54 +07:00
|
|
|
formData.value = {
|
2024-08-07 10:08:45 +00:00
|
|
|
code: res.code,
|
2024-04-18 15:10:54 +07:00
|
|
|
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-08-16 17:31:40 +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-08-29 12:03:54 +07:00
|
|
|
webUrl: res.webUrl,
|
2024-09-03 18:15:45 +07:00
|
|
|
virtual: res.virtual,
|
2024-09-11 16:43:41 +07:00
|
|
|
selectedImage: res.selectedImage,
|
2024-09-18 14:29:32 +07:00
|
|
|
moo: res.moo,
|
|
|
|
|
mooEN: res.mooEN,
|
|
|
|
|
soi: res.soi,
|
|
|
|
|
soiEN: res.soiEN,
|
|
|
|
|
street: res.street,
|
|
|
|
|
streetEN: res.streetEN,
|
2024-09-12 14:35:49 +07:00
|
|
|
|
|
|
|
|
permitExpireDate: new Date(res.permitExpireDate),
|
|
|
|
|
permitIssueDate: new Date(res.permitIssueDate),
|
|
|
|
|
permitNo: res.permitNo,
|
2024-04-18 15:10:54 +07:00
|
|
|
};
|
2024-09-18 09:51:13 +07:00
|
|
|
return res;
|
2024-04-18 15:10:54 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearData() {
|
|
|
|
|
formData.value = structuredClone(defaultFormData);
|
2024-08-02 08:26:55 +00:00
|
|
|
imageUrl.value = '';
|
2024-09-11 13:44:57 +07:00
|
|
|
qrCodeimageUrl.value = '';
|
2024-04-22 10:52:26 +07:00
|
|
|
currentEdit.value = {
|
2024-04-19 11:47:41 +07:00
|
|
|
id: '',
|
|
|
|
|
code: '',
|
|
|
|
|
};
|
2024-09-11 13:44:57 +07:00
|
|
|
qrCodeFile.value = undefined;
|
2024-09-16 10:27:08 +07:00
|
|
|
currentAttachmentList.value = [];
|
|
|
|
|
currentTab.value = 'main';
|
2024-08-02 11:13:21 +00:00
|
|
|
formBankBook.value = [
|
|
|
|
|
{
|
|
|
|
|
bankName: '',
|
|
|
|
|
accountNumber: '',
|
|
|
|
|
bankBranch: '',
|
|
|
|
|
accountName: '',
|
|
|
|
|
accountType: '',
|
|
|
|
|
currentlyUse: true,
|
2024-08-05 13:39:29 +07:00
|
|
|
},
|
2024-08-02 11:13:21 +00:00
|
|
|
];
|
2024-04-18 15:10:54 +07:00
|
|
|
}
|
|
|
|
|
|
2024-04-19 11:47:41 +07:00
|
|
|
async function undo() {
|
2024-09-11 13:44:57 +07:00
|
|
|
isQrCodeEdit.value = false;
|
2024-08-05 07:13:46 +00:00
|
|
|
isImageEdit.value = false;
|
2024-04-19 11:47:41 +07:00
|
|
|
formType.value = 'view';
|
2024-09-11 16:43:41 +07:00
|
|
|
const tempSelectedImage = formData.value.selectedImage;
|
|
|
|
|
formData.value = JSON.parse(JSON.stringify(prevFormData.value));
|
|
|
|
|
formData.value.selectedImage = tempSelectedImage;
|
2024-04-18 15:47:53 +07:00
|
|
|
}
|
|
|
|
|
|
2024-09-06 17:25:06 +07:00
|
|
|
watch(expandedTree, async () => {
|
|
|
|
|
calculateStats(expandedTree.value[0]);
|
|
|
|
|
});
|
|
|
|
|
|
2024-09-03 18:15:45 +07:00
|
|
|
watch(modal, () => {
|
|
|
|
|
if (!modal.value) {
|
|
|
|
|
clearData();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2024-09-04 10:22:36 +07:00
|
|
|
watch(modalDrawer, () => {
|
|
|
|
|
if (!modalDrawer.value) {
|
|
|
|
|
clearData();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-22 10:52:26 +07:00
|
|
|
function triggerCreate(
|
|
|
|
|
type: 'headOffice' | 'subBranch',
|
|
|
|
|
id?: string,
|
|
|
|
|
code?: string,
|
|
|
|
|
) {
|
|
|
|
|
formTypeBranch.value = type;
|
2024-06-14 16:05:42 +07:00
|
|
|
|
2024-06-28 11:14:58 +07:00
|
|
|
if (type === 'subBranch' && id && code) {
|
2024-08-07 10:08:45 +00:00
|
|
|
isSubCreate.value = true;
|
2024-06-28 11:14:58 +07:00
|
|
|
formData.value.headOfficeId = id;
|
2024-08-07 10:08:45 +00:00
|
|
|
formData.value.code = code;
|
2024-06-28 11:14:58 +07:00
|
|
|
formData.value.codeHeadOffice = code;
|
2024-08-29 10:38:20 +07:00
|
|
|
formLastSubBranch.value = findLastSub(code);
|
2024-06-28 11:14:58 +07:00
|
|
|
}
|
2024-04-18 13:56:00 +07:00
|
|
|
formType.value = 'create';
|
2024-09-16 10:27:08 +07:00
|
|
|
currentId.value = '';
|
2024-04-18 13:56:00 +07:00
|
|
|
openDialog();
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-29 10:38:20 +07:00
|
|
|
function findLastSub(code: string) {
|
|
|
|
|
const abbrev = code.slice(0, -5);
|
|
|
|
|
const filteredArray = branchData.value.result.filter((v) =>
|
|
|
|
|
v.code.includes(abbrev),
|
|
|
|
|
);
|
|
|
|
|
const maxCodeNum = filteredArray.reduce((max, v) => {
|
|
|
|
|
const codeNum = parseInt(v.code.slice(-5), 10);
|
|
|
|
|
return codeNum > max ? codeNum : max;
|
|
|
|
|
}, 0);
|
|
|
|
|
return maxCodeNum;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-19 14:09:17 +07:00
|
|
|
function drawerEdit() {
|
2024-09-11 13:44:57 +07:00
|
|
|
isQrCodeEdit.value = true;
|
2024-08-05 07:13:46 +00:00
|
|
|
isImageEdit.value = true;
|
2024-04-19 14:09:17 +07:00
|
|
|
formType.value = 'edit';
|
2024-09-11 16:43:41 +07:00
|
|
|
prevFormData.value = JSON.parse(JSON.stringify(formData.value));
|
2024-04-19 14:09:17 +07:00
|
|
|
}
|
|
|
|
|
|
2024-08-14 15:30:01 +07:00
|
|
|
const currentBranchAdmin = ref<User | null>(null);
|
2024-04-22 10:52:26 +07:00
|
|
|
async function triggerEdit(
|
|
|
|
|
openFormType: string,
|
|
|
|
|
id: string,
|
|
|
|
|
typeBranch: 'headOffice' | 'subBranch',
|
2024-06-28 12:01:04 +07:00
|
|
|
code?: string,
|
2024-04-22 10:52:26 +07:00
|
|
|
) {
|
2024-09-18 09:51:13 +07:00
|
|
|
const currentRecord = await fetchBranchById(id);
|
2024-09-11 16:43:41 +07:00
|
|
|
await fetchImageList(id, formData.value.selectedImage || '');
|
|
|
|
|
|
2024-09-16 10:27:08 +07:00
|
|
|
formTypeBranch.value = typeBranch;
|
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
|
|
|
}
|
|
|
|
|
|
2024-06-28 12:01:04 +07:00
|
|
|
if (typeBranch === 'headOffice') {
|
|
|
|
|
formData.value.codeHeadOffice = code;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-07 10:08:45 +00:00
|
|
|
currentId.value = id;
|
|
|
|
|
|
2024-04-19 13:53:05 +07:00
|
|
|
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-28 12:01:04 +07:00
|
|
|
formData.value.codeHeadOffice = currentRecordHead?.code;
|
|
|
|
|
|
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-08-14 15:30:01 +07:00
|
|
|
const branchAdmin = await branchStore.getAdmin(id);
|
|
|
|
|
|
|
|
|
|
if (!branchAdmin) {
|
|
|
|
|
currentBranchAdmin.value = null;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
currentBranchAdmin.value = branchAdmin;
|
2024-04-18 15:10:54 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function triggerDelete(id: string) {
|
|
|
|
|
if (id) {
|
|
|
|
|
dialog({
|
|
|
|
|
color: 'negative',
|
|
|
|
|
icon: 'mdi-alert',
|
2024-08-27 11:46:26 +07:00
|
|
|
title: t('dialog.title.confirmDelete'),
|
|
|
|
|
actionText: t('general.delete'),
|
2024-04-18 15:10:54 +07:00
|
|
|
persistent: true,
|
2024-08-27 11:46:26 +07:00
|
|
|
message: t('dialog.message.confirmDelete'),
|
2024-04-18 15:10:54 +07:00
|
|
|
action: async () => {
|
|
|
|
|
await branchStore.deleteById(id);
|
2024-09-16 10:27:08 +07:00
|
|
|
await fetchList({ tree: true, pageSize: 99999 });
|
2024-04-19 11:47:41 +07:00
|
|
|
modalDrawer.value = false;
|
2024-06-28 13:04:02 +07:00
|
|
|
await calculateStats();
|
|
|
|
|
|
2024-08-08 04:17:47 +00:00
|
|
|
const branchLength = treeData.value.find(
|
|
|
|
|
(node) => node.id === expandedTree.value[0],
|
|
|
|
|
)?.branch.length;
|
|
|
|
|
if (branchLength === 0) {
|
|
|
|
|
expandedTree.value = [];
|
|
|
|
|
fieldSelectedBranch.value.value = 'branchHQLabel';
|
|
|
|
|
currentHq.value = {
|
|
|
|
|
id: '',
|
|
|
|
|
code: '',
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-06-26 17:03:49 +07:00
|
|
|
flowStore.rotate();
|
2024-04-18 15:10:54 +07:00
|
|
|
},
|
|
|
|
|
cancel: () => {},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-11 13:44:57 +07:00
|
|
|
function triggerEditQrCodeLine(opts?: { save?: boolean }) {
|
|
|
|
|
if (opts?.save === undefined) {
|
|
|
|
|
qrCodeDialog.value = true;
|
|
|
|
|
statusDeletsQrCode.value = false;
|
|
|
|
|
deletsStatusQrCodeImag.value = false;
|
|
|
|
|
statusQrCodeUrl.value = qrCodeimageUrl.value;
|
|
|
|
|
} else {
|
|
|
|
|
qrCodeimageUrl.value = statusQrCodeUrl.value;
|
|
|
|
|
qrCodeFile.value = statusQrCodeFile.value;
|
|
|
|
|
deletsStatusQrCodeImag.value = statusDeletsQrCode.value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function triggerEditQrCodeBank(opts?: { save?: boolean }) {
|
|
|
|
|
if (opts?.save === undefined) {
|
|
|
|
|
qrCodeDialog.value = true;
|
|
|
|
|
statusDeletsQrCode.value = false;
|
|
|
|
|
statusQrCodeUrl.value =
|
|
|
|
|
formBankBook.value[currentIndexQrCodeBank.value].bankUrl || '';
|
|
|
|
|
statusDeletsQrCode.value = false;
|
|
|
|
|
} else {
|
|
|
|
|
formBankBook.value[currentIndexQrCodeBank.value].bankUrl =
|
|
|
|
|
statusQrCodeUrl.value;
|
|
|
|
|
|
|
|
|
|
formBankBook.value[currentIndexQrCodeBank.value].bankQr =
|
|
|
|
|
statusQrCodeFile.value;
|
|
|
|
|
|
|
|
|
|
if (statusDeletsQrCode.value) {
|
|
|
|
|
deletsStatusQrCodeBankImag.value.push(currentIndexQrCodeBank.value);
|
|
|
|
|
}
|
|
|
|
|
currentIndexQrCodeBank.value = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-11 15:41:35 +07:00
|
|
|
async function fetchList(opts: {
|
|
|
|
|
page?: number;
|
|
|
|
|
pageSize?: number;
|
|
|
|
|
zipCode?: string;
|
|
|
|
|
query?: string;
|
|
|
|
|
tree?: boolean;
|
|
|
|
|
filter?: 'head' | 'sub';
|
|
|
|
|
}) {
|
|
|
|
|
await branchStore.fetchList(opts);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(inputSearch, () => {
|
|
|
|
|
fetchList({ tree: true, query: inputSearch.value });
|
|
|
|
|
currentSubBranch.value = undefined;
|
|
|
|
|
});
|
|
|
|
|
|
2024-07-23 11:04:44 +00:00
|
|
|
async function triggerChangeStatus(
|
|
|
|
|
id: string,
|
|
|
|
|
status: string,
|
2024-09-05 09:56:22 +07:00
|
|
|
): Promise<Branch> {
|
2024-07-23 11:04:44 +00:00
|
|
|
return await new Promise((resolve) => {
|
|
|
|
|
dialog({
|
2024-07-25 10:49:43 +00:00
|
|
|
color: status !== 'INACTIVE' ? 'warning' : 'info',
|
2024-08-09 06:17:57 +00:00
|
|
|
icon:
|
|
|
|
|
status !== 'INACTIVE' ? 'mdi-alert' : 'mdi-message-processing-outline',
|
2024-08-26 16:24:08 +07:00
|
|
|
title: t('dialog.title.confirmChangeStatus'),
|
2024-07-23 11:04:44 +00:00
|
|
|
actionText:
|
2024-08-26 16:24:08 +07:00
|
|
|
status !== 'INACTIVE' ? t('general.close') : t('general.open'),
|
2024-07-23 11:04:44 +00:00
|
|
|
message:
|
|
|
|
|
status !== 'INACTIVE'
|
2024-08-26 16:24:08 +07:00
|
|
|
? t('dialog.message.confirmChangeStatusOff')
|
|
|
|
|
: t('dialog.message.confirmChangeStatusOn'),
|
2024-07-23 11:04:44 +00:00
|
|
|
action: async () => {
|
|
|
|
|
const res = await branchStore.editById(id, {
|
|
|
|
|
status: status !== 'INACTIVE' ? 'INACTIVE' : 'ACTIVE',
|
|
|
|
|
});
|
|
|
|
|
if (res) resolve(res);
|
|
|
|
|
},
|
|
|
|
|
cancel: () => {},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-11 16:43:41 +07:00
|
|
|
async function onSubmit(submitSelectedItem?: boolean) {
|
|
|
|
|
if (formType.value === 'edit' || submitSelectedItem) {
|
2024-06-28 12:01:04 +07:00
|
|
|
delete formData.value['codeHeadOffice'];
|
2024-08-07 10:08:45 +00:00
|
|
|
delete formData.value['code'];
|
2024-06-28 12:01:04 +07:00
|
|
|
|
2024-09-11 16:43:41 +07:00
|
|
|
const res = await branchStore.editById(
|
2024-04-22 10:52:26 +07:00
|
|
|
currentEdit.value.id,
|
|
|
|
|
{
|
|
|
|
|
...formData.value,
|
|
|
|
|
status: undefined,
|
|
|
|
|
},
|
2024-09-11 13:44:57 +07:00
|
|
|
qrCodeFile.value,
|
2024-08-02 11:13:21 +00:00
|
|
|
formBankBook.value,
|
2024-09-11 13:44:57 +07:00
|
|
|
{
|
|
|
|
|
deleteQrCodeImage: deletsStatusQrCodeImag.value,
|
|
|
|
|
indexDeleteQrCodeBank: deletsStatusQrCodeBankImag.value,
|
|
|
|
|
},
|
2024-04-22 10:52:26 +07:00
|
|
|
);
|
|
|
|
|
|
2024-09-12 09:58:04 +07:00
|
|
|
if (!res) return;
|
2024-09-11 16:43:41 +07:00
|
|
|
formData.value.codeHeadOffice = formData.value.code = res.code;
|
|
|
|
|
imageUrl.value = `${baseUrl}/branch/${res.id}/image/${res.selectedImage}`;
|
|
|
|
|
|
2024-09-12 10:01:49 +07:00
|
|
|
await fetchList({ tree: true, pageSize: 99999 });
|
2024-09-11 16:43:41 +07:00
|
|
|
|
|
|
|
|
if (!imageDialog.value) modalDrawer.value = submitSelectedItem || false;
|
2024-04-18 15:10:54 +07:00
|
|
|
}
|
|
|
|
|
|
2024-04-22 10:52:26 +07:00
|
|
|
if (formType.value === 'create') {
|
2024-08-14 13:10:47 +07:00
|
|
|
const createBranch = async () => {
|
2024-09-16 10:27:08 +07:00
|
|
|
const res = await branchStore.create(
|
2024-08-14 13:10:47 +07:00
|
|
|
{
|
|
|
|
|
...formData.value,
|
2024-09-11 13:44:57 +07:00
|
|
|
qrCodeImage: qrCodeFile.value,
|
2024-08-14 13:10:47 +07:00
|
|
|
},
|
|
|
|
|
formBankBook.value,
|
2024-09-11 16:43:41 +07:00
|
|
|
onCreateImageList.value,
|
2024-08-14 13:10:47 +07:00
|
|
|
);
|
|
|
|
|
|
2024-09-16 10:27:08 +07:00
|
|
|
if (res) {
|
|
|
|
|
currentId.value = res.id;
|
|
|
|
|
formData.value.codeHeadOffice = res.code;
|
|
|
|
|
formData.value.code = res.code;
|
|
|
|
|
prevFormData.value = JSON.parse(JSON.stringify(formData.value));
|
|
|
|
|
|
|
|
|
|
currentEdit.value = {
|
|
|
|
|
id: res.id,
|
|
|
|
|
code: res.code,
|
|
|
|
|
};
|
|
|
|
|
formType.value = 'view';
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-12 10:01:49 +07:00
|
|
|
await fetchList({ tree: true, pageSize: 99999 });
|
2024-08-14 13:10:47 +07:00
|
|
|
};
|
2024-04-18 15:10:54 +07:00
|
|
|
|
2024-08-14 13:10:47 +07:00
|
|
|
if (formTypeBranch.value === 'subBranch') {
|
|
|
|
|
const currentRecord = branchData.value.result.find(
|
|
|
|
|
(x) => x.id === formData.value.headOfficeId,
|
|
|
|
|
);
|
2024-04-18 14:13:57 +07:00
|
|
|
|
2024-08-14 13:10:47 +07:00
|
|
|
formData.value.headOfficeId = currentRecord?.id;
|
2024-08-28 15:51:50 +07:00
|
|
|
formData.value.code = formData.value.code?.slice(0, -5);
|
2024-08-14 13:10:47 +07:00
|
|
|
delete formData.value['codeHeadOffice'];
|
|
|
|
|
await createBranch();
|
2024-08-29 14:46:45 +07:00
|
|
|
|
|
|
|
|
fieldSelectedBranch.value.value = '';
|
|
|
|
|
inputSearch.value = '';
|
|
|
|
|
currentHq.value = {
|
2024-09-03 18:15:45 +07:00
|
|
|
id: currentRecord?.id || '',
|
|
|
|
|
code: currentRecord?.code || '',
|
2024-08-29 14:46:45 +07:00
|
|
|
};
|
|
|
|
|
beforeBranch.value = {
|
|
|
|
|
id: '',
|
|
|
|
|
code: '',
|
|
|
|
|
};
|
|
|
|
|
expandedTree.value = [];
|
2024-09-03 18:15:45 +07:00
|
|
|
expandedTree.value.push(currentRecord?.id || '');
|
2024-08-14 13:10:47 +07:00
|
|
|
} else {
|
|
|
|
|
dialog({
|
|
|
|
|
color: 'info',
|
|
|
|
|
icon: 'mdi-message-processing-outline',
|
|
|
|
|
message: t('form.info.cantChange', {
|
2024-08-28 15:51:50 +07:00
|
|
|
field: t('branch.form.abbrev'),
|
2024-08-14 13:10:47 +07:00
|
|
|
name: formData.value.code,
|
|
|
|
|
}),
|
2024-08-28 16:33:51 +07:00
|
|
|
actionText: t('dialog.action.ok'),
|
2024-08-14 13:10:47 +07:00
|
|
|
persistent: true,
|
|
|
|
|
title: t('form.warning.title'),
|
|
|
|
|
cancel: () => {},
|
|
|
|
|
action: async () => {
|
|
|
|
|
await createBranch();
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
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 = [
|
|
|
|
|
{
|
2024-07-03 14:13:22 +07:00
|
|
|
icon: 'mdi-home',
|
2024-04-23 14:43:00 +07:00
|
|
|
count: _stats.hq,
|
2024-08-29 12:18:05 +07:00
|
|
|
label: 'branch.card.branchHQLabel',
|
2024-04-23 14:43:00 +07:00
|
|
|
color: 'pink',
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-07-03 14:13:22 +07:00
|
|
|
icon: 'mdi-domain',
|
2024-04-23 14:43:00 +07:00
|
|
|
count: _stats.br,
|
2024-08-29 12:18:05 +07:00
|
|
|
label: 'branch.card.branchLabel',
|
2024-04-23 14:43:00 +07:00
|
|
|
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',
|
|
|
|
|
) {
|
2024-08-26 16:24:08 +07:00
|
|
|
const _type =
|
|
|
|
|
typeBranch === 'headOffice'
|
|
|
|
|
? 'branch.card.branchHQLabel'
|
2024-08-26 17:18:15 +07:00
|
|
|
: 'branch.card.branchLabel';
|
2024-08-26 16:24:08 +07:00
|
|
|
|
|
|
|
|
return formType === 'create'
|
|
|
|
|
? t('form.title.create', { name: t(_type) })
|
|
|
|
|
: formType === 'view'
|
|
|
|
|
? t(_type)
|
|
|
|
|
: t('general.edit');
|
2024-04-18 13:56:00 +07:00
|
|
|
}
|
2024-04-18 15:21:32 +07:00
|
|
|
|
2024-07-19 04:56:08 +00:00
|
|
|
function handleHold(node: BranchWithChildren) {
|
2024-07-19 04:16:07 +00:00
|
|
|
if ($q.screen.gt.xs) return;
|
2024-08-26 17:18:15 +07:00
|
|
|
holdDialog.value = true;
|
|
|
|
|
currentNode.value = node;
|
|
|
|
|
// return function () {
|
|
|
|
|
// };
|
2024-07-19 04:16:07 +00:00
|
|
|
}
|
|
|
|
|
|
2024-09-11 16:43:41 +07:00
|
|
|
async function fetchImageList(id: string, selectedName: string) {
|
|
|
|
|
const res = await branchStore.fetchImageListById(id);
|
|
|
|
|
imageList.value = {
|
|
|
|
|
selectedImage: selectedName,
|
|
|
|
|
list: res.map((n: string) => `branch/${id}/image/${n}`),
|
|
|
|
|
};
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-02 03:52:56 +00:00
|
|
|
watch(
|
2024-08-28 16:33:51 +07:00
|
|
|
() => profileFile.value,
|
2024-08-02 03:52:56 +00:00
|
|
|
() => {
|
2024-08-28 16:33:51 +07:00
|
|
|
if (profileFile.value !== null) isImageEdit.value = true;
|
2024-08-02 03:52:56 +00:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
2024-09-11 13:44:57 +07:00
|
|
|
watch(
|
|
|
|
|
() => qrCodeFile.value,
|
|
|
|
|
() => {
|
2024-09-11 16:52:51 +07:00
|
|
|
if (qrCodeFile.value !== null) isQrCodeEdit.value = true;
|
2024-09-11 13:44:57 +07:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
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-07-18 09:10:51 +00:00
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => $q.screen.lt.md,
|
|
|
|
|
(v) => {
|
|
|
|
|
if (v) modeView.value = true;
|
|
|
|
|
},
|
|
|
|
|
);
|
2024-07-24 14:44:57 +07:00
|
|
|
|
|
|
|
|
watch(currentHq, () => {
|
|
|
|
|
const tmp: typeof utilsStore.currentTitle.path = [
|
|
|
|
|
{
|
2024-08-26 16:24:08 +07:00
|
|
|
text: 'branch.page.captionManage',
|
2024-08-07 11:46:46 +07:00
|
|
|
i18n: true,
|
2024-07-24 14:44:57 +07:00
|
|
|
handler: () => {
|
2024-08-09 10:54:03 +07:00
|
|
|
expandedTree.value = expandedTree.value.filter(
|
|
|
|
|
(i) => currentHq.value.id !== i,
|
|
|
|
|
);
|
|
|
|
|
|
2024-07-24 14:44:57 +07:00
|
|
|
fieldSelectedBranch.value.value = 'branchHQLabel';
|
|
|
|
|
currentHq.value = {
|
|
|
|
|
id: '',
|
|
|
|
|
code: '',
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (currentHq.value.id !== '') {
|
|
|
|
|
tmp.push({
|
|
|
|
|
text: currentHq.value.code,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-11 15:41:35 +07:00
|
|
|
selectedSubBranche(currentHq.value.id);
|
|
|
|
|
|
2024-07-24 14:44:57 +07:00
|
|
|
utilsStore.currentTitle.path = tmp;
|
|
|
|
|
});
|
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>
|
2024-07-02 09:22:06 +00:00
|
|
|
<div class="column full-height no-wrap">
|
2024-07-05 03:39:41 +00:00
|
|
|
<div class="text-body-2 q-mb-xs flex items-center">
|
2024-08-26 16:24:08 +07:00
|
|
|
{{ $t('general.dataSum') }}
|
2024-07-05 03:39:41 +00:00
|
|
|
<q-btn
|
|
|
|
|
class="q-ml-xs"
|
2024-08-08 06:41:15 +00:00
|
|
|
icon="mdi-pin-outline"
|
2024-07-05 03:39:41 +00:00
|
|
|
color="primary"
|
|
|
|
|
size="sm"
|
|
|
|
|
flat
|
|
|
|
|
dense
|
|
|
|
|
rounded
|
|
|
|
|
@click="hideStat = !hideStat"
|
|
|
|
|
:style="hideStat ? 'rotate: 90deg' : ''"
|
|
|
|
|
style="transition: 0.1s ease-in-out"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<transition name="slide">
|
|
|
|
|
<StatCard
|
|
|
|
|
v-if="!hideStat"
|
|
|
|
|
class="q-pb-md"
|
|
|
|
|
label-i18n
|
2024-09-06 17:25:06 +07:00
|
|
|
:branch="stats"
|
2024-07-05 03:39:41 +00:00
|
|
|
:dark="$q.dark.isActive"
|
|
|
|
|
/>
|
|
|
|
|
</transition>
|
2024-04-03 15:23:59 +07:00
|
|
|
|
2024-07-16 02:52:38 +00:00
|
|
|
<div class="col surface-2 rounded" :no-padding="!!branchData.total">
|
2024-04-16 18:33:41 +07:00
|
|
|
<template v-if="!branchData.total">
|
2024-07-17 02:17:10 +00:00
|
|
|
<div class="full-width full-height column">
|
|
|
|
|
<div class="self-end q-ma-md">
|
|
|
|
|
<TooltipComponent
|
|
|
|
|
class="self-end"
|
2024-08-26 16:24:08 +07:00
|
|
|
title="general.noData"
|
|
|
|
|
caption="general.clickToCreate"
|
2024-07-17 02:17:10 +00:00
|
|
|
imgSrc="personnel-table-"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col flex items-center justify-center">
|
2024-08-19 10:17:44 +07:00
|
|
|
<EmptyAddButton
|
2024-08-26 16:24:08 +07:00
|
|
|
label="general.add"
|
2024-09-16 10:45:31 +07:00
|
|
|
:i18nArgs="{ text: $t('branch.form.title.branchHQLabel') }"
|
2024-09-03 18:15:45 +07:00
|
|
|
@trigger="
|
|
|
|
|
() => {
|
|
|
|
|
triggerCreate('headOffice');
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-07-17 02:17:10 +00:00
|
|
|
/>
|
|
|
|
|
</div>
|
2024-04-16 18:33:41 +07:00
|
|
|
</div>
|
|
|
|
|
</template>
|
2024-07-16 02:52:38 +00:00
|
|
|
|
2024-04-16 18:33:41 +07:00
|
|
|
<template v-else>
|
2024-07-16 02:52:38 +00:00
|
|
|
<div class="full-height column" style="flex-grow: 1; flex-wrap: nowrap">
|
2024-07-04 17:56:37 +07:00
|
|
|
<q-splitter
|
|
|
|
|
v-model="splitterModel"
|
2024-07-08 14:26:30 +07:00
|
|
|
:limits="[0, 100]"
|
2024-07-16 02:52:38 +00:00
|
|
|
class="col"
|
2024-07-18 04:51:09 +00:00
|
|
|
before-class="overflow-hidden"
|
2024-07-16 10:29:47 +00:00
|
|
|
after-class="overflow-hidden"
|
2024-07-04 17:56:37 +07:00
|
|
|
>
|
|
|
|
|
<template v-slot:before>
|
2024-07-16 02:52:38 +00:00
|
|
|
<div class="surface-1 column full-height">
|
2024-07-04 17:56:37 +07:00
|
|
|
<div
|
2024-07-19 04:16:07 +00:00
|
|
|
class="row no-wrap full-width bordered-b text-weight-bold surface-3 items-center q-px-md q-py-sm"
|
2024-07-16 02:52:38 +00:00
|
|
|
:style="`min-height: ${$q.screen.gt.sm ? '57px' : '100.8px'}`"
|
2024-07-04 17:56:37 +07:00
|
|
|
>
|
2024-09-11 10:26:07 +07:00
|
|
|
<div class="col ellipsis-2-lines">
|
|
|
|
|
{{ $t('branch.allBranch') }}
|
|
|
|
|
</div>
|
2024-07-05 09:23:45 +07:00
|
|
|
<q-btn
|
|
|
|
|
round
|
|
|
|
|
flat
|
|
|
|
|
size="md"
|
|
|
|
|
dense
|
|
|
|
|
id="hq-add-btn"
|
|
|
|
|
class="q-mr-sm"
|
2024-07-05 09:39:10 +07:00
|
|
|
@click="
|
|
|
|
|
() => {
|
2024-09-09 09:41:08 +07:00
|
|
|
triggerCreate('headOffice');
|
2024-07-05 09:39:10 +07:00
|
|
|
}
|
|
|
|
|
"
|
2024-07-05 09:23:45 +07:00
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
icon="pixelarticons:plus"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
style="color: var(--foreground); scale: 1.5"
|
|
|
|
|
/>
|
|
|
|
|
</q-btn>
|
2024-07-04 17:56:37 +07:00
|
|
|
</div>
|
|
|
|
|
|
2024-07-23 11:04:44 +00:00
|
|
|
<div class="col full-width scroll">
|
2024-07-19 04:16:07 +00:00
|
|
|
<div class="q-pa-md">
|
2024-08-09 15:03:03 +07:00
|
|
|
<TreeComponent
|
2024-07-30 14:54:34 +07:00
|
|
|
v-model:nodes="treeData"
|
|
|
|
|
v-model:expanded-tree="expandedTree"
|
2024-07-05 13:10:37 +07:00
|
|
|
node-key="id"
|
|
|
|
|
label-key="name"
|
|
|
|
|
children-key="branch"
|
2024-07-30 14:54:34 +07:00
|
|
|
type-tree="branch"
|
|
|
|
|
@handle-hold="(v) => handleHold(v)"
|
|
|
|
|
@select="
|
|
|
|
|
(v) => {
|
|
|
|
|
if (
|
|
|
|
|
v.isHeadOffice &&
|
|
|
|
|
v._count.branch !== 0 &&
|
|
|
|
|
currentHq.id === v.id
|
|
|
|
|
) {
|
|
|
|
|
expandedTree = expandedTree.filter(
|
|
|
|
|
(i) => v.id !== i,
|
|
|
|
|
);
|
|
|
|
|
fieldSelectedBranch.value = 'branchHQLabel';
|
|
|
|
|
|
|
|
|
|
currentHq = {
|
|
|
|
|
id: '',
|
|
|
|
|
code: '',
|
|
|
|
|
};
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-07-18 11:01:19 +00:00
|
|
|
|
2024-07-30 14:54:34 +07:00
|
|
|
if (
|
|
|
|
|
v.isHeadOffice &&
|
|
|
|
|
v._count.branch !== 0 &&
|
|
|
|
|
currentHq.id !== v.id
|
|
|
|
|
) {
|
|
|
|
|
expandedTree = [];
|
|
|
|
|
expandedTree.push(v.id);
|
|
|
|
|
fieldSelectedBranch.value = '';
|
|
|
|
|
inputSearch = '';
|
|
|
|
|
currentHq = {
|
|
|
|
|
id: v.id,
|
|
|
|
|
code: v.code,
|
|
|
|
|
};
|
|
|
|
|
beforeBranch = {
|
|
|
|
|
id: '',
|
|
|
|
|
code: '',
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-09-03 18:15:45 +07:00
|
|
|
@create="
|
|
|
|
|
(v) => {
|
2024-09-04 10:23:07 +07:00
|
|
|
currentEdit.id = v.id;
|
|
|
|
|
currentEdit.code = v.code;
|
2024-09-03 18:15:45 +07:00
|
|
|
|
|
|
|
|
modelCreateTypeBranch = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// triggerCreate(v.virtual, 'subBranch', v.id, v.code)
|
|
|
|
|
"
|
2024-07-30 14:54:34 +07:00
|
|
|
@view="
|
|
|
|
|
(v) => {
|
|
|
|
|
if (v.isHeadOffice) {
|
|
|
|
|
triggerEdit('drawer', v.id, 'headOffice', v.code);
|
|
|
|
|
} else {
|
|
|
|
|
triggerEdit('drawer', v.id, 'subBranch');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@edit="
|
|
|
|
|
(v) => {
|
|
|
|
|
if (v.isHeadOffice) {
|
2024-08-14 13:10:47 +07:00
|
|
|
triggerEdit('drawer', v.id, 'headOffice', v.code);
|
2024-07-30 14:54:34 +07:00
|
|
|
} else {
|
2024-08-14 13:10:47 +07:00
|
|
|
triggerEdit('drawer', v.id, 'subBranch');
|
2024-07-30 14:54:34 +07:00
|
|
|
}
|
2024-08-14 13:10:47 +07:00
|
|
|
formType = 'edit';
|
2024-07-30 14:54:34 +07:00
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@delete="
|
|
|
|
|
(v) => {
|
|
|
|
|
triggerDelete(v.id);
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@change-status="
|
|
|
|
|
async (v) => {
|
|
|
|
|
const res = await triggerChangeStatus(v.id, v.status);
|
|
|
|
|
if (res) v.status = res.status;
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
2024-07-05 13:10:37 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-07-04 17:56:37 +07:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template v-slot:after>
|
2024-07-16 10:29:47 +00:00
|
|
|
<div class="column full-height no-wrap">
|
2024-07-04 17:56:37 +07:00
|
|
|
<div
|
2024-07-16 02:52:38 +00:00
|
|
|
class="row q-py-sm q-px-md justify-between full-width surface-3 bordered-b"
|
2024-07-04 17:56:37 +07:00
|
|
|
>
|
2024-07-16 02:52:38 +00:00
|
|
|
<q-input
|
|
|
|
|
for="input-search"
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
2024-08-26 16:24:08 +07:00
|
|
|
:label="$t('general.search')"
|
2024-07-16 02:52:38 +00:00
|
|
|
class="q-mr-md col-12 col-md-4"
|
|
|
|
|
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
|
|
|
|
v-model="inputSearch"
|
|
|
|
|
debounce="200"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:prepend>
|
|
|
|
|
<q-icon name="mdi-magnify" />
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
2024-07-04 17:56:37 +07:00
|
|
|
|
2024-07-16 02:52:38 +00:00
|
|
|
<div
|
|
|
|
|
class="row col-12 col-md-6"
|
|
|
|
|
:class="{ 'q-pt-xs': $q.screen.lt.md }"
|
|
|
|
|
>
|
|
|
|
|
<q-select
|
|
|
|
|
v-model="statusFilter"
|
|
|
|
|
outlined
|
2024-07-04 17:56:37 +07:00
|
|
|
dense
|
2024-07-16 02:52:38 +00:00
|
|
|
option-value="value"
|
2024-07-18 04:51:09 +00:00
|
|
|
:hide-dropdown-icon="$q.screen.lt.sm"
|
2024-07-16 02:52:38 +00:00
|
|
|
option-label="label"
|
|
|
|
|
class="col"
|
|
|
|
|
map-options
|
2024-07-30 16:18:37 +07:00
|
|
|
:for="'field-select-status'"
|
2024-07-16 02:52:38 +00:00
|
|
|
emit-value
|
|
|
|
|
:options="[
|
2024-08-26 16:24:08 +07:00
|
|
|
{ label: $t('general.all'), value: 'all' },
|
|
|
|
|
{ label: $t('status.ACTIVE'), value: 'statusACTIVE' },
|
2024-07-16 02:52:38 +00:00
|
|
|
{
|
2024-08-26 16:24:08 +07:00
|
|
|
label: $t('status.INACTIVE'),
|
2024-07-16 02:52:38 +00:00
|
|
|
value: 'statusINACTIVE',
|
|
|
|
|
},
|
|
|
|
|
]"
|
|
|
|
|
></q-select>
|
2024-07-04 17:56:37 +07:00
|
|
|
|
2024-07-05 13:08:07 +07:00
|
|
|
<q-select
|
|
|
|
|
id="select-field"
|
|
|
|
|
for="select-field"
|
|
|
|
|
:options="
|
2024-08-26 16:24:08 +07:00
|
|
|
fieldDisplay.map((v) => ({
|
|
|
|
|
label: $t(`branch.card.${v}`),
|
|
|
|
|
value: v,
|
|
|
|
|
}))
|
2024-07-05 13:08:07 +07:00
|
|
|
"
|
2024-08-26 16:24:08 +07:00
|
|
|
:display-value="$t('general.displayField')"
|
2024-07-18 04:51:09 +00:00
|
|
|
:hide-dropdown-icon="$q.screen.lt.sm"
|
2024-07-16 02:52:38 +00:00
|
|
|
class="col q-mx-sm"
|
2024-07-05 13:08:07 +07:00
|
|
|
v-model="fieldSelected"
|
|
|
|
|
option-label="label"
|
|
|
|
|
option-value="value"
|
|
|
|
|
map-options
|
|
|
|
|
emit-value
|
|
|
|
|
outlined
|
|
|
|
|
multiple
|
|
|
|
|
dense
|
|
|
|
|
/>
|
|
|
|
|
|
2024-07-04 17:56:37 +07:00
|
|
|
<q-btn-toggle
|
|
|
|
|
id="btn-mode"
|
2024-07-16 02:52:38 +00:00
|
|
|
v-model="modeView"
|
2024-07-04 17:56:37 +07:00
|
|
|
dense
|
2024-07-05 11:43:07 +07:00
|
|
|
class="no-shadow bordered rounded surface-1"
|
|
|
|
|
:toggle-color="$q.dark.isActive ? 'grey-9' : 'grey-2'"
|
2024-07-04 17:56:37 +07:00
|
|
|
size="xs"
|
|
|
|
|
:options="[
|
|
|
|
|
{ value: true, slot: 'folder' },
|
|
|
|
|
{ value: false, slot: 'list' },
|
|
|
|
|
]"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:folder>
|
|
|
|
|
<q-icon
|
|
|
|
|
name="mdi-view-grid-outline"
|
|
|
|
|
size="16px"
|
|
|
|
|
class="q-px-sm q-py-xs rounded"
|
|
|
|
|
:style="{
|
2024-07-05 09:53:17 +07:00
|
|
|
color: $q.dark.isActive
|
|
|
|
|
? modeView
|
|
|
|
|
? '#C9D3DB '
|
|
|
|
|
: '#787B7C'
|
|
|
|
|
: modeView
|
|
|
|
|
? '#787B7C'
|
|
|
|
|
: '#C9D3DB',
|
2024-07-04 17:56:37 +07:00
|
|
|
}"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:list>
|
|
|
|
|
<q-icon
|
|
|
|
|
name="mdi-format-list-bulleted"
|
|
|
|
|
class="q-px-sm q-py-xs rounded"
|
|
|
|
|
size="16px"
|
|
|
|
|
:style="{
|
2024-07-05 09:53:17 +07:00
|
|
|
color: $q.dark.isActive
|
|
|
|
|
? modeView === false
|
|
|
|
|
? '#C9D3DB'
|
|
|
|
|
: '#787B7C'
|
|
|
|
|
: modeView === false
|
|
|
|
|
? '#787B7C'
|
|
|
|
|
: '#C9D3DB',
|
2024-07-04 17:56:37 +07:00
|
|
|
}"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</q-btn-toggle>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-07-05 12:09:45 +07:00
|
|
|
|
2024-07-16 10:29:47 +00:00
|
|
|
<div class="surface-2 q-pa-md scroll full-width">
|
2024-07-16 02:52:38 +00:00
|
|
|
<q-table
|
|
|
|
|
flat
|
|
|
|
|
bordered
|
2024-07-16 10:29:47 +00:00
|
|
|
class="full-width"
|
2024-07-16 02:52:38 +00:00
|
|
|
:rows-per-page-options="[0]"
|
2024-09-11 16:15:40 +07:00
|
|
|
:rows="
|
|
|
|
|
(
|
|
|
|
|
currentSubBranch ||
|
|
|
|
|
(inputSearch !== ''
|
|
|
|
|
? treeData.flatMap((v) => [v, ...v.branch])
|
|
|
|
|
: treeData)
|
|
|
|
|
).filter((v) => {
|
|
|
|
|
if (
|
|
|
|
|
statusFilter === 'statusACTIVE' &&
|
|
|
|
|
v.status === 'INACTIVE'
|
|
|
|
|
) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
statusFilter === 'statusINACTIVE' &&
|
|
|
|
|
v.status !== 'INACTIVE'
|
|
|
|
|
) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
})
|
|
|
|
|
"
|
2024-07-16 02:52:38 +00:00
|
|
|
:columns="columns"
|
|
|
|
|
:grid="modeView"
|
|
|
|
|
card-container-class="row q-col-gutter-md"
|
|
|
|
|
row-key="name"
|
|
|
|
|
hide-pagination
|
|
|
|
|
:visible-columns="fieldSelected"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:header="props">
|
2024-07-31 06:18:52 +00:00
|
|
|
<q-tr
|
|
|
|
|
style="background-color: hsla(var(--info-bg) / 0.07)"
|
|
|
|
|
:props="props"
|
|
|
|
|
>
|
2024-07-16 02:52:38 +00:00
|
|
|
<q-th
|
|
|
|
|
v-for="col in props.cols"
|
|
|
|
|
:key="col.name"
|
|
|
|
|
:props="props"
|
2024-08-07 11:30:01 +07:00
|
|
|
:class="{
|
|
|
|
|
'q-pl-sm': col.label === 'orderNumber',
|
|
|
|
|
}"
|
2024-07-16 02:52:38 +00:00
|
|
|
>
|
|
|
|
|
{{ $t(col.label) }}
|
|
|
|
|
</q-th>
|
|
|
|
|
<q-th auto-width />
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template v-slot:body="props">
|
|
|
|
|
<q-tr
|
|
|
|
|
:class="{
|
|
|
|
|
'app-text-muted': props.row.status === 'INACTIVE',
|
2024-09-11 15:41:35 +07:00
|
|
|
'cursor-pointer': props.row._count?.branch !== 0,
|
2024-07-16 02:52:38 +00:00
|
|
|
}"
|
2024-08-09 10:55:19 +00:00
|
|
|
:style="
|
|
|
|
|
props.rowIndex % 2 !== 0
|
|
|
|
|
? $q.dark.isActive
|
|
|
|
|
? 'background: hsl(var(--gray-11-hsl)/0.2)'
|
|
|
|
|
: `background: #f9fafc`
|
|
|
|
|
: ''
|
|
|
|
|
"
|
2024-07-16 02:52:38 +00:00
|
|
|
:props="props"
|
|
|
|
|
@click="
|
|
|
|
|
() => {
|
2024-07-05 12:09:45 +07:00
|
|
|
if (
|
2024-07-16 02:52:38 +00:00
|
|
|
props.row.isHeadOffice &&
|
2024-09-18 14:29:32 +07:00
|
|
|
props.row._count?.branch !== 0
|
2024-07-05 12:09:45 +07:00
|
|
|
) {
|
2024-07-16 02:52:38 +00:00
|
|
|
fieldSelectedBranch.value = '';
|
|
|
|
|
inputSearch = '';
|
|
|
|
|
currentHq = {
|
|
|
|
|
id: props.row.id,
|
|
|
|
|
code: props.row.code,
|
|
|
|
|
};
|
|
|
|
|
beforeBranch = {
|
|
|
|
|
id: '',
|
|
|
|
|
code: '',
|
|
|
|
|
};
|
2024-07-19 04:16:07 +00:00
|
|
|
expandedTree = [];
|
|
|
|
|
expandedTree.push(props.row.id);
|
2024-07-05 12:09:45 +07:00
|
|
|
}
|
2024-07-16 02:52:38 +00:00
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
>
|
2024-08-07 11:30:01 +07:00
|
|
|
<q-td
|
|
|
|
|
class="text-center"
|
2024-08-09 10:47:35 +07:00
|
|
|
v-if="fieldSelected.includes('orderNumber')"
|
2024-08-07 11:30:01 +07:00
|
|
|
>
|
2024-08-05 13:39:29 +07:00
|
|
|
{{ props.rowIndex + 1 }}
|
|
|
|
|
</q-td>
|
|
|
|
|
|
2024-09-09 15:47:09 +07:00
|
|
|
<q-td v-if="fieldSelected.includes('office')">
|
2024-08-19 17:52:02 +07:00
|
|
|
<div class="row items-center no-wrap">
|
2024-07-16 02:52:38 +00:00
|
|
|
<div
|
|
|
|
|
:class="{
|
2024-08-07 10:08:45 +00:00
|
|
|
'q-mr-sm': true,
|
2024-07-16 02:52:38 +00:00
|
|
|
'status-active':
|
|
|
|
|
props.row.status !== 'INACTIVE',
|
|
|
|
|
'status-inactive':
|
|
|
|
|
props.row.status === 'INACTIVE',
|
|
|
|
|
'branch-card__hq': props.row.isHeadOffice,
|
2024-09-06 17:25:06 +07:00
|
|
|
'branch-card__br':
|
|
|
|
|
!props.row.isHeadOffice && !props.row.virtual,
|
|
|
|
|
'branch-card__br-virtual':
|
|
|
|
|
!props.row.isHeadOffice && props.row.virtual,
|
2024-07-16 02:52:38 +00:00
|
|
|
}"
|
2024-09-03 13:23:52 +07:00
|
|
|
style="display: flex"
|
2024-07-16 02:52:38 +00:00
|
|
|
>
|
2024-09-06 17:25:06 +07:00
|
|
|
<div
|
|
|
|
|
:style="`
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
border-style: solid;
|
|
|
|
|
border-width: 2px;
|
|
|
|
|
border-color: hsl(var(${props.row.isHeadOffice ? '--pink-6-hsl' : props.row.virtual ? '--blue-6-hsl' : '--violet-11-hsl'}));
|
|
|
|
|
`"
|
|
|
|
|
class="q-pa-xs"
|
|
|
|
|
>
|
|
|
|
|
<q-avatar size="md">
|
|
|
|
|
<q-img
|
|
|
|
|
class="text-center"
|
|
|
|
|
:ratio="1"
|
|
|
|
|
:src="
|
|
|
|
|
baseUrl +
|
2024-09-11 16:43:41 +07:00
|
|
|
`/branch/${props.row.id}/image/${props.row.selectedImage}`.concat(
|
|
|
|
|
refreshImageState
|
|
|
|
|
? `?ts=${Date.now()}`
|
|
|
|
|
: '',
|
|
|
|
|
)
|
2024-09-06 17:25:06 +07:00
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
<template #error>
|
|
|
|
|
<div
|
|
|
|
|
class="branch-card__icon no-padding full-width full-height items-center justify-center"
|
|
|
|
|
>
|
|
|
|
|
<q-icon
|
|
|
|
|
size="sm"
|
|
|
|
|
name="mdi-office-building-outline"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</q-img>
|
|
|
|
|
|
|
|
|
|
<q-badge
|
|
|
|
|
class="absolute-bottom-right no-padding"
|
|
|
|
|
style="
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
min-width: 8px;
|
|
|
|
|
min-height: 8px;
|
|
|
|
|
"
|
|
|
|
|
:style="{
|
|
|
|
|
background: `var(--${props.row.status === 'INACTIVE' ? 'stone-5' : 'green-6'})`,
|
|
|
|
|
}"
|
|
|
|
|
></q-badge>
|
|
|
|
|
</q-avatar>
|
|
|
|
|
</div>
|
2024-07-16 02:52:38 +00:00
|
|
|
</div>
|
|
|
|
|
<div class="col">
|
2024-09-11 10:28:24 +07:00
|
|
|
<div class="col">
|
|
|
|
|
{{
|
|
|
|
|
$i18n.locale === 'eng'
|
|
|
|
|
? props.row.nameEN
|
|
|
|
|
: props.row.name
|
|
|
|
|
}}
|
|
|
|
|
</div>
|
2024-07-16 02:52:38 +00:00
|
|
|
<div class="col app-text-muted">
|
|
|
|
|
{{ props.row.code }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</q-td>
|
2024-09-09 11:59:51 +07:00
|
|
|
|
|
|
|
|
<q-td v-if="fieldSelected.includes('taxNo')">
|
|
|
|
|
{{ props.row.taxNo }}
|
2024-07-16 02:52:38 +00:00
|
|
|
</q-td>
|
2024-09-09 11:59:51 +07:00
|
|
|
|
2024-07-16 02:52:38 +00:00
|
|
|
<q-td v-if="fieldSelected.includes('branchLabelTel')">
|
2024-09-11 15:41:35 +07:00
|
|
|
{{
|
|
|
|
|
props.row.contact !== undefined
|
2024-09-18 14:29:32 +07:00
|
|
|
? props.row.contact[0]?.telephoneNo || '-'
|
2024-09-11 15:41:35 +07:00
|
|
|
: '-'
|
|
|
|
|
}}
|
2024-07-16 02:52:38 +00:00
|
|
|
</q-td>
|
2024-09-09 11:59:51 +07:00
|
|
|
|
|
|
|
|
<q-td v-if="fieldSelected.includes('contactName')">
|
2024-09-18 14:29:32 +07:00
|
|
|
{{ props.row.contactName || '-' }}
|
2024-09-09 11:59:51 +07:00
|
|
|
</q-td>
|
|
|
|
|
|
|
|
|
|
<q-td
|
|
|
|
|
v-if="fieldSelected.includes('branchLabelAddress')"
|
|
|
|
|
>
|
2024-09-18 14:29:32 +07:00
|
|
|
{{
|
|
|
|
|
locale === 'eng'
|
|
|
|
|
? `${props.row.addressEN} ${props.row.mooEN && `Moo ${props.row.mooEN}`} ${props.row.soiEN && `Soi ${props.row.soiEN}`} ${props.row.streetEN && `${props.row.streetEN} Street`} ${props.row.subDistrict.nameEN} ${props.row.district.nameEN} ${props.row.province.nameEN} ${props.row.subDistrict.zipCode}` ||
|
|
|
|
|
'-'
|
|
|
|
|
: `${props.row.address} ${props.row.moo && `หมู่ ${props.row.moo}`} ${props.row.soi && `ซอย ${props.row.soi}`} ${props.row.street && `ถนน ${props.row.street}`} ต.${props.row.subDistrict.name} อ.${props.row.district.name} จ.${props.row.province.name} ${props.row.subDistrict.zipCode}` ||
|
|
|
|
|
'-'
|
|
|
|
|
}}
|
2024-07-16 02:52:38 +00:00
|
|
|
</q-td>
|
|
|
|
|
<q-td>
|
2024-08-27 11:46:26 +07:00
|
|
|
<KebabAction
|
|
|
|
|
:status="props.row.status"
|
2024-09-09 16:31:32 +07:00
|
|
|
:idName="props.row.name"
|
2024-08-27 11:46:26 +07:00
|
|
|
@view="
|
|
|
|
|
if (props.row.isHeadOffice) {
|
|
|
|
|
triggerEdit(
|
|
|
|
|
'drawer',
|
|
|
|
|
props.row.id,
|
|
|
|
|
'headOffice',
|
|
|
|
|
props.row.code,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
triggerEdit(
|
|
|
|
|
'drawer',
|
|
|
|
|
props.row.id,
|
|
|
|
|
'subBranch',
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@edit="
|
|
|
|
|
async () => {
|
|
|
|
|
if (props.row.isHeadOffice) {
|
|
|
|
|
await triggerEdit(
|
|
|
|
|
'drawer',
|
|
|
|
|
props.row.id,
|
|
|
|
|
'headOffice',
|
|
|
|
|
props.row.code,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
await triggerEdit(
|
|
|
|
|
'drawer',
|
|
|
|
|
props.row.id,
|
|
|
|
|
'subBranch',
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-09-11 16:43:41 +07:00
|
|
|
await drawerEdit();
|
2024-08-27 11:46:26 +07:00
|
|
|
formType = 'edit';
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@delete="triggerDelete(props.row.id)"
|
|
|
|
|
@changeStatus="
|
|
|
|
|
async () => {
|
|
|
|
|
const res = await triggerChangeStatus(
|
|
|
|
|
props.row.id,
|
|
|
|
|
props.row.status,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (res) props.row.status = res.status;
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
2024-07-16 02:52:38 +00:00
|
|
|
</q-td>
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template v-slot:item="props">
|
|
|
|
|
<div class="col-12 col-md-6">
|
|
|
|
|
<BranchCard
|
2024-07-16 10:29:47 +00:00
|
|
|
class="surface-1"
|
2024-09-09 14:22:07 +07:00
|
|
|
:virtual-branch="props.row.virtual"
|
2024-07-16 02:52:38 +00:00
|
|
|
:id="`branch-card-${props.row.name}`"
|
2024-07-05 12:09:45 +07:00
|
|
|
:class="{
|
2024-09-18 14:29:32 +07:00
|
|
|
'cursor-pointer': props.row._count?.branch !== 0,
|
2024-07-05 12:09:45 +07:00
|
|
|
}"
|
2024-07-04 17:56:37 +07:00
|
|
|
@click="
|
|
|
|
|
() => {
|
2024-07-16 02:52:38 +00:00
|
|
|
if (
|
|
|
|
|
props.row.isHeadOffice &&
|
2024-09-18 14:29:32 +07:00
|
|
|
props.row._count?.branch !== 0
|
2024-07-16 02:52:38 +00:00
|
|
|
) {
|
2024-07-04 17:56:37 +07:00
|
|
|
fieldSelectedBranch.value = '';
|
|
|
|
|
inputSearch = '';
|
|
|
|
|
currentHq = {
|
|
|
|
|
id: props.row.id,
|
|
|
|
|
code: props.row.code,
|
|
|
|
|
};
|
|
|
|
|
beforeBranch = {
|
|
|
|
|
id: '',
|
|
|
|
|
code: '',
|
|
|
|
|
};
|
2024-07-19 04:16:07 +00:00
|
|
|
expandedTree = [];
|
|
|
|
|
expandedTree.push(props.row.id);
|
2024-07-04 17:56:37 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-07-16 02:52:38 +00:00
|
|
|
:metadata="props.row"
|
2024-09-09 14:26:14 +07:00
|
|
|
:color="
|
|
|
|
|
props.row.isHeadOffice
|
|
|
|
|
? 'hq'
|
|
|
|
|
: props.row.virtual
|
|
|
|
|
? 'br-virtual'
|
|
|
|
|
: 'br'
|
|
|
|
|
"
|
2024-07-16 02:52:38 +00:00
|
|
|
:key="props.row.id"
|
|
|
|
|
:data="{
|
|
|
|
|
branchLabelCode: props.row.code,
|
|
|
|
|
branchLabelName:
|
2024-08-26 16:24:08 +07:00
|
|
|
$i18n.locale === 'eng'
|
2024-07-16 02:52:38 +00:00
|
|
|
? props.row.nameEN
|
|
|
|
|
: props.row.name,
|
2024-09-09 11:59:51 +07:00
|
|
|
taxNo: props.row.taxNo,
|
2024-09-18 14:29:32 +07:00
|
|
|
branchLabelTel:
|
|
|
|
|
props.row.contact &&
|
|
|
|
|
props.row.contact
|
|
|
|
|
.map((c: BranchContact) => c.telephoneNo || '-')
|
|
|
|
|
.join(','),
|
|
|
|
|
contactName: props.row.contactName || '-',
|
2024-07-16 02:52:38 +00:00
|
|
|
branchLabelAddress:
|
2024-08-26 16:24:08 +07:00
|
|
|
$i18n.locale === 'eng'
|
2024-09-18 14:29:32 +07:00
|
|
|
? `${props.row.addressEN} ${props.row.mooEN && `Moo ${props.row.mooEN}`} ${props.row.soiEN && `Soi ${props.row.soiEN}`} ${props.row.streetEN && `${props.row.streetEN} Street`} ${props.row.subDistrict.nameEN} ${props.row.district.nameEN} ${props.row.province.nameEN} ${props.row.subDistrict.zipCode}`
|
|
|
|
|
: `${props.row.address} ${props.row.moo && `หมู่ ${props.row.moo}`} ${props.row.soi && `ซอย ${props.row.soi}`} ${props.row.street && `ถนน ${props.row.street}`} ต.${props.row.subDistrict.name} อ.${props.row.district.name} จ.${props.row.province.name} ${props.row.subDistrict.zipCode}`,
|
2024-09-11 16:43:41 +07:00
|
|
|
branchImgUrl: `/branch/${props.row.id}/branch`,
|
2024-07-16 02:52:38 +00:00
|
|
|
}"
|
|
|
|
|
:field-selected="fieldSelected"
|
|
|
|
|
:badge-field="['branchLabelStatus']"
|
|
|
|
|
:inactive="props.row.status === 'INACTIVE'"
|
|
|
|
|
@view-detail="
|
|
|
|
|
(v) => {
|
|
|
|
|
triggerEdit(
|
|
|
|
|
'drawer',
|
|
|
|
|
v.id,
|
|
|
|
|
v.isHeadOffice ? 'headOffice' : 'subBranch',
|
|
|
|
|
v.code,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-07-05 12:09:45 +07:00
|
|
|
>
|
2024-07-16 02:52:38 +00:00
|
|
|
<template v-slot:action>
|
2024-08-27 11:46:26 +07:00
|
|
|
<KebabAction
|
|
|
|
|
:status="props.row.status"
|
2024-09-09 16:31:32 +07:00
|
|
|
:idName="props.row.name"
|
2024-08-27 11:46:26 +07:00
|
|
|
@view="
|
|
|
|
|
if (props.row.isHeadOffice) {
|
|
|
|
|
triggerEdit(
|
|
|
|
|
'drawer',
|
|
|
|
|
props.row.id,
|
|
|
|
|
'headOffice',
|
|
|
|
|
props.row.code,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
triggerEdit(
|
|
|
|
|
'drawer',
|
|
|
|
|
props.row.id,
|
|
|
|
|
'subBranch',
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@edit="
|
|
|
|
|
async () => {
|
|
|
|
|
if (props.row.isHeadOffice) {
|
|
|
|
|
await triggerEdit(
|
|
|
|
|
'drawer',
|
|
|
|
|
props.row.id,
|
|
|
|
|
'headOffice',
|
|
|
|
|
props.row.code,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
await triggerEdit(
|
|
|
|
|
'drawer',
|
|
|
|
|
props.row.id,
|
|
|
|
|
'subBranch',
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-09-11 16:43:41 +07:00
|
|
|
await drawerEdit();
|
2024-08-27 11:46:26 +07:00
|
|
|
formType = 'edit';
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@delete="triggerDelete(props.row.id)"
|
|
|
|
|
@change-status="
|
|
|
|
|
async () => {
|
|
|
|
|
const res = await triggerChangeStatus(
|
|
|
|
|
props.row.id,
|
|
|
|
|
props.row.status,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (res) props.row.status = res.status;
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
2024-07-16 02:52:38 +00:00
|
|
|
</template>
|
|
|
|
|
</BranchCard>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</q-table>
|
2024-07-04 17:56:37 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</q-splitter>
|
2024-04-05 18:00:30 +07:00
|
|
|
</div>
|
2024-04-16 18:33:41 +07:00
|
|
|
</template>
|
2024-07-02 09:22:06 +00:00
|
|
|
</div>
|
2024-04-02 17:47:32 +07:00
|
|
|
</div>
|
2024-04-18 13:56:00 +07:00
|
|
|
|
2024-08-01 08:44:40 +00:00
|
|
|
<DialogForm
|
2024-09-16 10:27:08 +07:00
|
|
|
hide-footer
|
2024-04-18 13:56:00 +07:00
|
|
|
ref="formDialogRef"
|
|
|
|
|
v-model:modal="modal"
|
2024-04-22 10:52:26 +07:00
|
|
|
:title="changeTitle(formType, formTypeBranch) + ' ' + currentEdit.code"
|
2024-04-18 13:56:00 +07:00
|
|
|
:submit="
|
|
|
|
|
() => {
|
|
|
|
|
onSubmit();
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-08-02 08:26:55 +00:00
|
|
|
:close="
|
2024-09-11 16:43:41 +07:00
|
|
|
() => {
|
|
|
|
|
formLastSubBranch = 0;
|
|
|
|
|
modal = false;
|
|
|
|
|
profileFile = null;
|
|
|
|
|
isImageEdit = false;
|
|
|
|
|
isSubCreate = false;
|
|
|
|
|
imageList = { selectedImage: '', list: [] };
|
|
|
|
|
onCreateImageList = { selectedImage: '', list: [] };
|
|
|
|
|
}
|
2024-08-02 08:26:55 +00:00
|
|
|
"
|
2024-04-18 13:56:00 +07:00
|
|
|
>
|
2024-08-01 08:44:40 +00:00
|
|
|
<div class="q-mx-lg q-mt-lg">
|
|
|
|
|
<!-- title="บริษัทจ๊อบส์ เวิร์คเกอร์ เซอร์วิส จำกัด"
|
|
|
|
|
caption="Jobs Worker Service Co., Ltd." -->
|
|
|
|
|
<ProfileBanner
|
|
|
|
|
active
|
2024-08-07 10:08:45 +00:00
|
|
|
useToggle
|
2024-08-05 06:54:07 +00:00
|
|
|
:title="formData.name"
|
2024-08-28 15:51:50 +07:00
|
|
|
:toggleTitle="$t('status.title')"
|
|
|
|
|
:caption="
|
|
|
|
|
formTypeBranch === 'headOffice'
|
|
|
|
|
? `${formData.code}00000`
|
2024-08-29 10:38:20 +07:00
|
|
|
: `${formData.code?.slice(0, -5)}${(formLastSubBranch + 1).toString().padStart(5, '0')}`
|
2024-08-28 15:51:50 +07:00
|
|
|
"
|
2024-08-07 10:08:45 +00:00
|
|
|
v-model:toggle-status="formData.status"
|
2024-08-02 08:26:55 +00:00
|
|
|
v-model:cover-url="imageUrl"
|
2024-08-02 03:52:56 +00:00
|
|
|
:hideFade="imageUrl === '' || imageUrl === null"
|
|
|
|
|
:img="imageUrl || null"
|
2024-08-01 08:44:40 +00:00
|
|
|
icon="mdi-office-building-outline"
|
2024-08-08 04:17:47 +00:00
|
|
|
:color="`hsla(var(${
|
|
|
|
|
formTypeBranch === 'headOffice'
|
|
|
|
|
? '--pink-6'
|
2024-09-09 14:26:14 +07:00
|
|
|
: formData.virtual
|
|
|
|
|
? '--blue-6'
|
|
|
|
|
: $q.dark.isActive
|
|
|
|
|
? '--violet-10'
|
|
|
|
|
: '--violet-11'
|
2024-08-08 04:17:47 +00:00
|
|
|
}-hsl)/1)`"
|
|
|
|
|
:bg-color="`hsla(var(${
|
2024-08-27 17:32:17 +07:00
|
|
|
imageUrl
|
|
|
|
|
? '--gray-0'
|
|
|
|
|
: formTypeBranch === 'headOffice'
|
|
|
|
|
? '--pink-6'
|
2024-09-09 14:26:14 +07:00
|
|
|
: formData.virtual
|
|
|
|
|
? '--blue-6'
|
|
|
|
|
: $q.dark.isActive
|
|
|
|
|
? '--violet-10'
|
|
|
|
|
: '--violet-11'
|
2024-08-27 17:32:17 +07:00
|
|
|
}-hsl)/${imageUrl ? '0' : '0.15'})`"
|
2024-08-07 10:08:45 +00:00
|
|
|
:menu="formMenuIcon"
|
2024-09-12 14:35:49 +07:00
|
|
|
v-model:current-tab="currentTab"
|
2024-09-16 10:27:08 +07:00
|
|
|
:tabs-list="
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
name: 'main',
|
|
|
|
|
label: 'customerBranch.tab.main',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'attachment',
|
|
|
|
|
label: 'customerBranch.tab.attachment',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'remark',
|
|
|
|
|
label: 'customerBranch.tab.remark',
|
|
|
|
|
},
|
|
|
|
|
].filter((v) => {
|
|
|
|
|
if (!currentId && v.name === 'attachment') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!currentId && v.name === 'remark') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
})
|
|
|
|
|
"
|
2024-09-11 16:43:41 +07:00
|
|
|
@view="
|
|
|
|
|
() => {
|
|
|
|
|
imageDialog = true;
|
|
|
|
|
isImageEdit = false;
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@edit="imageDialog = isImageEdit = true"
|
2024-08-07 10:08:45 +00:00
|
|
|
@update:toggle-status="
|
|
|
|
|
() => {
|
|
|
|
|
formData.status =
|
|
|
|
|
formData.status === 'CREATED' ? 'INACTIVE' : 'CREATED';
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-04-18 13:56:00 +07:00
|
|
|
/>
|
2024-08-01 08:44:40 +00:00
|
|
|
</div>
|
2024-09-16 10:27:08 +07:00
|
|
|
<div class="col q-pa-lg">
|
|
|
|
|
<div
|
|
|
|
|
style="overflow-y: auto"
|
|
|
|
|
class="row full-width full-height surface-1 rounded relative-position"
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
v-if="currentTab === 'main'"
|
|
|
|
|
class="q-py-md q-px-lg"
|
|
|
|
|
style="position: absolute; z-index: 99999; top: 0; right: 0"
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
v-if="formData.status !== 'INACTIVE'"
|
|
|
|
|
class="surface-1 row rounded"
|
|
|
|
|
>
|
|
|
|
|
<UndoButton
|
|
|
|
|
v-if="formType === 'edit' && !!currentId"
|
|
|
|
|
icon-only
|
|
|
|
|
@click="undo()"
|
|
|
|
|
type="button"
|
|
|
|
|
/>
|
|
|
|
|
<SaveButton
|
|
|
|
|
v-if="formType === 'edit' || formType === 'create'"
|
|
|
|
|
id="btn-info-basic-save"
|
|
|
|
|
icon-only
|
|
|
|
|
type="submit"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<EditButton
|
|
|
|
|
v-if="formType !== 'edit' && !!currentId"
|
|
|
|
|
id="btn-info-basic-edit"
|
|
|
|
|
icon-only
|
|
|
|
|
@click="drawerEdit()"
|
|
|
|
|
type="button"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<DeleteButton
|
|
|
|
|
v-if="formType !== 'edit' && !!currentId"
|
|
|
|
|
id="btn-info-basic-delete"
|
|
|
|
|
icon-only
|
|
|
|
|
@click="triggerDelete(currentEdit.id)"
|
|
|
|
|
type="button"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
class="col full-height rounded scroll row q-py-md q-pl-md q-pr-sm"
|
|
|
|
|
v-if="$q.screen.gt.sm"
|
|
|
|
|
>
|
2024-08-01 08:44:40 +00:00
|
|
|
<SideMenu
|
2024-09-16 10:27:08 +07:00
|
|
|
:menu="
|
2024-08-01 08:44:40 +00:00
|
|
|
{
|
2024-09-16 10:27:08 +07:00
|
|
|
main: [
|
|
|
|
|
{
|
|
|
|
|
name: $t('form.field.basicInformation'),
|
|
|
|
|
anchor: 'form-information',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('branch.form.group.contact'),
|
|
|
|
|
anchor: 'form-contact',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('form.address'),
|
|
|
|
|
anchor: 'form-address',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('branch.form.group.location'),
|
|
|
|
|
anchor: 'form-location',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'QR Code',
|
|
|
|
|
anchor: 'form-qr',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('branch.form.group.bankAccount'),
|
|
|
|
|
anchor: 'form-bank',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('branch.form.group.admin'),
|
|
|
|
|
anchor: 'form-branch-admin-view',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
attachment: [
|
|
|
|
|
{
|
|
|
|
|
name: $t('customerBranch.tab.attachment'),
|
|
|
|
|
anchor: 'form-attachment',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
remark: [
|
|
|
|
|
{
|
|
|
|
|
name: $t('customerBranch.tab.remark'),
|
|
|
|
|
anchor: 'form-remark',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}[currentTab] || []
|
|
|
|
|
"
|
2024-08-01 08:44:40 +00:00
|
|
|
background="transparent"
|
|
|
|
|
:active="{
|
|
|
|
|
background: 'hsla(var(--blue-6-hsl) / .2)',
|
|
|
|
|
foreground: 'var(--blue-6)',
|
|
|
|
|
}"
|
|
|
|
|
scroll-element="#branch-form"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-09-16 10:27:08 +07:00
|
|
|
<div
|
2024-09-20 14:56:26 +07:00
|
|
|
class="col-12 col-md-10 q-py-md q-pr-md full-height q-gutter-y-xl"
|
2024-09-16 10:27:08 +07:00
|
|
|
:class="$q.screen.xs ? 'q-pl-md' : 'q-pl-sm'"
|
|
|
|
|
id="branch-form"
|
|
|
|
|
style="overflow-y: auto"
|
|
|
|
|
>
|
|
|
|
|
<template v-if="currentTab === 'main'">
|
|
|
|
|
<FormBranchInformation
|
|
|
|
|
id="form-information"
|
|
|
|
|
v-model:branchCount="formLastSubBranch"
|
|
|
|
|
v-model:abbreviation="formData.code"
|
|
|
|
|
v-model:code="formData.codeHeadOffice"
|
|
|
|
|
v-model:code-sub-branch="currentEdit.code"
|
|
|
|
|
v-model:taxNo="formData.taxNo"
|
|
|
|
|
v-model:name="formData.name"
|
|
|
|
|
v-model:nameEN="formData.nameEN"
|
|
|
|
|
v-model:type-branch="formTypeBranch"
|
|
|
|
|
v-model:permit-no="formData.permitNo"
|
|
|
|
|
v-model:permit-issue-date="formData.permitIssueDate"
|
|
|
|
|
v-model:permit-expire-date="formData.permitExpireDate"
|
|
|
|
|
:separator="true"
|
|
|
|
|
:dense="true"
|
|
|
|
|
:outlined="true"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
title="form.field.basicInformation"
|
|
|
|
|
:view="isSubCreate || !!currentId"
|
|
|
|
|
onCreate
|
|
|
|
|
/>
|
|
|
|
|
<FormBranchContact
|
|
|
|
|
id="form-contact"
|
|
|
|
|
v-model:type-branch="formTypeBranch"
|
|
|
|
|
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"
|
|
|
|
|
v-model:web-url="formData.webUrl"
|
|
|
|
|
:separator="true"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
title="branch.form.group.contact"
|
|
|
|
|
:dense="true"
|
|
|
|
|
:outlined="true"
|
|
|
|
|
/>
|
2024-08-13 16:35:10 +07:00
|
|
|
|
2024-09-16 10:27:08 +07:00
|
|
|
<AddressForm
|
|
|
|
|
id="form-address"
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
separator
|
|
|
|
|
prefix-id="default"
|
|
|
|
|
:title="'form.address'"
|
|
|
|
|
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-09-18 14:29:32 +07:00
|
|
|
v-model:moo="formData.moo"
|
|
|
|
|
v-model:mooEN="formData.mooEN"
|
|
|
|
|
v-model:soi="formData.soi"
|
|
|
|
|
v-model:soiEN="formData.soiEN"
|
|
|
|
|
v-model:street="formData.street"
|
|
|
|
|
v-model:streetEN="formData.streetEN"
|
2024-09-16 10:27:08 +07:00
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
/>
|
|
|
|
|
<FormLocation
|
|
|
|
|
id="form-location"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
:separator="true"
|
|
|
|
|
v-model:latitude="formData.latitude"
|
|
|
|
|
v-model:longitude="formData.longitude"
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
title="branch.form.group.location"
|
|
|
|
|
/>
|
|
|
|
|
<FormQr
|
|
|
|
|
id="form-qr"
|
|
|
|
|
title="QR Code"
|
|
|
|
|
:separator="true"
|
|
|
|
|
:qr="qrCodeimageUrl"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
@view-qr="
|
|
|
|
|
() => {
|
|
|
|
|
triggerEditQrCodeLine();
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@edit-qr="() => refQrCodeUpload && refQrCodeUpload.browse()"
|
|
|
|
|
/>
|
|
|
|
|
<FormBank
|
|
|
|
|
id="form-bank"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
title="branch.form.group.bankAccount"
|
|
|
|
|
dense
|
|
|
|
|
v-model:bank-book-list="formBankBook"
|
|
|
|
|
@view-qr="
|
|
|
|
|
(i) => {
|
|
|
|
|
currentIndexQrCodeBank = i;
|
|
|
|
|
triggerEditQrCodeBank();
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@edit-qr="
|
|
|
|
|
(i) => {
|
|
|
|
|
currentIndexQrCodeBank = i;
|
|
|
|
|
refQrCodeUpload && refQrCodeUpload.browse();
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
<FormBranchAdmin
|
|
|
|
|
id="form-branch-admin-view"
|
|
|
|
|
:admin="currentBranchAdmin"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template v-if="currentTab === 'attachment'">
|
|
|
|
|
<UploadFile
|
|
|
|
|
branch
|
|
|
|
|
:file="currentAttachmentList"
|
|
|
|
|
:tree-file="
|
|
|
|
|
Object.values(
|
|
|
|
|
currentAttachmentList.reduce<
|
|
|
|
|
Record<string, { label: string; file: { label: string }[] }>
|
|
|
|
|
>((a, b) => {
|
|
|
|
|
if (b.name && !a[b.name]) {
|
|
|
|
|
a[b.name] = {
|
|
|
|
|
label: b.name,
|
|
|
|
|
file: [],
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return a;
|
|
|
|
|
}, {}) || {},
|
|
|
|
|
)
|
|
|
|
|
"
|
|
|
|
|
@save="
|
|
|
|
|
async (_group, file) => {
|
|
|
|
|
if (file) {
|
|
|
|
|
attachmentList.push(file);
|
2024-09-12 14:35:49 +07:00
|
|
|
|
2024-09-16 10:27:08 +07:00
|
|
|
await branchStore.putAttachment(currentId, attachmentList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@deleteFile="
|
|
|
|
|
async (filename) => {
|
|
|
|
|
const res = await branchStore.deleteByIdAttachment(
|
|
|
|
|
currentId,
|
|
|
|
|
filename,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
|
currentAttachmentList = currentAttachmentList.filter(
|
|
|
|
|
(v) => {
|
|
|
|
|
if (v.name === filename) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template v-if="currentTab === 'remark'"></template>
|
|
|
|
|
</div>
|
2024-08-01 08:44:40 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</DialogForm>
|
2024-04-19 11:47:41 +07:00
|
|
|
|
|
|
|
|
<DrawerInfo
|
|
|
|
|
ref="formDialogRef"
|
2024-09-04 14:41:25 +07:00
|
|
|
v-model:drawer-open="modalDrawer"
|
2024-09-11 16:43:41 +07:00
|
|
|
:submit="() => onSubmit()"
|
2024-08-08 08:55:28 +00:00
|
|
|
:category="changeTitle(formType, formTypeBranch)"
|
2024-08-26 16:24:08 +07:00
|
|
|
:title="$i18n.locale === 'eng' ? formData.nameEN : formData.name"
|
2024-08-02 08:26:55 +00:00
|
|
|
:close="
|
2024-09-11 16:43:41 +07:00
|
|
|
() => {
|
|
|
|
|
modalDrawer = false;
|
|
|
|
|
isImageEdit = false;
|
|
|
|
|
imageList = { selectedImage: '', list: [] };
|
|
|
|
|
onCreateImageList = { selectedImage: '', list: [] };
|
|
|
|
|
flowStore.rotate();
|
|
|
|
|
resetScrollBar('branch-info');
|
|
|
|
|
}
|
2024-08-02 08:26:55 +00:00
|
|
|
"
|
2024-04-19 13:13:57 +07:00
|
|
|
:statusBranch="formData.status"
|
2024-08-19 10:17:44 +07:00
|
|
|
hide-action
|
2024-04-19 11:47:41 +07:00
|
|
|
>
|
2024-08-02 03:52:56 +00:00
|
|
|
<InfoForm>
|
|
|
|
|
<div class="q-mx-lg q-mt-lg">
|
|
|
|
|
<ProfileBanner
|
2024-08-07 10:08:45 +00:00
|
|
|
:active="formData.status !== 'INACTIVE'"
|
|
|
|
|
useToggle
|
2024-08-02 08:26:55 +00:00
|
|
|
v-model:cover-url="imageUrl"
|
2024-08-28 15:51:50 +07:00
|
|
|
:toggleTitle="$t('status.title')"
|
2024-08-02 08:26:55 +00:00
|
|
|
:hideFade="imageUrl === '' || imageUrl === null"
|
2024-09-11 16:43:41 +07:00
|
|
|
:img="
|
|
|
|
|
`${baseUrl}/branch/${currentId}/image/${formData.selectedImage}`.concat(
|
|
|
|
|
refreshImageState ? `?ts=${Date.now()}` : '',
|
|
|
|
|
) || null
|
|
|
|
|
"
|
2024-08-02 03:52:56 +00:00
|
|
|
:title="formData.name"
|
2024-08-08 02:17:00 +00:00
|
|
|
:caption="formData.code"
|
2024-08-02 03:52:56 +00:00
|
|
|
icon="mdi-office-building-outline"
|
2024-09-16 10:27:08 +07:00
|
|
|
v-model:current-tab="currentTab"
|
|
|
|
|
:tabs-list="[
|
|
|
|
|
{
|
|
|
|
|
name: 'main',
|
|
|
|
|
label: 'customerBranch.tab.main',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'attachment',
|
|
|
|
|
label: 'customerBranch.tab.attachment',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'remark',
|
|
|
|
|
label: 'customerBranch.tab.remark',
|
|
|
|
|
},
|
|
|
|
|
]"
|
2024-08-08 04:17:47 +00:00
|
|
|
:color="`hsla(var(${
|
|
|
|
|
formTypeBranch === 'headOffice'
|
|
|
|
|
? '--pink-6'
|
2024-09-09 14:26:14 +07:00
|
|
|
: formData.virtual
|
|
|
|
|
? '--blue-6'
|
|
|
|
|
: $q.dark.isActive
|
|
|
|
|
? '--violet-10'
|
|
|
|
|
: '--violet-11'
|
2024-08-08 04:17:47 +00:00
|
|
|
}-hsl)/1)`"
|
|
|
|
|
:bg-color="`hsla(var(${
|
2024-08-27 17:32:17 +07:00
|
|
|
imageUrl
|
|
|
|
|
? '--gray-0'
|
|
|
|
|
: formTypeBranch === 'headOffice'
|
|
|
|
|
? '--pink-6'
|
2024-09-09 14:26:14 +07:00
|
|
|
: formData.virtual
|
|
|
|
|
? '--blue-6'
|
|
|
|
|
: $q.dark.isActive
|
|
|
|
|
? '--violet-10'
|
|
|
|
|
: '--violet-11'
|
2024-09-11 16:43:41 +07:00
|
|
|
}-hsl)/${imageUrl ? '0' : '0.1'})`"
|
2024-08-07 10:08:45 +00:00
|
|
|
v-model:toggle-status="formData.status"
|
2024-09-11 16:43:41 +07:00
|
|
|
@view="
|
|
|
|
|
() => {
|
|
|
|
|
imageDialog = true;
|
|
|
|
|
isImageEdit = false;
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@edit="imageDialog = isImageEdit = true"
|
2024-08-07 10:08:45 +00:00
|
|
|
@update:toggle-status="
|
|
|
|
|
async (v) => {
|
|
|
|
|
const res = await triggerChangeStatus(currentId, v);
|
2024-09-09 13:41:44 +07:00
|
|
|
if (res) {
|
|
|
|
|
undo();
|
|
|
|
|
formData.status = res.status;
|
|
|
|
|
formType = 'view';
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-11 15:41:35 +07:00
|
|
|
await fetchList({ pageSize: 99999 });
|
2024-08-07 10:08:45 +00:00
|
|
|
}
|
|
|
|
|
"
|
2024-08-02 03:52:56 +00:00
|
|
|
:menu="formMenuIcon"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-08-19 10:17:44 +07:00
|
|
|
<div class="col q-pa-lg">
|
|
|
|
|
<div
|
|
|
|
|
style="overflow-y: auto"
|
|
|
|
|
class="row full-width full-height surface-1 rounded relative-position"
|
|
|
|
|
>
|
|
|
|
|
<div
|
2024-09-16 10:27:08 +07:00
|
|
|
v-if="currentTab === 'main'"
|
2024-08-19 10:17:44 +07:00
|
|
|
class="q-py-md q-px-lg"
|
|
|
|
|
style="position: absolute; z-index: 99999; top: 0; right: 0"
|
|
|
|
|
>
|
2024-09-05 14:36:18 +07:00
|
|
|
<div
|
|
|
|
|
v-if="formData.status !== 'INACTIVE'"
|
|
|
|
|
class="surface-1 row rounded"
|
|
|
|
|
>
|
2024-08-19 10:17:44 +07:00
|
|
|
<UndoButton
|
|
|
|
|
v-if="formType === 'edit'"
|
|
|
|
|
icon-only
|
|
|
|
|
@click="undo()"
|
|
|
|
|
type="button"
|
|
|
|
|
/>
|
|
|
|
|
<SaveButton
|
|
|
|
|
v-if="formType === 'edit'"
|
|
|
|
|
id="btn-info-basic-save"
|
|
|
|
|
icon-only
|
|
|
|
|
type="submit"
|
|
|
|
|
/>
|
|
|
|
|
<EditButton
|
|
|
|
|
v-if="formType !== 'edit'"
|
|
|
|
|
id="btn-info-basic-edit"
|
|
|
|
|
icon-only
|
|
|
|
|
@click="drawerEdit()"
|
|
|
|
|
type="button"
|
|
|
|
|
/>
|
|
|
|
|
<DeleteButton
|
|
|
|
|
v-if="formType !== 'edit'"
|
|
|
|
|
id="btn-info-basic-delete"
|
|
|
|
|
icon-only
|
|
|
|
|
@click="triggerDelete(currentEdit.id)"
|
|
|
|
|
type="button"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
2024-08-27 11:46:26 +07:00
|
|
|
v-if="$q.screen.gt.sm"
|
2024-08-19 10:17:44 +07:00
|
|
|
class="col full-height rounded scroll row q-py-md q-pl-md q-pr-sm"
|
|
|
|
|
>
|
2024-08-02 03:52:56 +00:00
|
|
|
<SideMenu
|
2024-09-16 10:27:08 +07:00
|
|
|
:menu="
|
2024-08-02 03:52:56 +00:00
|
|
|
{
|
2024-09-16 10:27:08 +07:00
|
|
|
main: [
|
|
|
|
|
{
|
|
|
|
|
name: $t('form.field.basicInformation'),
|
|
|
|
|
anchor: 'info-information',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('branch.form.group.contact'),
|
|
|
|
|
anchor: 'info-contact',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('form.address'),
|
|
|
|
|
anchor: 'info-address',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('branch.form.group.location'),
|
|
|
|
|
anchor: 'info-location',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'QR Code',
|
|
|
|
|
anchor: 'info-qr',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('branch.form.group.bankAccount'),
|
|
|
|
|
anchor: 'info-bank',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('branch.form.group.admin'),
|
|
|
|
|
anchor: 'info-branch-admin-view',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
attachment: [
|
|
|
|
|
{
|
|
|
|
|
name: $t('customerBranch.tab.attachment'),
|
|
|
|
|
anchor: 'info-attachment',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
remark: [
|
|
|
|
|
{
|
|
|
|
|
name: $t('customerBranch.tab.remark'),
|
|
|
|
|
anchor: 'info-remark',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}[currentTab] || []
|
|
|
|
|
"
|
2024-08-02 03:52:56 +00:00
|
|
|
background="transparent"
|
|
|
|
|
:active="{
|
|
|
|
|
background: 'hsla(var(--blue-6-hsl) / .2)',
|
|
|
|
|
foreground: 'var(--blue-6)',
|
|
|
|
|
}"
|
|
|
|
|
scroll-element="#branch-info"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-08-19 10:17:44 +07:00
|
|
|
<div
|
2024-08-27 11:46:26 +07:00
|
|
|
class="col-12 col-md-10 q-py-md q-pr-md full-height"
|
|
|
|
|
:class="$q.screen.xs ? 'q-pl-md' : 'q-pl-sm'"
|
2024-08-19 10:17:44 +07:00
|
|
|
id="branch-info"
|
|
|
|
|
style="overflow-y: auto"
|
|
|
|
|
>
|
2024-09-16 10:27:08 +07:00
|
|
|
<template v-if="currentTab === 'main'">
|
|
|
|
|
<FormBranchInformation
|
|
|
|
|
id="info-information"
|
|
|
|
|
v-model:virtual="formData.virtual"
|
|
|
|
|
v-model:abbreviation="formData.code"
|
|
|
|
|
v-model:code="formData.codeHeadOffice"
|
|
|
|
|
v-model:code-sub-branch="currentEdit.code"
|
|
|
|
|
v-model:taxNo="formData.taxNo"
|
|
|
|
|
v-model:name="formData.name"
|
|
|
|
|
v-model:nameEN="formData.nameEN"
|
|
|
|
|
v-model:type-branch="formTypeBranch"
|
|
|
|
|
v-model:permit-no="formData.permitNo"
|
|
|
|
|
v-model:permit-issue-date="formData.permitIssueDate"
|
|
|
|
|
v-model:permit-expire-date="formData.permitExpireDate"
|
|
|
|
|
:separator="true"
|
|
|
|
|
:dense="true"
|
|
|
|
|
:outlined="true"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
view
|
|
|
|
|
title="form.field.basicInformation"
|
|
|
|
|
class="q-mb-xl"
|
|
|
|
|
/>
|
|
|
|
|
<FormBranchContact
|
|
|
|
|
id="info-contact"
|
|
|
|
|
title="branch.form.group.contact"
|
|
|
|
|
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"
|
|
|
|
|
v-model:web-url="formData.webUrl"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
:view="formType === 'view'"
|
|
|
|
|
:separator="true"
|
|
|
|
|
:dense="true"
|
|
|
|
|
:outlined="true"
|
|
|
|
|
class="q-mb-xl"
|
|
|
|
|
/>
|
|
|
|
|
<AddressForm
|
|
|
|
|
id="info-address"
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
separator
|
|
|
|
|
prefix-id="default"
|
|
|
|
|
:title="'form.address'"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
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-09-18 14:29:32 +07:00
|
|
|
v-model:moo="formData.moo"
|
|
|
|
|
v-model:mooEN="formData.mooEN"
|
|
|
|
|
v-model:soi="formData.soi"
|
|
|
|
|
v-model:soiEN="formData.soiEN"
|
|
|
|
|
v-model:street="formData.street"
|
|
|
|
|
v-model:streetEN="formData.streetEN"
|
2024-09-16 10:27:08 +07:00
|
|
|
v-model:zip-code="formData.zipCode"
|
|
|
|
|
class="q-mb-xl"
|
|
|
|
|
/>
|
|
|
|
|
<FormLocation
|
|
|
|
|
id="info-location"
|
|
|
|
|
title="branch.form.group.location"
|
|
|
|
|
v-model:latitude="formData.latitude"
|
|
|
|
|
v-model:longitude="formData.longitude"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
:separator="true"
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
class="q-mb-xl"
|
|
|
|
|
/>
|
|
|
|
|
<FormQr
|
|
|
|
|
id="info-qr"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
title="QR Code"
|
|
|
|
|
:separator="true"
|
|
|
|
|
:qr="qrCodeimageUrl"
|
|
|
|
|
@view-qr="
|
|
|
|
|
() => {
|
|
|
|
|
triggerEditQrCodeLine();
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@edit-qr="() => refQrCodeUpload && refQrCodeUpload.browse()"
|
|
|
|
|
class="q-mb-xl"
|
|
|
|
|
/>
|
|
|
|
|
<FormBank
|
|
|
|
|
id="info-bank"
|
|
|
|
|
:readonly="formType === 'view'"
|
|
|
|
|
title="branch.form.group.bankAccount"
|
|
|
|
|
dense
|
|
|
|
|
v-model:bank-book-list="formBankBook"
|
|
|
|
|
class="q-mb-xl"
|
|
|
|
|
@view-qr="
|
|
|
|
|
(i) => {
|
|
|
|
|
currentIndexQrCodeBank = i;
|
|
|
|
|
triggerEditQrCodeBank();
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@edit-qr="
|
|
|
|
|
(i) => {
|
|
|
|
|
currentIndexQrCodeBank = i;
|
|
|
|
|
refQrCodeUpload.browse();
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
<FormBranchAdmin
|
|
|
|
|
id="info-branch-admin-view"
|
|
|
|
|
:admin="currentBranchAdmin"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template v-if="currentTab === 'attachment'">
|
|
|
|
|
<UploadFile
|
|
|
|
|
id="info-attachment"
|
|
|
|
|
branch
|
|
|
|
|
:file="currentAttachmentList"
|
|
|
|
|
:tree-file="
|
|
|
|
|
Object.values(
|
|
|
|
|
currentAttachmentList.reduce<
|
|
|
|
|
Record<
|
|
|
|
|
string,
|
|
|
|
|
{ label: string; file: { label: string }[] }
|
|
|
|
|
>
|
|
|
|
|
>((a, b) => {
|
|
|
|
|
if (b.name && !a[b.name]) {
|
|
|
|
|
a[b.name] = {
|
|
|
|
|
label: b.name,
|
|
|
|
|
file: [],
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return a;
|
|
|
|
|
}, {}) || {},
|
|
|
|
|
)
|
|
|
|
|
"
|
|
|
|
|
@save="
|
|
|
|
|
async (_group, file) => {
|
|
|
|
|
if (file) {
|
|
|
|
|
attachmentList.push(file);
|
|
|
|
|
|
|
|
|
|
await branchStore.putAttachment(
|
|
|
|
|
currentId,
|
|
|
|
|
attachmentList,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@deleteFile="
|
|
|
|
|
async (filename) => {
|
|
|
|
|
const res = await branchStore.deleteByIdAttachment(
|
|
|
|
|
currentId,
|
|
|
|
|
filename,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
|
currentAttachmentList = currentAttachmentList.filter(
|
|
|
|
|
(v) => {
|
|
|
|
|
if (v.name === filename) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template v-if="currentTab === 'remark'"></template>
|
2024-08-19 10:17:44 +07:00
|
|
|
</div>
|
2024-08-02 03:52:56 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</InfoForm>
|
2024-04-19 11:47:41 +07:00
|
|
|
</DrawerInfo>
|
2024-07-19 04:16:07 +00:00
|
|
|
|
|
|
|
|
<q-dialog v-model="holdDialog" position="bottom">
|
2024-07-19 10:35:18 +00:00
|
|
|
<div class="surface-1 full-width rounded column q-pb-md">
|
2024-07-19 04:16:07 +00:00
|
|
|
<div class="flex q-py-sm justify-center full-width">
|
|
|
|
|
<div
|
|
|
|
|
class="rounded"
|
|
|
|
|
style="
|
|
|
|
|
width: 8%;
|
|
|
|
|
height: 4px;
|
|
|
|
|
background-color: hsla(0, 0%, 50%, 0.75);
|
|
|
|
|
"
|
|
|
|
|
></div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-07-19 04:56:08 +00:00
|
|
|
<q-list v-if="currentNode">
|
|
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
v-ripple
|
|
|
|
|
v-close-popup
|
|
|
|
|
@click.stop="
|
2024-08-29 10:38:20 +07:00
|
|
|
triggerCreate('subBranch', currentNode.id, currentNode.code)
|
2024-07-19 04:56:08 +00:00
|
|
|
"
|
|
|
|
|
>
|
2024-07-19 04:16:07 +00:00
|
|
|
<q-item-section avatar>
|
2024-08-08 06:41:15 +00:00
|
|
|
<q-icon name="mdi-file-plus-outline" class="app-text-muted-2" />
|
2024-07-19 04:16:07 +00:00
|
|
|
</q-item-section>
|
|
|
|
|
<q-item-section>
|
2024-08-26 17:18:15 +07:00
|
|
|
{{
|
|
|
|
|
$t('form.title.create', { name: $t('branch.card.branchLabel') })
|
|
|
|
|
}}
|
2024-07-19 04:16:07 +00:00
|
|
|
</q-item-section>
|
|
|
|
|
</q-item>
|
|
|
|
|
|
2024-07-19 04:56:08 +00:00
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
v-ripple
|
|
|
|
|
v-close-popup
|
|
|
|
|
@click.stop="
|
|
|
|
|
if (currentNode.isHeadOffice) {
|
|
|
|
|
triggerEdit(
|
|
|
|
|
'drawer',
|
|
|
|
|
currentNode.id,
|
|
|
|
|
'headOffice',
|
|
|
|
|
currentNode.code,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
triggerEdit('drawer', currentNode.id, 'subBranch');
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
>
|
2024-07-19 04:16:07 +00:00
|
|
|
<q-item-section avatar>
|
|
|
|
|
<q-icon
|
|
|
|
|
name="mdi-eye-outline"
|
|
|
|
|
style="color: hsl(var(--green-6-hsl))"
|
|
|
|
|
/>
|
|
|
|
|
</q-item-section>
|
2024-08-26 17:18:15 +07:00
|
|
|
<q-item-section>{{ $t('general.viewDetail') }}</q-item-section>
|
2024-07-19 04:16:07 +00:00
|
|
|
</q-item>
|
|
|
|
|
|
2024-07-19 04:56:08 +00:00
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
v-ripple
|
|
|
|
|
v-close-popup
|
|
|
|
|
@click="
|
2024-08-09 02:49:32 +00:00
|
|
|
async () => {
|
2024-07-19 04:56:08 +00:00
|
|
|
if (currentNode && currentNode.isHeadOffice) {
|
2024-08-09 02:49:32 +00:00
|
|
|
await triggerEdit(
|
|
|
|
|
'drawer',
|
2024-07-19 04:56:08 +00:00
|
|
|
currentNode.id,
|
|
|
|
|
'headOffice',
|
|
|
|
|
currentNode.code,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
2024-08-09 02:49:32 +00:00
|
|
|
currentNode &&
|
|
|
|
|
triggerEdit('drawer', currentNode.id, 'subBranch');
|
2024-07-19 04:56:08 +00:00
|
|
|
}
|
2024-08-14 13:10:47 +07:00
|
|
|
formType = 'edit';
|
2024-07-19 04:56:08 +00:00
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
>
|
2024-07-19 04:16:07 +00:00
|
|
|
<q-item-section avatar>
|
|
|
|
|
<q-icon
|
|
|
|
|
name="mdi-pencil-outline"
|
|
|
|
|
style="color: hsl(var(--cyan-6-hsl))"
|
|
|
|
|
/>
|
|
|
|
|
</q-item-section>
|
2024-08-26 17:18:15 +07:00
|
|
|
<q-item-section>{{ $t('general.edit') }}</q-item-section>
|
2024-07-19 04:16:07 +00:00
|
|
|
</q-item>
|
|
|
|
|
|
2024-07-19 04:56:08 +00:00
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
v-ripple
|
|
|
|
|
v-close-popup
|
|
|
|
|
@click="triggerDelete(currentNode.id)"
|
|
|
|
|
>
|
2024-07-19 04:16:07 +00:00
|
|
|
<q-item-section avatar>
|
|
|
|
|
<q-icon name="mdi-trash-can-outline" class="app-text-negative" />
|
|
|
|
|
</q-item-section>
|
2024-08-26 17:18:15 +07:00
|
|
|
<q-item-section>{{ $t('general.delete') }}</q-item-section>
|
2024-07-19 04:16:07 +00:00
|
|
|
</q-item>
|
|
|
|
|
|
2024-07-19 10:35:18 +00:00
|
|
|
<q-item clickable v-ripple>
|
2024-07-19 04:16:07 +00:00
|
|
|
<q-item-section avatar>
|
2024-08-13 08:55:49 +00:00
|
|
|
<ToggleButton
|
|
|
|
|
two-way
|
2024-07-19 04:56:08 +00:00
|
|
|
:id="`view-detail-btn-${currentNode.name}-status`"
|
|
|
|
|
@click="
|
|
|
|
|
async () => {
|
|
|
|
|
if (!currentNode) return;
|
2024-07-23 11:04:44 +00:00
|
|
|
const res = await triggerChangeStatus(
|
|
|
|
|
currentNode.id,
|
|
|
|
|
currentNode.status,
|
|
|
|
|
);
|
2024-07-19 04:56:08 +00:00
|
|
|
if (res) currentNode.status = res.status;
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
:model-value="
|
|
|
|
|
currentNode.status === 'CREATED' ||
|
|
|
|
|
currentNode.status === 'ACTIVE'
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</q-item-section>
|
|
|
|
|
<q-item-section>
|
|
|
|
|
{{
|
|
|
|
|
currentNode.status !== 'INACTIVE'
|
2024-08-26 16:24:08 +07:00
|
|
|
? $t('general.open')
|
|
|
|
|
: $t('general.close')
|
2024-07-19 04:56:08 +00:00
|
|
|
}}
|
2024-07-19 04:16:07 +00:00
|
|
|
</q-item-section>
|
|
|
|
|
</q-item>
|
|
|
|
|
</q-list>
|
|
|
|
|
</div>
|
|
|
|
|
</q-dialog>
|
2024-08-02 03:52:56 +00:00
|
|
|
|
2024-09-11 13:44:57 +07:00
|
|
|
<QrCodeUploadDialog
|
|
|
|
|
ref="refQrCodeUpload"
|
|
|
|
|
v-model:dialogState="qrCodeDialog"
|
|
|
|
|
v-model:file="statusQrCodeFile as File"
|
|
|
|
|
v-model:image-url="statusQrCodeUrl"
|
|
|
|
|
@save="
|
2024-09-11 17:59:49 +07:00
|
|
|
(_file, imageUrl) => {
|
2024-09-11 13:44:57 +07:00
|
|
|
qrCodeDialog = false;
|
|
|
|
|
if (currentIndexQrCodeBank === -1) {
|
|
|
|
|
triggerEditQrCodeLine({ save: true });
|
|
|
|
|
}
|
|
|
|
|
if (currentIndexQrCodeBank !== -1) {
|
|
|
|
|
triggerEditQrCodeBank({ save: true });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@clear="statusDeletsQrCode = true"
|
|
|
|
|
clearButton
|
|
|
|
|
>
|
|
|
|
|
<template #error>
|
|
|
|
|
<div
|
|
|
|
|
class="full-width full-height flex items-center justify-center"
|
|
|
|
|
style="color: gray"
|
|
|
|
|
>
|
|
|
|
|
<q-icon size="15rem" name="mdi-qrcode" />
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</QrCodeUploadDialog>
|
|
|
|
|
|
2024-08-02 03:52:56 +00:00
|
|
|
<ImageUploadDialog
|
2024-08-02 08:26:55 +00:00
|
|
|
ref="refImageUpload"
|
2024-08-02 03:52:56 +00:00
|
|
|
v-model:dialogState="imageDialog"
|
2024-09-11 16:43:41 +07:00
|
|
|
v-model:file="profileFile"
|
2024-08-02 03:52:56 +00:00
|
|
|
v-model:image-url="imageUrl"
|
2024-09-11 16:43:41 +07:00
|
|
|
v-model:data-list="imageList"
|
|
|
|
|
v-model:on-create-data-list="onCreateImageList"
|
|
|
|
|
:on-create="modal"
|
|
|
|
|
:hiddenFooter="!isImageEdit"
|
|
|
|
|
@add-image="
|
|
|
|
|
async (v) => {
|
|
|
|
|
if (!v) return;
|
|
|
|
|
if (!currentId) return;
|
2024-09-12 09:58:04 +07:00
|
|
|
await branchStore.addImageList(v, currentId, Date.now().toString());
|
2024-09-11 16:43:41 +07:00
|
|
|
await fetchImageList(currentId, formData.selectedImage || '');
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@remove-image="
|
|
|
|
|
async (v) => {
|
|
|
|
|
if (!v) return;
|
|
|
|
|
if (!currentId) return;
|
|
|
|
|
const name = v.split('/').pop() || '';
|
|
|
|
|
await branchStore.deleteImageByName(currentId, name);
|
2024-09-12 16:41:09 +07:00
|
|
|
await fetchImageList(currentId, formData.selectedImage || '');
|
2024-09-11 16:43:41 +07:00
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@submit="
|
|
|
|
|
async (v) => {
|
|
|
|
|
if (modal) {
|
|
|
|
|
imageUrl = v;
|
|
|
|
|
imageDialog = false;
|
|
|
|
|
} else {
|
|
|
|
|
refreshImageState = true;
|
|
|
|
|
formData.selectedImage = v;
|
|
|
|
|
imageList ? (imageList.selectedImage = v) : '';
|
|
|
|
|
imageUrl = `${baseUrl}/branch/${currentId && currentId}/image/${v}`;
|
|
|
|
|
await onSubmit(true);
|
|
|
|
|
imageDialog = false;
|
|
|
|
|
refreshImageState = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-08-02 03:52:56 +00:00
|
|
|
>
|
2024-09-11 16:43:41 +07:00
|
|
|
<template #title>
|
|
|
|
|
<span v-if="!modal" class="justify-center flex text-bold">
|
|
|
|
|
{{ $t('general.image') }}
|
|
|
|
|
{{ changeTitle(formType, formTypeBranch) }}
|
|
|
|
|
{{ $i18n.locale === 'eng' ? formData.nameEN : formData.name }}
|
|
|
|
|
</span>
|
|
|
|
|
</template>
|
2024-08-02 03:52:56 +00:00
|
|
|
<template #error>
|
|
|
|
|
<div class="full-height full-width" style="background: white">
|
|
|
|
|
<div
|
|
|
|
|
class="full-height full-width flex justify-center items-center"
|
2024-08-08 04:17:47 +00:00
|
|
|
:style="`background: hsla(var(${
|
|
|
|
|
formTypeBranch === 'headOffice'
|
|
|
|
|
? '--pink-6'
|
2024-09-09 14:26:14 +07:00
|
|
|
: formData.virtual
|
|
|
|
|
? '--blue-6'
|
|
|
|
|
: $q.dark.isActive
|
|
|
|
|
? '--violet-10'
|
|
|
|
|
: '--violet-11'
|
2024-08-08 04:17:47 +00:00
|
|
|
}-hsl)/0.15)`"
|
2024-08-02 03:52:56 +00:00
|
|
|
>
|
|
|
|
|
<q-icon
|
2024-09-09 14:26:14 +07:00
|
|
|
size="3rem"
|
2024-08-02 03:52:56 +00:00
|
|
|
name="mdi-office-building-outline"
|
2024-08-08 04:17:47 +00:00
|
|
|
:style="`color: hsla(var(${
|
|
|
|
|
formTypeBranch === 'headOffice'
|
|
|
|
|
? '--pink-6'
|
2024-09-09 14:26:14 +07:00
|
|
|
: formData.virtual
|
|
|
|
|
? '--blue-6'
|
|
|
|
|
: $q.dark.isActive
|
|
|
|
|
? '--violet-10'
|
|
|
|
|
: '--violet-11'
|
2024-08-08 04:17:47 +00:00
|
|
|
}-hsl)/1)`"
|
2024-08-02 03:52:56 +00:00
|
|
|
></q-icon>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</ImageUploadDialog>
|
2024-09-03 18:15:45 +07:00
|
|
|
|
|
|
|
|
<DialogForm
|
|
|
|
|
v-model:modal="modelCreateTypeBranch"
|
|
|
|
|
:title="$t('general.typeBranch')"
|
|
|
|
|
hide-footer
|
|
|
|
|
no-app-box
|
2024-09-04 14:41:25 +07:00
|
|
|
width="40vw"
|
2024-09-06 11:11:28 +07:00
|
|
|
height="250px"
|
2024-09-03 18:15:45 +07:00
|
|
|
:close="() => (modelCreateTypeBranch = false)"
|
|
|
|
|
>
|
2024-09-06 11:11:28 +07:00
|
|
|
<div class="full-height row q-pa-md" style="gap: 16px">
|
2024-09-03 18:15:45 +07:00
|
|
|
<ItemCard
|
2024-09-06 11:11:28 +07:00
|
|
|
v-for="(value, index) in typeBranchItem"
|
|
|
|
|
class="col full-height"
|
|
|
|
|
:key="value.text"
|
|
|
|
|
:icon="value.icon"
|
|
|
|
|
:text="value.text"
|
|
|
|
|
:icon-color="value.iconColor"
|
|
|
|
|
:bg-color="value.color"
|
|
|
|
|
:index="index"
|
2024-09-03 18:15:45 +07:00
|
|
|
@trigger="
|
|
|
|
|
() => {
|
|
|
|
|
modelCreateTypeBranch = false;
|
|
|
|
|
|
2024-09-06 17:25:06 +07:00
|
|
|
if (value.text === $t('branch.card.branchVirtual')) {
|
2024-09-03 18:15:45 +07:00
|
|
|
formData.virtual = true;
|
|
|
|
|
} else {
|
|
|
|
|
formData.virtual = false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-04 13:02:00 +07:00
|
|
|
triggerCreate(
|
|
|
|
|
'subBranch',
|
|
|
|
|
currentEdit.id || currentHq.id,
|
|
|
|
|
currentEdit.code || currentHq.code,
|
|
|
|
|
);
|
2024-09-03 18:15:45 +07:00
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</DialogForm>
|
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
|
|
|
}
|
|
|
|
|
}
|
2024-07-04 17:56:37 +07:00
|
|
|
|
|
|
|
|
.branch-card__hq {
|
|
|
|
|
--_branch-card-bg: var(--pink-6-hsl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.branch-card__br {
|
|
|
|
|
--_branch-card-bg: var(--violet-11-hsl);
|
|
|
|
|
|
|
|
|
|
&.branch-card__dark {
|
|
|
|
|
--_branch-card-bg: var(--violet-10-hsl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-06 17:25:06 +07:00
|
|
|
.branch-card__br-virtual {
|
|
|
|
|
--_branch-card-bg: var(--blue-6-hsl);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-04 17:56:37 +07:00
|
|
|
.status-active {
|
|
|
|
|
--_branch-status-color: var(--green-6-hsl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.status-inactive {
|
|
|
|
|
--_branch-status-color: var(--red-4-hsl);
|
|
|
|
|
--_branch-badge-bg: var(--red-4-hsl);
|
|
|
|
|
filter: grayscale(1);
|
|
|
|
|
opacity: 0.5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.branch-card__icon {
|
|
|
|
|
background-color: hsla(var(--_branch-card-bg) / 0.15);
|
|
|
|
|
border-radius: 50%;
|
2024-08-06 13:46:09 +07:00
|
|
|
padding: var(--size-2);
|
2024-07-04 17:56:37 +07:00
|
|
|
position: relative;
|
2024-08-06 13:46:09 +07:00
|
|
|
width: 3rem;
|
2024-07-04 17:56:37 +07:00
|
|
|
transform: rotate(45deg);
|
2024-08-06 13:46:09 +07:00
|
|
|
aspect-ratio: 1;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
2024-07-04 17:56:37 +07:00
|
|
|
|
2024-09-03 13:23:52 +07:00
|
|
|
/* &::after {
|
2024-07-04 17:56:37 +07:00
|
|
|
content: ' ';
|
|
|
|
|
display: block;
|
|
|
|
|
block-size: 0.5rem;
|
|
|
|
|
aspect-ratio: 1;
|
|
|
|
|
position: absolute;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
right: -0.25rem;
|
|
|
|
|
top: calc(50% - 0.25rem);
|
|
|
|
|
bottom: calc(50% - 0.25rem);
|
|
|
|
|
background-color: hsla(var(--_branch-status-color) / 1);
|
2024-09-03 13:23:52 +07:00
|
|
|
} */
|
2024-07-04 17:56:37 +07:00
|
|
|
|
|
|
|
|
& :deep(.q-icon) {
|
|
|
|
|
transform: rotate(-45deg);
|
|
|
|
|
color: hsla(var(--_branch-card-bg) / 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-05 03:39:41 +00:00
|
|
|
|
|
|
|
|
.slide-enter-active {
|
|
|
|
|
transition: all 0.1s ease-out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.slide-leave-active {
|
|
|
|
|
transition: all 0.1s cubic-bezier(1, 0.5, 0.8, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.slide-enter-from,
|
|
|
|
|
.slide-leave-to {
|
|
|
|
|
transform: translateY(-20px);
|
|
|
|
|
opacity: 0;
|
|
|
|
|
}
|
2024-07-23 02:26:15 +00:00
|
|
|
|
|
|
|
|
* :deep(.q-icon.mdi-play) {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
2024-09-04 14:41:25 +07:00
|
|
|
|
|
|
|
|
.badge-virtual {
|
|
|
|
|
--_badge-fg: var(--blue-8-hsl);
|
|
|
|
|
--_badge-bg: var(--blue-6-hsl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.badge-branch {
|
|
|
|
|
--_badge-fg: var(--purple-8-hsl);
|
|
|
|
|
--_badge-bg: var(--purple-6-hsl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.badge-color {
|
|
|
|
|
color: hsl(var(--_badge-fg));
|
|
|
|
|
background-color: hsla(var(--_badge-bg) / 0.1);
|
|
|
|
|
}
|
2024-04-05 18:00:30 +07:00
|
|
|
</style>
|