<template>
  <div>     <!-- height="calc(100% - 40px)"-->
            <div v-if="itemName" style="padding-bottom:10px;text-align:center;color: #606266;">{{itemName}}</div>
            <el-table class="com-table" ref="multipleTable" :data="tableData"
                        tooltip-effect="dark" size="small" border style="width: 100%" v-loading="loading">

              <template v-if="step==3">
                <el-table-column prop="idx"   label="序号" align="center" width="50px"/>
              </template>
              <template v-else>
                <el-table-column prop="idx" type="index"  label="序号" align="center" width="50px"/>
              </template>

              <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">
                      <div v-html="filesToUrl(scope.row.businessLicense)" />
                  </template>
                </el-table-column>
                <el-table-column  prop="orgCode"         label="组织机构代码证"   align="center">
                  <template slot-scope="scope">
                    <div v-html="filesToUrl(scope.row.orgCode)" />
                  </template>
                </el-table-column>
                <el-table-column  prop="taxReg"          label="税务登记证"       align="center">
                  <template slot-scope="scope">
                    <div v-html="filesToUrl(scope.row.taxReg)" />
                  </template>                
                </el-table-column>
                <el-table-column  prop="bankAccount"     label="银行开户许可证"   align="center">
                  <template slot-scope="scope">
                      <div v-html="filesToUrl(scope.row.bankAccount)" />
                  </template>                
                </el-table-column>
                <el-table-column  prop="addService"      label="增值业务许可证"   align="center">
                  <template slot-scope="scope">
                      <div v-html="filesToUrl(scope.row.addService)" />
                  </template>                
                </el-table-column>
                <el-table-column  prop="productInfo"     label="产品介绍"         align="center">
                  <template slot-scope="scope">
                      <div v-html="filesToUrl(scope.row.productInfo)" />
                  </template>               
                </el-table-column>
                <el-table-column  prop="otherInfo"       label="其他说明材料"     align="center">
                  <template slot-scope="scope">
                      <div v-html="filesToUrl(scope.row.otherInfo)" />
                  </template>                
                </el-table-column>
              </el-table-column>
              -->
                <template v-if="step=='2'">
                  <el-table-column label="内部评估材料" align="center">
                    <el-table-column  label="内容资源" align="center">
                          <el-table-column   label="内容品质" align="center">
                          <template slot-scope="scope">
                            <myUpload ref="contentQuality" type="contentQuality" :fList="scope.row.contentQuality" :itemId="dataId"   :idx="scope.row.idx" @handleResult="uploadCallBack"></myUpload>
                          </template>                        
                          </el-table-column>
                          <el-table-column   label="内容授权" align="center">
                          <template slot-scope="scope">
                            <myUpload ref="contentAuth" type="contentAuth"       :fList="scope.row.contentAuth"    :itemId="dataId" :idx="scope.row.idx" @handleResult="uploadCallBack"></myUpload>
                          </template>
                          </el-table-column>
                          <el-table-column   label="用户认知" align="center">
                          <template slot-scope="scope">
                            <myUpload ref="userCognition" type="userCognition"   :fList="scope.row.userCognition" :itemId="dataId"  :idx="scope.row.idx" @handleResult="uploadCallBack"></myUpload>
                          </template>                        
                          </el-table-column>
                    </el-table-column>

                    <el-table-column  label="创新性" align="center">
                          <template slot-scope="scope">
                            <myUpload ref="innovation" type="innovation"         :fList="scope.row.innovation"    :itemId="dataId"  :idx="scope.row.idx" @handleResult="uploadCallBack"></myUpload>
                          </template>
                    </el-table-column>
                    <el-table-column  label="用户体验" align="center">
                          <template slot-scope="scope">
                            <myUpload ref="userExperience" type="userExperience" :fList="scope.row.userExperience" :itemId="dataId"  :idx="scope.row.idx" @handleResult="uploadCallBack"></myUpload>
                          </template>                  
                    </el-table-column>
                    <el-table-column  label="资费" align="center">
                          <template slot-scope="scope">
                            <myUpload ref="fee" type="fee" :itemId="dataId"      :fList="scope.row.fee" :idx="scope.row.idx" @handleResult="uploadCallBack"></myUpload>
                          </template>                  
                    </el-table-column>
                    <el-table-column  label="信息安全" align="center">
                        <template slot-scope="scope">
                          <myUpload ref="infoSafety" type="infoSafety"  :fList="scope.row.infoSafety"  :itemId="dataId"  :idx="scope.row.idx" @handleResult="uploadCallBack"></myUpload>
                        </template>
                    </el-table-column>
                  </el-table-column>

            
                  <el-table-column label="是否通过" align="center" width="130px">
                    <template slot-scope="scope">
                      <el-select v-model="scope.row.isPass" @change="(value)=>{setPassValue(value,scope.row.itemId,scope.row.idx)}" placeholder="请选择" size="small">
                        <el-option
                          v-for="item in options"
                          :key="item.value" 
                          :label="item.label"  
                          :value="item.value">
                        </el-option>
                      </el-select>
                    </template>
                  </el-table-column>
              </template> 

                <template v-if="step=='3'">
                  <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" 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>
                </template>
 
 
              <el-table-column label="操作" align="center">
                  <template slot-scope="scope">
                    <el-button type="text" size="small" @click="viewItem(scope.row.itemId,scope.row.idx)">查看</el-button>
                  </template>
              </el-table-column>
      
          </el-table>


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


            <idxDialog :dialogVisible="dialogVisible" :itemId="dataId" :idx="curIdx" @closeWin="closeWin"></idxDialog>

  </div>


