<template>
  <div>
    <basicDetails
        ref="details"
        :titleText="mainData.projectname"
        formPath="QuotedPrice"
        :editData="mainData"
        :mainAreaData="mainAreaData"
        turnPageId="20221020165103"
        idname="sa_quotedpriceid"
        :tags="[]"
        :tabs="['详细信息','项目商机','产品设置','联系人','地址管理']"
        @pageChange="pageChange"
        @onEditSuccess="queryMainData($route.query.id)">
      <div slot="tags">
        <!-- 使用此插槽可不传[tags] -->
        <!-- :tabs="['经销商团队','代理区域','营销类别','账户余额']" -->
      </div>
      <div slot="customOperation">
        <!-- 此区域提供了自定义操作按钮 -->

      </div>
      <div slot="slot0" class="container normal-panel">
        <detailed ref="detailed" ></detailed>
      </div>
      <div slot="slot3" class="container normal-panel">
        <contacts  :data="mainData"  v-if="flag"></contacts>
      </div>
      <div slot="slot4" class="container normal-panel">
        <address_manage  :data="mainData"  v-if="flag"></address_manage>
      </div>
    </basicDetails>
  </div>
</template>

<script>
import detailed from './modules/detailed/index'
import contacts from './modules/contacts/list'
import address_manage from './modules/addressManage/list'
export default {
  name: "index",
  data(){
    return {
      mainData:[],
      mainAreaData:[],
      flag:false
    }
  },
  components:{
    detailed,contacts,address_manage
  },
  methods:{
    async queryMainData(id){
      const res = await this.$api.requested({
        "id": 20221020165203,
        "version":1,
        "content": {
          "sa_quotedpriceid":id
        }
      })
      this.mainData = res.data
      this.changeDataStructure()
      this.$refs.detailed.detailedList(this.mainData)
      this.flag = true
    },
    // 监听切换数据,上一页,下一页
    pageChange (id,rowindex) {
      this.flag = false
      this.$router.replace({path:'/quotedPriceDetail',query:{id:id,rowindex:rowindex}})
      this.queryMainData(id)
    },
    changeDataStructure(){
      this.mainAreaData = [
        {
          label:'单号',
          value:this.mainData.billno
        },
        {
          label:'项目编号',
          value:this.mainData.sa_projectid
        },
        {
          label:'项目名称',
          value:this.mainData.projectname
        },
        {
          label:'报价日期',
          value:this.mainData.createdate
        },
        {
          label:'整单折扣',
          value:this.mainData.discountrate
        },
        {
          label:'有效期',
          value:this.mainData.invaliddate
        },
        {
          label:'负责人',
          value:this.mainData.name
        },
        {
          label:'负责人部门',
          value:this.mainData.depname
        },
        {
          label:'备注',
          value:this.mainData.remarks
        },
        {
          label:'状态',
          value:this.mainData.status
        }
      ]
    }
  },
  mounted() {
    console.log(this.$route.query.id)
    this.queryMainData(this.$route.query.id)
  }
}
</script>

<style scoped>

</style>