<template>
	<u-popup :show="show" @close="show=false" bgColor="#fff" mode="top">
		<view class="selectPopup">
			<div class="content">

				<u-input v-model="keywords" shape="circle" placeholder="订单编号/商品名称" border="surround">
					<u-icon name="search" slot="prefixIcon" size="22"></u-icon>
				</u-input>
				<u-form labelPosition="left" :model="form" ref="form1" labelWidth="auto" style="margin: 20rpx 0 40rpx;">
					<u-form-item label="客户" prop="userInfo.name" borderBottom ref="item1" @click="btn">
						<u-input v-if="position_name.length==0" disabled disabledColor="#ffffff" placeholder="请选择客户"
							border="none" inputAlign="right">
						</u-input>
						<u-input v-if="position_name.length!=0" disabled disabledColor="#ffffff"
							:placeholder=position_name border="none" inputAlign="right">
						</u-input>
						<u-icon slot="right" name="arrow-right" color="#c0c4cc"></u-icon>
					</u-form-item>

					<u-form-item label="审核状态" prop="userInfo.name" borderBottom ref="item1" @click="show2=true">
						<u-input v-if="depart_name.length==0" disabled disabledColor="#ffffff" placeholder="请选择额度代客下单状态"
							border="none" inputAlign="right">
						</u-input>
						<u-input v-if="depart_name.length!=0" disabled disabledColor="#ffffff" :placeholder=depart_name
							border="none" inputAlign="right">
						</u-input>
						<u-icon slot="right" name="arrow-right" color="#c0c4cc"></u-icon>
					</u-form-item>




					<u-form-item label="下单时间起" prop="userInfo.name" borderBottom ref="item1"
						@click="showStartTimeBtn()">
						<u-input v-if="!start_time" disabled disabledColor="#ffffff" placeholder="请选择下单时间起始时间"
							border="none" inputAlign="right">
						</u-input>
						<u-input v-if="start_time" disabled disabledColor="#ffffff" :placeholder="start_time"
							border="none" inputAlign="right">
						</u-input>
						<u-icon slot="right" name="arrow-right" color="#c0c4cc"></u-icon>
					</u-form-item>



					<u-form-item label="下单时间止" prop="userInfo.name" borderBottom ref="item1" @click="showEndTimeBtn()">
						<u-input v-if="!end_time" disabled disabledColor="#ffffff" placeholder="请选择下单时间截止时间"
							border="none" inputAlign="right">
						</u-input>
						<u-input v-if="end_time" disabled disabledColor="#ffffff" :placeholder="end_time" border="none"
							inputAlign="right">
						</u-input>
						<u-icon slot="right" name="arrow-right" color="#c0c4cc"></u-icon>
					</u-form-item>




					<!-- <u-form-item label="归属地" prop="userInfo.name" borderBottom ref="item1" @click="show4=true">
						<u-input v-if="province_name.length==0" disabled disabledColor="#ffffff" placeholder="请选择归属地" border="none" inputAlign="right">
						</u-input>
						<u-input v-if="province_name.length!=0" disabled disabledColor="#ffffff" :placeholder=province_name border="none" inputAlign="right">
						</u-input>
						<u-icon slot="right" name="arrow-right" color="#c0c4cc"></u-icon>
					</u-form-item> -->
					<u-form-item v-if="false" label="订单状态" prop="userInfo.name" borderBottom ref="item1"
						@click="show3=true">
						<u-input v-if="auth_name.length==0" disabled disabledColor="#ffffff" placeholder="请选择状态"
							border="none" inputAlign="right">
						</u-input>
						<u-input v-if="auth_name.length!=0" disabled disabledColor="#ffffff" :placeholder=auth_name
							border="none" inputAlign="right">
						</u-input>
						<u-icon slot="right" name="arrow-right" color="#c0c4cc"></u-icon>
					</u-form-item>
				</u-form>
				<view class="df aic jcsb anniu" style="font-size: 30rpx;">
					<div>今日订单</div>
					<div>
						<u-switch v-model="value" @change="change"></u-switch>
					</div>
				</view>
			</div>

			<!-- <button @click="childMethod()">点击按钮</button> -->
			<div class="btns">
				<div class="btn1" @click="qingkongsin">清空筛选</div>
				<div class="btn2" @click="childMethod">确定</div>
			</div>
		</view>
		<!-- <image :src="$util.img(`/upload/weapp/user/gou.png`)" v-if="index==isRadio"></image>
		<image :src="$util.img(`/upload/weapp/user/un_gou.png`)" v-else></image> -->
		<u-picker @cancel="show1=false" closeOnClickOverlay @confirm="tment" :show="show1"
			:columns="[radiolist1]"></u-picker>


		<u-picker @cancel="show2=false" closeOnClickOverlay @confirm="tmenttwo" :show="show2"
			:columns="[salesList]"></u-picker>
		<!-- 	<u-overlay :show="show2">
			<view class="connection-type">

				<div v-for="(item,index) in radiolist2" :key="index">
					<div class="arr df aic jcsb" @click="timeone(index)">
						<div class="df aic">
							<text>{{item.label}}</text>
						</div>
						<image v-if="index==indexb" :src="$util.img(`/upload/weapp/user/gou.png`)" mode=""></image>
						<image v-else :src="$util.img(`/upload/weapp/user/un_gou.png`)" mode=""></image>
					</div>

				</div>

				<view class="df Type-confirmation">
					<div class="df aic jcsa btn1" @click="show2 = false">返回</div>
					<div class="df aic jcsa btn2" @click="tmenttwo(indexb)">确定</div>
				</view>
			</view>

		</u-overlay> -->
		<u-overlay :show="show3">
			<view class="connection-type">

				<div v-for="(item,index) in radiolist3" :key="index">
					<div class="arr df aic jcsb" @click="timetwo(index)">
						<div class="df aic">
							<text>{{item.label}}</text>
						</div>
						<image v-if="index==indexc" :src="$util.img(`/upload/weapp/user/gou.png`)" mode=""></image>
						<image v-else :src="$util.img(`/upload/weapp/user/un_gou.png`)" mode=""></image>
					</div>

				</div>

				<view class="df Type-confirmation">
					<div class="df aic jcsa btn1" @click="show3 = false">返回</div>
					<div class="df aic jcsa btn2" @click="tmentsui(indexc)">确定</div>
				</view>
			</view>

		</u-overlay>
		<u-picker @cancel="show4=false" closeOnClickOverlay @confirm="confirm" :show="show4"
			:columns="columns"></u-picker>

		<u-datetime-picker :show="showStartTime" :value="timVal" mode="date" closeOnClickOverlay
			@confirm="start_timeConfirm" @cancel="timeClose" @close="timeClose"></u-datetime-picker>

		<u-datetime-picker :show="showEndTime" :value="timVal" mode="date" closeOnClickOverlay
			@confirm="end_timeConfirm" @cancel="timeClose" @close="timeClose"></u-datetime-picker>
	</u-popup>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: uni.getStorageSync('userInfo'),
				form: {},
				show: false,
				show1: false,
				show2: false,
				show3: false,
				show4: false,
				showStartTime: false,
				showEndTime: false,
				columns: [],
				indexa: 0,
				valueone: false,
				value: false,
				keywords: '',
				depart_id: '',
				auth_level: '',
				position_id: '',
				position_name: '',
				depart_name: '',
				timVal: Number(new Date()),
				start_time: '',
				end_time: '',
				auth_name: '',
				province_id: '',
				province_name: '',
				indexb: 0,
				selock: false,
				indexc: 0,
				suoone: [],
				suotwo: [],
				list: [],
				radiolist1: [],
				one: true,
				two: false,
				salesList: ['待审核', '通过', '已确认'],
				radiolist2: [{
						id: 0,
						label: '待审核'
					},
					{
						id: 1,
						label: '通过'
					},
					{
						id: 2,
						label: '已确认'
					}
				],
				radiolist3: [{
						id: 'all',
						label: '全部'
					},
					{
						id: 'waitpay',
						label: '待付款'
					},
					{
						id: 'waitsend',
						label: '待发货'
					},
					{
						id: 'waitconfirm',
						label: '待收货'
					},
					{
						id: 'waitrate',
						label: '待评价'
					}
				]
			};
		},
		props: {
			fatherMethod: {
				type: Function,
				default: null
			}
		},
		created() {

			this.$api.sendRequest({
				url: '/api/salasman/getMemberPageList',
				data: {
					page_size: 999
				},
				success: (res) => {
					console.log(res, '业务员列表');
					this.suoone = res.data.list
					for (let i = 0; i < res.data.list.length; i++) {
						this.radiolist1.push(res.data.list[i].nickname)
					}
				},
			})
			// this.$api.sendRequest({
			// 	url: '/api/member/getStoreTypeList',
			// 	data: {},
			// 	success: (res) => {
			// 		console.log(res.data, '店铺类型');
			// 		this.suotwo=res.data
			// 		for(let i=0;i<res.data.length;i++){
			// 			this.radiolist2.push({label:res.data[i]})
			// 		}
			// 	},
			// })
			this.$api.sendRequest({
				url: '/api/address/lists',
				data: {
					pid: 0
				},
				success: res => {
					this.list = res.data
					console.log(res.data, '地区');
					let a = []
					for (let i = 0; i < res.data.length; i++) {
						a.push(res.data[i].name)
					}
					this.columns = [a]

				}
			})
		},
		methods: {
			//取消
			qingkongsin() {
				this.show = false
				this.auth_level = ''
				this.position_id = ''
				this.depart_id = ''
				this.keywords = ''
				this.position_name = ''
				this.depart_name = ''
				this.auth_name = ''
				this.province_id = ''
				this.value = false
				this.selock = ''
				this.start_time = ''
				this.end_time = ''
				this.fatherMethod(this.radiolist3[0].id, this.depart_id, this.value ? 1 : 0, this.selock, this.keywords,
					this.two, this.start_time, this.end_time)
			},
			confirm(value) {
				console.log(value.value[0]);
				for (let i = 0; i < this.list.length; i++) {
					if (value.value[0] == this.list[i].name) {
						this.province_id = this.list[i].id
						this.province_name = this.list[i].name
					}
				}
				this.show4 = false
			},
			change(e) {
				console.log('change', e);
			},
			//确定
			childMethod() {
				console.log({
					order_status: this.radiolist3[this.indexc]
						.id, //	是	string	默认全部：all 待付款：waitpay 待发货：waitsend 待收货：waitconfirm 待评价：waitrate
					member_id: this.depart_id, //	否	string	客户id 若不传则获取该业务员或其下级所有业务员的客户订单列表
					is_today: this.value ? 1 : 0, //	否	string	是否为今日订单 1是 0否 默认0
					sales_status: this.selock, //	否	string	默认false(包括非业务员余额下单) 代客下单的情况下 0待审核 1通过 2驳回
					searchText: this.keywords //	否	string	关键字查询 订单编号/规格名称
				});

				this.fatherMethod(this.radiolist3[this.indexc].id, this.depart_id, this.value ? 1 : 0, this.selock, this
					.keywords, this.one,this.start_time, this.end_time)
				this.show = false
				// this.fatherMethod(this.auth_level,this.position_id,this.depart_id,this.keywords);
			},
			tment(e) {
				console.log(e);
				let index = e.indexs[0]
				this.depart_id = this.suoone[index].member_id
				this.position_name = this.suoone[index].nickname
				this.show1 = false
			},
			// tment(indexa) {
			// 	this.depart_id = this.suoone[indexa].member_id
			// 	this.position_name = this.suoone[indexa].username
			// 	this.show1 = false
			// 	// console.log(this.suoone[indexa].id);
			// },
			tmenttwo(e) {
				let index = e.indexs[0]
				console.log(this.radiolist2[index]);
				this.selock = this.radiolist2[index].id
				this.depart_name = this.radiolist2[index].label
				this.show2 = false
			},
			tmentsui(indexa) {
				this.auth_level = this.radiolist3[indexa].id
				this.auth_name = this.radiolist3[indexa].label
				this.show3 = false
				// console.log(this.suotwo[indexa].id);
			},
			start() {
				this.show = true
			},
			btn() {
				this.show1 = true
			},
			time(index) {
				this.indexa = index
			},
			timeone(index) {
				this.indexb = index
			},
			timetwo(index) {
				this.indexc = index
			},
			showStartTimeBtn() {
				this.showStartTime = true;

			},
			showEndTimeBtn() {
				this.showEndTime = true;
			},
			start_timeConfirm(e) {
				this.showStartTime = false
				this.start_time = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
			},
			end_timeConfirm(e) {
				this.showEndTime = false
				this.end_time = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
			},
			timeClose() {
				this.showBirthday = false
			},
		}
	}
