<template>
  <basicDetails 
    :titleText="mainData.enterprisename"
    formPath="EnterpriseArchives"
    :editData="mainData"
    :mainAreaData="mainAreaData" 
    turnPageId="20220920083901" 
    idname="sys_enterpriseid"
    :tags="[]"
    @pageChange="pageChange"
    @onEditSuccess="queryMainData($route.query.id)">
    <div slot="tags">
      <!-- 使用此插槽可不传[tags] -->
      <!-- :tabs="['经销商团队','代理区域','营销类别','账户余额']" -->
    </div>
    <div slot="customOperation">
      <!-- 此区域提供了自定义操作按钮 -->
    </div>
    <div slot="custom">
      <!-- 自定义内容区域 -->
    </div>
  </basicDetails>
</template>

<script>
import { log } from '@antv/g2plot/lib/utils'
export default {
  data () {
    return {
      mainData:{},
      mainAreaData:[]
    }
  },
  methods:{
    async queryMainData (id) {
      const res = await this.$api.requested({
        "id": 20220920084001,
        "content": {
          "sys_enterpriseid": id
        }
      })
      this.mainData = res.data
      console.log(this.mainData);
      
      this.changeDataStructure()
    },
    pageChange (id,rowindex) {
      this.queryMainData(id)
      this.$router.replace({path:'/EnterpriseArchivesDetail',query:{id:id,rowindex:rowindex}})
    },
    changeDataStructure () {
      this.mainAreaData = [
        {
          label:'企业名称',
          value: this.mainData.enterprisename
        },
        {
          label:'erp编号',
          value: this.mainData.erpagentnum
        },
        {
          label:'免运费金额',
          value: this.mainData.freefreightamount == -1 ? '不免运费' : this.mainData.freefreightamount == 0 ? '免运费' : this.mainData.freefreightamount
        },
        {
          label:'订单可退货天数',
          value: this.mainData.limitreturnday
        },
        {
          label:'是否审核订单可开票',
          value: this.mainData.invoicingpoint == 1 ? '订单审核' : '发货'
        },
        {
          label:'省市县',
          value: `${this.mainData.province}-${this.mainData.city}-${this.mainData.county}`
        },
        {
          label:'详细地址',
          value: this.mainData.address
        },
        {
          label:'企业联系人',
          value: this.mainData.contact
        },
        {
          label:'联系电话',
          value: this.mainData.phonenumber
        },
        {
          label:'税号',
          value: this.mainData.taxno
        },
        {
          label:'是否授权所有营销类别',
          value: this.mainData.saleclassauth ? '否' : '是'
        },
        {
          label:'企业等级',
          value: this.mainData.grade
        },
        /*{
          label:'免运费金额',
          value: this.mainData.freefreightamount
        },
        {
          label:'订单可退货天数',
          value: this.mainData.limitreturnday
        },
        {
          label:'是否订单审核可开票',
          value: this.mainData.invoicingpoint == '1' ? '订单审核' : '发货'
        },*/
        {
          label:'创建人',
          value: this.mainData.createby
        },
        {
          label:'创建时间',
          value: this.mainData.createdate
        },
      ]
    }
  },
  mounted () {
    this.queryMainData(this.$route.query.id)
  }
}

</script>
<style>
</style>