<template>
	<view class="pagesCons">
		<!-- 自定义标题 -->
		<u-navbar title-color="#fff" back-icon-size="30" back-icon-color="#fff" :border-bottom="false" :background="background" id="navbar">
			<view class="slot-wrap">
				<view class="left-icon">待办单</view>
				<view class="right-icon">
					<u-icon name="plus-circle" color="#fff" size="32"></u-icon>新增
				</view>
			</view>
		</u-navbar>
		<view class="tab-body">
			    <view>
					<u-tabs-swiper ref="uTabs" :list="tabList" name="dispName" :current="current" @change="tabsChange" :is-scroll="false"
					 swiperWidth="750"></u-tabs-swiper>
				</view>
				<view class="all-filter" v-show="current==2">
					<u-row>
						<text>发起时间</text>
						<view class="filter-icon">
							<u-icon name="arrow-up-fill" color="#888888" size="24"></u-icon>
							<u-icon name="arrow-down-fill" color="#2979ff" size="24"></u-icon>
						</view>
					</u-row>
					<u-row>
						<text>处理时间</text>
						<view class="filter-icon">
							<u-icon name="arrow-up-fill" color="#888888" size="24"></u-icon>
							<u-icon name="arrow-down-fill" color="#888888" size="24"></u-icon>
						</view>
					</u-row>
					<view @click="showSearch=true">
						<text>筛选</text>
						<u-icon name="shaixuan" custom-prefix="xd-icon" size="32" color="#888888"></u-icon>
					</view>
				</view>
				<swiper class="check-list" :current="swiperCurrent" @transition="transition" @change="swiperChange" @animationfinish="animationfinish">
					<swiper-item class="swiper-item" v-for="(tabs, index) in tabList" :key="index">
						<scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
							<view  
							class="check-order-list" 
							v-for="(item,index) in list" 
							:key="item.id"
							@click="viewRow(item)"
							>
								 <view class="check-row">
									 <view class="ellipsis-one">{{item.storeName}}</view>
									 <view class="createDate">{{item.createDate}}</view>
								 </view>
								 <view class="check-row">
									 <view class="ellipsis-one">
										 {{item.clsName}}
									</view>
									 <view class="text-right">
										 <text>{{item.userName}}</text>
									 </view>
									 <view class="icon-xian" >
										 <u-icon name="icon-xian-11" custom-prefix="xd-icon" size="30" color="#888888"></u-icon>
									 </view>
								 </view>
								 <view class="check-row">
									 <view>
										{{item.sourceType}}
									 </view>
									 <view class="text-right">
										 <text class="mark">
										 	抄送
										 </text>
										 <view class="status">{{item.status}}</view>
									 </view>
								 </view>
							 </view>
							 <u-empty :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
							 <view style="padding: 20upx;">
								 <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
							 </view>
						</scroll-view>
					</swiper-item>
				</swiper>
		</view>
		<!-- 待办单查询弹框 -->
		<search-modal :visible="showSearch" @openPicke="openPicker" @refresh="refresh" @close="showSearch=false"></search-modal>
	</view>
</template>

