diff --git a/ruoyi-ui/src/components/Pagination/index.vue b/ruoyi-ui/src/components/Pagination/index.vue index e876702..d9d6707 100644 --- a/ruoyi-ui/src/components/Pagination/index.vue +++ b/ruoyi-ui/src/components/Pagination/index.vue @@ -65,6 +65,7 @@ export default { return { } }, + computed: { currentPage: { get() { @@ -98,16 +99,6 @@ export default { } }, handleCurrentChange(val) { - // 计算最大页数,进行边界检查 - const maxPage = Math.ceil(this.total / this.pageSize) || 1; - - // 如果请求的页码超出范围,限制在有效范围内 - if (val > maxPage) { - val = maxPage; - } else if (val < 1) { - val = 1; - } - this.$emit('pagination', { page: val, limit: this.pageSize }) if (this.autoScroll) { scrollTo(0, 800) diff --git a/ruoyi-ui/src/views/activity/index.vue b/ruoyi-ui/src/views/activity/index.vue index e529498..be3ea64 100644 --- a/ruoyi-ui/src/views/activity/index.vue +++ b/ruoyi-ui/src/views/activity/index.vue @@ -89,7 +89,7 @@ :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" - @pagination="handlePagination" + @pagination="getList" /> @@ -123,7 +123,9 @@ type="datetime" placeholder="选择开始时间" value-format="yyyy-MM-dd HH:mm:ss" + format="yyyy-MM-dd HH:mm:ss" style="width: 100%" + :clearable="true" /> @@ -132,7 +134,9 @@ type="datetime" placeholder="选择结束时间" value-format="yyyy-MM-dd HH:mm:ss" + format="yyyy-MM-dd HH:mm:ss" style="width: 100%" + :clearable="true" /> @@ -166,10 +170,23 @@ export default { // 验证结束时间必须大于开始时间 const validateEndTime = (rule, value, callback) => { if (value && this.form.startTime) { - if (new Date(value) <= new Date(this.form.startTime)) { - callback(new Error('结束时间必须大于开始时间')); - } else { - callback(); + try { + const startDate = new Date(this.form.startTime); + const endDate = new Date(value); + + // 检查日期是否有效 + if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) { + callback(new Error('时间格式不正确')); + return; + } + + if (endDate <= startDate) { + callback(new Error('结束时间必须大于开始时间')); + } else { + callback(); + } + } catch (error) { + callback(new Error('时间格式不正确')); } } else { callback(); @@ -265,7 +282,7 @@ export default { listActivity(cleanParams).then(response => { this.activityList = response.rows || []; - this.total = response.total || 0; + this.total = parseInt(response.total) || 0; this.loading = false; console.log('活动搜索结果:', { @@ -321,13 +338,7 @@ export default { console.log('重置查询参数:', this.queryParams); this.handleQuery(); }, - /** 分页事件处理 */ - handlePagination(pagination) { - this.queryParams.pageNum = pagination.page; - this.queryParams.pageSize = pagination.limit; - console.log('分页参数变更:', pagination); - this.getList(); - }, + // 多选框选中数据 handleSelectionChange(selection) { this.ids = selection.map(item => item.id) @@ -346,6 +357,34 @@ export default { const id = row.id || this.ids getActivity(id).then(response => { this.form = response.data; + + // 处理时间格式,确保日期选择器能正确显示 + if (this.form.startTime) { + // 如果是时间戳,转换为日期字符串 + if (typeof this.form.startTime === 'number') { + this.form.startTime = new Date(this.form.startTime).toISOString().slice(0, 19).replace('T', ' '); + } else if (typeof this.form.startTime === 'string') { + // 确保时间格式正确 + const date = new Date(this.form.startTime); + if (!isNaN(date.getTime())) { + this.form.startTime = date.toISOString().slice(0, 19).replace('T', ' '); + } + } + } + + if (this.form.endTime) { + // 如果是时间戳,转换为日期字符串 + if (typeof this.form.endTime === 'number') { + this.form.endTime = new Date(this.form.endTime).toISOString().slice(0, 19).replace('T', ' '); + } else if (typeof this.form.endTime === 'string') { + // 确保时间格式正确 + const date = new Date(this.form.endTime); + if (!isNaN(date.getTime())) { + this.form.endTime = date.toISOString().slice(0, 19).replace('T', ' '); + } + } + } + // 确保图片URL正确处理,用于回显 if (this.form.img) { // 如果img不是完整URL,则处理为相对路径 @@ -362,25 +401,55 @@ export default { } } } + + console.log('修改活动数据处理后:', this.form); this.open = true; this.title = "修改活动"; + }).catch(error => { + console.error('获取活动详情失败:', error); + this.$modal.msgError("获取活动详情失败"); }); }, /** 提交按钮 */ submitForm() { this.$refs["form"].validate(valid => { if (valid) { + // 验证时间格式 + if (this.form.startTime) { + const startDate = new Date(this.form.startTime); + if (isNaN(startDate.getTime())) { + this.$modal.msgError("开始时间格式不正确"); + return; + } + } + + if (this.form.endTime) { + const endDate = new Date(this.form.endTime); + if (isNaN(endDate.getTime())) { + this.$modal.msgError("结束时间格式不正确"); + return; + } + } + + console.log('提交活动数据:', this.form); + if (this.form.id != null) { updateActivity(this.form).then(response => { this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); + }).catch(error => { + console.error('修改活动失败:', error); + this.$modal.msgError("修改失败,请重试"); }); } else { addActivity(this.form).then(response => { this.$modal.msgSuccess("新增成功"); this.open = false; this.getList(); + }).catch(error => { + console.error('新增活动失败:', error); + this.$modal.msgError("新增失败,请重试"); }); } } @@ -389,7 +458,8 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const ids = row.id || this.ids; - this.$modal.confirm('是否确认删除活动编号为"' + ids + '"的数据项?').then(function() { + const activityName = row.name || '选中的活动'; + this.$modal.confirm('是否确认删除活动"' + activityName + '"?').then(function() { return delActivity(ids); }).then(() => { this.getList(); diff --git a/ruoyi-ui/src/views/consult/index.vue b/ruoyi-ui/src/views/consult/index.vue index 32b825f..c102604 100644 --- a/ruoyi-ui/src/views/consult/index.vue +++ b/ruoyi-ui/src/views/consult/index.vue @@ -193,7 +193,7 @@ export default { this.loading = true listInfo(this.queryParams).then(response => { this.infoList = response.rows - this.total = response.total + this.total = parseInt(response.total) || 0 this.loading = false }) }, diff --git a/ruoyi-ui/src/views/content/banner/index.vue b/ruoyi-ui/src/views/content/banner/index.vue index 1062426..4d07c92 100644 --- a/ruoyi-ui/src/views/content/banner/index.vue +++ b/ruoyi-ui/src/views/content/banner/index.vue @@ -174,7 +174,7 @@ export default { this.loading = true; listBanner(this.queryParams).then(response => { this.bannerList = response.rows; - this.total = response.total; + this.total = parseInt(response.total) || 0; this.loading = false; }); }, diff --git a/ruoyi-ui/src/views/content/category/index.vue b/ruoyi-ui/src/views/content/category/index.vue index 7e3cbc2..49b4709 100644 --- a/ruoyi-ui/src/views/content/category/index.vue +++ b/ruoyi-ui/src/views/content/category/index.vue @@ -199,7 +199,7 @@ :total="musicTotal" :page.sync="musicQueryParams.pageNum" :limit.sync="musicQueryParams.pageSize" - @pagination="handleMusicPagination" + @pagination="getMusicList" />