<template lang="html">
  <div class="channelDeleteVue pop-up">
    <div class="title">
      删除渠道表
      <i class="close" @click="close()"></i>
    </div>
    <div class="main">
      <p>是否确认删除以下{{ checkedChannel.length }}个渠道表？</p>
      <ul>
        <li class="lengthLimit" v-for="n,i in checkedChannel">{{ n.pt }} ({{ n.value }})</li>
      </ul>
    </div>
    <div class="btns">
      <button type="button" class="btn3" @click="submit()">确认</button>
      <button type="button" class="btn3" @click="close()">返回</button>
    </div>
  </div>
</template>

<script>
import { bus, requestDeleteChannel } from '@/vuex/request.js'

export default {
  data () {
    return {
    }
  },
  props: ['checkedChannel'],
  mounted () {
    // 弹框弹出动画
    window.$(() => {
      bus.$emit('pop-up-show', '.channelDeleteVue.pop-up')
    })
  },
  methods: {
    // 关闭弹窗&动画
    close () {
      window.$(() => {
        bus.$emit('pop-up-close', '.channelDeleteVue.pop-up')
        setTimeout(() => {
          window.$('#generationTime').DatePickerClear()
          this.$emit('close')
        }, 500)
      })
    },
    submit () {
      let data = {
        id: this.checkedChannel.map((n, i) => {
          return n.id
        })
      }
      requestDeleteChannel({}, data, (response) => {
        if (response.data) {
          if (response.data.state) {
            bus.$emit('alert', response.data.message)
            this.$emit('update')
            this.$emit('clear-checkbox')
            this.$emit('close')
          } else {
            bus.$emit('alert', response.data.message)
          }
        } else {
          bus.$emit('alert', response + '.')
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.channelDeleteVue{
  width: 500px;
  .main{
    p{
      font-size: 16px;
      margin-bottom: 20px;
    }
    ul{
      padding-left: 20px;
      margin-bottom: 50px;
      max-height: 150px;
      overflow-y: auto;
      li{
        display: list-item;
        list-style-type: circle;
        line-height: 1.5;
        overflow: visible;
        max-width: 400px;
      }
    }
  }
}
</style>
