<template>
    <div class="signFor">
        <div>
            <el-row style="height: 40px;line-height: 40px;text-align: center;">
                <el-col :span="8"><div>案件编号</div></el-col>
                <el-col :span="16"><div>{{ dataList.caseNum }}</div></el-col>
            </el-row>
            <hr>
            <el-row style="height: 40px;line-height: 40px;text-align: center;">
                <el-col :span="8"><div>申请人</div></el-col>
                <el-col :span="16"><div>{{ dataList.applicationName }}</div></el-col>
            </el-row>
            <hr>
            <el-row style="height: 40px;line-height: 40px;text-align: center;">
                <el-col :span="8"><div>被申请人</div></el-col>
                <el-col :span="16"><div>{{ dataList.respondentName }}</div></el-col>
            </el-row>
            <hr>
            <el-row style="height: 40px;line-height: 40px;text-align: center;">
                <el-col :span="8"><div>调解员</div></el-col>
                <el-col :span="16"><div>{{ dataList.mediatorName }}</div></el-col>
            </el-row>
            <hr>
            <el-row style="height: 40px;line-height: 40px;text-align: center;">
                <el-col :span="8"><div>调解方式</div></el-col>
                <el-col :span="16"><div>{{ dataList.mediationMethodName }}</div></el-col>
            </el-row>
            <hr>
            <el-row style="height: 40px;line-height: 40px;text-align: center;">
                <el-col :span="8"><div>调解时间</div></el-col>
                <el-col :span="16"><div>{{ dataList.hearDate }}</div></el-col>
            </el-row>
            <hr>
            <el-row style="height: 40px;line-height: 40px;text-align: center;">
                <el-col :span="8"><div>案件状态</div></el-col>
                <el-col :span="16"><div>{{ dataList.caseStatusName }}</div></el-col>
            </el-row>
            <hr>
            <el-row style="height: 40px;line-height: 40px;text-align: center;">
                <el-col :span="8"><div>创建时间</div></el-col>
                <el-col :span="16"><div>{{ dataList.createTime }}</div></el-col>
            </el-row>
            <hr>
            <el-row style="height: 40px;line-height: 40px;text-align: center;">
                <el-col :span="7"><div>调解书</div></el-col>
                <el-col :span="15"><div v-for="(item,index) in fileList" :key="index" style="color: blue; cursor: pointer"  @click="toPreview(item.annexPath)">{{ item.annexName }}</div></el-col>
            </el-row>
            <hr>
            <el-row>
                <el-col :span="24">
                    <div style="width: 90px; margin: 30px auto;">
                        <el-button type="primary" @click="getMsCaseSign(caseId)" v-if="showSign" icon="el-icon-edit">签收</el-button>
                    </div>
                </el-col>
            </el-row>
        </div>
    </div>
    
</template>

<script>
import { getEncryptInfoByid,caseApplicationList,msCaseSign,fileList } from "@/api/home";
export default {
    name: "signFor",
    components: {},
    data() {
        return {
            dataList: [],
            loading: false,
            token:'',
            caseId:'',
            showSign:true,
            fileURL: 'http://121.40.189.20:8002' + "/API",
            fileList:[]

        };
    },
    created() {
        console.log(this.fileURL)
    },
    methods: {
        /**获取链接参数 */
        async getEncryptInfoByidFn(data) {
            await getEncryptInfoByid(data).then((res) => {
                this.caseId = res.caseId
                sessionStorage.setItem('token',res.token)
            });
        },
        // 获取案件列表
        async getList(params){
            await caseApplicationList(params).then(res =>{
                res.rows.forEach(item => {
                    this.dataList = item;
                });
            })
        },
        // 案件签收
        async getMsCaseSign(params){
            console.log(params)
            let caseIds = {
                caseId:params
            }
            await msCaseSign(caseIds).then(res =>{
                console.log(res)
                this.$message({
                    message: '签收成功',
                    type: 'success'
                });
                this.showSign = false
            })
        },
        // 查看附件
        async getFileList(caseAppliIds,annexTypeList){
            fileList(caseAppliIds,annexTypeList).then(res=>{
                this.fileList = res.data;
                console.log(this.fileList)
            })
        },
        toPreview(val){
            console.log(val)
            window.open(this.fileURL + val)
        }
    },
    async mounted() {
        let routeParams = this.$route.query;
        await this.getEncryptInfoByidFn(routeParams.authId)
        await this.getList(this.caseId)
        // await this.getList("5461248676208928")
        let caseAppliIds = this.caseId
        let annexTypeList = 7
        await this.getFileList(caseAppliIds,annexTypeList)
    }
};
</script>

<style scoped>
    .signFor{
        margin-top: 30px;
        width: 100%;
    }
</style>