employee.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import mockjs from 'mockjs'
  2. const { Random } = mockjs
  3. const city = ['广州', '江门', '上海', '香港']
  4. const organizationUnit = ['MIS', 'WTTO', 'CSO', 'PD', 'ITIS', 'WTT', 'BM', 'BD']
  5. const positionName = ['android开发', 'CEO', 'CFO', 'HR', 'CTO', 'COO']
  6. function employeeList(count) {
  7. const list = []
  8. for (let i = 0; i < count; i++) {
  9. list.push({
  10. id: Random.natural(1, 1000),
  11. name: Random.cname(), // 姓名
  12. organizationUnit: Random.pick(organizationUnit), // 部门
  13. positionName: Random.pick(positionName), // 职位
  14. city: Random.pick(city), // 工作城市
  15. mobilePhone: mockjs.mock(/^1[385][1-9]\d{8}/), // 手机
  16. enterpriseEmail: Random.email(), // 企业邮箱
  17. workingAge: Random.natural(1, 1000), // 司龄
  18. status: Random.pick([0, 1, 2]), // 离职, 试用,在职
  19. isJoin: Random.boolean(), // 是否加入到公司
  20. entryDate: Random.date('yyyy-MM-dd'), // 入职日期
  21. quitReason: Random.csentence(5, 8)
  22. })
  23. }
  24. return list
  25. }
  26. function getEmployees(req, res) {
  27. const params = req.query
  28. const pageSize = params.pageSize * 1 || 10
  29. const list = employeeList(pageSize)
  30. const response = {
  31. result: {
  32. items: list,
  33. totalCount: 100
  34. }
  35. }
  36. return res.json(response)
  37. }
  38. export default {
  39. 'GET /api/employee/getEmployees': getEmployees
  40. }