浏览代码

Merge branch 'master' of http://git.ycjcjy.com/estateagents/pc-channel

zhoulisen 5 年前
父节点
当前提交
ac710ddb2b
共有 4 个文件被更改,包括 96 次插入49 次删除
  1. 47
    8
      src/pages/sample/h5/components/H5Card.jsx
  2. 4
    3
      src/pages/sample/h5/edit.jsx
  3. 28
    34
      src/pages/sample/h5/index.jsx
  4. 17
    4
      src/services/apis.js

+ 47
- 8
src/pages/sample/h5/components/H5Card.jsx 查看文件

@@ -1,5 +1,5 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Select, Form, Alert, Card } from 'antd';
2
+import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Select, Form, Alert, Card, Modal } from 'antd';
3 3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 4
 import router from 'umi/router';
5 5
 import apis from '../../../../services/apis';
@@ -10,14 +10,53 @@ import moment from 'moment';
10 10
 const { Meta } = Card
11 11
 
12 12
 const H5Card = props => {
13
+  const { h5Data } = props
14
+
15
+  const colerArr = ["#2db7f5","#87d068","#108ee9","magenta","red","volcano","orange","green","geekblue","purple"]
16
+  const toEdit = () => {
17
+    router.push({
18
+      pathname: '/sample/h5/edit',
19
+      query: {
20
+        id: h5Data.sampleId
21
+      },
22
+    });
23
+  }
24
+
25
+  const deleteSample = () => {
26
+    const title = '确认将所选数据删除?可删除条件:无关联的H5需求单'
27
+    Modal.confirm({
28
+      title: title,
29
+      okText: '确认',
30
+      cancelText: '取消',
31
+      onOk() {
32
+        request({ ...apis.sample.puth5, urlData: { id: h5Data.sampleId }}).then((data) => {
33
+          message.info('操作成功!')
34
+          props.onChange()
35
+        }).catch((err) => {
36
+          console.log(err)
37
+          message.info(err.msg || err.message)
38
+        })
39
+      }
40
+    });
41
+  }
42
+
13 43
     return (
14
-    <Card
15
-      hoverable
16
-      style={{ width: 240 }}
17
-      cover={<img alt="example" src="https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png" />}
18
-    >
19
-      <Meta title="Europe Street beat" description="www.instagram.com" />
20
-    </Card>
44
+      <>
45
+      <Card
46
+        hoverable
47
+        style={{ width: 480,height: 450,marginTop: 50,position: "relative" }}
48
+        cover={<img height="335px" alt="example" onClick={toEdit} src={h5Data.coverImg} />}
49
+        extra={<a onClick={deleteSample}>删除</a>}
50
+        title={h5Data.status == 1 ? '已发布' : h5Data.status == 0 ? '未发布' : ''}
51
+      >
52
+        <Meta onClick={toEdit} title={h5Data.sampleName} />
53
+        <div style={{position: "absolute", bottom: "50px", right: "20px", margin: '20px 0'}}>
54
+          {(h5Data.tags || []).map((x,i) => {
55
+            return <Tag color={colerArr[i]}>{x}</Tag>
56
+          })}
57
+        </div>
58
+      </Card>
59
+    </>
21 60
     )
22 61
   }
23 62
  

+ 4
- 3
src/pages/sample/h5/edit.jsx 查看文件

