Selaa lähdekoodia

vhs - type define

abpcoder 1 kuukausi sitten
vanhempi
commit
3391661ad2

+ 92 - 0
src/api/modules/vhs.ts

@@ -0,0 +1,92 @@
+import flyio from "../flyio";
+import {ApiResponse, ApiResponseList} from "@/types";
+import {
+    BatchEntity,
+    ScoreRank, UniversityFilter,
+    VoluntaryData, VoluntaryDto, VoluntaryEntity,
+    VoluntaryHeaderResponse,
+    VoluntaryMajor,
+    VoluntaryRecommend
+} from "@/types/vhs";
+import config from "@/config";
+
+
+// 志愿填报  科目和分数要求
+export function getVoluntaryData(params: any) {
+    return flyio.get('/front/syzy/zytb/getVoluntaryData', params) as Promise<ApiResponse<VoluntaryData>>
+}
+
+
+// 志愿填报  位次
+export function getRankByScore(params: any) {
+    return flyio.get('/front/syzy/yfyd/getRankByScore', params) as Promise<ApiResponse<ScoreRank>>
+}
+
+// 志愿填报  01.填报批次
+export function zytbBatches(params: any) {
+    return flyio.get('/front/syzy/zytb/batches', params) as Promise<ApiResponseList<BatchEntity>>
+}
+
+// 获取推荐志愿表头
+export function getVoluntaryHeaders(params: any) {
+    return flyio.get('/front/syzy/zytb/getVoluntaryHeaders', params) as Promise<VoluntaryHeaderResponse>
+}
+
+// 志愿填报  志愿组
+export function getRecommendVoluntary(data: any, params: any) {
+    return flyio.post('/front/syzy/zytb/getRecommendVoluntary', data, {params}) as Promise<ApiResponseList<VoluntaryRecommend>>
+}
+
+// 志愿填报  专业
+export function getVoluntaryMarjors(data: any) {
+    return flyio.post('/front/syzy/zytb/getVoluntaryMarjors', data) as Promise<ApiResponse<VoluntaryMajor[]>>
+}
+
+
+// 志愿填报  04.志愿保存
+export function saveZhiyuan(data: VoluntaryDto) {
+    return flyio.post('/front/syzy/zytb/save', data) as Promise<ApiResponse<number>>
+}
+
+// 获取志愿明细
+export function getZhiyuanDetail(wishResId: number) {
+    return flyio.get('/front/syzy/zytb/recordDetail', {wishResId}) as Promise<ApiResponse<VoluntaryEntity>>
+}
+
+// 填报批次  筛选条件
+export function universityFilters(params: any) {
+    return flyio.get('/front/syzy/zytb/university/filters', params) as Promise<ApiResponse<UniversityFilter>>
+}
+
+
+// 查询我的志愿表
+export function selectZytbRecord(params: any) {
+    return flyio.get(`/front/syzy/zytb/record`, params) as Promise<ApiResponseList<VoluntaryEntity>>
+}
+
+/**
+ * 删除我的志愿表
+ * @param params
+ */
+export function delZytbRecord(params: any) {
+    return flyio.get(`/front/syzy/zytb/record/del`, params) as Promise<ApiResponse<boolean>>
+}
+
+/* download voluntary simulated excel */
+export function downloadRecommendReport(params: any) {
+    return flyio.get(`/front/syzy/zytb/export`, params, {responseType: 'arrayBuffer'}) as Promise<ApiResponse<string>>
+}
+
+export function getDownloadRecommendReportOptionsForWap2App(params: any) {
+    return {
+        url: config.serverBaseUrl + '/front/syzy/zytb/export',
+        params
+    }
+}
+
+export function getVoluntarySpecialProjectFilter(params: any) {
+    // params = { year } // 缺省年份返回当前年份的专项选项
+    // returns ['专项A', '专项B', '专项C', '不看专项']
+    // getRecommendVoluntary 新增参数specialProjects: Array // 原来的参数specialProjectNation,specialProjectLocal不动
+    return flyio.get(`/front/syzy/zytb/specialProjectFilter`, params) as Promise<ApiResponse<string[]>>
+}

+ 6 - 0
src/common/enum.ts

@@ -346,4 +346,10 @@ export enum EnumBrochureType {
   EXAM_TIME = 3, // 考试大纲
   WORK = 4, // 就业
   OTHER_RULE = 5 // 其它
+}
+
+export enum EnumSimulatePickType {
+  DANGER = 0,
+  NORMAL = 1,
+  SAFETY = 2
 }

