知与行后台管理端

ActivityList.jsx 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. import React from 'react';
  2. import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal } from 'antd';
  3. import { FormattedMessage } from 'umi-plugin-react/locale';
  4. import styles from '../style/GoodsList.less';
  5. import router from 'umi/router';
  6. const { Option } = Select;
  7. // 提交事件
  8. function handleSubmit(e, props) {
  9. e.preventDefault();
  10. props.form.validateFields((err, values) => {
  11. if (!err) {
  12. console.log('提交数据: ', values)
  13. }
  14. });
  15. }
  16. // Change 事件
  17. function handleSelectChange(props) {
  18. console.log(props)
  19. }
  20. // 分页
  21. function onChange(pageNumber) {
  22. console.log('Page: ', pageNumber);
  23. }
  24. // 跳转到编辑商品
  25. function toEditGoods() {
  26. router.push({
  27. pathname: '/activity/editActivity',
  28. query: {
  29. a: 'b',
  30. },
  31. });
  32. }
  33. /**
  34. *
  35. *
  36. * @param {*} props
  37. * @returns
  38. */
  39. const dataSource = [
  40. {
  41. key: '1',
  42. img: 'http://img0.imgtn.bdimg.com/it/u=4246326797,2657995307&fm=26&gp=0.jpg',
  43. name: '华为P30 Pro',
  44. },
  45. {
  46. key: '2',
  47. img: '',
  48. name: '大米',
  49. },
  50. ];
  51. const columns = [
  52. {
  53. title: '商品图片',
  54. dataIndex: 'img',
  55. key: 'img',
  56. align: 'center',
  57. render: (text, record) => <img src={record.img} className={styles.touxiang} />,
  58. },
  59. {
  60. title: '商品名称',
  61. dataIndex: 'name',
  62. key: 'name',
  63. align: 'center',
  64. },
  65. {
  66. title: '所属积分',
  67. dataIndex: 'integral',
  68. key: 'integral',
  69. align: 'center',
  70. },
  71. {
  72. title: '总数量',
  73. dataIndex: 'total',
  74. key: 'total',
  75. align: 'center',
  76. },
  77. {
  78. title: '已兑换数量',
  79. dataIndex: 'exchanged',
  80. key: 'exchanged',
  81. align: 'center',
  82. },
  83. {
  84. title: '剩余数量',
  85. dataIndex: 'rest',
  86. key: 'rest',
  87. align: 'center',
  88. },
  89. {
  90. title: '状态',
  91. dataIndex: 'state',
  92. key: 'state',
  93. align: 'center',
  94. },
  95. {
  96. title: '操作',
  97. dataIndex: 'handle',
  98. key: 'handle',
  99. align: 'center',
  100. render: () => <><span style={{ color: '#1990FF', marginRight: '20px' }} onClick={confirm}>下架<Icon type="shopping-cart" className={styles.shoppingCart} /></span><span style={{ color: '#FF925C' }}>编辑<Icon type="form" className={styles.edit} /></span></>,
  101. },
  102. ];
  103. const confirm = () => {
  104. Modal.confirm({
  105. title: '确认下架该商品?',
  106. okText: '确认',
  107. cancelText: '取消',
  108. onOk() {
  109. console.log('OK');
  110. },
  111. onCancel() {
  112. console.log('Cancel');
  113. },
  114. });
  115. }
  116. const header = (props) => {
  117. const { getFieldDecorator } = props.form
  118. return (
  119. <>
  120. <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
  121. <Form.Item>
  122. {getFieldDecorator('name')(
  123. <Input
  124. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  125. placeholder="商品名称"
  126. />,
  127. )}
  128. </Form.Item>
  129. <Form.Item>
  130. {getFieldDecorator('goodState')(
  131. <Select style={{ width: '180px' }} placeholder="状态" onChange={handleSelectChange}>
  132. <Option value="1">上架</Option>
  133. <Option value="0">下架</Option>
  134. </Select>,
  135. )}
  136. </Form.Item>
  137. <Form.Item>
  138. {getFieldDecorator('isMain')(
  139. <Select style={{ width: '180px' }} placeholder="所属项目" onChange={handleSelectChange}>
  140. <Option value="1">首页推荐</Option>
  141. <Option value="0">首页未推荐</Option>
  142. </Select>,
  143. )}
  144. </Form.Item>
  145. <Form.Item>
  146. {getFieldDecorator('min')(
  147. <Input
  148. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  149. placeholder="最小积分"
  150. />,
  151. )}
  152. </Form.Item>
  153. <Form.Item>
  154. {getFieldDecorator('max')(
  155. <Input
  156. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  157. placeholder="最大积分"
  158. />,
  159. )}
  160. </Form.Item>
  161. <Form.Item>
  162. <Button type="primary" htmlType="submit" className={styles.searchBtn}>
  163. 搜索
  164. </Button>
  165. </Form.Item>
  166. </Form>
  167. <Button type="primary" className={styles.addBtn} onClick={toEditGoods}>新增</Button>
  168. <Table dataSource={dataSource} columns={columns} />
  169. {/* 分页 */
  170. /* <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
  171. <Pagination showQuickJumper defaultCurrent={1} total={500} onChange={onChange} />
  172. </div> */}
  173. </>
  174. )
  175. }
  176. const WrappedHeader = Form.create({ name: 'header' })(header);
  177. export default WrappedHeader