feat: createProductService

This commit is contained in:
Net 2024-06-11 15:04:01 +07:00
parent 566798e35a
commit 22f7329267

View file

@ -8,6 +8,21 @@ 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';
import useProductServiceStore from 'src/stores/product-service';
import {
ProductGroup,
ProductGroupCreate,
} from 'src/stores/product-service/types';
const productServiceStore = useProductServiceStore();
const {
fetchStatsProductGroup,
fetchListProductService,
createProductService,
} = productServiceStore;
const cardData = ref({
title: 'งาน MCU',
subtitle: 'G00000000001',
@ -37,6 +52,7 @@ const stat = ref<
]);
import { useI18n } from 'vue-i18n';
import { onMounted } from 'vue';
const { t } = useI18n();
@ -47,16 +63,15 @@ const dialogInputForm = ref<boolean>(false);
const isType = ref<boolean>(false);
const groupName = ref<string>('test');
const formData = ref({
const productGroup = ref<ProductGroup[]>();
const formData = ref<ProductGroupCreate>({
remark: '',
detail: '',
name: '',
code: '',
});
async function submitGroup() {
console.log(formData.value);
}
async function submitType() {
console.log(formData.value);
}
@ -76,6 +91,36 @@ async function deleteProductById() {
cancel: () => {},
});
}
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();
});
</script>
<template>
@ -211,7 +256,7 @@ async function deleteProductById() {
:title="$t('customerEmployerAdd')"
:submit="
() => {
console.log('submit');
submitGroup();
}
"
:close="() => {}"
@ -222,7 +267,6 @@ async function deleteProductById() {
:isType="isType"
v-model:remark="formData.remark"
v-model:name="formData.name"
v-model:code="formData.code"
v-model:detail="formData.detail"
/>
</template>