import { IPublicTypeSnippet } from '@alilc/lowcode-types' const getColumns = () => { return [ { title: '姓名', dataIndex: 'name', valueType: 'text' }, { title: '年龄', dataIndex: 'age', valueType: 'digit' }, { title: '性别', dataIndex: 'gender', valueType: 'select' }, { title: '头像', dataIndex: 'avatar', valueType: 'avatar' }, { title: '状态', dataIndex: 'status', renderTag: true, valueEnum: { all: { text: '全部', status: 'Default' }, close: { text: '关闭', status: 'Default' }, running: { text: '运行中', status: 'Processing' }, online: { text: '已上线', status: 'Success' }, error: { text: '异常', status: 'Error' } } }, { title: '贷款金额', dataIndex: 'loan', valueType: 'money' }, { title: '交易进度', dataIndex: 'trade_progress', valueType: 'progress' }, // { // title: '个人简介', // dataIndex: 'link', // valueType: 'link', // copyable: true // }, // { // title: '地址', // dataIndex: 'address', // valueType: 'tag' // }, { title: '创建日期', dataIndex: 'create_date', valueType: 'date' }, { title: '更新时间', dataIndex: 'update_time', valueType: 'time' }, ] } const generateMockData = (count: number) => { // 预设一些随机数据池 const firstNames = ['张', '王', '李', '赵', '刘', '陈', '杨', '黄', '周', '吴']; const lastNames = ['伟', '芳', '娜', '秀英', '敏', '静', '丽', '强', '磊', '洋']; const avatarUrls = [ 'https://randomuser.me/api/portraits/men/', 'https://randomuser.me/api/portraits/women/' ]; const cities = ['杭州', '北京', '上海', '广州', '深圳', '成都', '武汉']; const districts = ['西湖区', '滨江区', '上城区', '下城区', '江干区', '拱墅区']; const streets = ['网商路', '学院路', '文一路', '文二路', '文三路', '莫干山路']; const statusList = ['close', 'running', 'online', 'error']; return Array.from({ length: count }, (_, index) => { const randomId = (index + 1).toString(); const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)]; const randomLastName = lastNames[Math.floor(Math.random() * lastNames.length)]; const gender = Math.random() > 0.5 ? 'men' : 'women'; const avatarNumber = Math.floor(Math.random() * 70) + 1; return { id: randomId, name: randomFirstName + randomLastName, age: Math.floor(Math.random() * 40) + 20, // 20-60岁 avatar: `${avatarUrls[gender === 'men' ? 0 : 1]}${avatarNumber}.jpg`, status: statusList[Math.floor(Math.random() * statusList.length)], loan: Math.floor(Math.random() * 900000) + 100000, // 10-100万 trade_progress: Math.floor(Math.random() * 100), // 0-100 // link: `https://example.com/profile/${randomId}`, // address: `${cities[Math.floor(Math.random() * cities.length)]}${ // districts[Math.floor(Math.random() * districts.length)] // }${streets[Math.floor(Math.random() * streets.length)]}${ // Math.floor(Math.random() * 1000) + 1 // }号`, create_date: (() => { const date = new Date(); date.setDate(date.getDate() - Math.floor(Math.random() * 365)); // 最近一年内 // date.setHours(Math.floor(Math.random() * 24)); // date.setMinutes(Math.floor(Math.random() * 60)); return date.toISOString().replace('T', ' ').substring(0, 10); })(), update_time: `${Math.floor(Math.random() * 24)}:${Math.floor(Math.random() * 60)}:${Math.floor(Math.random() * 60)}`, // 随机时间 }; }); }; // 生成100条数据 const getDataSource = generateMockData(50); export const snippets: IPublicTypeSnippet[] = [ { title: '可编辑表格', screenshot: 'https://img.alicdn.com/imgextra/i4/O1CN01dtjMvv1heoyqst9u5_!!6000000004303-55-tps-56-56.svg', // 'https://alifd.alicdn.com/fusion-cool/icons/icon-antd/table-1.png', schema: { componentName: 'EditProTable', props: { // cardBordered: true, // dataSource: getDataSource, // columns: [ // ...getColumns(), // ], dataSource: {}, columns: [], rowKey: 'id', pagination: { showSizeChanger: true, showQuickJumper: true, }, // search: { // defaultCollapsed: false, // resetText: '', // searchText: '', // labelWidth: 'auto' // }, // toolBarRenderOpen: true, // toolBarRender: { // type: 'JSSlot', // params: ['currentPageData'], // value: [ // { // componentName: 'Button', // props: { // type: 'primary', // children: '新增', // htmlType: 'button', // size: 'middle', // shape: 'default', // icon: { // type: 'JSSlot', // value: [ // { // componentName: 'Icon', // props: { // type: 'PlusOutlined', // size: 16, // rotate: 0, // spin: false // } // } // ] // }, // block: false, // danger: false, // ghost: false, // disabled: false // } // } // ] // }, // intl: 'zhCNIntl' } } } ]