<template>
	<view>


		<view class="my-notice-item-box-tg" v-for="(item,index) in dataList">
			<view class="notice-status">{{item.reportStatusText}}</view>
			<!-- 通告信息 -->
			<view class="notice-main-box">
				<notice-item :dataObj="item"></notice-item>
			</view>
			<!-- 操作按钮 -->
			<view class="opt-button-box">
				<!-- 状态为待审核和已审核的可以关闭 -->
				<view class="opt-item" v-if="tabStatus!='1'" @click="updateStatus(0,item.id)">关闭</view>
				<view class="opt-item" v-if="tabStatus!='1'" @click="editNotice(item)">编辑</view>
				<!-- 状态为已关闭的可以重启 -->
				<!-- <view class="opt-item" v-if="item.approvalStatus=='2'" @click="updateStatus(1,item.id)">重启</view> -->
				<view class="opt-item" @click="goDetail(item.id)">查看详情</view>
				<view class="opt-item" @click="publish(item)">发类似</view>

			</view>
		</view>
	</view>
</template>

<script>
	import noticeItem from '@/pages/components/notice-item.vue'
	import {
		publishTakeDown
	} from '@/api/business/notice.js'
	export default {
		props: {
			dataList: {
				type: Array,
				default: []
			},
			tabStatus: {
				type: String,
				default: '0'
			}
		},
		components: {
			noticeItem
		},
		data() {
			return {

			}
		},
		methods: {
			publish(item) {
				this.$tab.navigateTo('/pages/notice/public-notice?sameId=' + item.id)
			},
			editNotice(item) {
				this.$tab.navigateTo('/pages/notice/public-notice?sameId=' + item.id + '&isEdit=1')
			},
			evaluate() {
				this.$tab.navigateTo('/pages/mine/set/evaluate')
			},
			updateStatus(status, id) {
				let data = {
					publishTakeDown: status,
					noticeId: id
				}
				publishTakeDown(data).then(res => {
					uni.showToast({
						icon: 'none',
						duration: 1000,
						title: '成功'
					});
					uni.$emit('updateList', {
						msg: '页面更新'
					})

				})
			},
			/**
			 * 查看详情
			 * @param {Object} id
			 */
			goDetail(id) {
				this.$emit("goDetail", id)
			}
		}
	}
</script>

<style lang="scss">
	.my-notice-item-box:first-child {
		margin-top: 20rpx;
	}

	.my-notice-item-box-tg {
		width: 100%;
		border-radius: 20rpx;
		padding: 10rpx 20rpx 20rpx 20rpx;
		background-color: white;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		margin-bottom: 20rpx;
		position: relative;

		.notice-status {
			position: absolute;
			right: 0;
			top: 0;
			font-size: 20rpx;
			background-color: #FC1F3E;
			color: white;
			border-radius: 0 20rpx 0 20rpx;
			padding: 7rpx 14rpx;
		}

		.report-title {
			width: 100%;
			display: flex;
			align-items: flex-end;
			justify-content: start;

			.time-text {
				flex: 1;
				display: flex;
				justify-content: flex-end;
				align-items: center;
				font-size: 20rpx;
				color: #929292;
			}

			.status-text {
				width: 200rpx;
				font-size: 32rpx;
				font-weight: bold;
				padding: 5rpx;
			}
		}

		.notice-main-box {
			font-size: 29rpx;
			width: 100%;
			border-radius: 20rpx;
			margin-bottom: 20rpx;
			border-bottom: 1px solid #F4F4F4;
		}

		.opt-button-box {
			width: 100%;
			font-size: 26rpx;
			padding-top: 10rpx;
			display: flex;
			justify-content: flex-end;
			align-items: center;

			.opt-item {
				padding: 10rpx 25rpx;
				margin-left: 20rpx;
				color: #626464;
				background-color: white;
				border: 1rpx solid #C8C8C8;
				border-radius: 40rpx;
			}
		}
	}
</style>