
<template>
  <basicDetails 
    ref="details"
    :titleText="mainData.enterprisename"
    formPath="Creditbilladj"
    :editData="mainData"
    :mainAreaData="mainAreaData" 
    :turnPageId="20221008155103" 
    idname="sa_creditbillid"
    :tags="[]"
    @pageChange="pageChange"
    delApiId="20221008155403"
    @onEditSuccess="queryMainData($route.query.id)">
    <div slot="tags">
      <!-- 使用此插槽可不传[tags] -->
      <!-- :tabs="['经销商团队','代理区域','营销类别','账户余额']" -->
    </div>
    <div slot="customOperation">
      <el-button class="inline-16" size="mini" @click="checkBuill(mainData)" v-if="mainData.status == '新建'">审 核</el-button>
      <!-- 此区域提供了自定义操作按钮 -->
    </div>
    <!-- <div slot="slot0" class="container normal-panel">
      <el-button size="small" type="primary" @click="createAgentAccount" class="normal-margin">创建经销商主账号</el-button>
      <tableLayout :layout="tablecols" :data="mainData.hrs" :custom="false" height="300px"></tableLayout>
    </div>
    <div slot="slot1" class="container normal-panel">
      <salescope :data="mainData"></salescope>
    </div>
    <div slot="slot2" class="container normal-panel">
      <SaleClass :data="mainData"></SaleClass>
    </div>
    <div slot="slot3" class="container normal-panel">
      <accountMoney :mainData="mainData"></accountMoney>
    </div> -->
  </basicDetails>
</template>

<script>
// import salescope from './modules/salescope/list'
// import SaleClass from './modules/saleclass/index'
// import accountMoney from './modules/accountMoney/index'
export default {
  data () {
    return {
      mainData:{},
      mainAreaData:[],
    }
  },
  components:{
    // salescope,
    // SaleClass,
    // accountMoney
  },
  methods:{
    async queryMainData (id) {
      const res = await this.$api.requested({
        "id": "20221008155203",
        "version":1,
        "content": {
            "sa_creditbillid":this.$route.query.id
        }
      })
      this.mainData = res.data
      this.changeDataStructure()
    },
    // 监听切换数据,上一页,下一页
    pageChange (id,rowindex) {
      this.$router.replace({path:'/creditbilladjDetail',query:{id:id,rowindex:rowindex}})
      this.queryMainData(id)
    },
    /* 审核 */
    async checkBuill(data) {
      if(data.status != '新建') return
      let res = this.$api.requested({
        "id": "20221008155303",
        "version":1,
        "content": {
            "sa_creditbillid":data.sa_creditbillid
        }
      })
      this.tool.showMessage(res,() => {
        this.queryMainData()
      })
    },
    changeDataStructure () {
      this.mainAreaData = [
        {
          label:'额度单号',
          value: this.mainData.billno
        },
        {
          label:'客户名称',
          value: this.mainData.enterprisename
        },
        {
          label:'账户编号',
          value: this.mainData.accountno
        },
        {
          label:'账户类型',
          value: this.mainData.accountname
        },
        {
          label:'信用额度',
          value: this.mainData.creditquota
        },
        {
          label:'状态',
          value: this.mainData.status
        },
        {
          label:'备注',
          value: this.mainData.remarks
        },
        {
          label:'状态',
          value: this.mainData.status
        },
        {
          label:'创建人',
          value: this.mainData.createby
        },
        {
          label:'创建时间',
          value: this.mainData.createdate
        },
        {
          label:'最近修改人',
          value: this.mainData.changeby
        },
        {
          label:'修改时间',
          value: this.mainData.changedate 
        },
        {
          label:'审核人',
          value: this.mainData.checkby
        },
        {
          label:'审核时间',
          value: this.mainData.checkdate
        },
        
      ]
    }
  },
  mounted () {
    this.queryMainData(this.$route.query.id)
  },
  created () {
    // 验证权限
    this.tool.checkAuth(this.$route.name,'update')?'':this.$router.go(-1)
  },
}

</script>
<style>
</style>