<!--
 * @Description:: 请补充填写
 * @Version: 请配置版本号
 * @Author: 舟舟
 * @Date: 2022-06-25 23:00:54
 * @LastEditors: 舟舟
 * @LastEditTime: 2022-07-29 16:10:50
 * @FilePath: /ouicai_web_framework_vite_ep_nolang/src/views/backend/system/auth/admin/index.vue
-->
<template>
  <div class="default-main ba-table-box" >
    <el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
    <el-row>
      <el-col :span="24">
        <!-- 表格顶部菜单 -->
        <TableHeader :buttons="['refresh', 'add', 'edit', 'delete', 'comSearch']" quick-search-placeholder="通过姓名模糊搜索"
          @action="baTable.onTableHeaderAction" />

        <!-- 表格 -->
        <!-- 要使用`el-table`组件原有的属性，直接加在Table标签上即可 -->
        <Table @action="baTable.onTableAction" />
      </el-col>
    </el-row>

    <!-- 表单 -->
    <PopupForm />
  </div>
</template>

<script setup lang="ts">
import { provide } from 'vue'
import baTableClass from '/@/utils/baTable'
import { authAdmin } from '/@/api/controllerUrls'
import PopupForm from './popupForm.vue'
import Table from '/@/components/table/index.vue'
import TableHeader from '/@/components/table/header/index.vue'
import { defaultOptButtons } from '/@/components/table'
import { baTableApi } from '/@/api/common'

const baTable = new baTableClass(
    new baTableApi(authAdmin),
    {
        column: [
            { type: 'selection', align: 'center', operator: false },
            { label: '头像', prop: 'avatar', align: 'center', render: 'image', operator: false },
            { label: '姓名', prop: 'trueName', align: 'center', operator: 'LIKE', operatorPlaceholder: '模糊查询' },
            { label: '性别', prop: 'sexName', align: 'center', operator: false },
            { label: '部门', prop: 'departmentName', align: 'center', operator: 'LIKE', operatorPlaceholder: '模糊查询' },
            { label: '职务', prop: 'postName', align: 'center', operator: 'LIKE', operatorPlaceholder: '模糊查询' },
            { label: '账号', prop: 'accountName', align: 'center', operator: false },
            { label: '角色', prop: 'roles', align: 'center', operator: false, render: 'tags' },
            {
                label: '最后登录',
                prop: 'lastLoginTime',
                align: 'center',
                render: 'datetime',
                sortable: 'custom',
                operator: 'RANGE',
                width: 200,
            },
            { label: '创建时间', prop: 'createTime', align: 'center', render: 'datetime', sortable: 'custom', operator: false, width: 200 },
            {
                label: '状态',
                prop: 'status',
                align: 'center',
                render: 'tag',
                width: 100,
                custom: { '0': 'danger', '1': 'success' },
                replaceValue: { '0': '禁用', '1': '启用' },
            },
            {
                label: '操作',
                align: 'center',
                width: '100',
                render: 'buttons',
                buttons: defaultOptButtons(['edit', 'delete']),
                operator: false,
                fixed: 'right',
            },
        ],
        dblClickNotEditColumn: [undefined, 'status'],
        rowStyle: 'table-row-compact',
        headerRowStyle: 'table-header-row-compact',
    },
    {
        defaultItems: {
            departmentPids: [],
            status: '1',
        },
    }
)

baTable.mount()
baTable.getIndex()

provide('baTable', baTable)
</script>

<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
    name: 'auth/admin',
})
</script>

<style scoped lang="scss"></style>
