
<template>
  <basicDetails 
    ref="details"
    :titleText="mainData.enterprisename"
    formPath="projectChange/rival"
    :editData="mainData"  
    :mainAreaData="mainAreaData" 
    :turnPageId="20221018164302" 
    idname="sa_competitorid"
    tags=""
    @pageChange="pageChange"
    @onEditSuccess="queryMainData($route.query.id)">
    <!-- 使用此插槽可不传[tags] -->
    <tagPanl slot="tags" :data="tagObj" ownertable="sa_project" :id="mainData.sa_competitorid" @onSuccess="queryMainData"/>
    <div slot="customOperation">
      <!-- 此区域提供了自定义操作按钮 -->
    </div>
  </basicDetails>
</template>

<script>

export default {
  components:{},
  data () {
    return {
      mainData:{},
      mainAreaData:'',
      enterpriseList:'',
      tagObj:''
    }
  },
  provide () {
    return {
      detailData:() => this.mainData,
      enterpriseList:() => this.enterpriseList,
    }
  },
  methods:{
    async queryMainData (id) {
      const res = await this.$api.requested({
        "id": "20221019105802",
        "version":1,
        "content": {
            "sa_competitorid":this.$route.query.id
        }
      })
      this.mainData = res.data
      console.log(this.mainData);
      this.changeDataStructure()
      this.getEnterprise()
      /* 获取标签数据 */
      this.tagObj = await this.$store.dispatch('queryTagList',{table:'sa_competitor',id:this.mainData.sa_competitorid})
    },
    // 监听切换数据,上一页,下一页
    pageChange (id,rowindex) {
      this.$router.replace({path:'/projectChangeDetail',query:{id:id,rowindex:rowindex}})
      this.queryMainData(id)
    },
    /** 获取公司数据 */
    async getEnterprise () {
      let res = await this.$api.requested({
        "id": 20221021095802,
        "content": {
            "pageNumber": 1,
            "pageSize": 99999,
            "where": {
                "condition": ""
            }
        },
      })
      this.enterpriseList = res.data
    },
    changeDataStructure () {
      this.mainAreaData = [
        {
          label:'企业名称',
          value: this.mainData.enterprisename
        },
        {
          label:'品牌名称',
          value: this.mainData.brandname
        },
        {
          label:'所在行业',
          value:this.mainData.industry
        },
        {
          label:'劣势信息',
          value: this.mainData.inferiority
        },
        {
          label:'优势信息',
          value: this.mainData.advantage
        },
        {
          label:'创建时间',
          value: this.mainData.createdate
        },
        {
          label:'创建人',
          value: this.mainData.createby
        },{
          label:'跟进时间',
          value: this.mainData.followdate
        },{
          label:'跟进人',
          value: this.mainData.followby
        }
      ]
    }
  },
  mounted () {
    this.queryMainData()
  },
  async created () {
    // 验证权限
    this.tool.checkAuth(this.$route.name,'update')?'':this.$router.go(-1)
  },
}

</script>
<style>
</style>