|
@@ -953,28 +953,6 @@ export default {
|
|
|
this.getList();
|
|
|
},
|
|
|
methods: {
|
|
|
- searchProjects() {
|
|
|
- // 实现项目搜索逻辑
|
|
|
- if (this.projectQueryParams.title) {
|
|
|
- // 这里应该调用项目搜索API
|
|
|
- console.log('搜索项目:', this.projectQueryParams.title);
|
|
|
- }
|
|
|
- },
|
|
|
- /** 过滤分类节点 */
|
|
|
- filterNode(value, data) {
|
|
|
- if (!value) return true;
|
|
|
- return data.cateName.indexOf(value) !== -1;
|
|
|
- },
|
|
|
- /** 处理项目选择 */
|
|
|
- handleProjectSelect(selection, row) {
|
|
|
- this.selectedProjectIds = selection.map(item => item.id);
|
|
|
- console.log('选中的项目:', this.selectedProjectIds);
|
|
|
- },
|
|
|
- /** 处理分类点击 */
|
|
|
- handleCategoryClick(data) {
|
|
|
- this.projectQueryParams.cateId = data.cateId;
|
|
|
- this.searchProjects();
|
|
|
- },
|
|
|
/** 将数字索引转换为字母序号 (0->A, 1->B, 等) */
|
|
|
convertToLetter(index) {
|
|
|
// 确保索引是数字
|
|
@@ -1190,23 +1168,7 @@ export default {
|
|
|
this.videoPreviewVisible = true;
|
|
|
this.videoPreviewUrl = url || this.form.videoUrl;
|
|
|
},
|
|
|
- handleCloseVideoPreview(done) {
|
|
|
- this.videoPreviewVisible = false;
|
|
|
- if (done) {
|
|
|
- done();
|
|
|
- }
|
|
|
- },
|
|
|
- cancelSelectProject() {
|
|
|
- this.projectDialogVisible = false;
|
|
|
- this.selectedProjectIds = [];
|
|
|
- this.projectList = [];
|
|
|
- this.projectQueryParams = {
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 10,
|
|
|
- title: null,
|
|
|
- cateId: null
|
|
|
- };
|
|
|
- },
|
|
|
+
|
|
|
/** 格式化视频时长 */
|
|
|
formatDuration(seconds) {
|
|
|
if (!seconds) return '00:00';
|
|
@@ -1830,6 +1792,243 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+
|
|
|
+ /** 复制视频链接到剪贴板 */
|
|
|
+ copy(url) {
|
|
|
+ // 创建一个临时的input元素
|
|
|
+ const input = document.createElement('input');
|
|
|
+ // 设置input的值为要复制的视频链接
|
|
|
+ input.value = url;
|
|
|
+ // 将input添加到DOM中
|
|
|
+ document.body.appendChild(input);
|
|
|
+ // 选中input的值
|
|
|
+ input.select();
|
|
|
+ // 执行复制命令
|
|
|
+ document.execCommand('copy');
|
|
|
+ // 从DOM中移除input元素
|
|
|
+ document.body.removeChild(input);
|
|
|
+ // 提示用户复制成功
|
|
|
+ this.$message({
|
|
|
+ message: '已复制到剪贴板',
|
|
|
+ type: 'success',
|
|
|
+ duration: 1500
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getProjectList() {
|
|
|
+ this.projectLoading = true
|
|
|
+ listCourseQuestionBank(this.projectQueryParams).then(response => {
|
|
|
+ this.projectList = response.rows;
|
|
|
+ this.projectListTotal = response.total;
|
|
|
+
|
|
|
+ // 如果存在已选择的项目,预选中表格中对应的行
|
|
|
+ this.$nextTick(() => {
|
|
|
+ // 获取表格组件实例
|
|
|
+ const projectTable = this.$refs.projectTable;
|
|
|
+ if (projectTable) {
|
|
|
+ if (this.selectedProjectIds.length > 0) {
|
|
|
+ // 遍历项目列表,找到匹配的ID并选中对应行
|
|
|
+ const selectedIds = this.selectedProjectIds;
|
|
|
+ this.projectList.forEach(row => {
|
|
|
+ if (selectedIds.includes(row.id)) {
|
|
|
+ projectTable.toggleRowSelection(row, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.projectLoading = false
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 打开项目选择弹窗 */
|
|
|
+ openProjectDialog(projectIds, type) {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.$refs.customSelect) {
|
|
|
+ this.$refs.customSelect.blur();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 重置查询参数
|
|
|
+ this.projectQueryParams = {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ questionType: null,
|
|
|
+ title: null
|
|
|
+ };
|
|
|
+
|
|
|
+ this.selectedType = type
|
|
|
+
|
|
|
+ // 设置选中的项目IDs
|
|
|
+ if (projectIds) {
|
|
|
+ if (typeof projectIds === 'string') {
|
|
|
+ this.selectedProjectIds = projectIds.split(',').map(id => parseInt(id));
|
|
|
+ } else if (Array.isArray(projectIds)) {
|
|
|
+ this.selectedProjectIds = [...projectIds];
|
|
|
+ } else if (typeof projectIds === 'number') {
|
|
|
+ this.selectedProjectIds = [projectIds];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.selectedProjectIds = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示弹窗
|
|
|
+ this.projectDialogVisible = true;
|
|
|
+
|
|
|
+ // 加载分类树数据
|
|
|
+ this.initCategoryTree();
|
|
|
+
|
|
|
+ // 加载项目列表
|
|
|
+ this.getProjectList();
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 确认选择项目 */
|
|
|
+ confirmSelectProject() {
|
|
|
+ // 更新表单中的项目ID
|
|
|
+ if (this.selectedType === 0) {
|
|
|
+ this.form.projectIds = this.selectedProjectIds;
|
|
|
+ }
|
|
|
+
|
|
|
+ else if (this.selectedType === 1) {
|
|
|
+ this.batchUploadForm.projectIds = this.selectedProjectIds;
|
|
|
+ }
|
|
|
+
|
|
|
+ else if (this.selectedType === 2) {
|
|
|
+ this.batchEditDialog.form.projectIds = this.selectedProjectIds;
|
|
|
+ }
|
|
|
+
|
|
|
+ else if (this.selectedType === 3) {
|
|
|
+ const params = {
|
|
|
+ id: this.currentRow.id,
|
|
|
+ projectIds: this.selectedProjectIds.join(",")
|
|
|
+ }
|
|
|
+ updateVideoResource(params).then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.msgSuccess("修改成功");
|
|
|
+ this.open = false;
|
|
|
+ this.getList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ else if (this.selectedType === 4) {
|
|
|
+ this.currentRow.projectIds = this.selectedProjectIds
|
|
|
+ }
|
|
|
+
|
|
|
+ this.projectDialogVisible = false;
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 取消选择项目 */
|
|
|
+ cancelSelectProject() {
|
|
|
+ const projectTable = this.$refs.projectTable;
|
|
|
+ if (projectTable) {
|
|
|
+ // 清空表格数据
|
|
|
+ projectTable.clearSelection();
|
|
|
+ }
|
|
|
+ this.projectDialogVisible = false;
|
|
|
+ },
|
|
|
+ handleProjectSelect(selection) {
|
|
|
+ this.selectedProjectIds = selection.map(item => item.id);
|
|
|
+ selection.forEach(item => {
|
|
|
+ // 检查是否已存在该项目,不存在则添加
|
|
|
+ if (!this.projectShowList.some(p => p.id === item.id)) {
|
|
|
+ this.projectShowList.push(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 项目列表页码变更 */
|
|
|
+ handleProjectPageChange(page) {
|
|
|
+ this.projectQueryParams.pageNum = page;
|
|
|
+ this.getProjectList();
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 项目列表每页条数变更 */
|
|
|
+ handleProjectPageSizeChange(size) {
|
|
|
+ this.projectQueryParams.pageNum = 1;
|
|
|
+ this.projectQueryParams.pageSize = size;
|
|
|
+ this.getProjectList();
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 处理查看项目 */
|
|
|
+ handleViewProject(row, type) {
|
|
|
+ // 保存当前选择的行,以便后续操作
|
|
|
+ this.currentRow = row;
|
|
|
+
|
|
|
+ // 设置form对象的projectIds为当前行的项目IDs
|
|
|
+ this.projectShowList = [];
|
|
|
+
|
|
|
+ if (!row.projectIds || row.projectIds.length === 0) {
|
|
|
+ this.openProjectDialog(null, type)
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ let projectIds = row.projectIds
|
|
|
+ if (Array.isArray(row.projectIds)) {
|
|
|
+ projectIds = projectIds.join(',');
|
|
|
+ }
|
|
|
+
|
|
|
+ getByIds({ids: projectIds}).then(response => {
|
|
|
+ this.projectShowList = response.data;
|
|
|
+ })
|
|
|
+
|
|
|
+ // 打开弹窗展示列表
|
|
|
+ this.projectListDialogVisible = true;
|
|
|
+ },
|
|
|
+ /** 初始化分类树 */
|
|
|
+ initCategoryTree() {
|
|
|
+ // 获取分类列表
|
|
|
+ listUserCourseCategory().then(response => {
|
|
|
+ const treeDate = this.handleTree(response.data, "cateId", "pid");
|
|
|
+ this.categoryTreeData = [{
|
|
|
+ cateId: 0,
|
|
|
+ cateName: '全部',
|
|
|
+ children: treeDate
|
|
|
+ }];
|
|
|
+ });
|
|
|
+ },
|
|
|
+ filterNode(value, data) {
|
|
|
+ if (!value) return true;
|
|
|
+ return data.cateName.indexOf(value) !== -1;
|
|
|
+ },
|
|
|
+ /** 处理分类点击 */
|
|
|
+ handleCategoryClick(data, node) {
|
|
|
+ // 更新查询参数
|
|
|
+ this.projectQueryParams.pageNum = 1;
|
|
|
+
|
|
|
+ // 如果是全部分类,则清空分类过滤
|
|
|
+ if (node.level === 1) {
|
|
|
+ this.projectQueryParams.questionType = null;
|
|
|
+ this.projectQueryParams.questionSubType = null;
|
|
|
+ }
|
|
|
+ else if (node.level === 2) {
|
|
|
+ this.projectQueryParams.questionType = data.cateId;
|
|
|
+ this.projectQueryParams.questionSubType = null;
|
|
|
+ }
|
|
|
+ else if (node.level === 3) {
|
|
|
+ this.projectQueryParams.questionType = null;
|
|
|
+ this.projectQueryParams.questionSubType = data.cateId;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 重新加载项目列表
|
|
|
+ this.getProjectList();
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 搜索项目 */
|
|
|
+ searchProjects() {
|
|
|
+ this.projectQueryParams.pageNum = 1;
|
|
|
+ this.getProjectList();
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 视频预览弹窗关闭前的处理函数 */
|
|
|
+ handleCloseVideoPreview(done) {
|
|
|
+ // 停止视频播放
|
|
|
+ const video = document.getElementById('video');
|
|
|
+ if (video) {
|
|
|
+ video.pause();
|
|
|
+ video.currentTime = 0;
|
|
|
+ }
|
|
|
+ // 关闭弹窗
|
|
|
+ this.videoPreviewVisible = false;
|
|
|
+ done();
|
|
|
+ },
|
|
|
+
|
|
|
updateQueuePositions() {
|
|
|
this.uploadQueue.forEach((video, index) => {
|
|
|
video.queuePosition = index + 1;
|
|
@@ -2266,78 +2465,6 @@ export default {
|
|
|
}
|
|
|
return '';
|
|
|
},
|
|
|
- getQueueStatusColor(status) {
|
|
|
- switch (status) {
|
|
|
- case 'success':
|
|
|
- return '#67C23A';
|
|
|
- case 'failed':
|
|
|
- return '#F56C6C';
|
|
|
- case 'uploading':
|
|
|
- return '#409EFF';
|
|
|
- case 'queued':
|
|
|
- return '#E6A23C';
|
|
|
- default:
|
|
|
- return '#909399';
|
|
|
- }
|
|
|
- },
|
|
|
- /** 复制视频链接到剪贴板 */
|
|
|
- copy(url) {
|
|
|
- // 创建一个临时的input元素
|
|
|
- const input = document.createElement('input');
|
|
|
- // 设置input的值为要复制的视频链接
|
|
|
- input.value = url;
|
|
|
- // 将input添加到DOM中
|
|
|
- document.body.appendChild(input);
|
|
|
- // 选中input的值
|
|
|
- input.select();
|
|
|
- // 执行复制命令
|
|
|
- document.execCommand('copy');
|
|
|
- // 从DOM中移除input元素
|
|
|
- document.body.removeChild(input);
|
|
|
- // 提示用户复制成功
|
|
|
- this.$message({
|
|
|
- message: '已复制到剪贴板',
|
|
|
- type: 'success',
|
|
|
- duration: 1500
|
|
|
- });
|
|
|
- },
|
|
|
- // 处理项目分页变化
|
|
|
- handleProjectPageChange(page) {
|
|
|
- this.projectQueryParams.pageNum = page;
|
|
|
- this.getProjectList();
|
|
|
- },
|
|
|
-
|
|
|
- // 处理项目分页大小变化
|
|
|
- handleProjectPageSizeChange(size) {
|
|
|
- this.projectQueryParams.pageSize = size;
|
|
|
- this.projectQueryParams.pageNum = 1;
|
|
|
- this.getProjectList();
|
|
|
- },
|
|
|
-
|
|
|
- // 确认选择项目
|
|
|
- confirmSelectProject() {
|
|
|
- if (this.selectedProjectIds.length === 0) {
|
|
|
- this.$message.warning('请至少选择一个题目');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 获取选中的项目详情
|
|
|
- const selectedProjects = this.projectList.filter(project =>
|
|
|
- this.selectedProjectIds.includes(project.id)
|
|
|
- );
|
|
|
-
|
|
|
- // 将选中的项目添加到显示列表
|
|
|
- this.projectShowList = [...selectedProjects];
|
|
|
-
|
|
|
- // 关闭对话框
|
|
|
- this.projectDialogVisible = false;
|
|
|
-
|
|
|
- // 清空选择
|
|
|
- this.selectedProjectIds = [];
|
|
|
- this.$refs.projectTable && this.$refs.projectTable.clearSelection();
|
|
|
-
|
|
|
- this.$message.success(`已选择 ${selectedProjects.length} 个题目`);
|
|
|
- },
|
|
|
}
|
|
|
}
|
|
|
</script>
|