diff --git a/common/http.api.js b/common/http.api.js index d1eb5a9..785a043 100644 --- a/common/http.api.js +++ b/common/http.api.js @@ -11,6 +11,8 @@ let apiApp = { batchDetail: '/api/mobile/batch/detail', batchSubmit: '/api/mobile/batch/user-submit', batchData: '/api/mobile/user/batch-data', + batchDataDetail: '/api/mobile/user/batch-data-detail', + specialtyList: '/api/mobile/school/specialty', } const apiUser = { appletLogin: '/api/mobile/user/applet-login', @@ -46,6 +48,8 @@ const install = (Vue, vm) => { const batchDetail = (params = {}) => vm.$u.get(apiApp.batchDetail, params) const batchSubmit = (params = {}) => vm.$u.post(apiApp.batchSubmit, params) const batchData = (params = {}) => vm.$u.get(apiApp.batchData, params) + const batchDataDetail = (params = {}) => vm.$u.get(apiApp.batchDataDetail, params) + const specialtyList = (params = {}) => vm.$u.get(apiApp.specialtyList, params) // 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下 vm.$u.api = { // 用户相关 @@ -68,6 +72,8 @@ const install = (Vue, vm) => { batchDetail, batchSubmit, batchData, + batchDataDetail, + specialtyList, }; } diff --git a/package_sub/pages/BatchDetail/BatchDetail.vue b/package_sub/pages/BatchDetail/BatchDetail.vue new file mode 100644 index 0000000..8da32d5 --- /dev/null +++ b/package_sub/pages/BatchDetail/BatchDetail.vue @@ -0,0 +1,340 @@ + + + + + diff --git a/package_sub/pages/BatchForm/BatchForm.vue b/package_sub/pages/BatchForm/BatchForm.vue index 74125d1..a983703 100644 --- a/package_sub/pages/BatchForm/BatchForm.vue +++ b/package_sub/pages/BatchForm/BatchForm.vue @@ -16,7 +16,7 @@ }" @click="isShowTime = true"> - + @@ -93,10 +93,22 @@ - + - + @@ -119,10 +131,24 @@ {{ spec.number }} - + - + @@ -209,6 +235,9 @@ }" @confirm="e => form.year = e.year"> + + + @@ -220,6 +249,19 @@ export default { step: 1, isShowTime: false, areaList: [], + forSchoolName: { + code: '', + value: '', + needSpec: false, + }, + isShowSchoolSelect: false, + schoolList: [], + isShowSpecSelect: false, + forSpecName: { + code: '', + value: '', + }, + specList: [], form: { name: "", finish_school: "", @@ -239,8 +281,83 @@ export default { }; }, methods: { + specListCancel() { + if (this.forSpecName.code) { + this.flatForm[this.forSpecName.code] = '' + } + if (this.forSpecName.value) { + this.flatForm[this.forSpecName.value] = '' + } + }, + specListConfirm(e) { + const { label, value, extra } = e[0] + if (this.forSpecName.code) { + this.flatForm[this.forSpecName.code] = value + } + if (this.forSpecName.value) { + this.flatForm[this.forSpecName.value] = label + } + }, + schoolListCancel() { + if (this.forSchoolName.code) { + this.flatForm[this.forSchoolName.code] = "" + } + if (this.forSchoolName.value) { + this.flatForm[this.forSchoolName.value] = "" + } + + this.forSchoolName.needSpec = false + }, + schoolListConfirm(e) { + console.log(e) + if (e[1]) { + const { label, value, extra } = e[1] + if (this.forSchoolName.code) { + this.flatForm[this.forSchoolName.code] = value + } + if (this.forSchoolName.value) { + this.flatForm[this.forSchoolName.value] = label + } + + if (this.forSchoolName.needSpec) { + this.getSpecialties(extra) + } + } + }, + async getSpecialties(school_id) { + try { + const { list } = await this.$u.api.specialtyList({ + page: 1, + page_size: 9999, + school_id + }) + this.specList = list.map(i => ({ label: i.name, value: i.code, extra: i.id })) + } catch (err) { + console.error(err) + } + }, + async getSchools() { + try { + const { list } = await this.$u.api.schoolList({ + page: 1, + page_size: 9999 + }) + this.schoolList = this.areaList.map(area => ({ + id: area.id, + value: area.id, + label: area.name, + children: list.data.filter(school => school.area_id === area.id)?.map(i => ({ + value: i.code, + label: i.name, + extra: i.id + })) + })) + } catch (err) { + console.error(err) + } + }, async getBatchSub(batchId) { - if (!this.subForm.find(i => i.id === batchId)) { + if (!this.subForm.find(i => i.batchId === batchId)) { this.subForm.push({ batchId, name: this.batches.find(j => j.id === batchId)?.name, @@ -265,12 +382,13 @@ export default { value: "", specialties: subSchool.specialty?.map((spec, specIndex) => ({ specialtyId: specIndex, + name: spec.number, code: "", value: "" })) })), - specialtyObey: "1", - schoolObey: "1" + [resSub.show_specialty_obey ? 'specialtyObey' : 'notShowSpecialtyObey']: "1", + [resSub.show_school_obey ? 'schoolObey' : 'notShowSchoolObey']: "1" })) } catch (err) { console.error(err) @@ -353,7 +471,7 @@ export default { }, setTitle() { uni.setNavigationBarTitle({ - title: `志愿模拟填报 - Step ${this.step}${ this.step !== 1 ? ('/'+(this.batches.length+1)) : '' }` + title: `志愿模拟填报 - Step ${this.step}${ this.step !== 1 ? ('/'+(this.batches.length)) : '' }` }) }, async getArea() { @@ -365,43 +483,42 @@ export default { } }, - submit () { - const idName = ['batchId', 'batchSubId', 'batchSubSchoolId', 'specialtyId'] - const linkName = ['batchSubs', 'batchSubSchools', 'specialties'] - for (let key in this.flatForm) { - let target = null - let keys = key.split('-') - for (let i = 0;i < keys.length;i++) { - const val = keys[i] - if (i === 1) { - let myTarget = target.find(j => j[idName[i]] === Number(val)) + submit() { + const idName = ['batchId', 'batchSubId', 'batchSubSchoolId', 'specialtyId']; + const linkName = ['batchSubs', 'batchSubSchools', 'specialties']; + + const updateTargetProperty = (target, key, property) => { + if (target && target.hasOwnProperty(property)) { + target[property] = this.flatForm[key]; + } + }; + + for (const key in this.flatForm) { + let target = null; + const keys = key.split('-'); + + keys.forEach((val, i) => { + + if (i === 2) { if (/school$/.test(key)) { - if (myTarget.hasOwnProperty('schoolObey')) { - myTarget['schoolObey'] = this.flatForm[key] - } + updateTargetProperty(target, key, 'schoolObey'); } else if (/specialty$/.test(key)) { - if (myTarget.hasOwnProperty('specialtyObey')) { - myTarget['specialtyObey'] = this.flatForm[key] - } - } - } else if (i === 2) { - let myTarget = target.find(j => j[idName[i]] === Number(val)) - if (val === 'code') { - if (myTarget.hasOwnProperty('code')) { - myTarget['code'] = this.flatForm[key] - } - } else if (val === 'value') { - if (myTarget.hasOwnProperty('value')) { - myTarget['value'] = this.flatForm[key] - } + updateTargetProperty(target, key, 'specialtyObey'); } } - if (isNaN(Number(val))) { + if (isNaN(Number(val))) { + if (i === 3 || i === 4) { + if (val === 'code' || val === 'value') { + updateTargetProperty(target, key, val); + } + } } else { - target = target ? target.find(j => j[idName[i]] === Number(val))[linkName[i]] : this.subForm.find(j => j[idName[i]] === Number(val))[linkName[i]] + target = (target && target[linkName[i - 1]]) + ? target[linkName[i - 1]].find(j => j[idName[i]] === Number(val)) + : this.subForm.find(j => j[idName[i]] === Number(val)); } - } + }); } this.$u.api.batchSubmit({ aspiration_id: this.aspiration.id, @@ -414,10 +531,11 @@ export default { url: '/package_sub/pages/FormSuccess/FormSuccess', params: { title: "志愿填报", - redirect: '/pages/list/list' + redirect: '/pages/list/list', + type: 'switchTab' } - }) - }) + }); + }); } }, computed: { @@ -443,7 +561,9 @@ export default { this.setTitle() }, created() { - this.getArea() + this.getArea().then(_ => { + this.getSchools() + }) }, } diff --git a/package_sub/pages/FormSuccess/FormSuccess.vue b/package_sub/pages/FormSuccess/FormSuccess.vue index 3d514a0..871005b 100644 --- a/package_sub/pages/FormSuccess/FormSuccess.vue +++ b/package_sub/pages/FormSuccess/FormSuccess.vue @@ -24,7 +24,11 @@ 'letter-spacing': '3rpx', color: '#fff', 'margin-top': '10vh' - }">返回列表 + }" + @click="$u.route({ + url: redirect, + type: type + })">返回列表 @@ -34,7 +38,8 @@ export default { data() { return { title: "填报", - redirect: '/pages/index/index' + redirect: 'pages/index/index', + type: 'switchTab' }; }, onLoad(options) { @@ -46,7 +51,12 @@ export default { if (options.redirect) { this.redirect = options.redirect } else { - this.redirect = '/pages/index/index' + this.redirect = 'pages/index/index' + } + if (options.type) { + this.type = options.type + } else { + this.type = 'switchTab' } } } diff --git a/package_sub/pages/ReportDetail/ReportDetail.vue b/package_sub/pages/ReportDetail/ReportDetail.vue deleted file mode 100644 index 70761a8..0000000 --- a/package_sub/pages/ReportDetail/ReportDetail.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - - - diff --git a/pages.json b/pages.json index 73b2b84..3383d33 100644 --- a/pages.json +++ b/pages.json @@ -75,13 +75,6 @@ "enablePullDownRefresh": true } }, - { - "path": "pages/ReportDetail/ReportDetail", - "style": { - "navigationBarTitleText": "我的模拟填报", - "enablePullDownRefresh": true - } - }, { "path": "pages/IndependentRecruitment/IndependentRecruitment", "style": { @@ -102,6 +95,13 @@ "navigationBarTitleText": "志愿填报", "enablePullDownRefresh": false } + }, + { + "path": "pages/BatchDetail/BatchDetail", + "style": { + "navigationBarTitleText": "我的模拟填报", + "enablePullDownRefresh": false + } } ] } diff --git a/pages/list/list.vue b/pages/list/list.vue index 121baa8..1ce60a2 100644 --- a/pages/list/list.vue +++ b/pages/list/list.vue @@ -15,10 +15,10 @@ - 所属区域:吴中区 + 所属区域:{{ (item.aspiration && item.aspiration.area) ? item.aspiration.area.name : '-' }} - 填报年份:2025年 + 填报年份:{{ item.aspiration ? item.aspiration.year : '' }}年 @@ -36,9 +36,9 @@ 'font-size': '24rpx' }" @click="$u.route({ - url: '/package_sub/pages/ReportDetail/ReportDetail', + url: '/package_sub/pages/BatchDetail/BatchDetail', params: { - id: '' + id: item.id } })">查看 @@ -81,6 +81,7 @@ export default { const res = await this.$u.api.batchData(this.select); console.log(res); this.list.push(...res.list) + this.total = res.list.length if (this.list.length >= res.total) { this.status = 'nomore' } else { @@ -94,7 +95,7 @@ export default { } catch (err) { console.error(err) } finally { - uni.hideNavigationBarLoading() + uni.stopPullDownRefresh() } } }, @@ -158,7 +159,7 @@ export default { padding: 26rpx 28rpx; } } - &-item + &-item { + .list-item + .list-item { margin-top: 24rpx; } } diff --git a/pages/me/me.vue b/pages/me/me.vue index 1f1c2a0..d3e0fef 100644 --- a/pages/me/me.vue +++ b/pages/me/me.vue @@ -12,7 +12,7 @@ - + 我的模拟填报