<template>
	<view class="collection">
		<u-navbar ref="uNavbar" :border-bottom="false" :back-icon-color="setNav.backColor" :is-back="setNav.isdisPlayNavTitle"
		 :title-size="setNav.size" :title-bold="setNav.bold" :title="setNav.navTitle" :title-color="setNav.color" :background="setNav"></u-navbar>
		<view class="contentMain" v-if="data.length">
			<view  v-for="(item, index) in data" :key="item.id"
			 class="u-swipe-action">
				<view class="item">
					<view class="title">{{item.message_title}}</view>
					<view class="userInfo">
						<view class="user">
							<view class="name">拟稿人：{{item.send_user_name}}</view>
							<view class="name">发文日期：{{item.message_time}}</view>
							<view class="name">流程结束日期：{{item.finish_time == null ? '未结束' : item.finish_time}}</view>
						</view>
						<!-- <view class="status">发文审核中</view> -->
						<view class="statusBtn" @click="approvalProcess(item)">催收文</view>
					</view>
				</view>
			</view>
		</view>
		<view class="no-data" v-else>暂无数据</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				setNav: {
					backgroundColor: '#fff', //背景色
					color: '##343434', //字体颜色
					bold: true,
					size: '36',
					backColor: '##343434',
					isdisPlayNavTitle: true, //是否显示返回按钮
					navTitle: '催收文' //导航标题
				},
				data: [],
				pageNo: 1,
				total: 0,
				userInfo: {}
			}
		},
		onLoad() {
			this.userInfo = JSON.parse(uni.getStorageSync('userInfo') || '{}');
			this.getQueryList()
		},
		computed: {

		},
		onReachBottom() {
			if (this.data.length >= this.total) {
				return
			}
			this.pageNo += 1
			this.getQueryList()
		},
		methods: {
			async getQueryList(message_situation) {
				let res = await this.$u.post(`boman-web-core/p/cs/queryList`, {
					"table": "boman_message",
					"pageNo": this.pageNo,
					"isUi": false,
					"pageSize": 10,
					"orderBy": "create_time desc",
					"fixedData": {
					    "condition": {
					        "message_situation": "1",
					        "send_user_id": this.userInfo.id,
					        "is_del":"N"
					    }
					}
				})
				if (res.data && res.data.rows) {
					res.data.rows = res.data.rows.map(item => {
						return Object.assign({}, item, {
							show: false
						})
					})
					if (this.pageNo == 1) {
						this.data = res.data.rows
						this.total = res.data.total
					} else {
						this.data = this.data.concat(res.data.rows)
					}
				}
			},
			approvalProcess (item) {
				uni.navigateTo({
					url: "/pages/centerView/collection/details?id=" + item.id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.collection {
		height: 100%;
		background: #fff;
		.contentMain {
			padding: 0 20rpx;
			.item {
				background: #fff;
				.title {
					font-size: 28rpx;
					font-weight: bold;
					color: #343434;
					padding: 30rpx 30rpx 0 30rpx;
					white-space: break-word;
					word-break:break-all;
				}

				.userInfo {
					display: flex;
					align-items: flex-end;
					border-bottom: solid 1rpx #DADADA;
					padding: 30rpx;

					.user {
						flex: 1;
						color: #666;
						font-size: 24rpx;

						.name {
							margin-bottom: 10rpx;
						}
					}

					.status {
						color: #009FE8;
						font-size: 26rpx;
						margin-bottom: 4rpx;
					}

					.statusBtn {
						color: #fff;
						font-size: 22rpx;
						margin-bottom: 4rpx;
						background: #61C320;
						padding: 10rpx 20rpx;
						border-radius: 40rpx;
					}
				}
			}
		}

	}
</style>
