123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- import { defineMock } from './base'
- export default defineMock([
- {
- url: 'dict/:code/options',
- method: ['GET'],
- body: ({ params }) => {
- const typeCode = params.code
- let list = null
- if (typeCode == 'gender') {
- list = [
- {
- value: '1',
- label: '男'
- },
- {
- value: '2',
- label: '女'
- },
- {
- value: '0',
- label: '未知'
- }
- ]
- }
- return {
- code: '200',
- data: list,
- message: '一切ok'
- }
- }
- },
- {
- url: 'dict/types/page',
- method: ['GET'],
- body: {
- code: '200',
- data: {
- list: [
- {
- id: 1,
- name: '性别',
- code: 'gender',
- status: 1
- },
- {
- id: 2,
- name: '状态',
- code: 'status',
- status: 1
- }
- ],
- total: 2
- },
- message: '一切ok'
- }
- },
- {
- url: 'dict/page',
- method: ['GET'],
- body: {
- code: '200',
- data: {
- list: [
- {
- id: 1,
- name: '男',
- value: '1',
- status: 1
- },
- {
- id: 2,
- name: '女',
- value: '2',
- status: 1
- },
- {
- id: 3,
- name: '未知',
- value: '0',
- status: 1
- }
- ],
- total: 3
- },
- message: '一切ok'
- }
- },
- // 新增字典类型
- {
- url: 'dict/types',
- method: ['POST'],
- body({ body }) {
- return {
- code: '200',
- data: null,
- message: '新增字典类型' + body.name + '成功'
- }
- }
- },
- // 获取字典类型表单数据
- {
- url: 'dict/types/:id/form',
- method: ['GET'],
- body: ({ params }) => {
- return {
- code: '200',
- data: dictTypeMap[params.id],
- message: '一切ok'
- }
- }
- },
- // 修改字典类型
- {
- url: 'dict/types/:id',
- method: ['PUT'],
- body({ body }) {
- return {
- code: '200',
- data: null,
- message: '修改字典类型' + body.name + '成功'
- }
- }
- },
- // 删除字典类型
- {
- url: 'dict/types/:id',
- method: ['DELETE'],
- body({ params }) {
- return {
- code: '200',
- data: null,
- message: '删除字典类型' + params.id + '成功'
- }
- }
- },
- // 新增字典
- {
- url: 'dict',
- method: ['POST'],
- body({ body }) {
- return {
- code: '200',
- data: null,
- message: '新增字典' + body.name + '成功'
- }
- }
- },
- // 获取字典表单数据
- {
- url: 'dict/:id/form',
- method: ['GET'],
- body: ({ params }) => {
- return {
- code: '200',
- data: dictMap[params.id],
- message: '一切ok'
- }
- }
- },
- // 修改字典
- {
- url: 'dict/:id',
- method: ['PUT'],
- body({ body }) {
- return {
- code: '200',
- data: null,
- message: '修改字典类型' + body.name + '成功'
- }
- }
- },
- // 删除字典
- {
- url: 'dict/:id',
- method: ['DELETE'],
- body({ params }) {
- return {
- code: '200',
- data: null,
- message: '删除字典' + params.id + '成功'
- }
- }
- }
- ])
- // 字典类型映射表数据
- const dictTypeMap: Record<string, any> = {
- 1: {
- id: 1,
- name: '性别',
- code: 'gender',
- status: 1,
- remark: null
- },
- 2: {
- id: 2,
- name: '状态',
- code: 'status',
- status: 1,
- remark: null
- }
- }
- // 字典映射表数据
- const dictMap: Record<string, any> = {
- 1: {
- id: 1,
- typeCode: 'gender',
- name: '男',
- value: '1',
- status: 1,
- sort: 1,
- remark: null
- },
- 2: {
- id: 2,
- typeCode: 'gender',
- name: '女',
- value: '2',
- status: 1,
- sort: 2,
- remark: null
- },
- 3: {
- id: 3,
- typeCode: 'gender',
- name: '未知',
- value: '0',
- status: 1,
- sort: 1,
- remark: null
- }
- }
|