123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- const { mock } = require("mockjs");
- const List = [];
- const count = 50;
- for (let i = 0; i < count; i++) {
- List.push(mock({ uuid: "@uuid", id: "@id", title: "@title(1, 2)" }));
- }
- module.exports = [
- {
- url: "/{{name}}/getList",
- type: "get",
- response: (config) => {
- const { title, pageNo = 1, pageSize = 20 } = config.query;
- let mockList = List.filter((item) => {
- if (title && item.title.indexOf(title) < 0) return false;
- return true;
- });
- const pageList = mockList.filter(
- (item, index) =>
- index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
- );
- return {
- code: 200,
- msg: "success",
- totalCount: mockList.length,
- data: pageList,
- };
- },
- },
- {
- url: "/{{name}}/doEdit",
- type: "post",
- response: () => {
- return {
- code: 200,
- msg: "模拟保存成功",
- };
- },
- },
- {
- url: "/{{name}}/doDelete",
- type: "post",
- response: () => {
- return {
- code: 200,
- msg: "模拟删除成功",
- };
- },
- },
- ];
|