2024-04-02 17:47:32 +07:00
|
|
|
<script setup lang="ts">
|
2024-04-09 16:47:52 +07:00
|
|
|
import { storeToRefs } from 'pinia';
|
2024-04-05 18:14:53 +07:00
|
|
|
import { ref, onMounted } from 'vue';
|
|
|
|
|
import { Icon } from '@iconify/vue';
|
2024-04-05 18:00:30 +07:00
|
|
|
|
2024-04-05 18:14:53 +07:00
|
|
|
import useBranchStore from 'stores/branch';
|
2024-04-10 16:02:28 +07:00
|
|
|
import useBranchContactStore from 'stores/branch-contact';
|
2024-04-02 17:47:32 +07:00
|
|
|
import AppBox from 'components/app/AppBox.vue';
|
2024-04-10 20:26:32 +07:00
|
|
|
import AddButton from 'components/AddButton.vue';
|
2024-04-05 18:14:53 +07:00
|
|
|
import TooltipComponent from 'components/TooltipComponent.vue';
|
|
|
|
|
import StatCardComponent from 'components/StatCardComponent.vue';
|
2024-04-09 15:54:47 +07:00
|
|
|
import CardDetailsComponent from 'src/components/01_branch-management/CardDetailsComponent.vue';
|
2024-04-10 18:49:41 +07:00
|
|
|
import DetailBranchDrawerComponent from 'src/components/01_branch-management/DetailBranchDrawerComponent.vue';
|
2024-04-09 15:55:15 +07:00
|
|
|
import FormDialog from 'src/components/FormDialog.vue';
|
2024-04-10 09:46:30 +07:00
|
|
|
import TableCardComponent from 'src/components/01_branch-management/TableCardComponent.vue';
|
2024-04-10 19:35:00 +07:00
|
|
|
import { dialog } from 'src/stores/utils';
|
2024-04-05 18:00:30 +07:00
|
|
|
|
2024-04-10 16:02:28 +07:00
|
|
|
import { BranchContactCreate } from 'src/stores/branch-contact/types';
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
BranchWithChildren,
|
|
|
|
|
Branch,
|
|
|
|
|
BranchCreate,
|
|
|
|
|
} from 'src/stores/branch/types';
|
2024-04-09 15:54:47 +07:00
|
|
|
|
2024-04-10 18:49:41 +07:00
|
|
|
const profileFile = ref<File | undefined>(undefined);
|
|
|
|
|
const inputFile = document.createElement('input');
|
|
|
|
|
inputFile.type = 'file';
|
|
|
|
|
inputFile.accept = 'image/*';
|
|
|
|
|
|
|
|
|
|
inputFile.addEventListener('change', (e) => {
|
|
|
|
|
profileFile.value = (e.currentTarget as HTMLInputElement).files?.[0];
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-09 15:54:47 +07:00
|
|
|
const branchStore = useBranchStore();
|
2024-04-10 16:02:28 +07:00
|
|
|
const branchContactStore = useBranchContactStore();
|
|
|
|
|
|
2024-04-09 16:47:52 +07:00
|
|
|
const { data: branchData } = storeToRefs(branchStore);
|
2024-04-05 18:00:30 +07:00
|
|
|
|
2024-04-09 15:54:47 +07:00
|
|
|
const modal = ref<boolean>(false);
|
|
|
|
|
|
2024-04-11 14:41:29 +07:00
|
|
|
const currentHeadOfficeId = ref<string>();
|
|
|
|
|
const currentHeadOfficeName = ref<{
|
|
|
|
|
nameTh: string;
|
|
|
|
|
nameEn: string;
|
|
|
|
|
}>({ nameTh: '', nameEn: '' });
|
2024-04-10 16:02:28 +07:00
|
|
|
const currentBranchIdEdit = ref<string>('');
|
|
|
|
|
const currentBranchContactIdEdit = ref<string>('');
|
2024-04-10 09:46:30 +07:00
|
|
|
const showCurrentBranch = ref<Branch>();
|
2024-04-09 15:54:47 +07:00
|
|
|
|
2024-04-05 18:00:30 +07:00
|
|
|
const shape = ref<boolean>(false);
|
2024-04-10 17:41:22 +07:00
|
|
|
const openBranchDrawer = ref<boolean>(false);
|
2024-04-10 09:46:30 +07:00
|
|
|
const openCardDetails = ref<boolean>(false);
|
|
|
|
|
const openTableCard = ref<boolean>(true);
|
2024-04-05 18:00:30 +07:00
|
|
|
|
2024-04-11 12:12:16 +07:00
|
|
|
const formDialogRef = ref();
|
2024-04-05 18:00:30 +07:00
|
|
|
const inputSelectBranch = ref<string>('ทั้งหมด');
|
|
|
|
|
const inputFilter = ref<string>('คอลัมน์');
|
|
|
|
|
const inputSearch = ref<string>('');
|
|
|
|
|
const optionsBranch: string[] = ['ทั้งหมด', 'สำนักงานใหญ่', 'สาขา'];
|
|
|
|
|
const optionsFilter: string[] = [
|
|
|
|
|
'ชื่อสาขา',
|
|
|
|
|
'ที่อยู่',
|
|
|
|
|
'เบอร์โทร',
|
|
|
|
|
'สำนักงานใหญ่',
|
|
|
|
|
'ประเภท',
|
|
|
|
|
'สถานะ',
|
|
|
|
|
];
|
|
|
|
|
|
2024-04-10 18:49:41 +07:00
|
|
|
const urlQrCode = ref<string | boolean>(false);
|
2024-04-10 16:02:28 +07:00
|
|
|
const formDataContact = ref<BranchContactCreate>({
|
|
|
|
|
lineId: '',
|
|
|
|
|
telephoneNo: '',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const formType = ref<'edit' | 'create' | 'delete'>('create');
|
|
|
|
|
const typeBranch = ref<'headOffice' | 'subBranch'>('headOffice');
|
|
|
|
|
const inputCode = ref<string>('');
|
|
|
|
|
const formData = ref<BranchCreate>({
|
|
|
|
|
taxNo: '',
|
|
|
|
|
nameEN: '',
|
|
|
|
|
name: '',
|
|
|
|
|
addressEN: '',
|
|
|
|
|
address: '',
|
|
|
|
|
zipCode: '',
|
2024-04-09 15:55:15 +07:00
|
|
|
email: '',
|
2024-04-10 16:02:28 +07:00
|
|
|
telephoneNo: '',
|
|
|
|
|
longitude: '',
|
|
|
|
|
latitude: '',
|
|
|
|
|
subDistrictId: '',
|
|
|
|
|
districtId: '',
|
|
|
|
|
provinceId: '',
|
|
|
|
|
headOfficeId: null,
|
2024-04-09 15:55:15 +07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const selected = ref<string>('');
|
|
|
|
|
|
2024-04-05 18:00:30 +07:00
|
|
|
const expanded = ref<string[]>([]);
|
|
|
|
|
|
2024-04-10 20:44:46 +07:00
|
|
|
const branchStats = ref<{ amount: number; label: string }[]>([]);
|
2024-04-05 18:00:30 +07:00
|
|
|
|
2024-04-09 15:54:47 +07:00
|
|
|
const treeData = ref<BranchWithChildren[]>([]);
|
|
|
|
|
|
2024-04-10 09:46:30 +07:00
|
|
|
const subBranch = ref<boolean>(false);
|
|
|
|
|
const rowsBranch = ref<
|
|
|
|
|
{
|
2024-04-10 17:22:33 +07:00
|
|
|
id: string;
|
2024-04-10 09:46:30 +07:00
|
|
|
name: string;
|
|
|
|
|
branchName: string;
|
|
|
|
|
address: string;
|
|
|
|
|
telephoneNo: string;
|
|
|
|
|
code: string;
|
|
|
|
|
type: boolean;
|
|
|
|
|
status: string;
|
|
|
|
|
}[]
|
|
|
|
|
>([]);
|
|
|
|
|
|
2024-04-10 16:02:28 +07:00
|
|
|
function clearData() {
|
|
|
|
|
formData.value = {
|
|
|
|
|
taxNo: '',
|
|
|
|
|
nameEN: '',
|
|
|
|
|
name: '',
|
|
|
|
|
addressEN: '',
|
|
|
|
|
address: '',
|
|
|
|
|
zipCode: '',
|
|
|
|
|
email: '',
|
|
|
|
|
telephoneNo: '',
|
|
|
|
|
longitude: '',
|
|
|
|
|
latitude: '',
|
|
|
|
|
subDistrictId: '',
|
|
|
|
|
districtId: '',
|
|
|
|
|
provinceId: '',
|
|
|
|
|
headOfficeId: null,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
formDataContact.value = {
|
|
|
|
|
lineId: '',
|
|
|
|
|
telephoneNo: '',
|
|
|
|
|
};
|
2024-04-10 18:49:41 +07:00
|
|
|
|
|
|
|
|
profileFile.value = undefined;
|
2024-04-10 19:35:00 +07:00
|
|
|
urlQrCode.value = false;
|
2024-04-10 16:02:28 +07:00
|
|
|
}
|
2024-04-09 15:55:15 +07:00
|
|
|
function openDialog() {
|
|
|
|
|
modal.value = true;
|
|
|
|
|
}
|
2024-04-09 15:54:47 +07:00
|
|
|
|
|
|
|
|
async function getTree() {
|
|
|
|
|
const result = await branchStore.fetchList<BranchWithChildren>({
|
|
|
|
|
tree: true,
|
|
|
|
|
});
|
2024-04-10 16:02:28 +07:00
|
|
|
|
2024-04-10 09:46:30 +07:00
|
|
|
if (result) {
|
|
|
|
|
treeData.value = result.result;
|
|
|
|
|
rowsBranch.value = treeData.value
|
|
|
|
|
.filter((v) => v.isHeadOffice)
|
|
|
|
|
.map((v) => ({
|
2024-04-10 17:22:33 +07:00
|
|
|
id: v.id,
|
|
|
|
|
name: v.code,
|
2024-04-10 09:46:30 +07:00
|
|
|
branchName: v.name,
|
|
|
|
|
address: v.address,
|
|
|
|
|
telephoneNo: v.telephoneNo,
|
|
|
|
|
code: v.code,
|
|
|
|
|
type: v.isHeadOffice,
|
|
|
|
|
status: v.status.toString(),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
subBranch.value = false;
|
2024-04-11 14:41:29 +07:00
|
|
|
showCurrentBranch.value = undefined;
|
|
|
|
|
currentHeadOfficeId.value = undefined;
|
2024-04-10 09:46:30 +07:00
|
|
|
}
|
2024-04-09 15:54:47 +07:00
|
|
|
}
|
|
|
|
|
|
2024-04-10 16:02:28 +07:00
|
|
|
function changeSubject(
|
|
|
|
|
formType: 'edit' | 'create' | 'delete',
|
|
|
|
|
typeBranch: 'headOffice' | 'subBranch',
|
|
|
|
|
) {
|
|
|
|
|
if (typeBranch === 'headOffice') {
|
2024-04-11 11:46:42 +07:00
|
|
|
return formType === 'create' ? 'เพิ่มสำนักงานใหญ่' : 'แก้ไขสำนักงานใหญ่';
|
2024-04-10 16:02:28 +07:00
|
|
|
}
|
|
|
|
|
if (typeBranch === 'subBranch') {
|
2024-04-11 11:46:42 +07:00
|
|
|
return formType === 'create' ? 'เพิ่มสาขา' : 'แก้ไขสาขา';
|
2024-04-10 16:02:28 +07:00
|
|
|
}
|
2024-04-11 11:46:42 +07:00
|
|
|
return '';
|
2024-04-10 16:02:28 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function triggerCreateSubBranch(code: string, id: string) {
|
|
|
|
|
clearData();
|
|
|
|
|
formType.value = 'create';
|
|
|
|
|
typeBranch.value = 'subBranch';
|
|
|
|
|
inputCode.value = code;
|
|
|
|
|
formData.value.headOfficeId = id;
|
|
|
|
|
openDialog();
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-11 12:12:16 +07:00
|
|
|
async function triggerEditSubBranch(code: string, id: string) {
|
|
|
|
|
await clearData();
|
2024-04-10 16:02:28 +07:00
|
|
|
formType.value = 'edit';
|
|
|
|
|
typeBranch.value = 'subBranch';
|
|
|
|
|
inputCode.value = code;
|
|
|
|
|
formData.value.headOfficeId = id;
|
|
|
|
|
currentBranchIdEdit.value = id;
|
2024-04-11 12:12:16 +07:00
|
|
|
await fetchFormEditBranch(id);
|
|
|
|
|
await fetchFormEditBranchContact(id);
|
|
|
|
|
await formDialogRef.value.fetchDistrict(formData.value.provinceId);
|
|
|
|
|
await formDialogRef.value.fetchSubDistrict(formData.value.districtId);
|
2024-04-10 16:02:28 +07:00
|
|
|
openDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function triggerDeleteSubBranch(id: string) {
|
|
|
|
|
clearData();
|
|
|
|
|
formType.value = 'delete';
|
|
|
|
|
typeBranch.value = 'subBranch';
|
|
|
|
|
formData.value.headOfficeId = id;
|
2024-04-10 19:35:00 +07:00
|
|
|
dialog({
|
|
|
|
|
color: 'negative',
|
|
|
|
|
icon: 'mdi-alert',
|
|
|
|
|
title: 'ยืนยังการลบข้อมูล',
|
|
|
|
|
actionText: 'ตกลง',
|
|
|
|
|
persistent: true,
|
|
|
|
|
message: 'ท่านต้องการลบข้อมูลหรือมั้ย',
|
|
|
|
|
action: async () => {
|
|
|
|
|
await deleteForm(id);
|
|
|
|
|
await getTree();
|
|
|
|
|
},
|
|
|
|
|
cancel: () => {},
|
|
|
|
|
});
|
2024-04-10 16:02:28 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function triggerCreateHeadOffice() {
|
|
|
|
|
clearData();
|
|
|
|
|
formType.value = 'create';
|
|
|
|
|
typeBranch.value = 'headOffice';
|
|
|
|
|
openDialog();
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-11 12:12:16 +07:00
|
|
|
async function triggerEditHeadOffice(id: string) {
|
|
|
|
|
await clearData();
|
2024-04-10 16:02:28 +07:00
|
|
|
formType.value = 'edit';
|
|
|
|
|
typeBranch.value = 'headOffice';
|
|
|
|
|
currentBranchIdEdit.value = id;
|
2024-04-11 12:12:16 +07:00
|
|
|
await fetchFormEditBranch(id);
|
|
|
|
|
await fetchFormEditBranchContact(id);
|
|
|
|
|
|
|
|
|
|
await formDialogRef.value.fetchDistrict(formData.value.provinceId);
|
|
|
|
|
await formDialogRef.value.fetchSubDistrict(formData.value.districtId);
|
|
|
|
|
|
2024-04-10 16:02:28 +07:00
|
|
|
openDialog();
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-10 19:35:00 +07:00
|
|
|
function triggerDeleteHeadOffice(id: string) {
|
2024-04-10 16:02:28 +07:00
|
|
|
clearData();
|
|
|
|
|
formType.value = 'delete';
|
|
|
|
|
typeBranch.value = 'headOffice';
|
2024-04-10 19:35:00 +07:00
|
|
|
|
|
|
|
|
dialog({
|
|
|
|
|
color: 'negative',
|
|
|
|
|
icon: 'mdi-alert',
|
|
|
|
|
title: 'ยืนยังการลบข้อมูล',
|
|
|
|
|
actionText: 'ตกลง',
|
|
|
|
|
persistent: true,
|
|
|
|
|
message: 'ท่านต้องการลบข้อมูลหรือมั้ย',
|
|
|
|
|
action: async () => {
|
|
|
|
|
await deleteForm(id);
|
|
|
|
|
await getTree();
|
|
|
|
|
},
|
|
|
|
|
cancel: () => {},
|
|
|
|
|
});
|
2024-04-10 16:02:28 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function fetchFormEditBranch(id: string) {
|
|
|
|
|
const result = await branchStore.fetchById<Branch>(id);
|
2024-04-11 14:56:01 +07:00
|
|
|
|
2024-04-10 16:02:28 +07:00
|
|
|
if (result) {
|
|
|
|
|
formData.value = {
|
|
|
|
|
taxNo: result.taxNo,
|
|
|
|
|
nameEN: result.nameEN,
|
|
|
|
|
name: result.name,
|
|
|
|
|
addressEN: result.addressEN,
|
|
|
|
|
address: result.address,
|
|
|
|
|
zipCode: result.zipCode,
|
|
|
|
|
email: result.email,
|
|
|
|
|
telephoneNo: result.telephoneNo,
|
|
|
|
|
longitude: result.longitude,
|
|
|
|
|
latitude: result.latitude,
|
|
|
|
|
subDistrictId: result.subDistrictId,
|
|
|
|
|
districtId: result.districtId,
|
|
|
|
|
provinceId: result.provinceId,
|
|
|
|
|
headOfficeId: result.headOfficeId,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-10 19:35:00 +07:00
|
|
|
async function deleteForm(idBranch: string) {
|
|
|
|
|
await fetchFormEditBranchContact(idBranch);
|
|
|
|
|
await branchContactStore.deleteById(
|
|
|
|
|
idBranch,
|
|
|
|
|
currentBranchContactIdEdit.value,
|
|
|
|
|
);
|
|
|
|
|
await branchStore.deleteById(idBranch);
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-10 16:02:28 +07:00
|
|
|
async function fetchFormEditBranchContact(id: string) {
|
|
|
|
|
const result = await branchContactStore.fetchList(id);
|
|
|
|
|
|
|
|
|
|
if (result) {
|
2024-04-11 14:56:01 +07:00
|
|
|
const first = result.result.pop();
|
|
|
|
|
|
|
|
|
|
if (!first) return;
|
|
|
|
|
|
|
|
|
|
currentBranchContactIdEdit.value = first.id;
|
|
|
|
|
urlQrCode.value = first.qrCodeImageUrl;
|
2024-04-10 16:02:28 +07:00
|
|
|
formDataContact.value = {
|
2024-04-11 14:56:01 +07:00
|
|
|
lineId: first.lineId,
|
|
|
|
|
telephoneNo: first.telephoneNo,
|
2024-04-10 16:02:28 +07:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function submitForm(
|
|
|
|
|
typeSubmit: 'create' | 'edit' | 'delete',
|
|
|
|
|
formTypeSubmit: 'headOffice' | 'subBranch',
|
|
|
|
|
inputBranchCreate: BranchCreate,
|
|
|
|
|
inputBranchContactCreate: BranchContactCreate,
|
|
|
|
|
) {
|
|
|
|
|
if (formTypeSubmit === 'headOffice') {
|
|
|
|
|
if (typeSubmit === 'create') {
|
|
|
|
|
const result = await branchStore.create(inputBranchCreate);
|
|
|
|
|
if (result) {
|
2024-04-10 18:49:41 +07:00
|
|
|
await branchContactStore.create(
|
|
|
|
|
result.id,
|
|
|
|
|
inputBranchContactCreate,
|
2024-04-11 11:46:42 +07:00
|
|
|
profileFile.value,
|
2024-04-10 18:49:41 +07:00
|
|
|
);
|
2024-04-10 16:02:28 +07:00
|
|
|
getTree();
|
|
|
|
|
modal.value = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (typeSubmit === 'edit') {
|
|
|
|
|
await branchStore.editById(currentBranchIdEdit.value, inputBranchCreate);
|
2024-04-11 14:56:01 +07:00
|
|
|
|
|
|
|
|
if (currentBranchIdEdit.value && currentBranchContactIdEdit.value) {
|
|
|
|
|
await branchContactStore.editById(
|
|
|
|
|
currentBranchIdEdit.value,
|
|
|
|
|
currentBranchContactIdEdit.value,
|
|
|
|
|
inputBranchContactCreate,
|
|
|
|
|
profileFile.value ? profileFile.value : undefined,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
await branchContactStore.create(
|
|
|
|
|
currentBranchIdEdit.value,
|
|
|
|
|
inputBranchContactCreate,
|
|
|
|
|
profileFile.value ? profileFile.value : undefined,
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-04-10 16:02:28 +07:00
|
|
|
|
|
|
|
|
getTree();
|
|
|
|
|
modal.value = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (formTypeSubmit === 'subBranch') {
|
|
|
|
|
if (typeSubmit === 'create') {
|
|
|
|
|
const result = await branchStore.create(inputBranchCreate);
|
|
|
|
|
if (result) {
|
2024-04-10 18:49:41 +07:00
|
|
|
await branchContactStore.create(
|
|
|
|
|
result.id,
|
|
|
|
|
inputBranchContactCreate,
|
2024-04-11 11:46:42 +07:00
|
|
|
profileFile.value,
|
2024-04-10 18:49:41 +07:00
|
|
|
);
|
2024-04-10 16:02:28 +07:00
|
|
|
getTree();
|
|
|
|
|
modal.value = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (typeSubmit === 'edit') {
|
|
|
|
|
await branchStore.editById(currentBranchIdEdit.value, inputBranchCreate);
|
|
|
|
|
await branchContactStore.editById(
|
|
|
|
|
currentBranchIdEdit.value,
|
|
|
|
|
currentBranchContactIdEdit.value,
|
|
|
|
|
inputBranchContactCreate,
|
2024-04-10 19:35:00 +07:00
|
|
|
profileFile.value ? profileFile.value : undefined,
|
2024-04-10 16:02:28 +07:00
|
|
|
);
|
|
|
|
|
getTree();
|
|
|
|
|
modal.value = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-11 09:43:48 +07:00
|
|
|
async function fetchCard(id: string, drawer = false) {
|
2024-04-10 09:46:30 +07:00
|
|
|
const result = await branchStore.fetchById<Branch>(id);
|
|
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
|
showCurrentBranch.value = result;
|
2024-04-11 09:43:48 +07:00
|
|
|
|
|
|
|
|
if (drawer) openBranchDrawer.value = true;
|
|
|
|
|
else {
|
|
|
|
|
openCardDetails.value = true;
|
|
|
|
|
openTableCard.value = false;
|
|
|
|
|
}
|
2024-04-09 15:54:47 +07:00
|
|
|
}
|
|
|
|
|
}
|
2024-04-11 09:43:48 +07:00
|
|
|
|
2024-04-10 09:46:30 +07:00
|
|
|
async function fetchSubBranch(id: string) {
|
|
|
|
|
const result = await branchStore.fetchById<BranchWithChildren>(id, {
|
|
|
|
|
includeSubBranch: true,
|
|
|
|
|
});
|
2024-04-09 15:54:47 +07:00
|
|
|
|
2024-04-10 09:46:30 +07:00
|
|
|
if (result) {
|
2024-04-11 14:41:29 +07:00
|
|
|
if (result.isHeadOffice) {
|
|
|
|
|
currentHeadOfficeId.value = result.id;
|
|
|
|
|
currentHeadOfficeName.value = {
|
|
|
|
|
nameTh: result.name,
|
|
|
|
|
nameEn: result.nameEN,
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-04-10 09:46:30 +07:00
|
|
|
rowsBranch.value = result.branch.map((v) => ({
|
2024-04-10 17:22:33 +07:00
|
|
|
id: v.id,
|
|
|
|
|
name: v.code,
|
2024-04-10 09:46:30 +07:00
|
|
|
branchName: v.name,
|
|
|
|
|
address: v.address,
|
|
|
|
|
telephoneNo: v.telephoneNo,
|
|
|
|
|
code: v.code,
|
|
|
|
|
type: v.isHeadOffice,
|
|
|
|
|
status: v.status,
|
|
|
|
|
}));
|
2024-04-11 14:41:29 +07:00
|
|
|
|
|
|
|
|
showCurrentBranch.value = undefined;
|
2024-04-10 09:46:30 +07:00
|
|
|
subBranch.value = true;
|
|
|
|
|
openCardDetails.value = false;
|
|
|
|
|
openTableCard.value = true;
|
2024-04-09 15:54:47 +07:00
|
|
|
}
|
2024-04-10 09:46:30 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
getTree();
|
2024-04-10 17:41:22 +07:00
|
|
|
const result = await branchStore.stats();
|
|
|
|
|
|
|
|
|
|
if (result) {
|
2024-04-10 20:44:46 +07:00
|
|
|
branchStats.value.push({
|
2024-04-10 17:41:22 +07:00
|
|
|
amount: result.hq,
|
|
|
|
|
label: 'branchHQLabel',
|
|
|
|
|
});
|
2024-04-10 20:44:46 +07:00
|
|
|
branchStats.value.push({
|
2024-04-10 17:41:22 +07:00
|
|
|
amount: result.br,
|
|
|
|
|
label: 'branchLabel',
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-04-05 18:00:30 +07:00
|
|
|
});
|
2024-04-02 17:47:32 +07:00
|
|
|
</script>
|
|
|
|
|
<template>
|
|
|
|
|
<div class="column">
|
2024-04-03 14:55:37 +07:00
|
|
|
<div class="row text-h6 text-weight-bold q-mb-md">
|
|
|
|
|
{{ $t('branchManagement') }}
|
|
|
|
|
</div>
|
2024-04-02 17:47:32 +07:00
|
|
|
|
2024-04-09 16:47:52 +07:00
|
|
|
<AppBox
|
2024-04-05 18:00:30 +07:00
|
|
|
bordered
|
|
|
|
|
class="q-mb-md"
|
|
|
|
|
:class="{ 'bg-card-branch-title': $q.dark.isActive }"
|
|
|
|
|
>
|
2024-04-11 09:43:48 +07:00
|
|
|
<StatCardComponent :branch="branchStats" :dark="$q.dark.isActive" />
|
2024-04-09 16:47:52 +07:00
|
|
|
</AppBox>
|
2024-04-03 15:23:59 +07:00
|
|
|
|
2024-04-09 17:21:34 +07:00
|
|
|
<AppBox bordered style="width: 100%" v-if="!branchData?.total">
|
|
|
|
|
<div class="column">
|
2024-04-02 17:47:32 +07:00
|
|
|
<div class="col-1 self-end">
|
2024-04-09 16:47:52 +07:00
|
|
|
<TooltipComponent
|
|
|
|
|
title="branchNoMainOfficeYet"
|
|
|
|
|
caption="branchClickToCreateMainOffice"
|
|
|
|
|
imgSrc="img-table-"
|
|
|
|
|
/>
|
2024-04-02 17:47:32 +07:00
|
|
|
</div>
|
2024-04-09 16:47:52 +07:00
|
|
|
<div class="col self-center" style="display: flex; align-items: center">
|
2024-04-10 20:26:32 +07:00
|
|
|
<AddButton
|
2024-04-02 17:47:32 +07:00
|
|
|
:label="'สร้างสำนักงานใหญ่'"
|
2024-04-09 15:54:47 +07:00
|
|
|
@trigger="() => openDialog()"
|
2024-04-02 17:47:32 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-04-09 16:47:52 +07:00
|
|
|
</AppBox>
|
2024-04-05 18:00:30 +07:00
|
|
|
|
2024-04-09 16:47:52 +07:00
|
|
|
<AppBox
|
2024-04-09 17:21:34 +07:00
|
|
|
class="bordered branch-container no-padding"
|
2024-04-05 18:00:30 +07:00
|
|
|
:class="{ dark: $q.dark.isActive }"
|
|
|
|
|
>
|
2024-04-09 16:47:52 +07:00
|
|
|
<AppBox class="bg-card-branch-title" style="border-radius: 0">
|
2024-04-05 18:00:30 +07:00
|
|
|
<div class="row items-center">
|
2024-04-09 17:21:34 +07:00
|
|
|
<span
|
2024-04-11 14:41:29 +07:00
|
|
|
v-if="false"
|
2024-04-05 18:00:30 +07:00
|
|
|
class="col q-pl-md text-h6 text-weight-bold color-card-branch-title"
|
|
|
|
|
>
|
|
|
|
|
{{ $t('headQuarters') }}
|
2024-04-09 17:21:34 +07:00
|
|
|
</span>
|
2024-04-11 14:41:29 +07:00
|
|
|
|
|
|
|
|
<span class="col text-h7 text-weight-bold color-card-branch-title">
|
|
|
|
|
<div class="row" style="width: 300px">
|
|
|
|
|
<div class="column q-px-sm" @click="getTree()">ทั้งหมด</div>
|
|
|
|
|
<div class="column q-px-sm" v-if="currentHeadOfficeId">></div>
|
|
|
|
|
<div
|
|
|
|
|
class="column q-px-sm"
|
|
|
|
|
v-if="currentHeadOfficeId"
|
|
|
|
|
@click="fetchSubBranch(currentHeadOfficeId)"
|
|
|
|
|
>
|
|
|
|
|
{{ currentHeadOfficeName.nameTh }}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
class="column q-px-sm"
|
|
|
|
|
v-if="showCurrentBranch && !showCurrentBranch.isHeadOffice"
|
|
|
|
|
>
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
class="column q-px-sm"
|
|
|
|
|
v-if="showCurrentBranch && !showCurrentBranch.isHeadOffice"
|
|
|
|
|
>
|
|
|
|
|
{{ showCurrentBranch.code }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</span>
|
|
|
|
|
|
2024-04-05 18:00:30 +07:00
|
|
|
<div class="col-3">
|
|
|
|
|
<q-input
|
2024-04-09 16:47:52 +07:00
|
|
|
class="bordered rounded q-px-md"
|
|
|
|
|
borderless
|
2024-04-05 18:00:30 +07:00
|
|
|
dense
|
2024-04-09 16:47:52 +07:00
|
|
|
v-model="inputSearch"
|
2024-04-05 18:00:30 +07:00
|
|
|
label="ค้นหา"
|
|
|
|
|
>
|
|
|
|
|
<template #prepend>
|
2024-04-05 18:14:53 +07:00
|
|
|
<Icon icon="ic:baseline-search" />
|
2024-04-05 18:00:30 +07:00
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-04-09 16:47:52 +07:00
|
|
|
</AppBox>
|
2024-04-05 18:00:30 +07:00
|
|
|
|
2024-04-09 17:21:34 +07:00
|
|
|
<AppBox class="no-padding row bordered-t" style="border-radius: 0">
|
2024-04-09 16:47:52 +07:00
|
|
|
<div class="q-pa-md bg-branch-tree-box bordered-r" style="width: 21%">
|
2024-04-05 18:00:30 +07:00
|
|
|
<div
|
2024-04-10 16:02:28 +07:00
|
|
|
@click="triggerCreateHeadOffice()"
|
2024-04-05 18:00:30 +07:00
|
|
|
class="btn-add col-2 text-weight-bold cursor-pointer color-card-branch-btn"
|
|
|
|
|
>
|
|
|
|
|
<div class="text-h4 q-mr-md">+</div>
|
|
|
|
|
{{ $t('btnCreate') }}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<q-scroll-area
|
2024-04-09 16:47:52 +07:00
|
|
|
class="q-pa-sm bg-branch-tree-scroll"
|
2024-04-05 18:00:30 +07:00
|
|
|
style="height: 350px; width: 100%; border-radius: 6px"
|
|
|
|
|
>
|
|
|
|
|
<div class="col">
|
|
|
|
|
<q-tree
|
2024-04-09 15:54:47 +07:00
|
|
|
:nodes="treeData"
|
2024-04-05 18:00:30 +07:00
|
|
|
dense
|
2024-04-09 15:54:47 +07:00
|
|
|
node-key="name"
|
2024-04-05 18:00:30 +07:00
|
|
|
v-model:expanded="expanded"
|
2024-04-09 15:54:47 +07:00
|
|
|
v-model:selected="selected"
|
|
|
|
|
children-key="branch"
|
2024-04-05 18:00:30 +07:00
|
|
|
>
|
|
|
|
|
<template #default-header="prop">
|
|
|
|
|
<div
|
2024-04-11 14:41:29 +07:00
|
|
|
@click="
|
|
|
|
|
() => {
|
|
|
|
|
fetchSubBranch(prop.node.id);
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
!expanded.includes(prop.node.name) &&
|
|
|
|
|
expanded.length <= 1
|
|
|
|
|
) {
|
|
|
|
|
expanded.push(prop.node.name);
|
|
|
|
|
} else expanded[1] = prop.node.name;
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-04-09 17:28:59 +07:00
|
|
|
class="q-px-sm color-brach-tree-text"
|
2024-04-05 18:00:30 +07:00
|
|
|
:class="{
|
2024-04-09 15:54:47 +07:00
|
|
|
'color-tree-active': expanded.includes(prop.node.name),
|
2024-04-05 18:00:30 +07:00
|
|
|
'bg-branch-tree':
|
|
|
|
|
prop.node.isHeadOffice &&
|
2024-04-09 15:54:47 +07:00
|
|
|
expanded.includes(prop.node.name),
|
2024-04-05 18:00:30 +07:00
|
|
|
'dark-tree': $q.dark.isActive,
|
|
|
|
|
}"
|
|
|
|
|
style="border-radius: 6px"
|
|
|
|
|
>
|
2024-04-09 15:54:47 +07:00
|
|
|
{{ prop.node.name }}
|
2024-04-05 18:00:30 +07:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<q-space />
|
|
|
|
|
|
|
|
|
|
<q-btn
|
|
|
|
|
class="color-brach-tree-btn"
|
2024-04-10 16:02:28 +07:00
|
|
|
@click.stop="
|
|
|
|
|
triggerCreateSubBranch(prop.node.code, prop.node.id)
|
|
|
|
|
"
|
2024-04-05 18:00:30 +07:00
|
|
|
v-if="prop.node.isHeadOffice"
|
2024-04-09 17:28:59 +07:00
|
|
|
size="lg"
|
|
|
|
|
flat
|
|
|
|
|
square
|
2024-04-05 18:00:30 +07:00
|
|
|
dense
|
|
|
|
|
>
|
2024-04-05 18:14:53 +07:00
|
|
|
<Icon
|
2024-04-09 15:54:47 +07:00
|
|
|
v-if="expanded.includes(prop.node.name)"
|
2024-04-05 18:00:30 +07:00
|
|
|
icon="eva:file-add-fill"
|
|
|
|
|
/>
|
|
|
|
|
|
2024-04-05 18:14:53 +07:00
|
|
|
<Icon v-else icon="eva:file-add-outline" />
|
2024-04-05 18:00:30 +07:00
|
|
|
</q-btn>
|
2024-04-10 16:02:28 +07:00
|
|
|
<!-- subBranch -->
|
|
|
|
|
<q-btn
|
|
|
|
|
v-else
|
|
|
|
|
class="color-brach-tree-btn"
|
|
|
|
|
@click.stop
|
|
|
|
|
size="lg"
|
|
|
|
|
dense
|
|
|
|
|
flat
|
|
|
|
|
name="menu"
|
|
|
|
|
>
|
|
|
|
|
<Icon icon="ri:more-2-fill" width="16px" />
|
|
|
|
|
<q-menu class="bordered" style="width: 150px">
|
|
|
|
|
<q-list>
|
|
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
v-close-popup
|
|
|
|
|
dense
|
|
|
|
|
@click="
|
|
|
|
|
triggerEditSubBranch(prop.node.code, prop.node.id)
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
<q-item-section avatar class="q-py-sm">
|
|
|
|
|
<q-icon
|
|
|
|
|
style="color: hsl(var(--cyan-6-hsl))"
|
|
|
|
|
name="mdi-pencil-outline"
|
|
|
|
|
/>
|
|
|
|
|
</q-item-section>
|
|
|
|
|
<q-item-section>{{ $t('edit') }}</q-item-section>
|
|
|
|
|
</q-item>
|
|
|
|
|
|
|
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
v-close-popup
|
|
|
|
|
dense
|
|
|
|
|
@click="triggerDeleteSubBranch(prop.node.id)"
|
|
|
|
|
>
|
|
|
|
|
<q-item-section avatar class="q-py-sm">
|
|
|
|
|
<q-icon
|
|
|
|
|
style="color: hsl(var(--red-6-hsl))"
|
|
|
|
|
name="mdi-trash-can-outline"
|
|
|
|
|
/>
|
|
|
|
|
</q-item-section>
|
|
|
|
|
<q-item-section>{{ $t('delete') }}</q-item-section>
|
|
|
|
|
</q-item>
|
|
|
|
|
|
|
|
|
|
<q-item v-close-popup dense>
|
|
|
|
|
<q-item-section class="q-py-sm">
|
|
|
|
|
<div
|
|
|
|
|
class="bg-branch-tree-toggle q-pa-sm"
|
|
|
|
|
style="border-radius: 6px"
|
|
|
|
|
:class="{ 'dark-toggle': $q.dark.isActive }"
|
|
|
|
|
>
|
|
|
|
|
<q-toggle
|
|
|
|
|
dense
|
|
|
|
|
:label="$t('closedStatus')"
|
|
|
|
|
size="sm"
|
|
|
|
|
v-model="shape"
|
|
|
|
|
val="md"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</q-item-section>
|
|
|
|
|
</q-item>
|
|
|
|
|
</q-list>
|
|
|
|
|
</q-menu>
|
|
|
|
|
</q-btn>
|
2024-04-05 18:00:30 +07:00
|
|
|
|
|
|
|
|
<q-btn
|
2024-04-10 16:02:28 +07:00
|
|
|
v-if="prop.node.isHeadOffice"
|
2024-04-05 18:00:30 +07:00
|
|
|
class="color-brach-tree-btn"
|
2024-04-09 17:28:59 +07:00
|
|
|
@click.stop
|
|
|
|
|
size="lg"
|
2024-04-05 18:00:30 +07:00
|
|
|
dense
|
|
|
|
|
flat
|
|
|
|
|
name="menu"
|
|
|
|
|
>
|
2024-04-09 17:28:59 +07:00
|
|
|
<Icon icon="ri:more-2-fill" width="16px" />
|
2024-04-05 18:00:30 +07:00
|
|
|
<q-menu class="bordered" style="width: 150px">
|
2024-04-09 17:21:34 +07:00
|
|
|
<q-list>
|
2024-04-10 16:02:28 +07:00
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
v-close-popup
|
|
|
|
|
dense
|
|
|
|
|
@click="triggerEditHeadOffice(prop.node.id)"
|
|
|
|
|
>
|
2024-04-09 17:21:34 +07:00
|
|
|
<q-item-section avatar class="q-py-sm">
|
2024-04-05 18:00:30 +07:00
|
|
|
<q-icon
|
2024-04-09 17:21:34 +07:00
|
|
|
style="color: hsl(var(--cyan-6-hsl))"
|
2024-04-05 18:00:30 +07:00
|
|
|
name="mdi-pencil-outline"
|
|
|
|
|
/>
|
|
|
|
|
</q-item-section>
|
2024-04-09 17:21:34 +07:00
|
|
|
<q-item-section>{{ $t('edit') }}</q-item-section>
|
2024-04-05 18:00:30 +07:00
|
|
|
</q-item>
|
|
|
|
|
|
2024-04-10 16:02:28 +07:00
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
v-close-popup
|
|
|
|
|
dense
|
2024-04-10 19:35:00 +07:00
|
|
|
@click="triggerDeleteHeadOffice(prop.node.id)"
|
2024-04-10 16:02:28 +07:00
|
|
|
>
|
2024-04-09 17:21:34 +07:00
|
|
|
<q-item-section avatar class="q-py-sm">
|
2024-04-05 18:00:30 +07:00
|
|
|
<q-icon
|
2024-04-09 17:21:34 +07:00
|
|
|
style="color: hsl(var(--red-6-hsl))"
|
2024-04-05 18:00:30 +07:00
|
|
|
name="mdi-trash-can-outline"
|
|
|
|
|
/>
|
|
|
|
|
</q-item-section>
|
|
|
|
|
<q-item-section>{{ $t('delete') }}</q-item-section>
|
|
|
|
|
</q-item>
|
|
|
|
|
|
2024-04-09 17:21:34 +07:00
|
|
|
<q-item v-close-popup dense>
|
|
|
|
|
<q-item-section class="q-py-sm">
|
2024-04-05 18:00:30 +07:00
|
|
|
<div
|
|
|
|
|
class="bg-branch-tree-toggle q-pa-sm"
|
|
|
|
|
style="border-radius: 6px"
|
2024-04-09 17:21:34 +07:00
|
|
|
:class="{ 'dark-toggle': $q.dark.isActive }"
|
2024-04-05 18:00:30 +07:00
|
|
|
>
|
|
|
|
|
<q-toggle
|
|
|
|
|
dense
|
|
|
|
|
:label="$t('closedStatus')"
|
|
|
|
|
size="sm"
|
|
|
|
|
v-model="shape"
|
|
|
|
|
val="md"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</q-item-section>
|
|
|
|
|
</q-item>
|
|
|
|
|
</q-list>
|
|
|
|
|
</q-menu>
|
|
|
|
|
</q-btn>
|
|
|
|
|
</template>
|
|
|
|
|
</q-tree>
|
|
|
|
|
</div>
|
|
|
|
|
</q-scroll-area>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-04-10 09:46:30 +07:00
|
|
|
<div v-if="openTableCard" class="col" style="overflow-y: auto">
|
2024-04-09 16:47:52 +07:00
|
|
|
<AppBox class="q-pb-none">
|
2024-04-05 18:00:30 +07:00
|
|
|
<div class="row">
|
|
|
|
|
<div class="col">
|
|
|
|
|
<q-select
|
|
|
|
|
style="width: 150px"
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
v-model="inputSelectBranch"
|
|
|
|
|
:options="optionsBranch"
|
|
|
|
|
label="เลือก"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-04-10 18:08:01 +07:00
|
|
|
<div class="col-3">
|
2024-04-05 18:00:30 +07:00
|
|
|
<q-select
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
v-model="inputFilter"
|
|
|
|
|
:options="optionsFilter"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-04-09 16:47:52 +07:00
|
|
|
</AppBox>
|
2024-04-05 18:00:30 +07:00
|
|
|
|
2024-04-09 16:47:52 +07:00
|
|
|
<AppBox>
|
2024-04-10 09:46:30 +07:00
|
|
|
<TableCardComponent
|
2024-04-10 17:22:33 +07:00
|
|
|
@navigate="(v) => fetchSubBranch(v.id)"
|
2024-04-11 09:43:48 +07:00
|
|
|
@show-info="(v) => fetchCard(v.id, !subBranch)"
|
2024-04-10 09:46:30 +07:00
|
|
|
:sub-branch="subBranch"
|
|
|
|
|
:rows="rowsBranch"
|
|
|
|
|
/>
|
2024-04-09 16:47:52 +07:00
|
|
|
</AppBox>
|
2024-04-05 18:00:30 +07:00
|
|
|
</div>
|
|
|
|
|
|
2024-04-10 09:46:30 +07:00
|
|
|
<div
|
|
|
|
|
v-if="openCardDetails"
|
|
|
|
|
class="col bordered"
|
|
|
|
|
style="overflow-y: auto"
|
|
|
|
|
>
|
2024-04-09 15:54:47 +07:00
|
|
|
<CardDetailsComponent
|
2024-04-11 14:56:01 +07:00
|
|
|
v-if="showCurrentBranch"
|
|
|
|
|
:data="showCurrentBranch"
|
2024-04-09 15:54:47 +07:00
|
|
|
class="q-pa-sm"
|
|
|
|
|
/>
|
2024-04-05 18:00:30 +07:00
|
|
|
</div>
|
2024-04-09 16:47:52 +07:00
|
|
|
</AppBox>
|
|
|
|
|
</AppBox>
|
2024-04-02 17:47:32 +07:00
|
|
|
</div>
|
2024-04-09 15:55:15 +07:00
|
|
|
|
2024-04-10 18:49:41 +07:00
|
|
|
<DetailBranchDrawerComponent
|
2024-04-11 14:56:01 +07:00
|
|
|
@trigger-edit="
|
|
|
|
|
(v) => {
|
|
|
|
|
subBranch
|
|
|
|
|
? triggerEditSubBranch(v.code, v.id)
|
|
|
|
|
: triggerEditHeadOffice(v.id);
|
|
|
|
|
openBranchDrawer = false;
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@trigger-delete="
|
|
|
|
|
(v) => {
|
|
|
|
|
subBranch
|
|
|
|
|
? triggerDeleteSubBranch(v.id)
|
|
|
|
|
: triggerDeleteHeadOffice(v.id);
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-04-11 09:43:48 +07:00
|
|
|
v-if="showCurrentBranch"
|
2024-04-10 09:46:30 +07:00
|
|
|
v-model:open="openBranchDrawer"
|
2024-04-11 09:43:48 +07:00
|
|
|
:data="showCurrentBranch"
|
2024-04-09 15:55:15 +07:00
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<FormDialog
|
2024-04-11 12:12:16 +07:00
|
|
|
ref="formDialogRef"
|
2024-04-09 15:55:15 +07:00
|
|
|
v-model:modal="modal"
|
2024-04-10 16:02:28 +07:00
|
|
|
v-model:address="formData.address"
|
2024-04-11 11:46:42 +07:00
|
|
|
v-model:addressEN="formData.addressEN"
|
2024-04-10 16:02:28 +07:00
|
|
|
v-model:provinceId="formData.provinceId as string"
|
|
|
|
|
v-model:districtId="formData.districtId as string"
|
|
|
|
|
v-model:subDistrictId="formData.subDistrictId as string"
|
|
|
|
|
v-model:zipCode="formData.zipCode"
|
2024-04-11 11:46:42 +07:00
|
|
|
:title="changeSubject(formType, typeBranch)"
|
2024-04-10 16:02:28 +07:00
|
|
|
:submit="() => submitForm(formType, typeBranch, formData, formDataContact)"
|
2024-04-09 15:55:15 +07:00
|
|
|
>
|
|
|
|
|
<template #top>
|
|
|
|
|
<div class="row full-width">
|
|
|
|
|
<div class="col">
|
|
|
|
|
<q-input
|
2024-04-11 12:12:16 +07:00
|
|
|
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
2024-04-10 16:02:28 +07:00
|
|
|
v-model="inputCode"
|
2024-04-09 15:55:15 +07:00
|
|
|
dense
|
|
|
|
|
outlined
|
2024-04-11 12:12:16 +07:00
|
|
|
:label="$t('formDialogInputCode')"
|
2024-04-10 16:02:28 +07:00
|
|
|
readonly
|
2024-04-09 15:55:15 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col q-pl-md">
|
|
|
|
|
<q-input
|
2024-04-11 12:12:16 +07:00
|
|
|
hide-bottom-space
|
|
|
|
|
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
2024-04-10 16:02:28 +07:00
|
|
|
v-model="formData.taxNo"
|
2024-04-09 15:55:15 +07:00
|
|
|
dense
|
|
|
|
|
outlined
|
2024-04-11 12:12:16 +07:00
|
|
|
:label="$t('formDialogInputTaxNo')"
|
|
|
|
|
lazy-rules
|
|
|
|
|
:rules="[
|
|
|
|
|
(val) =>
|
|
|
|
|
(val && val.length > 0) || $t('formDialogInputTaxNoValidate'),
|
|
|
|
|
]"
|
2024-04-09 15:55:15 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="row full-width">
|
|
|
|
|
<div class="col">
|
|
|
|
|
<q-input
|
2024-04-11 12:12:16 +07:00
|
|
|
hide-bottom-space
|
|
|
|
|
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
2024-04-10 16:02:28 +07:00
|
|
|
v-model="formData.name"
|
2024-04-09 15:55:15 +07:00
|
|
|
dense
|
|
|
|
|
outlined
|
2024-04-11 12:12:16 +07:00
|
|
|
:label="
|
|
|
|
|
typeBranch === 'headOffice'
|
|
|
|
|
? $t('formDialogInputNameHq')
|
|
|
|
|
: $t('formDialogInputNameSubBranch')
|
|
|
|
|
"
|
|
|
|
|
lazy-rules
|
|
|
|
|
:rules="[(val) => val && val.length > 0]"
|
|
|
|
|
:error-message="
|
|
|
|
|
typeBranch === 'headOffice'
|
|
|
|
|
? $t('formDialogInputNameHqValidate')
|
|
|
|
|
: $t('formDialogInputNameSubBranchValidate')
|
|
|
|
|
"
|
2024-04-09 15:55:15 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col q-pl-md">
|
|
|
|
|
<q-input
|
2024-04-11 12:12:16 +07:00
|
|
|
hide-bottom-space
|
|
|
|
|
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
2024-04-10 16:02:28 +07:00
|
|
|
v-model="formData.nameEN"
|
2024-04-09 15:55:15 +07:00
|
|
|
dense
|
|
|
|
|
outlined
|
2024-04-11 12:12:16 +07:00
|
|
|
:label="
|
|
|
|
|
typeBranch === 'headOffice'
|
|
|
|
|
? $t('formDialogInputNameHqEn')
|
|
|
|
|
: $t('formDialogInputNameSubBranchEn')
|
|
|
|
|
"
|
|
|
|
|
:rules="[(val) => val && val.length > 0]"
|
|
|
|
|
:error-message="
|
|
|
|
|
typeBranch === 'headOffice'
|
|
|
|
|
? $t('formDialogInputNameHqEnValidate')
|
|
|
|
|
: $t('formDialogInputNameSubBranchEnValidate')
|
|
|
|
|
"
|
2024-04-09 15:55:15 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template #append>
|
2024-04-11 12:12:16 +07:00
|
|
|
<AppBox
|
|
|
|
|
class="q-mt-md branch-form-input-Contact"
|
|
|
|
|
:class="{ 'dark-form-input-Contact': $q.dark.isActive }"
|
|
|
|
|
>
|
2024-04-09 15:55:15 +07:00
|
|
|
<div class="row q-mb-md">
|
|
|
|
|
<div class="col">
|
|
|
|
|
<q-input
|
2024-04-11 12:12:16 +07:00
|
|
|
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
|
|
|
|
hide-bottom-space
|
2024-04-10 16:02:28 +07:00
|
|
|
v-model="formDataContact.telephoneNo"
|
2024-04-09 15:55:15 +07:00
|
|
|
dense
|
|
|
|
|
outlined
|
2024-04-11 12:12:16 +07:00
|
|
|
:label="$t('formDialogInputTelephoneContact')"
|
2024-04-09 15:55:15 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col q-pl-md">
|
2024-04-10 16:02:28 +07:00
|
|
|
<q-input
|
2024-04-11 12:12:16 +07:00
|
|
|
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
|
|
|
|
hide-bottom-space
|
2024-04-10 16:02:28 +07:00
|
|
|
v-model="formDataContact.lineId"
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
2024-04-11 12:12:16 +07:00
|
|
|
label="Line Id"
|
2024-04-10 16:02:28 +07:00
|
|
|
/>
|
2024-04-09 15:55:15 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
2024-04-11 12:12:16 +07:00
|
|
|
class="branch-form-show-qr-code q-pa-md column items-center justify-center full-width"
|
|
|
|
|
:class="{ 'dark-form-show-qr-code': $q.dark.isActive }"
|
2024-04-09 15:55:15 +07:00
|
|
|
>
|
2024-04-11 12:12:16 +07:00
|
|
|
<div class="col q-pb-md">
|
2024-04-10 18:49:41 +07:00
|
|
|
<q-img
|
|
|
|
|
v-if="urlQrCode"
|
|
|
|
|
:src="urlQrCode as string"
|
|
|
|
|
style="width: 100px; height: 100px"
|
|
|
|
|
/>
|
2024-04-09 15:55:15 +07:00
|
|
|
<q-btn
|
2024-04-11 12:12:16 +07:00
|
|
|
class="branch-form-btn-qr-code"
|
2024-04-10 18:49:41 +07:00
|
|
|
v-else
|
2024-04-09 15:55:15 +07:00
|
|
|
unelevated
|
2024-04-11 12:12:16 +07:00
|
|
|
:color="$q.dark.isActive ? 'grey-10' : 'grey-2'"
|
|
|
|
|
:text-color="$q.dark.isActive ? 'white' : 'grey-5'"
|
2024-04-09 15:55:15 +07:00
|
|
|
>
|
|
|
|
|
<Icon icon="teenyicons:add-outline" width="20px" height="50px" />
|
|
|
|
|
</q-btn>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col">
|
|
|
|
|
<q-btn
|
|
|
|
|
style="
|
|
|
|
|
background: var(--blue-5);
|
|
|
|
|
color: var(--blue-0);
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
"
|
|
|
|
|
unelevated
|
|
|
|
|
rounded
|
2024-04-11 12:12:16 +07:00
|
|
|
:label="$t('formDialogUploadQrCode')"
|
2024-04-10 18:49:41 +07:00
|
|
|
@click="inputFile.click()"
|
2024-04-09 15:55:15 +07:00
|
|
|
></q-btn>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</AppBox>
|
|
|
|
|
</template>
|
|
|
|
|
|
2024-04-10 09:46:30 +07:00
|
|
|
<template #midBottom>
|
2024-04-09 15:55:15 +07:00
|
|
|
<div>
|
|
|
|
|
<div class="row full-width q-pb-md">
|
|
|
|
|
<div class="col q-pr-md">
|
|
|
|
|
<q-input
|
2024-04-10 16:02:28 +07:00
|
|
|
v-model="formData.telephoneNo"
|
2024-04-09 15:55:15 +07:00
|
|
|
dense
|
|
|
|
|
outlined
|
2024-04-11 12:12:16 +07:00
|
|
|
:label="$t('formDialogInputTelephoneHq')"
|
2024-04-09 15:55:15 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col">
|
|
|
|
|
<q-input
|
2024-04-10 16:02:28 +07:00
|
|
|
v-model="formData.email"
|
2024-04-09 15:55:15 +07:00
|
|
|
dense
|
|
|
|
|
outlined
|
2024-04-11 12:12:16 +07:00
|
|
|
:label="$t('formDialogInputEmailHq')"
|
2024-04-09 15:55:15 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
class="column q-pa-sm full-width bordered"
|
|
|
|
|
style="border-radius: 6px"
|
|
|
|
|
>
|
|
|
|
|
<div class="col">location</div>
|
|
|
|
|
<div class="col self-center bg-image q-pa-md">
|
|
|
|
|
<q-btn
|
|
|
|
|
rounded
|
|
|
|
|
style="
|
|
|
|
|
background: var(--blue-5);
|
|
|
|
|
color: var(--blue-0);
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
"
|
|
|
|
|
class="flex flrx-center"
|
|
|
|
|
label="location"
|
|
|
|
|
></q-btn>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</FormDialog>
|
2024-04-02 17:47:32 +07:00
|
|
|
</template>
|
|
|
|
|
|
2024-04-05 18:00:30 +07:00
|
|
|
<style scoped>
|
2024-04-09 15:55:15 +07:00
|
|
|
.bg-image {
|
|
|
|
|
background-image: url(/map.png);
|
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
background-size: auto;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-11 12:12:16 +07:00
|
|
|
.branch-form-show-qr-code {
|
|
|
|
|
--_bg-branch-form-show-qr-code: linear-gradient(
|
|
|
|
|
180deg,
|
|
|
|
|
var(--indigo-0),
|
|
|
|
|
var(--sand-0)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
--_border-branch-form-show-qr-code: 2px dashed var(--gray-4);
|
|
|
|
|
border: var(--_border-branch-form-show-qr-code);
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
background-image: var(--_bg-branch-form-show-qr-code);
|
|
|
|
|
|
|
|
|
|
&.dark-form-show-qr-code {
|
|
|
|
|
background: var(--gray-9);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.branch-form-btn-qr-code {
|
|
|
|
|
--_color-btn-qr-code: 3px solid var(--gray-4);
|
|
|
|
|
|
|
|
|
|
border: var(--_color-btn-qr-code);
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.branch-form-input-Contact {
|
|
|
|
|
--_bg-branch-form-input-Contact: var(--gray-1-hsl);
|
|
|
|
|
background: hsl(var(--_bg-branch-form-input-Contact));
|
|
|
|
|
|
|
|
|
|
&.dark-form-input-Contact {
|
|
|
|
|
--_bg-branch-form-input-Contact: var(--gray-10-hsl);
|
|
|
|
|
border: 2px solid var(--gray-9);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-09 17:11:59 +07:00
|
|
|
.branch-container {
|
2024-04-05 18:00:30 +07:00
|
|
|
--_color-branch-tree-text: var(--blue-6-hsl);
|
|
|
|
|
--_color-branch-title: var(--blue-10-hsl);
|
2024-04-11 11:46:42 +07:00
|
|
|
--_bg-branch-title: var(--blue-0-hsl) / 0.5;
|
2024-04-05 18:00:30 +07:00
|
|
|
--_color-branch-btn: var(--cyan-6-hsl);
|
|
|
|
|
--_color-branch-tree-active: var(--blue-6-hsl);
|
|
|
|
|
--_bg-branch-tree-box: var(--gray-0-hsl);
|
|
|
|
|
--_bg-branch-tree-scroll: var(--gray-0-hsl);
|
|
|
|
|
--_color-branch-tree-scroll: var(--gray-0-hsl);
|
|
|
|
|
|
|
|
|
|
&.dark {
|
|
|
|
|
--_color-branch-title: var(--blue-0-hsl);
|
|
|
|
|
--_bg-branch-title: var(--gray-9-hsl) / 1;
|
|
|
|
|
--_color-branch-btn: var(--cyan-6-hsl);
|
|
|
|
|
--_color-branch-tree-active: var(--blue-6-hsl);
|
|
|
|
|
--_bg-branch-tree-box: var(--gray-10-hsl);
|
|
|
|
|
--_bg-branch-tree-scroll: var(--gray-11-hsl);
|
|
|
|
|
--_color-branch-tree-scroll: var(--gray-8-hsl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.bg-branch-tree-toggle {
|
|
|
|
|
--_bg-branch-tree-toggle: var(--gray-3-hsl);
|
|
|
|
|
background: hsl(var(--_bg-branch-tree-toggle));
|
|
|
|
|
|
|
|
|
|
&.dark-toggle {
|
|
|
|
|
--_bg-branch-tree-toggle: var(--gray-9-hsl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.bg-branch-tree-scroll {
|
|
|
|
|
background: hsl(var(--_bg-branch-tree-scroll));
|
|
|
|
|
color: hsl(var(--_color-branch-tree-scroll));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.bg-branch-tree-box {
|
|
|
|
|
background: hsl(var(--_bg-branch-tree-box));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.bg-card-branch-title {
|
|
|
|
|
background: hsla(var(--_bg-branch-title));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.color-card-branch-title {
|
|
|
|
|
color: hsl(var(--_color-branch-title));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.color-card-branch-btn {
|
|
|
|
|
color: hsl(var(--_color-branch-btn));
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.color-brach-tree-text,
|
|
|
|
|
.color-brach-tree-btn {
|
|
|
|
|
color: var(--stone-6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.color-tree-active {
|
|
|
|
|
color: hsl(var(--_color-branch-tree-active));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.bg-branch-tree {
|
|
|
|
|
background: hsla(var(--_color-branch-tree-active) / 0.08);
|
|
|
|
|
|
|
|
|
|
&.dark-tree {
|
|
|
|
|
background: hsla(var(--_color-branch-tree-active) / 0.01);
|
|
|
|
|
border: 1px solid hsla(var(--_color-branch-tree-active));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|