<template>
  <div>
    <basicDetails
        ref="details"
        :titleText="mainData.taskname"
        formPath="projectTask"
        :editData="mainData"
        :mainAreaData="mainAreaData"
        turnPageId="20221128143904"
        :delApiId="20221128144004"
        idname="sa_projtaskmagid"
        ownertable="sa_projtaskmag"
        :tags="[]"
        :tabs="['评估项']"
        @pageChange="pageChange"
        @onEditSuccess="queryMainData($route.query.id)">
      <div slot="tags">
        <!-- 使用此插槽可不传[tags] -->
        <!-- :tabs="['经销商团队','代理区域','营销类别','账户余额']" -->
      </div>
      <div slot="customOperation" >
      </div>
      <div slot="slot0" >
        <evaluationItems :data="mainData" v-if="flag === 1"></evaluationItems>
      </div>
<!--      <div slot="slot1" >
        <associatedObjects :data="mainData" v-if="flag === 1"></associatedObjects>
      </div>-->
    </basicDetails>
  </div>
</template>

<script>
import evaluationItems from './modules/evaluationItems'
import associatedObjects from './modules/associatedObjects'
export default {
  name: "index",
  components:{evaluationItems,associatedObjects},
  data(){
    return {
      mainData:{},
      mainAreaData:{},
      flag: 0
    }
  },
  methods:{
    async queryMainData(id){
      const res = await this.$api.requested({
        "id": 20221128144104,
        "content": {
          "sa_projtaskmagid":this.$route.query.id
        }
      })
      this.mainData = res.data
      console.log(this.mainData,"工作内容")
      this.flag = 1
      this.changeDataStructure()
    },
    changeDataStructure() {
      this.mainAreaData = [
        {
          label:'顺序',
          value:this.mainData.sequence === 0?'0':this.mainData.sequence
        },
        {
          label:'关键任务',
          value:this.mainData.important === 1?'是':'否'
        },
        {
          label:'是否关联客户对象',
          value:this.mainData.onparties === 1?'是':'否'
        },
        {
          label:'是否关联项目阶段',
          value:this.mainData.onstage === 1?'是':'否'
        }
      ]
    },
    // 监听切换数据,上一页,下一页
    pageChange (id,rowindex) {
      console.log(rowindex)
      this.$router.replace({path:'/projectTaskDetail',query:{id:id,rowindex:rowindex}})
      this.queryMainData(id)
    },
  },
  mounted() {
    this.queryMainData(this.$route.query.id)
  },
  created() {

  }
}
</script>

<style scoped>

</style>