<template>
    <div class="default-main">
        <TableHeader>
            <template v-slot:operation>
                <el-button :icon="Plus" type="primary" @click="addMenu">添加</el-button>
            </template>
        </TableHeader>
        <Table ref="tableRef" />
        <popupForm ref="popupRef"></popupForm>
    </div>
</template>
<script setup lang="ts">
import { Plus } from '@element-plus/icons-vue'
import { ref, onMounted, provide } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'

defineOptions({
    name: 'auth/role'
})
const popupRef = ref()
const tableStore = new TableStore({
    url: '/user-boot/role/selectRoleDetail?id=1',
    method: 'POST',
    column: [
        { title: '角色名称', field: 'name', align: 'center' },
        { title: '角色编码', field: 'code', align: 'center' },
        { title: '备注', field: 'remark', align: 'center' },
        { title: '状态', field: 'state', align: 'center' },
        {
            title: '操作',
            align: 'center',
            width: '130',
            render: 'buttons',
            buttons: [
                {
                    name: 'edit',
                    title: '编辑',
                    type: 'primary',
                    icon: 'el-icon-EditPen',
                    render: 'tipButton',
                    click: row => {
                        popupRef.value.open('编辑角色', row)
                    }
                },
                {
                    name: 'del',
                    title: '删除',
                    type: 'danger',
                    icon: 'el-icon-Delete',
                    render: 'confirmButton',
                    popconfirm: {
                        confirmButtonText: '确认',
                        cancelButtonText: '取消',
                        confirmButtonType: 'danger',
                        title: '确定删除该角色吗？'
                    },
                    click: row => {}
                }
            ]
        }
    ]
})
provide('tableStore', tableStore)
tableStore.table.params.searchValue = ''
onMounted(() => {
    tableStore.index()
})
const addMenu = () => {}
</script>
