|
@@ -0,0 +1,220 @@
|
|
1
|
+import React, { useState, useEffect } from 'react';
|
|
2
|
+import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal,Breadcrumb } from 'antd';
|
|
3
|
+import { FormattedMessage } from 'umi-plugin-react/locale';
|
|
4
|
+import styles from '../style/GoodsList.less';
|
|
5
|
+import router from 'umi/router';
|
|
6
|
+import BuildSelect from '../../components/SelectButton/BuildSelect'
|
|
7
|
+import apis from '../../services/apis';
|
|
8
|
+import request from '../../utils/request'
|
|
9
|
+import AuthButton from '@/components/AuthButton';
|
|
10
|
+
|
|
11
|
+const { Option } = Select;
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+function header(props) {
|
|
15
|
+ // 获取初始化数据
|
|
16
|
+ const [ data, setData ] = useState({})
|
|
17
|
+
|
|
18
|
+ useEffect(() => {
|
|
19
|
+ getList({ pageNum: 1, pageSize: 10 });
|
|
20
|
+ },[])
|
|
21
|
+
|
|
22
|
+ // 查询列表
|
|
23
|
+ const getList = (params) => {
|
|
24
|
+ request({ ...apis.integralMall.getTaGoods, params: { ...params },}).then((data) => {
|
|
25
|
+ console.log(data)
|
|
26
|
+ setData(data)
|
|
27
|
+ })
|
|
28
|
+ }
|
|
29
|
+
|
|
30
|
+ // 提交事件
|
|
31
|
+ const handleSubmit = (e, props) => {
|
|
32
|
+ e.preventDefault();
|
|
33
|
+ props.form.validateFields((err, values) => {
|
|
34
|
+ if (!err) {
|
|
35
|
+ getList({ pageNum: 1, pageSize: 10, ...values })
|
|
36
|
+ }
|
|
37
|
+ });
|
|
38
|
+ }
|
|
39
|
+
|
|
40
|
+ const changePageNum = (pageNumber) => {
|
|
41
|
+ props.form.validateFields((err, values) => {
|
|
42
|
+ if (!err) {
|
|
43
|
+ getList({ pageNumber: pageNumber, pageSize: 10, ...values })
|
|
44
|
+ }
|
|
45
|
+ });
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ function handleReset() {
|
|
49
|
+ props.form.resetFields();
|
|
50
|
+ getList({ pageNum: 1, pageSize: 10 });
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+ // 跳转到编辑商品
|
|
54
|
+ const toEditIcons = (goodsId) => () => {
|
|
55
|
+ router.push({
|
|
56
|
+ pathname: '/miniapp/editIcons',
|
|
57
|
+ query: {
|
|
58
|
+ goodsId
|
|
59
|
+ },
|
|
60
|
+ });
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+ const changeGoodsStatus = (row) => () => {
|
|
65
|
+ const title = row.status === 1 ? '商品在小程序端隐藏,后台可继续编辑重新发布?':'商品会重新显示在小程序端?'
|
|
66
|
+
|
|
67
|
+ Modal.confirm({
|
|
68
|
+ title: title,
|
|
69
|
+ okText: '确认',
|
|
70
|
+ cancelText: '取消',
|
|
71
|
+ onOk() {
|
|
72
|
+ request({ ...apis.integralMall.changeTaGoods, data: { ...row },}).then((data) => {
|
|
73
|
+ message.info('操作成功!')
|
|
74
|
+ getList({ pageNum: 1, pageSize: 10, ...props.form.getFieldsValue() });
|
|
75
|
+ })
|
|
76
|
+ }
|
|
77
|
+ });
|
|
78
|
+ }
|
|
79
|
+ /**
|
|
80
|
+ *
|
|
81
|
+ *
|
|
82
|
+ * @param {*} props
|
|
83
|
+ * @returns
|
|
84
|
+ */
|
|
85
|
+ const columns = [
|
|
86
|
+ {
|
|
87
|
+ title: '商品图片',
|
|
88
|
+ dataIndex: 'imgUrl',
|
|
89
|
+ key: 'imgUrl',
|
|
90
|
+ align: 'center',
|
|
91
|
+ render: (text, record) => <img src={record.imgUrl} className={styles.touxiang} />,
|
|
92
|
+ },
|
|
93
|
+ {
|
|
94
|
+ title: '商品名称',
|
|
95
|
+ dataIndex: 'goodsName',
|
|
96
|
+ key: 'goodsName',
|
|
97
|
+ align: 'center',
|
|
98
|
+
|
|
99
|
+ },
|
|
100
|
+ {
|
|
101
|
+ title: '所属积分',
|
|
102
|
+ dataIndex: 'pointPrice',
|
|
103
|
+ key: 'pointPrice',
|
|
104
|
+ align: 'center',
|
|
105
|
+ },
|
|
106
|
+ {
|
|
107
|
+ title: '总数量',
|
|
108
|
+ dataIndex: 'totalNum',
|
|
109
|
+ key: 'totalNum',
|
|
110
|
+ align: 'center',
|
|
111
|
+ },
|
|
112
|
+ {
|
|
113
|
+ title: '已兑换数量',
|
|
114
|
+ dataIndex: 'exchanged',
|
|
115
|
+ key: 'exchanged',
|
|
116
|
+ align: 'center',
|
|
117
|
+ render: (x,row) => <><span>{row.totalNum - row.inventory}</span></>
|
|
118
|
+ },
|
|
119
|
+ {
|
|
120
|
+ title: '剩余数量',
|
|
121
|
+ dataIndex: 'inventory',
|
|
122
|
+ key: 'inventory',
|
|
123
|
+ align: 'center',
|
|
124
|
+ },
|
|
125
|
+ {
|
|
126
|
+ title: '状态',
|
|
127
|
+ dataIndex: 'status',
|
|
128
|
+ key: 'status',
|
|
129
|
+ align: 'center',
|
|
130
|
+ render: (status)=> <><span>{status == 1 ? '已上架' : '已下架'}</span></>
|
|
131
|
+ },
|
|
132
|
+ {
|
|
133
|
+ title: '操作',
|
|
134
|
+ dataIndex: 'handle',
|
|
135
|
+ key: 'handle',
|
|
136
|
+ align: 'center',
|
|
137
|
+ render: (x, row) => (
|
|
138
|
+ <>
|
|
139
|
+ <AuthButton name="admin.taGoods.change.put" noRight={null}>
|
|
140
|
+ <span style={{ color: '#EF273A', marginRight: '20px',cursor: 'pointer' }} onClick={changeGoodsStatus(row)}>
|
|
141
|
+ {row.status == 1 ? '下架' : '上架'}
|
|
142
|
+ {<Icon type="shopping-cart" className={styles.shoppingCart} />}
|
|
143
|
+ </span>
|
|
144
|
+ </AuthButton>
|
|
145
|
+ <AuthButton name="admin.taGoods.put" noRight={null}>
|
|
146
|
+ <span style={{ color: '#FF925C',cursor: 'pointer' }} onClick={toEditIcons(row.goodsId)}>
|
|
147
|
+ 编辑<Icon type="form" className={styles.edit} />
|
|
148
|
+ </span>
|
|
149
|
+ </AuthButton>
|
|
150
|
+ </>
|
|
151
|
+ ),
|
|
152
|
+ },
|
|
153
|
+ ];
|
|
154
|
+
|
|
155
|
+ const { getFieldDecorator } = props.form
|
|
156
|
+ return (
|
|
157
|
+
|
|
158
|
+ <>
|
|
159
|
+ <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
|
|
160
|
+ <Form.Item>
|
|
161
|
+ {getFieldDecorator('goodsName')(
|
|
162
|
+ <Input
|
|
163
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
164
|
+ placeholder="商品名称"
|
|
165
|
+ />,
|
|
166
|
+ )}
|
|
167
|
+ </Form.Item>
|
|
168
|
+ <Form.Item>
|
|
169
|
+ {getFieldDecorator('status')(
|
|
170
|
+ <Select style={{ width: '180px' }} placeholder="状态">
|
|
171
|
+ <Option value="1">已上架</Option>
|
|
172
|
+ <Option value="0">已下架</Option>
|
|
173
|
+ </Select>,
|
|
174
|
+ )}
|
|
175
|
+ </Form.Item>
|
|
176
|
+ <Form.Item>
|
|
177
|
+ {getFieldDecorator('buildingId')(
|
|
178
|
+ <BuildSelect />,
|
|
179
|
+ )}
|
|
180
|
+ </Form.Item>
|
|
181
|
+ <Form.Item>
|
|
182
|
+ {getFieldDecorator('priceLesser')(
|
|
183
|
+ <Input
|
|
184
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
185
|
+ placeholder="价格小"
|
|
186
|
+ />,
|
|
187
|
+ )}
|
|
188
|
+ </Form.Item>
|
|
189
|
+ <Form.Item>
|
|
190
|
+ {getFieldDecorator('priceGreater')(
|
|
191
|
+ <Input
|
|
192
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
193
|
+ placeholder="价格大"
|
|
194
|
+ />,
|
|
195
|
+ )}
|
|
196
|
+ </Form.Item>
|
|
197
|
+ <Form.Item>
|
|
198
|
+ <AuthButton name="admin.taGoods.search" noRight={null}>
|
|
199
|
+ <Button type="primary" htmlType="submit" className={styles.searchBtn}>
|
|
200
|
+ 搜索
|
|
201
|
+ </Button>
|
|
202
|
+ </AuthButton>
|
|
203
|
+ <Button style={{ marginLeft: 8 }} onClick={handleReset}>
|
|
204
|
+ 重置
|
|
205
|
+ </Button>
|
|
206
|
+ </Form.Item>
|
|
207
|
+ </Form>
|
|
208
|
+ <AuthButton name="admin.taGoods.add.post" noRight={null}>
|
|
209
|
+ <Button type="danger" className={styles.addBtn} onClick={toEditIcons()}>新增</Button>
|
|
210
|
+ </AuthButton>
|
|
211
|
+ <Table rowKey="goodsList" dataSource={data.records} columns={columns} pagination={false} />
|
|
212
|
+ <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
|
213
|
+ <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current}/>
|
|
214
|
+ </div>
|
|
215
|
+ </>
|
|
216
|
+ )
|
|
217
|
+}
|
|
218
|
+const WrappedHeader = Form.create({ name: 'header' })(header);
|
|
219
|
+
|
|
220
|
+export default WrappedHeader
|