<template>
  <div>
    <basicDetails
        ref="details"
        :titleText="mainData.groupname"
        :editData="mainData"
        :mainAreaData="mainAreaData"
        turnPageId="20220922164403"
        delApiId="20220922164503"
        idname="sa_itemgroupid"
        :tabs="['商品明细']"
        @pageChange="pageChange"
        @onEditSuccess="queryMainData($route.query.id)"
        :statusCheck="[{key:'isonsale',value:1}]">
      <div slot="customOperation">
        <Edit class="inline-16" v-if="mainData.isonsale == 0 && tool.checkAuth($route.name,'update')" :data="mainData" @onSuccess="queryMainData"/>
        <shelves class="inline-16" @upSuccess="queryMainData" :data="mainData"></shelves>
      </div>
      <div slot="slot0" >
        <addGroupDetail :disabled="mainData.isonsale" v-if="mainData" :rowData="mainData"/>
      </div>
    </basicDetails>
  </div>
</template>

<script>
import addGroupDetail from './addGroupDetail'
import Up from './up'
import Down from './down'
import shelves from '../components/shelves'
import Edit from './edit'
import saleClass from './saleClass'
export default {
  name: "detail",
  data() {
    return {
      mainData:'',
      mainAreaData:{},
      detailInfo:{},
    }
  },
  components:{
    addGroupDetail,
    Up,
    Down,
    shelves,
    Edit,
    saleClass
  },
  methods:{
    async queryMainData(id) {
      const res = await this.$api.requested({
        "id": "20220923091903",
        "version":1,
        "content": {
          "sa_itemgroupid":this.$route.query.id
        }
      })
      this.mainData = res.data
      console.log(this.mainData);
      
      this.changeDataStructure()
    },
    changeDataStructure() {
      this.mainAreaData = [
        {
          label:'商品组编号',
          value:this.mainData.groupnum
        },
        {
          label:'商品组名',
          value:this.mainData.groupname
        },
        {
          label:'品牌名称',
          value:this.mainData.brandname
        },
        {
          label:'是否上架',
          value:this.mainData.isonsale ? '上架' : '下架'
        },
        /*{
          label:'默认展示产品',
          value:this.mainData.itemname
        },*/
        {
          label:'默认展示产品编码',
          value:this.mainData.itemno
        },
        {
          label:'默认展示产品名称',
          value:this.mainData.itemname
        },
        /*{
          label:'产品类别',
          value:this.mainData.itemclassname
        },*/
      ]
 
    },
    // 监听切换数据,上一页,下一页
    pageChange (id,rowindex) {
      this.flag = false
      this.$router.replace({path:'/productGroupDetail',query:{id:id,rowindex:rowindex}})
      this.queryMainData(id)
    },
  },
  mounted () {
    this.queryMainData(this.$route.query.id)
  },
  created() {
  }
}
</script>

<style scoped>

</style>