index.vue 2.48 KB
Newer Older
水落(YangLei)'s avatar
水落(YangLei) committed
1
<template>
2 3
    <my-table url="/api/v1/schedules" rowKey="taskId" :addBtn="addBtn" ref="table">
        <template #drawer>
水落(YangLei)'s avatar
水落(YangLei) committed
4
            <Form ref="form" :row="currentClickRow" />
5
        </template>
水落(YangLei)'s avatar
水落(YangLei) committed
6 7 8 9
        <a-table-column title="任务名称" data-index="taskName" />
        <a-table-column title="调度规则" data-index="taskRule" />
        <a-table-column title="实现类" data-index="implementClass" />
        <a-table-column title="说明" data-index="remark" />
10 11 12 13 14
        <a-table-column title="操作">
            <template #default="row">
                <ActionButton :buttons="buttons" :row="row" />
            </template>
        </a-table-column>
水落(YangLei)'s avatar
水落(YangLei) committed
15 16 17 18
    </my-table>
</template>

<script>
19
import ActionButton from '@/components/action_button/index.vue';
20
import Form from './form.vue';
21 22

export default {
23
    components: { ActionButton, Form },
24 25
    data() {
        return {
水落(YangLei)'s avatar
水落(YangLei) committed
26 27 28 29 30 31
            addBtn: {
                onOk: () => {
                    return this.$refs.form.submit();
                },
            },
            currentClickRow: null,
32 33 34
            buttons: [
                {
                    label: '查看',
35 36 37 38 39 40
                    click: row => {
                        this.showDrawer(2, true);
                        this.$nextTick(() => {
                            this.$refs['form'].setData(row, 2);
                        });
                    },
41 42 43
                },
                {
                    label: '编辑',
44 45 46 47 48
                    click: row => {
                        this.showDrawer(1);
                        this.$nextTick(() => {
                            this.$refs['form'].setData(row, 1);
                        });
49 50 51
                    },
                },
                {
52 53 54
                    type: 'confirm',
                    label: '失效',
                    title: '确认是否失效?',
水落(YangLei)'s avatar
水落(YangLei) committed
55
                    url: row => ({ url: `/api/v1/schedules/${row.taskId}/pause`, method: 'del' }),
56
                    after: () => this.refreshTable(),
水落(YangLei)'s avatar
水落(YangLei) committed
57
                    isHidden: row => row.isPaused === 1,
58 59
                },
                {
60 61 62
                    type: 'confirm',
                    url: row => `/api/v1/schedules/${row.taskId}`,
                    after: () => this.refreshTable(),
63 64 65 66
                },
            ],
        };
    },
67 68 69 70 71 72 73 74
    methods: {
        refreshTable() {
            this.$refs.table.getData();
        },
        showDrawer(type, noFooter) {
            this.$refs['table'].show({ type, noFooter });
        },
    },
75
};
水落(YangLei)'s avatar
水落(YangLei) committed
76
</script>