</script>

<style lang="scss">
	.anniu {
		margin-top: 20rpx;
	}

	::v-deep {
		.u-transition {}

		/* #ifdef APP */
		.u-popup__content {
			margin-top: 170rpx !important;
		}

		/* #endif */
	}

	.connection-type {

		width: 596rpx;
		height: 1430rpx;
		background: #F8F6F6;
		border-radius: 2rpx;
		position: fixed;
		right: 0;
		bottom: 88rpx;

		.Add-label {
			font-size: 28rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #222222;
			line-height: 44rpx;
			margin: 32rpx 0 0 34rpx;
		}

		.add-name {
			padding: 0 32rpx;
			box-sizing: border-box;
			margin-top: 32rpx;

			div {
				width: 166rpx;
				height: 60rpx;
				background: #FFFFFF;
				border-radius: 12rpx;

				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #585858;
				line-height: 34rpx;

			}

			div:nth-child(2) {
				margin-left: 18rpx;
				margin-right: 18rpx;
			}

			div:nth-child(5) {
				margin: 0 18rpx;
			}

			div:nth-child(n+4) {
				margin-top: 40rpx;
			}
		}

		.arr {
			margin-right: 16rpx;
			margin-bottom: 32rpx;

			margin: 0 32rpx;
			margin-top: 32rpx;

			image {
				width: 40rpx;
				height: 40rpx;
			}

			text {
				font-size: 28rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #222222;
				line-height: 40rpx;
			}

		}

		.Type-confirmation {

			position: fixed;
			bottom: 0;

			.btn1 {
				width: 172rpx;
				height: 88rpx;
				background: #DDDDDD;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #585858;
				line-height: 40rpx;
			}

			.btn2 {
				width: 424rpx;
				height: 88rpx;
				background: #21BBF3;
				font-size: 28rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 40rpx;
			}
		}
	}

	.selectPopup {
		.content {
			padding: 32rpx;
		}

		.btns {
			display: flex;
			align-items: center;

			.btn1 {
				text-align: center;
				line-height: 88rpx;
				min-width: 216rpx;
				height: 88rpx;
				background: #F6F6F6;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #585858;
			}

			.btn2 {
				text-align: center;
				line-height: 88rpx;
				width: 100%;
				height: 88rpx;
				background: #21BBF3;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #fff;
			}
		}



	}
</style>