import mockjs from 'mockjs' const { Random } = mockjs const city = ['广州', '江门', '上海', '香港'] const organizationUnit = ['MIS', 'WTTO', 'CSO', 'PD', 'ITIS', 'WTT', 'BM', 'BD'] const positionName = ['android开发', 'CEO', 'CFO', 'HR', 'CTO', 'COO'] function employeeList(count) { const list = [] for (let i = 0; i < count; i++) { list.push({ id: Random.natural(1, 1000), name: Random.cname(), // 姓名 organizationUnit: Random.pick(organizationUnit), // 部门 positionName: Random.pick(positionName), // 职位 city: Random.pick(city), // 工作城市 mobilePhone: mockjs.mock(/^1[385][1-9]\d{8}/), // 手机 enterpriseEmail: Random.email(), // 企业邮箱 workingAge: Random.natural(1, 1000), // 司龄 status: Random.pick([0, 1, 2]), // 离职, 试用,在职 isJoin: Random.boolean(), // 是否加入到公司 entryDate: Random.date('yyyy-MM-dd'), // 入职日期 quitReason: Random.csentence(5, 8) }) } return list } function getEmployees(req, res) { const params = req.query const pageSize = params.pageSize * 1 || 10 const list = employeeList(pageSize) const response = { result: { items: list, totalCount: 100 } } return res.json(response) } export default { 'GET /api/employee/getEmployees': getEmployees }