<template>
    <div class="app-container">
        <el-table v-loading="loading" :data="dataList" style="width: 100%">
            <el-table-column label="序号" type="index" align="center">
                <template slot-scope="scope">
                    <span>{{
                        (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1
                    }}</span>
                </template>
            </el-table-column>
            <el-table-column label="仲裁机构名称" align="center" prop="deptName" :show-overflow-tooltip="true" />
            <el-table-column label="公章名称" align="center" prop="sealName" :show-overflow-tooltip="true" />
            <el-table-column label="经办人姓名" align="center" prop="nickName" :show-overflow-tooltip="true" />
            <el-table-column label="经办人手机号" align="center" prop="phonenumber" :show-overflow-tooltip="true" />
            <el-table-column label="认证时间" align="center" prop="updateTime" />
            <el-table-column label="认证状态" align="center" prop="identifyStatus" :show-overflow-tooltip="true" />
            <el-table-column label="是否启用" align="center" prop="isUse"></el-table-column>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                    <el-button size="mini" @click="DeptIndefiUrl(scope.row)" type="text" icon="el-icon-thumb"
                        v-if="scope.row.identifyStatus == '未认证'">认证</el-button>
                    <el-button size="mini" @click="changeStatus(scope.row)" type="text" icon="el-icon-thumb"
                        v-if="scope.row.isUse == '未启用' && scope.row.identifyStatus == '已认证'">启用</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList(queryParams)" />

    </div>
</template>
  
<script>
import {
    deptIdentifyList,
    enableDept,
    selectDeptIndefiUrl
} from "@/api/officialSeal/officialSeal.js";

import { getDicts } from '@/api/system/dict/data.js'
export default {
    name: "paymentList",
    dicts: ["case_status"],
    components: {},
    data() {
        return {
            queryParams: {
                pageNum: 1,
                pageSize: 10,
            },
            caseStatus: [],
            // 遮罩层
            loading: false,
            // 总条数
            total: 0,
            // 表格数据
            form: {},
            // 校验表单
            rules: {},
            dataList: [],
        };
    },
    created() {
        getDicts("case_status").then(res => {
            this.caseStatus = res.data;
            this.getList(this.queryParams);
        })
    },
    methods: {
        // 启用认证按钮
        changeStatus(row) {
            this.$modal.confirm('是否进行启用？')
                .then(function () {

                })
                .then(() => {
                    enableDept({ id: row.id }).then(res => {
                        this.$modal.msgSuccess("启用成功！");
                        this.getList(this.queryParams);
                    })

                })
                .catch(function () {
                });
        },
        // 认证按钮
        DeptIndefiUrl(row) {
            this.$modal.confirm('是否认证？')
                .then(function () {
                    selectDeptIndefiUrl({ id: row.id }).then(res => {
                        let url = res.data.identifyUrl;
                        window.open(url)
                    })
                })
                .then(() => {
                    // this.$modal.msgSuccess("认证成功！");
                    // this.getList(this.queryParams);
                })
                .catch(function () {
                });
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList(this.queryParams);
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        // 查询列表数据
        getList(parms) {
            this.loading = true;
            deptIdentifyList(parms).then((response) => {
                this.dataList = response.rows;
                this.total = response.total;
                this.loading = false;
                this.dataList.forEach(item => {
                    if (item.identifyStatus == 0 || item.identifyStatus == null) {
                        item.identifyStatus = '未认证'
                    } else {
                        item.identifyStatus = '已认证'
                    }
                    if (item.isUse == 0 || item.isUse == null) {
                        item.isUse = '未启用'
                    } else {
                        item.isUse = '已启用'
                    }
                })
            });
        },
    },
};
</script>
  
<style lang="scss" scoped></style>