<template>
  <el-dialog
    ref="dialog"
    :close-on-click-modal="false"
    :title="title"
    :top="dialogFormTop"
    :visible.sync="dialogVisible"
    :destroy-on-close="true"
    width="97.5%"
    :model="false"
    :before-close="handleClose"
  >
    <div  v-loading="loading"  element-loading-text="数据加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(3, 30, 57, 0.8)">
      <div class="dialog_content">
        <div class="block-info">
          <div class="cate-title">
            <span class="order">01</span>
            <span>基本信息</span>
          </div>
          <div class="info-content base-info">
            <div class="item" v-for="(item,index) in baseInfo" :key="index">
              <span class="item_name">{{item.name}}：</span>
              <span>{{item.value}}</span>
            </div>
          </div>
        </div>
        <div class="block-info">
          <div class="cate-title">
            <span class="order">02</span>
            <span>评价信息</span>
          </div>
          <div class="info-content base-info">
            <div class="item" v-for="(item,index) in evaluateInfo.slice(0,5)" :key="index">
              <span class="item_name">{{item.name}}：</span>
              <span>{{item.value}}</span>
            </div>
            <div class="item_line" v-for="(item,index) in evaluateInfo.slice(5,8)" :key="index">
              <span class="item_name">{{item.name}}：</span>
              <span>{{item.value}}</span>
            </div>
          </div>
          <div>
            <el-button type="primary" size="small">屏蔽文字</el-button>
            <el-button type="primary" size="small">撤销屏蔽</el-button>
          </div>
        </div>
        <div v-if="operationType === 'find' || operationType === 'exam'" class="block-info">
          <div class="cate-title">
            <span class="order">03</span>
            <span>答复管理信息</span>
          </div>
          <div class="info-content base-info">
            <div class="item_line" v-for="(item,index) in repeatInfo" :key="index">
              <span class="item_name">{{item.name}}：</span>
              <span>{{item.value}}</span>
            </div>
          </div>
        </div>
        <div v-if="operationType ===  'find'" class="block-info">
          <div class="cate-title">
            <span class="order">04</span>
            <span>审核回复信息</span>
          </div>
          <div class="info-content base-info">
            <div class="item_line" v-for="(item,index) in examInfo" :key="index">
              <span class="item_name">{{item.name}}：</span>
              <span>{{item.value}}</span>
            </div>
          </div>
        </div>
        <div v-if="operationType === 'exam'" class="block-info">
          <div class="cate-title">
            <span  class="order">04</span>
            <span>审核回复信息</span>
          </div>
          <div class="form-area">
            <el-form  size="small" :model="formData" inline label-width="100">
              <el-form-item label="审核意见">
                <el-input v-model="formData.advance" type="textarea"></el-input>
              </el-form-item>
            </el-form>
          </div>

        </div>
        <div v-if="operationType === 'repeat'" class="block-info">
          <div class="cate-title">
            <span class="order">03</span>
            <span>答复管理信息</span>
          </div>
          <div class="form-area">
            <el-form  size="small" :model="formData" inline label-width="100">
              <el-form-item  label="回复内容">
                <el-input v-model="formData.advance" type="textarea"></el-input>
              </el-form-item>
            </el-form>
          </div>

        </div>
        <div class="btns model-btns save-class" v-if="operationType!=='exam'">
          <el-button size="small" v-if="operationType === 'repeat'" @click="saveRepeatInfo()" type="primary">保存</el-button>
          <el-button size="small"  @click="handleClose" type="primary">关闭</el-button>

        </div>
        <div class="btns model-btns save-class"  v-else>
          <el-button size="small" type="primary">审核通过</el-button>
          <el-button size="small" type="primary">审核不通过</el-button>
          <el-button size="small" @click="handleClose" type="primary">关闭</el-button>
        </div>
      </div>
    </div>
  </el-dialog>
</template>

