<template>
  <div>

      <el-dialog
        :title="itemName"
        :visible.sync="dialogVisible"
        width="90%"
        :close-on-click-modal="false"
        :modal-append-to-body="false"
        :before-close="handleClose">


            <div class="el-label"><i class="el-icon-collection-tag"></i>基本信息1</div>
            <div class="el-line"></div>
            <el-table class="com-table" ref="multipleTable" :data="tableData"
                        tooltip-effect="dark" size="small" border style="width: 100%" v-loading="loading"
            >

           <el-table-column prop="idx"   label="序号" align="center" width="50px"/>
 

            <el-table-column label="业务属性" align="center">
              <el-table-column  prop="busiType"    label="业务类型" align="center"/>
              <el-table-column  prop="productName" label="产品名称" align="center"/>
              <el-table-column  prop="parterName"  label="企业名称" align="center"/>
            </el-table-column>

            <el-table-column label="介绍材料" align="center">
              <el-table-column  prop="isBlack"         label="黑名单"          align="center" width="60px">
                  <template slot-scope="scope">
                      <div v-if="scope.row.isBlack==0">否</div>
                      <div v-if="scope.row.isBlack==1">是</div>
                  </template>
              </el-table-column>

              <el-table-column  prop="businessLicense" label="企业法人营业执照" align="center">
                <template slot-scope="scope">
                    <down :files="scope.row.businessLicense"></down>
                </template>
              </el-table-column>
              <el-table-column  prop="orgCode"         label="组织机构代码证"   align="center">
                <template slot-scope="scope">
                    <down :files="scope.row.orgCode"></down>
                </template>
              </el-table-column>
              <el-table-column  prop="taxReg"          label="税务登记证"       align="center">
                <template slot-scope="scope">
                    <down :files="scope.row.taxReg"></down>
                </template>                
              </el-table-column>
              <el-table-column  prop="bankAccount"     label="银行开户许可证"   align="center">
                <template slot-scope="scope">
                    <down :files="scope.row.bankAccount"></down>
                </template>                
              </el-table-column>
              <el-table-column  prop="addService"      label="增值业务许可证"   align="center">
                <template slot-scope="scope">
                    <down :files="scope.row.addService"></down>
                </template>                
              </el-table-column>
              <el-table-column  prop="productInfo"     label="产品介绍"         align="center">
                <template slot-scope="scope">
                    <down :files="scope.row.productInfo"></down>
                </template>               
              </el-table-column>
              <el-table-column  prop="otherInfo"       label="其他说明材料"     align="center">
                <template slot-scope="scope">
                    <down :files="scope.row.otherInfo"></down>
                </template>                
              </el-table-column>
            </el-table-column>


            <el-table-column label="内部评估材料" align="center">
                <el-table-column  label="内容资源" align="center">
                      <el-table-column   label="内容品质" align="center">
                      <template slot-scope="scope">
                        <down :files="scope.row.contentQuality"></down>
                      </template>                        
                      </el-table-column>
                      <el-table-column   label="内容授权" align="center">
                      <template slot-scope="scope">
                        <down :files="scope.row.contentAuth"></down>
                      </template>
                      </el-table-column>
                      <el-table-column   label="用户认知" align="center">
                      <template slot-scope="scope">
                        <down :files="scope.row.userCognition"></down>
                      </template>                        
                      </el-table-column>
                </el-table-column>

                <el-table-column  label="创新性" align="center">
                      <template slot-scope="scope">
                        <down :files="scope.row.innovation"></down>
                      </template>
                </el-table-column>
                <el-table-column  label="用户体验" align="center">
                      <template slot-scope="scope">
                        <down :files="scope.row.userExperience"></down>
                      </template>                  
                </el-table-column>
                <el-table-column  label="资费" align="center">
                      <template slot-scope="scope">
                        <down :files="scope.row.fee"></down>
                      </template>                  
                </el-table-column>
                <el-table-column  label="信息安全" align="center">
                    <template slot-scope="scope">
                        <down :files="scope.row.infoSafety"></down>
                    </template>
                </el-table-column>
              </el-table-column>

            <el-table-column label="审核信息" align="center">
              <el-table-column  prop="isPass"          label="是否通过" align="center" width="50px">
                   <template slot-scope="scope">
                      <div v-if="scope.row.isPass==0">否</div>
                      <div v-if="scope.row.isPass==1">是</div>
                  </template>
              </el-table-column>
              <el-table-column  prop="s8"              label="总平均分"  align="center" width="60px"/>
              <el-table-column  prop="publishInRule"   label="2月内上线" align="center" width="60px">
                   <template slot-scope="scope">
                      <div v-if="scope.row.publishInRule==0">否</div>
                      <div v-if="scope.row.publishInRule==1">是</div>
                  </template>
              </el-table-column>
              <el-table-column  label="上线文档"  align="center" >
                  <template slot-scope="scope">
                    <down :files="scope.row.publishFile"></down>
                </template>       
            </el-table-column>
            </el-table-column>
          </el-table>

          <div style="margin-top:20px;" v-if="extFiles.length>0" >
            <div class="el-label"><i class="el-icon-paperclip"></i>附件列表</div>
            <div class="el-line"></div>
            <el-table class="com-table" :show-header="false" ref="multipleTable"  :data="extFiles"
              tooltip-effect="dark" size="small" border style="width: 100%" v-loading="loading">
                <el-table-column align="left" prop="l" width="180px"></el-table-column>
                <el-table-column align="left" prop="n"></el-table-column>
                <el-table-column align="center" prop="u" width="140px"></el-table-column>
                <el-table-column align="left" width="300px">
                      <template slot-scope="scope">
                          <down :files="scope.row.f"></down>
                       </template>
                </el-table-column>
            </el-table>
          </div>


          <div style="margin-top:20px;" v-if="expertData.length>0" >
            <div class="el-label"><i class="el-icon-collection-tag"></i>专家评审</div>
            <div class="el-line"></div>
            <el-table class="com-table" ref="multipleTable"  :data="expertData"
              tooltip-effect="dark" size="small" border style="width: 100%" :span-method="rowSpanForInputFile"> v-loading="loading">

                <el-table-column prop="idx"   label="序号" align="center" width="50px"/>
                <el-table-column label="业务属性" align="center">
                  <el-table-column  prop="busiType"    label="业务类型" align="center"/>
                  <el-table-column  prop="productName" label="产品名称" align="center"/>
                  <el-table-column  prop="parterName"  label="企业名称" align="center"/>
                </el-table-column>

                <el-table-column label="产品打分评审" align="center">
                      <el-table-column label="内容资源" align="center">
                        <el-table-column label="内容品质(15%)" prop="s1" align="center"></el-table-column>
                        <el-table-column label="内容授权(5%)"  prop="s2" align="center"></el-table-column>
                        <el-table-column label="用户认知(20%)" prop="s3" align="center"></el-table-column>
                      </el-table-column>
                        
                        <el-table-column label="创新性(20%)" prop="s4" align="center"></el-table-column>
                        <el-table-column label="用户体验(20%)" prop="s5" align="center"></el-table-column>
                        <el-table-column label="资费(10%)" prop="s6" align="center"></el-table-column>
                        <el-table-column label="信息安全(10%)" prop="s7" align="center"></el-table-column>
                </el-table-column>

                <el-table-column label="合计(100%)" prop="s8" align="center">
                </el-table-column>

                
                <el-table-column label="评审专家" prop="expertLoginName" align="center">
                </el-table-column>

                <el-table-column label="备注" prop="note" align="center" >
                </el-table-column>

                <el-table-column label="总平均分" prop="avgAllScore" align="center">
                </el-table-column>
            </el-table>
          </div>
 

        <div style="margin-top:20px;" v-if="itemId!==''">
          <div class="el-label"><i class="el-icon-collection-tag"></i>审批轨迹</div>
          <div class="el-line"></div>
          <audit :itemId="itemId"></audit>
        </div>


        <span slot="footer" class="dialog-footer">
          <el-button @click="handleClose">取 消</el-button>
          <el-button type="primary" @click="handleClose">确 定</el-button>
        </span>
      </el-dialog>

  </div>
