
<template>
  <basicDetails 
    ref="details"
    :titleText="mainData.billno"
    formPath="productMoneyOdd"
    :editData="mainData"
    :mainAreaData="mainAreaData" 
    :turnPageId="20221024163504" 
    idname="sa_itempriceadjustid"
    @pageChange="pageChange"
    :tabs="['调整单明细']"
    @onEditSuccess="queryMainData($route.query.id)">
    <!-- 使用此插槽可不传[tags] -->
    <div slot="customOperation">
      <!-- 此区域提供了自定义操作按钮 -->
      <Check class="inline-16" v-if="mainData.status == '新建' && tool.checkAuth($route.name,'check')" :rowData="mainData" @checkSuccess="queryMainData"/>
      <delete-btn v-if="tool.checkAuth($route.name,'delete')" :id="$route.query.id" @deleteSuccess="onSuccess" nameId="20221025092904" nameKey="sa_itempriceadjustids"/>
    </div>
    <div slot="slot0" class="container normal-panel">
      <productOddDetail :rowData="mainData"/>
    </div>
  </basicDetails>
</template>

<script>
import productOddDetail from './productOddDetail'
import Check from '../components/check'
import DeleteBtn from '../components/Del'
export default {
  data () {
    return {
      mainData:{},
      mainAreaData:'',
      visible:false,
      isEdit:''
    }
  },
  components:{
    productOddDetail,
    Check,
    DeleteBtn
  },
  provide () {
    return {
      isEdit: () => this.isEdit
    }
  },
  methods:{
    onSuccess(){
      this.$store.dispatch('changeDetailDrawer',false)
      this.visible = false
      this.$emit('onSuccess')
    },
    async queryMainData (id) {
      const res = await this.$api.requested({
        "id": "20221025093404",
        "version":1,
        "content": {
            "sa_itempriceadjustid":this.$route.query.id
        }
      })
      this.mainData = res.data[0]
      this.$refs.details.param.content.isExport = false
      this.isEdit = this.mainData.status == '新建' ? false : true
      console.log(this.isEdit);
      
      this.changeDataStructure()
    },
    // 监听切换数据,上一页,下一页
    pageChange (id,rowindex) {
      this.$router.replace({path:'/productMoneyOddDetail',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:"#000000"}
                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
        },
        {
          label:'备注',
          value: this.mainData.remarks
        },
      ]
    }
  },
  mounted () {
  },
  created () {
    // 验证权限
    // this.tool.checkAuth(this.$route.name,'update')?'':this.$router.go(-1)
    this.queryMainData(this.$route.query.id)
  },
}

</script>
<style>
</style>