<template>
  <div>
    <basicDetails
        ref="details"
        :titleText="mainData.brandname"
        formPath="competitor"
        :editData="mainData"
        :mainAreaData="mainAreaData"
        turnPageId="20221018164302"
        idname="sa_competitorid"
        :tags="[]"
        :tabs="['详细信息','项目商机','联系人','地址管理']"
        @pageChange="pageChange"
        @onEditSuccess="queryMainData($route.query.id)">
      <div slot="tags">
        <!-- 使用此插槽可不传[tags] -->
        <!-- :tabs="['经销商团队','代理区域','营销类别','账户余额']" -->
      </div>
      <div slot="customOperation">
        <!-- 此区域提供了自定义操作按钮 -->
        <toVoid :id="$route.query.id" class="inline-16"></toVoid>
      </div>
      <div slot="slot0" >
        <detailed :basic="mainData" v-if="flag"></detailed>
      </div>
      <div slot="slot1" class=" normal-panel">
        <compete_projects :data="mainData" v-if="flag"></compete_projects>
      </div>
<!--      <div slot="slot2" class="container normal-panel">
        <product_Information :data="this.$route.query.id"></product_Information>
      </div>-->
      <div slot="slot2" class=" normal-panel">
        <contacts :data="mainData" v-if="flag"></contacts>
      </div>
      <div slot="slot3" class=" normal-panel">
        <address_manage :data="mainData" v-if="flag"></address_manage>
      </div>
    </basicDetails>
  </div>
</template>

<script>
import toVoid from  './modules/toVoid'
import detailed from './modules/detailedData'
import compete_projects from './modules/competeProjects/list'
/*import product_Information from './modules/productInformation/list'*/
import contacts from './modules/contacts/list'
import address_manage from './modules/addressManage/list'
export default {
  name: "index",
  data(){
    return {
      dialogNullifyVisible:false,
      mainData:[],
      mainAreaData:[],
      flag:false,
    }
  },
  components:{toVoid,detailed,compete_projects,contacts,address_manage},
  methods:{
    async queryMainData(id){
      const res = await this.$api.requested({
        "id": 20221019105802,
        "content": {
          "sa_competitorid":this.$route.query.id

        },
      })
      this.mainData = res.data
      this.$refs['details'].param.content.isExport = false
      this.$refs['details'].param.content.sa_competitorid = [this.mainData.sa_competitorid]
      this.changeDataStructure()
      this.flag = true
    },
    // 监听切换数据,上一页,下一页
    pageChange (id,rowindex) {
      this.flag = false
      this.$router.replace({path:'/competitorDetail',query:{id:id,rowindex:rowindex}})
      this.queryMainData(id)
    },
    changeDataStructure(){
      this.mainAreaData = [
        {
          label:'编号',
          value:this.mainData.sa_competitorid
        },
        {
          label:'品牌名称',
          value:this.mainData.brandname
        },
        {
          label:'企业名称',
          value:this.mainData.enterprisename
        },
        {
          label:'所属行业',
          value:this.mainData.industry
        },
        {
          label:'优势信息',
          value:this.mainData.advantage
        },
        {
          label:'劣势信息',
          value:this.mainData.inferiority
        },
        {
          label:'创建人',
          value:this.mainData.createby
        },
        {
          label:'创建时间',
          value:this.mainData.createdate
        }
      ]
    }
  },
  mounted() {
    this.queryMainData(this.$route.query.id)
  },
  created () {
    // 验证权限
    this.tool.checkAuth(this.$route.name,'update')?'':this.$router.go(-1)
    this.tool.checkAuth(this.$route.name,'toVoid')?'':this.$router.go(-1)
  },
}
</script>

<style scoped>

</style>