2024-06-10 16:42:59 +07:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
import AppBox from 'components/app/AppBox.vue';
|
|
|
|
|
import ProductCardComponent from 'src/components/04_product-service/ProductCardComponent.vue';
|
|
|
|
|
import StatCard from 'components/StatCardComponent.vue';
|
2024-06-10 17:42:37 +07:00
|
|
|
import NewProductCardCompoent from 'components/04_product-service/NewProductCardComponent.vue';
|
2024-06-11 12:01:35 +07:00
|
|
|
import DrawerInfo from 'src/components/DrawerInfo.vue';
|
|
|
|
|
import BasicInformation from 'src/components/04_product-service/BasicInformation.vue';
|
|
|
|
|
import FormDialog from 'src/components/FormDialog.vue';
|
|
|
|
|
import { dialog } from 'src/stores/utils';
|
2024-06-11 15:04:01 +07:00
|
|
|
|
|
|
|
|
import useProductServiceStore from 'src/stores/product-service';
|
|
|
|
|
import {
|
|
|
|
|
ProductGroup,
|
|
|
|
|
ProductGroupCreate,
|
|
|
|
|
} from 'src/stores/product-service/types';
|
|
|
|
|
|
|
|
|
|
const productServiceStore = useProductServiceStore();
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
fetchStatsProductGroup,
|
|
|
|
|
fetchListProductService,
|
|
|
|
|
createProductService,
|
|
|
|
|
} = productServiceStore;
|
|
|
|
|
|
2024-06-11 15:11:55 +07:00
|
|
|
import ItemCard from 'src/components/ItemCard.vue';
|
|
|
|
|
import TotalProductComponent from 'src/components/04_product-service/TotalProductComponent.vue';
|
|
|
|
|
|
2024-06-10 16:42:59 +07:00
|
|
|
const cardData = ref({
|
|
|
|
|
title: 'งาน MCU',
|
|
|
|
|
subtitle: 'G00000000001',
|
2024-06-10 17:42:37 +07:00
|
|
|
color: 'var(--pink-6)',
|
2024-06-10 16:42:59 +07:00
|
|
|
status: true,
|
|
|
|
|
date: new Date(),
|
|
|
|
|
});
|
|
|
|
|
|
2024-06-11 12:01:35 +07:00
|
|
|
const cardTypeData = ref({
|
|
|
|
|
title: 'บริการพิสูจน์สัญชาติ',
|
|
|
|
|
subtitle: 'TG10000000001',
|
|
|
|
|
color: 'var(--purple-11)',
|
|
|
|
|
status: true,
|
|
|
|
|
date: new Date(),
|
|
|
|
|
});
|
|
|
|
|
|
2024-06-10 16:42:59 +07:00
|
|
|
const stat = ref<
|
|
|
|
|
{
|
|
|
|
|
count: number;
|
|
|
|
|
label: string;
|
|
|
|
|
color: 'pink' | 'purple' | 'green';
|
|
|
|
|
}[]
|
|
|
|
|
>([
|
|
|
|
|
{ count: 5, label: 'branchHQLabel', color: 'pink' },
|
|
|
|
|
{ count: 4, label: 'branchLabel', color: 'purple' },
|
|
|
|
|
{ count: 12, label: 'branchLabel', color: 'green' },
|
|
|
|
|
]);
|
|
|
|
|
|
2024-06-11 12:01:35 +07:00
|
|
|
import { useI18n } from 'vue-i18n';
|
2024-06-11 15:04:01 +07:00
|
|
|
import { onMounted } from 'vue';
|
2024-06-11 12:01:35 +07:00
|
|
|
|
|
|
|
|
const { t } = useI18n();
|
|
|
|
|
|
2024-06-10 16:42:59 +07:00
|
|
|
const inputSearch = ref<string>('');
|
2024-06-11 12:01:35 +07:00
|
|
|
const drawerInfo = ref<boolean>(false);
|
|
|
|
|
const isEdit = ref<boolean>(false);
|
|
|
|
|
const dialogInputForm = ref<boolean>(false);
|
2024-06-11 14:20:58 +07:00
|
|
|
const isType = ref<boolean>(false);
|
2024-06-11 12:01:35 +07:00
|
|
|
const groupName = ref<string>('test');
|
2024-06-11 15:11:55 +07:00
|
|
|
const dialogProductServiceType = ref<boolean>(false);
|
|
|
|
|
const dialogTotalProduct = ref<boolean>(false);
|
|
|
|
|
const productMode = ref<'group' | 'type' | 'service' | 'product'>('group');
|
2024-06-11 15:04:01 +07:00
|
|
|
const productGroup = ref<ProductGroup[]>();
|
|
|
|
|
|
|
|
|
|
const formData = ref<ProductGroupCreate>({
|
2024-06-11 12:01:35 +07:00
|
|
|
remark: '',
|
|
|
|
|
detail: '',
|
|
|
|
|
name: '',
|
|
|
|
|
code: '',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
async function submitType() {
|
|
|
|
|
console.log(formData.value);
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-11 15:11:55 +07:00
|
|
|
const itemCard = [
|
|
|
|
|
{
|
|
|
|
|
icon: 'mdi:server-network',
|
|
|
|
|
text: 'บริการ',
|
|
|
|
|
color: 'var(--orange-5)',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
icon: 'mdi:shopping',
|
|
|
|
|
text: 'สินค้า',
|
|
|
|
|
color: 'var(--green-9)',
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
2024-06-11 12:01:35 +07:00
|
|
|
async function deleteProductById() {
|
|
|
|
|
dialog({
|
|
|
|
|
color: 'negative',
|
|
|
|
|
icon: 'mdi-alert',
|
|
|
|
|
title: t('deleteConfirmTitle'),
|
|
|
|
|
actionText: t('ok'),
|
|
|
|
|
persistent: true,
|
|
|
|
|
message: t('deleteConfirmMessage'),
|
|
|
|
|
action: async () => {
|
|
|
|
|
console.log('deleted');
|
|
|
|
|
drawerInfo.value = false;
|
|
|
|
|
},
|
|
|
|
|
cancel: () => {},
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-06-11 15:04:01 +07:00
|
|
|
|
|
|
|
|
function clearForm() {
|
|
|
|
|
formData.value = {
|
|
|
|
|
remark: '',
|
|
|
|
|
detail: '',
|
|
|
|
|
name: '',
|
|
|
|
|
code: '',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
dialogInputForm.value = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function submitGroup() {
|
|
|
|
|
await createProductService(formData.value);
|
|
|
|
|
|
|
|
|
|
await fetchList();
|
|
|
|
|
clearForm();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function fetchList() {
|
|
|
|
|
const res = await fetchListProductService();
|
|
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
|
productGroup.value = res;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
await fetchList();
|
|
|
|
|
});
|
2024-06-10 16:42:59 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2024-06-11 12:01:35 +07:00
|
|
|
<div v class="column q-pb-lg">
|
2024-06-11 14:20:58 +07:00
|
|
|
<div v-if="isType" class="row items-center q-mb-md">
|
2024-06-11 12:01:35 +07:00
|
|
|
<q-btn
|
|
|
|
|
round
|
|
|
|
|
icon="mdi-arrow-left"
|
|
|
|
|
flat
|
|
|
|
|
dense
|
2024-06-11 14:20:58 +07:00
|
|
|
@click="isType = false"
|
2024-06-11 12:01:35 +07:00
|
|
|
class="q-mr-md"
|
|
|
|
|
/>
|
2024-06-11 15:11:55 +07:00
|
|
|
<div class="text-h6 app-text-muted q-mr-sm">
|
|
|
|
|
{{ groupName }}
|
2024-06-11 12:01:35 +07:00
|
|
|
</div>
|
|
|
|
|
<div class="text-h6 app-text-muted q-mx-sm">/</div>
|
2024-06-11 15:11:55 +07:00
|
|
|
<div class="text-h6 text-weight-bold">
|
|
|
|
|
{{ $t('ProductAndServiceType') }}
|
2024-06-11 12:01:35 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else class="text-h6 text-weight-bold q-mb-md">
|
|
|
|
|
{{ $t('ProductAndService') }}
|
2024-06-11 15:11:55 +07:00
|
|
|
// ปุ่มเลือกสร้าง
|
|
|
|
|
<q-btn
|
|
|
|
|
unelevated
|
|
|
|
|
@click="dialogProductServiceType = true"
|
|
|
|
|
size="lg"
|
|
|
|
|
class="color-btn"
|
|
|
|
|
icon="mdi-plus"
|
|
|
|
|
round
|
|
|
|
|
/>
|
|
|
|
|
// ปุ่มรวมสินค้าทั้งหมด
|
|
|
|
|
<q-btn
|
|
|
|
|
unelevated
|
|
|
|
|
@click="dialogTotalProduct = true"
|
|
|
|
|
size="lg"
|
|
|
|
|
class="color-btn"
|
|
|
|
|
icon="mdi-plus"
|
|
|
|
|
round
|
|
|
|
|
/>
|
2024-06-11 12:01:35 +07:00
|
|
|
</div>
|
2024-06-11 15:11:55 +07:00
|
|
|
|
2024-06-10 16:42:59 +07:00
|
|
|
<AppBox bordered class="q-mb-md">
|
|
|
|
|
<StatCard label-i18n :branch="stat" :dark="$q.dark.isActive" />
|
|
|
|
|
</AppBox>
|
|
|
|
|
<AppBox bordered style="min-height: 80vh">
|
|
|
|
|
<div class="row justify-between">
|
2024-06-11 14:20:58 +07:00
|
|
|
<div v-if="isType" class="text-h6 text-weight-bold q-mb-md">
|
2024-06-11 12:01:35 +07:00
|
|
|
{{ $t('ProductAndServiceType') }}
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else class="text-h6 text-weight-bold q-mb-md">
|
|
|
|
|
{{ $t('ProductAndServiceAll') }}
|
2024-06-10 16:42:59 +07:00
|
|
|
</div>
|
|
|
|
|
<div class="row q-px-md q-pb-md">
|
|
|
|
|
<q-input
|
|
|
|
|
style="width: 250px"
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
:label="$t('search')"
|
|
|
|
|
class="q-mr-lg"
|
|
|
|
|
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
|
|
|
|
v-model="inputSearch"
|
|
|
|
|
debounce="500"
|
|
|
|
|
></q-input>
|
|
|
|
|
<q-btn
|
|
|
|
|
icon="mdi-tune-vertical-variant"
|
|
|
|
|
size="sm"
|
|
|
|
|
:color="$q.dark.isActive ? 'dark' : 'white'"
|
|
|
|
|
:text-color="$q.dark.isActive ? 'white' : 'dark'"
|
|
|
|
|
class="bordered rounded"
|
|
|
|
|
unelevated
|
|
|
|
|
>
|
|
|
|
|
<q-menu class="bordered">
|
|
|
|
|
<q-list v-close-popup dense>
|
|
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
class="flex items-center"
|
|
|
|
|
@click="console.log('test')"
|
|
|
|
|
>
|
|
|
|
|
{{ $t('all') }}
|
|
|
|
|
</q-item>
|
|
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
class="flex items-center"
|
|
|
|
|
@click="console.log('test')"
|
|
|
|
|
>
|
|
|
|
|
{{ $t('statusACTIVE') }}
|
|
|
|
|
</q-item>
|
|
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
class="flex items-center"
|
|
|
|
|
@click="console.log('test')"
|
|
|
|
|
>
|
|
|
|
|
{{ $t('statusINACTIVE') }}
|
|
|
|
|
</q-item>
|
|
|
|
|
</q-list>
|
|
|
|
|
</q-menu>
|
|
|
|
|
</q-btn>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="row q-col-gutter-lg">
|
2024-06-11 09:38:05 +07:00
|
|
|
<div
|
|
|
|
|
:class="`${$q.screen.gt.sm ? 'col-3' : $q.screen.gt.xs ? 'col-6' : 'col-12'}`"
|
2024-06-11 15:04:40 +07:00
|
|
|
v-for="(v, i) in isType ? productGroup : productGroup"
|
2024-06-11 09:38:05 +07:00
|
|
|
:key="i"
|
|
|
|
|
>
|
2024-06-10 16:42:59 +07:00
|
|
|
<ProductCardComponent
|
2024-06-11 14:20:58 +07:00
|
|
|
v-if="isType"
|
2024-06-11 12:01:35 +07:00
|
|
|
:title="cardTypeData.title"
|
|
|
|
|
:subtitle="cardTypeData.subtitle"
|
|
|
|
|
:date="cardTypeData.date"
|
2024-06-11 15:04:40 +07:00
|
|
|
:status="v.status"
|
2024-06-11 12:01:35 +07:00
|
|
|
:color="cardTypeData.color"
|
|
|
|
|
@view-detail="drawerInfo = true"
|
2024-06-11 15:04:40 +07:00
|
|
|
@on-click="
|
|
|
|
|
() => {
|
|
|
|
|
if (isType === true) drawerInfo = true;
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-06-11 12:01:35 +07:00
|
|
|
/>
|
|
|
|
|
<ProductCardComponent
|
|
|
|
|
v-else
|
2024-06-11 15:04:40 +07:00
|
|
|
:title="v.name"
|
|
|
|
|
:subtitle="v.code"
|
|
|
|
|
:date="new Date(v.updatedAt)"
|
|
|
|
|
:status="v.status"
|
|
|
|
|
color="var(--pink-6)"
|
2024-06-11 12:01:35 +07:00
|
|
|
@view-detail="drawerInfo = true"
|
2024-06-11 15:04:40 +07:00
|
|
|
@on-click="
|
|
|
|
|
() => {
|
|
|
|
|
if (isType === false) isType = true;
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-06-10 16:42:59 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
2024-06-11 09:38:05 +07:00
|
|
|
<div
|
|
|
|
|
:class="`${$q.screen.gt.sm ? 'col-3' : $q.screen.gt.xs ? 'col-6' : 'col-12'}`"
|
|
|
|
|
>
|
2024-06-10 17:42:37 +07:00
|
|
|
<NewProductCardCompoent
|
2024-06-11 14:20:58 +07:00
|
|
|
v-if="isType"
|
2024-06-11 12:01:35 +07:00
|
|
|
:label="$t('ProductAndServiceType')"
|
|
|
|
|
:isType="true"
|
|
|
|
|
@on-click="() => (dialogInputForm = true)"
|
|
|
|
|
/>
|
|
|
|
|
<NewProductCardCompoent
|
|
|
|
|
v-else
|
|
|
|
|
:label="$t('ProductAndService')"
|
2024-06-10 17:42:37 +07:00
|
|
|
:isType="false"
|
2024-06-11 12:01:35 +07:00
|
|
|
@on-click="() => (dialogInputForm = true)"
|
2024-06-10 17:42:37 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
2024-06-10 16:42:59 +07:00
|
|
|
</div>
|
|
|
|
|
</AppBox>
|
|
|
|
|
</div>
|
2024-06-11 12:01:35 +07:00
|
|
|
|
|
|
|
|
<FormDialog
|
|
|
|
|
v-model:modal="dialogInputForm"
|
|
|
|
|
noAddress
|
|
|
|
|
:title="$t('customerEmployerAdd')"
|
|
|
|
|
:submit="
|
|
|
|
|
() => {
|
2024-06-11 15:04:01 +07:00
|
|
|
submitGroup();
|
2024-06-11 12:01:35 +07:00
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
:close="() => {}"
|
|
|
|
|
>
|
|
|
|
|
<template #information>
|
|
|
|
|
<BasicInformation
|
|
|
|
|
dense
|
2024-06-11 14:20:58 +07:00
|
|
|
:isType="isType"
|
2024-06-11 12:01:35 +07:00
|
|
|
v-model:remark="formData.remark"
|
|
|
|
|
v-model:name="formData.name"
|
|
|
|
|
v-model:detail="formData.detail"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</FormDialog>
|
|
|
|
|
|
|
|
|
|
<DrawerInfo
|
|
|
|
|
ref="formDialogRef"
|
|
|
|
|
v-model:drawerOpen="drawerInfo"
|
|
|
|
|
:title="'test'"
|
|
|
|
|
:undo="() => (isEdit = false)"
|
|
|
|
|
:isEdit="isEdit"
|
|
|
|
|
:editData="() => (isEdit = true)"
|
2024-06-11 14:20:58 +07:00
|
|
|
:submit="() => (isType ? submitType() : submitGroup())"
|
2024-06-11 12:01:35 +07:00
|
|
|
:delete-data="() => deleteProductById()"
|
|
|
|
|
:close="() => (drawerInfo = false)"
|
|
|
|
|
>
|
|
|
|
|
<template #info>
|
|
|
|
|
<AppBox class="q-ma-md" bordered>
|
|
|
|
|
<BasicInformation
|
|
|
|
|
dense
|
2024-06-11 14:20:58 +07:00
|
|
|
:isType="isType"
|
2024-06-11 12:01:35 +07:00
|
|
|
:readonly="!isEdit"
|
|
|
|
|
v-model:remark="formData.remark"
|
|
|
|
|
v-model:name="formData.name"
|
|
|
|
|
v-model:code="formData.code"
|
|
|
|
|
v-model:detail="formData.detail"
|
|
|
|
|
/>
|
|
|
|
|
</AppBox>
|
|
|
|
|
</template>
|
|
|
|
|
</DrawerInfo>
|
2024-06-11 15:11:55 +07:00
|
|
|
|
|
|
|
|
<FormDialog
|
|
|
|
|
v-model:modal="dialogProductServiceType"
|
|
|
|
|
:title="'สร้างสินค้าและบริการ'"
|
|
|
|
|
no-footer
|
|
|
|
|
no-app-box
|
|
|
|
|
:max-width="80"
|
|
|
|
|
>
|
|
|
|
|
<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;
|
|
|
|
|
console.log('test');
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</FormDialog>
|
|
|
|
|
|
|
|
|
|
<FormDialog
|
|
|
|
|
v-model:modal="dialogTotalProduct"
|
|
|
|
|
noAddress
|
|
|
|
|
noAppBox
|
|
|
|
|
title="รวมสินค้าทั้งหมด (2 ชิ้น)"
|
|
|
|
|
:submit="
|
|
|
|
|
() => {
|
|
|
|
|
console.log('submit');
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
:close="() => {}"
|
|
|
|
|
>
|
|
|
|
|
<TotalProductComponent />
|
|
|
|
|
</FormDialog>
|
2024-06-10 16:42:59 +07:00
|
|
|
</template>
|
|
|
|
|
|
2024-06-11 12:01:35 +07:00
|
|
|
<style scoped>
|
|
|
|
|
.hover-underline:hover {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
}
|
|
|
|
|
</style>
|