<template>
    <div class="app-container">
        <el-table :data="authenticationList">
            <el-table-column label="企业名称" align="center" prop="enterpriseName" />
            <el-table-column label="企业前缀" align="center" prop="certificationPrefix">
                <template slot-scope="scope">
                    {{scope.row.certificationType == 0 ? '—':scope.row.certificationPrefix}}
                </template>
            </el-table-column>
            <el-table-column label="认证类型" align="center" prop="certificationType" >
                <template slot-scope="scope">
                    {{scope.row.certificationType == 0 ? '工商认证':'工业互联网认证'}}
                </template>
            </el-table-column>
            <el-table-column label="认证日期" align="center" prop="certificationDate" />
            <el-table-column label="认证状态" align="center" prop="certificationStatus">
                <template slot-scope="scope">
                    <span v-if="scope.row.certificationStatus == 0" class="text-warning">未认证</span>
                    <span v-else-if="scope.row.certificationStatus == 1" class="text-navy">认证成功</span>
                    <span v-else-if="scope.row.certificationStatus == 2" class="text-danger">认证失败</span>
                    <span v-else-if="scope.row.certificationStatus == 3" class="text-success">认证中</span>
                </template>
            </el-table-column>
            <el-table-column label="认证结果" align="center" class-name="small-padding fixed-width" prop="faildReason" >
            </el-table-column>
            <el-table-column label="认证操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                <el-button
                    size="mini"
                    type="text"
                    @click="applyAuthen(scope.row)"
                >认证</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
import { getEnterpriseCertificationInfoByLogin,certificationEnterprise,industrialInternetCertification} from "@/api/system/certification";
export default {
    name:'authentication',
    data(){
        return {
            authenticationList:[],
            queryParams: {
                pageNum: 1,
                pageSize: 10,
            },
        }
    },
    mounted() {
        this.initData()
    },
    methods: {
        initData(){
            getEnterpriseCertificationInfoByLogin().then(response => {
                this.authenticationList = response.data;
            });
        },
        applyAuthen(row) {
            if(row.certificationType == 0){
                certificationEnterprise().then(res => {
                    this.msgInfo(res.msg);
                    this.initData()
                })
            } else if (row.certificationType == 1) {
                industrialInternetCertification().then(res => {
                    this.msgSuccess("工业互联网认证申请成功");
                    this.initData()
                })
            }
        }
    },
}
</script>