MyTripletDayInfo.vue 9.5 KB
Newer Older
1 2 3 4 5
<template>
	<div>
		<el-container>
			<el-main>
				<el-form :inline="true" :model="formInline" class="demo-form-inline">
6
					<!-- <el-form-item>
7 8 9 10
						<el-date-picker v-model="formInline.startDate" type="date" placeholder="选择开始日期" :value-format="'yyyy-MM-dd'"></el-date-picker>
					</el-form-item>
					<el-form-item>
						<el-date-picker v-model="formInline.endDate" type="date" placeholder="选择结束日期" :value-format="'yyyy-MM-dd'"></el-date-picker>
11 12 13 14
					</el-form-item> -->

					<el-date-picker v-model="formInline.tripletDate" type="daterange" align="right" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :value-format="'yyyy-MM-dd'" :picker-options="pickerOptions"></el-date-picker>

15 16 17
					<el-form-item>
						<el-button type="primary" @click="tripletDayInfoPage">查询</el-button>
					</el-form-item>
18 19 20
					<el-form-item>
						<el-button type="primary" @click="prepareReset">重置</el-button>
					</el-form-item>
21
					<el-dialog title="提示" :visible.sync="resetDialogVisible" width="30%">
22 23 24
						<span>确认重置吗?</span>
						<span slot="footer" class="dialog-footer">
							<el-button @click="resetDialogVisible = false">取 消</el-button>
25
							<el-button type="primary" @click.prevent="tripletDayReset()">确 定</el-button>
26 27
						</span>
					</el-dialog>
28 29 30 31 32 33 34 35 36 37 38
				</el-form>
				<el-table border :data="tripletDayInfoList" v-loading="loading">
					<el-table-column prop="id" label="序号" width="100" sortable></el-table-column>
					<el-table-column label="三连时间">
						<template slot-scope="props">
							{{ props.row.tripletDate | dateDayFormat }}
						</template>
					</el-table-column>
					<el-table-column prop="likeNum" label="点赞数量" show-overflow-tooltip></el-table-column>
					<el-table-column prop="collectNum" label="收藏数量" show-overflow-tooltip></el-table-column>
					<el-table-column prop="commentNum" label="评论数量" show-overflow-tooltip></el-table-column>
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

					<el-table-column prop="likeStatusName" label="点赞状态" width="130" show-overflow-tooltip>
						<template slot-scope="scope">
							<el-tag :type="getTagType(scope.row.likeStatusName)">{{ scope.row.likeStatusName }}</el-tag>
						</template>
					</el-table-column>

					<el-table-column prop="collectStatusName" label="收藏状态" width="130" show-overflow-tooltip>
						<template slot-scope="scope">
							<el-tag :type="getTagType(scope.row.collectStatusName)">{{ scope.row.collectStatusName }}</el-tag>
						</template>
					</el-table-column>

					<el-table-column prop="commentStatusName" label="评论状态" width="130" show-overflow-tooltip>
						<template slot-scope="scope">
							<el-tag :type="getTagType(scope.row.commentStatusName)">{{ scope.row.commentStatusName }}</el-tag>
						</template>
					</el-table-column>
57

58
					<el-table-column sortable prop="myAmount" label="红包金额" show-overflow-tooltip></el-table-column>
59
					<el-table-column prop="redPackageCount" label="红包个数" show-overflow-tooltip></el-table-column>
60
				</el-table>
61
				<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[8, 50, 100, 200, 400]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
62 63 64 65 66 67 68 69
			</el-main>
			<el-backtop class="backtop"></el-backtop>
		</el-container>
	</div>
</template>

