|
@@ -25,25 +25,27 @@
|
|
/>
|
|
/>
|
|
</template>
|
|
</template>
|
|
</BasicTable>
|
|
</BasicTable>
|
|
- <addCategoryModal @register="registeraddCategoryModal" />
|
|
|
|
|
|
+ <AddCategoryModal @register="registeraddCategoryModal" @update="reload" />
|
|
|
|
+ <EditCategoryModal @register="registerEditCategoryModal" @update="reload" />
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
- import { defineComponent, h } from 'vue';
|
|
|
|
|
|
+ import { defineComponent, h, nextTick } from 'vue';
|
|
import { BasicTable, useTable, BasicColumn, TableAction } from '/@/components/Table';
|
|
import { BasicTable, useTable, BasicColumn, TableAction } from '/@/components/Table';
|
|
- import { categoryApi } from '/@/api/product/category';
|
|
|
|
|
|
+ import { categoryApi, deleteCategoryApi } from '/@/api/product/category';
|
|
import { Tag } from 'ant-design-vue';
|
|
import { Tag } from 'ant-design-vue';
|
|
|
|
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
import { makeTree } from '/@/utils/treeUtils';
|
|
import { makeTree } from '/@/utils/treeUtils';
|
|
|
|
|
|
- import addCategoryModal from './addCategoryModal.vue';
|
|
|
|
|
|
+ import AddCategoryModal from './addCategoryModal.vue';
|
|
|
|
+ import EditCategoryModal from './editCategoryModal.vue';
|
|
import { useModal } from '/@/components/Modal';
|
|
import { useModal } from '/@/components/Modal';
|
|
|
|
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
- components: { BasicTable, TableAction, addCategoryModal },
|
|
|
|
|
|
+ components: { BasicTable, TableAction, AddCategoryModal, EditCategoryModal },
|
|
setup() {
|
|
setup() {
|
|
const { createMessage } = useMessage();
|
|
const { createMessage } = useMessage();
|
|
|
|
|
|
@@ -74,11 +76,11 @@
|
|
},
|
|
},
|
|
{
|
|
{
|
|
title: '状态',
|
|
title: '状态',
|
|
- dataIndex: 'status',
|
|
|
|
|
|
+ dataIndex: 'isShow',
|
|
width: 80,
|
|
width: 80,
|
|
customRender: ({ record }) => {
|
|
customRender: ({ record }) => {
|
|
- const status = record.status;
|
|
|
|
- const enable = ~~status === 0;
|
|
|
|
|
|
+ const status = record.isShow;
|
|
|
|
+ const enable = status === 1;
|
|
const color = enable ? 'green' : 'red';
|
|
const color = enable ? 'green' : 'red';
|
|
const text = enable ? '启用' : '停用';
|
|
const text = enable ? '启用' : '停用';
|
|
return h(Tag, { color: color }, () => text);
|
|
return h(Tag, { color: color }, () => text);
|
|
@@ -90,9 +92,9 @@
|
|
width: 180,
|
|
width: 180,
|
|
},
|
|
},
|
|
];
|
|
];
|
|
- const [registeraddCategoryModal, { openModal }] = useModal();
|
|
|
|
-
|
|
|
|
- const [registerTable, { expandAll, collapseAll }] = useTable({
|
|
|
|
|
|
+ const [registeraddCategoryModal, { openModal: openAddCategoryModal }] = useModal();
|
|
|
|
+ const [registerEditCategoryModal, { openModal: openEditategoryModal }] = useModal();
|
|
|
|
+ const [registerTable, { reload, expandAll, collapseAll }] = useTable({
|
|
title: '商品分类',
|
|
title: '商品分类',
|
|
api: categoryApi,
|
|
api: categoryApi,
|
|
columns: columns,
|
|
columns: columns,
|
|
@@ -113,16 +115,21 @@
|
|
},
|
|
},
|
|
afterFetch(data) {
|
|
afterFetch(data) {
|
|
const treeData = makeTree(data);
|
|
const treeData = makeTree(data);
|
|
- console.log('data', treeData);
|
|
|
|
return treeData;
|
|
return treeData;
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
|
|
function handleCreate(record: Recordable) {
|
|
function handleCreate(record: Recordable) {
|
|
- openModal(true, record);
|
|
|
|
|
|
+ openAddCategoryModal(true, record);
|
|
|
|
+ }
|
|
|
|
+ function handleEdit(record: Recordable) {
|
|
|
|
+ openEditategoryModal(true, record);
|
|
|
|
+ }
|
|
|
|
+ async function handleDelete(record: Recordable) {
|
|
|
|
+ await deleteCategoryApi([record.id]);
|
|
|
|
+ createMessage.success(t('common.optSuccess'));
|
|
|
|
+ nextTick(reload);
|
|
}
|
|
}
|
|
- function handleEdit() {}
|
|
|
|
- function handleDelete() {}
|
|
|
|
return {
|
|
return {
|
|
registerTable,
|
|
registerTable,
|
|
createMessage,
|
|
createMessage,
|
|
@@ -133,6 +140,8 @@
|
|
expandAll,
|
|
expandAll,
|
|
collapseAll,
|
|
collapseAll,
|
|
registeraddCategoryModal,
|
|
registeraddCategoryModal,
|
|
|
|
+ registerEditCategoryModal,
|
|
|
|
+ reload,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
});
|
|
});
|