Skip to content

Commit

Permalink
Add delete business product category #41
Browse files Browse the repository at this point in the history
  • Loading branch information
Jzow committed Oct 7, 2023
1 parent dedd1ee commit 6388a1c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/views/product/category/CategoryModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {BasicForm, useForm} from '/@/components/Form/index';
import {CategorySchema} from "@/views/product/category/category.data";
import {AddOrUpdateProductCategoryReq} from "@/api/product/model/productCategoryModel";
import {addOrUpdateCategory} from "@/api/product/productCategory";
import {getCategoryList} from "@/api/product/productCategory";
export default defineComponent({
name: 'CategoryModal',
Expand All @@ -23,7 +23,7 @@ export default defineComponent({
const isUpdate = ref(true);
const getTitle = computed(() => (!unref(isUpdate) ? '新增产品分类' : '编辑产品分类'));
const [registerForm, {setFieldsValue, resetFields, validate}] = useForm({
const [registerForm, {setFieldsValue, updateSchema, resetFields, validate}] = useForm({
labelWidth: 100,
baseColProps: {span: 24},
schemas: CategorySchema,
Expand All @@ -44,7 +44,13 @@ export default defineComponent({
...data.record,
});
}
const treeData = (await getCategoryList()).data
updateSchema([
{
field: 'categoryName',
componentProps: {treeData},
},
]);
});
async function handleSubmit() {
Expand Down
6 changes: 5 additions & 1 deletion src/views/product/category/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {BasicModal, useModal} from "@/components/Modal";
import {BasicTree,} from "@/components/Tree";
import CategoryModal from "@/views/product/category/CategoryModal.vue";
import {BasicTable, TableAction, useTable} from "@/components/Table";
import {getCategoryList} from "@/api/product/productCategory";
import {getCategoryList, deleteCategory} from "@/api/product/productCategory";
import {columns} from "@/views/product/category/category.data";
import MenuDrawer from "@/views/sys/menu/MenuDrawer.vue";
import AccountModal from "@/views/sys/user/AccountModal.vue";
Expand Down Expand Up @@ -89,6 +89,10 @@ export default defineComponent({
}
async function handleDelete(record: Recordable) {
const result = await deleteCategory(record.id);
if (result.code === 'P0002') {
await reload();
}
}
async function handleCreate() {
Expand Down

0 comments on commit 6388a1c

Please sign in to comment.