<template>
  <div>
    <basicDetails
        ref="details"
        formPath="commissionDistribution"
        turnPageId="20240117105404"
        idname="sa_hrpayapplyid"
        ownertable="sa_hrpayapply"
        :isBatch="false"
        :delApiId="20240117105504"
        :editData="mainData"
        :mainAreaData="mainAreaData"
        :titleText="mainData.billno"
        @pageChange="pageChange"
        :tabs="['收入明细','详细信息']"
        @onEditSuccess="queryMainData"
        :statusCheck="[{key:'status',value:'发放'}]"
    >
      <div slot="customOperation">
        <toGrant class="inline-16" v-if="tool.checkAuth($route.name,'grant')" @examineSuccess="queryMainData" :status="mainData.status"></toGrant>
      </div>
      <div slot="slot0" class="normal-panel">
        <incomes  :data="mainData" @delSuccess="queryMainData"></incomes>
      </div>
      <div slot="slot1" class="normal-panel">
        <baseInfo  :detailInfo="detailInfo"></baseInfo>
      </div>
    </basicDetails>
  </div>
</template>

<script>
import baseInfo from '@/components/baseInfo/index.vue'
import incomes from './components/income.vue'
import toGrant from './modules/toGrant.vue'
export default {
  name: "index",
  components:{baseInfo,incomes,toGrant},
  data(){
    return {
      mainData:[],
      mainAreaData:[],
      detailInfo:''
    }
  },
  methods:{
    async queryMainData(){
      const res = await this.$api.requested({
        "id": "20240117105304",
        "content": {
          "sa_hrpayapplyid":this.$route.query.id
        }
      })
      this.mainData = res.data
      this.changeDataStructure()
    },
    // 监听切换数据,上一页,下一页
    pageChange (id,rowindex) {
      this.$router.replace({path:'/commissionDistributionDetail',query:{id:id,rowindex:rowindex}})
      this.queryMainData(id)
    },
    changeDataStructure(){
      let that = this
      this.mainAreaData = [
        {
          label:'单号',
          value:this.mainData.billno
        },
        {
          label:'状态',
          value:this.mainData.status,
          style:function () {
            let style = {}
            switch (that.mainData.status) {
              case '新建':
                style = {color:'#333333'}
                break;
              case '发放':
                style = {color:'#52c41a'}
                break;
              default:
                break;
            }
            return style

          }
        },
        {
          label:'创建人',
          value:this.mainData.createby
        },
        {
          label:'创建时间',
          value:this.mainData.createdate
        },
        {
          label:'发放人',
          value:this.mainData.checkby
        },
        {
          label:'发放时间',
          value:this.mainData.checkdate?this.mainData.checkdate:'--'
        },
        {
          label:'金额(元)',
          value:this.mainData.amount?this.tool.formatAmount(this.mainData.amount,2):'--'
        },
        /*{
          label:'备注',
          value:this.mainData.sourcenote !== '' && this.mainData.remarks !== ''?'系统备注:' + this.mainData.sourcenote + ';人工备注:' + this.mainData.remarks : this.mainData.sourcenote !== ''?'系统备注:' + this.mainData.sourcenote :
              this.mainData.remarks !== ''?'人工备注:' + this.mainData.remarks:'--'
        },*/
      ]
      this.detailInfo = {
        baseInfo: [
          {
            label:'单号',
            value:this.mainData.billno
          },
          {
            label:'状态',
            value:this.mainData.status,
            style:function () {
              let style = {}
              switch (that.mainData.status) {
                case '新建':
                  style = {color:'#333333'}
                  break;
                case '发放':
                  style = {color:'#52c41a'}
                  break;
                default:
                  break;
              }
              return style

            }
          },
          {
            label:'备注',
            value:this.mainData.remarks
          },
          /*{
            label:'备注',
            value:this.mainData.sourcenote !== '' && this.mainData.remarks !== ''?'系统备注:' + this.mainData.sourcenote + ';人工备注:' + this.mainData.remarks : this.mainData.sourcenote !== ''?'系统备注:' + this.mainData.sourcenote :
                this.mainData.remarks !== ''?'人工备注:' + this.mainData.remarks:'--'
          },*/
        ],
        systemInfo: [
          {
            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()
  }
}
</script>

<style scoped>

</style>
