<template lang="html">
  <div class="checkInfoDeleteVue pop-up">
    <div class="title">
      删除信息
      <i class="close" @click="close()"></i>
    </div>
    <div class="main">
      <p>是否确认删除以下{{ checkedMessage.length }}条信息？</p>
      <ul>
        <li class="lengthLimit" :title="n.errorMsg" v-for="n,i in checkedMessage">{{ n.templateName }} ({{ n.errorMsg }})</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, requestDeleteMsg } from '@/vuex/request.js'

export default {
  data () {
    return {
    }
  },
  props: ['checkedMessage', 'ptSelectedData'],
  mounted () {
    // 弹框弹出动画
    window.$(() => {
      bus.$emit('pop-up-show', '.checkInfoDeleteVue.pop-up')
    })
  },
  methods: {
    // 关闭弹窗&动画
    close () {
      window.$(() => {
        bus.$emit('pop-up-close', '.checkInfoDeleteVue.pop-up')
        setTimeout(() => {
          window.$('#generationTime').DatePickerClear()
          this.$emit('close')
        }, 500)
      })
    },
    submit () {
      let data = {
        messageId: this.checkedMessage.map((n, i) => {
          return n.messageId
        }),
        pt: this.ptSelectedData.pt
      }
      requestDeleteMsg({}, 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>
.checkInfoDeleteVue{
  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>
