feat: remodel product page

This commit is contained in:
caturbgs
2021-12-16 21:36:42 +07:00
parent d41681c217
commit cf3afb27c4
4 changed files with 154 additions and 94 deletions

View File

@@ -9,11 +9,6 @@ export class Category {
filterCategory = null;
visibleModalCategory = false;
pageCategories = 0;
pageSizeCategories = 10
dataCategories = [];
total_dataCategories = 0;
pageSubCategories = 0;
pageSizeSubCategories = 10
dataSubCategories = [];
@@ -37,16 +32,6 @@ export class Category {
this.total_dataSubCategories = response.body.count ?? 0
}
async getDataCategories() {
const response = await http.get(`/product/categories?page=${this.pageCategories}&pageSize=${this.pageSizeCategories}`);
this.dataCategories = response.body.data ?? []
this.total_dataCategories = response.body.total_data ?? 0
if (this.dataCategories.length > 0) {
this.filterCategory = this.dataCategories[0].id
}
}
async create(data) {
const response = await http.post('/product/categories').send(data);
await this.getData();

View File

@@ -6,8 +6,12 @@ export class Product {
pageSize = 10
data = [];
total_data = 0;
filterSupplier = null;
filterCategory = null;
filterSubCategory = null;
visibleModalProduct = false;
visibleModalFilterProduct = false;
uploadBtnProduct = false;
pageCategories = 0;
pageSizeCategories = 10
@@ -25,8 +29,7 @@ export class Product {
}
async getData() {
const response = await http.get(`/product/by-categories?categories=${this.filterCategory}&page=${this.page}&pageSize=${this.pageSize}`);
const response = await http.get(`/product/all?supplier=${this.filterSupplier}&categories=${this.filterCategory}&categories=${this.filterSubCategory}&page=${this.page}&pageSize=${this.pageSize}`);
this.data = response.body.data.map((item, idx) => {
item.key = idx;
return item
@@ -46,7 +49,6 @@ export class Product {
async getDataCategories() {
const response = await http.get(`/product/categories?page=${this.pageCategories}&pageSize=${this.pageSizeCategories}`);
this.dataCategories = response.body.data ?? []
this.total_dataCategories = response.body.total_data ?? 0