feat: 拖动排序

master
xjs 2025-03-28 18:10:27 +08:00
parent b74e480946
commit 67a0662493
9 changed files with 145 additions and 60 deletions

View File

@ -82,6 +82,7 @@ const show = ref(false)
const badgeValue = ref(1)
const close = () => {
filterMenuRef.value.clearForm()
show.value = false
}

View File

@ -140,8 +140,16 @@ const handleConfirm = () => {
}
}
const clearForm = () => {
defaultCollegeFeature.value = []
defaultUniType.value = []
defaultNature.value = []
defaultRegion.value = []
}
defineExpose({
handleConfirm,
clearForm,
})
</script>

View File

@ -26,7 +26,6 @@
<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 File

@ -0,0 +1,7 @@
<template></template>
<script lang="ts" setup>
onShow(() => {
uni.navigateBack()
})
</script>

View File

@ -8,9 +8,8 @@
<template>
<view class="h-screen flex flex-col">
<web-view :src="webUrl" :fullscreen="false" :update-title="false" @message="handleMessage" />
<web-view :src="webUrl" :update-title="false" @message="handleMessage" />
<!-- <HeaderTip :user-info="userStore.userInfo" :type="1" /> -->
<!-- <DragSortList
:list="list"
class="flex-auto overflow-auto"
@ -35,22 +34,16 @@
</view>
</template>
</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> -->
<!-- <view class="flex items-center pb-safe button-group px-[32rpx] pt-[32rpx]">
<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="志愿表名字">
<!-- <MessageBox v-model:show="messageBoxShow" title="志愿表名字">
<template>
<input
type="text"
@ -67,72 +60,120 @@
保存
</button>
</template>
</MessageBox>
</MessageBox> -->
</template>
<script setup lang="ts">
import HeaderTip from './components/HeaderTip.vue'
import DragSortList from '@/pages-sub/components/dragSort/DragSort.vue'
import SortCollege from './components/SortCollege.vue'
import MessageBox from '@/pages-sub/components/messageBox/MessageBox.vue'
// import HeaderTip from './components/HeaderTip.vue'
// import DragSortList from '@/pages-sub/components/dragSort/DragSort.vue'
// import SortCollege from './components/SortCollege.vue'
// import MessageBox from '@/pages-sub/components/messageBox/MessageBox.vue'
import { useUserStore } from '@/store/user'
import { useScore } from './composable/useWishesList'
import { saveWishList } from '@/service/index/api'
// import { useScore } from './composable/useWishesList'
import { putWishList, saveWishList } from '@/service/index/api'
const userStore = useUserStore()
const { score } = useScore(
userStore.userInfo.estimatedAchievement.provinceCode,
userStore.userInfo.batchName,
)
// const { score } = useScore(
// userStore.userInfo.estimatedAchievement.provinceCode,
// userStore.userInfo.batchName,
// )
const messageBoxShow = ref(false)
// const messageBoxShow = ref(false)
const wishListName = ref('')
const wishList = ref(JSON.parse(JSON.stringify(userStore.userInfo.wishList)))
const myDrop = ref()
// const wishList = ref(JSON.parse(JSON.stringify(userStore.userInfo.wishList)))
// const myDrop = ref()
const getDropList = (list) => {
//
userStore.sortWishCollegeList({ list })
// const getDropList = (list) => {
// //
// userStore.sortWishCollegeList({ list })
// }
// const handleMove = (index) => {
// myDrop.value.handleLongpress(index)
// }
// const handleDelete = async (index) => {
// //
// wishList.value.splice(index, 1)
// await myDrop.value.initList(wishList.value)
// }
// 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(() => {
// myDrop.value?.initList(wishList.value, true)
// })
// }
// const handleSave = () => {
// if (vTbId.value === 0) {
// addWishList()
// }
// }
const editWishList = (_wishList: any[]) => {
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._pId,
major: vItem.major,
majorCode: vItem.majorCode,
majorGroup: vItem.majorGroup,
type: vItem.type,
percentAge: vItem.percentAge,
}
const handleMove = (index) => {
myDrop.value.handleLongpress(index)
}),
}
})
const handleDelete = async (index) => {
//
wishList.value.splice(index, 1)
await myDrop.value.initList(wishList.value)
let params = {
vId: vTbId.value,
cId: userStore.userInfo.estimatedAchievement.wxId,
tableName: wishListName.value,
batchName: userStore.userInfo.batchName,
type: typeName,
subjectClaim: userStore.userInfo.estimatedAchievement.subjectGroup,
score: +userStore.userInfo.estimatedAchievement.expectedScore,
vTbDetails: _vTbDetails,
LocationCode: userStore.userInfo.estimatedAchievement.provinceCode,
}
console.log(params)
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(() => {
myDrop.value?.initList(wishList.value, true)
putWishList(params).then((res) => {
if (res.code === 200) {
userStore.clearWishList()
vTbId.value = res.result as number
} else {
uni.showToast({
title: res.message || '保存失败',
icon: 'none',
})
}
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,
unId: item.unId || item.uId,
unName: item.unName || item.universityName,
unCode: item.unCode || item.collegeCode,
type: item.type,
sort: index + 1,
vItems: item.vItems.map((vItem, vIndex) => {
@ -176,14 +217,27 @@ let editType = ''
let vTbId = ref(0)
let webUrl = computed(() => {
if (vTbId.value !== 0) {
return `http://localhost:3001/sort-college?id=${vTbId.value}&token=${userStore.userInfo.token}&score=${userStore.userInfo.estimatedAchievement.expectedScore}&batchName=${userStore.userInfo.batchName}&subjectGroup=${userStore.userInfo.estimatedAchievement.subjectGroup}&location=${userStore.userInfo.estimatedAchievement.provinceCode}`
}
return ''
})
const handleMessage = () => {}
const handleMessage = (evt) => {
// let saveItem = JSON.parse(evt.message)
let data = JSON.parse(evt.detail.data[0].message)
editWishList(data)
console.log(JSON.stringify(data))
}
onLoad((options) => {
typeName = options.typeName
editType = options.editType
if (editType === 'edit') {
vTbId.value = options.id
} else {
addWishList()
}
})
</script>

View File

@ -7,12 +7,13 @@
</route>
<template>
<scroll-view scroll-y class="pb-safe bg-[#f8f8f8]">
<scroll-view scroll-y class="bg-[#f8f8f8] h-screen">
<view class="px-[32rpx] mt-[32rpx] flex flex-col gap-[16rpx]">
<view
class="flex gap-[24rpx] wish-border justify-between p-[32rpx] rounded-[8rpx]"
v-for="(item, index) in wishList"
:key="index"
@click="toWishPage(item)"
>
<view>
<view class="flex gap-[18rpx] items-center">
@ -30,8 +31,8 @@
<text class="text-[22rpx] text-[#303030]">{{ item.createTime || '时间消失了' }}</text>
</view>
<view class="flex flex-col justify-between items-end">
<view class="i-carbon-trash-can" @click="handleDelete(item, index)"></view>
<button class="download-btn" @click="handleDownload(item)">PDF</button>
<view class="i-carbon-trash-can" @click.stop="handleDelete(item, index)"></view>
<button class="download-btn" @click.stop="handleDownload(item)">下载PDF</button>
</view>
</view>
</view>
@ -95,6 +96,12 @@ const handleDownload = (item) => {
},
})
}
const toWishPage = (item: any) => {
uni.navigateTo({
url: `/pages-sub/home/wishesList/wishesList?typeName=${item.type}&editType=edit&id=${item.vId}`,
})
}
</script>
<style lang="scss" scoped>

View File

@ -254,6 +254,10 @@
"navigationBarTitleText": "我的志愿表"
}
},
{
"path": "home/wishesList/temp",
"type": "page"
},
{
"path": "home/wishesList/wishesList",
"type": "page",

View File

@ -311,6 +311,10 @@ export const saveWishList = (params: WishListParams) => {
return http.post('/api/volunTb/post', params)
}
export const putWishList = (params: WishListParams) => {
return http.post('/api/volunTb/put', params)
}
export const getProductionList = (params: { Id: string }) => {
return http.get('/api/busProduct/detail', params)
}

View File

@ -28,6 +28,7 @@ interface NavigateToOptions {
"/pages-sub/home/news/newsList" |
"/pages-sub/home/schoolRank/index" |
"/pages-sub/home/wishesList/index" |
"/pages-sub/home/wishesList/temp" |
"/pages-sub/home/wishesList/wishesList" |
"/pages-sub/ucenter/active/activePage" |
"/pages-sub/ucenter/appointment/appointment" |