<template>
  <div>
  <!--  评估项  -->
    <div>
      <el-table
          :header-cell-style="{background:'#EEEEEE',color:'#333'}"
          style="width: 100%"
          size="mini"
          border
          highlight-current-row
          ref="listItem" :data="listItem" :opwidth="200" :custom="true" @row-click="rowClick"
          >
        <el-table-column
            prop="optionname"
            label="评估项"
            >
        </el-table-column>
        <el-table-column
            prop="remarks"
            label="描述"
            >
        </el-table-column>
        <el-table-column
            prop="score"
            label="独立项分值">
        </el-table-column>
      </el-table>
    </div>
  <!-- 关联对象  -->
    <div style="margin-top: 20px" v-if="flag">
      <el-table
          :header-cell-style="{background:'#EEEEEE',color:'#333'}"
          :data="listObject"
          ref="listObject"
          stripe
          size="mini"
          style="width: 100%"
          border>
        <el-table-column
            v-if="flagObject"
            prop="partiestype"
            label="客户对象">
          <template slot-scope="scope">
            <div v-for="(item,index) in scope" :key="index" >
              {{item.partiestype}}
            </div>
          </template>
        </el-table-column>
        <el-table-column
            v-if="flagStage"
            prop="enterprisename"
            label="项目阶段">
          <template slot-scope="scope">
            <div v-for="(item,index) in scope" :key="index" >
              {{item.stagename}}
            </div>
          </template>
        </el-table-column>
        <el-table-column
            prop="enterprisename"
            label="分值">
          <template slot-scope="scope">
            <div v-for="(item,index) in scope" :key="index">
              {{item.score}}
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>

  </div>
</template>

<script>
export default {
  name: "evaluationItems",
  props:["data"],
  data(){
    return {
      tableHieght:"600px",
      tablecolsItem:[],
      listItem:[],
      listObject:[],
      flag:false,
      flagObject:true,
      flagStage:true,
      total:0,
      currentPage:0,
      act_row:null
    }
  },
  methods:{
    rowClick(row){
      if (this.data.onparties === 0){
        this.flagObject = false
      }else {
        console.log("有对象")
        this.flagObject = true
      }
      if (this.data.onstage === 0){
        this.flagStage = false
      }else {
        console.log("有阶段")
        this.flagStage = true
      }
      if (this.data.onstage === 0 && this.data.onparties === 0){
        this.flag = false
      }else {
        this.flag = true
        this.listObject = row.projtaskmag_optionscore
      }
    },
    setDefault () {
      this.listItem = this.data.projtaskmag_options
      if (this.data.onstage === 0 && this.data.onparties === 0){
        this.listObject = []
      } else {
        this.listObject = this.data.projtaskmag_options[0].projtaskmag_optionscore
        this.rowClick(this.data.projtaskmag_options[0])
      }
      this.$nextTick(()=>{
        this.$refs['listItem'].setCurrentRow(this.listItem[0])
      })
    }
  },
  watch: {
    data (val) {
      this.setDefault()
    }
  },
  mounted () {
    this.setDefault()
  }
}
</script>
<style>
</style>
<style scoped>

</style>