bug
This commit is contained in:
@@ -89,7 +89,7 @@
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
@pagination="handlePagination"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改活动对话框 -->
|
||||
@@ -247,10 +247,38 @@ export default {
|
||||
/** 查询活动列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listActivity(this.queryParams).then(response => {
|
||||
this.activityList = response.rows;
|
||||
this.total = response.total;
|
||||
|
||||
// 清理查询参数,移除空值
|
||||
const cleanParams = {};
|
||||
Object.keys(this.queryParams).forEach(key => {
|
||||
const value = this.queryParams[key];
|
||||
if (value !== null && value !== undefined && value !== '') {
|
||||
cleanParams[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
// 确保分页参数存在
|
||||
cleanParams.pageNum = this.queryParams.pageNum || 1;
|
||||
cleanParams.pageSize = this.queryParams.pageSize || 10;
|
||||
|
||||
console.log('活动搜索参数:', cleanParams);
|
||||
|
||||
listActivity(cleanParams).then(response => {
|
||||
this.activityList = response.rows || [];
|
||||
this.total = response.total || 0;
|
||||
this.loading = false;
|
||||
|
||||
console.log('活动搜索结果:', {
|
||||
total: this.total,
|
||||
count: this.activityList.length,
|
||||
params: cleanParams
|
||||
});
|
||||
}).catch(error => {
|
||||
console.error('获取活动列表失败:', error);
|
||||
this.activityList = [];
|
||||
this.total = 0;
|
||||
this.loading = false;
|
||||
this.$modal.msgError("获取活动列表失败");
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
@@ -276,13 +304,30 @@ export default {
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
console.log('执行搜索,当前查询参数:', this.queryParams);
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
// 手动重置查询参数,确保所有条件都被清空
|
||||
this.queryParams = {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
name: null,
|
||||
status: null,
|
||||
shelf: null
|
||||
};
|
||||
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)
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
@pagination="handlePagination"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改普通歌曲对话框 -->
|
||||
@@ -290,6 +290,20 @@ export default {
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// 计算最大页数
|
||||
maxPage() {
|
||||
return Math.ceil(this.total / this.queryParams.pageSize) || 1;
|
||||
},
|
||||
// 检查是否为第一页
|
||||
isFirstPage() {
|
||||
return this.queryParams.pageNum <= 1;
|
||||
},
|
||||
// 检查是否为最后一页
|
||||
isLastPage() {
|
||||
return this.queryParams.pageNum >= this.maxPage;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getTagOptions();
|
||||
@@ -303,9 +317,25 @@ export default {
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listNormalSong(this.queryParams).then(response => {
|
||||
this.playlistList = response.rows;
|
||||
this.total = response.total;
|
||||
this.playlistList = response.rows || [];
|
||||
this.total = response.total || 0;
|
||||
|
||||
// 简单的边界检查:如果当前页码超出了实际页数,重置到最后一页
|
||||
const maxPage = Math.ceil(this.total / this.queryParams.pageSize) || 1;
|
||||
if (this.queryParams.pageNum > maxPage && this.total > 0) {
|
||||
this.queryParams.pageNum = maxPage;
|
||||
// 重新请求数据
|
||||
this.getList();
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading = false;
|
||||
}).catch(error => {
|
||||
console.error('获取歌曲列表失败:', error);
|
||||
this.playlistList = [];
|
||||
this.total = 0;
|
||||
this.loading = false;
|
||||
this.$modal.msgError("获取歌曲列表失败");
|
||||
});
|
||||
},
|
||||
// 获取标签选项
|
||||
@@ -358,6 +388,12 @@ export default {
|
||||
this.queryParams.musicType = 'ordinary';
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 分页事件处理 */
|
||||
handlePagination(pagination) {
|
||||
this.queryParams.pageNum = pagination.page;
|
||||
this.queryParams.pageSize = pagination.limit;
|
||||
this.getList();
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
|
||||
@@ -48,8 +48,16 @@
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="120" />
|
||||
<el-table-column label="更新时间" align="center" prop="updateTime" width="120" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="160" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="更新时间" align="center" prop="updateTime" width="160" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
@@ -73,7 +81,7 @@
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
@pagination="handlePagination"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改场景音乐对话框 -->
|
||||
@@ -110,6 +118,7 @@
|
||||
<script>
|
||||
import { listScene, getScene, delScene, addScene, updateScene } from "@/api/playlist/scene";
|
||||
import { getImageUrl } from "@/utils/image";
|
||||
import { parseTime } from "@/utils/ruoyi";
|
||||
import request from '@/utils/request';
|
||||
|
||||
export default {
|
||||
@@ -145,7 +154,19 @@ export default {
|
||||
// 表单校验
|
||||
rules: {
|
||||
scene: [
|
||||
{ required: true, message: "场景名称不能为空", trigger: "blur" }
|
||||
{ required: true, message: "场景名称不能为空", trigger: "blur" },
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
if (value && (value.trim() === '' || value !== value.trim())) {
|
||||
callback(new Error('场景名称不能为纯空格或包含首尾空格'));
|
||||
} else if (value && /\s/.test(value)) {
|
||||
callback(new Error('场景名称不能包含空格'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
trigger: "blur"
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
@@ -162,11 +183,33 @@ export default {
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listScene(this.queryParams).then(response => {
|
||||
this.sceneList = response.rows;
|
||||
this.total = response.total;
|
||||
this.sceneList = response.rows || [];
|
||||
this.total = response.total || 0;
|
||||
|
||||
// 简单的边界检查:如果当前页码超出了实际页数,重置到最后一页
|
||||
const maxPage = Math.ceil(this.total / this.queryParams.pageSize) || 1;
|
||||
if (this.queryParams.pageNum > maxPage && this.total > 0) {
|
||||
this.queryParams.pageNum = maxPage;
|
||||
// 重新请求数据
|
||||
this.getList();
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading = false;
|
||||
}).catch(error => {
|
||||
console.error('获取场景音乐列表失败:', error);
|
||||
this.sceneList = [];
|
||||
this.total = 0;
|
||||
this.loading = false;
|
||||
this.$modal.msgError("获取场景音乐列表失败");
|
||||
});
|
||||
},
|
||||
/** 分页事件处理 */
|
||||
handlePagination(pagination) {
|
||||
this.queryParams.pageNum = pagination.page;
|
||||
this.queryParams.pageSize = pagination.limit;
|
||||
this.getList();
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
@@ -218,6 +261,23 @@ export default {
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
// 提交前清理数据,去除首尾空格
|
||||
if (this.form.scene) {
|
||||
this.form.scene = this.form.scene.trim();
|
||||
}
|
||||
|
||||
// 再次验证清理后的数据
|
||||
if (!this.form.scene || this.form.scene === '') {
|
||||
this.$modal.msgError("场景名称不能为空或纯空格");
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否包含空格
|
||||
if (/\s/.test(this.form.scene)) {
|
||||
this.$modal.msgError("场景名称不能包含空格");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.form.id != null) {
|
||||
updateScene(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
@@ -237,7 +297,8 @@ export default {
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$modal.confirm('是否确认删除场景音乐编号为"' + ids + '"的数据项?').then(function() {
|
||||
const sceneName = row.scene || '未知场景';
|
||||
this.$modal.confirm('是否确认删除场景音乐"' + sceneName + '"?').then(function() {
|
||||
return delScene(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
|
||||
Reference in New Issue
Block a user