abpcoder пре 3 дана
родитељ
комит
2b86fd82d2
1 измењених фајлова са 28 додато и 2 уклоњено
  1. 28 2
      src/pagesOther/pages/voluntary/list/list.vue

+ 28 - 2
src/pagesOther/pages/voluntary/list/list.vue

@@ -14,17 +14,30 @@
                                 @more="showActions(item)" @error="handleError"/>
             </view>
         </z-paging>
+        <ie-safe-toolbar :height="84" :shadow="false">
+            <view class="px-30 py-16">
+                <ie-button @click="handleAdd">添加志愿</ie-button>
+            </view>
+        </ie-safe-toolbar>
         <uv-action-sheet ref="actionSheet" :actions="moreActions" safe-area-inset-bottom close-on-click-overlay
                          cancel-text="取消" @select="handleActionSelect"/>
     </ie-page>
 </template>
 
 <script setup lang="ts">
-import {VoluntaryRecord} from "@/types/voluntary";
+import {SelectedUniversityMajor, VoluntaryRecord} from "@/types/voluntary";
 import VoluntaryItem from "@/pagesOther/pages/voluntary/list/components/voluntary-item.vue";
 import {VOLUNTARY_SORTING} from "@/types/injectionSymbols";
-import {getVoluntaryList, removeVoluntaryByUniversity, sortVoluntaryByUniversity} from "@/api/modules/voluntary";
+import {
+    addVoluntary,
+    getVoluntaryList,
+    removeVoluntaryByUniversity,
+    sortVoluntaryByUniversity
+} from "@/api/modules/voluntary";
 import UvActionSheet from "@/uni_modules/uv-action-sheet/components/uv-action-sheet/uv-action-sheet.vue";
+import {useTransferPage} from "@/hooks/useTransferPage";
+import {UniversityPickerPageOptions} from "@/types/transfer";
+import {routes} from "@/common/routes";
 
 interface ActionItem {
     id: string;
@@ -35,6 +48,7 @@ interface ActionItem {
     disabled?: boolean;
 }
 
+const {transferTo} = useTransferPage()
 const list = ref<VoluntaryRecord[]>([])
 const paging = ref<ZPagingInstance>()
 const isSorting = ref<boolean>(false)
@@ -142,6 +156,18 @@ const handleError = () => {
     paging.value?.reload()
 }
 
+const handleAdd = async () => {
+    const option: UniversityPickerPageOptions = {
+        title: '选择你的意向院校专业',
+        fromVoluntary: true
+    }
+    const picked = await transferTo(routes.targetPicker, {data: option})
+    if (!picked) return
+    await addVoluntary(picked)
+    uni.$ie.showSuccess('保存成功')
+    paging.value?.reload()
+}
+
 provide(VOLUNTARY_SORTING, isSorting)
 </script>