2024-06-07 11:58:27 +07:00
|
|
|
<script setup lang="ts">
|
2024-07-01 13:30:21 +07:00
|
|
|
import { ref, onMounted, watch } from 'vue';
|
2024-08-15 15:39:54 +07:00
|
|
|
import { storeToRefs } from 'pinia';
|
|
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
|
import { QTableProps } from 'quasar';
|
2024-07-01 13:30:21 +07:00
|
|
|
|
2024-08-02 16:13:07 +07:00
|
|
|
import useCustomerStore from 'stores/customer';
|
|
|
|
|
import useFlowStore from 'stores/flow';
|
|
|
|
|
import useOptionStore from 'stores/options';
|
2024-08-15 15:39:54 +07:00
|
|
|
import { dialog } from 'stores/utils';
|
2024-07-03 17:55:12 +07:00
|
|
|
|
2024-08-02 16:13:07 +07:00
|
|
|
import { Status } from 'stores/types';
|
2024-08-15 15:39:54 +07:00
|
|
|
import { Employee, EmployeeHistory } from 'stores/employee/types';
|
2024-08-02 16:13:07 +07:00
|
|
|
import { CustomerBranch, CustomerType } from 'stores/customer/types';
|
2024-07-01 13:30:21 +07:00
|
|
|
|
2024-08-15 15:39:54 +07:00
|
|
|
import { columnsEmployee } from './constant';
|
|
|
|
|
import { useCustomerBranchForm, useEmployeeForm } from './form';
|
|
|
|
|
|
2024-08-09 17:58:51 +07:00
|
|
|
import ButtonAddComponent from 'components/ButtonAddCompoent.vue';
|
2024-08-09 15:09:46 +07:00
|
|
|
import SideMenu from 'components/SideMenu.vue';
|
|
|
|
|
import { DialogFormContainer, DialogHeader } from 'components/dialog';
|
2024-07-01 13:30:21 +07:00
|
|
|
import BranchCardCustomer from 'components/03_customer-management/BranchCardCustomer.vue';
|
2024-08-02 16:13:07 +07:00
|
|
|
import PaginationComponent from 'components/PaginationComponent.vue';
|
2024-07-01 13:30:21 +07:00
|
|
|
import NoData from 'components/NoData.vue';
|
2024-08-15 15:39:54 +07:00
|
|
|
import TableEmpoloyee from 'components/03_customer-management/TableEmpoloyee.vue';
|
2024-08-09 15:09:46 +07:00
|
|
|
import { AddressForm } from 'components/form';
|
2024-08-09 17:58:51 +07:00
|
|
|
import {
|
|
|
|
|
SaveButton,
|
|
|
|
|
CancelButton,
|
|
|
|
|
UndoButton,
|
|
|
|
|
EditButton,
|
|
|
|
|
DeleteButton,
|
|
|
|
|
} from 'components/button';
|
2024-08-09 15:09:46 +07:00
|
|
|
import {
|
|
|
|
|
EmployerFormAbout,
|
|
|
|
|
EmployerFormBusiness,
|
|
|
|
|
EmployerFormContact,
|
|
|
|
|
} from './components';
|
2024-06-07 14:16:38 +07:00
|
|
|
|
2024-07-03 17:55:12 +07:00
|
|
|
const flowStore = useFlowStore();
|
2024-08-09 15:09:46 +07:00
|
|
|
const customerStore = useCustomerStore();
|
2024-08-15 15:39:54 +07:00
|
|
|
const employeeFormStore = useEmployeeForm();
|
2024-08-09 15:09:46 +07:00
|
|
|
const customerBranchFormStore = useCustomerBranchForm();
|
2024-08-15 15:39:54 +07:00
|
|
|
|
|
|
|
|
const { t } = useI18n();
|
|
|
|
|
const { fetchListCustomeBranch } = customerStore;
|
2024-08-09 15:09:46 +07:00
|
|
|
const {
|
|
|
|
|
currentFormData: customerBranchFormData,
|
|
|
|
|
state: customerBranchFormState,
|
|
|
|
|
} = storeToRefs(customerBranchFormStore);
|
2024-06-07 11:58:27 +07:00
|
|
|
|
|
|
|
|
const inputSearch = ref<string>('');
|
|
|
|
|
|
2024-06-10 12:00:16 +07:00
|
|
|
const branch = defineModel<CustomerBranch[]>('branch');
|
|
|
|
|
const currentCustomerName = defineModel<string>('currentCustomerName');
|
2024-07-30 09:45:09 +00:00
|
|
|
const modeView = defineModel<boolean>('modeView');
|
2024-06-07 15:05:22 +07:00
|
|
|
|
2024-06-11 11:23:56 +07:00
|
|
|
const currentCustomerUrlImage = defineModel<string | null>(
|
|
|
|
|
'currentCustomerUrlImage',
|
|
|
|
|
);
|
|
|
|
|
|
2024-08-15 15:39:54 +07:00
|
|
|
const { state: employeeFormState, currentFromDataEmployee } =
|
|
|
|
|
storeToRefs(employeeFormStore);
|
|
|
|
|
|
2024-06-14 13:03:20 +07:00
|
|
|
const currentStatus = ref<Status | 'All'>('All');
|
2024-08-15 09:34:26 +07:00
|
|
|
const currentBtnOpen = ref<boolean[]>([]);
|
2024-07-01 13:30:21 +07:00
|
|
|
const totalBranch = ref(0);
|
2024-06-14 13:03:20 +07:00
|
|
|
|
2024-06-11 11:23:56 +07:00
|
|
|
const currentPageBranch = ref<number>(1);
|
|
|
|
|
const maxPageBranch = ref<number>(1);
|
|
|
|
|
const pageSizeBranch = ref<number>(30);
|
|
|
|
|
|
2024-06-07 14:16:38 +07:00
|
|
|
const prop = withDefaults(
|
2024-06-07 11:58:27 +07:00
|
|
|
defineProps<{
|
2024-06-07 14:19:35 +07:00
|
|
|
color?: 'purple' | 'green';
|
2024-07-01 13:30:21 +07:00
|
|
|
|
2024-06-11 11:23:56 +07:00
|
|
|
customerType: CustomerType;
|
2024-06-07 11:58:27 +07:00
|
|
|
}>(),
|
|
|
|
|
{
|
|
|
|
|
color: 'green',
|
|
|
|
|
},
|
|
|
|
|
);
|
2024-06-07 14:16:38 +07:00
|
|
|
|
2024-08-15 15:39:54 +07:00
|
|
|
const listEmployee = ref<Employee[]>([]);
|
|
|
|
|
|
2024-08-14 16:02:30 +07:00
|
|
|
const customerId = defineModel<string>('customerId', { required: true });
|
|
|
|
|
|
2024-07-05 17:35:40 +07:00
|
|
|
defineEmits<{
|
2024-06-10 12:00:16 +07:00
|
|
|
(e: 'back'): void;
|
2024-07-05 15:13:23 +07:00
|
|
|
(e: 'viewDetail', branch: CustomerBranch, index: number): void;
|
2024-06-10 12:00:16 +07:00
|
|
|
(e: 'dialog'): void;
|
|
|
|
|
}>();
|
|
|
|
|
|
2024-06-07 14:16:38 +07:00
|
|
|
onMounted(async () => {
|
2024-08-13 16:36:25 +07:00
|
|
|
const url = window.location.href;
|
|
|
|
|
const parts = url.split('/');
|
|
|
|
|
customerBranchFormState.value.currentCustomerId = parts[4];
|
|
|
|
|
|
2024-06-14 13:03:20 +07:00
|
|
|
await fetchList();
|
2024-08-15 09:34:26 +07:00
|
|
|
|
|
|
|
|
branch.value?.forEach((v) => {
|
|
|
|
|
currentBtnOpen.value.push(false);
|
|
|
|
|
});
|
2024-06-14 13:03:20 +07:00
|
|
|
});
|
|
|
|
|
|
2024-07-30 14:24:35 +07:00
|
|
|
const columns = [
|
|
|
|
|
{
|
|
|
|
|
name: 'branchLabelName',
|
|
|
|
|
align: 'left',
|
|
|
|
|
label: 'office',
|
|
|
|
|
field: 'name',
|
|
|
|
|
sortable: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'branchLabelAddress',
|
|
|
|
|
align: 'left',
|
|
|
|
|
label: 'address',
|
|
|
|
|
field: 'address',
|
|
|
|
|
sortable: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'branchLabelTel',
|
|
|
|
|
align: 'left',
|
|
|
|
|
label: 'formDialogInputTelephone',
|
|
|
|
|
field: 'telephoneNo',
|
|
|
|
|
},
|
|
|
|
|
] satisfies QTableProps['columns'];
|
|
|
|
|
|
|
|
|
|
const fieldDisplay = ref<
|
|
|
|
|
(
|
|
|
|
|
| 'branchName'
|
|
|
|
|
| 'customerBranchFormTab'
|
|
|
|
|
| 'address'
|
|
|
|
|
| 'telephone'
|
|
|
|
|
| 'businessTypePure'
|
|
|
|
|
| 'totalEmployee'
|
|
|
|
|
)[]
|
|
|
|
|
>([
|
|
|
|
|
'branchName',
|
|
|
|
|
'customerBranchFormTab',
|
|
|
|
|
'address',
|
|
|
|
|
'telephone',
|
|
|
|
|
'businessTypePure',
|
|
|
|
|
'totalEmployee',
|
|
|
|
|
]);
|
|
|
|
|
const branchFieldSelected = ref<
|
|
|
|
|
(
|
|
|
|
|
| 'customerBranchFormTab'
|
|
|
|
|
| 'branchName'
|
|
|
|
|
| 'address'
|
|
|
|
|
| 'telephone'
|
|
|
|
|
| 'businessTypePure'
|
|
|
|
|
| 'totalEmployee'
|
|
|
|
|
)[]
|
|
|
|
|
>(fieldDisplay.value);
|
|
|
|
|
|
2024-08-15 09:57:02 +07:00
|
|
|
async function deleteBranchById(id: string) {
|
|
|
|
|
return await new Promise((resolve) => {
|
|
|
|
|
dialog({
|
|
|
|
|
color: 'negative',
|
|
|
|
|
icon: 'mdi-alert',
|
|
|
|
|
title: t('deleteConfirmTitle'),
|
|
|
|
|
actionText: t('ok'),
|
|
|
|
|
persistent: true,
|
|
|
|
|
message: t('deleteConfirmMessage'),
|
|
|
|
|
action: async () => {
|
|
|
|
|
await customerStore.deleteBranchById(id);
|
|
|
|
|
await fetchList();
|
|
|
|
|
flowStore.rotate();
|
|
|
|
|
resolve(true);
|
|
|
|
|
customerBranchFormState.value.dialogModal = false;
|
|
|
|
|
},
|
|
|
|
|
cancel: () => {
|
|
|
|
|
resolve(false);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-14 13:03:20 +07:00
|
|
|
async function fetchList() {
|
2024-08-14 16:02:30 +07:00
|
|
|
if (!customerId.value) return;
|
|
|
|
|
|
2024-07-03 17:55:12 +07:00
|
|
|
const result = await fetchListCustomeBranch({
|
2024-08-14 16:02:30 +07:00
|
|
|
customerId: customerId.value,
|
2024-07-01 13:30:21 +07:00
|
|
|
query: !!inputSearch.value ? inputSearch.value : undefined,
|
|
|
|
|
page: currentPageBranch.value,
|
2024-06-11 11:23:56 +07:00
|
|
|
pageSize: pageSizeBranch.value,
|
2024-06-12 16:21:55 +07:00
|
|
|
includeCustomer: true,
|
2024-06-14 13:03:20 +07:00
|
|
|
status:
|
|
|
|
|
currentStatus.value === 'All'
|
|
|
|
|
? undefined
|
|
|
|
|
: currentStatus.value === 'ACTIVE'
|
|
|
|
|
? 'ACTIVE'
|
|
|
|
|
: 'INACTIVE',
|
2024-06-11 11:23:56 +07:00
|
|
|
});
|
2024-06-07 15:05:22 +07:00
|
|
|
if (result) {
|
2024-07-01 13:30:21 +07:00
|
|
|
totalBranch.value = result.total;
|
2024-06-12 15:36:36 +07:00
|
|
|
maxPageBranch.value = Math.ceil(result.total / pageSizeBranch.value);
|
2024-06-11 11:23:56 +07:00
|
|
|
branch.value = result.result;
|
|
|
|
|
}
|
2024-06-14 13:03:20 +07:00
|
|
|
}
|
2024-06-11 11:23:56 +07:00
|
|
|
|
2024-08-09 17:58:51 +07:00
|
|
|
function openEmployerBranchForm(formType: 'create' | 'edit' | 'info') {
|
|
|
|
|
customerBranchFormState.value.dialogType = formType;
|
|
|
|
|
customerBranchFormState.value.dialogModal = true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-14 15:18:31 +07:00
|
|
|
onMounted(async () => {
|
|
|
|
|
await fetchList();
|
|
|
|
|
});
|
|
|
|
|
|
2024-08-14 16:02:30 +07:00
|
|
|
watch([customerId, inputSearch, currentStatus], async () => {
|
2024-06-14 13:03:20 +07:00
|
|
|
await fetchList();
|
|
|
|
|
});
|
2024-06-07 11:58:27 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2024-08-09 17:58:51 +07:00
|
|
|
<ButtonAddComponent
|
|
|
|
|
style="z-index: 999"
|
|
|
|
|
v-if="$route.name !== 'CustomerManagement'"
|
|
|
|
|
>
|
|
|
|
|
<q-fab-action
|
|
|
|
|
id="add-branch"
|
|
|
|
|
:style="{
|
|
|
|
|
color: 'white',
|
|
|
|
|
'background-color':
|
|
|
|
|
customerType === 'CORP'
|
|
|
|
|
? 'hsla(var(--violet-11-hsl))'
|
|
|
|
|
: 'hsla(var(--pink-6-hsl))',
|
|
|
|
|
}"
|
|
|
|
|
@click="openEmployerBranchForm('create')"
|
|
|
|
|
padding="xs"
|
|
|
|
|
icon="mdi-office-building-outline"
|
|
|
|
|
:label="$t('formDialogTitleCreateSubBranch')"
|
|
|
|
|
external-label
|
|
|
|
|
label-position="left"
|
|
|
|
|
/>
|
|
|
|
|
</ButtonAddComponent>
|
2024-07-18 09:11:41 +00:00
|
|
|
<div
|
2024-08-09 15:09:46 +07:00
|
|
|
class="row justify-between bordered-b surface-3 full-width q-px-md"
|
2024-07-30 14:24:35 +07:00
|
|
|
style="z-index: 1"
|
2024-07-18 09:11:41 +00:00
|
|
|
>
|
2024-07-30 11:05:39 +00:00
|
|
|
<div class="row items-center col-12 col-md">
|
2024-07-30 14:24:35 +07:00
|
|
|
<q-card-section
|
|
|
|
|
class="q-pa-sm q-pt-md q-mr-md q-mb-sm"
|
|
|
|
|
:class="{
|
|
|
|
|
color__purple: customerType === 'CORP',
|
|
|
|
|
color__green: customerType === 'PERS',
|
|
|
|
|
}"
|
|
|
|
|
style="border-radius: 0 0 40px 40px; position: relative"
|
2024-07-24 11:34:05 +07:00
|
|
|
>
|
2024-07-30 14:24:35 +07:00
|
|
|
<q-avatar no-padding size="50px">
|
|
|
|
|
<img :src="currentCustomerUrlImage ?? '/no-profile.png'" />
|
|
|
|
|
</q-avatar>
|
|
|
|
|
</q-card-section>
|
|
|
|
|
<div>
|
|
|
|
|
<div>{{ currentCustomerName }}</div>
|
|
|
|
|
<div class="row items-center">
|
|
|
|
|
<i
|
|
|
|
|
class="isax isax-frame5"
|
|
|
|
|
style="font-size: 1rem; color: var(--stone-6)"
|
|
|
|
|
/>
|
|
|
|
|
<div class="q-px-sm">
|
|
|
|
|
{{ '10' }}
|
|
|
|
|
</div>
|
|
|
|
|
<q-icon name="mdi-home" size="16px" style="color: var(--stone-6)" />
|
|
|
|
|
<div class="q-px-sm">
|
|
|
|
|
{{ '2' }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-06-07 11:58:27 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-07-30 14:24:35 +07:00
|
|
|
|
2024-08-14 16:02:30 +07:00
|
|
|
<div class="row items-center justify-end col-12 col-md q-py-sm no-wrap">
|
2024-07-30 14:24:35 +07:00
|
|
|
<q-input
|
|
|
|
|
lazy-rules="ondemand"
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
class="col-6"
|
|
|
|
|
:label="$t('search')"
|
|
|
|
|
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
|
|
|
|
v-model="inputSearch"
|
|
|
|
|
debounce="500"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:prepend>
|
|
|
|
|
<q-icon name="mdi-magnify" />
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
|
|
|
|
|
<q-select
|
|
|
|
|
lazy-rules="ondemand"
|
|
|
|
|
id="select-status"
|
|
|
|
|
for="select-status"
|
|
|
|
|
v-model="currentStatus"
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
option-value="value"
|
|
|
|
|
option-label="label"
|
|
|
|
|
class="col q-pl-sm"
|
|
|
|
|
map-options
|
|
|
|
|
emit-value
|
|
|
|
|
:hide-dropdown-icon="$q.screen.lt.sm"
|
|
|
|
|
:options="[
|
|
|
|
|
{ label: $t('all'), value: 'All' },
|
|
|
|
|
{ label: $t('statusACTIVE'), value: 'ACTIVE' },
|
|
|
|
|
{ label: $t('statusINACTIVE'), value: 'INACTIVE' },
|
|
|
|
|
]"
|
|
|
|
|
></q-select>
|
|
|
|
|
|
|
|
|
|
<q-btn-toggle
|
|
|
|
|
id="btn-mode"
|
|
|
|
|
v-model="modeView"
|
|
|
|
|
dense
|
|
|
|
|
class="no-shadow bordered rounded surface-1 q-ml-sm"
|
|
|
|
|
:toggle-color="$q.dark.isActive ? 'grey-9' : 'grey-2'"
|
|
|
|
|
size="xs"
|
|
|
|
|
:options="[
|
|
|
|
|
{ value: true, slot: 'folder' },
|
|
|
|
|
{ value: false, slot: 'list' },
|
|
|
|
|
]"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:folder>
|
|
|
|
|
<q-icon
|
|
|
|
|
id="icon-mode-grid"
|
|
|
|
|
name="mdi-view-grid-outline"
|
|
|
|
|
size="16px"
|
|
|
|
|
class="q-px-sm q-py-sm rounded"
|
|
|
|
|
:style="{
|
|
|
|
|
color: $q.dark.isActive
|
|
|
|
|
? modeView
|
|
|
|
|
? '#C9D3DB'
|
|
|
|
|
: '#787B7C'
|
|
|
|
|
: modeView
|
|
|
|
|
? '#787B7C'
|
|
|
|
|
: '#C9D3DB',
|
|
|
|
|
}"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:list>
|
|
|
|
|
<q-icon
|
|
|
|
|
id="icon-mode-list"
|
|
|
|
|
name="mdi-format-list-bulleted"
|
|
|
|
|
class="q-px-sm q-py-xs rounded"
|
|
|
|
|
size="16px"
|
|
|
|
|
:style="{
|
|
|
|
|
color: $q.dark.isActive
|
|
|
|
|
? modeView === true
|
|
|
|
|
? '#C9D3DB'
|
|
|
|
|
: '#787B7C'
|
|
|
|
|
: modeView === false
|
|
|
|
|
? '#787B7C'
|
|
|
|
|
: '#C9D3DB',
|
|
|
|
|
}"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</q-btn-toggle>
|
2024-06-07 11:58:27 +07:00
|
|
|
</div>
|
2024-07-30 14:24:35 +07:00
|
|
|
</div>
|
|
|
|
|
<div
|
2024-07-30 10:09:30 +00:00
|
|
|
class="row q-pa-md col scroll full-width surface-2"
|
2024-07-30 14:24:35 +07:00
|
|
|
:class="{
|
|
|
|
|
'justify-center': totalBranch === 0,
|
|
|
|
|
'items-center': totalBranch === 0,
|
|
|
|
|
}"
|
|
|
|
|
>
|
|
|
|
|
<NoData v-if="totalBranch === 0" :not-found="!!inputSearch" />
|
2024-06-11 11:23:56 +07:00
|
|
|
|
2024-07-30 15:10:50 +07:00
|
|
|
<div style="width: 100%" v-else>
|
2024-07-30 14:24:35 +07:00
|
|
|
<q-table
|
|
|
|
|
v-if="branch"
|
|
|
|
|
flat
|
|
|
|
|
class="full-width"
|
|
|
|
|
bordered
|
|
|
|
|
:rows-per-page-options="[0]"
|
|
|
|
|
:rows="branch"
|
|
|
|
|
:columns="columns"
|
|
|
|
|
:grid="modeView"
|
|
|
|
|
card-container-class="row q-col-gutter-md"
|
|
|
|
|
row-key="name"
|
|
|
|
|
hide-pagination
|
|
|
|
|
:visible-columns="branchFieldSelected"
|
|
|
|
|
>
|
|
|
|
|
<template #header>
|
2024-07-31 06:18:52 +00:00
|
|
|
<q-tr style="background-color: hsla(var(--info-bg) / 0.07)">
|
2024-07-30 14:24:35 +07:00
|
|
|
<q-th
|
|
|
|
|
v-for="(v, i) in fieldDisplay"
|
|
|
|
|
:key="v"
|
|
|
|
|
:class="{ 'text-left': i === 0 }"
|
|
|
|
|
>
|
|
|
|
|
{{ $t(v) }}
|
|
|
|
|
</q-th>
|
|
|
|
|
<q-th auto-width />
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
|
|
|
|
<template #body="props">
|
|
|
|
|
<q-tr
|
|
|
|
|
:class="{
|
|
|
|
|
'app-text-muted': props.row.status === 'INACTIVE',
|
2024-08-01 11:28:17 +07:00
|
|
|
'cursor-pointer': props.row._count?.branch !== 0,
|
2024-07-30 14:24:35 +07:00
|
|
|
}"
|
|
|
|
|
:props="props"
|
|
|
|
|
@click="$emit('viewDetail', props.row, props.rowIndex)"
|
|
|
|
|
>
|
|
|
|
|
<q-td v-if="branchFieldSelected.includes('branchName')">
|
|
|
|
|
<div class="row items-center no-wrap">
|
|
|
|
|
<div
|
|
|
|
|
:class="{
|
|
|
|
|
'status-active': props.row.status !== 'INACTIVE',
|
|
|
|
|
'status-inactive': props.row.status === 'INACTIVE',
|
|
|
|
|
}"
|
|
|
|
|
class="q-mr-md"
|
|
|
|
|
style="display: flex; margin-bottom: var(--size-2)"
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
class="branch-card__icon"
|
|
|
|
|
:class="{ 'branch-card__dark': $q.dark.isActive }"
|
|
|
|
|
>
|
|
|
|
|
<q-icon
|
|
|
|
|
size="md"
|
|
|
|
|
style="scale: 0.8"
|
|
|
|
|
name="mdi-office-building-outline"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col" style="min-width: fit-content">
|
|
|
|
|
<div class="col">
|
|
|
|
|
{{
|
|
|
|
|
$i18n.locale === 'en-US'
|
|
|
|
|
? props.row.nameEN
|
|
|
|
|
: props.row.name
|
|
|
|
|
}}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col app-text-muted">
|
|
|
|
|
{{ props.row.code }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</q-td>
|
|
|
|
|
<q-td
|
|
|
|
|
v-if="branchFieldSelected.includes('customerBranchFormTab')"
|
|
|
|
|
class="text-center"
|
|
|
|
|
>
|
|
|
|
|
{{ props.row.branchNo || '-' }}
|
|
|
|
|
</q-td>
|
|
|
|
|
<q-td
|
|
|
|
|
v-if="branchFieldSelected.includes('address')"
|
|
|
|
|
class="text-center"
|
|
|
|
|
>
|
|
|
|
|
{{
|
|
|
|
|
$i18n.locale === 'en-US'
|
|
|
|
|
? `${props.row.addressEN || ''} ${props.row.subDistrict?.nameEN || ''} ${props.row.district?.nameEN || ''} ${props.row.province?.nameEN || ''}`
|
|
|
|
|
: `${props.row.address || ''} ${props.row.subDistrict?.name || ''} ${props.row.district?.name || ''} ${props.row.province?.name || ''}`
|
|
|
|
|
}}
|
|
|
|
|
</q-td>
|
|
|
|
|
<q-td
|
|
|
|
|
v-if="branchFieldSelected.includes('telephone')"
|
|
|
|
|
class="text-center"
|
|
|
|
|
>
|
|
|
|
|
{{ props.row.telephoneNo || '-' }}
|
|
|
|
|
</q-td>
|
|
|
|
|
<q-td
|
|
|
|
|
v-if="branchFieldSelected.includes('businessTypePure')"
|
|
|
|
|
class="text-center"
|
|
|
|
|
>
|
|
|
|
|
{{ useOptionStore().mapOption(props.row.bussinessType) || '-' }}
|
|
|
|
|
</q-td>
|
|
|
|
|
<q-td
|
|
|
|
|
v-if="branchFieldSelected.includes('totalEmployee')"
|
|
|
|
|
class="text-center"
|
|
|
|
|
>
|
|
|
|
|
{{ props.row._count?.employee }}
|
|
|
|
|
</q-td>
|
2024-07-30 10:09:30 +00:00
|
|
|
<q-td>
|
|
|
|
|
<q-btn
|
|
|
|
|
icon="mdi-eye-outline"
|
|
|
|
|
:id="`btn-eye-${props.row.customerName}`"
|
|
|
|
|
size="sm"
|
|
|
|
|
dense
|
|
|
|
|
round
|
|
|
|
|
flat
|
2024-08-09 15:09:46 +07:00
|
|
|
@click="
|
|
|
|
|
() => {
|
|
|
|
|
customerBranchFormStore.initForm('info', props.row.id);
|
|
|
|
|
customerBranchFormState.dialogModal = true;
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-07-30 10:09:30 +00:00
|
|
|
/>
|
2024-08-15 15:39:54 +07:00
|
|
|
<q-btn
|
|
|
|
|
class="btn-arrow-right"
|
|
|
|
|
:class="{ active: currentBtnOpen[props.rowIndex] }"
|
|
|
|
|
icon="mdi-arrow-right-bold-outline"
|
|
|
|
|
size="sm"
|
|
|
|
|
dense
|
|
|
|
|
round
|
|
|
|
|
flat
|
|
|
|
|
@click="
|
|
|
|
|
() => {
|
|
|
|
|
currentBtnOpen[props.rowIndex] =
|
|
|
|
|
!currentBtnOpen[props.rowIndex];
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
2024-07-30 10:09:30 +00:00
|
|
|
</q-td>
|
2024-07-30 14:24:35 +07:00
|
|
|
</q-tr>
|
2024-08-14 16:02:30 +07:00
|
|
|
|
2024-08-15 15:39:54 +07:00
|
|
|
<q-tr v-show="currentBtnOpen[props.rowIndex]" :props="props">
|
|
|
|
|
<q-td colspan="100%" style="padding: 16px">
|
|
|
|
|
<div class="text-center">
|
|
|
|
|
<TableEmpoloyee
|
|
|
|
|
:list-employee="listEmployee"
|
|
|
|
|
:columns-employee="columnsEmployee"
|
|
|
|
|
@history="(item) => {}"
|
|
|
|
|
@view="
|
|
|
|
|
(item) => {
|
|
|
|
|
employeeFormState.drawerModal = true;
|
|
|
|
|
//employeeFormState.isEmployeeEdit = true;
|
|
|
|
|
employeeFormStore.assignFormDataEmployee(item.id);
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</q-td>
|
2024-08-15 09:34:26 +07:00
|
|
|
</q-tr>
|
2024-07-30 14:24:35 +07:00
|
|
|
</template>
|
|
|
|
|
<template #item="props">
|
|
|
|
|
<div class="col-12 col-md-6">
|
|
|
|
|
<BranchCardCustomer
|
|
|
|
|
class="surface-1"
|
|
|
|
|
:inactive="props.row.status === 'INACTIVE'"
|
|
|
|
|
:color="customerType === 'CORP' ? 'corp' : 'pers'"
|
|
|
|
|
:badgeField="['status']"
|
|
|
|
|
:data="{
|
|
|
|
|
customerBranchFormTab: props.row.branchNo,
|
|
|
|
|
branchName: props.row.name,
|
|
|
|
|
address:
|
|
|
|
|
$i18n.locale === 'en-US'
|
|
|
|
|
? `${props.row.addressEN || ''} ${props.row.subDistrict?.nameEN || ''} ${props.row.district?.nameEN || ''} ${props.row.province?.nameEN || ''}`
|
|
|
|
|
: `${props.row.address || ''} ${props.row.subDistrict?.name || ''} ${props.row.district?.name || ''} ${props.row.province?.name || ''}`,
|
|
|
|
|
telephone: props.row.telephoneNo,
|
|
|
|
|
businessTypePure: useOptionStore().mapOption(
|
|
|
|
|
props.row.bussinessType,
|
|
|
|
|
),
|
|
|
|
|
totalEmployee: props.row._count?.employee,
|
|
|
|
|
}"
|
|
|
|
|
:visible-columns="branchFieldSelected"
|
|
|
|
|
@view-detail="$emit('viewDetail', props.row, props.rowIndex)"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</q-table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="row justify-between items-center q-px-md q-py-sm surface-2">
|
2024-07-30 10:09:30 +00:00
|
|
|
<div class="col"></div>
|
|
|
|
|
<div class="app-text-muted col text-center">
|
2024-07-30 14:24:35 +07:00
|
|
|
{{
|
|
|
|
|
$t('recordsPage', {
|
|
|
|
|
resultcurrentPage: branch?.length,
|
|
|
|
|
total: totalBranch,
|
|
|
|
|
})
|
|
|
|
|
}}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-4 flex justify-end">
|
|
|
|
|
<PaginationComponent
|
|
|
|
|
v-model:current-page="currentPageBranch"
|
|
|
|
|
v-model:max-page="maxPageBranch"
|
|
|
|
|
:fetch-data="
|
|
|
|
|
async () => {
|
|
|
|
|
await fetchList();
|
|
|
|
|
flowStore.rotate();
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
2024-06-11 11:23:56 +07:00
|
|
|
</div>
|
2024-07-15 07:39:06 +00:00
|
|
|
</div>
|
2024-08-09 15:09:46 +07:00
|
|
|
|
|
|
|
|
<DialogFormContainer
|
|
|
|
|
:model-value="customerBranchFormState.dialogModal"
|
2024-08-13 16:48:20 +07:00
|
|
|
:on-close="
|
2024-08-14 14:32:11 +07:00
|
|
|
async () => {
|
|
|
|
|
await fetchList();
|
2024-08-13 16:48:20 +07:00
|
|
|
customerBranchFormState.dialogModal = false;
|
2024-08-14 14:32:11 +07:00
|
|
|
flowStore.rotate();
|
2024-08-13 16:48:20 +07:00
|
|
|
}
|
|
|
|
|
"
|
2024-08-13 16:39:44 +07:00
|
|
|
@submit="
|
|
|
|
|
async () => {
|
|
|
|
|
const res = await customerBranchFormStore.submitForm();
|
|
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
|
customerBranchFormStore.initForm('info', res?.id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-08-09 15:09:46 +07:00
|
|
|
>
|
|
|
|
|
<template #header>
|
|
|
|
|
<DialogHeader
|
|
|
|
|
:title="
|
|
|
|
|
$t(`form.title.${customerBranchFormState.dialogType}`, {
|
|
|
|
|
name: $t('customer.employee'),
|
|
|
|
|
})
|
|
|
|
|
"
|
2024-08-09 17:58:51 +07:00
|
|
|
>
|
|
|
|
|
<template #before>
|
|
|
|
|
<EditButton
|
|
|
|
|
icon-only
|
|
|
|
|
v-if="customerBranchFormState.dialogType === 'info'"
|
|
|
|
|
@click="customerBranchFormState.dialogType = 'edit'"
|
|
|
|
|
/>
|
|
|
|
|
<DeleteButton
|
|
|
|
|
icon-only
|
|
|
|
|
v-if="customerBranchFormState.dialogType === 'info'"
|
2024-08-15 09:57:02 +07:00
|
|
|
@click="
|
|
|
|
|
() => {
|
|
|
|
|
deleteBranchById(customerBranchFormData.id || '');
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-08-09 17:58:51 +07:00
|
|
|
/>
|
|
|
|
|
<UndoButton
|
|
|
|
|
icon-only
|
|
|
|
|
v-if="customerBranchFormState.dialogType === 'edit'"
|
|
|
|
|
@click="customerBranchFormState.dialogType = 'info'"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</DialogHeader>
|
2024-08-09 15:09:46 +07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
style="flex: 1; width: 100%; overflow-y: auto"
|
2024-08-09 18:02:16 +07:00
|
|
|
class="surface-2 q-pa-md"
|
2024-08-09 15:09:46 +07:00
|
|
|
id="customer-form"
|
|
|
|
|
>
|
|
|
|
|
<div class="col surface-1 full-height rounded bordered row">
|
|
|
|
|
<div
|
|
|
|
|
class="col full-height"
|
|
|
|
|
style="max-height: 100%; overflow-y: auto"
|
|
|
|
|
v-if="$q.screen.gt.sm"
|
|
|
|
|
>
|
|
|
|
|
<div class="q-py-md q-pl-md q-pr-sm">
|
|
|
|
|
<SideMenu
|
|
|
|
|
:menu="[
|
|
|
|
|
{
|
2024-08-09 17:58:51 +07:00
|
|
|
name: $t('customerBranch.tab.main'),
|
|
|
|
|
anchor: 'employer-branch-main',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('customerBranch.tab.address'),
|
|
|
|
|
anchor: 'employer-branch-address',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('customerBranch.tab.business'),
|
|
|
|
|
anchor: 'employer-branch-business',
|
2024-08-09 15:09:46 +07:00
|
|
|
},
|
|
|
|
|
{
|
2024-08-09 17:58:51 +07:00
|
|
|
name: $t('customerBranch.tab.contact'),
|
|
|
|
|
anchor: 'employer-branch-contact',
|
2024-08-09 15:09:46 +07:00
|
|
|
},
|
|
|
|
|
]"
|
|
|
|
|
background="transparent"
|
|
|
|
|
:active="{
|
|
|
|
|
background: 'hsla(var(--blue-6-hsl) / .2)',
|
|
|
|
|
foreground: 'var(--blue-6)',
|
|
|
|
|
}"
|
2024-08-09 17:58:51 +07:00
|
|
|
scroll-element="#employer-branch-content"
|
2024-08-09 15:09:46 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
2024-08-09 17:58:51 +07:00
|
|
|
id="employer-branch-content"
|
2024-08-09 15:09:46 +07:00
|
|
|
class="col-12 col-md-10 q-py-md q-pr-md q-pl-sm full-height scroll"
|
|
|
|
|
>
|
2024-08-09 17:58:51 +07:00
|
|
|
<div class="row q-col-gutter-sm q-mb-sm" id="employer-branch-main">
|
2024-08-09 15:09:46 +07:00
|
|
|
<div class="col-12 text-weight-bold text-body1 row items-center">
|
|
|
|
|
<q-icon
|
|
|
|
|
flat
|
|
|
|
|
size="xs"
|
|
|
|
|
class="q-pa-sm rounded q-mr-sm"
|
|
|
|
|
color="info"
|
|
|
|
|
name="mdi-office-building-outline"
|
|
|
|
|
style="background-color: var(--surface-3)"
|
|
|
|
|
/>
|
|
|
|
|
<span>{{ $t('customerBranch.tab.main') }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<EmployerFormAbout
|
|
|
|
|
class="q-mb-xl"
|
|
|
|
|
:readonly="customerBranchFormState.dialogType === 'info'"
|
|
|
|
|
v-model:id="customerBranchFormData.id"
|
|
|
|
|
v-model:branch-no="customerBranchFormData.branchNo"
|
|
|
|
|
v-model:tax-no="customerBranchFormData.taxNo"
|
|
|
|
|
v-model:code="customerBranchFormData.code"
|
|
|
|
|
v-model:name="customerBranchFormData.name"
|
|
|
|
|
v-model:name-en="customerBranchFormData.nameEN"
|
|
|
|
|
v-model:registered-name="customerBranchFormData.registerName"
|
|
|
|
|
v-model:registered-date="customerBranchFormData.registerDate"
|
|
|
|
|
v-model:authorized-capital="
|
|
|
|
|
customerBranchFormData.authorizedCapital
|
|
|
|
|
"
|
|
|
|
|
/>
|
2024-08-09 17:58:51 +07:00
|
|
|
<div class="row q-col-gutter-sm q-mb-sm" id="employer-branch-address">
|
2024-08-09 15:09:46 +07:00
|
|
|
<div class="col-12 text-weight-bold text-body1 row items-center">
|
|
|
|
|
<q-icon
|
|
|
|
|
flat
|
|
|
|
|
size="xs"
|
|
|
|
|
class="q-pa-sm rounded q-mr-sm"
|
|
|
|
|
color="info"
|
|
|
|
|
name="mdi-office-building-outline"
|
|
|
|
|
style="background-color: var(--surface-3)"
|
|
|
|
|
/>
|
|
|
|
|
<span>{{ $t('customerBranch.tab.address') }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<AddressForm
|
|
|
|
|
prefix-id="employer-branch"
|
|
|
|
|
class="q-mb-xl"
|
|
|
|
|
hide-title
|
|
|
|
|
dense
|
|
|
|
|
:readonly="customerBranchFormState.dialogType === 'info'"
|
|
|
|
|
outlined
|
|
|
|
|
:title="$t('form.address')"
|
|
|
|
|
v-model:address="customerBranchFormData.address"
|
|
|
|
|
v-model:addressEN="customerBranchFormData.addressEN"
|
|
|
|
|
v-model:province-id="customerBranchFormData.provinceId"
|
|
|
|
|
v-model:district-id="customerBranchFormData.districtId"
|
|
|
|
|
v-model:sub-district-id="customerBranchFormData.subDistrictId"
|
|
|
|
|
:addressTitle="$t('form.address')"
|
|
|
|
|
:addressTitleEN="$t('form.address', { suffix: '(EN)' })"
|
|
|
|
|
/>
|
2024-08-09 17:58:51 +07:00
|
|
|
<div
|
|
|
|
|
class="row q-col-gutter-sm q-mb-sm"
|
|
|
|
|
id="employer-branch-business"
|
|
|
|
|
>
|
2024-08-09 15:09:46 +07:00
|
|
|
<div class="col-12 text-weight-bold text-body1 row items-center">
|
|
|
|
|
<q-icon
|
|
|
|
|
flat
|
|
|
|
|
size="xs"
|
|
|
|
|
class="q-pa-sm rounded q-mr-sm"
|
|
|
|
|
color="info"
|
|
|
|
|
name="mdi-office-building-outline"
|
|
|
|
|
style="background-color: var(--surface-3)"
|
|
|
|
|
/>
|
|
|
|
|
<span>{{ $t('customerBranch.tab.business') }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<EmployerFormBusiness
|
|
|
|
|
dense
|
2024-08-09 17:58:51 +07:00
|
|
|
class="q-mb-xl"
|
2024-08-09 15:09:46 +07:00
|
|
|
outlined
|
|
|
|
|
prefix-id="employer-branch"
|
|
|
|
|
:readonly="customerBranchFormState.dialogType === 'info'"
|
|
|
|
|
v-model:employment-office="customerBranchFormData.employmentOffice"
|
|
|
|
|
v-model:bussiness-type="customerBranchFormData.bussinessType"
|
|
|
|
|
v-model:bussiness-type-en="customerBranchFormData.bussinessTypeEN"
|
|
|
|
|
v-model:job-position="customerBranchFormData.jobPosition"
|
|
|
|
|
v-model:job-position-en="customerBranchFormData.jobPositionEN"
|
|
|
|
|
v-model:job-description="customerBranchFormData.jobDescription"
|
|
|
|
|
v-model:sale-employee="customerBranchFormData.saleEmployee"
|
|
|
|
|
v-model:pay-date="customerBranchFormData.payDate"
|
|
|
|
|
v-model:wage-rate="customerBranchFormData.wageRate"
|
|
|
|
|
/>
|
2024-08-09 17:58:51 +07:00
|
|
|
<div class="row q-col-gutter-sm q-mb-sm" id="employer-branch-contact">
|
2024-08-09 15:09:46 +07:00
|
|
|
<div class="col-12 text-weight-bold text-body1 row items-center">
|
|
|
|
|
<q-icon
|
|
|
|
|
flat
|
|
|
|
|
size="xs"
|
|
|
|
|
class="q-pa-sm rounded q-mr-sm"
|
|
|
|
|
color="info"
|
|
|
|
|
name="mdi-office-building-outline"
|
|
|
|
|
style="background-color: var(--surface-3)"
|
|
|
|
|
/>
|
|
|
|
|
<span>{{ $t('customerBranch.tab.contact') }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<EmployerFormContact
|
|
|
|
|
class="q-mb-lg"
|
|
|
|
|
:readonly="customerBranchFormState.dialogType === 'info'"
|
|
|
|
|
v-model:email="customerBranchFormData.email"
|
|
|
|
|
v-model:telephone="customerBranchFormData.telephoneNo"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<template #footer>
|
2024-08-09 17:58:51 +07:00
|
|
|
<CancelButton outlined class="q-ml-auto" v-close-popup />
|
|
|
|
|
<SaveButton
|
|
|
|
|
solid
|
|
|
|
|
class="q-ml-sm"
|
2024-08-14 11:11:09 +07:00
|
|
|
type="submit"
|
2024-08-09 17:58:51 +07:00
|
|
|
v-if="customerBranchFormState.dialogType !== 'info'"
|
|
|
|
|
/>
|
2024-08-09 15:09:46 +07:00
|
|
|
</template>
|
|
|
|
|
</DialogFormContainer>
|
2024-06-07 11:58:27 +07:00
|
|
|
</template>
|
|
|
|
|
|
2024-06-11 11:23:56 +07:00
|
|
|
<style scoped>
|
2024-07-30 14:24:35 +07:00
|
|
|
.branch-card__icon {
|
|
|
|
|
--_branch-card-bg: var(--pink-6-hsl);
|
|
|
|
|
|
|
|
|
|
background-color: hsla(var(--_branch-card-bg) / 0.15);
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
padding: var(--size-1);
|
|
|
|
|
position: relative;
|
|
|
|
|
transform: rotate(45deg);
|
2024-06-11 11:23:56 +07:00
|
|
|
|
2024-07-30 14:24:35 +07:00
|
|
|
&.branch-card__dark {
|
|
|
|
|
--_branch-card-bg: var(--pink-5-hsl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&::after {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
& :deep(.q-icon) {
|
|
|
|
|
transform: rotate(-45deg);
|
|
|
|
|
color: hsla(var(--_branch-card-bg) / 1);
|
|
|
|
|
}
|
2024-06-11 11:23:56 +07:00
|
|
|
}
|
2024-08-15 15:39:54 +07:00
|
|
|
|
|
|
|
|
.btn-arrow-right {
|
|
|
|
|
transform: rotate(0deg);
|
|
|
|
|
transition: transform 0.3s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.btn-arrow-right.active {
|
|
|
|
|
transform: rotate(90deg);
|
|
|
|
|
transition: transform 0.3s ease;
|
|
|
|
|
}
|
2024-06-11 11:23:56 +07:00
|
|
|
</style>
|