<template>
	<view>
		<scroll-view scroll-x>
			<view class="tab">
				<view class="item" @click="change_active(index,item)" v-for="(item,index) in fiveFixedCategory"
					:key="index">
					<view class="text" :class="active == index?'active':''">{{item}}</view>
				</view>

			</view>
		</scroll-view>


		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index" v-if="item.data.length > 0">
				<view class="title">
					<view class="text">{{item.title}}</view>
					<view class="tip" v-if="item.count > 0">{{item.count}}</view>
				</view>
				<view class="inner" v-for="(item_2,index_2) in item.data">
					<view class="left">
						<view class="user">
							<image :src="item_2.face" mode="aspectFill"></image>
						</view>
					</view>
					<view class="right">
						<view class="name">{{item_2.optname}}<text>{{item_2.depart}}</text></view>
						<view class="text">
							<view v-html="item_2.str"></view>
						</view>
						<view class="img_box">
							<view class="img" v-for="(item_3,index_3) in item_2.picture" :key="index_3">
								<view class="" v-for="(item_4,index_4) in item_3" :key="index_4">
									<image :src="item_4" mode="aspectFill" @click.stop="img_chakan(item_4)"></image>
								</view>
							</view>
						</view>
						<view class="time">{{item_2.optdt}}</view>
					</view>
				</view>
				<view class="btn">
					<view class="icon">
						<image src="./icon/btn.png" mode=""></image>
					</view>
					<view class="btn_text" @click="go_all_list(item.table,item.title,item.num)">点击查看全部信息</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "t-o-news-tab-2",
		data() {
			return {
				active: 0,
				// 五定表分类
				fiveFixedCategory: [],

				list: []
			};
		},
		mounted() {
			this.get_five_fixed_fiveFixedCategory()
		},
		methods: {
			change_active(index, item) {
				this.active = index
				
				this.get_five_fixed_getRecordDataByCategoryName(item)
			},
			// 记录管理分类
			get_five_fixed_fiveFixedCategory() {
				this.$api.five_fixed_fiveFixedCategory({

				}).then((res) => {
					this.fiveFixedCategory = res.data.content.data

					this.get_five_fixed_getRecordDataByCategoryName(res.data.content.data[0])
				})
			},
			// 获取记录管理列表
			get_five_fixed_getRecordDataByCategoryName(category_name) {
				uni.showLoading({
					mask: true
				})
				this.$api.five_fixed_getRecordDataByCategoryName({
					category_name: category_name
				}).then((res) => {
					uni.hideLoading()
					
					// console.log(res.data.content.data)
					
					this.list = res.data.content.data
				})
			},

			go_all_list(table,title,num) {
				uni.navigateTo({
					url: "../../origanization/news/tab_2/all_list/all_list?table=" + table + "&title=" + title + "&num=" + num
				})
			},
			
			img_chakan(url) {
			
				let data = []
				data[0] = url
				uni.previewImage({
					urls: data
				});
			},
		}
	}
</script>

<style lang="scss">
	.tab {
		display: flex;

		margin-bottom: 20rpx;
		background-color: #FFFFFF;

		box-sizing: border-box;
		padding: 0 20rpx;

		.item {
			background-color: #FFFFFF;

			.text {
				box-sizing: border-box;

				height: 90rpx;
				line-height: 90rpx;

				width: 188rpx;
				text-align: center;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;

				font-size: 30rpx;
				color: #666666;
			}

			.active {
				font-weight: 700;
				color: #000000;
				border-bottom: 4rpx solid #009FE8;
			}

		}
	}

	.list {
		box-sizing: border-box;
		padding: 0 25rpx;

		.item {
			margin-bottom: 20rpx;
			width: 700rpx;
			background-color: #FFFFFF;
			border-radius: 20rpx;

			box-sizing: border-box;
			padding: 0 25rpx;
			
			padding-bottom: 20rpx;
			
			.title {
				display: flex;
				justify-content: center;
				align-items: center;

				.text {
					text-align: center;
					height: 120rpx;
					line-height: 120rpx;
					font-size: 40rpx;
					font-weight: 700;
				}

				.tip {
					margin-left: 10rpx;
					width: 64rpx;
					height: 30rpx;
					color: red;
					text-align: right;
					font-size: 24rpx;

					background-image: url(./icon/new.png);
					background-size: 43rpx 30rpx;
					background-repeat: no-repeat;
				}
			}

			.inner {
				width: 650rpx;
				display: flex;

				.left {
					.user {
						image {
							width: 90rpx;
							height: 90rpx;

							border-radius: 50%;
						}
					}
				}

				.right {
					margin-left: 20rpx;

					width: 600rpx;

					.name {
						margin-top: 5rpx;
						font-size: 32rpx;

						text {
							margin-left: 20rpx;
							font-size: 26rpx;
							color: #3a3a3a;
						}
					}

					.text {
						width: 550rpx;
						margin-top: 10rpx;
						font-size: 28rpx;
					}

					.img_box {
						margin-top: 20rpx;

						width: 550rpx;
						overflow: hidden;

						.img {
							margin-bottom: 10rpx;
							float: left;
							margin-right: 20rpx;

							image {
								width: 170rpx;
								height: 170rpx;

								border-radius: 10rpx;
							}
						}

						.img:nth-child(3n) {
							margin-right: 0;
						}
					}

					.time {
						margin-top: 20rpx;
						font-size: 24rpx;
						color: #999999;
					}

					
				}
			}
			
			.btn {
				margin: 20rpx auto;
				width: 400rpx;
				height: 50rpx;
			
				background-color: #69BBFA;
				border-radius: 50rpx;
			
				display: flex;
				align-items: center;
				justify-content: center;
			
				.icon {
					image {
						width: 23rpx;
						height: 24rpx;
			
						display: block;
					}
				}
			
				.btn_text {
					margin-left: 10rpx;
					font-size: 28rpx;
					color: #FFFFFF;
				}
			}
		}
	}
</style>
