MyTripletDayInfo.vue 5.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<template>
	<div>
		<el-container>
			<el-main>
				<el-form :inline="true" :model="formInline" class="demo-form-inline">
					<el-form-item>
						<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>
					</el-form-item>
					<el-form-item>
						<el-button type="primary" @click="tripletDayInfoPage">查询</el-button>
					</el-form-item>
15 16 17
					<el-form-item>
						<el-button type="primary" @click="prepareReset">重置</el-button>
					</el-form-item>
18
					<el-dialog title="提示" :visible.sync="resetDialogVisible" width="30%">
19 20 21 22 23 24
						<span>确认重置吗?</span>
						<span slot="footer" class="dialog-footer">
							<el-button @click="resetDialogVisible = false">取 消</el-button>
							<el-button type="primary" @click.prevent="reset()">确 定</el-button>
						</span>
					</el-dialog>
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
				</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>
					<el-table-column label="创建时间">
						<template slot-scope="props">
							{{ props.row.createTime | dateFormat }}
						</template>
					</el-table-column>
					<el-table-column label="更新时间">
						<template slot-scope="props">
							{{ props.row.updateTime | dateFormat }}
						</template>
					</el-table-column>
				</el-table>
				<el-pagination class="pagination" background :key="elementui_page_component_key" :current-page.sync="currentPage" :page-size="pageSize" :total="total" @current-change="handleCurrentChange"></el-pagination>
			</el-main>
			<el-backtop class="backtop"></el-backtop>
		</el-container>
	</div>
</template>

<script>
import axios from 'axios'
export default {
57
	name: 'MyTripletDayInfo',
58

59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 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 107 108 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
	data() {
		return {
			formInline: {
				startDate: null,
				endDate: null,
			},
			// 用户列表数据
			tripletDayInfoList: [],
			loading: false,
			resetDialogVisible: false,
			elementui_page_component_key: 0,
			currentPage: Number(localStorage.getItem('csdnTripletDayInfoPage')) || 1,
			pageSize: 9,
			total: 0,
		}
	},
	watch: {
		'formInline.startDate'(newVal, oldVal) {
			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
			const { data: res } = await axios.post('http://120.79.36.53:8888/dayInfo/page', {
				page: this.currentPage,
				pageSize: this.pageSize,
				startDate: this.formInline.startDate,
				endDate: this.formInline.endDate,
			})
			if (res.code === 200) {
				this.total = res.result.totalElements
				this.tripletDayInfoList = res.result.content
			}
			this.loading = false
		},
		async reset() {
			this.loading = true
			const { data: res } = await axios.get('http://120.79.36.53:8888/dayInfo/add')
			this.resetDialogVisible = false
			this.tripletDayInfoPage()
			this.loading = false
		},
		handleCurrentChange(currentPage) {
			this.currentPage = currentPage
			this.tripletDayInfoPage()
		},
		refreshPage() {
			//获取问题类型的枚举
			this.tripletDayInfoPage()
			location.reload()
		},
	},
137 138 139 140 141 142 143 144 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 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
}
</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>