jws-frontend/src/pages/05_quotation/MainPage.vue

1016 lines
31 KiB
Vue
Raw Normal View History

2024-06-19 15:43:58 +07:00
<script lang="ts" setup>
2024-10-01 14:46:34 +07:00
import { pageTabs, fieldSelectedOption } from './constants';
2024-10-03 11:14:12 +07:00
2024-10-04 09:26:34 +07:00
import { onMounted, reactive, ref, watch } from 'vue';
2024-09-25 18:06:05 +07:00
import { storeToRefs } from 'pinia';
2024-10-01 14:46:34 +07:00
2024-10-03 11:22:21 +07:00
// NOTE: Import stores
2024-10-01 14:46:34 +07:00
import { useQuotationStore } from 'src/stores/quotations';
import { isRoleInclude } from 'stores/utils';
import { useNavigator } from 'src/stores/navigator';
2024-10-01 14:46:34 +07:00
import useFlowStore from 'src/stores/flow';
2024-10-02 14:05:36 +07:00
import useMyBranch from 'stores/my-branch';
2024-10-03 14:43:41 +07:00
import { useQuotationForm } from './form';
2024-10-01 14:46:34 +07:00
2024-10-03 11:22:21 +07:00
// NOTE Import Types
2024-10-01 14:46:34 +07:00
import { CustomerBranchCreate } from 'stores/customer/types';
2024-10-03 11:22:21 +07:00
// NOTE: Import Components
2024-10-01 14:46:34 +07:00
import QuotationCard from 'src/components/05_quotation/QuotationCard.vue';
import PaginationComponent from 'src/components/PaginationComponent.vue';
import StatCardComponent from 'src/components/StatCardComponent.vue';
2024-10-30 09:34:46 +07:00
import FloatingActionButton from 'components/FloatingActionButton.vue';
2024-10-01 14:46:34 +07:00
import FormAbout from 'src/components/05_quotation/FormAbout.vue';
import CreateButton from 'src/components/AddButton.vue';
import ItemCard from 'src/components/ItemCard.vue';
import DialogForm from 'components/DialogForm.vue';
import SideMenu from 'components/SideMenu.vue';
import NoData from 'src/components/NoData.vue';
2024-10-04 17:01:24 +07:00
import { dialogCreateCustomerItem } from 'src/pages/03_customer-management/constant';
2024-10-04 17:01:24 +07:00
import { SaveButton } from 'components/button';
2024-09-25 18:06:05 +07:00
import ProfileBanner from 'components/ProfileBanner.vue';
import { AddressForm } from 'components/form';
import {
EmployerFormBusiness,
EmployerFormAbout,
} from 'src/pages/03_customer-management/components';
2024-09-27 16:11:16 +07:00
2024-10-11 11:25:47 +07:00
import { useCustomerForm } from 'src/pages/03_customer-management/form';
2024-10-18 16:14:19 +07:00
import { Quotation } from 'src/stores/quotations/types';
2024-09-25 18:06:05 +07:00
2024-10-03 14:43:41 +07:00
const quotationFormStore = useQuotationForm();
2024-10-01 14:46:34 +07:00
const customerFormStore = useCustomerForm();
2024-09-30 15:03:36 +07:00
const flowStore = useFlowStore();
2024-10-02 14:05:36 +07:00
const userBranch = useMyBranch();
const navigatorStore = useNavigator();
2024-10-01 14:46:34 +07:00
const {
currentFormData: quotationFormData,
currentFormState: quotationFormState,
} = storeToRefs(quotationFormStore);
2024-10-01 14:46:34 +07:00
const { state: customerFormState, currentFormData: customerFormData } =
storeToRefs(customerFormStore);
2024-10-02 14:05:36 +07:00
const { currentMyBranch } = storeToRefs(userBranch);
2024-10-01 14:46:34 +07:00
2024-10-04 15:12:13 +07:00
const special = ref(false);
2024-10-03 11:14:12 +07:00
const branchId = ref('');
2024-10-04 14:39:05 +07:00
const agentPrice = ref<boolean>(false);
const emptyCreateDialog = ref(false);
2024-10-01 14:46:34 +07:00
const onCreateImageList = ref<{
selectedImage: string;
list: { url: string; imgFile: File | null; name: string }[];
}>({ selectedImage: '', list: [] });
2024-10-18 16:14:19 +07:00
const currentQuotationPayment = ref<Quotation>();
2024-10-01 14:46:34 +07:00
2024-09-27 16:11:16 +07:00
const pageState = reactive({
hideStat: false,
inputSearch: '',
fieldSelected: [],
2024-10-17 09:17:54 +07:00
gridView: true,
total: 0,
2024-09-27 16:11:16 +07:00
2024-11-07 14:23:55 +07:00
currentTab: 'Issued',
2024-09-27 16:11:16 +07:00
addModal: false,
quotationModal: false,
employeeModal: false,
2024-10-17 13:23:53 +07:00
receiptModal: false,
2024-09-18 16:04:07 +07:00
});
2024-10-07 16:58:45 +07:00
const CUSTOMER_BRANCH_DEFAULT: CustomerBranchCreate & {
id?: string;
branchCode?: string;
codeCustomer?: string;
} = {
customerCode: '',
customerId: '',
legalPersonNo: '',
citizenId: '',
namePrefix: '',
firstName: '',
lastName: '',
firstNameEN: '',
lastNameEN: '',
telephoneNo: '',
gender: '',
2024-10-02 14:05:36 +07:00
birthDate: new Date().toString(),
businessType: '',
jobPosition: '',
jobDescription: '',
payDate: '',
payDateEN: '',
wageRate: 0,
wageRateText: '',
homeCode: '',
employmentOffice: '',
employmentOfficeEN: '',
address: '',
addressEN: '',
street: '',
streetEN: '',
moo: '',
mooEN: '',
soi: '',
soiEN: '',
provinceId: '',
districtId: '',
subDistrictId: '',
contactName: '',
email: '',
contactTel: '',
officeTel: '',
2024-10-29 09:49:23 +07:00
agentUserId: undefined,
status: 'CREATED',
customerName: '',
registerName: '',
registerNameEN: '',
registerDate: new Date(),
authorizedCapital: '',
authorizedName: '',
authorizedNameEN: '',
code: '',
2024-10-07 16:58:45 +07:00
};
const formDataCustomerBranch = ref<
CustomerBranchCreate & {
id?: string;
branchCode?: string;
codeCustomer?: string;
}
>(structuredClone(CUSTOMER_BRANCH_DEFAULT));
2024-10-16 13:10:40 +07:00
function setDefaultCustomer() {
2024-10-07 16:58:45 +07:00
formDataCustomerBranch.value = structuredClone(CUSTOMER_BRANCH_DEFAULT);
}
2024-10-04 17:01:24 +07:00
async function submitCustomer() {
2024-10-02 14:05:36 +07:00
if (currentMyBranch.value === undefined) return;
const { code, customerCode, birthDate, ...payload } =
formDataCustomerBranch.value;
customerFormData.value.customerBranch = [{ ...payload }];
2024-10-04 17:01:24 +07:00
customerFormData.value.registeredBranchId = isRoleInclude(['system'])
? branchId.value
: currentMyBranch.value.id;
await customerFormStore.submitFormCustomer();
2024-10-02 14:05:36 +07:00
2024-10-04 17:01:24 +07:00
customerFormState.value.dialogModal = false;
// customerFormState.value.dialogType = 'info';
}
2024-10-08 14:05:43 +07:00
async function triggerDialogDeleteQuottaion(id: string) {
quotationFormStore.dialogDelete(async () => {
2024-10-24 13:57:22 +07:00
await quotationStore.deleteQuotation(id);
2024-10-08 14:05:43 +07:00
await fetchQuotationList();
});
}
function triggerCreateCustomerd(opts: { type: 'CORP' | 'PERS' }) {
2024-10-16 13:10:40 +07:00
setDefaultCustomer();
customerFormState.value.dialogType = 'create';
customerFormData.value.customerType = opts?.type;
customerFormState.value.dialogModal = true;
}
function triggerSelectTypeCustomerd() {
emptyCreateDialog.value = true;
}
2024-09-27 16:11:16 +07:00
function triggerAddQuotationDialog() {
pageState.addModal = true;
// TODO: form and state controll
}
2024-10-10 13:23:30 +07:00
function triggerQuotationDialog(opts: {
statusDialog: 'info' | 'edit' | 'create';
quotationId?: string;
branchId?: string;
}) {
2024-11-07 14:55:16 +07:00
const url = new URL(
`/quotation/${opts.statusDialog === 'create' ? 'add' : 'view'}`,
window.location.origin,
);
2024-10-04 15:12:13 +07:00
2024-10-21 11:13:34 +07:00
localStorage.setItem(
'new-quotation',
JSON.stringify({
customerBranchId: quotationFormData.value.customerBranchId,
branchId: opts.branchId ?? branchId.value,
agentPrice: agentPrice.value,
special: special.value,
statusDialog: opts.statusDialog,
quotationId: opts.quotationId,
}),
);
2024-10-04 15:12:13 +07:00
window.open(url.toString(), '_blank');
2024-09-27 16:11:16 +07:00
}
2024-10-18 16:14:19 +07:00
function triggerReceiptDialog(data: Quotation) {
currentQuotationPayment.value = data;
2024-10-17 13:23:53 +07:00
pageState.receiptModal = true;
}
2024-09-30 15:03:36 +07:00
const quotationStore = useQuotationStore();
const {
data: quotationData,
page: quotationPage,
pageSize: quotationPageSize,
pageMax: quotationPageMax,
2024-10-07 16:58:45 +07:00
stats: quotationStats,
2024-09-30 15:03:36 +07:00
} = storeToRefs(quotationStore);
2024-09-27 16:11:16 +07:00
onMounted(async () => {
navigatorStore.current.title = 'quotation.title';
navigatorStore.current.path = [
{
text: 'quotation.caption',
i18n: true,
handler: () => {
2024-11-07 14:23:55 +07:00
pageState.currentTab = 'Issued';
},
},
];
2024-09-30 15:03:36 +07:00
{
2024-10-07 16:58:45 +07:00
const ret = await quotationStore.getQuotationStats();
if (ret) {
quotationStats.value = Object.assign(quotationStats.value, ret);
}
2024-09-30 15:03:36 +07:00
}
{
const ret = await quotationStore.getQuotationList({
page: quotationPage.value,
pageSize: quotationPageSize.value,
2024-11-07 14:23:55 +07:00
status: 'Issued',
urgentFirst: true,
2024-09-30 15:03:36 +07:00
});
if (ret) {
quotationData.value = ret.result;
2024-10-03 11:23:18 +07:00
quotationPageMax.value = Math.ceil(ret.total / quotationPageSize.value);
pageState.total = ret.total;
2024-09-30 15:03:36 +07:00
}
}
flowStore.rotate();
2024-09-27 16:11:16 +07:00
});
2024-09-30 15:03:36 +07:00
2024-10-01 09:48:03 +07:00
async function fetchQuotationList() {
{
2024-11-07 14:23:55 +07:00
console.log(pageState.currentTab);
const ret = await quotationStore.getQuotationList({
page: quotationPage.value,
pageSize: quotationPageSize.value,
2024-11-07 14:23:55 +07:00
status:
pageState.currentTab !== 'Issued'
? (
{
2024-11-07 14:23:55 +07:00
Accepted: 'Accepted',
Expired: 'Expired',
Invoice: 'PaymentInProcess',
PaymentSuccess: 'PaymentSuccess',
ProcessComplete: 'ProcessComplete',
} as const
)[pageState.currentTab]
2024-11-07 14:23:55 +07:00
: 'Issued',
2024-10-21 13:34:12 +07:00
query: pageState.inputSearch,
2024-11-07 14:23:55 +07:00
urgentFirst: true,
});
2024-09-30 15:03:36 +07:00
if (ret) {
quotationData.value = ret.result;
quotationPageMax.value = Math.ceil(ret.total / quotationPageSize.value);
2024-10-25 16:22:58 +07:00
pageState.total = ret.total;
}
}
{
const ret = await quotationStore.getQuotationStats();
if (ret) {
quotationStats.value = Object.assign(quotationStats.value, ret);
}
2024-10-01 09:48:03 +07:00
}
2024-09-30 15:03:36 +07:00
2024-10-01 09:48:03 +07:00
flowStore.rotate();
}
watch(() => pageState.currentTab, fetchQuotationList);
2024-10-21 13:34:12 +07:00
watch(() => pageState.inputSearch, fetchQuotationList);
async function storeDataLocal(id: string) {
await quotationFormStore.assignFormData(id, 'assign');
localStorage.setItem(
'quotation-preview',
2024-10-18 12:32:55 +07:00
JSON.stringify({
data: quotationFormData.value,
meta: {
2024-10-18 14:57:57 +07:00
source: quotationFormState.value.source,
2024-10-18 12:32:55 +07:00
createdBy: quotationFormState.value.createdBy('tha'),
},
}),
);
window.open('/quotation/document-view', '_blank');
}
2024-06-19 15:43:58 +07:00
</script>
<template>
2024-10-30 09:34:46 +07:00
<FloatingActionButton
2024-10-03 11:14:12 +07:00
hide-icon
style="z-index: 999"
@click.stop="triggerAddQuotationDialog"
/>
2024-09-27 16:11:16 +07:00
<div class="column full-height no-wrap">
<!-- SEC: stat -->
<section class="text-body-2 q-mb-xs flex items-center">
{{ $t('general.dataSum') }}
<q-badge
rounded
class="q-ml-sm"
style="
background-color: hsla(var(--info-bg) / 0.15);
color: hsl(var(--info-bg));
"
>
{{
2024-11-07 14:23:55 +07:00
pageState.currentTab === 'Issued'
? quotationStats.issued
: pageState.currentTab === 'Accepted'
? quotationStats.accepted
: pageState.currentTab === 'Expired'
? quotationStats.expired
: pageState.currentTab === 'Invoice'
? quotationStats.paymentInProcess
: pageState.currentTab === 'PaymentSuccess'
? quotationStats.paymentSuccess
: pageState.currentTab === 'ProcessComplete'
? quotationStats.processComplete
: 0
}}
2024-09-27 16:11:16 +07:00
</q-badge>
<q-btn
class="q-ml-sm"
icon="mdi-pin-outline"
color="primary"
size="sm"
flat
dense
rounded
@click="pageState.hideStat = !pageState.hideStat"
:style="pageState.hideStat ? 'rotate: 90deg' : ''"
style="transition: 0.1s ease-in-out"
/>
</section>
<transition name="slide">
<div v-if="!pageState.hideStat" class="scroll q-mb-md">
<div style="display: inline-block">
<StatCardComponent
labelI18n
2024-10-07 16:58:45 +07:00
:branch="[
{
icon: 'mdi-cash',
2024-11-07 14:23:55 +07:00
count: quotationStats.issued,
label: 'quotation.status.Issued',
color: 'orange',
hidden: pageState.currentTab !== 'Issued',
2024-10-07 16:58:45 +07:00
},
{
icon: 'mdi-hand-coin-outline',
2024-11-07 14:23:55 +07:00
count: quotationStats.accepted,
label: 'quotation.status.Accepted',
color: 'pink',
hidden: pageState.currentTab !== 'Accepted',
},
{
icon: 'mdi-hand-coin-outline',
count: quotationStats.expired,
label: 'quotation.status.Expired',
color: 'cyan',
hidden: pageState.currentTab !== 'Expired',
2024-10-07 16:58:45 +07:00
},
2024-11-07 14:23:55 +07:00
2024-10-07 16:58:45 +07:00
{
2024-10-29 10:19:47 +07:00
icon: 'mdi-hand-coin-outline',
2024-11-07 14:23:55 +07:00
count: quotationStats.paymentInProcess,
label: 'quotation.status.Invoice',
color: 'purple',
hidden: pageState.currentTab !== 'Invoice',
},
{
icon: 'mdi-hand-coin-outline',
count: quotationStats.paymentSuccess,
label: 'quotation.status.PaymentSuccess',
color: 'dark-orange',
hidden: pageState.currentTab !== 'PaymentSuccess',
},
{
icon: 'mdi-hand-coin-outline',
count: quotationStats.processComplete,
label: 'quotation.status.ProcessComplete',
color: 'blue',
hidden: pageState.currentTab !== 'ProcessComplete',
2024-10-07 16:58:45 +07:00
},
]"
2024-09-27 16:11:16 +07:00
:dark="$q.dark.isActive"
/>
</div>
</div>
</transition>
<!-- SEC: header content -->
<header class="col surface-1 rounded">
<div class="column full-height">
<section
class="row surface-3 justify-between full-width items-center bordered-b"
style="z-index: 1"
>
<div class="row q-py-sm q-px-md justify-between full-width">
<q-input
for="input-search"
outlined
dense
:label="$t('general.search')"
class="q-mr-md col-12 col-md-3"
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
v-model="pageState.inputSearch"
debounce="200"
>
<template #prepend>
<q-icon name="mdi-magnify" />
</template>
</q-input>
2024-09-18 16:52:46 +07:00
2024-09-27 16:11:16 +07:00
<div
2024-10-18 10:46:19 +07:00
v-if="false"
2024-10-17 09:17:54 +07:00
class="row col-12 col-md-4 justify-end"
2024-09-27 16:11:16 +07:00
:class="{ 'q-pt-xs': $q.screen.lt.md }"
style="white-space: nowrap"
>
<q-select
v-if="!pageState.gridView"
id="select-field"
for="select-field"
class="col q-ml-sm"
:options="
fieldSelectedOption.map((v) => ({
...v,
label: $t(v.label),
}))
"
:display-value="$t('general.displayField')"
:hide-dropdown-icon="$q.screen.lt.sm"
v-model="pageState.fieldSelected"
option-label="label"
option-value="value"
map-options
emit-value
outlined
multiple
dense
/>
2024-09-18 16:52:46 +07:00
2024-09-27 16:11:16 +07:00
<q-btn-toggle
id="btn-mode"
v-model="pageState.gridView"
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
name="mdi-view-grid-outline"
size="16px"
class="q-px-sm q-py-xs rounded"
:style="{
color: $q.dark.isActive
? pageState.gridView
? '#C9D3DB '
: '#787B7C'
: pageState.gridView
? '#787B7C'
: '#C9D3DB',
}"
/>
</template>
<template v-slot:list>
<q-icon
name="mdi-format-list-bulleted"
class="q-px-sm q-py-xs rounded"
size="16px"
:style="{
color: $q.dark.isActive
? pageState.gridView === false
? '#C9D3DB'
: '#787B7C'
: pageState.gridView === false
? '#787B7C'
: '#C9D3DB',
}"
/>
</template>
</q-btn-toggle>
</div>
</div>
</section>
<nav class="surface-2 bordered-b q-px-md full-width">
<q-tabs
inline-label
mobile-arrows
dense
v-model="pageState.currentTab"
align="left"
class="full-width"
active-color="info"
>
<q-tab
v-for="tab in pageTabs"
:name="tab"
:key="tab"
@click="
2024-10-03 11:22:21 +07:00
() => {
quotationPage = 1;
2024-09-27 16:11:16 +07:00
pageState.currentTab = tab;
pageState.inputSearch = '';
flowStore.rotate();
}
"
>
<div
class="row text-capitalize"
:class="
pageState.currentTab === tab ? 'text-bold' : 'app-text-muted'
"
>
2024-11-07 14:23:55 +07:00
{{ $t(`quotation.status.${tab}`) }}
2024-09-27 16:11:16 +07:00
</div>
</q-tab>
</q-tabs>
</nav>
<!-- SEC: body content -->
2024-09-30 13:25:29 +07:00
<article
2024-10-03 11:14:12 +07:00
v-if="!quotationData || quotationData.length === 0"
2024-09-27 16:11:16 +07:00
class="col surface-2 flex items-center justify-center"
>
<NoData
v-if="pageState.inputSearch"
:not-found="!!pageState.inputSearch"
/>
2024-09-27 16:11:16 +07:00
<CreateButton
v-if="!pageState.inputSearch"
2024-09-27 16:11:16 +07:00
@click="triggerAddQuotationDialog"
label="general.add"
:i18n-args="{ text: $t('quotation.title') }"
/>
2024-09-30 13:25:29 +07:00
</article>
<article v-else class="col q-pa-md surface-2 scroll">
2024-09-27 16:11:16 +07:00
<div class="row q-col-gutter-md">
2024-10-18 16:14:19 +07:00
<div
v-for="v in quotationData"
:key="v.id"
class="col-md-4 col-sm-6 col-12"
>
2024-09-27 16:11:16 +07:00
<QuotationCard
2024-10-11 12:07:15 +07:00
:urgent="v.urgent"
2024-10-03 11:22:21 +07:00
:code="v.code"
:title="v.workName"
2024-11-07 11:54:40 +07:00
:created-at="
new Date(v.createdAt).toLocaleString('th-TH', {
2024-11-07 11:54:40 +07:00
hour12: false,
})
"
:valid-until="
(() => {
const date = new Date(v.dueDate);
date.setHours(23, 59, 59, 0);
return date.toLocaleString('th-TH', { hour12: false });
2024-11-07 11:54:40 +07:00
})()
"
:status="$t(`quotation.status.${v.quotationStatus}`)"
2024-10-25 18:10:36 +07:00
:worker-count="v._count.worker"
:worker-max="v.workerMax || v._count.worker"
2024-09-30 15:03:36 +07:00
:customer-name="
2024-10-03 14:43:41 +07:00
v.customerBranch.registerName ||
`${v.customerBranch.firstName || '-'} ${v.customerBranch.lastName || ''}`
2024-09-27 16:11:16 +07:00
"
2024-10-15 09:50:52 +07:00
:reporter="
2024-10-16 09:56:03 +07:00
$i18n.locale === 'eng'
2024-10-15 09:50:52 +07:00
? v.createdBy.firstNameEN + ' ' + v.createdBy.lastNameEN
: v.createdBy.firstName + ' ' + v.createdBy.lastName
"
:total-price="v.finalPrice"
@preview="storeDataLocal(v.id)"
@view="
() => {
2024-10-10 13:23:30 +07:00
triggerQuotationDialog({
statusDialog: 'info',
quotationId: v.id,
2024-10-10 18:15:45 +07:00
branchId: v.customerBranch.customer.registeredBranchId,
2024-10-10 13:23:30 +07:00
});
}
"
2024-10-10 13:23:30 +07:00
@edit="
triggerQuotationDialog({
statusDialog: 'edit',
quotationId: v.id,
2024-10-10 18:15:45 +07:00
branchId: v.customerBranch.customer.registeredBranchId,
2024-10-10 13:23:30 +07:00
})
"
2024-10-18 16:14:19 +07:00
@link="triggerReceiptDialog(v)"
2024-09-27 16:11:16 +07:00
@upload="console.log('upload')"
2024-10-08 14:05:43 +07:00
@delete="triggerDialogDeleteQuottaion(v.id)"
2024-09-27 16:11:16 +07:00
/>
</div>
</div>
2024-09-30 13:25:29 +07:00
</article>
2024-09-18 16:52:46 +07:00
2024-09-27 16:11:16 +07:00
<!-- SEC: footer content -->
<footer
class="row justify-between items-center q-px-md q-py-sm surface-2"
2024-10-03 11:22:21 +07:00
v-if="quotationPageMax > 0"
2024-09-27 16:11:16 +07:00
>
<div class="col-4">
<div class="row items-center no-wrap">
<div class="app-text-muted q-mr-sm" v-if="$q.screen.gt.sm">
{{ $t('general.recordPerPage') }}
</div>
<div>
<q-btn-dropdown
dense
unelevated
2024-10-03 11:22:21 +07:00
:label="quotationPageSize"
2024-09-27 16:11:16 +07:00
class="bordered q-pl-md"
>
<q-list>
<q-item
v-for="v in [10, 30, 50, 100, 500, 1000]"
:key="v"
clickable
v-close-popup
2024-10-03 11:22:21 +07:00
@click="quotationPageSize = v"
2024-09-27 16:11:16 +07:00
>
<q-item-section>
<q-item-label>{{ v }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
</div>
</div>
</div>
<div class="col-4 row justify-center app-text-muted">
{{
$t('general.recordsPage', {
resultcurrentPage: quotationData.length,
2024-10-24 17:47:43 +07:00
total: pageState.inputSearch
? quotationData.length
: pageState.total,
2024-09-27 16:11:16 +07:00
})
}}
</div>
<nav class="col-4 row justify-end">
<PaginationComponent
2024-10-01 09:48:03 +07:00
v-model:current-page="quotationPage"
v-model:max-page="quotationPageMax"
:fetch-data="fetchQuotationList"
2024-09-27 16:11:16 +07:00
/>
</nav>
</footer>
</div>
</header>
2024-09-16 10:32:06 +07:00
</div>
2024-09-27 16:11:16 +07:00
2024-10-03 11:22:21 +07:00
<!-- NOTE: SEC START - Dialog -->
2024-10-04 15:12:13 +07:00
<!-- NOTE: START - Quotation Form, Add Quotation -->
2024-10-03 11:22:21 +07:00
2024-09-27 16:11:16 +07:00
<DialogForm
:title="$t('general.add', { text: $t('quotation.title') })"
v-model:modal="pageState.addModal"
:submit-label="$t('general.add', { text: $t('quotation.title') })"
submit-icon="mdi-check"
height="auto"
width="60vw"
:submit="
() => {
quotationFormState.mode = 'create';
2024-10-10 13:23:30 +07:00
triggerQuotationDialog({ statusDialog: 'create' });
}
"
2024-10-03 11:14:12 +07:00
:close="
() => {
branchId = '';
quotationFormData.customerBranchId = '';
}
"
:beforeClose="
() => {
agentPrice = false;
special = false;
return false;
}
"
2024-08-02 16:13:07 +07:00
>
2024-09-27 16:11:16 +07:00
<header class="q-mx-lg q-mt-lg">
<ProfileBanner
img="/images/quotation-bg-avatar.png"
fallback-cover="/images/quotation-banner.png"
bg-color="var(--surface-1)"
:title="$t('general.itemNo', { msg: $t('quotation.title') })"
hideActive
readonly
noImageAction
hideFade
/>
</header>
<section class="col surface-1 q-ma-lg rounded bordered row scroll">
<div
class="col-12 q-px-md q-py-lg"
id="customer-form-content"
style="height: 100%; max-height: 100%; overflow-y: auto"
>
<FormAbout
2024-10-04 09:45:05 +07:00
on-create
2024-10-04 15:12:13 +07:00
v-model:agent-price="agentPrice"
2024-10-03 11:14:12 +07:00
v-model:branch-id="branchId"
2024-10-04 15:12:13 +07:00
v-model:special="special"
2024-10-03 11:14:12 +07:00
v-model:customer-branch-id="quotationFormData.customerBranchId"
@add-customer="triggerSelectTypeCustomerd()"
/>
2024-08-02 16:13:07 +07:00
</div>
2024-09-27 16:11:16 +07:00
</section>
</DialogForm>
2024-10-03 11:22:21 +07:00
<!-- NOTE: END - Quotation Form -->
2024-10-03 10:50:48 +07:00
<!-- NOTE: START - Customer / Employer Type Select Form -->
<DialogForm
v-model:modal="emptyCreateDialog"
:title="$t('customer.employerType')"
hide-footer
no-app-box
width="40vw"
height="250px"
:close="
() => {
emptyCreateDialog = false;
onCreateImageList = { selectedImage: '', list: [] };
}
"
>
<div class="full-height row q-pa-md">
<ItemCard
class="col q-mx-sm full-height"
v-for="value in dialogCreateCustomerItem"
:key="value.text"
:icon="value.icon"
:text="value.text"
:icon-color="value.iconColor"
:bg-color="value.color"
@trigger="
() => {
triggerCreateCustomerd({
type:
value.text === 'customer.employerLegalEntity' ? 'CORP' : 'PERS',
});
emptyCreateDialog = false;
}
2024-09-25 18:06:05 +07:00
"
/>
</div>
</DialogForm>
2024-09-25 18:06:05 +07:00
2024-10-03 10:50:48 +07:00
<!-- NOTE: END - Customer / Employer Type Form -->
<!-- NOTE: START - Customer / Employer Form -->
<DialogForm
hide-footer
ref="formDialogRef"
v-model:modal="customerFormState.dialogModal"
:title="
customerFormState.dialogType === 'create'
? $t(`general.add`, {
text: `${$t('customer.employer')} `,
})
: `${$t('customer.employer')} `
"
2024-10-02 14:05:36 +07:00
:submit="
() => {
submitCustomer();
}
"
:close="
() => {
customerFormState.dialogModal = false;
2024-10-04 17:01:24 +07:00
customerFormStore.resetForm(true);
2024-10-16 13:10:40 +07:00
setDefaultCustomer();
}
"
>
<div
:class="{
'q-mx-lg q-my-md': $q.screen.gt.sm,
'q-mx-md q-my-sm': !$q.screen.gt.sm,
}"
>
2024-09-25 18:06:05 +07:00
<ProfileBanner
v-if="customerFormData.customerBranch !== undefined"
active
hide-fade
:fallback-cover="`/images/customer-${customerFormData.customerType}-banner-bg.jpg`"
:img="
customerFormState.customerImageUrl ||
`/images/customer-${customerFormData.customerType}-avartar-${customerFormData.customerType === 'PERS' ? customerFormData.customerBranch[0]?.gender : 'male'}.png`
"
:fallbackImg="`/images/customer-${customerFormData.customerType}-avartar-${customerFormData.customerType === 'PERS' ? customerFormData.customerBranch[0]?.gender : 'male'}.png`"
:color="`hsla(var(--${customerFormData.customerType === 'PERS' ? 'teal-10-hsl' : 'violet-11-hsl'})/1)`"
:bg-color="`hsla(var(--${customerFormData.customerType === 'PERS' ? 'teal-10-hsl' : 'violet-11-hsl'})/0.1)`"
:icon="
customerFormData.customerType === 'PERS'
? 'mdi-account-plus-outline'
: 'mdi-office-building-outline'
"
:title="
customerFormData.customerType === 'PERS'
? `${customerFormData.customerBranch[0]?.firstName || ''} ${customerFormData.customerBranch[0]?.lastName || ''}`
: customerFormData.customerBranch[0]?.registerName || ''
2024-09-25 18:06:05 +07:00
"
:caption="
customerFormData.customerType === 'PERS'
? `${customerFormData.customerBranch[0]?.firstNameEN || ''} ${customerFormData.customerBranch[0]?.lastNameEN || ''}`
: customerFormData.customerBranch[0]?.registerNameEN || ''
2024-09-25 18:06:05 +07:00
"
@view="
() => {
customerFormState.imageDialog = true;
customerFormState.isImageEdit = false;
}
"
@edit="
customerFormState.imageDialog = customerFormState.isImageEdit = true
"
/>
</div>
<div
class="col"
:class="{
'q-px-lg q-pb-lg': $q.screen.gt.sm,
'q-px-md q-pb-sm': !$q.screen.gt.sm,
}"
2024-09-25 18:06:05 +07:00
>
<div
style="overflow-y: auto"
class="row full-width full-height surface-1 rounded bordered relative-position"
>
2024-09-25 18:06:05 +07:00
<div
:class="{
'q-py-md q-px-lg': $q.screen.gt.sm,
'q-py-sm q-px-lg': !$q.screen.gt.sm,
}"
style="position: absolute; z-index: 99999; top: 0; right: 0"
2024-09-25 18:06:05 +07:00
>
2024-09-30 11:04:12 +07:00
<div
v-if="customerFormData.status !== 'INACTIVE'"
class="surface-1 row rounded"
2024-09-30 11:04:12 +07:00
>
<SaveButton
v-if="
customerFormState.dialogType === 'edit' ||
customerFormState.dialogType === 'create'
"
2024-09-30 11:04:12 +07:00
id="btn-info-basic-save"
icon-only
type="submit"
/>
</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"
>
<SideMenu
:menu="[
{
name: $t('form.customerInformation'),
anchor: 'form-information',
},
{
name: $t('customerBranch.tab.business'),
anchor: 'form-business',
},
{
name: $t('form.address'),
anchor: 'form-address',
},
]"
background="transparent"
:active="{
background: 'hsla(var(--blue-6-hsl) / .2)',
foreground: 'var(--blue-6)',
}"
scroll-element="#branch-form"
/>
</div>
2024-09-25 18:06:05 +07:00
<div
class="col-12 col-md-10 full-height q-col-gutter-sm"
:class="{
'q-py-md q-pr-md ': $q.screen.gt.sm,
'q-py-md q-px-lg': !$q.screen.gt.sm,
}"
id="branch-form"
style="overflow-y: auto"
>
<EmployerFormAbout
id="form-information"
show-title
2024-10-17 12:56:35 +07:00
:index="'0'"
:customerType="customerFormData.customerType"
2024-10-04 17:01:24 +07:00
:readonly="customerFormState.dialogType === 'info'"
v-model:citizen-id="formDataCustomerBranch.citizenId"
v-model:prefix-name="formDataCustomerBranch.namePrefix"
v-model:first-name="formDataCustomerBranch.firstName"
v-model:last-name="formDataCustomerBranch.lastName"
v-model:first-name-en="formDataCustomerBranch.firstNameEN"
v-model:last-name-en="formDataCustomerBranch.lastNameEN"
v-model:gender="formDataCustomerBranch.gender"
v-model:birth-date="formDataCustomerBranch.birthDate"
v-model:customer-name="formDataCustomerBranch.customerName"
v-model:legal-person-no="formDataCustomerBranch.legalPersonNo"
v-model:register-name="formDataCustomerBranch.registerName"
v-model:register-name-en="formDataCustomerBranch.registerNameEN"
v-model:register-date="formDataCustomerBranch.registerDate"
v-model:authorized-capital="
formDataCustomerBranch.authorizedCapital
"
2024-10-02 14:05:36 +07:00
v-model:telephone-no="formDataCustomerBranch.telephoneNo"
/>
2024-09-30 11:04:12 +07:00
<EmployerFormBusiness
id="form-business"
show-title
2024-10-17 12:56:35 +07:00
prefix-id="dialog"
dense
outlined
2024-10-04 17:01:24 +07:00
:readonly="customerFormState.dialogType === 'info'"
v-model:bussiness-type="formDataCustomerBranch.businessType"
v-model:job-position="formDataCustomerBranch.jobPosition"
v-model:job-description="formDataCustomerBranch.jobDescription"
v-model:pay-date="formDataCustomerBranch.payDate"
v-model:pay-date-en="formDataCustomerBranch.payDateEN"
v-model:wage-rate="formDataCustomerBranch.wageRate"
v-model:wage-rate-text="formDataCustomerBranch.wageRateText"
/>
<AddressForm
id="form-address"
prefix-id="employer"
dense
outlined
use-employment
:title="$t('form.address')"
:addressTitle="$t('form.address')"
:addressTitleEN="$t('form.address', { suffix: '(EN)' })"
2024-10-04 17:01:24 +07:00
:readonly="customerFormState.dialogType === 'info'"
v-model:bussiness-type="formDataCustomerBranch.businessType"
v-model:address="formDataCustomerBranch.address"
2024-10-02 11:39:56 +07:00
v-model:address-en="formDataCustomerBranch.addressEN"
v-model:street="formDataCustomerBranch.street"
2024-10-02 11:39:56 +07:00
v-model:street-en="formDataCustomerBranch.streetEN"
v-model:moo="formDataCustomerBranch.moo"
2024-10-02 11:39:56 +07:00
v-model:moo-en="formDataCustomerBranch.mooEN"
v-model:soi="formDataCustomerBranch.soi"
2024-10-02 11:39:56 +07:00
v-model:soi-en="formDataCustomerBranch.soiEN"
v-model:province-id="formDataCustomerBranch.provinceId"
v-model:district-id="formDataCustomerBranch.districtId"
2024-10-02 11:39:56 +07:00
v-model:sub-district-id="formDataCustomerBranch.subDistrictId"
v-model:home-code="formDataCustomerBranch.homeCode"
/>
2024-09-25 18:06:05 +07:00
</div>
</div>
</div>
</DialogForm>
2024-06-19 15:43:58 +07:00
</template>
<style scoped></style>