<template>
  <ai-list isTabs>
    <template slot="content">
      <ai-search-bar class="search-bar" bottomBorder>
        <template slot="left">
          <el-button type="primary" icon="iconfont iconAdd" @click="newClient">新建群发</el-button>
        </template>
        <template slot="right">
          <el-input
            v-model="search.name"
            class="search-input"
            size="small"
            @keyup.enter.native="search.current = 1, getList()"
            placeholder="请输入标题或编号"
            clearable
            @clear="search.current = 1, search.name = '', getList()"
            suffix-icon="iconfont iconSearch" />
        </template>
      </ai-search-bar>
      <ai-table
        :tableData="tableData"
        :col-configs="colConfigs"
        :stripe="true"
        :total="total"
        ref="aitableex"
        style="margin-top: 20px;"
        :current.sync="search.current"
        :size.sync="search.size"
        @getList="getList">
        <el-table-column slot="identityNumber" label="群发内容" align="center">
          <template slot-scope="{ row }">
            <el-popover
              placement="right"
              width="400"
              trigger="hover">
              <div>您可以查询到本村(居)的基本情况、小微权力公开情况,并进行留言评价。您自己操作一下看看,是不是很简单?</div>
<!--              <ai-file-list :fileList="fileList" :fileOps="{name: 'name', size: 'fileSizeStr'}"></ai-file-list>-->
              <span style="cursor: pointer;" slot="reference">{{row.identityNumber}}</span>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column slot="options" label="操作" align="center">
          <template slot-scope="{ row }">
            <span class="table-btn" title="提醒发送" @click="remind(row.id)">提醒发送</span>
            <span class="table-btn" title="详情" @click="toDetail(row)">详情</span>
          </template>
        </el-table-column>
      </ai-table>
    </template>
  </ai-list>
</template>

<script>
  export default {
    name: 'TableList',

    props: {
      instance: Function,
      dict: Object,
      permissions:Function
    },

    data () {
      return {
        fileList:[],
        search: {
          current: 1,
          size: 10,
          name: ''
        },
        total: 0,
        colConfigs: [
          { prop: 'name',  label: '群发类型', align: 'center', width: '200' },
          { prop: 'phone', label: '类型', align: 'center' },
          { slot: 'identityNumber', label: '群发内容', align: 'center'},
          { prop: 'registTime', label: '发送时间', align: 'center' },
          { prop: 'recordUser', label: '已发送成员', align: 'center' },
          { prop: 'recordUser', label: '未发送成员', align: 'center' },
          { prop: 'recordUser', label: '已送达成员', align: 'center' },
          { prop: 'recordUser', label: '未送达成员', align: 'center' },
          { slot: 'options', label: '操作', align: 'center' }
        ],
        tableData: [],
      }
    },

    mounted () {
      this.getList()
    },

    methods: {
      toDetail(row){
        this.$emit("change",{
          type:"NewClientMass",
          row:{row,isAdd:false}
        })
      },
      newClient(){
        this.$emit("change",{
          type:"NewClientMass",
          row:{row:"",isAdd:true}
        })
      },

      getList() {
        this.instance.post(`/app/apppetition/list`, null, {
          params: {
            ...this.search,
            status: 1
          }
        }).then(res => {
          if (res.code == 0) {
            this.tableData = res.data.records
            this.total = res.data.total
          }
        })
      },

      remind (id) {

      },

      onAdd () {
        this.$emit('change', {
          type: 'add'
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .table-btn{
    font-size: 14px;
    color: #2266FF;
    cursor: pointer;
    &:nth-child(1){
      margin-right: 16px;
    }
  }
</style>
