feat: ค้นหา ของ Product type

This commit is contained in:
Net 2024-06-13 15:18:07 +07:00
parent b1302f05f9
commit c7cce35db7

View file

@ -13,11 +13,7 @@ import TooltipComponent from 'components/TooltipComponent.vue';
import { dialog } from 'src/stores/utils'; import { dialog } from 'src/stores/utils';
import useProductServiceStore from 'src/stores/product-service'; import useProductServiceStore from 'src/stores/product-service';
import { import { Product, ProductCreate } from 'src/stores/product-service/types';
Product,
ProductCreate,
ProductUpdate,
} from 'src/stores/product-service/types';
const productServiceStore = useProductServiceStore(); const productServiceStore = useProductServiceStore();
@ -79,7 +75,7 @@ const formData = ref<ProductCreate>({
const currentId = ref<string>(''); const currentId = ref<string>('');
const currentIdType = ref<string>(''); const currentIdType = ref<string>('');
const resultSearchGroup = ref<Product[]>(); const resultSearchGroup = ref<Product[]>();
const resultSearchType = ref<Product[]>(); const resultSearchType = ref<(Product & { productGroupId: string })[]>();
async function searchGroup() { async function searchGroup() {
const resultList = await fetchListProductService({ const resultList = await fetchListProductService({
@ -110,6 +106,17 @@ async function fetchListGroups() {
} }
} }
async function searchType() {
const res = await await fetchListProductServiceType({
query: inputSearch.value,
productGroupId: currentId.value,
});
if (res) {
resultSearchType.value = res;
}
}
async function submitType() { async function submitType() {
if (drawerInfo.value) { if (drawerInfo.value) {
await editProductServiceType(currentIdType.value, { await editProductServiceType(currentIdType.value, {
@ -339,7 +346,7 @@ watch(productMode, () => (inputSearch.value = ''));
productMode === 'group' productMode === 'group'
? searchGroup() ? searchGroup()
: productMode === 'type' : productMode === 'type'
? console.log('type') ? searchType()
: '' : ''
" "
> >