<template>
    <div class="app-container">
        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="addtemplate">新增裁决书模板</el-button>
                <!-- v-hasPermi="['caseManagement:list:add']" -->
            </el-col>
        </el-row>
        <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="identifyName" :show-overflow-tooltip="true" />
            <el-table-column label="裁决书名称" align="center" prop="temName" :show-overflow-tooltip="true" />
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                    <el-button size="mini" @click="deleteTemplate(scope.row)" type="text" icon="el-icon-delete">删除</el-button>
                    <el-button size="mini" @click="eidtTemplate(scope.row)" type="text" icon="el-icon-edit">修改模板</el-button>
                    <el-button size="mini" @click="grabRulesClick(scope.row)" type="text" icon="el-icon-edit">设置抓取规则</el-button>
                    <el-button size="mini" @click="templateList(scope.row)" type="text" icon="el-icon-edit">模板字段列表</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)" />
       
        <addTemplate :uploadVisable="uploadVisable" @cancelUpload="cancelUpload" :uploadData="uploadData" @getList="getList" :queryParams="queryParams">
        </addTemplate>
        <sealManage :sealVisable="sealVisable" @cancelSeal="cancelSeal" :sealData="sealData">
        </sealManage>
        <editTemplate :editVisable="editVisable" @cancelEdit="cancelEdit" @getList="getList" :editData="editData" :queryParams="queryParams"></editTemplate>
        <grabRules :rulesVisable="rulesVisable" @cancelRules="cancelRules" @getList="getList" :rulesData="rulesData" :queryParams="queryParams"></grabRules>
        <temmplateList :listVisable="listVisable" @cancelList="cancelList" @getList="getList" :listData="listData" :queryParams="queryParams"></temmplateList>
   </div>
</template>
  
<script>
import {
    getTemplate,
    deleteTemplate
} from "@/api/officialSeal/officialSeal.js";

import addInstitution from "./components/addInstitution";
import addTemplate from "./components/addTemplate";
import sealManage from "./components/sealManage";
import editTemplate from "./components/editTemplate";
import grabRules from "./components/grabRules.vue";
import temmplateList from "./components/temmplateList.vue";
export default {
    name: "paymentList",
    components: {
        addInstitution,
        addTemplate,
        sealManage,
        editTemplate,
        grabRules,
        temmplateList
    },
    data() {
        return {
            queryParams: {
                pageNum: 1,
                pageSize: 10,
            },
            // 遮罩层
            loading: false,
            // 总条数
            total: 0,
            // 表格数据
            form: {},
            // 校验表单
            rules: {},
            dataList: [],
            operateVisable: false,//新增弹窗
            uploadVisable: false,//上传弹窗
            sealVisable: false,//公章列表弹窗
            rulesVisable:false,//抓取规则弹窗
            uploadData: {},
            sealData: {},
            editVisable:false,
            editData:{},
            rulesData:{},
            listVisable:false,
            listData:{}
        };
    },
    created() {
        this.getList(this.queryParams)
    },
    methods: {
        // 删除
        deleteTemplate(row) {
            this.$modal
                .confirm("是否删除")
                .then((res) => {
                    this.deleteSealFn({ id: row.id })
                })
        },
        // 删除接口
        deleteSealFn(data) {
            deleteTemplate(data).then(res => {
                this.$modal.msgSuccess("删除成功！");
                this.getList(this.queryParams);
            })
        },
        cancelSeal() {
            this.sealVisable = false;
        },
        // 新增模板
        addtemplate(row) {
            this.uploadVisable = true;
            this.uploadData = row;
        },
        cancelUpload() {
            this.uploadVisable = false;
        },
        // 编辑
        eidtTemplate(row) {
            this.editVisable = true;
            this.editData = row;
        },
        cancelEdit() {
            this.editVisable = false;
        },
        // 模板字段列表
        templateList(row){
            this.listVisable = true;
            this.listData = row;
        },
        cancelList(){
            this.listVisable = false;
        },
        // 抓取规则
        grabRulesClick(row){
            this.rulesVisable = true;
            this.rulesData = row;
        },
        cancelRules(){
            this.rulesVisable = false;
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList(this.queryParams);
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        // 查询列表数据
        getList(parms) {
            this.loading = true;
            getTemplate(parms).then((response) => {
                this.dataList = response.rows;
                this.total = response.total;
                this.loading = false;
                console.log(this.dataList,"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL");
                // 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>