<template>
  <template-page
    ref="pageRef"
    :getList="getList"
    :exportList="exportList"
    :columnParsing="columnParsing"
    :optionsEvensGroup="optionsEvensGroup"
    :morePlan="morePlan"
    :operationColumnWidth="160"
    :operation="operation()"
  >
    <Popu v-if="visible">
      <SentEmailRecordsForm :item="item" @handleClose="handleClose" />
    </Popu>
  </template-page>
</template>

<script>
import TemplatePage from '@/components/template/template-page-1.vue'
import import_mixin from '@/components/template/import_mixin.js'
import add_callback_mixin from '@/components/template/add_callback_mixin.js'
import Popu from '@/components/template/popu.vue'
import SentEmailRecordsForm from './sentEmailRecordsForm.vue'
import operation_mixin from '@/components/template/operation_mixin.js'

import { insureListemail, insureListemailExport, insureResend } from '@/api/InsuranceManagement.js'
export default {
  components: { TemplatePage, Popu, SentEmailRecordsForm },
  mixins: [import_mixin, add_callback_mixin, operation_mixin],
  data() {
    return {
      morePlan: [],
      // 事件组合
      optionsEvensGroup: [],
      // 表格属性
      tableAttributes: {},
      // 表格事件
      tableEvents: {},
      recordSelected: [],
      visible: false,
      item: null
    }
  },
  methods: {
    // 列表请求函数
    getList: insureListemail,
    // 导出
    exportList: insureListemailExport,
    // 表格列解析渲染数据更改
    columnParsing(item, defaultData) {
      return defaultData
    },
    operation() {
      return this.operationBtn({
        detail: {
          conditions: ({ row, index, column }) => {
            return true
          },
          click: ({ row, index, column }) => {
            this.item = row
            this.visible = true
          }
        },
        anew: {
          conditions: ({ row, index, column }) => {
            return true
          },
          prompt: '是否确定重新发送？',
          click: ({ row, index, column }) => {
            // insureResend({
            //   emailBatchNo: row.emailBatchNo
            // })
            //   .then(res => {
            //     this.$refs.pageRef.refreshList()
            //     this.$message({
            //       type: 'success',
            //       message: `发送成功!`
            //     })
            //   })
            //   .catch(err => {
            //     console.log(err)
            //   })
          }
        }
      })
    },
    // 关闭新增弹窗
    handleClose() {
      this.visible = false
      this.item = null
    }
  }
}
</script>

<style lang="scss" scoped></style>
