<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" :data="mainData" @onSuccess="queryMainData" :disabled="mainData.isonsale"/>
        <shelves class="inline-16" @upSuccess="queryMainData" :data="mainData"></shelves>
<!--        <el-popover placement="bottom" style="20px">
          <Up type="one" @upSuccess="queryMainData" ":id="[mainData.sa_itemgroupid] v-if="mainData.isonsale == 0 && tool.checkAuth($route.name,'up_sales')"></Up>
          <Down type="one" @downSuccess="queryMainData" :id="[mainData.sa_itemgroupid]" v-if="mainData.isonsale == 1 && tool.checkAuth($route.name,'down_sales')"></Down>
          <el-button size="mini" slot="reference" icon="el-icon-more"></el-button>
        </el-popover>-->
      </div>
      <div slot="slot0" class="container normal-panel">
        <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'
export default {
  name: "detail",
  data() {
    return {
      mainData:'',
      mainAreaData:{},
      detailInfo:{},
    }
  },
  components:{
    addGroupDetail,
    Up,
    Down,
    shelves,
    Edit
  },
  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.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>