<template>
	<view>
		<cu-custom :isBack="true" :backUrl="'/pages/apps/apps'" bgColor="bg-gradual-blue">
			<block slot="backText">返回</block>
			<block slot="content">抽奖结果</block>
		</cu-custom>
		<view>
			<view class="uni-container">
				<uni-table ref="table" :loading="loading" stripe  emptyText="暂无更多数据" @selection-change="selectionChange">
					<uni-tr >
						<uni-th style="width: 50px;" @filter-change="searchChangeHandle"   field="awardsName" @sort-change="sortChangeHandle"  align="center">序号</uni-th>
						<uni-th @filter-change="searchChangeHandle"   field="awardsName" @sort-change="sortChangeHandle"  align="center">奖项名称</uni-th>
						<uni-th @filter-change="searchChangeHandle"   field="prizeName" @sort-change="sortChangeHandle"  align="center">奖品名称</uni-th>
						<uni-th @filter-change="searchChangeHandle"   field="number"  @sort-change="sortChangeHandle"  align="center">数量</uni-th>
					</uni-tr>
					<uni-tr v-for="(row, index) in dataList" :key="index">
						<uni-td align="center" :style="row.showFlag === '2'?'background-color: bisque;':''">
							<span v-if="row.showFlag === '2'"><b><text class="cuIcon-present text-red"></text></b></span>
							<span v-if="row.showFlag === '1'"><b><text class="cuIcon-peoplefill text-grey"></text></b></span>
							<span v-if="row.showFlag === '0'"><b>{{row.serialNumber}}</b></span>
						</uni-td>
						<uni-td align="center" :style="row.showFlag === '2'?'background-color: bisque;':''">
							<span v-if="row.showFlag === '2'"><b>{{row.awardsName}}</b></span>
							<span v-if="row.showFlag === '1'"><b>{{row.awardsName}}</b></span>
							<span v-if="row.showFlag === '0'">{{row.awardsName}}</span>
						
						</uni-td>
						<uni-td align="center" :style="row.showFlag === '2'?'background-color: bisque;':''">
							<span v-if="row.showFlag === '2'"><b>{{row.prizeName}}</b></span>
							<span v-if="row.showFlag === '1'"><b>{{row.prizeName}}</b></span>
							<span v-if="row.showFlag === '0'">{{row.prizeName}}</span>
						</uni-td>
						<uni-td align="center" :style="row.showFlag === '2'?'background-color: bisque;':''">
							<span v-if="row.showFlag === '2'"><b>{{row.number}}</b></span>
							<span v-if="row.showFlag === '1'"><b>{{row.number}}</b></span>
							<span v-if="row.showFlag === '0'">{{row.number}}</span>
						</uni-td>
					</uni-tr>
				</uni-table>
			</view>
		</view>
		</view>
</template>

<script>
  import uniFab from '@/components/uni-fab/uni-fab.vue';
  import TestMobileService from '@/api/test/luckyDraw/LuckyDrawService'
  export default {
	onShow(option) {
		
	},
	components:{
		uniFab
	},
    data () {
      return {
        searchForm: {},
        dataList: [], // 数据列表
        tablePage: {
          total: 0,
          currentPage: 1,
          pageSize: 10,
          orders: []
        },
        loading: false
      }
    },
    testMobileService: null,
	onLoad(option) {
	  this.testMobileService = new TestMobileService()
		let { eventId } = option
	  this.refreshList(eventId)
	},
    methods: {
	  /*获取数据列表 */
	  refreshList(eventId) {
	    this.loading = true
	    this.testMobileService.pjShowList({
	  	  'current': this.tablePage.currentPage,
	  	  'size': this.tablePage.pageSize,
	  	  'orders': this.tablePage.orders,
	  	  'id': eventId,
	  	  ...this.searchForm
	  	}).then((data) => {
	  	  this.dataList = data.records
	  	  this.tablePage.total = data.total
	  	  this.loading = false
	  	})
	  	
	  },
	  // 排序
	  sortChangeHandle (column) {
	  	this.tablePage.orders = []
	  	if (column.order != null) {
	  	  this.tablePage.orders.push({column: this.$utils.toLine(column.property), asc: column.order === 'ascending'})
	  	}
	  	this.refreshList()
	  },
	// 检索
	  searchChangeHandle (column) {
		this.searchForm[column.property] = column.filter
		this.refreshList()
	  }
    }
  }
</script>