<script>
import axios from 'axios'
70
import ApiService from '../../api/ApiService'
71
export default {
72
	name: 'MyTripletDayInfo',
73

74 75
	data() {
		return {
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
			pickerOptions: {
				shortcuts: [
					{
						text: '最近一周',
						onClick(picker) {
							const end = new Date()
							const start = new Date()
							start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
							picker.$emit('pick', [start, end])
						},
					},
					{
						text: '最近一个月',
						onClick(picker) {
							const end = new Date()
							const start = new Date()
							start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
							picker.$emit('pick', [start, end])
						},
					},
					{
						text: '最近三个月',
						onClick(picker) {
							const end = new Date()
							const start = new Date()
							start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
							picker.$emit('pick', [start, end])
						},
					},
				],
			},
107
			formInline: {
108
				tripletDate: null,
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
				endDate: null,
			},
			// 用户列表数据
			tripletDayInfoList: [],
			likeStatus: [
				{
					type: -1,
					name: '全部',
				},
				{
					type: 0,
					name: '未处理',
				},
				{ type: 1, name: '已经点过赞' },
				{ type: 2, name: '点赞已满' },
				{ type: 3, name: '取消点赞' },
				{ type: 4, name: '文章状态不能点赞' },
				{ type: 8, name: '其他错误' },
				{ type: 9, name: '点赞成功' },
			],
			collectStatus: [
				{
					type: -1,
					name: '全部',
				},
				{
					type: 0,
					name: '未处理',
				},
				{ type: 1, name: '已经收藏过' },
				{ type: 2, name: '收藏已满' },
				{ type: 3, name: '参数缺失' },
				{ type: 4, name: '收藏夹不存在' },
				{ type: 8, name: '其他错误' },
				{ type: 9, name: '收藏成功' },
			],
145

146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
			commentStatus: [
				{
					type: -1,
					name: '全部',
				},
				{
					type: 0,
					name: '未处理',
				},
				{ type: 1, name: '已经评论过' },
				{ type: 2, name: '评论已满' },
				{ type: 3, name: '禁言' },
				{ type: 4, name: '评论太快' },
				{ type: 5, name: '评论已经到了45条' },
				{ type: 8, name: '其他错误' },
				{ type: 9, name: '评论成功' },
			],
			loading: false,
			resetDialogVisible: false,
			elementui_page_component_key: 0,
			currentPage: Number(localStorage.getItem('csdnTripletDayInfoPage')) || 1,
			pageSize: 9,
			total: 0,
		}
	},
	watch: {
172
		'formInline.tripletDate'(newVal, oldVal) {
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
			if (newVal !== oldVal) {
				this.currentPage = 1
				localStorage.setItem('csdnTripletDayInfoPage', this.currentPage)
				this.tripletDayInfoPage()
			}
		},
		'formInline.endDate'(newVal, oldVal) {
			if (newVal !== oldVal) {
				this.currentPage = 1
				localStorage.setItem('csdnTripletDayInfoPage', this.currentPage)
				this.tripletDayInfoPage()
			}
		},
		// 监听currentPage的变化,将新值保存到localStorage中
		currentPage(newPage) {
			localStorage.setItem('csdnTripletDayInfoPage', newPage.toString())
		},
	},
	created() {
		//获取问题类型的枚举
		this.tripletDayInfoPage()
	},
	mounted() {
		this.currentPage = 1
	},
	methods: {
		prepareReset() {
			this.resetDialogVisible = true
		},
		async tripletDayInfoPage() {
			this.loading = true
204
			const { data: res } = await ApiService.tripletDayInfoPage(this.currentPage, this.pageSize, this.formInline.tripletDate)
205 206
			if (res.code === 200) {
				this.total = res.result.totalElements
207

208 209 210 211 212 213 214
				const likeStatusMap = {}
				this.likeStatus.forEach((option) => {
					likeStatusMap[option.type] = option.name
				})
				res.result.content.forEach((item) => {
					item.likeStatusName = likeStatusMap[item.likeStatus]
				})
215

216 217 218 219 220 221 222
				const collectStatusMap = {}
				this.collectStatus.forEach((option) => {
					collectStatusMap[option.type] = option.name
				})
				res.result.content.forEach((item) => {
					item.collectStatusName = collectStatusMap[item.collectStatus]
				})
223

224 225 226 227 228 229 230
				const commentStatusMap = {}
				this.commentStatus.forEach((option) => {
					commentStatusMap[option.type] = option.name
				})
				res.result.content.forEach((item) => {
					item.commentStatusName = commentStatusMap[item.commentStatus]
				})
231

232 233 234 235
				this.tripletDayInfoList = res.result.content
			}
			this.loading = false
		},
236
		async tripletDayReset() {
237
			this.loading = true
238
			const { data: res } = await ApiService.tripletDayReset()
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
			this.resetDialogVisible = false
			this.tripletDayInfoPage()
			this.loading = false
		},
		refreshPage() {
			//获取问题类型的枚举
			this.tripletDayInfoPage()
			location.reload()
		},
		getTagType(statusName) {
			if (statusName == '未处理') {
				return 'info'
			} else if (statusName == '已经点过赞' || statusName == '已经收藏过' || statusName == '已经评论过') {
				return 'success'
			} else if (statusName == '文章状态不能点赞' || statusName == '收藏已满' || statusName == '收藏夹不存在' || statusName == '评论已满' || statusName == '禁言' || statusName == '评论已经到了45条') {
				return 'danger'
			} else if (statusName == '点赞成功' || statusName == '收藏成功' || statusName == '评论成功') {
				return 'success'
			} else if (statusName == '点赞已满' || statusName == '参数缺失' || statusName == '其他错误' || statusName == '取消点赞' || statusName == '评论太快') {
				return 'warning'
			}
		},
		handleCurrentChange(currentPage) {
			this.currentPage = currentPage
			this.tripletDayInfoPage()
		},
		handleSizeChange(currentSize) {
			this.pageSize = currentSize
			this.tripletDayInfoPage()
		},
	},
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
}
</script>

<style lang="less" scoped>
.el-header {
	background-color: #b3c0d1;
	color: #333;
	line-height: 60px;
}

.el-aside {
	color: #333;
}

.pagination {
	margin-top: 16px;
	text-align: right;
}
.header-button-item {
	margin-right: 15px;
	font-size: 20px;
}

.red-title {
	line-height: 24px;
	font-size: 18px;
	color: red;
}

.backtop {
	position: fixed;
	bottom: 50px;
	right: 50px;
	height: 40px;
	width: 40px;
	line-height: 40px;
	text-align: center;
	border-radius: 20px;
	background-color: #007aff;
	color: #fff;
	cursor: pointer;
	z-index: 999;
}
.custom-textarea {
	width: 100%;
	text-align: left;
}
.backtop:hover {
	background-color: #0050a0;
}
</style>