123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- import { toAnyString } from '@/utils'
- import Mock from 'mockjs'
- import { SUCCESS_CODE } from '@/constants'
- const departmentList: any = []
- const citys = ['厦门总公司', '北京分公司', '上海分公司', '福州分公司', '深圳分公司', '杭州分公司']
- for (let i = 0; i < 5; i++) {
- departmentList.push({
- // 部门名称
- departmentName: citys[i],
- id: toAnyString(),
- createTime: '@datetime',
- // 状态
- status: Mock.Random.integer(0, 1),
- // 备注
- remark: '@cword(10, 15)',
- children: [
- {
- // 部门名称
- departmentName: '研发部',
- id: toAnyString(),
- createTime: '@datetime',
- // 状态
- status: Mock.Random.integer(0, 1),
- // 备注
- remark: '@cword(10, 15)'
- },
- {
- // 部门名称
- departmentName: '产品部',
- id: toAnyString(),
- createTime: '@datetime',
- // 状态
- status: Mock.Random.integer(0, 1),
- // 备注
- remark: '@cword(10, 15)'
- },
- {
- // 部门名称
- departmentName: '运营部',
- id: toAnyString(),
- createTime: '@datetime',
- // 状态
- status: Mock.Random.integer(0, 1),
- // 备注
- remark: '@cword(10, 15)'
- },
- {
- // 部门名称
- departmentName: '市场部',
- id: toAnyString(),
- createTime: '@datetime',
- // 状态
- status: Mock.Random.integer(0, 1),
- // 备注
- remark: '@cword(10, 15)'
- },
- {
- // 部门名称
- departmentName: '销售部',
- id: toAnyString(),
- createTime: '@datetime',
- // 状态
- status: Mock.Random.integer(0, 1),
- // 备注
- remark: '@cword(10, 15)'
- },
- {
- // 部门名称
- departmentName: '客服部',
- id: toAnyString(),
- createTime: '@datetime',
- // 状态
- status: Mock.Random.integer(0, 1),
- // 备注
- remark: '@cword(10, 15)'
- }
- ]
- })
- }
- export default [
- // 列表接口
- {
- url: '/mock/department/list',
- method: 'get',
- response: () => {
- return {
- code: SUCCESS_CODE,
- data: {
- list: departmentList
- }
- }
- }
- },
- {
- url: '/mock/department/table/list',
- method: 'get',
- response: () => {
- return {
- code: SUCCESS_CODE,
- data: {
- list: departmentList,
- total: 5
- }
- }
- }
- },
- {
- url: '/mock/department/users',
- method: 'get',
- timeout: 1000,
- response: ({ query }) => {
- const { pageSize } = query
- // 根据pageSize来创建数据
- const mockList: any = []
- for (let i = 0; i < pageSize; i++) {
- mockList.push(
- Mock.mock({
- // 用户名
- username: '@cname',
- // 账号
- account: '@first',
- // 邮箱
- email: '@EMAIL',
- // 创建时间
- createTime: '@datetime',
- // 用户id
- id: toAnyString()
- })
- )
- }
- return {
- code: SUCCESS_CODE,
- data: {
- total: 100,
- list: mockList
- }
- }
- }
- },
- // 保存接口
- {
- url: '/mock/department/user/save',
- method: 'post',
- timeout: 1000,
- response: () => {
- return {
- code: SUCCESS_CODE,
- data: 'success'
- }
- }
- },
- // 删除接口
- {
- url: '/mock/department/user/delete',
- method: 'post',
- response: ({ body }) => {
- const ids = body.ids
- if (!ids) {
- return {
- code: 500,
- message: '请选择需要删除的数据'
- }
- } else {
- return {
- code: SUCCESS_CODE,
- data: 'success'
- }
- }
- }
- },
- // 保存接口
- {
- url: '/mock/department/save',
- method: 'post',
- timeout: 1000,
- response: () => {
- return {
- code: SUCCESS_CODE,
- data: 'success'
- }
- }
- },
- // 删除接口
- {
- url: '/mock/department/delete',
- method: 'post',
- response: ({ body }) => {
- const ids = body.ids
- if (!ids) {
- return {
- code: 500,
- message: '请选择需要删除的数据'
- }
- } else {
- return {
- code: SUCCESS_CODE,
- data: 'success'
- }
- }
- }
- }
- ]
|