</template>

<script>
import {strToHerf} from "@/utils/tv.js"
import audit from "./audit.vue";
import idxDialog from "./idxDialog.vue";
import myUpload from "@/components/uploadNew.vue";
import down from "@/components/uploadNewDown.vue";


export default {
  components:{audit,idxDialog,myUpload,down},
  props: {
    woNo:   { required: false,type: String},
    itemId: { required: false,type: String},
    step:{ required: true, type: String}
  },

  data(){
    return{
      tableData:[],
      loading:false,
      itemName:'',
      dataId:'',
      isPass:"1",
      //
      passValue:'1',
      options: [{value: "1",label: "是"}, { value: "0",label: "否"}],
      dialogVisible:false,
      curIdx:''
    }
  },

  methods:{
    uploadCallBack(v){
      console.log({v})
      if(v.k===1){
        this.$http({
          url: "/market/tvImport/expert/set/quality",
          method: "post",
          headers: {"Content-Type": "application/json"},
          data: {"itemId":v.body.itemId,"idx":v.body.idx,"v":JSON.stringify(v.files),"k":v.type}
        }).then((res) => {
          if(res.data.result!=0){
            this.$message({ showClose: true, message: res.data.desc,type: 'error'});
          }
        });
      }
    },
    closeWin(){
      this.dialogVisible = false;
    },
    //
    viewItem(itemId,idx){
      this.curIdx = idx;
      this.dialogVisible = true;
    },
    //
    filesToUrl(files){
      return strToHerf(files)
    },
    setPassValue(value,itemId,idx){
      this.$http({
        url: "/market/tvImport/setIsPass",
        method: "post",
        headers: {"Content-Type": "application/json"},
        data: {"itemId":itemId,"idx":idx,"isPass":value}
      }).then((res) => {
         if(res.data.result!=0){
           this.$message({ showClose: true, message: '系统异常',type: 'error'});
         }
      });
    },
    //
    loadData(){
      if(this.step==='2'){this.isPass=""}
      if(this.step==='3'){this.isPass="1"}
      this.$http({
        url: "/market/tvImport/queryImport",
        method: "post",
        headers: {"Content-Type": "application/json"},
        data: {"itemId":this.itemId,"woNo":this.woNo,"isPass":this.isPass}
      }).then((res) => {
         if(res.data.result==0){
            this.tableData = res.data.body 
            if(null!=this.tableData && this.tableData.length>0){
              this.itemName = this.tableData[0].itemName;
              this.dataId = this.tableData[0].itemId;
              this.callBack(this.dataId)
            }
         }else{
           this.$message({ showClose: true, message: '系统异常',type: 'error'});
         }
      });
    },
    callBack(dataId){
        this.$emit("callBack",dataId);
    }
  },
  mounted(){
    this.itemId = this.$route.query.itemId
    this.woNo = this.$route.query.woNo
    this.loadData()
  }
}
</script>
