import { Snippet } from '@alilc/lowcode-types' const getColumns = () => { return [ { title: '姓名', dataIndex: 'name', valueType: 'text' }, { title: '年龄', dataIndex: 'age', valueType: 'digit' }, { 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: 'trade_progress', valueType: 'progress' }, { title: '公司网址', dataIndex: 'link', valueType: 'link', copyable: true }, { title: '地址', dataIndex: 'address', valueType: 'tag' }, { title: '创建时间', dataIndex: 'create_time', valueType: 'dateTime' } ] } const getDataSource = () => { return [ { id: '1', name: '小王', age: 30, link: 'https://www.chinaunicom.com/', loan: 700000, trade_progress: 17, address: '公园路1号', create_time: '2022-04-21 21:00', status: 'close' }, { id: '2', name: '小李', age: 28, link: 'https://www.chinaunicom.com/', loan: 600000, trade_progress: 36, address: '滨海路699号', create_time: '2022-04-21 22:00', status: 'running' } ] } export const snippets: Snippet[] = [ { title: 'CRUD 表格', screenshot: 'https://alifd.alicdn.com/fusion-cool/icons/icon-antd/table-1.png', schema: { componentName: 'ProTable', props: { cardBordered: true, dataSource: getDataSource(), columns: [ ...getColumns(), { title: '操作', dataIndex: 'options', valueType: 'option', align: 'left', fixed: '', render: { type: 'JSSlot', params: ['text', 'record', 'index'], value: [ { componentName: 'Button', props: { type: 'link', children: '编辑', htmlType: 'button', size: 'small', shape: 'default', block: false, danger: false, ghost: false, disabled: false, icon: '' } }, { componentName: 'ProPopconfirm', props: { title: '确定删除?', okType: 'primary', okText: '确定', cancelText: '取消' }, children: [ { componentName: 'Button', props: { children: '删除', htmlType: 'button', type: 'link', size: 'small', shape: 'default', block: false, danger: true, ghost: false, disabled: false, icon: '' } } ] } ] } } ], rowKey: 'id', pagination: { defaultPageSize: 10 }, search: { defaultCollapsed: false, resetText: '', searchText: '', labelWidth: 'auto' }, 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' } } }, { title: '查询表格', screenshot: 'https://alifd.alicdn.com/fusion-cool/icons/icon-antd/table-1.png', schema: { componentName: 'ProTable', props: { cardBordered: true, dataSource: getDataSource(), columns: getColumns(), rowKey: 'id', pagination: { defaultPageSize: 10 }, search: { defaultCollapsed: false, resetText: '', searchText: '', labelWidth: 'auto' }, intl: 'zhCNIntl' } } }, { title: '嵌套表格', screenshot: 'https://alifd.alicdn.com/fusion-cool/icons/icon-antd/table-1.png', schema: { componentName: 'ProTable', props: { cardBordered: true, dataSource: getDataSource(), columns: getColumns(), rowKey: 'id', pagination: { defaultPageSize: 10 }, expandable: { expandedRowRender: { type: 'JSSlot', params: ['record', 'index', 'indent', 'expanded'], value: [ { componentName: 'ProTable', props: { columns: [ { title: 'Date', dataIndex: 'date', key: 'date' }, { title: 'Name', dataIndex: 'name', key: 'name' }, { title: 'Upgrade Status', dataIndex: 'upgradeNum', key: 'upgradeNum' } ], headerTitle: false, search: false, options: false, dataSource: [ { key: 0, date: '2014-12-24 23:12:00', name: 'This is production name', upgradeNum: 'Upgraded: 56' }, { key: 1, date: '2014-12-24 23:12:00', name: 'This is production name', upgradeNum: 'Upgraded: 57' }, { key: 2, date: '2014-12-24 23:12:00', name: 'This is production name', upgradeNum: 'Upgraded: 58' } ], pagination: false } } ] } }, intl: 'zhCNIntl' } } } ]