feat: auto select current branch
This commit is contained in:
parent
dcefa3de02
commit
2dac800fad
5 changed files with 81 additions and 66 deletions
|
|
@ -1,6 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import { computed, ref, watch, toRaw } from 'vue';
|
||||
import type { QTableProps } from 'quasar';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { getUserId, getRole } from 'src/services/keycloak';
|
||||
import { Status } from 'src/stores/types';
|
||||
|
||||
import useCustomerStore from 'src/stores/customer';
|
||||
|
|
@ -64,10 +66,10 @@ import useFlowStore from 'src/stores/flow';
|
|||
const { t, locale } = useI18n();
|
||||
const utilsStore = useUtilsStore();
|
||||
const userCustomer = useCustomerStore();
|
||||
const useMyBranch = useMyBranchStore();
|
||||
const userBranchStore = useMyBranchStore();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const { fetchListOptionBranch } = useMyBranch;
|
||||
const { currentMyBranch } = storeToRefs(userBranchStore);
|
||||
|
||||
const columnsEmployee = [
|
||||
{
|
||||
|
|
@ -170,7 +172,7 @@ const formData = ref<CustomerCreate>({
|
|||
customerName: '',
|
||||
customerNameEN: '',
|
||||
taxNo: '',
|
||||
registeredBranchId: '',
|
||||
registeredBranchId: currentMyBranch.value?.id || '',
|
||||
customerBranch: [
|
||||
{
|
||||
code: '',
|
||||
|
|
@ -675,7 +677,7 @@ function clearForm() {
|
|||
customerNameEN: '',
|
||||
personName: '',
|
||||
taxNo: '',
|
||||
registeredBranchId: '',
|
||||
registeredBranchId: currentMyBranch.value?.id || '',
|
||||
customerBranch: [
|
||||
{
|
||||
code: '',
|
||||
|
|
@ -896,9 +898,20 @@ async function onSubmitCustomerBranch() {
|
|||
}
|
||||
|
||||
async function fetchListOfOptionBranch() {
|
||||
const res = await fetchListOptionBranch({ pageSize: 999 });
|
||||
const uid = getUserId();
|
||||
const role = getRole();
|
||||
|
||||
if (res) branchOption.value = res.result;
|
||||
if (!uid) return;
|
||||
|
||||
if (role?.includes('system')) {
|
||||
const result = await userBranchStore.fetchListOptionBranch();
|
||||
if (result && result.total > 0) branchOption.value = result.result;
|
||||
} else {
|
||||
const result = await userBranchStore.fetchListMyBranch(uid);
|
||||
if (result && result.total > 0) branchOption.value = result.result;
|
||||
}
|
||||
|
||||
formData.value.registeredBranchId = currentMyBranch.value?.id || '';
|
||||
}
|
||||
|
||||
async function fetchListCustomer() {
|
||||
|
|
@ -1773,11 +1786,10 @@ watch([inputSearch, currentStatus], async () => {
|
|||
<div class="column q-pa-md" style="gap: var(--size-1)">
|
||||
<template v-if="selectorLabel === 'EMPLOYER'">
|
||||
<q-item
|
||||
v-close-popup
|
||||
clickable
|
||||
v-close-popup
|
||||
clickable
|
||||
v-for="v in fieldCustomer"
|
||||
:key="v"
|
||||
|
||||
dense
|
||||
class="no-padding flex items-center rounded"
|
||||
active-class="employer-active"
|
||||
|
|
@ -1793,11 +1805,10 @@ watch([inputSearch, currentStatus], async () => {
|
|||
<q-item
|
||||
active
|
||||
dense
|
||||
|
||||
active-class="employer-active"
|
||||
class="no-padding flex items-center rounded"
|
||||
v-close-popup
|
||||
clickable
|
||||
v-close-popup
|
||||
clickable
|
||||
>
|
||||
<span class="q-px-md">
|
||||
{{ $t('totalEmployee') }}
|
||||
|
|
@ -1988,7 +1999,7 @@ watch([inputSearch, currentStatus], async () => {
|
|||
);
|
||||
}
|
||||
"
|
||||
v-close-popup
|
||||
v-close-popup
|
||||
clickable
|
||||
dense
|
||||
class="row q-py-sm"
|
||||
|
|
@ -2009,7 +2020,7 @@ watch([inputSearch, currentStatus], async () => {
|
|||
|
||||
<q-item
|
||||
:id="`view-detail-btn-${props.row.name}-edit`"
|
||||
v-close-popup
|
||||
v-close-popup
|
||||
clickable
|
||||
dense
|
||||
class="row q-py-sm"
|
||||
|
|
@ -2050,8 +2061,7 @@ watch([inputSearch, currentStatus], async () => {
|
|||
<q-item
|
||||
:id="`view-detail-btn-${props.row.name}-delete`"
|
||||
dense
|
||||
v-close-popup
|
||||
|
||||
v-close-popup
|
||||
:clickable="props.row.status === 'CREATED'"
|
||||
class="row"
|
||||
:class="{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
import { ref, watch, reactive } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { onMounted } from 'vue';
|
||||
import { getUserId, getRole } from 'src/services/keycloak';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import type { QTableProps } from 'quasar';
|
||||
import ItemCard from 'components/ItemCard.vue';
|
||||
|
|
@ -33,9 +34,9 @@ import useMyBranchStore from 'src/stores/my-branch';
|
|||
import { dateFormat } from 'src/utils/datetime';
|
||||
import { formatNumberDecimal } from 'src/stores/utils';
|
||||
|
||||
const useMyBranch = useMyBranchStore();
|
||||
const userBranchStore = useMyBranchStore();
|
||||
|
||||
const { fetchListOptionBranch } = useMyBranch;
|
||||
const { currentMyBranch } = storeToRefs(userBranchStore);
|
||||
|
||||
import { Status } from 'src/stores/types';
|
||||
|
||||
|
|
@ -403,9 +404,22 @@ async function featchStatsService() {
|
|||
}
|
||||
|
||||
async function fetchListOfOptionBranch() {
|
||||
const res = await fetchListOptionBranch({ pageSize: 999 });
|
||||
const uid = getUserId();
|
||||
const role = getRole();
|
||||
|
||||
if (res) branchOption.value = res.result;
|
||||
if (!uid) return;
|
||||
|
||||
if (role?.includes('system')) {
|
||||
const result = await userBranchStore.fetchListOptionBranch();
|
||||
if (result && result.total > 0) branchOption.value = result.result;
|
||||
} else {
|
||||
const result = await userBranchStore.fetchListMyBranch(uid);
|
||||
if (result && result.total > 0) branchOption.value = result.result;
|
||||
}
|
||||
|
||||
formDataProduct.value.registeredBranchId = currentMyBranch.value?.id || '';
|
||||
formDataProductService.value.registeredBranchId =
|
||||
currentMyBranch.value?.id || '';
|
||||
}
|
||||
|
||||
async function featchStatsProduct() {
|
||||
|
|
@ -3093,8 +3107,6 @@ watch(inputSearchProductAndService, async () => {
|
|||
class="col-md-10 col-sm-12"
|
||||
>
|
||||
<div class="surface-1 rounded bordered q-pa-lg full-width row">
|
||||
|
||||
|
||||
<BasicInformation
|
||||
dense
|
||||
service
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue