<template>
	<div class="app-container">
		<el-form :model="queryParams" ref="queryForm" size="small" :inline="true"
			label-width="68px">
			<el-form-item label="主播名称" prop="coanchorName">
				<el-input v-model="queryParams.coanchorName" placeholder="请输入主播名称" clearable @keyup.enter.native="handleQuery" />
			</el-form-item>
			<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-item label="" prop="coanchorName">
				<span>总金额： <span style="color: red;">{{totalPrice}}</span></span>
			</el-form-item>
		</el-form>

		<el-table v-loading="loading" :data="coanchorList" @selection-change="handleSelectionChange">
			<el-table-column type="selection" width="55" align="center" />
			<el-table-column label="主播" align="center" prop="coanchorName" />
			<el-table-column label="商品编号" align="center" prop="goodsId" />
			<el-table-column label="客户编号" align="center" prop="userId" />
			<el-table-column label="客户账号" align="center" prop="userName" />
			<el-table-column label="订单编号" align="center" prop="paymentId" />
			<el-table-column label="销售金额" align="center" prop="salesPrice" />
			<el-table-column label="到手金额" align="center" prop="paidinPrice" />
			<el-table-column label="邀请码" align="center" prop="invitationCode" />
			<el-table-column label="分红比例" align="center" prop="proportions">
				<template slot-scope="scope">
					<dict-tag :options="dict.type.propor_tions" :value="scope.row.proportions" />
				</template>
			</el-table-column>
			<el-table-column label="分红金额" align="center" prop="proportionsPrice" />
			<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/anchorDividends";
	import {
		getConfigKey
	} from "@/api/system/config";

	export default {
		name: "Coanchor",
		dicts: ['anchor_mode', 'propor_tions'],
		data() {
			return {
				totalPrice:'',
				value1:[],
				total: 0,
				// 合作主播表格数据
				coanchorList: [],
				// 弹出层标题
				title: "",
				// 是否显示弹出层
				open: false,
				// 查询参数
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					name: null,
					content: null,
					icon: null,
					ink: null,
					coNum: null,
					seq: null
				},
				// 表单参数
				form: {
					invitationCode: '',
				},
				// 表单校验
				rules: {}
			};
		},
		created() {
			this.getList();
		},
		methods: {
			/** 查询合作主播列表 */
			getList() {
				this.loading = true;
				listCoanchor(this.queryParams).then(response => {
					this.totalPrice=response.data.sum.proportionsPrice;
					this.coanchorList = response.data.table.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();
			},
			// 多选框选中数据
			handleSelectionChange(selection) {
				this.ids = selection.map(item => item.id)
				this.single = selection.length !== 1
				this.multiple = !selection.length
			},
		}
	};
</script>