feat: 志愿表编写中

master
xjs 2025-03-18 18:08:24 +08:00
parent 7c0357b67d
commit 2a44fe0747
22 changed files with 508 additions and 162 deletions

View File

@ -95,7 +95,7 @@ onLoad(() => {
const navigatorTo = () => { const navigatorTo = () => {
uni.navigateTo({ uni.navigateTo({
url: '/pages-sub/home/wishesList/index', url: '/pages-sub/home/wishesList/index?typeName=智能填报&editType=add',
}) })
} }
</script> </script>

View File

@ -46,8 +46,6 @@ export default {
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
cursor: pointer; cursor: pointer;
padding: 10px;
border-radius: 4px;
} }
.collapse-icon { .collapse-icon {

View File

@ -24,8 +24,8 @@
:style="[ :style="[
{ 'z-index': activeIndex === index ? 9 : 1 }, { 'z-index': activeIndex === index ? 9 : 1 },
{ top: activeIndex === index ? scrollInfo.y + 'px' : 0 }, { top: activeIndex === index ? scrollInfo.y + 'px' : 0 },
getItemStyle,
isList ? { height: item.height + 'px' } : {}, isList ? { height: item.height + 'px' } : getItemStyle,
]" ]"
class="base-drag-wrapper" class="base-drag-wrapper"
> >
@ -57,8 +57,7 @@
:style="[ :style="[
{ 'z-index': activeIndex === index ? 9 : 1 }, { 'z-index': activeIndex === index ? 9 : 1 },
{ top: activeIndex === index ? scrollInfo.y + 'px' : 0 }, { top: activeIndex === index ? scrollInfo.y + 'px' : 0 },
getItemStyle, isList ? { height: item.height + 'px' } : getItemStyle,
isList ? { height: item.height + 'px' } : {},
]" ]"
class="base-drag-wrapper" class="base-drag-wrapper"
> >
@ -331,67 +330,73 @@ const getPosition = (index: number, list = cloneList.value): [number, number] =>
} }
// //
const initList = (list: ItemType[] = [], changeheight: boolean = false) => { const initList = (list: ItemType[] = [], changeheight: boolean = false): Promise<void> => {
const newList = deepCopy(list) return new Promise((resolve) => {
// itemxykey const newList = deepCopy(list)
showList.value = newList.map((item, index) => { // itemxykey
const [x, y] = getPosition(index) showList.value = newList.map((item, index) => {
let data = { const [x, y] = getPosition(index)
...item, let data = {
x, ...item,
y, x,
dropId: index + 1, y,
} dropId: index + 1,
let key = 'slot' + Math.random() + index
// xykey
if (x === item?.x && y === item?.y) {
if (activeIndex.value !== index) {
// key
key = item.key
} }
} let key = 'slot' + Math.random() + index
// // xykey
data.key = key if (x === item?.x && y === item?.y) {
return data if (activeIndex.value !== index) {
}) // key
cloneList.value = deepCopy(showList.value) key = item.key
nextTick(() => { }
showArea.value = true }
}) //
data.key = key
if (changeheight && props.itemHeight === 'auto') { return data
// item })
cloneList.value = deepCopy(showList.value)
nextTick(() => { nextTick(() => {
showArea.value = true
})
if (changeheight && props.itemHeight === 'auto') {
// item
setTimeout(async () => { setTimeout(async () => {
// #ifdef APP-NVUE // #ifdef APP-NVUE
showArea.value = false showArea.value = false
let max = 0
for (let i = 0; i < slotContent.value.length; i++) { const calculateHeights = async () => {
// let max = 0
await new Promise<void>((resolve) => { let viewMaxHeightVal = 0
let viewMaxHeightVal = 0
dom.getComponentRect(slotContent.value[i], (res: any) => { const promises = slotContent.value.map((content, index) => {
let size = res.size return new Promise<void>((resolve) => {
if (isList.value) { dom.getComponentRect(content, (res: any) => {
cloneList.value[i].height = size.height let size = res.size
} if (isList.value) {
viewMaxHeightVal += size.height cloneList.value[index].height = size.height
if (size.height > max) { }
max = size.height viewMaxHeightVal += size.height
} if (size.height > max) {
resolve() max = size.height
}
resolve()
})
}) })
viewMaxHeight.value = viewMaxHeightVal })
await Promise.all(promises)
viewMaxHeight.value = viewMaxHeightVal
itemMaxHeight.value = max + 'px'
nextTick(() => {
initList(cloneList.value).then(resolve)
}) })
} }
itemMaxHeight.value = max + 'px'
nextTick(() => { await calculateHeights()
initList(cloneList.value)
})
// #endif // #endif
// #ifndef APP-NVUE // #ifndef APP-NVUE
const query = uni.createSelectorQuery().in(instance.proxy) const query = uni.createSelectorQuery().in(instance.proxy)
query query
.selectAll('.slotContent') .selectAll('.slotContent')
@ -412,13 +417,15 @@ const initList = (list: ItemType[] = [], changeheight: boolean = false) => {
} }
viewMaxHeight.value = viewMaxHeightVal // viewMaxHeight.value = viewMaxHeightVal //
itemMaxHeight.value = max + 'px' itemMaxHeight.value = max + 'px'
initList(cloneList.value) initList(cloneList.value).then(resolve)
}) })
.exec() .exec()
// #endif // #endif
}, 0) }, 0)
}) } else {
} resolve()
}
})
} }
// //

