To repair

In mock, create index.js

import Mock from 'mockjs'
import {baseUrl} from '@/utils/global'

import * as login from './modules/login'
import * as user from './modules/user'
import * as dept from './modules/dept'
import * as role from './modules/role'
import * as menu from './modules/menu'
import * as dict from './modules/dict'
import * as config from './modules/config'
import * as log from './modules/log'
import * as loginlog from './modules/loginlog'//1. Enable/disable all modules interception by calling the openMock argument to set //2. Enable/disable [business module] interception by calling fnCreate method [isOpen parameter] to set //3. Enable/disable the interception of a request in the business module, and return the isOpen property setting in the object through the functionlet openMock = true;
//let openMock = false;
fnCreate(login,openMock);
fnCreate(user,openMock);
fnCreate(dept,openMock);
fnCreate(role,openMock);
fnCreate(menu,openMock);
fnCreate(dict,openMock);
fnCreate(config,openMock);
fnCreate(log,openMock); fnCreate(loginlog,openMock); @param {*} mod @param {*} isOpen Enabled? * /function fnCreate(mod,isOpen=true) {if(isOpen){
        for(var key in mod){
            ((res)=>{
                if(res.isOpen! = =false) {let url = baseUrl
                    if(! url,endsWith("/")){
                        url = url+'/'
                    }
                    url = url+res.url
                    Mock.mock(new RegExp(url),res.type,(opts)=>{
                        opts['data'] = opts.body ? JSON.parse(opts.body) : null
                        delete opts.body
                        console.log('\n');
                        console.log('% cMock intercepts, request :'.'color:bulue',opts);
                        console.log('% cMock intercept, response: '.'color:blue',res.data);
                    })
                }
            })(mod[key]()|| {})
        }
    }
}
Copy the code

In modules, modify user.js

import axios from '.. /axios'/* User management module */ // saveexport function save() {return {url:'/user/save',method:'post',data:{"code": 200,"msg":null,"data"/ / : 1}}}export const save = (data) =>{
//     return axios({url:'/user/save',method:'post',data}) //} // deleteexport function batchDelete() {return {url:'/user/delete',method:'post',data:{"code": 200,"msg":null,"data"/ / : 1}}}export const batchDelete = (data) =>{
//     return axios({url:'/user/delete',method:'post',data}) //} // paging queryexport function findPage(params){
    let findPageData = {"code": 200,"msg":null,"data": {}}let pageNum = 1;
    let pageSize = 8;
    let content = this.getContent(pageNum,pageSize);
    
    findPageDate.data.pageNum = pageNum;
    findPageDate.data.pageSize = pageSize;
    findPageDate.data.totalSize = 50;
    findPageDate.data.content = content;

    return {url:'/user/findPage',method:'post',data:findPageData}
}
// export const findPage = (data) =>{
//     return axios({url:'/user/findPage',method:'post',data})
// }

export function getContent(pageNum,pageSize){
    let content = [];
    for(leti=0; i<pageSize; i++){let obj = {};
        let index = ((pageNum-1)*pageSize)+i+1
         obj.id = index
         obj.name = "mango"+index
         obj.password = "9ec9750e709431dad22365cabc5c625482e"
         obj.salt = "YzcmCZNvbXorsz9dm8e"
         obj.email = "mango"+index+"@qq.com"
         obj.mobile = "18688982323"
         obj.status = 1
         obj.deptId = 12
         obj.deptName ="Technical Department"
         obj.status = 1
         if(i%2===0){
            obj.detId = 13
            obj.deptName = 'Marketing Department'
         }
         obj.createBy = "admin"
         obj.createTime = "The 2018-08-14 11:11:11"
         obj.createBy = "admin"
         obj.ctrateTime ="The 2018-09-14 12:12:12"
         content.push(obj)
    }
    returnContent} // Find the user's menu permission identity set //export const findPermissions = (params) =>{
//     return axios({url:'/user/findPermissions',method:'get',params})
// }
export function findPermisstions() {let permsData = {"code": 200,"msg":null,data:["sys:user:view"."sys:menu:delete"]}
     return {url:'user/findPermissions'.type:"get",data:permsData}
}
Copy the code