<template>
	<view class="container">
		<view class="headerBox">
			<view class="searchBox">
				<icon class="icon-small searchIcon" type="search" size="14"></icon>
				<input type="text" data-code="code" v-model="CodeTitle" class="fway-form-input searchInput" placeholder="请输入编号或者标题搜索" />
				<text class="searchBtn" @tap="onTapSearch">搜索</text>
			</view>
		</view>
		<view class="contentBox">
			<z-paging ref="paging" v-model="listData" @query="onGetOrderList" refresher-update-time-key="list" :auto="false">
				<view class="listInfoBox">
					<view class="listInfo" v-for="(item, index) in listData" :key="index" @tap="onOrderViewTo(item.id)">
						<view class='listCode'>
							<view class="codeTextBox">
								编号：<text class="codeText">{{item.no}}</text>
							</view>
						</view>
						<rich-text :nodes="item.title" class="listTitle"></rich-text>
						<view class="listDetailBox">
							<text class="listArea">{{item.county}}</text>
							<text class="listDate">{{item.handleTime}}</text>
						</view>
					</view>
				</view>
			</z-paging>
		</view>
	</view>
</template>

<script>
	var that;
	export default {
		data() {
			return {
				CodeTitle: '',
				listData: [],
				isReLoad: false,
				industryID: '',
				industryName: '',
				industryData: []
			}
		},
		onLoad(options) {
			that = this;
			that.industryID = decodeURIComponent(options.industryID);
			that.industryName = decodeURIComponent(options.industryName);
			that.$nextTick(function() {
				uni.setNavigationBarTitle({
					title: that.industryName + '线索公示'
				})
				that.$refs.paging.reload()
			})
		},
		methods: {
			onGetOrderList(pageNo, pageSize) {
				that.$admin.reqDirect({
					method: 'GET',
					url: '/api/v1/Snapshot/order/published?Keyword=' + that.CodeTitle + '&IndustryId=' + that.industryID + '&QueryIndex=' + (pageNo - 1) + '&QueryCount=' + pageSize
				}).then(res => {
					if (res && res.length > 0) {
						res.forEach((item, index) => {
							item.handleTime = that.$util.formatTime(new Date(item.handleTime));
						})
						that.$refs.paging.complete(res);
					} else if (res && res.length == 0) {
						that.$refs.paging.complete([]);
					} else {
						that.$util.msg('网络出错！');
						that.$refs.paging.complete(false);
					}
					typeof fun === 'function' && fun();
				}, err => {
					if (!that.isReLoad) {
						that.isReLoad = true;
						that.onGetOrderList(pageNo, pageSize);
					} else {
						that.$util.msg(err);
						that.$refs.paging.complete(false);
					}
				})
			},
			// 点击查询按钮
			onTapSearch() {
				let that = this;
				that.$refs.paging.reload();
			},
			onOrderViewTo(id) {
				uni.navigateTo({
					url: '/pagesBase/Order/View?type=open&id=' + encodeURIComponent(id)
				})
			},
		}
	}
</script>

<style lang="less">
	.container {
		background-color: #f3f3f3;
	}

	.headerBox {
		line-height: 0;
		background-color: #fff;
	}

	.searchBox {
		padding: 20rpx;
		position: relative;
	}

	.searchIcon {
		position: absolute;
		top: 40rpx;
		left: 50rpx;
	}

	.searchInput {
		background-color: #F6F7F8;
		border-radius: 30rpx;
		padding: 10rpx 110rpx 10rpx 80rpx;
		width: calc(100% - 190rpx);
		height: 46rpx;
		line-height: 46rpx;
	}

	.searchBtn {
		position: absolute;
		line-height: 48rpx;
		top: 28rpx;
		right: 28rpx;
		background-color: #E5F7FF;
		color: #3e6ffd;
		font-size: 28rpx;
		padding: 2rpx 20rpx;
		border-radius: 30rpx;
	}

	.contentBox {
		position: relative;
		height: calc(100% - 108rpx);
	}

	.listInfo {
		margin: 20rpx;
		padding: 30rpx 20rpx;
		border-radius: 20rpx;
		background-color: #fff;
	}

	.listCode {
		padding-bottom: 30rpx;
		border-bottom: 2rpx #EEEEEE solid;
	}

	.codeTextBox {
		width: calc(100% - 120rpx);
		display: inline-block;
		font-size: 28rpx;
		color: #666666;
		vertical-align: middle;
	}

	.codeText {
		color: #000006;
	}

	.codeStatus {
		width: calc(120rpx);
		display: inline-block;
		color: #169BD5;
		font-size: 28rpx;
		text-align: right;
		vertical-align: middle;
	}

	.listTitle {
		color: #000405;
		font-size: 32rpx;
		line-height: 46rpx;
		white-space: pre-line;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		/*行向垂直排列*/
		-webkit-line-clamp: 2;
		width: 100%;
		padding-top: 20rpx;
	}

	.listDetailBox {
		color: #666666;
		font-size: 24rpx;
		padding-top: 30rpx;
		display: block;
	}

	.listArea {
		font-size: 24rpx;
		margin-right: 20rpx;
	}

	.listDate {
		font-size: 24rpx;
	}
</style>