+ 38 - 0
src/pagesOther/hooks/useVoluntaryDataInjection.ts

@@ -0,0 +1,38 @@
+import {VoluntaryData} from "@/types/vhs";
+import {empty} from "@/uni_modules/uv-ui-tools/libs/function/test";
+
+export const useVoluntaryDataInjection = (yearRef: Ref<string> | null = null) => {
+    // 如果页面有年份要求就必须传年份ref参数;
+    // 如果不传,表示只关心最新年份的配置;
+
+    const voluntaryData = ref<VoluntaryData>({} as VoluntaryData)
+
+    const loadData = async () => {
+        let payload = undefined
+        if (yearRef) {
+            const year = toValue(yearRef)
+            if (!year) return
+            payload = {year}
+        }
+        voluntaryData.value = await dispatchCache(cacheActions.getVoluntaryData, payload)
+    }
+
+    const validate = async (score: string, silence: boolean) => {
+        if (empty(voluntaryData.value)) {
+            return Promise.reject('VoluntaryData not be loaded.')
+        }
+        if (!score) {
+            if (!silence) uni.$ie.showError('请输入分数')
+            return Promise.reject(false)
+        }
+        if (!/^[1-9]\d*$/.test(score)) {
+            if (!silence) uni.$ie.showError('分数必须为正整数')
+            return Promise.reject(false)
+        }
+        if (Number(score) > voluntaryData.value.maxScore) {
+            if (!silence) uni.$ie.showError(`分数不能超过${voluntaryData.value.maxScore}`)
+            return Promise.reject(false)
+        }
+        return true
+    }
+}

+ 10 - 10
src/pagesOther/pages/vhs/index/index.vue

@@ -20,18 +20,18 @@
 <script setup>
 import {ref} from 'vue';
 import {useProvideTransfer} from "@/hooks/useTransfer";
-import {useProvideVoluntaryStep} from "@/pagesOther/pages/voluntary/hooks/useVoluntaryStepInjection";
-import {useProvideVoluntaryData} from "@/hooks/useVoluntaryDataInjection";
-import {useProvideVoluntaryForm} from "@/pagesOther/pages/voluntary/hooks/useVoluntaryFormInjection";
-import {useProvideVoluntaryCart} from "@/pagesOther/pages/voluntary/hooks/useVoluntaryCartInjection";
-import {useProvideVoluntaryAssistant} from "@/pagesOther/pages/voluntary/hooks/useVoluntaryAssistantInjection";
-import ScoreStep from "@/pagesOther/pages/voluntary/index/components/score-step.vue";
+import {useProvideVoluntaryStep} from "@/pagesOther/pages/vhs/hooks/useVoluntaryStepInjection";
+import {useProvideVoluntaryData} from "@/pagesOther/pages/vhs/hooks/useVoluntaryDataInjection";
+import {useProvideVoluntaryForm} from "@/pagesOther/pages/vhs/hooks/useVoluntaryFormInjection";
+import {useProvideVoluntaryCart} from "@/pagesOther/pages/vhs/hooks/useVoluntaryCartInjection";
+import {useProvideVoluntaryAssistant} from "@/pagesOther/pages/vhs/hooks/useVoluntaryAssistantInjection";
+import ScoreStep from "@/pagesOther/pages/vhs/index/components/score-step.vue";
 import {useElementSize} from "@vueuse/core";
 import {useProvideUserSnapshot} from "@/pagesOther/pages/ie/hooks/useUserSnapshotInjection";
-import BatchStep from "@/pagesOther/pages/voluntary/index/components/batch-step.vue";
-import CartStep from "@/pagesOther/pages/voluntary/index/components/cart-step.vue";
-import {useProvideVoluntaryMajorHighlight} from "@/pagesOther/pages/voluntary/hooks/useVoluntaryMajorHighlightInjection";
-import {useProvideVoluntaryHeader} from "@/pagesOther/pages/voluntary/hooks/useVoluntaryHeaderInjection";
+import BatchStep from "@/pagesOther/pages/vhs/index/components/batch-step.vue";
+import CartStep from "@/pagesOther/pages/vhs/index/components/cart-step.vue";
+import {useProvideVoluntaryMajorHighlight} from "@/pagesOther/pages/vhs/hooks/useVoluntaryMajorHighlightInjection";
+import {useProvideVoluntaryHeader} from "@/pagesOther/pages/vhs/hooks/useVoluntaryHeaderInjection";
 
 useProvideUserSnapshot()
 const {transferTo} = useProvideTransfer()

