You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

400 lines
19 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { Request, Response } from 'express';
const getDataSource = (req: Request, res: Response) => {
const { key = '' , schema = '', data = ''} = req.query;
switch (key) {
case 'users':
res.json({
data: [
{
uid: '1',
name: 'John Brown',
age: 32,
address: 'New York No. 1 Lake Park',
idcard: '220101190101012001'
},
{
uid: '2',
name: 'Jim Green',
age: 42,
address: 'London No. 1 Lake Park',
idcard: '220101190101012002'
},
{
uid: '3',
name: 'Joe Black',
age: 32,
address: 'Sidney No. 1 Lake Park',
idcard: '220101190101012003'
}
]
})
break;
/*
* 考点数据
*/
case 'examination':
let obj = {};
if( schema === 'true' ){
obj = {
data: [
/*{ title: '序号',
dataIndex: 'index',
valueType: 'indexBorder',
width: 48
},*/
{
key: '1', // 确定这个列的唯一值,一般用于 dataIndex 重复的情况
dataIndex: 'code', // 与实体映射的 key数组会被转化 [a,b] => Entity.a.b
valueType: 'text', // 数据的渲渲染方式,我们自带了一部分,你可以可以自定义 valueType 参照 https://procomponents.ant.design/components/schema/
title: '考点代码', // 标题的内容,在 form 中是 label
tooltip: '参照准考证考点', // 会在 title 旁边展示一个 icon鼠标浮动之后展示
valueEnum: '', // 支持 object 和 MapMap 是支持其他基础类型作为 key
fieldProps: '', // 传给渲染的组件的 props自定义的时候也会传递
formItemProps: {
// 参照 https://ant.design/components/form-cn/#Rule
rules: [
{
required: true,
message: '此项为必填项',
},
{
max: 6,
message: '最大长度为6字符',
}
],
}, // 传递给 Form.Item 的配置
proFieldProps: '', // 设置到 ProField 上面的 props内部属性
//renderText: '', // 修改的数据是会被 valueType 定义的渲染组件消费
//render: '', // 自定义只读模式的 dom,render 方法只管理的只读模式,编辑模式需要使用 renderFormItem
//renderFormItem: '', // 自定义编辑模式,返回一个 ReactNode会自动包裹 value 和 onChange
request: null, // 从远程请求网络数据,一般用于选择类组件
params: null, // 额外传递给 request 的参数,组件不做处理,但是变化会引起request 重新请求数据
hideInDescriptions: true, // 在 descriptions 中隐藏
hideInForm: false, // 在 Form 中隐藏
hideInTable: false, // 在 Table 中隐藏
hideInSearch: false, // 在 Table 的查询表格中隐藏
columns:[], // 嵌套子项valueType 为 dependency 时,请使用(values) => ProFormColumnsType[]其他情况使用 ProFormColumnsType[]
width: 150
},
{
key: '2', // 确定这个列的唯一值,一般用于 dataIndex 重复的情况
dataIndex: 'name', // 与实体映射的 key数组会被转化 [a,b] => Entity.a.b
valueType: 'text', // 数据的渲渲染方式,我们自带了一部分,你可以可以自定义 valueType https://procomponents.ant.design/components/schema/
title: '考点名称', // 标题的内容,在 form 中是 label
tooltip: '参照准考证考点', // 会在 title 旁边展示一个 icon鼠标浮动之后展示
valueEnum: '', // 支持 object 和 MapMap 是支持其他基础类型作为 key
fieldProps: '', // 传给渲染的组件的 props自定义的时候也会传递
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
{
type: 'string',
message: '此项为文本内容',
},
{
max: 50,
message: '最大长度50',
}
],
}, // 传递给 Form.Item 的配置
proFieldProps: '', // 设置到 ProField 上面的 props内部属性
//renderText: '', // 修改的数据是会被 valueType 定义的渲染组件消费
//render: '', // 自定义只读模式的 dom,render 方法只管理的只读模式,编辑模式需要使用 renderFormItem
//renderFormItem: '', // 自定义编辑模式,返回一个 ReactNode会自动包裹 value 和 onChange
request: null, // 从远程请求网络数据,一般用于选择类组件
params: null, // 额外传递给 request 的参数,组件不做处理,但是变化会引起request 重新请求数据
hideInDescriptions: true, // 在 descriptions 中隐藏
hideInForm: false, // 在 Form 中隐藏
hideInTable: false, // 在 Table 中隐藏
hideInSearch: false, // 在 Table 的查询表格中隐藏
columns:[
{
key: '2-1', // 确定这个列的唯一值,一般用于 dataIndex 重复的情况
dataIndex: 'realname', // 与实体映射的 key数组会被转化 [a,b] => Entity.a.b
valueType: 'text', // 数据的渲渲染方式,我们自带了一部分,你可以可以自定义 valueType https://procomponents.ant.design/components/schema/
title: '姓名', // 标题的内容,在 form 中是 label
tooltip: '', // 会在 title 旁边展示一个 icon鼠标浮动之后展示
valueEnum: '', // 支持 object 和 MapMap 是支持其他基础类型作为 key
fieldProps: '', // 传给渲染的组件的 props自定义的时候也会传递
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
{
type: 'string',
message: '此项为文本内容',
},
{
max: 20,
message: '最大长度20',
}
],
}, // 传递给 Form.Item 的配置
proFieldProps: '', // 设置到 ProField 上面的 props内部属性
//renderText: '', // 修改的数据是会被 valueType 定义的渲染组件消费
//render: '', // 自定义只读模式的 dom,render 方法只管理的只读模式,编辑模式需要使用 renderFormItem
//renderFormItem: '', // 自定义编辑模式,返回一个 ReactNode会自动包裹 value 和 onChange
request: null, // 从远程请求网络数据,一般用于选择类组件
params: null, // 额外传递给 request 的参数,组件不做处理,但是变化会引起request 重新请求数据
hideInDescriptions: true, // 在 descriptions 中隐藏
hideInForm: true, // 在 Form 中隐藏
hideInTable: false, // 在 Table 中隐藏
hideInSearch: false, // 在 Table 的查询表格中隐藏
//columns:[] // 嵌套子项valueType 为 dependency 时,请使用(values) => ProFormColumnsType[]其他情况使用 ProFormColumnsType[]
}
] // 嵌套子项valueType 为 dependency 时,请使用(values) => ProFormColumnsType[]其他情况使用 ProFormColumnsType[]
},
{
key: '3', // 确定这个列的唯一值,一般用于 dataIndex 重复的情况
dataIndex: 'examiner', // 与实体映射的 key数组会被转化 [a,b] => Entity.a.b
valueType: 'text', // 数据的渲渲染方式,我们自带了一部分,你可以可以自定义 valueType https://procomponents.ant.design/components/schema/
title: '主考姓名及联系方式', // 标题的内容,在 form 中是 label
tooltip: '', // 会在 title 旁边展示一个 icon鼠标浮动之后展示
valueEnum: '', // 支持 object 和 MapMap 是支持其他基础类型作为 key
fieldProps: '', // 传给渲染的组件的 props自定义的时候也会传递
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
{
type: 'string',
message: '此项为文本内容',
},
{
max: 50,
message: '最大长度50',
}
],
}, // 传递给 Form.Item 的配置
proFieldProps: '', // 设置到 ProField 上面的 props内部属性
//renderText: '', // 修改的数据是会被 valueType 定义的渲染组件消费
//render: '', // 自定义只读模式的 dom,render 方法只管理的只读模式,编辑模式需要使用 renderFormItem
//renderFormItem: '', // 自定义编辑模式,返回一个 ReactNode会自动包裹 value 和 onChange
request: null, // 从远程请求网络数据,一般用于选择类组件
params: null, // 额外传递给 request 的参数,组件不做处理,但是变化会引起request 重新请求数据
hideInDescriptions: true, // 在 descriptions 中隐藏
hideInForm: true, // 在 Form 中隐藏
hideInTable: false, // 在 Table 中隐藏
hideInSearch: false, // 在 Table 的查询表格中隐藏
columns:[] // 嵌套子项valueType 为 dependency 时,请使用(values) => ProFormColumnsType[]其他情况使用 ProFormColumnsType[]
},
{
key: '4', // 确定这个列的唯一值,一般用于 dataIndex 重复的情况
dataIndex: 'examinationRoomTotal', // 与实体映射的 key数组会被转化 [a,b] => Entity.a.b
valueType: 'digit', // 数据的渲渲染方式,我们自带了一部分,你可以可以自定义 valueType https://procomponents.ant.design/components/schema/
title: '考场数', // 标题的内容,在 form 中是 label
hideInSearch: true, // 在 Table 的查询表格中隐藏
width: 150
},
{
key: '5', // 确定这个列的唯一值,一般用于 dataIndex 重复的情况
dataIndex: 'publicTelephone', // 与实体映射的 key数组会被转化 [a,b] => Entity.a.b
valueType: 'text', // 数据的渲渲染方式,我们自带了一部分,你可以可以自定义 valueType https://procomponents.ant.design/components/schema/
title: '公开电话', // 标题的内容,在 form 中是 label
},
{
key: '6', // 确定这个列的唯一值,一般用于 dataIndex 重复的情况
dataIndex: 'address', // 与实体映射的 key数组会被转化 [a,b] => Entity.a.b
valueType: 'text', // 数据的渲渲染方式,我们自带了一部分,你可以可以自定义 valueType https://procomponents.ant.design/components/schema/
title: '地址', // 标题的内容,在 form 中是 label
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
{
type: 'string',
message: '此项为文本内容',
},
{
max: 50,
message: '最大长度200',
}
],
}, // 传递给 Form.Item 的配置
},
{
key: '7', // 确定这个列的唯一值,一般用于 dataIndex 重复的情况
dataIndex: 'busRoute', // 与实体映射的 key数组会被转化 [a,b] => Entity.a.b
valueType: 'text', // 数据的渲渲染方式,我们自带了一部分,你可以可以自定义 valueType https://procomponents.ant.design/components/schema/
title: '乘车路线', // 标题的内容,在 form 中是 label
hideInTable: true, // 在 Table 中隐藏
hideInSearch: true, // 在 Table 的查询表格中隐藏
},
{
key: '8', // 确定这个列的唯一值,一般用于 dataIndex 重复的情况
dataIndex: 'electricLine', // 与实体映射的 key数组会被转化 [a,b] => Entity.a.b
valueType: 'text', // 数据的渲渲染方式,我们自带了一部分,你可以可以自定义 valueType https://procomponents.ant.design/components/schema/
title: '用电线路', // 标题的内容,在 form 中是 label
hideInTable: true, // 在 Table 中隐藏
}
]
}
}
if( data === 'true' ){
let _data = [];
for(let i=1; i<=30; i++){
const _str = i.toString().padStart(2, '0')
_data.push(
{
id: '000000001'+ _str,
code: '2017' + _str, // 考点代码
name: '长春高新第'+_str+'实验学校',
examiner: // 主考姓名及联系方式
{
realname: '张安开', // 姓名
tel: '819629' + _str, // 电话
mobile: '130214563' + _str // 手机
},
contact: // 考点联系人方式
{
realname: '安若昂', // 姓名
tel: '819625' + _str, // 电话
mobile: '130214567' + _str // 手机
},
secretRoom: // 保密室
{
tel: '819625' + _str // 电话
},
monitorRoom: // 监控室
{
tel: '819625' + _str // 电话
},
examinationRoomTotal: 30, // 考场数
publicTelephone: '819612' + _str, // 公开电话
address: '长春市高新区飞跃路' + _str + '号', // 地址
busRoute: _str +'225路202路', // 乘车路线
electricLine: '飞跃路线' + _str // 用电线路
}
)
}
obj = {
// DATA 数据记录
data: _data
}
}
res.json(obj)
break;
case 'notices':
res.json({
data: [
{
id: '000000001',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
title: '你收到了 14 份新周报',
datetime: '2017-08-09',
type: 'notification',
},
{
id: '000000002',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png',
title: '你推荐的 曲妮妮 已通过第三轮面试',
datetime: '2017-08-08',
type: 'notification',
},
{
id: '000000003',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/kISTdvpyTAhtGxpovNWd.png',
title: '这种模板可以区分多种通知类型',
datetime: '2017-08-07',
read: true,
type: 'notification',
},
{
id: '000000004',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png',
title: '左侧图标用于区分不同的类型',
datetime: '2017-08-07',
type: 'notification',
},
{
id: '000000005',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
title: '内容不要超过两行字,超出时自动截断',
datetime: '2017-08-07',
type: 'notification',
},
{
id: '000000006',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
title: '曲丽丽 评论了你',
description: '描述信息描述信息描述信息',
datetime: '2017-08-07',
type: 'message',
clickClose: true,
},
{
id: '000000007',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
title: '朱偏右 回复了你',
description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
datetime: '2017-08-07',
type: 'message',
clickClose: true,
},
{
id: '000000008',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
title: '标题',
description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
datetime: '2017-08-07',
type: 'message',
clickClose: true,
},
{
id: '000000009',
title: '任务名称',
description: '任务需要在 2017-01-12 20:00 前启动',
extra: '未开始',
status: 'todo',
type: 'event',
},
{
id: '000000010',
title: '第三方紧急代码变更',
description: '冠霖提交于 2017-01-06需在 2017-01-07 前完成代码变更任务',
extra: '马上到期',
status: 'urgent',
type: 'event',
},
{
id: '000000011',
title: '信息安全考试',
description: '指派竹尔于 2017-01-09 前完成更新并发布',
extra: '已耗时 8 天',
status: 'doing',
type: 'event',
},
{
id: '000000012',
title: 'ABCD 版本发布',
description: '冠霖提交于 2017-01-06需在 2017-01-07 前完成代码变更任务',
extra: '进行中',
status: 'processing',
type: 'event',
},
],
});
break;
default:
res.json({data:[]})
break;
}
}
export default {
'GET /api/dataSource': getDataSource,
};