<template>
	<div>
		<!-- 列表 -->
		<div style="margin-left:10px;display: inline-block">
			<span>姓名：</span>
			<el-input
				style="width: 200px"
				placeholder="请输入姓名"
				v-model="name">
			</el-input>
		</div>
		<div style="margin-left:10px;display: inline-block">
			<span>电话：</span>
			<el-input
				style="width: 200px"
				placeholder="请输入电话"
				v-model="phone">
			</el-input>
		</div>
		<div style="margin-left:10px;display: inline-block;">
			<span>下单开始时间：</span>
			<el-date-picker style="width: 160px;" v-model="startTime" align="right"
							type="datetime" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择开始时间">
			</el-date-picker>&nbsp;&nbsp;&nbsp;
		</div>
		<div style="margin-left:10px;display: inline-block;">
			<span>下单截止时间：</span>
			<el-date-picker style="width: 160px;" v-model="endTime" align="right" type="datetime"
							format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择截止时间">
			</el-date-picker>
		</div>
		<el-button
			style="margin-left: 10px"
			size="mini"
			type="primary"
			icon="document"
			@click="handleSelect"
		>查询
		</el-button>
		<el-button
			style="margin-left: 10px"
			size="mini"
			type="primary"
			icon="document"
			@click="handleClear"
		>重置
		</el-button>
		<el-table v-loading="tableDataLoading" :data="tableData.list">
			<el-table-column
				prop="id"
				label="编号"
			>
			</el-table-column>
			<el-table-column
				prop="userId"
				label="用户ID"
			>
			</el-table-column>
			<el-table-column prop="avatar" label="头像">
				<template slot-scope="scope">
					<img
						v-if="scope.row.avatar && scope.row.avatar != ''"
						:src="scope.row.avatar"
						width="40"
						height="40"
					/>
					<span v-else>暂无图片</span>
				</template>
			</el-table-column>
			<el-table-column
				prop="name"
				label="姓名"
			>
			</el-table-column>
			<el-table-column
				prop="phone"
				label="手机号"
			>
			</el-table-column>
			<el-table-column label="成为角色" prop="blFxyLevel">
				<template slot-scope="scope">
					{{ showDictValue(scope.row.blFxyLevel, levelData) }}
				</template>
			</el-table-column>
			<el-table-column
				prop="money"
				label="门槛费"
			>
			</el-table-column>
			<el-table-column
				prop="tradeNo"
				label="订单号"
			>
			</el-table-column>
			<el-table-column
				prop="payTime"
				label="下单时间"
			>
			</el-table-column>
		</el-table>
		<div style="text-align: center; margin-top: 10px">
			<el-pagination
				@size-change="handleSizeChange"
				@current-change="handleCurrentChange"
				:page-sizes="[10, 20, 30, 40]"
				:page-size="limit"
				:current-page="page"
				layout="total,sizes, prev, pager, next,jumper"
				:total="tableData.totalCount"
			>
			</el-pagination>
		</div>
	</div>
</template>

<script>

export default {
	data() {
		return {
			levelData:[{id:1,value:'一级分销员'},{id:2,value:'二级分销员'}],
			tableDataLoading: false,
			tableData: {},
			name: "",
			phone: "",
			startTime: "",
			endTime: "",
			page: 1,
			limit: 10,
		};
	},
	methods: {
		showDictValue(data, datas){
			const dictItem = datas.find(item => data === item.id);
			return dictItem ? dictItem.value : '';
		},
		// 获取分销员订单列表数据
		handleSelect() {
			this.tableDataLoading = true;
			this.$http({
				url: this.$http.adornUrl("commission/fxyData/findOrderPage"),
				method: "get",
				params: this.$http.adornParams({
					page: this.page,
					limit: this.limit,
					name: this.name,
					phone: this.phone,
					startTime: this.startTime,
					endTime: this.endTime,
				}),
			}).then(({data}) => {
				if (data.code == 0) {
					this.tableData = data.data;
					console.log(this.tableData);
				} else {
					this.$notify({
						title: "提示",
						duration: 1800,
						message: data.msg,
						type: "warning",
					});
				}
				this.tableDataLoading = false;
			});
		},
		// 重置
		handleClear() {
			this.name = "";
			this.phone ="";
			this.startTime = "";
			this.endTime = "";
			this.page = 1;
			this.handleSelect();
		},

		//分页
		handleSizeChange(val) {
			this.limit = val;
			this.handleSelect();
		},

		//翻页
		handleCurrentChange(val) {
			this.page = val;
			this.handleSelect();
		},

		closeUserList(){
			this.handleClear();
		},
	},
	mounted() {
		this.handleSelect();
	},
};
</script>

<style>
.customWidth {
	width: 80% !important;
}
.el-dialog--center {
	text-align: center;
	margin-top: 1vh !important;
}

.el-tooltip__popper {
	width: 200px;
	padding: 10px;
	color: #000 !important;
	box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.4);
	background-color: #fff !important;
}

.adver_main.box a {
	display: flex;
	justify-content: center;
	height: 150px;
	line-height: 150px;
	text-decoration: none;
}

.bannerManin span {
	display: inline-block;
	margin-left: 5px;
}

.bannerManin img {
	width: 48px;
	height: 48px;
	border-radius: 50%;
}

.bannerbtn a {
	flex: 1;
	text-align: center;
	color: #3e8ef7 !important;
	text-decoration: none;
}

.imgs {
	position: relative;
	border-radius: 6px;
	width: 148px;
	height: 148px;
	margin-right: 10px;
	display: inline-block;
}

.dels {
	position: absolute;
	top: 0;
	left: 0;
	display: none;
}

.dels .el-icon-delete {
	line-height: 148px;
	padding-left: 58px;
	font-size: 25px;
	color: #fff;
}

.imgs:hover .dels {
	width: 100%;
	height: 100%;
	background: #000;
	display: block;
	opacity: 0.5;
}

.bqList {
	padding: 4px 14px;
	margin: 4px;
	border: 1px solid #efefef;
	font-size: 12px;
	color: #999;
	border-radius: 4px;
	margin-right: 15px;
}

.delss {
	display: none;
	position: relative;
}

.delss .el-icon-delete {
	position: absolute;
	top: 0;
}

.bqList:hover .delss {
	display: initial;
	opacity: 0.5;
}

.tj {
	padding: 6px !important;
	margin: 4px;
	font-size: 12px;
	border: 1px solid #ccc;
	border-radius: 4px;
}
</style>
