<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="name" :show-overflow-tooltip="true" />
            <el-table-column label="模板内容" align="center" prop="content" :show-overflow-tooltip="true" />
            <el-table-column label="模板类型" align="center" prop="typeName" :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>
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList(queryParams)" />
       
        <addManager :uploadVisable="uploadVisable" @cancelUpload="cancelUpload" :uploadData="uploadData" @getList="getList" :queryParams="queryParams">
        </addManager>
        <editManager :editVisable="editVisable" @cancelEdit="cancelEdit" @getList="getList" :editData="editData" :queryParams="queryParams"></editManager>
    </div>
</template>
  
<script>
import {
    getManagerList,
    deleteManager
} from "@/api/officialSeal/officialSeal.js";

import addManager from "./components/addManager";
import editManager from "./components/editManager";
export default {
    name: "paymentList",
    components: {
        addManager,
        editManager
    },
    data() {
        return {
            queryParams: {
                pageNum: 1,
                pageSize: 10,
            },
            // 遮罩层
            loading: false,
            // 总条数
            total: 0,
            // 表格数据
            form: {},
            // 校验表单
            rules: {},
            dataList: [],
            operateVisable: false,//新增弹窗
            uploadVisable: false,//上传弹窗
            uploadData: {},
            sealData: {},
            editVisable:false,
            editData:{}
        };
    },
    created() {
        this.getList(this.queryParams)
    },
    methods: {
        // 删除
        deleteTemplate(row) {
            this.$modal
                .confirm("是否删除")
                .then((res) => {
                    this.deleteSealFn({ id: row.id })
                })
        },
        // 删除接口
        deleteSealFn(data) {
            deleteManager(data).then(res => {
                this.$modal.msgSuccess("删除成功！");
                this.getList(this.queryParams);
            })
        },
        // 新增模板
        addtemplate(row) {
            this.uploadVisable = true;
            this.uploadData = row;
        },
        cancelUpload() {
            this.uploadVisable = false;
        },
        // 编辑
        eidtTemplate(row) {
            this.editVisable = true;
            this.editData = row;
        },
        cancelEdit() {
            this.editVisable = false;
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList(this.queryParams);
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        // 查询列表数据
        getList(parms) {
            this.loading = true;
            getManagerList(parms).then((response) => {
                this.dataList = response.rows;
                this.dataList.forEach(item => {
                    if(item.type == 1){
                        item.typeName = '裁决内容'
                    }else if(item.type == 2){
                        item.typeName = '调解协议'
                    }else if(item.type == 3){
                        item.typeName = '金融消费纠纷基本情况'
                    }
                });
                this.total = response.total;
                this.loading = false;
            });
        },
    },
};
</script>
  
<style lang="scss" scoped></style>