<template>
  <div class="tv-container">
      
        <div class="container-box">
             <div>
                <div class="el-label"><i class="el-icon-collection-tag"></i>基本信息</div>
                <div class="el-line"></div>
                <baseTable v-if="woNo" :woNo="woNo" step="3" @callBack="callBack"/>
                <div class="el-line"></div>
                <div class="el-label"><i class="el-icon-collection-tag"></i>指定评估专家</div>
                <div class="el-line"></div>

                <div>
                  <el-row>
                    <el-col :span="6">&nbsp;</el-col>
                    <el-col :span="12">
                        <el-form ref="form" :model="form" label-width="80px">
                          <el-form-item label="评估专家">

                              <el-select v-model="expertList" multiple placeholder="请选择" size="medium" style="width:547px">
                                <el-option
                                  v-for="item in expertOption"
                                  :key="item.value"
                                  :label="item.label"
                                  :value="item.value">
                                </el-option>
                              </el-select>

                          </el-form-item>
                          <el-form-item label="备注信息">
                            <el-input type="textarea" v-model="form.note"></el-input>
                          </el-form-item>
                        </el-form>
                    </el-col>
                    <el-col :span="6">&nbsp;</el-col>
                  </el-row>

                </div>

                <div class="el-line"></div>
                <div class="el-label"></div>
                <div class="el-line"></div>
                <div style="text-align:right">
                  <el-button type="primary" @click="handleAudit">确定</el-button>
                </div>
             </div>
        </div>
        <!--<fullscreen :fullscreen.sync="fullscreen" class="container"></fullscreen>-->
  </div>
</template>

<script>
import baseTable from "./base"
export default {
  components:{ baseTable },
  data(){
    return{
      woNo:'',
      itemId:'',
      fullscreen:true,
      form:{note:""},
      //expertList:"admin,yaolu,chensen,wangyong5,zhangbinqi",
      expertList:[],
      loginNoStr:'',
      bpmInfo:{},
      expertOption:[]
    }
  },
  methods:{
    callBack(itemId){
      this.itemId = itemId
    },
    loadExperData(){
        this.$http({
        url: "/market/tvImport/expertList",
        method: "post",
        headers: {"Content-Type": "application/json"},
        data:{}
        }).then((res) => {
         if(res.data.result==0){
            this.expertOption=[]
            let ul = res.data.body
            let tmp = {}
            ul.forEach(element => {
              tmp={}
              tmp.value = element.loginNoStr
              tmp.label = element.loginNameStr
              this.expertOption.push(tmp)              
            });
         }else{
            this.$message({ showClose: true, message: "逻辑异常",type: 'error'});
         }
      });
    },
    handleAudit(){
        this.loginNoStr=''
        if(this.itemId===""){
          this.$message({ showClose: true, message: "数据异常",type: 'error'});
          return
        }
        if(this.expertList.length===0 || this.expertList.length>5){
          this.$message({ showClose: true, message: "请选择5人以内的专家",type: 'error'});
          return
        }else{
          this.expertList.forEach((e)=>{
            this.loginNoStr = this.loginNoStr+e +","
          });
        }
        this.loginNoStr = this.loginNoStr.substring(0,this.loginNoStr.length-1)
 
        //拼装参数
        let info={}
        info.params={"extendInfo":this.loginNoStr,"note":this.form.note,"itemId":this.itemId,"woNo":this.woNo},
        info.taskId = this.bpmInfo.taskId
        info.woNo = this.bpmInfo.woNo 
        info.stepId = this.bpmInfo.stepId
        info.procId = this.bpmInfo.procId
        info.procVersion = this.bpmInfo.procVersion
        //POST请求
        this.$http({
        url: "/bpm/api/submitTask",
        method: "post",
        headers: {"Content-Type": "application/json"},
        data:info
        }).then((res) => {
         if(res.data.result==0){
           // afterAssignExpert
            this.$http({
            url: "/market/tvImport/afterAssignExpert",
            method: "post",
            headers: {"Content-Type": "application/json"},
            data:info
            }).then((res) => {
                if(res.data.result==0){
                    this.$router.push({	path: '/tvIntroduction'});
                }else{
                     this.$message({ showClose: true, message: "异常x",type: 'error'});
                }
            });

         }else{
            this.$message({ showClose: true, message: res.data.desc,type: 'error'});
         }
        });
    }
  },
  mounted(){
    this.loadExperData()
    this.woNo = this.$route.query.woNo
    this.bpmInfo.taskId = this.$route.query.taskId
    this.bpmInfo.woNo = this.woNo
    this.bpmInfo.stepId = this.$route.query.stepId
    this.bpmInfo.procId = this.$route.query.procId
    this.bpmInfo.procVersion = this.$route.query.procVersion
  }
}
</script>
<style lang="scss" scoped>
.tv-container{
  background-color: white;
  margin:15px 15px 15px 15px;
  padding:20px ;

}
.el-label{
  /*border-left:5px solid #0b82ff;*/
  /*padding-left:5px;*/
  color: #606266;
  border-bottom:1px dotted #bfc1c5;
  padding-bottom:5px;
}
.el-line{
  margin: 0px 0px 20px 0px;
}
</style>
