<template>
  <div class="container">

    <div class="card">

      <searchForm :keys="['activity']" ref="searchForm"
                  @on-search="handleSearch">
        <el-button type="primary" icon="el-icon-plus" plain size="small" >新增</el-button>
      </searchForm>

      <RxTable
          ref="rxTable"
          @sizeChange="changePageSize"
          @pageChange="changePage"
          :total="listData.total"
          :currentPage="pageInfo.page"
          :pageSize="pageInfo.pageSize"
          :data="listData.list"
          :blank-col="true"
          :loading="loading"
      >
        <el-table-column
            :align="item.align || 'left'"
            :prop="item.prop"

            :label="item.label"
            :key="item.id"
            v-for="(item) in tableHeader"
            :show-overflow-tooltip="true"
            :width="item.width"
            :min-width="item.minWidth"
        >
          <template slot-scope="scope">
            <div v-if="item.prop == 'flag'" style="height: 36px;">
              <el-image fit="fill" :src="scope.row[item.prop]" style="height: 36px;width: 80px;"></el-image>
            </div>

            <div v-else-if="item.prop == 'tvCounts'">
              <el-tag size="small" style="width: 50px;text-align: center;" @click="goTvList(scope.row)">{{scope.row[item.prop]}}</el-tag>
            </div>
            <span v-else>{{ scope.row[item.prop] || scope.row[item.prop] == 0 ? scope.row[item.prop] : '-' }} </span>
          </template>
        </el-table-column>
        <el-table-column label="操作" fixed="right" align="left" width="200">
          <template slot-scope="scope">
            <!--            <el-button type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">查看</el-button>-->
            <el-button type="text" class="btn_text_edit" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑
            </el-button>
            <!--            <el-button type="text" class="btn_text_edit" icon="el-icon-edit" @click="handleEdit(scope.row)">绑定微信-->
            <!--            </el-button>-->

          </template>
        </el-table-column>
      </RxTable>
    </div>

  </div>
</template>

<script>
import searchForm from "@/components/searchForm";
import RxTable from "@/components/RxTable";


export default {
  name: "vote",
  components: {
    searchForm,

    RxTable,
  },
  data() {
    return {

      searchParams: {},
      loading: false,
      dialogVisible: false,
      tableHeader: [
        {
          prop:"sequence",
          label:"序列",
          width: 100
        },
        {
          prop: "title",
          label: "表决主题",
          width: "300"
        },
        {
          prop: "content",
          label: "表决详情",
          width: "300"
        },
        {
          prop: "launchTime",
          label: "开始时间",
          width: "120"
        },

      ],
      listData: {
        list: [],
        total: 0,
      },
      pageInfo: {
        pageNum: 1,
        pageCapacity: 10,
      },
      addVisible: false,
      dialogVisibleUpdate: false,
    }
  },
  methods: {
    handleEdit(row) {

    },
    goTvList(item){
      console.log(item)
    },
    handleDelete(row){
      this.$confirm('确认刪除, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {

      })

    },

    onSubmit() {
      // let form = this.$refs.userForm.getParams();
      // this.$api.addUser(form).then(res => {
      //   this.$message.success("新增成功！");
      //   this.dialogVisible = false;
      //   this.handleSearch();
      // })
    },

    goDeleteSelect() {

    },
    //搜索
    handleSearch() {
      this.pageInfo.pageNum = 1

      let activityId = this.$refs.searchForm.form.activityId;

      this.searchParams = {
          activityId,
      }


      this.votes()
    },


    votes() {
      this.loading = true;


      this.$api.votes(this.searchParams).then(res => {
        this.loading = false;
        this.listData.list = res.content;
      })

    },



    changePageSize() {

    },
    changePage(page) {
      this.pageInfo.page = page
      this.countryList();

    },


    addPay() {
      this.addVisible = true;
    }
  },
  mounted() {
    // this.handleSearch()
  }
}
</script>

<style lang="less" scoped>
.container {
  /*position: relative;*/

  .btnBox {
    margin-left: 20px;
  }
}
</style>