View File

@ -19,7 +19,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import Overlay from '@/pages-sub/components/Overlay.vue' import Overlay from '@/pages-sub/components/overlay/Overlay.vue'
defineProps({ defineProps({
show: { show: {

View File

@ -31,6 +31,8 @@
<image <image
class="w-[286rpx] h-[286rpx] mt-[134rpx] mix-blend-multiply" class="w-[286rpx] h-[286rpx] mt-[134rpx] mix-blend-multiply"
src="@/pages-sub/static/images/autoFill/auto-fill.jpg" src="@/pages-sub/static/images/autoFill/auto-fill.jpg"
mode="widthFix"
@click="show = true"
></image> ></image>
</view> </view>
<ActionSheet <ActionSheet
@ -39,7 +41,7 @@
@close="close" @close="close"
custom-header-class="text-[36rpx]! text-[#303030]! font-medium!" custom-header-class="text-[36rpx]! text-[#303030]! font-medium!"
> >
<FilterMenu /> <FilterMenu ref="filterMenuRef" />
<template #footer> <template #footer>
<view class="flex items-center"> <view class="flex items-center">
<button <button
@ -67,23 +69,75 @@ import Navbar from '@/pages-sub/components/navbar/Navbar.vue'
import Badge from '@/pages-sub/components/badge/Badge.vue' import Badge from '@/pages-sub/components/badge/Badge.vue'
import ActionSheet from '@/pages-sub/components/ActionSheet.vue' import ActionSheet from '@/pages-sub/components/ActionSheet.vue'
import { ref } from 'vue' import { ref } from 'vue'
import { getUniversityListByFilter } from '@/service/index/api'
import { useUserStore } from '@/store/user'
const userStore = useUserStore()
const navigatorBack = () => { const navigatorBack = () => {
uni.navigateBack() uni.navigateBack()
} }
const show = ref(false) const show = ref(false)
const badgeValue = ref(12) const badgeValue = ref(1)
const close = () => { const close = () => {
show.value = false show.value = false
} }
const filterMenuRef = ref()
const handleResult = () => { const handleResult = () => {
uni.navigateTo({ let _params = filterMenuRef.value.handleConfirm()
url: `/pages-sub/home/wishesList/index`, countBadgeValue(_params)
let params = {
p: userStore.userInfo.estimatedAchievement.sp,
location: userStore.userInfo.estimatedAchievement.provinceCode,
subjects: userStore.userInfo.estimatedAchievement.subjectGroup.split(','),
score: +userStore.userInfo.estimatedAchievement.expectedScore,
batchname: _params.choosePhase,
nature: _params.chooseNature,
province: _params.chooseRegion,
subjectType: _params.chooseUniType,
}
getUniversityListByFilter(params).then((res) => {
if (res.code === 200) {
let collegeList = (res.result as { rows: any[] }).rows
let wishList = collegeList.map((item) => {
let _major = {
...item,
name: item.universityName,
vItems: item.majorItems.map((majorItem) => ({
...majorItem,
name: majorItem.majorName,
items: majorItem.planItems,
})),
}
return _major
})
userStore.sortWishCollegeList({ list: wishList })
uni.navigateTo({
url: `/pages-sub/home/wishesList/wishesList?typeName=一键填报&editType=add`,
})
}
}) })
} }
const countBadgeValue = (params) => {
badgeValue.value = 0
for (let key in params) {
let value = params[key]
if (value instanceof Object) {
badgeValue.value += value ? Object.keys(value).length : 0
} else if (typeof value === 'string' && value.trim() !== '') {
badgeValue.value += 1
}
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -28,7 +28,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import MessageBox from '../../components/MessageBox.vue' import MessageBox from '@/pages-sub/components/messageBox/MessageBox.vue'
import WXXTable from '@/pages-sub/components/table/Table.vue' import WXXTable from '@/pages-sub/components/table/Table.vue'
import WXXTableCol from '@/pages-sub/components/table/TableCol.vue' import WXXTableCol from '@/pages-sub/components/table/TableCol.vue'
import { getUniversityListByProvince } from '@/service/index/api' import { getUniversityListByProvince } from '@/service/index/api'

View File

@ -60,7 +60,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { getSubjectIntroduceList } from '@/service/index/api' import { getSubjectIntroduceList } from '@/service/index/api'
import MessageBox from '../../components/MessageBox.vue' import MessageBox from '@/pages-sub/components/messageBox/MessageBox.vue'
const subjectIntroduceList = ref([]) const subjectIntroduceList = ref([])
const assessmentSubjectList = ref([]) const assessmentSubjectList = ref([])

View File

@ -47,7 +47,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { UniversityResult } from '@/types/app-type' import { UniversityResult } from '@/types/app-type'
import MessageBox from '../../components/MessageBox.vue' import MessageBox from '@/pages-sub/components/messageBox/MessageBox.vue'
defineProps({ defineProps({
universityResult: { universityResult: {

View File

@ -43,6 +43,7 @@ const fetchBatchData = () => {
} }
}) })
choosePhase.value = userStore.userInfo.batchName choosePhase.value = userStore.userInfo.batchName
handleChange(choosePhase.value)
} }
onLoad(() => { onLoad(() => {

View File

@ -56,7 +56,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import MessageBox from '@/pages-sub/home/components/MessageBox.vue' import MessageBox from '@/pages-sub/components/messageBox/MessageBox.vue'
import { getCareerProspects } from '@/service/index/api' import { getCareerProspects } from '@/service/index/api'
import ProgressBar from '../../components/ProgressBar.vue' import ProgressBar from '../../components/ProgressBar.vue'

View File

@ -69,7 +69,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import MessageBox from '@/pages-sub/home/components/MessageBox.vue' import MessageBox from '@/pages-sub/components/messageBox/MessageBox.vue'
import WXXTable from '@/pages-sub/components/table/Table.vue' import WXXTable from '@/pages-sub/components/table/Table.vue'
import WXXTableCol from '@/pages-sub/components/table/TableCol.vue' import WXXTableCol from '@/pages-sub/components/table/TableCol.vue'
import { getMajorCourse } from '@/service/index/api' import { getMajorCourse } from '@/service/index/api'

View File

@ -58,6 +58,9 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
defineOptions({
inheritAttrs: true,
})
const props = defineProps({ const props = defineProps({
data: { data: {
type: Array, type: Array,
@ -85,13 +88,13 @@ const rankDiff = (index: number, item) => {
} }
const recompileData = computed(() => { const recompileData = computed(() => {
const _data = Object.create(props.data) let _data = props.data.map((item, index) => {
console.log(props.score)
_data.forEach((item, index) => {
item['rankDiff'] = rankDiff(index, item) item['rankDiff'] = rankDiff(index, item)
item['lineDiff'] = item['score'] - props.score item['lineDiff'] = item['score'] - props.score
return item
}) })
return _data return _data
}) })
</script> </script>

View File

@ -1,107 +1,152 @@
<template> <template>
<view class="h-[16rpx] bg-[#f8f8f8]"></view> <view class="h-[16rpx] bg-[#f8f8f8]"></view>
<Collapse <view
:default-collapsed="false"
class="flex flex-col items-center gap-[16rpx] custom-background px-[32rpx]" class="flex flex-col items-center gap-[16rpx] custom-background px-[32rpx]"
:style="`--background-color:${calcTypeName(college.type).style.backgroundColor}`" :style="`--background-color:${calcTypeName(college.type).style.backgroundColor}`"
> >
<template #header> <view class="flex py-[32rpx] gap-[30rpx]">
<view class="flex py-[32rpx] gap-[30rpx]"> <view class="flex flex-col items-center gap-[16rpx]">
<view class="flex flex-col items-center gap-[16rpx]"> <view
<view class="flex items-center gap-[8rpx] text-[#303030] text-[28rpx]"> class="flex items-center gap-[8rpx] text-[#303030] text-[28rpx]"
{{ collegeIndex }} @click.stop="toggleCollapse"
<view class="i-carbon-chevron-down text-[16rpx]"></view> >
</view> {{ collegeIndex }}
<view <view
class="w-[52rpx] h-[52rpx] rounded-[8rpx] font-semibold text-[28rpx] flex items-center justify-center" class="i-carbon-chevron-down text-[16rpx] transition-transform duration-300"
:style="calcTypeName(college.type).style" :class="{ 'rotate-180': !isCollapsed }"
> ></view>
{{ calcTypeName(college.type).text }}
</view>
<text class="text-[32rpx] font-semibold">
{{
Math.round(
college.vItems.reduce((a, b) => a + Number(b.percentAge.replace('%', '')), 0) /
college.vItems.length,
)
}}%
</text>
</view> </view>
<view class="flex flex-col justify-between flex-1"> <view
<view class="flex justify-between mb-[14rpx]"> class="w-[52rpx] h-[52rpx] rounded-[8rpx] font-semibold text-[28rpx] flex items-center justify-center"
<view class="flex justify-between flex-col gap-[6rpx]"> :style="calcTypeName(college.type).style"
<text class="text-[32rpx] font-semibold">{{ college.name }}</text> >
<text class="text-[22rpx] text-[#505050]"> {{ calcTypeName(college.type).text }}
{{ college.city }}·{{ college.educationCategory }}
</text>
<view class="text-[22rpx] text-[#8F959E] flex items-center">
<text class="truncate max-w-[300rpx]" v-show="college.features.length > 0">
{{ college.features.slice(0, 3).join('/') }}/
</text>
<text>排名{{ college.rank }}</text>
</view>
<view class="text-[22rpx] text-[#1F2329] mt-[8rpx] flex gap-[10rpx]">
<text class="">代码{{ college.collegeCode }}</text>
<text>
{{ college.year }}计划{{ college.vItems.reduce((a, b) => a + b.planCount, 0) }}
</text>
</view>
</view>
</view>
<DataTable :data="college.childItems" v-bind="$attrs" />
</view> </view>
<text class="text-[32rpx] font-semibold">
{{
Math.round(
college.vItems.reduce((a, b) => a + Number(b.percentAge.replace('%', '')), 0) /
college.vItems.length,
)
}}%
</text>
</view> </view>
</template> <view class="flex flex-col justify-between flex-1">
<view class="h-[2rpx] bg-[#EDEDED] w-full"></view> <view class="flex justify-between mb-[14rpx]">
<view <view class="flex justify-between flex-col gap-[6rpx]">
v-for="major in college.vItems" <text class="text-[32rpx] font-semibold">{{ college.name }}</text>
:key="major.planId" <text class="text-[22rpx] text-[#505050]">
class="pt-[32rpx] pb-[30rpx] flex gap-[30rpx] not-last:border-b border-[#EDEDED]" {{ college.ownership }}·{{ college.educationCategory }}
>
<view class="flex flex-col gap-[16rpx]">
<text class="text-[32rpx] font-semibold text-[#000]">{{ major.percentAge || '0%' }}</text>
</view>
<view class="flex flex-col gap-[16rpx]">
<view class="flex justify-between flex-auto">
<view class="flex flex-col">
<text class="text-[32rpx] text-[#000] font-semibold truncate max-w-[400rpx]">
{{ major.major.replace(/(\r\n|\n|\r)/g, '') }}
</text> </text>
<text class="text-[22rpx] text-[#1F2329] mt-[14rpx]">{{ major.remark }}</text> <view class="text-[22rpx] text-[#8F959E] flex items-center">
<view class="flex justify-between text-[22rpx] text-[#1F2329] mt-[14rpx]"> <text class="truncate max-w-[300rpx]" v-show="college.features.length > 0">
<view class="flex flex-col gap-[6rpx]"> {{ college.features.slice(0, 3).join('/') }}/
<text>代码{{ major.majorCode }}</text> </text>
<text>{{ college.year }}计划{{ major.planCount }}</text> <text>排名{{ college.rank }}</text>
</view> </view>
<view class="flex flex-col gap-[6rpx]"> <view class="text-[22rpx] text-[#1F2329] mt-[8rpx] flex gap-[10rpx]">
<text>选科:{{ major.subjectClam }}</text> <text class="">代码{{ college.collegeCode }}</text>
<text>学费/学制:{{ major.fee }}/{{ major.academic }}</text> <text>
</view> {{ college.year }}计划{{ college.vItems.reduce((a, b) => a + b.planCount, 0) }}
</text>
</view> </view>
</view> </view>
<view class="flex gap-[40rpx]">
<view class="i-carbon-move" @touchstart="handleMove"></view>
<view class="i-carbon-trash-can" @click="handleDelete"></view>
</view>
</view> </view>
<DataTable :data="major.items" :score="score" />
<DataTable :data="college.childItems" :score="score" />
</view> </view>
</view> </view>
</Collapse> <view class="h-[2rpx] bg-[#EDEDED] w-full"></view>
<view
class="overflow-hidden transition-all duration-300"
:style="{ maxHeight: isCollapsed ? '0' : '2000px' }"
>
<DragSort v-model:list="college.vItems" ref="majorDrop" @get-list="getMajorList">
<template #content="{ data }">
<view
:style="[{ transform: data.index === data.activeIndex ? 'scale(1.05)' : 'scale(1)' }]"
>
<SortMajor
:major="data"
:score="score"
:year="college.year"
:major-index="data.index"
@move="handleMajorMove(data.index)"
@delete="handleMajorDelete(data.index)"
/>
</view>
</template>
</DragSort>
</view>
</view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { calcTypeName } from '../composable/useWishesList' import { calcTypeName } from '../composable/useWishesList'
import DataTable from './DataTable.vue' import DataTable from './DataTable.vue'
import Collapse from '@/pages-sub/components/collapse/Collapse.vue' import SortMajor from './SortMajor.vue'
import DragSort from '@/pages-sub/components/dragSort/DragSort.vue'
import { useUserStore } from '@/store/user'
defineProps<{ const userStore = useUserStore()
const props = defineProps<{
college: any college: any
score: number score: number
collegeIndex: number collegeIndex: number
}>() }>()
const emit = defineEmits(['toggleCollapse', 'updateHeight', 'move', 'delete', 'deleteMajor'])
//
const isCollapsed = ref(true)
const toggleCollapse = () => {
isCollapsed.value = !isCollapsed.value
emit('toggleCollapse', props.collegeIndex)
// DOM
nextTick(() => {
//
emit('updateHeight')
})
}
const handleMove = () => {
emit('move')
}
const handleDelete = () => {
emit('delete')
}
const majorDrop = ref()
const handleMajorMove = (index) => {
majorDrop.value.handleLongpress(index)
}
const getMajorList = (list) => {
userStore.sortWishMajorList({ list, uIndex: props.collegeIndex - 1 })
}
const handleMajorDelete = (index) => {
majorDrop.value.initList(props.college.vItems, true).then(() => {
emit('deleteMajor', index)
})
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.custom-background { .custom-background {
background: linear-gradient(180deg, var(--background-color) 0%, #fff 30%, #fff 100%); background: linear-gradient(180deg, var(--background-color) 0%, #fff 30%, #fff 100%);
} }
//
.transition-all {
transition-property: all;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
</style> </style>

View File

@ -0,0 +1,58 @@
<template>
<view
class="pt-[32rpx] pb-[30rpx] flex justify-center gap-[30rpx] not-last:border-b border-[#EDEDED]"
>
<view class="flex flex-col gap-[16rpx]">
<text class="text-[32rpx] font-semibold text-[#000]">{{ major.percentAge || '0%' }}</text>
</view>
<view class="flex flex-col gap-[16rpx]">
<view class="flex justify-between flex-auto">
<view class="flex flex-col">
<text class="text-[32rpx] text-[#000] font-semibold truncate max-w-[400rpx]">
{{ major.major.replace(/(\r\n|\n|\r)/g, '') }}
</text>
<text class="text-[22rpx] text-[#1F2329] mt-[14rpx]">{{ major.remark }}</text>
<view class="flex justify-between text-[22rpx] text-[#1F2329] mt-[14rpx]">
<view class="flex flex-col gap-[6rpx]">
<text>代码{{ major.majorCode }}</text>
<text>{{ year }}计划{{ major.planCount }}</text>
</view>
<view class="flex flex-col gap-[6rpx]">
<text>选科:{{ major.subjectClam }}</text>
<text>学费/学制:{{ major.fee }}/{{ major.academic }}</text>
</view>
</view>
</view>
<view class="flex gap-[40rpx]">
<view class="i-carbon-move" @touchstart="handleMove"></view>
<view class="i-carbon-trash-can" @click="handleDelete"></view>
{{ score }}
</view>
</view>
<DataTable :data="major.items" :score="score" />
</view>
</view>
</template>
<script setup lang="ts">
import DataTable from './DataTable.vue'
defineProps<{
major: any
score: number
year: string
majorIndex: number
}>()
const emit = defineEmits(['move', 'delete'])
const handleMove = () => {
emit('move')
}
const handleDelete = () => {
emit('delete')
}
</script>
<style lang="scss" scoped></style>

View File

@ -261,7 +261,7 @@ const handlePreview = () => {
if (majorCount.value === 0) { if (majorCount.value === 0) {
return return
} }
uni.navigateTo({ url: '/pages-sub/home/wishesList/wishesList' }) uni.navigateTo({ url: '/pages-sub/home/wishesList/wishesList?editType=add&typeName=智能填报' })
} }
</script> </script>

View File

@ -9,26 +9,73 @@
<template> <template>
<view class="h-screen flex flex-col"> <view class="h-screen flex flex-col">
<HeaderTip :user-info="userStore.userInfo" :type="1" /> <HeaderTip :user-info="userStore.userInfo" :type="1" />
<DragSortList v-model:list="wishList" class="flex-auto pb-safe overflow-auto" ref="myDrop"> <DragSortList
v-model:list="wishList"
class="flex-auto overflow-auto"
ref="myDrop"
@get-list="getDropList"
>
<template #content="{ data }"> <template #content="{ data }">
<view <view
class="drop" class="drop"
:style="[{ transform: data.index === data.activeIndex ? 'scale(1.05)' : 'scale(1)' }]" :style="[{ transform: data.index === data.activeIndex ? 'scale(1.05)' : 'scale(1)' }]"
> >
<SortCollege :college="data" :score="score" :college-index="data.index + 1" /> <SortCollege
:college="data"
:score="score"
:college-index="data.index + 1"
@move="handleMove(data.index)"
@update-height="handleUpdateHeight"
@delete="handleDelete(data.index)"
@delete-major="(majorIndex) => handleDeleteMajor(data.index, majorIndex)"
/>
</view> </view>
</template> </template>
</DragSortList> </DragSortList>
<view class="flex items-center pb-safe button-group px-[32rpx] pt-[32rpx]">
<button
plain
class="border-[#f5f5f5]! flex-auto bg-[#f5f5f5]! rounded-[8rpx]! text-[#1580FF]! text-[32rpx]! font-normal! mr-[22rpx]"
>
下载PDF
</button>
<button
class="border-[#1580FF]! flex-auto bg-[#1580FF]! rounded-[8rpx]! text-[#fff]! text-[32rpx]! font-normal!"
@click="messageBoxShow = true"
>
保存
</button>
</view>
</view> </view>
<MessageBox v-model:show="messageBoxShow" title="志愿表名字">
<template>
<input
type="text"
class="w-auto p-[20rpx] text-center input-border mb-[16rpx]"
v-model="wishListName"
placeholder="请输入志愿表名字"
confirm-type="done"
@confirm="handleSave"
/>
<button
class="border-[#1580FF]! flex-auto bg-[#1580FF]! rounded-[8rpx]! text-[#fff]! text-[32rpx]! font-normal!"
@click="handleSave"
>
保存
</button>
</template>
</MessageBox>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import HeaderTip from './components/HeaderTip.vue' import HeaderTip from './components/HeaderTip.vue'
import DragSortList from '@/pages-sub/components/dragSort/DragSort.vue' import DragSortList from '@/pages-sub/components/dragSort/DragSort.vue'
import SortCollege from './components/SortCollege.vue' import SortCollege from './components/SortCollege.vue'
import MessageBox from '@/pages-sub/components/messageBox/MessageBox.vue'
import { useUserStore } from '@/store/user' import { useUserStore } from '@/store/user'
import { useScore } from './composable/useWishesList' import { useScore } from './composable/useWishesList'
import { saveWishList } from '@/service/index/api'
const userStore = useUserStore() const userStore = useUserStore()
const { score } = useScore( const { score } = useScore(
@ -36,23 +83,113 @@ const { score } = useScore(
userStore.userInfo.batchName, userStore.userInfo.batchName,
) )
const wishList = ref(userStore.userInfo.wishList) const messageBoxShow = ref(false)
const wishListName = ref('')
const wishList = ref(JSON.parse(JSON.stringify(userStore.userInfo.wishList)))
const myDrop = ref() const myDrop = ref()
const getDropList = (list) => { const getDropList = (list) => {
// //
console.log(list, 'eeee') userStore.sortWishCollegeList({ list })
} }
const touchstart = (i) => {
//
console.log(myDrop.value)
myDrop.value.handleLongpress(i) const handleMove = (index) => {
myDrop.value.handleLongpress(index)
} }
const changeList = () => {
const handleDelete = async (index) => {
// //
let list = wishList wishList.value.splice(index, 1)
myDrop.value.initList(list, true) await myDrop.value.initList(wishList.value, true)
} }
const handleUpdateHeight = async () => {
// DragSort
await myDrop.value?.initList(wishList.value, true)
}
const handleDeleteMajor = async (index, majorIndex) => {
wishList.value[index].vItems.splice(majorIndex, 1)
userStore.sortWishMajorList({ list: wishList.value[index].vItems, uIndex: index })
myDrop.value?.initList(wishList.value, true).then(() => {
handleUpdateHeight()
})
}
const handleSave = () => {
if (editType === 'add') {
addWishList()
}
}
const addWishList = () => {
let _wishList = userStore.userInfo.wishList
let _vTbDetails = _wishList.map((item, index) => {
return {
unId: item.unId,
unName: item.unName,
unCode: item.unCode,
type: item.type,
sort: index + 1,
vItems: item.vItems.map((vItem, vIndex) => {
return {
sort: vIndex + 1,
_pId: vItem.planId,
major: vItem.major,
majorCode: vItem.majorCode,
majorGroup: vItem.majorGroup,
type: vItem.type,
percentAge: vItem.percentAge,
}
}),
}
})
let params = {
cId: userStore.userInfo.estimatedAchievement.id,
tableName: wishListName.value,
batchName: userStore.userInfo.batchName,
type: typeName,
subjectClaim: userStore.userInfo.estimatedAchievement.subjectGroup,
score: +userStore.userInfo.estimatedAchievement.expectedScore,
vTbDetails: _vTbDetails,
}
saveWishList(params).then((res) => {
if (res.code === 200) {
uni.showToast({
title: '保存成功',
icon: 'success',
})
userStore.clearWishList()
uni.switchTab({
url: '/pages/home/index/index',
})
} else {
uni.showToast({
title: res.message || '保存失败',
icon: 'none',
})
}
})
}
let typeName = ''
let editType = ''
onLoad((options) => {
typeName = options.typeName
editType = options.editType
})
</script> </script>
<style lang="scss" scoped>
.button-group {
box-shadow: 0rpx -8rpx 8rpx 0rpx rgba(225, 225, 225, 0.2);
}
.input-border {
border: 1rpx solid #ccc;
border-radius: 8rpx;
padding: 20rpx;
}
</style>

View File

@ -280,3 +280,32 @@ export const getPlanProListByFilter = (params: AutoFillParams) => {
export const getBatchBase = (params: { locationCode: string }) => { export const getBatchBase = (params: { locationCode: string }) => {
return http.get('/api/busBatchBase/batch', params) return http.get('/api/busBatchBase/batch', params)
} }
type WishListParams = {
vId?: number
cId: number
tableName?: string
batchName: string
type: string
subjectClaim: string
score: number
vTbDetails: {
unId: number
unName: string
unCode: string
type: number
sort: number
vItems: {
sort: number
_pId: number
major: string
majorCode: string
majorGroup: string
type: number
percentAge: string
}[]
}[]
}
export const saveWishList = (params: WishListParams) => {
return http.post('/api/volunTb/post', params)
}

View File

@ -155,6 +155,18 @@ export const useUserStore = defineStore(
const setWishListMajorWithUn = (val) => { const setWishListMajorWithUn = (val) => {
userInfo.value.wishList.push({ ...val, sort: userInfo.value.wishList.length + 1 }) userInfo.value.wishList.push({ ...val, sort: userInfo.value.wishList.length + 1 })
} }
// 排序专业
const sortWishMajorList = ({ list, uIndex }: { list: any[]; uIndex: number }) => {
userInfo.value.wishList[uIndex].vItems = [...list]
if (userInfo.value.wishList[uIndex].vItems.length === 0) {
userInfo.value.wishList.splice(uIndex, 1)
}
}
// 排序大学
const sortWishCollegeList = ({ list }: { list: any[] }) => {
userInfo.value.wishList = list
}
// 清除志愿表 // 清除志愿表
const clearWishList = () => { const clearWishList = () => {
@ -191,6 +203,8 @@ export const useUserStore = defineStore(
setWishListMajor, setWishListMajor,
setWishListMajorWithUn, setWishListMajorWithUn,
deleteWishListMajor, deleteWishListMajor,
sortWishMajorList,
sortWishCollegeList,
} }
}, },
{ {

2
src/typings.d.ts vendored
View File

@ -3,7 +3,7 @@
declare global { declare global {
type IResData<T> = { type IResData<T> = {
code: number code: number
msg: string message: string
result: T result: T
} }

View File

@ -38,7 +38,7 @@ export const http = <T>(options: CustomRequestOptions) => {
!options.hideErrorToast && !options.hideErrorToast &&
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: (res.data as IResData<T>).msg || '请求错误', title: (res.data as IResData<T>).message || '请求错误',
}) })
reject(res) reject(res)
} }

View File

@ -30,7 +30,7 @@ const http = <T>(options: CustomRequestOptions) => {
!options.hideErrorToast && !options.hideErrorToast &&
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: (res.data as T & { msg?: string })?.msg || '请求错误', title: (res.data as T & { message?: string })?.message || '请求错误',
}) })
reject(res) reject(res)
} }