<template>
  <div v-wechat-title="$route.meta.title" style="height:100%;background-color:#FAFAFA;">
    <div style="height:1px;"></div>    
        <div class="housebackgroundcolor">
           <div class="houselist" >
                <Icon  type="ios-arrow-back" style="color:#fff;" @click="openYiBan"/>
                <span style="color:#fff;" @click="openYiBan">返回</span>
                <Icon @click="openMain" size="18" style="color:#fff;float:right;margin-right:10px;" type="md-home" />
            </div>
            <hr style="border:0.5px solid #DDDDDD;" align="center">
        </div>
        <hr style="border:0.5px solid #DDDDDD;" align="center">
        <div style="height:10px;"></div>
        <!-- 处理意见 -->
        <hr style="border:0.5px solid #DDDDDD;" align="center">
        <div style="background-color:#fff;">
            <p class="bodyone"><Icon type="ios-create" size="18" style="margin-right:5px;"/>处理意见</p>
            <div style="width:90%;margin:10px 0px 10px 20px;">
                 <Input v-model="text" type="textarea" :rows="4" placeholder="请输入您的处理意见"/>
            </div>
        </div>
        <hr style="border:0.5px solid #DDDDDD;" align="center">
        <div style="height:10px;"></div>
         <Button @click="openSend" long style="height:40px;" type="primary">确定</Button>
        <!-- 模态框 -->
    </div>
</template>

<script>
export default {
    data() {
        return {
            text:'同意',
            user:JSON.parse(sessionStorage.getItem('usercode')),
            code:JSON.parse(sessionStorage.getItem('actCode')),
            approve:'',
            ress:'',
        }
    },
    created() {
          let a = "Webservice接口地址"
        this.$store.dispatch('GetSystemURL',a).then(rurles=>{
            this.ress = rurles;
            this.$axios({
                url: '/'+this.ress+'/'+"GetWorkFlowPage?userCode="+this.user+"&actCode="+this.code,
                method:'get',
                //发送格式为json
                headers:{
                'Content-Type': 'application/json'
                }
            }).then(r=>{
                if(r.data.data.auditResult.items==null){
                    this.approve = '';
                }
                else{
                    this.approve = 'Approve';
                }
            })
        })
    },
    methods: {
        //返回上一层
        openYiBan(){
            this.$router.push('/detauils');
        },
        //返回主页
        openMain(){
            this.$router.push('/main');
        },
        //确定
        openSend(){
            if(this.user==null || this.code==null){
                this.$Message.error('发生错误!');
                return;
            }
            // 流程退回,点击确定接口.
            this.$axios({
                url: '/'+this.ress+'/'+"WorkFlowTaskFinish?userCode=" + this.user +
                 "&actCode=" + this.code +
                 "&opinion=" + this.text +
                 "&auditValue=" + this.approve,
                method:'get',
                //发送格式为json
                headers:{
                'Content-Type': 'application/json'
                }
            }).then(r=>{
                if(r.data.msg=='合同完成'){
                    this.$Message.success(r.data.msg);
                    this.$router.push('/zaiban')
                }
                else{
                    this.$Message.error(r.data.msg);
                }
            })            
        },
    },
}
</script>

<style>
    .housebackgroundcolor{
    background-color:rgb(55, 150, 223);
    }
    .housebackgroundcolor:hover{
    cursor: pointer;  
    }
    .houselist{
    padding:13px 0px 0px 10px;height:45px;font-size:13px;
    }
    .headdone{
    width:25%;display: inline-block;text-align:center;height:40px;
    }
    .headdtwo:hover{
    cursor: pointer;
    }
    .headdtwo{
    margin-top:10px;font-weight:bold;
    }
    .bodyone{
        padding:10px 0px 0px 10px;font-weight:bold;font-size:15px;display:inline-block;
    }
    .bodyone:hover{
        cursor: pointer;
    }
     input{
        border: none;
        outline: none;
    }
</style>
