dykj-college-back-office-ma.../mock/modules/sdy.js
2024-04-08 20:08:23 +08:00

111 lines
3.1 KiB
JavaScript

import Mock from "mockjs"
const data = Mock.mock({
"list|200": [
{
"id|+1": '1',
"name": "@cname",
"studentnumber": "@integer(1000000000,9999999999)",
"department": `@pick(['机电工程系', '护理分院','建筑系','材料科学与工程系','环境科学与工程系'])`,
"major": `@pick(['机械制造与自动化', '材料科学与工程', '环境科学与工程', '建筑工程', '护理学'])`,
"grade": `@pick(['机制1班', '材料1班', '环境1班', '建筑1班','护理1班'])`,
"tuition": `@pick(['已付学费', '未缴学费'])`,
"tu": 16800,
}
]
})
const loans = Mock.mock({
"list|45": [
{
"id|+1": 1,
'proposer': '@cname',
'student': '@integer(100000000,999999999)',
'allowance': '@integer(10000,50000)',
'department': '@pick(["机电工程系","护理分院","建筑系","材料科学与工程系","环境科学与工程系"])',
'cation': '@pick(["2021-2022学年度","2022-2023学年度"])',
'loanTerm': '@pick(["已放款","未放款"])',
'timeofapplication': '@date("yyyy-MM-dd")',
}
]
})
export default [
// 应收管理
{
url: '/get-sdy-managment-list',
method: 'get',
response: () => {
return {
code: 200,
data: data
}
}
},
// 查找应收管理
{
url: '/post-sdy-managment-find',
method: 'post',
response: (req) => {
if (req.body.name !== '') {
return data.list.filter(item => item.name.includes(req.body.name))
}
else if (req.body.studentnumber !== '') {
const studentnumber = Number(req.body.studentnumber)
if (!isNaN(studentnumber)) {
return data.list.filter(item => item.studentnumber === studentnumber)
} else {
return {
code: 400,
message: 'Invalid student number format'
}
}
}
else if (req.body.department !== '') {
return data.list.filter(item => item.department.includes(req.body.department))
}
else if (req.body.major !== '') {
return data.list.filter(item => item.major.includes(req.body.major))
}
else if (req.body.grade !== '') {
return data.list.filter(item => item.grade.includes(req.body.grade))
}
else if (req.body.tuition !== '') {
return data.list.filter(item => item.tuition.includes(req.body.tuition))
}
return {
code: 200,
}
}
},
// 借款管理
{
url: '/get-sdy-loan-list',
method: 'get',
response: () => {
return {
code: 200,
data: loans
}
}
},
// 添加借款人
{
url: '/post-sdy-loan-add',
method: 'post',
response: (req) => {
const newLoan = {
id: loans.list.length + 1,
proposer: req.body.proposer,
student: req.body.student,
allowance: req.body.allowance,
department: req.body.department,
cation: req.body.cation,
loanTerm: req.body.loanTerm,
timeofapplication: req.body.timeofapplication,
}
loans.list.push(newLoan)
return {
code: 200,
data: newLoan
}
}
},
]