<template>
  <div>
    <list ref="list">
      <template #add>
        <add v-if="tool.checkAuth($route.name,'insert')" @onSuccess="onSuccess"></add>
      </template>
      <template v-slot:detail="scope">
        <el-button type="text" size="small" @click="$store.dispatch('DrawerShowChange',true),$router.push({path:'/projectTarget_edit',query:{id:scope.data.sa_salestargetbillid,type:'onlyread'}})">详 情</el-button>
      </template>
      <template v-slot:edit="scope">
        <el-button :disabled="scope.data.status === '已下达'"  v-if="tool.checkAuth($route.name,'update')" class="inline-16" type="text" size="small" @click="$store.dispatch('DrawerShowChange',true),$router.push({path:'/projectTarget_edit',query:{id:scope.data.sa_salestargetbillid}})">编 辑</el-button>
      </template>
      <template v-slot:issue="scope">
        <onissue :data="scope.data" v-if="tool.checkAuth($route.name,'issue')" @onSuccess="onSuccess"></onissue>
      </template>
      <template v-slot:adjustment="scope">
        <adjustment v-if="tool.checkAuth($route.name,'adjust')" :data="scope.data" @onSuccess="onSuccess"></adjustment>
      </template>
    </list>
    <!--抽屉面板-->
    <el-drawer
      title="我是标题"
      :visible.sync="drawer"
      :with-header="false"
      direction="rtl"
      size="90%"
      append-to-body
      @close="closeDrawer">
      <div class="detail__panel">
        <router-view/>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import {mapGetters} from 'vuex'

import list from './modules/list.vue'
import add from './modules/add.vue'
import onissue from './modules/issue.vue'
import adjustment from './modules/adjustment.vue'

export default {
  data () {
    return {
      drawer:false,
    }
  },
  components:{
    list,
    add,
    onissue,
    adjustment
  },
  watch: {
  $route (val) {
    if (val.path == '/mProjectTarget') {
      this.$refs.list.listData()
    }
  },
  DrawerShow (val) {
    val ? this.drawer = true : this.drawer = false
  }
  },
  computed: {
    ...mapGetters({
      DrawerShow:'DrawerShow'
    })
  },
  methods:{
    closeDrawer () {
      this.$router.push('/mProjectTarget')
      this.$store.dispatch('DrawerShowChange',false)
    },
    onSuccess () {
      this.$refs['list'].listData()
    }
  }
}
</script>
<style>
</style>