From 2a44fe0747e4c53d4fe2782e5f72637ff10a6d1a Mon Sep 17 00:00:00 2001 From: xjs Date: Tue, 18 Mar 2025 18:08:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BF=97=E6=84=BF=E8=A1=A8=E7=BC=96?= =?UTF-8?q?=E5=86=99=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages-evaluation-sub/aiAutoFill/index.vue | 2 +- .../components/collapse/Collapse.vue | 2 - .../components/dragSort/DragSort.vue | 121 +++++------ .../messageBox}/MessageBox.vue | 2 +- .../components/{ => overlay}/Overlay.vue | 0 src/pages-sub/home/autoFill/index.vue | 62 +++++- .../home/college/components/Colleges.vue | 2 +- .../home/college/components/FirstClass.vue | 2 +- .../home/college/components/Profile.vue | 2 +- src/pages-sub/home/components/Phase.vue | 1 + .../major/components/EmploymentProspects.vue | 2 +- .../home/major/components/MajorBaseInfo.vue | 2 +- .../home/wishesList/components/DataTable.vue | 9 +- .../wishesList/components/SortCollege.vue | 193 +++++++++++------- .../home/wishesList/components/SortMajor.vue | 58 ++++++ src/pages-sub/home/wishesList/index.vue | 2 +- src/pages-sub/home/wishesList/wishesList.vue | 159 ++++++++++++++- src/service/index/api.ts | 29 +++ src/store/user.ts | 14 ++ src/typings.d.ts | 2 +- src/utils/http.ts | 2 +- src/utils/request.ts | 2 +- 22 files changed, 508 insertions(+), 162 deletions(-) rename src/pages-sub/{home/components => components/messageBox}/MessageBox.vue (94%) rename src/pages-sub/components/{ => overlay}/Overlay.vue (100%) create mode 100644 src/pages-sub/home/wishesList/components/SortMajor.vue diff --git a/src/pages-evaluation-sub/aiAutoFill/index.vue b/src/pages-evaluation-sub/aiAutoFill/index.vue index 8e243b1..557c9b5 100644 --- a/src/pages-evaluation-sub/aiAutoFill/index.vue +++ b/src/pages-evaluation-sub/aiAutoFill/index.vue @@ -95,7 +95,7 @@ onLoad(() => { const navigatorTo = () => { uni.navigateTo({ - url: '/pages-sub/home/wishesList/index', + url: '/pages-sub/home/wishesList/index?typeName=智能填报&editType=add', }) } diff --git a/src/pages-sub/components/collapse/Collapse.vue b/src/pages-sub/components/collapse/Collapse.vue index eccd76c..7b8171f 100644 --- a/src/pages-sub/components/collapse/Collapse.vue +++ b/src/pages-sub/components/collapse/Collapse.vue @@ -46,8 +46,6 @@ export default { align-items: center; justify-content: space-between; cursor: pointer; - padding: 10px; - border-radius: 4px; } .collapse-icon { diff --git a/src/pages-sub/components/dragSort/DragSort.vue b/src/pages-sub/components/dragSort/DragSort.vue index 672bca4..90e8e4d 100644 --- a/src/pages-sub/components/dragSort/DragSort.vue +++ b/src/pages-sub/components/dragSort/DragSort.vue @@ -24,8 +24,8 @@ :style="[ { 'z-index': activeIndex === index ? 9 : 1 }, { top: activeIndex === index ? scrollInfo.y + 'px' : 0 }, - getItemStyle, - isList ? { height: item.height + 'px' } : {}, + + isList ? { height: item.height + 'px' } : getItemStyle, ]" class="base-drag-wrapper" > @@ -57,8 +57,7 @@ :style="[ { 'z-index': activeIndex === index ? 9 : 1 }, { top: activeIndex === index ? scrollInfo.y + 'px' : 0 }, - getItemStyle, - isList ? { height: item.height + 'px' } : {}, + isList ? { height: item.height + 'px' } : getItemStyle, ]" 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 newList = deepCopy(list) - // 给每个item添加一x,y和key - showList.value = newList.map((item, index) => { - const [x, y] = getPosition(index) - let data = { - ...item, - x, - y, - dropId: index + 1, - } - let key = 'slot' + Math.random() + index - // 如果x轴和y轴没变,那么不用更新key来刷新状态 - if (x === item?.x && y === item?.y) { - if (activeIndex.value !== index) { - // 非当前点击的下标和目标下标的下标不需要生成新的key - key = item.key +const initList = (list: ItemType[] = [], changeheight: boolean = false): Promise => { + return new Promise((resolve) => { + const newList = deepCopy(list) + // 给每个item添加一x,y和key + showList.value = newList.map((item, index) => { + const [x, y] = getPosition(index) + let data = { + ...item, + x, + y, + dropId: index + 1, } - } - // 判断拖动位置的元素是那个 - data.key = key - return data - }) - cloneList.value = deepCopy(showList.value) - nextTick(() => { - showArea.value = true - }) - - if (changeheight && props.itemHeight === 'auto') { - // 获取到最高的item + let key = 'slot' + Math.random() + index + // 如果x轴和y轴没变,那么不用更新key来刷新状态 + if (x === item?.x && y === item?.y) { + if (activeIndex.value !== index) { + // 非当前点击的下标和目标下标的下标不需要生成新的key + key = item.key + } + } + // 判断拖动位置的元素是那个 + data.key = key + return data + }) + cloneList.value = deepCopy(showList.value) nextTick(() => { + showArea.value = true + }) + + if (changeheight && props.itemHeight === 'auto') { + // 获取到最高的item setTimeout(async () => { // #ifdef APP-NVUE showArea.value = false - let max = 0 - for (let i = 0; i < slotContent.value.length; i++) { - // 循环 需要异步处理 - await new Promise((resolve) => { - let viewMaxHeightVal = 0 - dom.getComponentRect(slotContent.value[i], (res: any) => { - let size = res.size - if (isList.value) { - cloneList.value[i].height = size.height - } - viewMaxHeightVal += size.height - if (size.height > max) { - max = size.height - } - resolve() + + const calculateHeights = async () => { + let max = 0 + let viewMaxHeightVal = 0 + + const promises = slotContent.value.map((content, index) => { + return new Promise((resolve) => { + dom.getComponentRect(content, (res: any) => { + let size = res.size + if (isList.value) { + cloneList.value[index].height = size.height + } + viewMaxHeightVal += size.height + if (size.height > max) { + 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(() => { - initList(cloneList.value) - }) + + await calculateHeights() // #endif // #ifndef APP-NVUE - const query = uni.createSelectorQuery().in(instance.proxy) query .selectAll('.slotContent') @@ -412,13 +417,15 @@ const initList = (list: ItemType[] = [], changeheight: boolean = false) => { } viewMaxHeight.value = viewMaxHeightVal // 内容区域总高度 itemMaxHeight.value = max + 'px' - initList(cloneList.value) + initList(cloneList.value).then(resolve) }) .exec() // #endif }, 0) - }) - } + } else { + resolve() + } + }) } // 方法 diff --git a/src/pages-sub/home/components/MessageBox.vue b/src/pages-sub/components/messageBox/MessageBox.vue similarity index 94% rename from src/pages-sub/home/components/MessageBox.vue rename to src/pages-sub/components/messageBox/MessageBox.vue index a916854..ebbeef9 100644 --- a/src/pages-sub/home/components/MessageBox.vue +++ b/src/pages-sub/components/messageBox/MessageBox.vue @@ -19,7 +19,7 @@ diff --git a/src/pages-sub/home/wishesList/components/SortMajor.vue b/src/pages-sub/home/wishesList/components/SortMajor.vue new file mode 100644 index 0000000..41ee505 --- /dev/null +++ b/src/pages-sub/home/wishesList/components/SortMajor.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/src/pages-sub/home/wishesList/index.vue b/src/pages-sub/home/wishesList/index.vue index 218e207..708decb 100644 --- a/src/pages-sub/home/wishesList/index.vue +++ b/src/pages-sub/home/wishesList/index.vue @@ -261,7 +261,7 @@ const handlePreview = () => { if (majorCount.value === 0) { return } - uni.navigateTo({ url: '/pages-sub/home/wishesList/wishesList' }) + uni.navigateTo({ url: '/pages-sub/home/wishesList/wishesList?editType=add&typeName=智能填报' }) } diff --git a/src/pages-sub/home/wishesList/wishesList.vue b/src/pages-sub/home/wishesList/wishesList.vue index 3def87e..57cbcf4 100644 --- a/src/pages-sub/home/wishesList/wishesList.vue +++ b/src/pages-sub/home/wishesList/wishesList.vue @@ -9,26 +9,73 @@ + + diff --git a/src/service/index/api.ts b/src/service/index/api.ts index 1662b3a..f82142f 100644 --- a/src/service/index/api.ts +++ b/src/service/index/api.ts @@ -280,3 +280,32 @@ export const getPlanProListByFilter = (params: AutoFillParams) => { export const getBatchBase = (params: { locationCode: string }) => { 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) +} diff --git a/src/store/user.ts b/src/store/user.ts index f21efaf..aa19c7a 100644 --- a/src/store/user.ts +++ b/src/store/user.ts @@ -155,6 +155,18 @@ export const useUserStore = defineStore( const setWishListMajorWithUn = (val) => { 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 = () => { @@ -191,6 +203,8 @@ export const useUserStore = defineStore( setWishListMajor, setWishListMajorWithUn, deleteWishListMajor, + sortWishMajorList, + sortWishCollegeList, } }, { diff --git a/src/typings.d.ts b/src/typings.d.ts index 0de7fea..f630803 100644 --- a/src/typings.d.ts +++ b/src/typings.d.ts @@ -3,7 +3,7 @@ declare global { type IResData = { code: number - msg: string + message: string result: T } diff --git a/src/utils/http.ts b/src/utils/http.ts index 661ffd7..0db7deb 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -38,7 +38,7 @@ export const http = (options: CustomRequestOptions) => { !options.hideErrorToast && uni.showToast({ icon: 'none', - title: (res.data as IResData).msg || '请求错误', + title: (res.data as IResData).message || '请求错误', }) reject(res) } diff --git a/src/utils/request.ts b/src/utils/request.ts index 79f05ab..62f26c5 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -30,7 +30,7 @@ const http = (options: CustomRequestOptions) => { !options.hideErrorToast && uni.showToast({ icon: 'none', - title: (res.data as T & { msg?: string })?.msg || '请求错误', + title: (res.data as T & { message?: string })?.message || '请求错误', }) reject(res) }