@@ -35,10 +35,12 @@ const header = props => {
35 35
     // 查询列表
36 36
     const getH5Data = (sampleId) => {
37 37
       request({
38
-          ...apis.sample.get,
38
+          ...apis.sample.geth5,
39 39
           urlData: { id: sampleId }
40 40
       }).then((data) => {
41 41
         setData(data)
42
+        props.form.setFieldsValue(data)
43
+        setTypeState(data.sampleType)
42 44
       }).catch((err) => {
43 45
         message.error(err.msg || err.message)
44 46
       })
@@ -52,9 +54,8 @@ const header = props => {
52 54
         console.log(values,"valuesvaluesvaluesvaluesvaluesvaluesvalues")
53 55
         debugger
54 56
         if (!err) {
55
-          console.log(values,"h5Sample/addh5Sample/add")
56 57
           if(sampleId){
57
-            request({ ...apis.sample.update, urlData: { id: sampleId }, data: { ...values }}).then((data) => {
58
+            request({ ...apis.sample.updateh5, urlData: { id: sampleId }, data: { ...values }}).then((data) => {
58 59
               cancelPage();
59 60
             }).catch((err) => {
60 61
               message.error(err.msg || err.message)

+ 28
- 34
src/pages/sample/h5/index.jsx 查看文件

@@ -1,6 +1,6 @@
1 1
 import React, { useState, useEffect } from 'react';
2 2
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
3
-import { Form, Pagination, Card, Button, Icon, Tooltip, message,   notification, Modal, Table, Select,Input, DatePicker  } from 'antd';
3
+import { Form, Pagination, Card, Button, Icon, Tooltip, message,   notification, Modal, Table, Select,Input, DatePicker,Row, Col  } from 'antd';
4 4
 import router from 'umi/router';
5 5
 import moment from 'moment';
6 6
 import className from 'classnames';
@@ -35,6 +35,15 @@ function header(props) {
35 35
     e.preventDefault();
36 36
     props.form.validateFields((err, values) => {
37 37
       if (!err) {
38
+        let {createDate, ...submitValue} = values
39
+        if(null != createDate && createDate.length > 0){
40
+          const [startCreateDate, endCreateDate] = createDate
41
+          submitValue.startCreateDate = moment(startCreateDate).format('YYYY-MM-DD');
42
+          submitValue.endCreateDate = moment(endCreateDate).format('YYYY-MM-DD');
43
+        }else{
44
+          submitValue.startCreateDate = null
45
+          submitValue.endCreateDate = null
46
+        }
38 47
         getList({ pageNum: 1, pageSize: 10, ...values })
39 48
       }
40 49
     });
@@ -104,43 +113,25 @@ function header(props) {
104 113
           )}
105 114
         </Form.Item>
106 115
         <Form.Item>
107
-          {getFieldDecorator('orgName')(
108
-            <Input
109
-              prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
110
-              placeholder="下单组织"
111
-            />,
112
-          )}
113
-        </Form.Item>
114
-        <Form.Item>
115
-          {getFieldDecorator('orderer')(
116
-            <Input
117
-              prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
118
-              placeholder="下单人"
119
-            />,
120
-          )}
121
-        </Form.Item>
122
-        <Form.Item>
123
-          {getFieldDecorator('phone')(
124
-            <Input
125
-              prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
126
-              placeholder="联系方式"
127
-            />,
116
+          {getFieldDecorator('status')(
117
+            <Select style={{ width: '180px' }} placeholder="发布状态">
118
+              <Select.Option value="1">是</Select.Option>
119
+              <Select.Option value="0">否</Select.Option>
120
+            </Select>,
128 121
           )}
129 122
         </Form.Item>
130 123
         <Form.Item>
131
-            <span style={{marginRight:'10px'}}>下单时间段:</span>
124
+            <span style={{marginRight:'10px'}}>新增时间段:</span>
132 125
                 {getFieldDecorator('createDate')(
133 126
                   <RangePicker placeholder={['开始时间','结束时间']} />
134 127
                 )}
135 128
         </Form.Item>
136 129
         <Form.Item>
137
-          {getFieldDecorator('demandStatus')(
138
-            <Select style={{ width: '180px' }} placeholder="需求单状态">
139
-              <Select.Option value="1">已提交</Select.Option>
140
-              <Select.Option value="2">处理中</Select.Option>
141
-              <Select.Option value="3">已交付</Select.Option>
142
-              <Select.Option value="4">作废</Select.Option>
143
-            </Select>,
130
+          {getFieldDecorator('tag')(
131
+            <Input
132
+              prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
133
+              placeholder="标签"
134
+            />,
144 135
           )}
145 136
         </Form.Item>
146 137
         <Form.Item>
@@ -154,10 +145,13 @@ function header(props) {
154 145
       </Form>
155 146
       
156 147
       <Button type="danger" className={styles.addBtn} onClick={toEditH5()}>新增</Button>
157
- 
158
-      {(data.records || []).map(x => (
159
-          <H5Card />
160
-        ))}
148
+      <Row>      
149
+          {(data.records || []).map(x => (
150
+              <Col span={6}>
151
+                <H5Card h5Data={x} onChange={handleReset}/>
152
+              </Col>
153
+            ))}
154
+      </Row>
161 155
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
162 156
         <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current}/>
163 157
       </div>

+ 17
- 4
src/services/apis.js 查看文件

@@ -95,13 +95,21 @@ const apis = {
95 95
       method: 'POST',
96 96
       action: 'channel',
97 97
     },
98
-  },
99
-  contact: {
100
-    list: {
101
-      url: `${prefix}/taContact`,
98
+    geth5: {
99
+      url: `${prefix}/get/h5Sample/:id`,
102 100
       method: 'GET',
103 101
       action: 'channel',
104 102
     },
103
+    updateh5: {
104
+      url: `${prefix}/update/h5Sample/:id`,
105
+      method: 'PUT',
106
+      action: 'channel',
107
+    },
108
+    puth5: {
109
+      url: `${prefix}/put/h5Sample/:id`,
110
+      method: 'PUT',
111
+      action: 'channel',
112
+    }
105 113
   },
106 114
   image: {
107 115
     uploadForAnt: {
@@ -178,6 +186,11 @@ const apis = {
178 186
       method: 'PUT',
179 187
       action: 'center',
180 188
     },
189
+    list: {
190
+      url: `${prefix}/taContact`,
191
+      method: 'GET',
192
+      action: 'channel',
193
+    },
181 194
   }
182 195
   
183 196
 }