<script>
	import { getBackLogList } from '@/api/backLog.js'
	import { getLookUpDatas, listLookUp } from '@/api/data'
	import searchModal from './searchModal.vue'
	export default {
		components: {
			searchModal
		},
		data() {
			return {
				showSearch: false, // 是否显示搜索弹框
				searchParams: null, // 查询数据参数
				status: 'loadmore',
				noDataText: '暂无数据',
				background: {
					// 渐变色
					backgroundImage: 'linear-gradient(45deg, rgb(85, 170, 255), rgb(21, 102, 223))'
				},
				tabList: [
					  {
						  dispName: '发给我的',
						  typeId: 3
					   },
					  {
					    dispName: '我创建的',
					  	typeId: 1
					  },
					  {
					    dispName: '全部',
					  	typeId: 2
					  },
				  ],
				current: 0,
				swiperCurrent: 0,
				pageNo: 1,
				pageSize: 10,
				list: [
					{
						storeName: '常青二路店',
						createDate: '2020-08-08 16:12:00',
						clsName: '正常营业',
						userName: '张三',
						sourceType: '视频巡店',
						status: '待整改',
						id: 1
					},
					{
						storeName: '常青二路店',
						createDate: '2020-08-08 16:12:00',
						clsName: '正常营业',
						userName: '张三',
						sourceType: '视频巡店',
						status: '待整改',
						id: 2
					},
					{
						storeName: '常青二路店',
						createDate: '2020-08-08 16:12:00',
						clsName: '正常营业',
						userName: '张三',
						sourceType: '视频巡店',
						status: '待整改',
						id: 3
					}
				],
				total: 0,
			}
		},
		onLoad() {
			this.getRow()
		},
		methods:{
			message(title){
				uni.showToast({
					icon:'none',
					title: title
				})
			},
			// tabs通知swiper切换
			tabsChange(index) {
				this.swiperCurrent = index;
				// this.list = []
				// this.status = "loading"
			},
			swiperChange(event){
				console.log(event.detail)
				// this.list = []
				// this.status = "loading"
			},
			// swiper-item左右移动，通知tabs的滑块跟随移动
			transition(e) {
				let dx = e.detail.dx;
				this.$refs.uTabs.setDx(dx);
			},
			// 由于swiper的内部机制问题，快速切换swiper不会触发dx的连续变化，需要在结束时重置状态
			// swiper滑动结束，分别设置tabs和swiper的状态
			animationfinish(e) {
				let current = e.detail.current;
				if(current != this.current){
					this.$refs.uTabs.setFinishCurrent(current);
					this.swiperCurrent = current;
					this.current = current;
					this.getRow()
				}
			},
			// scroll-view到底部加载更多
			onreachBottom() {
				console.log(this.list.length, this.total)
				if(this.list.length < this.total){
					this.pageNo += 1
					this.getRow()
				}else{
					this.status = "nomore"
				}
			},
			// 查询列表
			getRow (pageNo) {
			  let _this = this
			  if (pageNo) {
			    this.pageNo = pageNo
			  }
			  
			  let params = {
			    pageNo: this.pageNo,
			    pageSize: this.pageSize
			  }
			  // this.status = "loading"
			 //  orderQueryLike(params).then(res => {
				// if (res.code == 200 || res.status == 204 || res.status == 200) {
				//   if(_this.pageNo>1){
				// 	  _this.list = _this.list.concat(res.data.list || [])
				//   }else{
				// 	  _this.list = res.data.list || []
				//   }
				//   _this.total = res.data.count || 0
				// } else {
				//   _this.list = []
				//   _this.total = 0
				//   _this.noDataText = res.message
				// }
				// _this.status = "loadmore"
			 //  })
			},
			// 查询刷新
			refresh(params){
				console.log(params,'1111111111')
				this.searchParams = params
				this.getRow(1)
			},
			// 详细页
			viewRow(item){
				// 已完成的
				uni.navigateTo({
					url: "/pages/toDoList/backlogDetail?id="+item.id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	page{
		height: 100%;
	}
	/* 自定义导航栏样式 */
	.slot-wrap {
		display: flex;
		align-items: center;
		/* 如果您想让slot内容占满整个导航栏的宽度 */
		flex: 1;
		/* 如果您想让slot内容与导航栏左右有空隙 */
		padding: 0 30rpx 0 0;
		color: #fff;
		font-size: 28upx;
		.left-icon{
			flex-grow: 1;
			font-size: 32upx;
		}
		.right-icon{
			padding-left:50upx;
		}
		.uni-icons{
			margin-right: 10upx;
		}
	}
	.text-right {
		text-align: right;
	}
	.pagesCons{
		height: 100%;
		display: flex;
		flex-direction: column;
		.tab-body{
			flex: 1;
			display: flex;
			flex-direction: column;
			.check-list{
				flex: 1;
				overflow-y: scroll;
				.swiper-item{
					width: 100%;
					height: 100%;
					overflow: hidden;
					.scroll-view {
						width: 100%;
						height: 100%;
						overflow: auto;
					}
				}
			}
			// 全部筛选
			.all-filter{
				width: 100%;
				height: 100upx;
				display: flex;
				align-items: center;
				justify-content: space-around;
				box-shadow: 1px 1px 3px #EEEEEE;
				.filter-icon{
					display: flex;
					flex-direction: column;
					margin-left: 10upx;
				}
			}
			// 列表样式
			.check-order-list{
				background: #ffffff;
				padding: 10upx 20upx;
				margin: 25upx;
				border-radius: 6upx;
				box-shadow: 1px 1px 3px #EEEEEE;
				.check-row{
					display: flex;
					align-items: center;
					padding: 20upx 10upx;
					font-size: 28upx;
					.icon-xian{
						text-align: right;
						width: 40upx;
					}
					&:first-child{
						border-bottom: 1px dashed #F8F8F8;
						.createDate{
							// color: #666;
							font-size: 26upx;
							margin-left: 10upx;
						}
					}
					&:last-child{
						border-top: 1px dashed #F8F8F8;
					}
					> view{
						&:first-child{
							flex: 1;
						}
					}
					// 抄送标记
					.mark {
						color: #00C1DE;
						padding: 6upx;
						font-size: 24upx;
						border: 1px solid #00C1DE;
						border-radius: 6upx;
						margin-right: 10upx;
					}
					// 状态
					.status {
						display: inline-block;
						width: 150upx;
						color: red;
					}
				}
			}
		}
	}
   
	
</style>
