<template>
    <basic-container>
        <avue-crud :option="option" :table-loading="loading" :data="data" ref="crud" v-model="form" :search.sync="search"
            :permission="permissionList" :before-open="beforeOpen" :before-close="beforeClose" @row-del="rowDel"
            @row-update="rowUpdate" @row-save="rowSave" @search-change="searchChange" @search-reset="searchReset"
            @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
            @refresh-change="refreshChange" @on-load="onLoad" @tree-load="treeLoad" :page.sync="page">
            <template slot-scope="{row}" slot="menu">
                <el-button icon="el-icon-setting" type="text" @click="clickCheck(row)">审核</el-button>
            </template>
        </avue-crud>
        <el-dialog width="70%" title="账号审核" :visible.sync="dialogCheck" :append-to-body="true">
            <el-form :model="checkForm" label-width="120px"  label-position="left">
                <el-form-item label="企业名称" prop="deptName">
                    <el-input placeholder="请输入企业名称" v-model="checkForm.deptName"></el-input>
                </el-form-item>
                <el-form-item label="账号" prop="phone">
                    <el-input disabled placeholder="请输入账号" v-model="checkForm.phone"></el-input>
                </el-form-item>
                <el-form-item label="负责人姓名" prop="name">
                    <el-input disabled placeholder="请输入负责人姓名" v-model="checkForm.name"></el-input>
                </el-form-item>
                <el-form-item label="详细地址" prop="address">
                    <el-input disabled placeholder="请输入详细地址" v-model="checkForm.address"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="handleClose">关 闭</el-button>
                <el-button v-show="viewType != 'view'" @click="handleRefuse">拒 绝</el-button>
                <el-button v-show="viewType != 'view'" type="primary" @click="handlePass">通 过</el-button>
            </span>
        </el-dialog>
    </basic-container>
</template>

<script>
import {getRegisterList,auditPass,auditRefuse} from "@/api/registerAccount/registerAccount"
export default {
    data() {
        return {
            data: [],
            form:{},
            search:{},
            option: {
                lazy: true,
                tip: false,
                simplePage: true,
                searchShow: true,
                searchMenuSpan: 6,
                tree: true,
                border: true,
                index: true,
                selection: true,
                viewBtn: true,
                editBtn: false,
                delBtn: false,
                addBtn: false,
                menuWidth: 300,
                dialogClickModal: false,
                column: [
                    {
                        label: '账号',
                        prop: 'account',
                        span: 24,
                        labelWidth: 120,
                        search:true
                    },
                    {
                        label: '企业名称',
                        prop: 'deptName',
                        span: 24,
                        labelWidth: 120,
                    },
                    {
                        label: '负责人姓名',
                        prop: 'name',
                        span: 24,
                        labelWidth: 120,
                    },
                    {
                        label: '详细地址',
                        prop: 'address',
                        span: 24,
                        labelWidth: 120,
                    },
                ]
            },
            dialogCheck:false,
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0
            },
            checkForm:{}
        }
    },
    mounted() {

    },
    methods: {
        searchChange(params, done){
            this.onLoad()
            done()
        },
        onLoad() {
            console.log('search=========>',this.search)
            getRegisterList({current:this.page.currentPage,size:this.page.pageSize,}).then(res =>{
                console.log('res==========>',res)
                this.data = res.data.data.records
                this.page.total = res.data.data.total
            })
        },
        clickCheck(row){
            this.checkForm = row
            this.dialogCheck = true
        },
        handleClose(){
            this.checkForm = {}
            this.dialogCheck = false
        },
        handleRefuse(){
            let query = {
                id:this.checkForm.id
            }
            auditRefuse(query).then(res =>{
                if(res.data.code == 200){
                    this.$message.success('审核成功')
                }
            })
        },
        handlePass(){
            let query = {
                id:this.checkForm.id,
                deptName:this.checkForm.deptName
            }
            auditPass(query).then(res =>{
                if(res.data.code == 200){
                    this.$message.success('审核成功')
                }
            })
        },
    }
}
</script>

<style></style>