MenuManagement.vue 2.55 KB
Newer Older
wb-ct393452's avatar
wb-ct393452 committed
1
<template>
2 3 4 5 6 7 8 9
    <my-table
        url="/api/v1/menus"
        :addBtn="addBtn"
        :formatData="formatData"
        rowKey="menuId"
        noPage
        ref="table"
    >
10
        <template #drawer>
11
            <AddCom v-if="addCom" :row="currentClickRow" ref="addCom" />
12
            <Form ref="addForm" v-else />
水落(YangLei)'s avatar
水落(YangLei) committed
13
        </template>
14

水落(YangLei)'s avatar
水落(YangLei) committed
15 16 17 18 19
        <a-table-column title="名称" data-index="menuName" />
        <a-table-column title="类型" data-index="menuTypeName" />
        <a-table-column title="显示排序" data-index="viewIndex" :sorter="sorter" sortOrder="ascend" />
        <a-table-column title="显示图标" data-index="menuIcon" />
        <a-table-column title="模块URL" data-index="menuUrl" />
水落(YangLei)'s avatar
水落(YangLei) committed
20
        <a-table-column title="操作">
21
            <template #default="row">
22
                <my-ac-btn :row="row" :buttons="buttons" />
水落(YangLei)'s avatar
水落(YangLei) committed
23 24 25
            </template>
        </a-table-column>
    </my-table>
wb-ct393452's avatar
wb-ct393452 committed
26
</template>
水落(YangLei)'s avatar
水落(YangLei) committed
27 28

<script>
水落(YangLei)'s avatar
水落(YangLei) committed
29
import { convertListToTree } from '@/utils';
30
import Form from './form.vue';
31
import AddCom from './add_com.vue';
水落(YangLei)'s avatar
水落(YangLei) committed
32

水落(YangLei)'s avatar
水落(YangLei) committed
33
export default {
34
    data: vm => ({
35
        addCom: false,
36
        currentClickRow: null,
37 38
        addBtn: {
            text: '新建',
水落(YangLei)'s avatar
水落(YangLei) committed
39
            onOk() {
40
                return vm.addCom ? vm.$refs['addCom']?.submit() : vm.$refs['addForm']?.submit();
41
            },
42 43
            onCancel() {
                vm.addCom = false;
44
                vm.currentClickRow = null;
45
            },
46
        },
水落(YangLei)'s avatar
水落(YangLei) committed
47
        sortOrder: 'ascend',
48 49 50
        buttons: [
            {
                label: '新增组件',
51
                option: {
水落(YangLei)'s avatar
水落(YangLei) committed
52
                    style: 'color: #ff4d4f',
53 54
                },
                click(row) {
55 56
                    vm.show();
                    vm.addCom = true;
57
                    vm.currentClickRow = row;
58
                },
59
                isHidden: row => row.menuType !== 'MENU',
60 61 62 63
            },
            { label: '编辑', click: vm.edit },
            { type: 'confirm', url: row => `/api/v1/menus/${row.menuId}`, after: vm.refreshTable },
        ],
水落(YangLei)'s avatar
水落(YangLei) committed
64
    }),
水落(YangLei)'s avatar
水落(YangLei) committed
65

66
    components: { Form, AddCom },
67

水落(YangLei)'s avatar
水落(YangLei) committed
68
    methods: {
水落(YangLei)'s avatar
水落(YangLei) committed
69
        formatData: convertListToTree,
70
        refreshTable() {
水落(YangLei)'s avatar
水落(YangLei) committed
71
            this.$refs['table'].getData();
72
        },
水落(YangLei)'s avatar
水落(YangLei) committed
73 74 75
        sorter(pre, next) {
            return pre.viewIndex - next.viewIndex;
        },
76
        edit(data) {
77
            this.$refs['table']?.show({ type: 1 });
78
            this.$nextTick(() => {
水落(YangLei)'s avatar
水落(YangLei) committed
79
                this.$refs['addForm'].setEdit({ ...data });
80 81
            });
        },
82
        show() {
83
            this.$refs['table'].show({ title: '菜单组件' });
84
        },
水落(YangLei)'s avatar
水落(YangLei) committed
85
    },
水落(YangLei)'s avatar
水落(YangLei) committed
86 87
};
</script>