+ 2 - 1
src/types/index.ts

@@ -11,10 +11,11 @@ import * as Dropdown from "./dropdown";
 import * as University from "./university";
 import * as TestCenter from "./test-center";
 import * as Pay from "./pay";
+import * as VHS from "./vhs";
 import { VipCardInfo } from "./user";
 import { EnumExamMode, EnumExamType, EnumReviewMode } from "@/common/enum";
 
-export { Study, User, News, Transfer, System, Major, Career, Tree, Voluntary, Dropdown, University, TestCenter, Pay };
+export { Study, User, News, Transfer, System, Major, Career, Tree, Voluntary, Dropdown, University, TestCenter, Pay, VHS };
 
 /// 接口响应
 export interface ApiResponse<T> {

+ 4 - 2
src/types/injectionSymbols.ts

@@ -1,6 +1,6 @@
 import type { InjectionKey } from 'vue'
 import { StudyPlan, StudyPlanStats } from './study';
-import { Study, Transfer, University, Voluntary, Major } from '.';
+import { Study, Transfer, University, Voluntary, Major, VHS } from '.';
 import { useExam } from '@/composables/useExam';
 
 /**
@@ -54,4 +54,6 @@ export const UNIVERSITY_FILTER = Symbol('UNIVERSITY_FILTER') as InjectionKey<Ref
 export const VOLUNTARY_REFRESHER_ENABLED = Symbol('VOLUNTARY_REFRESHER_ENABLED') as InjectionKey<Ref<boolean>>
 
 export const UNIVERSITY_DETAIL = Symbol('UNIVERSITY_DETAIL') as InjectionKey<Ref<University.UniversityDetail>>
-export const MAJOR_TREE = Symbol('MAJOR_TREE') as InjectionKey<Ref<Major.MajorItem[]>>
+export const MAJOR_TREE = Symbol('MAJOR_TREE') as InjectionKey<Ref<Major.MajorItem[]>>
+
+export const VOLUNTARY_DATA = Symbol('VOLUNTARY_DATA') as InjectionKey<Ref<VHS.VoluntaryData>>

+ 201 - 0
src/types/vhs.ts

@@ -0,0 +1,201 @@
+// 职高对口/文化类填报
+
+import {ApiResponse, Entity} from "@/types/index";
+import {University} from "@/types/university";
+import {EnumSimulatePickType} from "@/common/enum";
+
+export type SortType = 'letter' | 'number' // 除了字母,其它都按数字处理
+
+export interface BatchConfig {
+    "batch": number;
+    "profession": number; // profession limitation
+    "groups": number; // major group limitation
+}
+
+export interface VoluntaryData {
+    "batches": BatchConfig[];
+    "minScore": number;
+    "newGaokaoType": number;
+    "location": string;
+    "sort": SortType;
+    "maxScore": number;
+}
+
+export interface ScoreRank extends Entity {
+    "location": string;
+    "year": string;
+    "mode": string;
+    "score": number;
+    "num": number;
+    "numTotal": number;
+    "status": number;
+    "maxScore": number;
+    "lowestRank": number;
+    "highestRank": number;
+    "scoreRank": string | null;
+    "type": string | null;
+}
+
+export interface BatchEntity extends Entity {
+    "batch": number;
+    "name": string;
+    "year": string;
+    "score2": number;
+    "recommand": boolean;
+    "tips": string;
+    "ben": boolean;
+}
+
+export interface VoluntaryHeaderResponse extends ApiResponse<string[]> {
+    isMock: boolean;
+}
+
+export interface VoluntaryPlan {
+    "collegeCode": string;
+    "year": string;
+    "type": string;
+    "universityId": string;
+    "universityNameText": string;
+    "planCount": number;
+    "course": string;
+    "group": string;
+    "groupsName": string;
+    "majorCount": number;
+}
+
+export interface VoluntaryHistory {
+    "year": string;
+    "type": string;
+    "score": number;
+    "seat": number;
+    "numReal": number;
+    "collect": boolean;
+    "collectDesc": string;
+    "sinoForeignDesc": string;
+    "group": string;
+    "inheritScore": boolean;
+    "sinoforeign": boolean;
+}
+
+export interface SimulatePickType {
+    text: string;
+    value: number;
+}
+
+export interface VoluntaryRecommend {
+    "pickType": EnumSimulatePickType;
+    "specialProject": string;
+    "enrollOver": number;
+    "enrollRatio": string;
+    "enrollRatioText": string;
+    "jCode": string;
+    "university": University;
+    "recruitPlan": VoluntaryPlan;
+    "histories": VoluntaryHistory[],
+    "history": VoluntaryHistory;
+}
+
+export interface VoluntaryMajor {
+    "id": number;
+    "marjorId": string;
+    "marjorBelongs": string;
+    "marjorCode": string;
+    "marjorName": string;
+    "marjorDirection": string;
+    "planCount": number;
+    "xuefei": string;
+    "xuezhi": string;
+    "pickType": EnumSimulatePickType;
+    "enrollOver": number;
+    "enrollRatio": string;
+    "enrollRatioText": string;
+    "professionType": string;
+    "typeNames": string | null;
+    "level": string | null;
+    "enrollFluctuate": boolean; // 大小年
+    "limitationTags": string;
+    "isNew": number;
+    "histories": VoluntaryHistory[],
+    "history": VoluntaryHistory
+}
+
+export interface VoluntaryWishMajorDto {
+    id: number;
+    code: string;
+    name: string;
+    pickType: EnumSimulatePickType;
+    submitMajorId: number;
+    enrollRatio: string;
+    enrollRatioText: string;
+    enrollFluctuate: boolean;
+}
+
+export interface VoluntaryWishDto {
+    uniqueCode: string;
+    universityId: number;
+    collegeCode: string;
+    code: string;
+    jCode: string;
+    name: string;
+    pickType: EnumSimulatePickType;
+    enrollRatio: string;
+    enrollRatioText: string;
+    ranking: number | string;
+    rankingOfEdu: string | number;
+    seat: number | null;
+    marjors: VoluntaryWishMajorDto[]
+}
+
+export interface VoluntaryBatchDto {
+    batch: number;
+    name: string;
+    score1: string | number;
+    score2: string | number;
+    scoreBatchLimit: number;
+    recommand: boolean;
+    scores: [],
+    wishes: VoluntaryWishDto[],
+    sort: string;
+    paramBatches: BatchConfig[];
+    highlightMajorIds: string[];
+}
+
+export interface VoluntaryDetailDto {
+    batch: number;
+    mode: string;
+    score: string;
+    seatInput: string;
+    year: string;
+    isMock: boolean;
+}
+
+export interface VoluntaryDto {
+    id: number | null;
+    name: string;
+    batch: number;
+    detail: VoluntaryDetailDto;
+}
+
+export interface VoluntaryEntity extends Entity {
+    "customerCode": string;
+    "type": number;
+    "code": string;
+    "name": string;
+    "exactName": boolean;
+    "batch": string;
+    "batchName": string;
+    "mode": string;
+    "score": number;
+    "detail": string;
+    "summary": string[]
+    "status": number;
+    "obsoleted": number;
+}
+
+export interface UniversityFilter {
+    "locations": string[],
+    "natureTypes": string[],
+    "types": string[],
+    "levels": string[],
+    "features": string[]
+}

+ 12 - 0
src/utils/common.ts

@@ -0,0 +1,12 @@
+import {SimulatePickType} from "@/types/vhs";
+
+export const SimulatePickTypes: SimulatePickType[] = [{
+    text: '冲刺型',
+    value: 0
+}, {
+    text: '稳妥型',
+    value: 1
+}, {
+    text: '保守型',
+    value: 2
+}]

+ 2 - 2
src/utils/index.js

@@ -1,6 +1,5 @@
 import {array, func, object, string} from "@/uni_modules/uv-ui-tools/libs/function/test";
 import _ from "lodash";
-import mxConfig from "@/common/mxConfig";
 
 export const sizeFormat = function (size, decimals = 2) {
     if (size === 0) return '0 B';
@@ -39,7 +38,8 @@ export const combineOssFile = function (src) {
     const lowerCaseStr = src.toLowerCase()
     if (lowerCaseStr.startsWith('http')) return src
     if (['.jpg', '.png', '.gif', '.jpeg'].every(suffix => !lowerCaseStr.includes(suffix))) return src
-    const baseUrl = mxConfig.ossFileBase || ''
+    throw new Error('TS error: import config.ts')
+    const baseUrl = '' //mxConfig.ossFileBase || ''
     const comb = baseUrl.endsWith('/') || src.startsWith('/') ? '' : '/'
     return [baseUrl, comb, src].join('')
 }