</template>

<script>
import {strToHerf} from "@/utils/tv.js"
import audit from "./audit.vue";
import down from "@/components/uploadNewDown.vue";
export default {
  components:{audit,down},
  props:{
    itemId: { required: true,type: String},
    dialogVisible: {required: true,type: Boolean, default() {return false;},
    },
  },
  data(){
    return{
      loading:false,
      itemName:"",
      tableData:[],
      extFiles:[],
      expertData:[]
    }
  },
  methods:{
    filesToUrl(files){
      return strToHerf(files)
    },
    handleClose(){
       this.$emit("closeWin")
       this.tableData=[]
       this.extFiles=[]
       this.expertData=[]
    },
    loadExpert(){
      this.loading = true;
      this.$http({
        url: "/market/tvImport/queryExpert",
        method: "post",
        headers: {
          "Content-Type": "application/json"
        },
        data:{"itemId":this.itemId,"orderBy":"a.item_id,a.idx"}
      }).then((res) => {
        if(res.data.result===0){
            this.expertData = res.data.body
        }
        this.loading = false;
      });
    },
    loadData(){
      this.loading = true;
      this.$http({
        url: "/market/tvImport/queryImport",
        method: "post",
        headers: {
          "Content-Type": "application/json"
        },
        data:{"itemId":this.itemId}
      }).then((res) => {
        if(res.data.result===0){
          this.tableData = res.data.body
          if(null!==this.tableData){
            return 
          }
          let iData = this.tableData[0]
          this.itemName =iData.itemName
          if(iData.marketFile!=undefined){
              let extFile = {"f":iData.marketFile,'n':iData.marketNote,'l':'市场决策委员会审核','u':''}
              this.extFiles.push(extFile)
          }
          if(iData.sendFile!=undefined){
            //
            let units = JSON.parse(iData.receiveUnit);
            let unit = "";
            for(var i = 0 ;i <units.length;i++){
              unit = unit + units[i]+" ,";
            }
            unit = unit.substring(0,unit.length -1)
            unit = "收函单位 : "+unit;

            let extFile = {"f":iData.sendFile,'n':iData.sendNote,'l':'专业公司发函','u':unit}
            this.extFiles.push(extFile)
          }
          if(iData.provinceFile!=undefined){
            let extFile = {"f":iData.provinceFile,'n':iData.provinceNote,'l':'省内引入','u':''}
            this.extFiles.push(extFile)
          }

          this.loading = false;
        }else{
          this.$message({ showClose: true, message: '系统异常',type: 'error'});
        }
      });
    },
    rowSpanForInputFile({ row, column, rowIndex, columnIndex }){
        if (columnIndex === 0 || columnIndex === 1 || columnIndex === 2 || columnIndex===3  || columnIndex===14) {
          if ((rowIndex % row.expertCount) ===0) {
          return {
            rowspan: row.expertCount,
            colspan: 1
          };
        }else {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
      }
    }
  },
  watch:{
    dialogVisible(val,oldVal){
      if(val===true){
          this.loadData()
          this.loadExpert()
      }
    }
  },
  mounted(){
    this.loadData()
    this.loadExpert()
  }
}
</script>
<style>
.el-label{
  color: #606266;
  border-bottom:1px dotted #bfc1c5;
  padding-bottom:5px;
}
.el-line{
  margin: 0px 0px 20px 0px;
}
</style>