<script>
import {getCurrentTime} from "@/commomUse";
import {MessageBox} from "element-ui";
export default {
  name: "EvaluateRepeatModel",
  data(){
   return {
     loading:false,
     dialogFormTop:'12vh',
     baseInfo:[
       {
         name:'办件编号',
         code:'HANDING_NUMBER',
         value:"",
       },
       {
         name:'事项名称',
         code:'MATTER_NAME',
         value:"",
       },
       {
         name:'归属部门',
         code:'BELONGING_DEPARTMENT',
         value:"",
       },
       {
         name:'事项编码',
         code:'MATTER_CODE',
         value:"",
       },
       {
         name:'办理点',
         code:'HANDING_POING',
         value:"",
       },
       {
         name:'评价对象',
         code:'EVALUATION_OBJECT',
         value:"",
       },
       {
         name:'窗口号',
         code:'WINDOW_NUMBER',
         value:"",
       },
       {
         name:'数据来源',
         code:'DATA_SOURCES',
         value:"",
       },
       {
         name:'工作人员',
         code:'WORKING_PERSONNEL',
         value:"",
       },
       {
         name:'办件对象',
         code:'HANDING_OBJECT',
         value:"",
       },
       {
         name:'工号',
         code:'JOB_NUMBER',
         value:"",
       },
       {
         name:'实名途径',
         code:'REAL_NAME_CHANNEL',
         value:"",
       },
       {
         name:'是否转办12345',
         code:'TRANSFER',
         value:"",
       },
     ],
     evaluateInfo:[
       {
         name:'联系人',
         code:'CONTACTS',
         value:''
       },
       {
        name:'联系方式',
         code:'CONTACT_MODE',
         value:''
      },
       {
         name:'评价时间',
         code:'COMMENT_TIME',
         value:''
       },
       {
         name:'社会信用代码',
         code:'CREDIT_CODE',
         value:''
       },
       {
         name:'总体满意度',
         code:'OVERALL_SATISFACTION',
         value:''
       },
       {
         name:'勾选理由',
         code:'REASON',
         value:''
       },
       {
         name:'评价内容(原文)',
         code:'EVALUATION_CONTENT',
         value:''
       },
       {
         name:'评价内容(发布)',
         code:'EVALUATION_CONTENT',
         value:''
       },
     ],
     repeatInfo:[
       {
         name:'回复人',
         code:'',
         value:''
       },
       {
         name:'回复时间',
         code:'REPLY_TIME',
         value:''
       },
       {
         name:'回复内容',
         code:'REPLY_CONTENT',
         value:''
       },
     ],
     examInfo:[
       {
         name:'审核人',
         code:'',
         value:''
       },
       {
         name:'审核时间',
         code:'',
         value:''
       },
       {
         name:'审核内容',
         code:'',
         value:''
       },
     ],
     formData: {
       advance:''
     }
   }
  },
  props:{
    dialogVisible:{

    },
    title:{

    },
    currentData:{

    },
    operationType:{

    }
  },
  methods:{
    showData(){
      let DataList = ["baseInfo","evaluateInfo","repeatInfo","examInfo"];
      for(let i =0;i<DataList.length;i++){
        for(let j=0;j< this[DataList[i]].length;j++){
          this[DataList[i]][j].value = '';
        }
      }
      for(let obj in this.currentData){
        for(let i=0;i<DataList.length;i++){
          for(let j=0;j<this[DataList[i]].length;j++){
            if(obj==this[DataList[i]][j].code){
              this[DataList[i]][j].value =this.currentData[obj]
            }
          }
        }
      }
    },
    saveRepeatInfo(){
      this.loading=true;
      let time =getCurrentTime()
      this.$request({
        url:'/ywtb/editYwtbEvaluate',
        method:'post',
        data:{
          "REPLY_TIME":time,
          "REPLY_CONTENT":this.formData.advance,
          "MARK_UUID":this.currentData.MARK_UUID,
        }
      }).then(response => {
        let dataArr = response.data.msg[0].success;
        if(dataArr=='true'){
          console.log(dataArr);
          this.loading=false;
          MessageBox.alert('回复成功', '提示', {
            confirmButtonText: '确定'
          });
          this.handleClose();
        }else{
          this.loading=false;
          MessageBox.alert('回复失败', '提示', {
            confirmButtonText: '确定'
          });
        }
      })
    },
    handleClose() {
      this.formData.advance = '';
      this.$emit('update:dialogVisible',false)
    },
  },
  watch:{
    dialogVisible:{
      handler(val){
        if(val){
          this.showData();
        }
      },
      deep:true
    }
  }

}
</script>

<style scoped lang="scss">

.el-dialog__wrapper{
  overflow: hidden;
}

.form-area{
  margin-top: 10px;
  margin-bottom: 10px;
}
::v-deep{
  .el-form-item__label{
    font-weight: bolder !important;
    //color: #71d7ff;
  }
  .el-form-item--small .el-form-item__content{
    .el-textarea__inner{
      height:110px;
    }
    width: 600px;

  }
  .el-dialog__wrapper{
    overflow: hidden;
  }
  .el-dialog{
    //height: 70%;
   // overflow: auto;
  }
}
.dialog_content{
  height: 650px;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  //overflow: auto;
}
.block-info{
  width: 45%;
  padding-left: 2.5%;
  padding-right: 2.5%;
  margin: 15px 0;
  .info-content{
     display: flex;
    flex-wrap: wrap;
    .item{
      width: 50%;
      line-height:40px;
    }
    .item_line{
      width: 100%;
      line-height:40px;
    }
  }
   .cate-title{
     padding: 10px 0;
     margin-bottom: 4px;
     border-bottom: 1px solid #2c91cc;
     color: #71d7ff;
     font-size: 18px;
     font-weight: bold;
   }
  .order{
    margin-right: 6px;
  }
  color: #fff;
  font-size: 16px;

}
.save-class{
  width: 100%;
}
.item_name{
  //color: #71d7ff;
  font-weight: bolder;
}
</style>
