diff --git a/ruoyi-ui/src/views/content/banner/index.vue b/ruoyi-ui/src/views/content/banner/index.vue
index b100d74..75f5f90 100644
--- a/ruoyi-ui/src/views/content/banner/index.vue
+++ b/ruoyi-ui/src/views/content/banner/index.vue
@@ -277,8 +277,52 @@ export default {
if (this.form.bannerAddr) {
this.form.previewUrl = this.getImageUrlMethod(this.form.bannerAddr);
}
- this.open = true;
- this.title = "修改Banner";
+ // 如果跳转类型为空,通过跳转链接进行判断
+ if (!this.form.jumpType && this.form.jumpUrl) {
+ if (this.form.jumpUrl.startsWith('music:')) {
+ // 音乐类型,解析musicId
+ this.form.jumpType = 'music';
+ this.form.musicId = parseInt(this.form.jumpUrl.replace('music:', ''));
+ } else {
+ // URL类型
+ this.form.jumpType = 'url';
+ }
+ } else if (!this.form.jumpType) {
+ // 如果既没有jumpType也没有jumpUrl,默认为url
+ this.form.jumpType = 'url';
+ }
+
+ // 如果jumpType是music,但musicId未设置,尝试从jumpUrl解析
+ if (this.form.jumpType === 'music' && !this.form.musicId && this.form.jumpUrl) {
+ if (this.form.jumpUrl.startsWith('music:')) {
+ this.form.musicId = parseInt(this.form.jumpUrl.replace('music:', ''));
+ }
+ }
+
+ // 如果是音乐类型,需要加载音乐列表以便回显
+ if (this.form.jumpType === 'music') {
+ this.loadMusicList().then(() => {
+ // 如果musicId存在但不在列表中,尝试加载更多数据
+ if (this.form.musicId && !this.musicList.find(m => m.musicId === this.form.musicId)) {
+ // 尝试加载更多数据
+ return listMusic({
+ pageNum: 1,
+ pageSize: 100,
+ musicType: 'ordinary'
+ }).then(response => {
+ this.musicList = response.rows || [];
+ });
+ }
+ }).then(() => {
+ // 确保音乐列表加载完成后再显示对话框
+ this.open = true;
+ this.title = "修改Banner";
+ });
+ } else {
+ // 非音乐类型,直接显示对话框
+ this.open = true;
+ this.title = "修改Banner";
+ }
});
},
/** 提交按钮 */
@@ -412,13 +456,14 @@ export default {
// 加载音乐列表
loadMusicList() {
this.musicLoading = true;
- listMusic({
+ return listMusic({
pageNum: 1,
pageSize: 50,
musicType: 'ordinary'
}).then(response => {
this.musicList = response.rows || [];
this.musicLoading = false;
+ return response;
}).catch(() => {
this.musicLoading = false;
});
diff --git a/ruoyi-ui/src/views/content/category/index.vue b/ruoyi-ui/src/views/content/category/index.vue
index f7008fe..79544aa 100644
--- a/ruoyi-ui/src/views/content/category/index.vue
+++ b/ruoyi-ui/src/views/content/category/index.vue
@@ -156,13 +156,13 @@
- {{ scope.row.vip === 1 ? 'VIP' : '免费' }}
+ {{ parseInt(scope.row.vip) === 1 ? 'VIP' : '免费' }}
-
- {{ scope.row.shelf === 1 ? '上架' : '下架' }}
+
+ {{ parseInt(scope.row.shelf) === 1 ? '上架' : '下架' }}
@@ -253,7 +253,8 @@ export default {
name: null,
author: null
},
- bindLoading: false
+ bindLoading: false,
+ isRestoringSelection: false // 标志位:是否正在恢复选择状态
};
},
created() {
@@ -438,6 +439,7 @@ export default {
};
this.selectedMusicIds = []; // 重置选中的音乐
this.boundMusicIds = []; // 重置已绑定的音乐ID
+ this.isRestoringSelection = false; // 重置标志位
this.getBoundMusic(row.categoryId); // 先获取已绑定的音乐
this.getMusicList();
this.bindMusicOpen = true;
@@ -451,13 +453,24 @@ export default {
} else if (response.rows && Array.isArray(response.rows)) {
this.boundMusicIds = response.rows.map(item => item.musicId || item.id);
}
+ // 初始化选中列表为已绑定的音乐ID
+ this.selectedMusicIds = [...this.boundMusicIds];
+ // 如果当前页已经加载,需要重新设置选择状态
+ if (this.musicList.length > 0) {
+ this.$nextTick(() => {
+ this.setDefaultSelection();
+ });
+ }
}).catch(() => {
this.boundMusicIds = [];
+ this.selectedMusicIds = [];
});
},
/** 查询音乐列表 */
getMusicList() {
this.musicLoading = true;
+ // 在数据更新前设置标志位,防止数据更新时触发选择变更事件
+ this.isRestoringSelection = true;
listMusic(this.musicQueryParams).then(response => {
this.musicList = response.rows;
this.musicTotal = response.total;
@@ -468,21 +481,47 @@ export default {
});
}).catch(() => {
this.musicLoading = false;
+ this.isRestoringSelection = false;
});
},
- /** 设置默认勾选已绑定的音乐 */
+ /** 设置默认勾选已绑定的音乐和用户选择的音乐 */
setDefaultSelection() {
- if (this.$refs.musicTable && this.boundMusicIds.length > 0) {
- this.musicList.forEach((row, index) => {
- if (this.boundMusicIds.includes(row.musicId)) {
- this.$refs.musicTable.toggleRowSelection(row, true);
+ if (this.$refs.musicTable) {
+ // 标志位已经在 getMusicList 中设置,这里不需要再设置
+ // 清除所有选择,避免重复选择
+ this.$refs.musicTable.clearSelection();
+ // 恢复选择状态
+ this.$nextTick(() => {
+ if (this.selectedMusicIds.length > 0) {
+ this.musicList.forEach((row, index) => {
+ if (this.selectedMusicIds.includes(row.musicId)) {
+ this.$refs.musicTable.toggleRowSelection(row, true);
+ }
+ });
}
+ // 恢复完成后,重置标志位
+ this.isRestoringSelection = false;
});
+ } else {
+ // 如果表格引用不存在,也要重置标志位
+ this.isRestoringSelection = false;
}
},
// 音乐多选框选中数据
handleMusicSelectionChange(selection) {
- this.selectedMusicIds = selection.map(item => item.musicId);
+ // 如果正在恢复选择状态,不处理选择变更
+ if (this.isRestoringSelection) {
+ return;
+ }
+ // 获取当前页面的音乐ID列表
+ const currentPageMusicIds = this.musicList.map(item => item.musicId);
+ // 获取当前页面选中的音乐ID列表
+ const currentPageSelectedIds = selection.map(item => item.musicId);
+
+ // 从完整选择列表中移除当前页面的音乐ID(包括选中和未选中的)
+ this.selectedMusicIds = this.selectedMusicIds.filter(id => !currentPageMusicIds.includes(id));
+ // 将当前页面选中的音乐ID添加到完整选择列表中
+ this.selectedMusicIds = [...this.selectedMusicIds, ...currentPageSelectedIds];
},
/** 提交绑定音乐 */
submitBindMusic() {
diff --git a/ruoyi-ui/src/views/content/recommend/index.vue b/ruoyi-ui/src/views/content/recommend/index.vue
index 24d4c05..d0a947b 100644
--- a/ruoyi-ui/src/views/content/recommend/index.vue
+++ b/ruoyi-ui/src/views/content/recommend/index.vue
@@ -152,13 +152,13 @@
- {{ scope.row.vip === 1 ? 'VIP' : '免费' }}
+ {{ parseInt(scope.row.vip) === 1 ? 'VIP' : '免费' }}
-
- {{ scope.row.shelf === 1 ? '上架' : '下架' }}
+
+ {{ parseInt(scope.row.shelf) === 1 ? '上架' : '下架' }}
@@ -254,7 +254,8 @@ export default {
name: null,
musicType: 'ordinary' // 默认只获取普通音乐
},
- bindLoading: false
+ bindLoading: false,
+ isRestoringSelection: false // 标志位:是否正在恢复选择状态
};
},
created() {
@@ -459,6 +460,7 @@ export default {
this.musicQueryParams.musicType = 'ordinary'; // 只获取普通音乐
this.selectedMusicIds = []; // 重置选中的音乐
this.boundMusicIds = []; // 重置已绑定的音乐ID
+ this.isRestoringSelection = false; // 重置标志位
this.getBoundMusic(row.id); // 先获取已绑定的音乐
this.getMusicList();
this.bindMusicOpen = true;
@@ -472,13 +474,24 @@ export default {
} else if (response.rows && Array.isArray(response.rows)) {
this.boundMusicIds = response.rows.map(item => item.musicId || item.id);
}
+ // 初始化选中列表为已绑定的音乐ID
+ this.selectedMusicIds = [...this.boundMusicIds];
+ // 如果当前页已经加载,需要重新设置选择状态
+ if (this.musicList.length > 0) {
+ this.$nextTick(() => {
+ this.setDefaultSelection();
+ });
+ }
}).catch(() => {
this.boundMusicIds = [];
+ this.selectedMusicIds = [];
});
},
/** 查询音乐列表 */
getMusicList() {
this.musicLoading = true;
+ // 在数据更新前设置标志位,防止数据更新时触发选择变更事件
+ this.isRestoringSelection = true;
listMusic(this.musicQueryParams).then(response => {
this.musicList = response.rows;
this.musicTotal = response.total;
@@ -489,21 +502,47 @@ export default {
});
}).catch(() => {
this.musicLoading = false;
+ this.isRestoringSelection = false;
});
},
- /** 设置默认勾选已绑定的音乐 */
+ /** 设置默认勾选已绑定的音乐和用户选择的音乐 */
setDefaultSelection() {
- if (this.$refs.musicTable && this.boundMusicIds.length > 0) {
- this.musicList.forEach((row, index) => {
- if (this.boundMusicIds.includes(row.musicId)) {
- this.$refs.musicTable.toggleRowSelection(row, true);
+ if (this.$refs.musicTable) {
+ // 标志位已经在 getMusicList 中设置,这里不需要再设置
+ // 清除所有选择,避免重复选择
+ this.$refs.musicTable.clearSelection();
+ // 恢复选择状态
+ this.$nextTick(() => {
+ if (this.selectedMusicIds.length > 0) {
+ this.musicList.forEach((row, index) => {
+ if (this.selectedMusicIds.includes(row.musicId)) {
+ this.$refs.musicTable.toggleRowSelection(row, true);
+ }
+ });
}
+ // 恢复完成后,重置标志位
+ this.isRestoringSelection = false;
});
+ } else {
+ // 如果表格引用不存在,也要重置标志位
+ this.isRestoringSelection = false;
}
},
// 音乐多选框选中数据
handleMusicSelectionChange(selection) {
- this.selectedMusicIds = selection.map(item => item.musicId);
+ // 如果正在恢复选择状态,不处理选择变更
+ if (this.isRestoringSelection) {
+ return;
+ }
+ // 获取当前页面的音乐ID列表
+ const currentPageMusicIds = this.musicList.map(item => item.musicId);
+ // 获取当前页面选中的音乐ID列表
+ const currentPageSelectedIds = selection.map(item => item.musicId);
+
+ // 从完整选择列表中移除当前页面的音乐ID(包括选中和未选中的)
+ this.selectedMusicIds = this.selectedMusicIds.filter(id => !currentPageMusicIds.includes(id));
+ // 将当前页面选中的音乐ID添加到完整选择列表中
+ this.selectedMusicIds = [...this.selectedMusicIds, ...currentPageSelectedIds];
},
/** 提交绑定音乐 */
submitBindMusic() {
diff --git a/ruoyi-ui/src/views/playlist/normal/index.vue b/ruoyi-ui/src/views/playlist/normal/index.vue
index a2f1bb5..a8a9cb9 100644
--- a/ruoyi-ui/src/views/playlist/normal/index.vue
+++ b/ruoyi-ui/src/views/playlist/normal/index.vue
@@ -31,12 +31,6 @@
-
-
-
-
-
-
搜索
重置
@@ -45,7 +39,11 @@
-
+
+
+ {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
+
+
@@ -91,13 +89,6 @@
-
-
-
- {{ scope.row.musicType === 'ordinary' ? '普通歌曲' : '混音歌曲' }}
-
-
-
-
-
-
-
-
-
{
+ this.form = {
+ id: null,
+ musicId: null,
+ name: null,
+ author: null,
+ vip: 2,
+ shelf: 1,
+ imgAddr: null,
+ musicAddr: null,
+ musicType: "ordinary",
+ label: null
+ };
+ this.selectedTags = [];
+ });
},
/** 搜索按钮操作 */
handleQuery() {
@@ -413,6 +397,9 @@ export default {
if (this.form.shelf !== null && this.form.shelf !== undefined) {
this.form.shelf = parseInt(this.form.shelf);
}
+
+ // 确保音乐类型固定为普通歌曲
+ this.form.musicType = 'ordinary';
} else {
this.$modal.msgError("未找到歌曲信息");
return;
@@ -454,6 +441,14 @@ export default {
return;
}
+ // 确保音乐类型固定为普通歌曲
+ this.form.musicType = 'ordinary';
+
+ // 确保上架状态是数字类型
+ if (this.form.shelf !== null && this.form.shelf !== undefined) {
+ this.form.shelf = parseInt(this.form.shelf);
+ }
+
if (this.form.id != null) {
updateNormalSong(this.form).then(response => {
this.$modal.msgSuccess("修改成功");