【后台管理系统】—— Ant Design Pro 页面相关(三)
2024-08-30 03:30:36
一、卡片Card分类
- 与普通卡片使用区别:底部按钮及内容样式
<Card
hoverable
bodyStyle={{ paddingBottom: 20 }}
actions={[ // 卡片操作组,位置在卡片底部
<Button size='large' onClick={() => this.showEditModal(item)}>修改</Button>,
<Popconfirm title="是否要删除此孵化企业?" onConfirm={() => this.deleteItem(item)}>
<Button type='danger' size='large'>删除</Button>
</Popconfirm>
]}
>
<Card.Meta avatar={<Avatar size="small" src={`${setFileHost() + item.comLogo}`} />} title={item.comName} /> //头像、类名、描述等,位置在卡片左侧
<div className={styles.cardItemContent}>
<CardInfo
productCount={item.productCount}
/>
</div>
</Card>
- 动态添加卡片分类:List的dataSource数组第一个位置为空串,遍历时,遇到item渲染卡片,否则ListItem中包裹自定义按钮
<List
rowKey="id"
loading={loading}
grid={{ gutter: 24, lg: 3, md: 2, sm: 1, xs: 1 }}
dataSource={['', ...list]} // 构建第一个位置为空串的list数组
renderItem={item =>
item ? (
<List.Item key={item.id}>
<Card hoverable className={styles.card}
actions={[ <a onClick={() => this.editCategory(item)}>修改</a>,
<Popconfirm title="是否要删除此分类?" onConfirm={() => this.deleteCategory(item)}>
<a style={{color: 'red'}}>删除</a>
</Popconfirm>
]}>
<Card.Meta
avatar={<img alt="" className={styles.cardAvatar} src={`${setFileHost() + item.categoryLogo }`} />}
title={<a style={{ fontWeight: 600 }}>{item.categoryName}</a>}
description={
<Ellipsis className={styles.item} lines={3}>
{`共 ${item.productCount}个商品`}
</Ellipsis>
}
/>
</Card>
</List.Item>
) : (
<List.Item> // 空串位置 渲染按钮
<Button type="dashed" className={styles.newButton} onClick={() => this.addCategory()}>
<Icon type="plus" /> 新增分类
</Button>
</List.Item>
)
/>
二、分布表单
- <Step/>步骤条组件的使用,current指定当前步骤,从 0 开始记数
export default class StepForm extends PureComponent {
getCurrentStep() {
const { location } = this.props;
const { pathname } = location;
const pathList = pathname.split('/');
switch (pathList[pathList.length - 1]) {
case 'info':
return 0;
case 'confirm':
return 1;
case 'result':
return 2;
default:
return 0;
}
} render() {
const { location, children } = this.props; return (
<PageHeaderWrapper
title="分步表单"
tabActiveKey={location.pathname}
content="将一个冗长或用户不熟悉的表单任务分成多个步骤,指导用户完成。"
>
<Card bordered={false}>
<Fragment>
<Steps current={this.getCurrentStep()} className={styles.steps}>
<Step title="填写转账信息" />
<Step title="确认转账信息" />
<Step title="完成" />
</Steps>
{children} // 可直接写为三个状态对应的三个表单子组件
</Fragment>
</Card>
</PageHeaderWrapper>
);
}
}有个疑问:框架自带Mock页面Form->StepForm->index.js、step1.js、step2.js、step3.js实现切换表单的方式还没弄明白。。。
注:转载请注明出处
最新文章
- [deviceone开发]-小草用户分享的Listview停靠的示例
- C++设计模式——简单工厂模式
- 【knowledgebase】不要在一个很大的RDD上调用collect
- 从你的u盘启动:30天自制操作系统第四天u盘启动学习笔记
- COJ 0026 汉诺塔问题
- RenderBody, RenderPage and RenderSection methods in MVC 3
- jsp中获取json字符串,并解析
- iOS拨打电话
- WPF 自定义图表(柱状图,曲线图)
- Vue基本使用
- Android中自定义广播的实现
- Let Encrypt延期(转自虞大胆的叽叽喳喳)
- 使用NetBox实现ASP网页封装为EXE教程
- linux ping命令
- cqlsh 一个错误
- 【问题定位】tcpdump 抓包简易命令
- Croc Champ 2013 - Round 1 E. Copying Data 线段树
- shell命令技巧——文本去重并保持原有顺序
- ZT ANDROID jni 中的事件回调机制JNIenv的使用 2012-09-10 12:53:01
- fatal: read error: Connection reset by peer解决办法