refactor: move button product

This commit is contained in:
Methapon Metanipat 2024-08-19 15:15:39 +07:00
parent a6ad22f8de
commit 42598b0653

View file

@ -214,7 +214,6 @@ const profileUrl = ref<string | null>('');
const pathGroupName = ref(''); const pathGroupName = ref('');
const pathTypeName = ref(''); const pathTypeName = ref('');
const dialogProductServiceType = ref(false);
const dialogTotalProduct = ref(false); const dialogTotalProduct = ref(false);
const productMode = ref<'group' | 'type' | 'service' | 'product'>('group'); const productMode = ref<'group' | 'type' | 'service' | 'product'>('group');
@ -225,7 +224,6 @@ const product = ref<(ProductList & { type: 'product' })[]>();
const productIsAdd = ref<(ProductList & { type: 'product' })[]>(); const productIsAdd = ref<(ProductList & { type: 'product' })[]>();
const service = ref<(Service & { type: 'service' })[]>(); const service = ref<(Service & { type: 'service' })[]>();
const resultSearchProduct = ref<ProductList[]>(); const resultSearchProduct = ref<ProductList[]>();
const productAndService = ref<ServiceAndProduct[]>([]);
const productAndServiceTab = ref<'product' | 'service'>('service'); const productAndServiceTab = ref<'product' | 'service'>('service');
const manageWorkNameDialog = ref(false); const manageWorkNameDialog = ref(false);
@ -477,13 +475,6 @@ async function searchProduct(isAdd: boolean = true) {
flowStore.rotate(); flowStore.rotate();
} }
async function featchStatsService() {
const resStatsService = await fetchStatsService();
totalService.value = resStatsService;
flowStore.rotate();
}
async function fetchListOfOptionBranch() { async function fetchListOfOptionBranch() {
const uid = getUserId(); const uid = getUserId();
const role = getRole(); const role = getRole();
@ -503,15 +494,6 @@ async function fetchListOfOptionBranch() {
currentMyBranch.value?.id || ''; currentMyBranch.value?.id || '';
} }
async function featchStatsProduct() {
const resStatsProduct = await fetchStatsProduct({
productTypeId: currentIdType.value,
});
totalProduct.value = resStatsProduct;
flowStore.rotate();
}
async function fetchListType() { async function fetchListType() {
const res = await fetchListProductServiceType({ const res = await fetchListProductServiceType({
page: currentPageType.value, page: currentPageType.value,
@ -663,19 +645,6 @@ async function submitType() {
await fetchListType(); await fetchListType();
} }
const itemCard = [
{
icon: 'mdi:server-network',
text: 'บริการ',
color: 'var(--orange-5)',
},
{
icon: 'mdi:shopping',
text: 'สินค้า',
color: 'var(--green-9)',
},
];
async function toggleStatusProduct(id: string, status: Status) { async function toggleStatusProduct(id: string, status: Status) {
const res = await editProduct(id, { const res = await editProduct(id, {
status: status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE', status: status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE',
@ -783,7 +752,7 @@ async function deleteServiceById(serviceId?: string) {
}); });
} }
async function deleteTypeOfProduct(id?: string) { async function deleteProductConfirm(id?: string) {
dialog({ dialog({
color: 'negative', color: 'negative',
icon: 'mdi-alert', icon: 'mdi-alert',
@ -794,6 +763,11 @@ async function deleteTypeOfProduct(id?: string) {
action: async () => { action: async () => {
const res = await deleteProduct(id ?? currentIdProduct.value); const res = await deleteProduct(id ?? currentIdProduct.value);
if (!res) {
flowStore.rotate();
return;
}
if (productAndServiceTab.value === 'product') { if (productAndServiceTab.value === 'product') {
await fetchListOfProduct(); await fetchListOfProduct();
} }
@ -2734,7 +2708,8 @@ watch(
}[productAndServiceTab] }[productAndServiceTab]
" "
@update:model-value=" @update:model-value="
(v) => (tbControl[productAndServiceTab].fieldSelected = v) (v: string[]) =>
(tbControl[productAndServiceTab].fieldSelected = v)
" "
option-label="label" option-label="label"
option-value="value" option-value="value"
@ -3258,7 +3233,7 @@ watch(
@click=" @click="
() => { () => {
if (props.row.type === 'product') { if (props.row.type === 'product') {
deleteTypeOfProduct(props.row.id); deleteProductConfirm(props.row.id);
} }
if (props.row.type === 'service') { if (props.row.type === 'service') {
deleteServiceById(props.row.id); deleteServiceById(props.row.id);
@ -3710,34 +3685,6 @@ watch(
</InfoForm> </InfoForm>
</DrawerInfo> </DrawerInfo>
<DialogForm
v-model:modal="dialogProductServiceType"
:title="'สร้างสินค้าและบริการ'"
no-footer
no-app-box
max-width="80%"
:close="() => (dialogProductServiceType = false)"
>
<template #body>
<div class="row q-gutter-xl q-pa-sm">
<ItemCard
class="col"
v-for="i in itemCard"
changeColor
:key="i.text"
:icon="i.icon"
:text="i.text"
:color="i.color"
@trigger="
() => {
dialogProductServiceType = false;
}
"
/>
</div>
</template>
</DialogForm>
<!-- work product, product work --> <!-- work product, product work -->
<DialogForm <DialogForm
v-model:modal="dialogTotalProduct" v-model:modal="dialogTotalProduct"
@ -4013,8 +3960,6 @@ watch(
<!-- edit product --> <!-- edit product -->
<!-- :edit="!(formDataProduct.status === 'INACTIVE')" --> <!-- :edit="!(formDataProduct.status === 'INACTIVE')" -->
<DialogForm <DialogForm
edit
:isEdit="infoProductEdit"
v-model:modal="dialogProductEdit" v-model:modal="dialogProductEdit"
noAddress noAddress
:title="$t('editProduct')" :title="$t('editProduct')"
@ -4026,16 +3971,8 @@ watch(
flowStore.rotate(); flowStore.rotate();
} }
" "
:deleteData=" :deleteData="() => deleteProductConfirm()"
() => { :submit="() => submitProduct()"
deleteTypeOfProduct();
}
"
:submit="
() => {
submitProduct();
}
"
:close=" :close="
() => { () => {
infoProductEdit = false; infoProductEdit = false;
@ -4043,6 +3980,7 @@ watch(
flowStore.rotate(); flowStore.rotate();
} }
" "
hide-footer
> >
<div class="q-mx-lg q-mt-lg"> <div class="q-mx-lg q-mt-lg">
<ProfileBanner <ProfileBanner
@ -4084,6 +4022,43 @@ watch(
class="col surface-1 q-ma-lg rounded bordered scroll row relative-position" class="col surface-1 q-ma-lg rounded bordered scroll row relative-position"
id="group-form" id="group-form"
> >
<div
class="surface-1 rounded q-pt-sm row"
style="position: absolute; z-index: 999; right: 4%"
>
<UndoButton
v-if="infoProductEdit"
id="btn-info-basic-undo"
icon-only
@click="
() => {
formDataProduct = { ...prevProduct };
infoProductEdit = false;
}
"
type="button"
/>
<SaveButton
v-if="infoProductEdit"
id="btn-info-basic-save"
icon-only
type="submit"
/>
<EditButton
v-if="!infoProductEdit"
id="btn-info-basic-edit"
icon-only
@click="infoProductEdit = true"
type="button"
/>
<DeleteButton
v-if="!infoProductEdit"
id="btn-info-basic-delete"
icon-only
@click="() => deleteProductConfirm()"
type="button"
/>
</div>
<div <div
class="col" class="col"
style="height: 100%; max-height: 100; overflow-y: auto" style="height: 100%; max-height: 100; overflow-y: auto"