Переглянути джерело

在链接视图中为管理员添加团队选择功能,优化编辑表单,确保非管理员角色不传递团队ID,提升用户体验。

wuyi 3 місяців тому
батько
коміт
81d560b674
1 змінених файлів з 31 додано та 2 видалено
  1. 31 2
      src/views/LinkView.vue

+ 31 - 2
src/views/LinkView.vue

@@ -257,6 +257,20 @@
           />
         </div>
 
+        <div v-if="isAdmin" class="field mt-4">
+          <label for="edit-teamId" class="font-medium text-sm mb-2 block">选择团队</label>
+          <Select
+            id="edit-teamId"
+            v-model="editForm.teamId"
+            :options="teamSelectOptions"
+            optionLabel="label"
+            optionValue="value"
+            placeholder="选择团队"
+            class="w-full"
+            showClear
+          />
+        </div>
+
         <div class="field mt-4">
           <label for="edit-link" class="font-medium text-sm mb-2 block">链接地址</label>
           <InputText id="edit-link" v-model="editForm.link" class="w-full" />
@@ -353,7 +367,8 @@ const editForm = ref({
   name: null,
   type: null,
   link: null,
-  image: null
+  image: null,
+  teamId: null
 })
 
 // 搜索表单
@@ -381,6 +396,14 @@ const teamOptions = computed(() => {
   return options
 })
 
+// 团队选择选项(用于编辑表单)
+const teamSelectOptions = computed(() => {
+  return teamStore.teams.map((team) => ({
+    label: team.name,
+    value: team.id
+  }))
+})
+
 // 获取链接类型文本
 const getLinkTypeText = (type) => {
   return LinkType[type] || type
@@ -577,7 +600,8 @@ const openAddDialog = () => {
     name: null,
     type: null,
     link: null,
-    image: null
+    image: null,
+    teamId: null
   }
   // 重置图片预览状态
   imagePreview.value = null
@@ -608,6 +632,11 @@ const saveEdit = async () => {
     // 准备保存的数据
     const saveData = { ...editForm.value }
 
+    // 非管理员角色不传递团队ID
+    if (!isAdmin.value) {
+      delete saveData.teamId
+    }
+
     // 处理图片逻辑
     if (imageFile.value) {
       // 有新选择的图片文件,先上传