feat: แก้ สถานะ ของCustomer
This commit is contained in:
parent
5a0087b649
commit
0a10ac94fd
3 changed files with 84 additions and 6 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import AppBox from './app/AppBox.vue';
|
import AppBox from './app/AppBox.vue';
|
||||||
|
|
||||||
|
import AppCircle from 'components/app/AppCircle.vue';
|
||||||
|
|
||||||
import { CustomerBranch } from 'stores/customer/types';
|
import { CustomerBranch } from 'stores/customer/types';
|
||||||
|
|
||||||
withDefaults(
|
withDefaults(
|
||||||
|
|
@ -20,6 +22,7 @@ withDefaults(
|
||||||
name: string;
|
name: string;
|
||||||
code: string;
|
code: string;
|
||||||
detail?: { label: string; value: string }[];
|
detail?: { label: string; value: string }[];
|
||||||
|
status: string;
|
||||||
};
|
};
|
||||||
hideButton?: boolean;
|
hideButton?: boolean;
|
||||||
badge?: CustomerBranch[];
|
badge?: CustomerBranch[];
|
||||||
|
|
@ -48,6 +51,7 @@ defineEmits<{
|
||||||
class="flip"
|
class="flip"
|
||||||
:class="{
|
:class="{
|
||||||
'person-box__no-hover': noHover,
|
'person-box__no-hover': noHover,
|
||||||
|
'status-inactive': list.status === 'INACTIVE',
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<AppBox
|
<AppBox
|
||||||
|
|
@ -132,7 +136,7 @@ defineEmits<{
|
||||||
dense
|
dense
|
||||||
size="sm"
|
size="sm"
|
||||||
@click="$emit('toggleStatus', metadata.id)"
|
@click="$emit('toggleStatus', metadata.id)"
|
||||||
:model-value="!metadata.disabled"
|
:model-value="metadata.disabled"
|
||||||
val="xs"
|
val="xs"
|
||||||
padding="none"
|
padding="none"
|
||||||
>
|
>
|
||||||
|
|
@ -152,9 +156,35 @@ defineEmits<{
|
||||||
</q-btn>
|
</q-btn>
|
||||||
<div class="row justify-center relative-position">
|
<div class="row justify-center relative-position">
|
||||||
<q-card-section class="q-pt-md img-decoration">
|
<q-card-section class="q-pt-md img-decoration">
|
||||||
<q-avatar size="80px">
|
<div style="position: relative">
|
||||||
|
<AppCircle
|
||||||
|
bordered
|
||||||
|
class="avatar"
|
||||||
|
style="border: 2px solid var(--border-color); height: 80px"
|
||||||
|
>
|
||||||
|
<q-img
|
||||||
|
:src="list.imageUrl ?? '/no-profile.png'"
|
||||||
|
style="object-fit: cover; width: 100%; height: 100%"
|
||||||
|
/>
|
||||||
|
<div class="status-circle" style="">
|
||||||
|
<q-icon
|
||||||
|
:name="`mdi-${list.status === 'INACTIVE' ? 'close' : 'check'}`"
|
||||||
|
:style="`color:${list.status === 'INACTIVE' ? 'var(--gray-6)' : 'white'}`"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</AppCircle>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- <q-avatar size="80px">
|
||||||
<img :src="list.imageUrl ?? '/no-profile.png'" />
|
<img :src="list.imageUrl ?? '/no-profile.png'" />
|
||||||
</q-avatar>
|
</q-avatar>
|
||||||
|
|
||||||
|
<div class="status-circle">
|
||||||
|
<q-icon
|
||||||
|
:name="`mdi-${list.status === 'INACTIVE' ? 'close' : 'check'}`"
|
||||||
|
:style="`color:${list.status === 'INACTIVE' ? 'var(--gray-6)' : 'white'}`"
|
||||||
|
/>
|
||||||
|
</div> -->
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-title">
|
<div class="box-title">
|
||||||
|
|
@ -293,4 +323,26 @@ defineEmits<{
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.status-inactive {
|
||||||
|
opacity: 0.5;
|
||||||
|
|
||||||
|
.status-circle {
|
||||||
|
background-color: var(--surface-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-circle {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: var(--teal-6);
|
||||||
|
border: 2px solid var(--border-color);
|
||||||
|
bottom: 0.5rem;
|
||||||
|
right: 0.3rem;
|
||||||
|
position: absolute;
|
||||||
|
display: inline-flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -720,6 +720,12 @@ async function fetchListEmployee(param?: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function toggleStatusCustomer(id: string, status: boolean) {
|
||||||
|
await editById(id, { status: !status ? 'ACTIVE' : 'INACTIVE' });
|
||||||
|
|
||||||
|
await fetchListCustomer();
|
||||||
|
}
|
||||||
|
|
||||||
async function onSubmitEdit(id: string) {
|
async function onSubmitEdit(id: string) {
|
||||||
if (selectorLabel.value === 'EMPLOYER') {
|
if (selectorLabel.value === 'EMPLOYER') {
|
||||||
if (!formData.value) return;
|
if (!formData.value) return;
|
||||||
|
|
@ -1429,7 +1435,10 @@ watch(selectorLabel, async () => {
|
||||||
:key="i.id"
|
:key="i.id"
|
||||||
class="hover-card"
|
class="hover-card"
|
||||||
:color="i.customerType === 'CORP' ? 'purple' : 'green'"
|
:color="i.customerType === 'CORP' ? 'purple' : 'green'"
|
||||||
:metadata="{ id: '1', disabled: false }"
|
:metadata="{
|
||||||
|
id: i.id,
|
||||||
|
disabled: i.status === 'ACTIVE' || i.status === 'CREATED',
|
||||||
|
}"
|
||||||
:badge="i.branch"
|
:badge="i.branch"
|
||||||
:list="{
|
:list="{
|
||||||
id: i.id,
|
id: i.id,
|
||||||
|
|
@ -1437,6 +1446,7 @@ watch(selectorLabel, async () => {
|
||||||
type: i.customerType,
|
type: i.customerType,
|
||||||
name: i.customerName === '' ? '-' : i.customerName,
|
name: i.customerName === '' ? '-' : i.customerName,
|
||||||
code: i.code,
|
code: i.code,
|
||||||
|
status: i.status,
|
||||||
|
|
||||||
detail: [
|
detail: [
|
||||||
{
|
{
|
||||||
|
|
@ -1488,6 +1498,14 @@ watch(selectorLabel, async () => {
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
@delete-card="deleteCustomerById(i.id)"
|
@delete-card="deleteCustomerById(i.id)"
|
||||||
|
@toggle-status="
|
||||||
|
() => {
|
||||||
|
toggleStatusCustomer(
|
||||||
|
i.id,
|
||||||
|
i.status === 'ACTIVE' ? true : false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -2250,12 +2268,16 @@ watch(selectorLabel, async () => {
|
||||||
:color="
|
:color="
|
||||||
currentCustomer.customerType === 'CORP' ? 'purple' : 'green'
|
currentCustomer.customerType === 'CORP' ? 'purple' : 'green'
|
||||||
"
|
"
|
||||||
:metadata="{ id: '1', disabled: false }"
|
:metadata="{
|
||||||
|
id: '1',
|
||||||
|
disabled: currentCustomer.status === 'ACTIVE',
|
||||||
|
}"
|
||||||
:list="{
|
:list="{
|
||||||
id: '1',
|
id: '1',
|
||||||
type: currentCustomer.customerType,
|
type: currentCustomer.customerType,
|
||||||
name: currentCustomer.customerName,
|
name: currentCustomer.customerName,
|
||||||
imageUrl: currentCustomer.imageUrl,
|
imageUrl: currentCustomer.imageUrl,
|
||||||
|
status: currentCustomer.status,
|
||||||
code: 'HQ006',
|
code: 'HQ006',
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
|
|
@ -2442,12 +2464,16 @@ watch(selectorLabel, async () => {
|
||||||
:color="
|
:color="
|
||||||
currentCustomer.customerType === 'CORP' ? 'purple' : 'green'
|
currentCustomer.customerType === 'CORP' ? 'purple' : 'green'
|
||||||
"
|
"
|
||||||
:metadata="{ id: '1', disabled: false }"
|
:metadata="{
|
||||||
|
id: '1',
|
||||||
|
disabled: currentCustomer.status === 'ACTIVE',
|
||||||
|
}"
|
||||||
:list="{
|
:list="{
|
||||||
id: '1',
|
id: '1',
|
||||||
type: currentCustomer.customerType,
|
type: currentCustomer.customerType,
|
||||||
name: currentCustomer.customerName,
|
name: currentCustomer.customerName,
|
||||||
imageUrl: currentCustomer.imageUrl,
|
imageUrl: currentCustomer.imageUrl,
|
||||||
|
status: currentCustomer.status,
|
||||||
code: 'HQ006',
|
code: 'HQ006',
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ const useCustomerStore = defineStore('api-customer', () => {
|
||||||
|
|
||||||
async function editById(
|
async function editById(
|
||||||
id: string,
|
id: string,
|
||||||
data: CustomerUpdate,
|
data: Partial<CustomerUpdate>,
|
||||||
flow?: {
|
flow?: {
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
refTransactionId: string;
|
refTransactionId: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue