<template>
	<div class="app-container">
		<el-form :model="queryParams" ref="queryForm" size="small" :inline="true"
			label-width="68px">
			<!-- <el-form-item prop="reportsType" label="日期">
				<el-date-picker style="70%" v-model="value1" value-format="yyyy-MM-dd" type="daterange"
					range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
				</el-date-picker>
			</el-form-item> -->
			<el-form-item>
				<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
				<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
			</el-form-item>
		</el-form>

		<el-table v-loading="loading" :data="coanchorList">
			<el-table-column label="客户编号" align="center" prop="userId" />
			<el-table-column label="客户账号" align="center" prop="userName" />
			<el-table-column label="客户姓名" align="center" prop="nickName" />
			<el-table-column label="邀请码" align="center" prop="invitationCode" />
			<el-table-column label="邀请时间" align="center" prop="createTime" />
		</el-table>

		<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
			@pagination="getList" />
	</div>
</template>

<script>
	import {
		listCoanchor,
		getCoanchor,
		delCoanchor,
		addCoanchor,
		updateCoanchor
	} from "@/api/data/inviteUsers";
	import {
		getConfigKey
	} from "@/api/system/config";

	export default {
		name: "Coanchor",
		dicts: ['anchor_mode', 'propor_tions'],
		data() {
			return {
				value1:[],
				total: 0,
				// 合作主播表格数据
				coanchorList: [],
				// 弹出层标题
				title: "",
				// 是否显示弹出层
				open: false,
				// 查询参数
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					invitationCode:'',
					name: null,
					content: null,
					icon: null,
					ink: null,
					coNum: null,
					seq: null
				},
				// 表单参数
				form: {
					invitationCode: '',
				},
				// 表单校验
				rules: {}
			};
		},
		watch: {
			'$route.query.invitationCode': {
				handler: function(newValue, oldValue) {
					if(this.$route.query.invitationCode){
						this.getList();
					}
				}
			}
		},
		created() {
			this.getList();
		},
		methods: {
			/** 查询合作主播列表 */
			getList() {
				this.queryParams.invitationCode = this.$route.query.invitationCode;
				this.loading = true;
				listCoanchor(this.queryParams).then(response => {
					this.coanchorList = response.rows;
					this.total = response.total;
					this.loading = false;
				});
			},
			/** 搜索按钮操作 */
			handleQuery() {
				this.queryParams.pageNum = 1;
				if(this.value1!=null){
					this.queryParams.beginTime = this.value1[0]
					this.queryParams.endTime = this.value1[1]
				}else{
					this.queryParams.beginTime = ''
					this.queryParams.endTime = ''
				}
				this.getList();
			},
		}
	};
</script>