知与行后台管理端

index.jsx 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. import React from 'react';
  2. import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination } from 'antd';
  3. import { connect } from 'dva';
  4. import Styles from './style.less';
  5. const { Option } = Select;
  6. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  7. const { Meta } = Card;
  8. // 假数据
  9. const tempData = [
  10. {
  11. code: 'S101',
  12. name: '城开花园',
  13. price: '111',
  14. address: '顾戴路1801弄',
  15. status: '1', // 已发布
  16. createDate: '2019-08-28 17',
  17. },
  18. {
  19. code: 'S102',
  20. name: '星河天街',
  21. price: '111',
  22. address: '长征路1801弄',
  23. status: '1', // 已发布
  24. createDate: '2019-08-29 17',
  25. },
  26. {
  27. code: 'S103',
  28. name: '喜洋洋别墅',
  29. price: '111',
  30. address: '阳杨路1801弄',
  31. status: '1', // 已发布
  32. createDate: '2019-08-29 17',
  33. },
  34. {
  35. code: 'S104',
  36. name: '武大郎洋房',
  37. price: '111',
  38. address: '太郎路1801弄',
  39. status: '1', // 已发布
  40. createDate: '2019-08-29 17',
  41. },
  42. ]
  43. // 网路数据请求
  44. connect(({ getList, loading }) => ({
  45. getList,
  46. submitting: loading.effects['building/getList'],
  47. }))
  48. // 提交事件
  49. function handleSubmit(e, props) {
  50. e.preventDefault();
  51. props.form.validateFields((err, values) => {
  52. if (!err) {
  53. // eslint-disable-next-line no-console
  54. console.log('提交数据: ', values)
  55. }
  56. });
  57. }
  58. // Change 事件
  59. function handleSelectChange(props) {
  60. // eslint-disable-next-line no-console
  61. console.log(props)
  62. }
  63. // 分页
  64. function onChange(pageNumber) {
  65. // eslint-disable-next-line no-console
  66. console.log('Page: ', pageNumber);
  67. }
  68. /**
  69. *卡片
  70. *
  71. * @returns
  72. */
  73. function CartBody(props) {
  74. const { data } = props
  75. return (
  76. <Card
  77. hoverable
  78. style={{ minWidth: '400px', borderRadius: '12px', margin: '10px', boxShadow: '0px 0px 16px 2px rgba(0,0,0,0.12)' }}
  79. cover={<img alt="example" src="https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png" style={{ borderRadius: '12px 12px 0 0', width: '100%', height: '14vw' }}></img>}
  80. bodyStyle={{ padding: '10px 20px' }}
  81. >
  82. <p className={Styles.cardText}>
  83. <span className={Styles.title}>楼盘编号</span>
  84. <span >:{ data.code }</span>
  85. <span className={Styles.ediText}>
  86. 编辑
  87. <Icon type="form" style={{ color: '#C0C4CC', marginLeft: '10px' }} />
  88. </span>
  89. </p>
  90. <p className={Styles.cardText}>
  91. <span className={Styles.title}>楼盘名称</span>
  92. <span >:{ data.name }</span>
  93. </p>
  94. <p className={Styles.cardItem}>
  95. <span className={Styles.title}>均价</span>
  96. <span >
  97. :约<span style={{ color: '#FF0707', fontSize: '20px' }}> { data.price } </span>元/m
  98. </span>
  99. </p>
  100. <p className={Styles.cardItem}>
  101. <span className={Styles.title}>项目地址</span>
  102. <span >:{ data.address }</span>
  103. </p>
  104. <p className={Styles.cardItem}>
  105. <span className={Styles.title}>发布状态</span>
  106. <span >:{ data.status === '1' ? '已发布' : '未发布' }</span>
  107. </p>
  108. <p className={Styles.cardItem}>
  109. <span className={Styles.title}>录入时间</span>
  110. <span >:2019-08-28 17</span>
  111. </p>
  112. <p style={{ margin: '15px 0', position: 'relative', fontSize: '18px' }}>
  113. <span style={{ color: '#1990FF' }}>
  114. 取消发布
  115. <Icon type="close-circle" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
  116. </span>
  117. <span style={{
  118. color: '#FF4A4A', position: 'absolute', right: '0',
  119. }} >
  120. 删除
  121. <Icon type="rest" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
  122. </span>
  123. </p>
  124. </Card>
  125. )
  126. }
  127. /**
  128. *
  129. *
  130. * @param {*} props
  131. * @returns
  132. */
  133. function body(props) {
  134. const { getFieldDecorator } = props.form
  135. connect()
  136. return (
  137. <>
  138. <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
  139. <Form.Item>
  140. {getFieldDecorator('code')(
  141. <Input
  142. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  143. placeholder="楼盘编号"
  144. />,
  145. )}
  146. </Form.Item>
  147. <Form.Item>
  148. {getFieldDecorator('name')(
  149. <Input
  150. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  151. type="password"
  152. placeholder="楼盘名称"
  153. />,
  154. )}
  155. </Form.Item>
  156. <Form.Item>
  157. {getFieldDecorator('startDate')(
  158. <DatePicker placeholder="开盘时间" />,
  159. )}
  160. </Form.Item>
  161. <Form.Item>
  162. {getFieldDecorator('buildingStatus')(
  163. <Select style={{ width: '180px' }} placeholder="楼盘状态" onChange={handleSelectChange}>
  164. <Option value="1">发布</Option>
  165. <Option value="0">未发布</Option>
  166. </Select>,
  167. )}
  168. </Form.Item>
  169. <Form.Item>
  170. {getFieldDecorator('marketStatus')(
  171. <Select style={{ width: '180px' }} placeholder="销售状态" onChange={handleSelectChange}>
  172. <Option value="1">已销售</Option>
  173. <Option value="0">未销售</Option>
  174. </Select>,
  175. )}
  176. </Form.Item>
  177. <Form.Item>
  178. {getFieldDecorator('cityId')(
  179. <Select style={{ width: '180px' }} placeholder="城市" onChange={handleSelectChange}>
  180. <Option value="male">male</Option>
  181. <Option value="female">female</Option>
  182. </Select>,
  183. )}
  184. </Form.Item>
  185. <Form.Item>
  186. {getFieldDecorator('isMain')(
  187. <Select style={{ width: '180px' }} placeholder="首页推荐" onChange={handleSelectChange}>
  188. <Option value="1">首页推荐</Option>
  189. <Option value="0">首页未推荐</Option>
  190. </Select>,
  191. )}
  192. </Form.Item>
  193. <Form.Item>
  194. <Button type="primary" htmlType="submit" className={Styles.SubmitButton}>
  195. 搜索
  196. </Button>
  197. </Form.Item>
  198. </Form>
  199. <Button type="primary" className={Styles.addButton}>
  200. 新增楼盘
  201. </Button>
  202. {/* 卡片内容,显示楼盘项目 */}
  203. <Row style={{ padding: ' 0 10px' }}>
  204. {
  205. tempData.map((item, index) => (
  206. <Col span={8}>
  207. <CartBody data={item} />
  208. </Col>
  209. ))
  210. }
  211. </Row>
  212. {/* 分页 */}
  213. <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
  214. <Pagination showQuickJumper defaultCurrent={1} total={500} onChange={onChange} />
  215. </div>
  216. </>
  217. );
  218. }
  219. const WrappedBody = Form.create({ name: 'body' })(body);
  220. export default WrappedBody