<template>
    <headerTop @search="searchFn" @reset="resetFn" @export="exportFn" @add="addFn" @batchDown="batchDownFn"></headerTop>
    <addCom ref="addComRef"></addCom>
    <el-card shadow="always" class="content_body_row">
        <el-table :data="tableListInfo.list" border style="width: 100%" show-overflow-tooltip
        @selection-change="handleSelectionChange"
            :max-height="'calc(100vh - 72px - 48px - 65px - 12px - 60px - 88px)'"
            :height="'calc(100vh - 72px - 48px - 65px - 12px - 60px  - 88px)'">
            <el-table-column type="selection" width="55" />
            <el-table-column type="index" width="72" label="序号" />
            <el-table-column prop="v_name" label="姓名" min-width="150" />
            <el-table-column prop="v_IDcard" label="身份证号" min-width="150" />

            <el-table-column prop="v_sex" label="性别" min-width="160">

            </el-table-column>
            <el-table-column prop="v_contact" label="联系方式" min-width="160">

            </el-table-column>
            <el-table-column prop="v_position" label="所属岗位" min-width="160">

            </el-table-column>

            <el-table-column prop="v_system_role" label="系统角色" min-width="160">

            </el-table-column>

            <el-table-column prop="v_create_time" label="创建日期" min-width="160">

            </el-table-column>
            <el-table-column label="操作" align="center" width="240">

                <template #default="scope">
                    <el-button type="primary" size="small" @click.prevent="editRowFn(scope.row)">
                        编辑
                    </el-button>
                    <el-button type="primary" size="small" @click.prevent="resetPasswordFn(scope.row)">
                        重置密码
                    </el-button>
                    <el-button type="danger" size="small" @click.prevent="deleteRowFn(scope.row)">
                        删除
                    </el-button>
 
                </template>
            </el-table-column>
        </el-table>
        <div class="paination_out">
            <Pagination :currentPage="paginationInfo.currentPage" :pageSize="paginationInfo.pageSize" @sendPage="getPageFn">
            </Pagination>
        </div>
    </el-card>
</template>

<script lang="ts" setup>
import headerTop from "./com/headerTop.vue"
import addCom from "./com/addCom.vue"
import { ElConfirmBeforeOpert, ElMessageBoxOpert } from "utils/elementCom"
const addComRef = ref()
const paginationInfo = reactive({
    currentPage: 1,
    pageSize: 15
})
const tableData = [
    {
        v_id: '1',
        v_name: '2016-05-03',
        v_IDcard: 'Tom',
        v_sex: 'California',
        v_contact: 'Los Angeles',
        v_position: 'No. 189, Grove St, Los Angeles',
        v_system_role: 'CA 90036',
        v_create_time: 'No. 189, Grove St, Los Angeles',
    },
    {
        v_id: '2',
        v_name: '2016-05-03',
        v_IDcard: 'Tom',
        v_sex: 'California',
        v_contact: 'Los Angeles',
        v_position: 'No. 189, Grove St, Los Angeles',
        v_system_role: 'CA 90036',
        v_create_time: 'No. 189, Grove St, Los Angeles',
    },
    {
        v_id: '3',
        v_name: '2016-05-03',
        v_IDcard: 'Tom',
        v_sex: 'California',
        v_contact: 'Los Angeles',
        v_position: 'No. 189, Grove St, Los Angeles',
        v_system_role: 'CA 90036',
        v_create_time: 'No. 189, Grove St, Los Angeles',
    },
    {
        v_id: '4',
        v_name: '2016-05-03',
        v_IDcard: 'Tom',
        v_sex: 'California',
        v_contact: 'Los Angeles',
        v_position: 'No. 189, Grove St, Los Angeles',
        v_system_role: 'CA 90036',
        v_create_time: 'No. 189, Grove St, Los Angeles',

    },
    {
        v_id: '5',
       v_name: '2016-05-03',
        v_IDcard: 'Tom',
        v_sex: 'California',
        v_contact: 'Los Angeles',
        v_position: 'No. 189, Grove St, Los Angeles',
        v_system_role: 'CA 90036',
        v_create_time: 'No. 189, Grove St, Los Angeles',
    },

]

let tableListInfo = reactive({
    list: tableData
})


const editRowFn = (row: any) => {
    addComRef.value.edit({
        a: "111"
    })

}
const editCallBack = (row: any, value: any) => {
  console.log("editCallBack", row, value)
}
const resetPasswordFn = (row: any) => {
    ElMessageBoxOpert(
    '编辑',
    '',
    '确定',
    '取消',
    (val: any) => {
      if (!val) {
        return false
      }
    },
    "请填写类型模板", 
    editCallBack,
    row
  )
}
const deleteItem = (row: any) => {
    const itemID = row.v_id
    console.log("ITEMid", row)
}

const deleteRowFn = (row: any) => {
    ElConfirmBeforeOpert(
        '操作确认',
        '是否确定删除数据？',
        deleteItem,
        '确定',
        '取消',
        row
    )

}

const searchFn = () => {

}

const resetFn = () => {

}

const addFn = () => {
    addComRef.value.open()
}
const batchDownFn =()=>{
    
}
const getPageFn = (val: any) => {
    paginationInfo.currentPage = val.currentPage
    paginationInfo.pageSize = val.pageSize
    initTableList()
}

const initTableList = () => {

}

</script>

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