123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534 |
- const Mock = require('mockjs')
- const Random = Mock['Random']
- const mockGeneration = 8 // primary
- const mockGroups = [1, 2, 3, 4, 5, 6]
- const mockPreferenceCount = 3 // 1 or 3 // 1志愿/3志愿
- module.exports = [
- {
- url: '/mock/front/report/getElectiveStatus',
- type: 'get',
- response: config => {
- return {
- code: 200,
- msg: 'success',
- data: {
- year: 2021,
- roundId: 1,
- roundName: '第X次选科',
- groupIds: mockGroups.toString(),
- roundGroups: mockGroups.map(groupId => ({
- groupId: groupId,
- classCount: Random.integer(2, 6),
- personCount: function() {
- return this.classCount * 50
- },
- limitPerson: false,
- rankOut: false
- })),
- allMatched: Random.boolean(1, 10, 8),
- currentGeneration: mockGeneration,
- // +
- disenrollCount: Random.integer(20, 100), // 未录人数
- enablePushNextDMGeneration: Random.boolean(1, 10, 8),
- allowDMAlgorithm: true,
- doneDMAlgorithm: Random.boolean(1, 10, 8),
- allowForce: Random.boolean(1, 10, 8)
- }
- }
- }
- },
- {
- url: '/mock/front/report/getElectiveSummary',
- type: 'get',
- response: config => {
- const results = []
- for (let generation = 1; generation <= mockGeneration; generation++) {
- const copyGeneration = generation
- switch (generation) {
- case 1:
- // primary
- const allPreferences = []
- for (let pref = 0; pref < mockPreferenceCount; pref++) {
- const preferences = []
- const groupDefines = [
- {
- category: 'actualCount',
- queryCode: Random.cname(),
- displayName: '已报名',
- detailName: '报名组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: 'B',
- bold: false,
- star: false,
- disabled: false
- }))
- }
- ]
- const nonGroupDefines = [
- {
- category: 'unfinishedCount',
- queryCode: Random.cname(),
- displayName: '未报名',
- detailName: '',
- values: [{
- groupId: 0,
- value: Random.integer(0, 10),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }]
- }
- ]
- preferences.push(...groupDefines)
- preferences.push(...nonGroupDefines)
- allPreferences.push(preferences)
- }
- const primary = {
- roundId: 1,
- generation: copyGeneration,
- categories: allPreferences
- }
- results.push(primary)
- break
- default:
- const accumulateDefine = {
- generations: [2, 4, 6, 7],
- factory: () => [
- {
- category: 'approvedCount',
- queryCode: Random.cname(),
- displayName: '正常录取',
- detailName: '录取组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 300),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'forcedCount',
- queryCode: Random.cname(),
- displayName: '调剂录取',
- detailName: '调剂组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(0, 10),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- }
- ]
- }
- const commonDefines = [
- {
- generations: [2],
- factory: () => [
- {
- category: 'indicateCount',
- displayName: '指标',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: true,
- queryCode: 'abc',
- disabled: false
- }))
- },
- {
- category: 'approvedCount',
- queryCode: Random.cname(),
- displayName: '录取人数',
- detailName: '录取组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'adjustCount',
- queryCode: Random.cname(),
- displayName: '调剂人数',
- detailName: '调剂组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'matchedCount',
- queryCode: Random.cname(),
- displayName: '专业符合',
- detailName: '推荐组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'nonmatchedCount',
- queryCode: Random.cname(),
- displayName: '专业不符',
- detailName: '推荐组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- }
- ]
- },
- {
- generations: [3, 5],
- factory: () => [
- {
- category: 'matchedApproved',
- queryCode: Random.cname(),
- displayName: '专业符合同意',
- detailName: '报名组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'matchedNotOptional',
- queryCode: Random.cname(),
- displayName: '专业符合改选',
- detailName: '报名组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'matchedRejected',
- queryCode: Random.cname(),
- displayName: '专业符合拒绝',
- detailName: '拒绝组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'matchedNonaction',
- queryCode: Random.cname(),
- displayName: '专业符合未填',
- detailName: '推荐组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'matchedRankout',
- queryCode: Random.cname(),
- displayName: '专业符合被挤出',
- detailName: '报名组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'nonmatchedApproved',
- queryCode: Random.cname(),
- displayName: '专业符合已填',
- detailName: '报名组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'nonmatchedRejected',
- queryCode: Random.cname(),
- displayName: '不可调剂拒绝',
- detailName: '报名组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'nonmatchedNonaction',
- queryCode: Random.cname(),
- displayName: '不可调剂未填',
- detailName: '报名组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- }
- ]
- },
- {
- generations: [4],
- factory: () => [
- {
- category: 'approvedCount',
- queryCode: Random.cname(),
- displayName: '补录录取',
- detailName: '录取组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'forcedCount',
- queryCode: Random.cname(),
- displayName: '调剂录取',
- detailName: '录取组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'matchedCount',
- queryCode: Random.cname(),
- displayName: '可调剂人数',
- detailName: '调剂组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'nonmatchedCount',
- queryCode: Random.cname(),
- displayName: '不可调剂人数',
- detailName: '报名组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- }
- ]
- },
- {
- generations: [6],
- factory: () => [
- {
- category: 'approvedCount',
- queryCode: Random.cname(),
- displayName: '补录录取',
- detailName: '录取组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- },
- {
- category: 'forcedCount',
- queryCode: Random.cname(),
- displayName: '调剂录取',
- detailName: '录取组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- }
- ]
- },
- {
- generations: [7],
- factory: () => [
- {
- category: 'forcedCount',
- queryCode: Random.cname(),
- displayName: '调剂录取',
- detailName: '录取组合',
- values: mockGroups.map(groupId => ({
- groupId: groupId,
- value: Random.integer(120, 400),
- color: '',
- bold: false,
- star: false,
- disabled: false
- }))
- }
- ]
- }
- ]
- const defines = commonDefines.find(d => d.generations.includes(generation))
- const inAccDef = accumulateDefine.generations.includes(generation)
- if (defines) {
- results.push({
- roundId: 1,
- generation: copyGeneration,
- categories: defines.factory(),
- accumulates: inAccDef ? accumulateDefine.factory() : undefined
- })
- }
- break
- }
- }
- return {
- code: 200,
- msg: 'success',
- data: results
- }
- }
- },
- {
- url: '/mock/front/report/getElectiveGenerationDetails',
- type: 'get',
- response: config => {
- return {
- code: 200,
- msg: 'success',
- total: Random.integer(5, 200),
- data: {
- groupDescriptors: mockGroups.map(groupId => {
- return {
- groupId,
- descriptors: [
- { key: 'setting', value: Random.integer(100, 9999), description: '设置人数' },
- { key: 'actual', value: Random.integer(0, 9999), description: '实报人数' }
- ]
- }
- }),
- 'details|5-20': [
- {
- 'id|+1': 1000,
- 'roundId': 1,
- 'studentId|+1': 100,
- 'studentName': Random.cname(),
- 'groupId': config.query.groupId,
- 'groupName': Random.cname(),
- 'classId|+1': 20,
- 'className': Random.cname(),
- 'datetime': Random.date(),
- 'histories|4-15': [
- {
- 'generation|1': [1, 2, 3, 4, 5, 6, 7],
- 'groupId|1': mockGroups,
- 'description': Random.cname(),
- 'rankDescriptors|1-3': [
- { key: Random.cname(), value: Random.integer(1, 300), description: Random.cname() }
- ]
- }
- ]
- }
- ]
- }
- }
- }
- },
- {
- url: '/mock/front/report/getGenerationOptionalMajorsBatch',
- type: 'get',
- response: config => {
- let studentIds = config.query.studentIds
- if (typeof studentIds === 'string') studentIds = studentIds.split(',')
- const majorsMap = {}
- studentIds.forEach(id => {
- majorsMap[id] = {
- 'bestMatchedGroupId|1': mockGroups,
- 'majors|0-6': [{
- 'collegeId|+1': 5000,
- 'collegeName': Random.cname(),
- 'majorCategoryCode': Random.cname(),
- 'majorCategoryName': Random.cname(),
- 'majors': {},
- 'limitationA': '', // 选科限制1
- 'limitationB': '', // 选科限制2
- 'matchedGroupIds|0-3': mockGroups // 匹配的组合
- }]
- }
- })
- return {
- code: 200,
- msg: 'success',
- data: majorsMap
- }
- }
- }
- ]
|