成就等界面接口调整

This commit is contained in:
2025-10-31 19:13:21 +08:00
parent 9ad9507a72
commit 16754b527e
61 changed files with 4748 additions and 592 deletions

View File

@@ -60,6 +60,30 @@
<span v-if="errors.endTime" class="error-msg">{{ errors.endTime }}</span>
</div>
</div>
<div class="form-group">
<label class="form-label">任务分类标签</label>
<select
v-model="selectedTagID"
class="form-input form-select"
@change="handleTagChange"
>
<option value="">请选择分类标签可选</option>
<option
v-for="tag in availableTags"
:key="tag.tagID"
:value="tag.tagID"
>
{{ tag.name }}
</option>
</select>
<div v-if="selectedTag" class="selected-tag-preview">
<div class="tag-badge" :style="{ backgroundColor: selectedTag.color || '#409eff' }">
{{ selectedTag.name }}
</div>
<span v-if="selectedTag.description" class="tag-hint">{{ selectedTag.description }}</span>
</div>
</div>
</section>
<!-- 选择课程 -->
@@ -273,6 +297,7 @@
@confirm="handleUserSelectConfirm"
@cancel="showUserSelector = false"
/>
</div>
</template>
@@ -283,9 +308,10 @@ import { courseApi } from '@/apis/study';
import { resourceApi } from '@/apis/resource';
import { userApi } from '@/apis/system';
import { learningTaskApi } from '@/apis/study';
import { resourceTagApi } from '@/apis/resource';
import { GenericSelector } from '@/components/base';
import type { TaskVO, Course, TaskItemVO } from '@/types/study';
import type { Resource } from '@/types/resource';
import type { Resource, Tag } from '@/types/resource';
import type { SysUser } from '@/types/user';
defineOptions({
@@ -331,11 +357,14 @@ const errors = ref({
const selectedCourses = ref<Course[]>([]);
const selectedResources = ref<Resource[]>([]);
const selectedUsers = ref<SysUser[]>([]);
const selectedTagID = ref<string>('');
const selectedTag = ref<Tag | null>(null);
// 可选数据
const availableCourses = ref<Course[]>([]);
const availableResources = ref<Resource[]>([]);
const availableUsers = ref<SysUser[]>([]);
const availableTags = ref<Tag[]>([]);
// 弹窗控制
const showCourseSelector = ref(false);
@@ -350,6 +379,7 @@ const resourceSearchKeyword = ref('');
const courseLoading = ref(false);
const resourceLoading = ref(false);
const userLoading = ref(false);
const tagLoading = ref(false);
const submitting = ref(false);
onMounted(async () => {
@@ -357,7 +387,8 @@ onMounted(async () => {
await Promise.all([
loadCourses(),
loadResources(),
loadUsers()
loadUsers(),
loadTags()
]);
// 如果是编辑模式,加载任务数据并恢复选择
@@ -398,6 +429,13 @@ async function loadTask() {
const userIds = taskData.value.taskUsers.map(tu => tu.userID);
selectedUsers.value = availableUsers.value.filter(u => userIds.includes(u.id));
}
// 恢复标签选择
if (taskData.value.taskTags && taskData.value.taskTags.length > 0) {
const firstTag = taskData.value.taskTags[0];
selectedTagID.value = firstTag.tagID || '';
selectedTag.value = firstTag;
}
}
} catch (error) {
console.error('加载任务失败:', error);
@@ -671,6 +709,31 @@ function removeUser(index: number) {
selectedUsers.value.splice(index, 1);
}
// 加载标签列表
async function loadTags() {
tagLoading.value = true;
try {
const res = await resourceTagApi.getTagList({ tagType: 3 }); // 获取所有标签
if (res.success && res.dataList) {
// 只保留 tagType 为 3 的学习任务分类标签
availableTags.value = res.dataList.filter(tag => tag.tagType === 3);
}
} catch (error) {
console.error('加载标签失败:', error);
} finally {
tagLoading.value = false;
}
}
// 处理标签选择变化
function handleTagChange() {
if (selectedTagID.value) {
selectedTag.value = availableTags.value.find(tag => tag.tagID === selectedTagID.value) || null;
} else {
selectedTag.value = null;
}
}
// 表单验证
function validateTaskName() {
if (!taskData.value.learningTask.name) {
@@ -750,6 +813,9 @@ async function handleSubmit() {
status: 0
} as TaskItemVO));
// 组装任务标签数据
taskData.value.taskTags = selectedTag.value ? [selectedTag.value] : [];
let res;
if (props.taskId) {
res = await learningTaskApi.updateTask(taskData.value);
@@ -890,6 +956,38 @@ function handleCancel() {
}
}
.form-select {
cursor: pointer;
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1024 1024'%3E%3Cpath fill='%23606266' d='M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 8px center;
background-size: 14px;
padding-right: 30px;
}
.selected-tag-preview {
display: flex;
align-items: center;
gap: 12px;
margin-top: 8px;
.tag-badge {
display: inline-flex;
align-items: center;
padding: 4px 12px;
border-radius: 4px;
color: #fff;
font-size: 13px;
font-weight: 500;
}
.tag-hint {
font-size: 12px;
color: #909399;
}
}
.form-textarea {
resize: vertical;
font-family: inherit;
@@ -1185,5 +1283,6 @@ function handleCancel() {
color: #909399;
margin: 0;
}
</style>