|
@@ -1,5 +1,116 @@
|
|
|
<template>
|
|
|
- <div> 商品分类 </div>
|
|
|
+ <BasicTable @register="registerTable">
|
|
|
+ <template #toolbar>
|
|
|
+ <a-button type="primary" @click="handleCreate"> 新增商品分类</a-button>
|
|
|
+ <a-button type="warning" @click="expandAll">展开全部</a-button>
|
|
|
+ <a-button type="error" @click="collapseAll">折叠全部</a-button>
|
|
|
+ </template>
|
|
|
+ <template #action="{ record }">
|
|
|
+ <TableAction
|
|
|
+ :actions="[
|
|
|
+ {
|
|
|
+ icon: 'clarity:note-edit-line',
|
|
|
+ onClick: handleEdit.bind(null, record),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ icon: 'ant-design:delete-outlined',
|
|
|
+ color: 'error',
|
|
|
+ popConfirm: {
|
|
|
+ title: '是否确认删除',
|
|
|
+ confirm: handleDelete.bind(null, record),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ]"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </BasicTable>
|
|
|
</template>
|
|
|
|
|
|
-<script lang="ts" setup></script>
|
|
|
+<script lang="ts">
|
|
|
+ import { defineComponent, h } from 'vue';
|
|
|
+ import { BasicTable, useTable, BasicColumn, TableAction } from '/@/components/Table';
|
|
|
+ import { categoryApi } from '/@/api/product/category';
|
|
|
+ import { Tag } from 'ant-design-vue';
|
|
|
+
|
|
|
+ import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
+
|
|
|
+ export default defineComponent({
|
|
|
+ components: { BasicTable, TableAction },
|
|
|
+ setup() {
|
|
|
+ const { createMessage } = useMessage();
|
|
|
+
|
|
|
+ const { t } = useI18n();
|
|
|
+
|
|
|
+ const columns: BasicColumn[] = [
|
|
|
+ {
|
|
|
+ title: 'ID',
|
|
|
+ dataIndex: 'id',
|
|
|
+ fixed: 'left',
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '分类名称',
|
|
|
+ dataIndex: 'name',
|
|
|
+ width: 200,
|
|
|
+ align: 'left',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '排序',
|
|
|
+ dataIndex: 'orderNo',
|
|
|
+ width: 50,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '状态',
|
|
|
+ dataIndex: 'status',
|
|
|
+ width: 80,
|
|
|
+ customRender: ({ record }) => {
|
|
|
+ const status = record.status;
|
|
|
+ const enable = ~~status === 0;
|
|
|
+ const color = enable ? 'green' : 'red';
|
|
|
+ const text = enable ? '启用' : '停用';
|
|
|
+ return h(Tag, { color: color }, () => text);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '创建时间',
|
|
|
+ dataIndex: 'createTime',
|
|
|
+ width: 180,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ const [registerTable, { expandAll, collapseAll }] = useTable({
|
|
|
+ title: '商品分类',
|
|
|
+ api: categoryApi,
|
|
|
+ columns: columns,
|
|
|
+ useSearchForm: true,
|
|
|
+ showTableSetting: true,
|
|
|
+ tableSetting: { fullScreen: true },
|
|
|
+ showIndexColumn: false,
|
|
|
+ isTreeTable: true,
|
|
|
+ rowKey: 'id',
|
|
|
+ bordered: true,
|
|
|
+ actionColumn: {
|
|
|
+ width: 80,
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'action',
|
|
|
+ slots: { customRender: 'action' },
|
|
|
+ fixed: undefined,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ function handleCreate() {}
|
|
|
+ function handleEdit() {}
|
|
|
+ function handleDelete() {}
|
|
|
+ return {
|
|
|
+ registerTable,
|
|
|
+ createMessage,
|
|
|
+ t,
|
|
|
+ handleCreate,
|
|
|
+ handleEdit,
|
|
|
+ handleDelete,
|
|
|
+ expandAll,
|
|
|
+ collapseAll,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ });
|
|
|
+</script>
|