<template>
  <div>
    <list ref="list" @selectData="selectData">
      <BtnGroup
        v-if="tool.checkAuth($route.name,'update')" 
        :rows="selectRow" 
        slot="operation"
        @checkProducts="checkProducts" 
        @cancel="cancel" 
        @onSuccess="onSuccess">
      </BtnGroup>
      <add v-if="tool.checkAuth($route.name,'insert')" slot="add" @onSuccess="onSuccess"></add>
      <template v-slot:setclass="scope">
        <saleClass :data="scope.data" @uploadSuccess="onSuccess"></saleClass>
      </template>
      <template v-slot:setimage="scope">
        <SetImage :data="scope.data" @uploadSuccess="onSuccess"></SetImage>
      </template>
      <template v-slot:onsale="scope">
        <onsale v-if="tool.checkAuth($route.name,'update')"  :data="scope.data" @onSuccess="onSuccess"></onsale>
      </template>
      <template v-slot:edit="scope">
        <edit v-if="tool.checkAuth($route.name,'update')"  :data="scope.data" @onSuccess="onSuccess"></edit>
      </template>
      <template v-slot:del="scope">
        <ondel v-if="tool.checkAuth($route.name,'delete')"  :data="scope.data" @onSuccess="onSuccess"></ondel>
      </template>
    </list>
  </div>
</template>

<script>
import add from './modules/add'
import edit from './modules/edit'
import ondel from './modules/del'
import onsale from './modules/onsale'
import BtnGroup from './modules/BtnGroup'
import SetImage from './modules/SetImage'

import list from './modules/list'
import saleClass from './modules/saleClass'

export default {
  components:{
    list,
    add,
    edit,
    ondel,
    onsale,
    BtnGroup,
    SetImage,
    saleClass
  },
  data () {
    return {
      selectRow:[]
    }
  },
  methods:{
    onSuccess () {
      this.$refs['list'].listData()
    },
    checkProducts (type) {
       this.$refs['list'].selection(type)
    },
    selectData (data) {
      this.selectRow = data
    },
    cancel () {
      this.$refs['list'].clearSelection()
    }
  }
}

</script>
<style>
</style>
<style scoped>
</style>