Преглед изворни кода

Merge branch 'master' of http://git.ycjcjy.com/marketing/pc-admin into master

张延森 пре 3 година
родитељ
комит
5b54c26641

+ 1
- 1
src/pages/activity/lookHouseActivity/index.jsx Прегледај датотеку

@@ -328,4 +328,4 @@ const LookHouseActivity = props => {
328 328
   );
329 329
 };
330 330
 
331
-export default SignupActivity;
331
+export default LookHouseActivity;

+ 123
- 62
src/pages/building/Edit/Apartment/Form.jsx Прегледај датотеку

@@ -1,112 +1,173 @@
1
-import React, { useEffect, useState } from 'react'
2
-import { Button, Form, Input, message, Select } from 'antd'
3
-import ImageUpload from '@/components/XForm/ImageUpload'
4
-import { fetch, apis } from '@/utils/request'
5
-import ModalForm from '../components/ModalForm'
6
-import InputNumber from '../components/InputNumber'
7
-import { validMinNum } from '../utils'
1
+import React, { useEffect, useState } from 'react';
2
+import { Button, Form, Input, message, Select } from 'antd';
3
+import ImageUpload from '@/components/XForm/ImageUpload';
4
+import { fetch, apis } from '@/utils/request';
5
+import ModalForm from '../components/ModalForm';
6
+import InputNumber from '../components/InputNumber';
7
+import { validMinNum } from '../utils';
8 8
 
9
-const Option = Select.Option
10
-const fullWidth = { width: '100%' }
11
-const saveData = fetch(apis.building.buildingApartmentAdd)
12
-const updateData = fetch(apis.building.buildingApartmentUpdate)
9
+const Option = Select.Option;
10
+const fullWidth = { width: '100%' };
11
+const saveData = fetch(apis.building.buildingApartmentAdd);
12
+const updateData = fetch(apis.building.buildingApartmentUpdate);
13 13
 
14
-const AMForm = (props) => {
15
-  const { visible, onCancel, form, formData, onSuccess } = props
16
-  const { getFieldDecorator, setFieldsValue, resetFields, validateFields } = form
14
+const saleType = [
15
+  {
16
+    id: '1',
17
+    name: '待售',
18
+  },
19
+  {
20
+    id: '2',
21
+    name: '售罄',
22
+  },
23
+  {
24
+    id: '3',
25
+    name: '在售',
26
+  },
27
+  // {
28
+  //   id: '4',
29
+  //   name: '在租',
30
+  // },
31
+];
17 32
 
18
-  const [loading, setLoading] = useState(false)
33
+const houseType = [
34
+  {
35
+    id: '1',
36
+    name: '1室',
37
+  },
38
+  {
39
+    id: '2',
40
+    name: '2室',
41
+  },
42
+  {
43
+    id: '3',
44
+    name: '3室',
45
+  },
46
+  {
47
+    id: '4',
48
+    name: '4室',
49
+  },
50
+  {
51
+    id: '5',
52
+    name: '5室及以上',
53
+  },
54
+];
19 55
 
20
-  const handleSubmit = (e) => {
56
+const AMForm = props => {
57
+  const { visible, onCancel, form, formData, onSuccess,buildingId } = props;
58
+  const { getFieldDecorator, setFieldsValue, resetFields, validateFields } = form;
59
+
60
+  const [loading, setLoading] = useState(false);
61
+
62
+  const handleSubmit = e => {
21 63
     e.preventDefault();
22 64
     validateFields((err, values) => {
23 65
       if (err) {
24
-        console.error(err)
25
-        return
66
+        console.error(err);
67
+        return;
26 68
       }
27 69
 
28
-      const request = formData && formData.apartmentId ? updateData : saveData
70
+      const request = formData && formData.apartmentId ? updateData : saveData;
71
+
72
+      //  console.log(values)
73
+      // TODO 这里应该是要支持多图,但是封装的控件没有
74
+      // data.img = data.img.map((item, index) => ({ imgType: 'aparment', url: item, orderNo: index }))
75
+      console.log(formData, values, '--------------');
76
+      values.img = [{ imgType: 'aparment', url: values.img, orderNo: 0 }];
77
+      values.buildingId = buildingId;
78
+      values.apartmentType = 'apart';
79
+      // const api = data.apartmentId !== undefined ? apis.building.buildingApartmentUpdate : apis.building.buildingApartmentAdd;
80
+
29 81
       const data = {
30 82
         ...(formData || {}),
31 83
         ...values,
32
-      }
84
+      };
33 85
 
34
-      setLoading(true)
35
-      request({ data }).then((res) => {
36
-        setLoading(false)
37
-        message.success('操作成功')
38
-        onSuccess(res)
39
-      }).catch((err) => {
40
-        setLoading(false)
41
-        console.error(err)
42
-      })
43
-    })
44
-  }
86
+      setLoading(true);
87
+      request({ data })
88
+        .then(res => {
89
+          setLoading(false);
90
+          message.success('操作成功');
91
+          onSuccess(res);
92
+        })
93
+        .catch(err => {
94
+          setLoading(false);
95
+          console.error(err);
96
+        });
97
+    });
98
+  };
45 99
 
46 100
   useEffect(() => {
47
-    resetFields()
48
-    setFieldsValue(formData || {})
49
-  }, [formData])
101
+    resetFields();
102
+    if (formData?.buildingImgList) {
103
+      formData.img = formData.buildingImgList[0].url;
104
+    }
105
+    setFieldsValue(formData || {});
106
+    setFieldsValue(formData || {});
107
+  }, [formData]);
50 108
 
51 109
   return (
52
-    <ModalForm
53
-      title="户型设置"
54
-      visible={visible}
55
-      onCancel={onCancel}
56
-      onSubmit={handleSubmit}
57
-    >
110
+    <ModalForm title="户型设置" visible={visible} onCancel={onCancel} onSubmit={handleSubmit}>
58 111
       <Form.Item label="户型名称">
59 112
         {getFieldDecorator('apartmentName', {
60 113
           rules: [
61 114
             { required: true, message: '请填写户型名称' },
62 115
             { max: 10, message: '户型名称不超过10个字符' },
63 116
           ],
64
-        })(<Input placeholder="户型名称不超过10个字符"/>)}
117
+        })(<Input placeholder="户型名称不超过10个字符" />)}
65 118
       </Form.Item>
66 119
       <Form.Item label="销售状态">
67 120
         {getFieldDecorator('marketStatus', {
68 121
           rules: [{ required: true, message: '请选择销售状态' }],
69 122
         })(
70 123
           <Select placeholder="销售状态">
71
-            <Option value="未开盘">未开盘</Option>
72
-            <Option value="在售">在售</Option>
73
-            <Option value="售罄">售罄</Option>
74
-          </Select>
124
+            {saleType.map((item, _) => (
125
+              <Option value={item.id}>{item.name}</Option>
126
+            ))}
127
+          </Select>,
75 128
         )}
76 129
       </Form.Item>
77 130
       <Form.Item label="图片" help="建议图片尺寸336px*336px,比例1:1,格式:jpg">
78
-      {getFieldDecorator('img', {
131
+        {getFieldDecorator('img', {
79 132
           rules: [{ required: true, message: '请上传户型图片' }],
80
-      })(
81
-        <ImageUpload />,
82
-      )}
133
+        })(<ImageUpload />)}
83 134
       </Form.Item>
84 135
       <Form.Item label="厅室">
85 136
         {getFieldDecorator('houseType', {
86 137
           rules: [{ required: true, message: '请填写户型厅室' }],
87
-        })(<Input placeholder="例如: 三室一厅" />)}
138
+        })(
139
+          <Select placeholder="户型">
140
+            {houseType.map((item, _) => (
141
+              <Option value={item.id}>{item.name}</Option>
142
+            ))}
143
+          </Select>,
144
+        )}
88 145
       </Form.Item>
89 146
       <Form.Item label="面积">
90 147
         {getFieldDecorator('buildingArea', {
91
-            rules: [{ validator: validMinNum }]
92
-          })(<InputNumber precision={2} min={0} step={0.01} addonAfter="㎡" />)}
148
+          rules: [{ validator: validMinNum }],
149
+        })(<InputNumber precision={2} min={0} step={0.01} addonAfter="㎡" />)}
93 150
       </Form.Item>
94 151
       <Form.Item label="使用面积">
95 152
         {getFieldDecorator('insideArea', {
96
-            rules: [{ validator: validMinNum }]
97
-          })(<InputNumber precision={2} min={0} step={0.01} addonAfter="㎡" />)}
153
+          rules: [{ validator: validMinNum }],
154
+        })(<InputNumber precision={2} min={0} step={0.01} addonAfter="㎡" />)}
98 155
       </Form.Item>
99 156
       <Form.Item label="权重" help="数值越大越靠前">
100 157
         {getFieldDecorator('orderNo', {
101
-            rules: [{ validator: validMinNum }]
102
-          })(<InputNumber min={0} step={1} style={fullWidth} />)}
158
+          rules: [{ validator: validMinNum }],
159
+        })(<InputNumber min={0} step={1} style={fullWidth} />)}
103 160
       </Form.Item>
104
-      <Form.Item label=" " colon={false} style={{marginTop: '2em'}}>
105
-        <Button loading={loading} style={{marginLeft: '4em'}} type="primary" htmlType="submit">保存</Button>
106
-        <Button style={{marginLeft: '2em'}} onClick={props.onCancel}>取消</Button>
161
+      <Form.Item label=" " colon={false} style={{ marginTop: '2em' }}>
162
+        <Button loading={loading} style={{ marginLeft: '4em' }} type="primary" htmlType="submit">
163
+          保存
164
+        </Button>
165
+        <Button style={{ marginLeft: '2em' }} onClick={props.onCancel}>
166
+          取消
167
+        </Button>
107 168
       </Form.Item>
108 169
     </ModalForm>
109
-  )
110
-}
170
+  );
171
+};
111 172
 
112
-export default Form.create({})(AMForm)
173
+export default Form.create({})(AMForm);

+ 44
- 0
src/pages/building/Edit/Apartment/List.jsx Прегледај датотеку

@@ -2,6 +2,48 @@ import React from 'react'
2 2
 import { Button, Table, Popconfirm } from 'antd'
3 3
 import moment from 'moment'
4 4
 
5
+const saleType = [
6
+  {
7
+    id: 1,
8
+    name: '待售',
9
+  },
10
+  {
11
+    id: 2,
12
+    name: '售罄',
13
+  },
14
+  {
15
+    id: 3,
16
+    name: '在售',
17
+  },
18
+  {
19
+    id: 4,
20
+    name: '在租',
21
+  },
22
+]
23
+
24
+const houseType = [
25
+  {
26
+    id: 1,
27
+    name: '1室',
28
+  },
29
+  {
30
+    id: 2,
31
+    name: '2室',
32
+  },
33
+  {
34
+    id: 3,
35
+    name: '3室',
36
+  },
37
+  {
38
+    id: 4,
39
+    name: '4室',
40
+  },
41
+  {
42
+    id: 5,
43
+    name: '5室及以上',
44
+  },
45
+]
46
+
5 47
 export default (props) => {
6 48
   const columns = [
7 49
     {
@@ -13,11 +55,13 @@ export default (props) => {
13 55
       title: '销售状态',
14 56
       dataIndex: 'marketStatus',
15 57
       key: 'marketStatus',
58
+      render: (_, record) => <span>{(saleType.filter(x => x.id == record.marketStatus)[0] || {}).name}</span>,
16 59
     },
17 60
     {
18 61
       title: '户型',
19 62
       dataIndex: 'houseType',
20 63
       key: 'houseType',
64
+      render: (_, record) => <span>{(houseType.filter(x => x.id == record.houseType)[0] || {}).name}</span>,
21 65
     },
22 66
     {
23 67
       title: '面积',

+ 1
- 1
src/pages/building/Edit/Apartment/index.jsx Прегледај датотеку

@@ -64,7 +64,7 @@ export default (props) => {
64 64
       <div>
65 65
         <Button type="primary" onClick={() => handleEdit()}>新增户型</Button>
66 66
       </div>
67
-      <Form visible={visible} onCancel={() => setVisible(false)} formData={apartmentRef.current} onSuccess={handleSuccess} />
67
+      <Form buildingId={id} visible={visible} onCancel={() => setVisible(false)} formData={apartmentRef.current} onSuccess={handleSuccess} />
68 68
       <List loading={loading} dataSource={list} onEdit={handleEdit} onDelete={handleDelete} />
69 69
     </div>
70 70
   )

+ 0
- 8
src/pages/home/Recommend/index.jsx Прегледај датотеку

@@ -5,14 +5,6 @@ import request from '../../../utils/request';
5 5
 import apis from '../../../services/apis';
6 6
 import QueryTable from '@/components/QueryTable'
7 7
 import { router } from 'umi';
8
-import { render } from 'enzyme';
9
-import WxDictSelect from '@/components/SelectButton/WxDictSelect';
10
-import BuildingSelect from '@/components/SelectButton/BuildSelect';
11
-import renderAuthorize from '@/components/Authorized/renderAuthorize';
12
-import { setLocale } from 'umi-plugin-locale';
13
-import { fromPairs } from 'lodash';
14
-import { backgroundColor } from 'echarts/lib/theme/dark';
15
-
16 8
 
17 9
 
18 10
 /**

+ 5
- 161
src/pages/news/list/compents/Poster.jsx Прегледај датотеку

@@ -4,6 +4,7 @@ import { message, Radio, Input, Button } from 'antd';
4 4
 import apis from '@/services/apis';
5 5
 import router from 'umi/router';
6 6
 import request from '@/utils/request';
7
+import Poster from '@/components/Poster';
7 8
 import ImageUploader from '@/components/XForm/ImageUpload';
8 9
 import logo from '../../../../assets/logo.svg';
9 10
 import yinhao from '../../../../assets/yinhao.png';
@@ -14,6 +15,8 @@ import xiaochengxu from '../../../../assets/xiaochengxu.png';
14 15
 
15 16
 const { TextArea } = Input;
16 17
 export default props => {
18
+  const target = { id: '', type: 'news' };
19
+
17 20
   const { newsId } = props;
18 21
   const [inputValue, changeInput] = useState('');
19 22
   const [textAreaValue, changeTextArea] = useState('');
@@ -24,7 +27,6 @@ export default props => {
24 27
     if (newsId) {
25 28
       request({ ...apis.activity.poster, params: { targetId: newsId, targetType: 'news' } })
26 29
         .then(data => {
27
-     
28 30
           if (data.length > 0) {
29 31
             setPosterId(data[0].posterId);
30 32
             changeImg(data[0].posterImg);
@@ -35,11 +37,9 @@ export default props => {
35 37
         .catch(err => {
36 38
           message.info(err.msg || err.message);
37 39
         });
38
-
39
-    } 
40
+    }
40 41
   }, []);
41 42
 
42
-  
43 43
   const submitPoster = () => {
44 44
     if (newsId) {
45 45
       if (posterId) {
@@ -90,163 +90,7 @@ export default props => {
90 90
 
91 91
   return (
92 92
     <div>
93
-      <div style={{ display: 'flex' }}>
94
-        <div
95
-          style={{ width: '420px', height: '900px', display: 'inline-block', marginTop: '30px' }}
96
-        >
97
-          <div
98
-            style={{
99
-              width: '375px',
100
-              height: '700px',
101
-              backgroundColor: '#fff',
102
-              boxShadow: '0px 0px 16px 6px rgba(0,0,0,0.15)',
103
-              position: 'relative',
104
-              margin: '0 auto',
105
-            }}
106
-          >
107
-            <img
108
-              style={{ width: '100%', height: '300px' }}
109
-              src={imgValue ? imgValue : poster1}
110
-              alt=""
111
-            />
112
-            <div style={{ display: 'flex', alignItems: 'center', marginTop: '-24px' }}>
113
-              <img
114
-                style={{
115
-                  width: '70px',
116
-                  height: '70px',
117
-                  border: '4px solid #fff',
118
-                  borderRadius: '35px',
119
-                  marginLeft: '16px',
120
-                }}
121
-                src={touxiang}
122
-                alt=""
123
-              />
124
-              <span
125
-                style={{
126
-                  color: '#222',
127
-                  fontWeight: '600',
128
-                  margin: '24px 10px 0 14px',
129
-                  fontSize: '17px',
130
-                }}
131
-              >
132
-                喵喵
133
-              </span>
134
-              <span style={{ color: '#999', marginTop: '25px', fontSize: '17px' }}>邀您阅读</span>
135
-              <span style={{ color: '#999', margin: '25px 0 0 60px', fontSize: '17px' }}>
136
-                2019.09.21
137
-              </span>
138
-            </div>
139
-            <p
140
-              style={{
141
-                margin: '10px 20px',
142
-                fontSize: '20px',
143
-                color: '#222',
144
-                fontWeight: '600',
145
-                display: '-webkit-box',
146
-                lineClamp: '3',
147
-                height: '60px',
148
-                WebkitLineClamp: '2',
149
-                WebkitBoxOrient: 'vertical',
150
-                overflow: 'hidden',
151
-                textOverflow: 'ellipsis',
152
-              }}
153
-            >
154
-              {inputValue ? inputValue : '海报标题'}
155
-            </p>
156
-
157
-            <img src={yinhao} style={{ width: '30px', marginLeft: '20px' }} alt="" />
158
-            <p
159
-              style={{
160
-                margin: '16px 20px 28px 20px',
161
-                fontSize: '17px',
162
-                color: '#999',
163
-                display: '-webkit-box',
164
-                lineClamp: '3',
165
-                height: '72px',
166
-                WebkitLineClamp: '3',
167
-                WebkitBoxOrient: 'vertical',
168
-                overflow: 'hidden',
169
-                textOverflow: 'ellipsis',
170
-              }}
171
-            >
172
-              {textAreaValue ? textAreaValue : '海报描述'}
173
-            </p>
174
-            <div
175
-              style={{
176
-                backgroundColor: '#f1f1f1',
177
-                padding: '22px 30px',
178
-                boxShadow: '0px 6px 12px -4px #dcdcdc',
179
-                position: 'relative',
180
-              }}
181
-            >
182
-              <p style={{ margin: '0', fontSize: '18px', color: '#888' }}>长按识别小程序码</p>
183
-              <p style={{ margin: '0', fontSize: '18px', color: '#888' }}>进入资讯查看详情</p>
184
-              <img
185
-                style={{ width: '80px', position: 'absolute', right: '30px', top: '10px' }}
186
-                src={xiaochengxu}
187
-                alt=""
188
-              />
189
-            </div>
190
-          </div>
191
-          <p style={{ textAlign: 'center', fontSize: '19px', color: '#666', marginTop: '30px' }}>
192
-            海报模板
193
-          </p>
194
-        </div>
195
-
196
-        <div>
197
-          <div style={{ display: 'flex', width: '100%', margin: '60px 0' }}>
198
-            <p
199
-              style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}
200
-            >
201
-              资讯海报图
202
-            </p>
203
-            <ImageUploader value={imgValue} onChange={e => changeImg(e)} />
204
-          </div>
205
-          <p
206
-            style={{
207
-              fontSize: '0.5vw',
208
-              color: '#A9A9A9',
209
-              marginLeft: '230px',
210
-              marginBottom: '30px',
211
-            }}
212
-          >
213
-            建议图片尺寸:640*670px,比例64:67,格式:jpg,用于资讯海报
214
-          </p>
215
-          <div
216
-            style={{ display: 'flex', alignItems: 'center', width: '100%', marginBottom: '60px' }}
217
-          >
218
-            <p
219
-              style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}
220
-            >
221
-              海报标题
222
-            </p>
223
-            <Input
224
-              style={{ width: '20vw' }}
225
-              value={inputValue}
226
-              placeholder="请输入海报标题"
227
-              onChange={e => changeInput(e.target.value)}
228
-            />
229
-          </div>
230
-          <div style={{ display: 'flex', margin: '10px 0 40px 0', width: '100%' }}>
231
-            <p
232
-              style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}
233
-            >
234
-              海报描述
235
-            </p>
236
-            <TextArea
237
-              rows={5}
238
-              maxLength={1024}
239
-              value={textAreaValue}
240
-              onChange={e => changeTextArea(e.target.value)}
241
-            />
242
-          </div>
243
-        </div>
244
-      </div>
245
-      <Button type="primary" onClick={submitPoster} style={{ margin: '40px 40px 40px 30vw' }}>
246
-        {' '}
247
-        确定
248
-      </Button>
249
-      <Button onClick={cancelPage}>取消</Button>
93
+      <Poster target={target} {...props} />
250 94
     </div>
251 95
   );
252 96
 };

+ 66
- 59
src/pages/news/list/compents/Share.jsx Прегледај датотеку

@@ -5,75 +5,82 @@ import apis from '@/services/apis';
5 5
 import router from 'umi/router';
6 6
 import request from '@/utils/request';
7 7
 import ImageUploader from '@/components/XForm/ImageUpload';
8
+import Share from '@/components/Share';
8 9
 import logo from '../../../../assets/logo.svg';
9 10
 import poster2 from '../../../../assets/poster2.png';
10 11
 
11
-
12
-export default (props) => {
12
+export default props => {
13 13
   const { newsId } = props;
14
-  const [inputValue, changeInput] = useState('')
15
-  const [imgValue, changeImg] = useState('')
16
-  const [shareContentId, setShareContentId] = useState('')
17
-  
18
-  if(newsId){
19
-    useEffect(() => {
20
-      request({ ...apis.activity.shareContent, params: {targetId: newsId,targetType: 'news'},}).then((data) => {
21
-        console.log(data,"2222")
22
-        if(data.length > 0){
23
-          setShareContentId(data[0].shareContentId)
24
-          changeImg(data[0].shareContentImg)
25
-          changeInput(data[0].shareContentTitle)
26
-        }
27
-      }).catch((err) => {
28
-        message.info(err.msg || err.message)
29
-      })
30
-    }, [])
31
-  }
14
+  const [inputValue, changeInput] = useState('');
15
+  const [imgValue, changeImg] = useState('');
16
+  const [shareContentId, setShareContentId] = useState('');
17
+
18
+  useEffect(() => {
19
+    if (newsId) {
20
+      request({ ...apis.activity.shareContent, params: { targetId: newsId, targetType: 'news' } })
21
+        .then(data => {
22
+          console.log(data, '2222');
23
+          if (data.length > 0) {
24
+            setShareContentId(data[0].shareContentId);
25
+            changeImg(data[0].shareContentImg);
26
+            changeInput(data[0].shareContentTitle);
27
+          }
28
+        })
29
+        .catch(err => {
30
+          message.info(err.msg || err.message);
31
+        });
32
+    }
33
+  }, []);
32 34
 
33 35
   const submitShare = () => {
34
-    if(newsId){
35
-      if(shareContentId){
36
-        request({ ...apis.activity.updateShareContent, urlData: {id: shareContentId},data: {targetId: newsId,shareContentType: 'news',shareContentImg: imgValue,shareContentTitle: inputValue},}).then((data) => {
37
-          message.info("保存成功")
38
-        }).catch((err) => {
39
-          message.info(err.msg || err.message)
36
+    if (newsId) {
37
+      if (shareContentId) {
38
+        request({
39
+          ...apis.activity.updateShareContent,
40
+          urlData: { id: shareContentId },
41
+          data: {
42
+            targetId: newsId,
43
+            shareContentType: 'news',
44
+            shareContentImg: imgValue,
45
+            shareContentTitle: inputValue,
46
+          },
40 47
         })
41
-       }else{
42
-        request({ ...apis.activity.addShareContent, data: {targetId: newsId,shareContentType: 'news',shareContentImg: imgValue,shareContentTitle: inputValue},}).then((data) => {
43
-          setShareContentId(data.shareContentId)
44
-          message.info("保存成功")
45
-        }).catch((err) => {
46
-          message.info(err.msg || err.message)
48
+          .then(data => {
49
+            message.info('保存成功');
50
+          })
51
+          .catch(err => {
52
+            message.info(err.msg || err.message);
53
+          });
54
+      } else {
55
+        request({
56
+          ...apis.activity.addShareContent,
57
+          data: {
58
+            targetId: newsId,
59
+            shareContentType: 'news',
60
+            shareContentImg: imgValue,
61
+            shareContentTitle: inputValue,
62
+          },
47 63
         })
48
-       }
49
-     }else{
50
-      message.warn("请先保存基本信息数据")
51
-     }
52
-  }
64
+          .then(data => {
65
+            setShareContentId(data.shareContentId);
66
+            message.info('保存成功');
67
+          })
68
+          .catch(err => {
69
+            message.info(err.msg || err.message);
70
+          });
71
+      }
72
+    } else {
73
+      message.warn('请先保存基本信息数据');
74
+    }
75
+  };
53 76
 
54 77
   const cancelPage = () => {
55 78
     router.go(-1);
56 79
   };
57
-
58
-  return <div style={{ padding: '20px' }}>
59
-    <div style={{ display: 'flex', margin: '10px 0 40px 0', width: '100%' }}>
60
-      <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>分享模板</p>
61
-      <div>
62
-        <p style={{ display: 'flex', alignItems: 'center', fontSize: '14px', color: '#999', margin: '0', lineHeight: '0' }}><img src={logo} style={{ width: '22px', marginRight: '10px' }} />橙蕉互动</p>
63
-        <p style={{ fontSize: '16px', color: '#222', fontWeight: '600', margin: '0' }}>{inputValue ? inputValue : '置业V客厅 精准获客平台'}</p>
64
-        <img style={{ width: '200px', height: '160px' }} src={imgValue ? imgValue : poster2} alt="" />
65
-      </div>
66
-    </div>
67
-    <div style={{ display: 'flex', alignItems: 'center', width: '100%' }}>
68
-      <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>分享标题</p>
69
-      <Input placeholder="请输入分享标题" value={inputValue} onChange={e => changeInput(e.target.value)} />
70
-    </div>
71
-    <div style={{ display: 'flex', width: '100%', marginTop: '40px' }}>
72
-      <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>资讯分享好友图</p>
73
-      <ImageUploader value={imgValue} onChange={e => changeImg(e)} />
80
+  const target = { id: '', type: 'news' };
81
+  return (
82
+    <div style={{ padding: '20px' }}>
83
+      <Share target={target} {...props} />
74 84
     </div>
75
-    <p style={{ fontSize: '0.5vw', color: '#A9A9A9', marginLeft: '230px', marginTop: '20px' }}>建议图片尺寸:750*600px,比例5:4,格式:jpg,用于资讯分享好友</p>
76
-    <Button type="primary" htmlType="submit" onClick={submitShare} style={{ margin: '40px 40px 40px 220px' }}> 确定</Button>
77
-    <Button onClick={cancelPage}>取消</Button>
78
-  </div>
79
-  }
85
+  );
86
+};

+ 120
- 2
src/pages/staff/Organization/form.jsx Прегледај датотеку

@@ -1,4 +1,122 @@
1
+import React from 'react'
2
+import { Row, Col, Card, Tree, DatePicker, Radio,Form, Select, Input,InputNumber, Button } from 'antd';
1 3
 
2
-export default (props) => {
3 4
 
4
-}
5
+import ImageUpload from '@/components/XForm/ImageUpload';
6
+
7
+const { Option } = Select;
8
+const FormItem = Form.Item;
9
+const {RangePicker}=DatePicker
10
+
11
+const formItemLayout = {
12
+    labelCol: { span: 6 },
13
+    wrapperCol: { span: 14 },
14
+};
15
+
16
+class TreedataFrom extends React.Component {
17
+  handleSubmit = e => {
18
+    e.preventDefault();
19
+    this.props.form.validateFields((err, values) => {
20
+      if (!err) {
21
+        console.log('Received values of form: ', values);
22
+      }
23
+    });
24
+  };
25
+
26
+  handleSelectChange = value => {
27
+    console.log(value);
28
+    this.props.form.setFieldsValue({
29
+      note: `Hi, ${value === 'male' ? 'man' : 'lady'}!`,
30
+    });
31
+  };
32
+
33
+  render() {
34
+    const { getFieldDecorator } = this.props.form;
35
+    return (
36
+      <Form {...formItemLayout} onSubmit={this.handleSubmit}>
37
+        <FormItem label="照片" help="建议尺寸:750px*600px,比例5:4,格式:jpg,用于:列表和详情">
38
+          {
39
+            getFieldDecorator('curriculumImg', {
40
+              rules: [
41
+                { required: true, message: '请上传照片' }
42
+              ]
43
+            })(
44
+              <ImageUpload />
45
+            )
46
+          }
47
+        </FormItem>
48
+        <FormItem label="姓名">
49
+          {getFieldDecorator('note', {
50
+            rules: [{ required: true, message: '请输入姓名!' }],
51
+          })(<Input />)}
52
+        </FormItem>
53
+        <FormItem label="年龄" >
54
+           {
55
+            getFieldDecorator('weight', {
56
+              rules: [{ required: true, message: '请输入年龄' }]
57
+            })(
58
+              <InputNumber min='18' />
59
+            )
60
+          }
61
+        </FormItem>
62
+        <FormItem label="性别">
63
+          {
64
+            getFieldDecorator('type', {
65
+              rules: [
66
+                { required: true, message: '请选择性别' }
67
+              ]
68
+            })(
69
+              <Radio.Group  style={{ width: '500px' }} defaultValue={1}>
70
+                {/* onChange={e => setContentType(e.target.value)} */}
71
+                <Radio value={1}>男</Radio>
72
+                <Radio value={2}>女</Radio>
73
+              </Radio.Group>
74
+            )
75
+          }
76
+        </FormItem>
77
+        <FormItem label="工作总时间" style={{ marginBottom: 0 }} help="如未离职,结束日期和开始日期一样即可">
78
+          <FormItem style={{ display: 'inline-block' }} >
79
+            <RangePicker style={{width: '255px'}}/>
80
+          </FormItem>
81
+        </FormItem>
82
+        <FormItem label="Gender">
83
+          {getFieldDecorator('gender', {
84
+            rules: [{ required: true, message: 'Please select your gender!' }],
85
+          })(
86
+            <Select
87
+              placeholder="Select a option and change input text above"
88
+              onChange={this.handleSelectChange}
89
+            >
90
+              <Option value="male">male</Option>
91
+              <Option value="female">female</Option>
92
+            </Select>,
93
+          )}
94
+        </FormItem>
95
+        <FormItem wrapperCol={{ span: 12, offset: 5 }}>
96
+          <Button type="primary" htmlType="submit">
97
+            Submit
98
+          </Button>
99
+        </FormItem>
100
+      </Form>
101
+    );
102
+  }
103
+}
104
+
105
+
106
+TreedataFrom = Form.create({})(TreedataFrom);
107
+
108
+export default TreedataFrom
109
+
110
+
111
+
112
+
113
+// import React from 'react'
114
+
115
+// class Hello extends React.Component{
116
+//     render(){
117
+//         return<h1>asdasdasdas</h1>
118
+//     }
119
+// }
120
+
121
+
122
+// export default Hello

+ 102
- 46
src/pages/staff/Organization/index.jsx Прегледај датотеку

@@ -205,68 +205,124 @@
205 205
 
206 206
 
207 207
 
208
-import { Row, Col, Card, Tree, DatePicker, Form, Input, InputNumber, Radio, Button } from 'antd'
209
-import React, { useEffect, useState, useCallback } from 'react';
210
-import ImageUpload from '@/components/XForm/ImageUpload';
211 208
 
212
-// import userTrees from './tree'
213 209
 
214
-const { TreeNode, DirectoryTree } = Tree
215
-const FormItem = Form.Item;
216 210
 
217 211
 
218 212
 
219 213
 
220
-const userTree = React.forwardRef((props, ref) => {
221
-  const [loading, setLoading] = useState(false);//防止多次点击 定义loadind
222
-  // const [formData, setFormData] = useState();//提交表单的数据
223
-  const [contentType, setContentType] = useState(1);//单选。初始默认显示1 富文本框。点击视频, 渲染2
224
-  const { form, history } = props;
225
-  const { getFieldDecorator, setFieldsValue, validateFields } = form;
226
-  const {RangePicker} = DatePicker;
227
-  const { curriculumId } = history.location.query || {}
228
-  const formItemLayout = {
229
-    //布局
230
-    labelCol: { span: 6 },
231
-    wrapperCol: { span: 14 },
214
+import { Row, Col, Card, Tree, DatePicker, Form, Input, InputNumber, Radio, Button } from 'antd'
215
+import { title } from 'echarts/lib/theme/dark';
216
+import React, { useEffect, useState, useCallback,useRef } from 'react';
217
+import TreedataFrom from './form';
218
+
219
+const { TreeNode,DirectoryTree } = Tree;
220
+
221
+// const [treeData, settreeData] = useState([])
222
+
223
+
224
+const treeData = [
225
+  {
226
+    title: '分厂厂长管理',
227
+    key: '0-0',
228
+    children: [
229
+        { title: '刘厂长', key: '0-0-0-1' },
230
+        { title: '王副厂长', key: '0-0-0-2' },
231
+    ],
232
+  },
233
+  {
234
+      title: '分厂员工管理',
235
+      key: '0-0-1',
236
+      children: [
237
+        { title: '王王王', key: '0-0-1-0' },
238
+        { title: '张张张', key: '0-0-1-1' },
239
+        { title: '刘刘刘', key: '0-0-1-2' },
240
+      ],
241
+  },
242
+];
243
+
244
+class Demo extends React.Component {
245
+
246
+  state = {
247
+    expandedKeys: ['0-0', '0-0-1'],
248
+    autoExpandParent: false,
249
+    checkedKeys: ['0-0-1'],
250
+    selectedKeys: [],
251
+  };
252
+
253
+  onExpand = expandedKeys => {
254
+    //自动展开
255
+    console.log('onExpand', expandedKeys);
256
+      // 如果没有将 autoExpandParent 设置为 false,如果子项展开,父项不能折叠。
257
+     // 或者,您可以删除所有扩展的子键。
258
+    this.setState({
259
+      expandedKeys,
260
+      autoExpandParent: false,
261
+    });
262
+  };
263
+
264
+  onCheck = checkedKeys => {
265
+    //单击复选框
266
+    console.log('onCheck', checkedKeys);
267
+    this.setState({ checkedKeys });
268
+    
269
+  };
232 270
 
271
+  onSelect = (selectedKeys, info) => {
272
+    //单击姓名
273
+    for (let i = 0; i < selectedKeys.length; i++) {
274
+      const element = selectedKeys[i];
275
+      console.log(element);
276
+  }
277
+  
278
+    console.log('onSelect',info);
279
+    this.setState({ selectedKeys });
233 280
   };
234 281
 
235
-  return (
236
-    <Card>
237
-      <Row justify='center'>
282
+  renderTreeNodes = data =>
283
+    data.map(item => {
284
+      if (item.children) {
285
+        return (
286
+          <TreeNode title={item.title} key={item.key} dataRef={item}  >
287
+            {this.renderTreeNodes(item.children)}
288
+          </TreeNode>
289
+        );
290
+      }
291
+      return <TreeNode key={item.key} {...item} />;
292
+    });
293
+
294
+
295
+
296
+  render() {
297
+    return (
298
+     <Card>
299
+      <Row>
238 300
         <Col xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 0 }}>
239 301
           <Card>
240
-            <Button type='danger' style={{ marginLeft: '2em' }} >
241
-              删除
242
-            </Button>
243
-            <DirectoryTree >
244
-              <TreeNode title="厂长管理" key="0-0">
245
-                <TreeNode  title="刘张" value='刘帐' key="0-0-0" isLeaf />
246
-                <TreeNode title="李徐" key="0-0-1" isLeaf />
247
-              </TreeNode>
248
-              <TreeNode title="员工管理" key="0-1">
249
-                <TreeNode title="leaf 1-0" key="0-1-0" isLeaf />
250
-                <TreeNode title="leaf 1-1" key="0-1-1" isLeaf />
251
-                <TreeNode title="leaf 1-1" key="0-1-2" isLeaf />
252
-                <TreeNode title="leaf 1-1" key="0-1-3" isLeaf />
253
-                <TreeNode title="leaf 1-1" key="0-1-4" isLeaf />
254
-                <TreeNode title="leaf 1-1" key="0-1-5" isLeaf />
255
-              </TreeNode>
256
-            </DirectoryTree>
302
+              <Tree 
303
+                // checkable
304
+                showLine={true}
305
+                onExpand={this.onExpand}
306
+                expandedKeys={this.state.expandedKeys}
307
+                autoExpandParent={this.state.autoExpandParent}
308
+                onCheck={this.onCheck}
309
+                checkedKeys={this.state.checkedKeys}
310
+                onSelect={this.onSelect}
311
+                selectedKeys={this.state.selectedKeys}
312
+              >
313
+                {this.renderTreeNodes(treeData)}
314
+              </Tree >
257 315
           </Card>
258 316
         </Col>
259
-        {/* FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF>Form表单 */}
260 317
         <Col xs={{ span: 10, offset: 10 }} lg={{ span: 10, offset: 4 }}>
261 318
           <Card>
262
-            
319
+          <TreedataFrom />
263 320
           </Card>
264 321
         </Col>
265 322
       </Row>
266
-    </Card>
267
-
268
-  )
269
-})
270
-
323
+     </Card> 
324
+    );
325
+  }
326
+}
271 327
 
272
-export default Form.create({})(userTree);
328
+export default Demo 

+ 110
- 18
src/pages/staff/Organization/tree.jsx Прегледај датотеку

@@ -1,18 +1,110 @@
1
-import { Tree } from 'antd'
2
-
3
-export default (props) => {
4
-    const { TreeNode, DirectoryTree } = Tree
5
-
6
-    return (
7
-        <DirectoryTree multiple>
8
-            <TreeNode title="parent 0" key="0-0">
9
-                <TreeNode title="leaf 0-0" key="0-0-0" isLeaf />
10
-                <TreeNode title="leaf 0-1" key="0-0-1" isLeaf />
11
-            </TreeNode>
12
-            <TreeNode title="parent 1" key="0-1">
13
-                <TreeNode title="leaf 1-0" key="0-1-0" isLeaf />
14
-                <TreeNode title="leaf 1-1" key="0-1-1" isLeaf />
15
-            </TreeNode>
16
-        </DirectoryTree>
17
-    )
18
-}
1
+
2
+
3
+
4
+// import { Tree } from 'antd';
5
+
6
+// const { TreeNode } = Tree;
7
+
8
+// const treeData = [
9
+//   {
10
+//     title: '0-0',
11
+//     key: '0-0',
12
+//     children: [
13
+//       {
14
+//         title: '0-0-0',
15
+//         key: '0-0-0',
16
+//         children: [
17
+//           { title: '0-0-0-0', key: '0-0-0-0' },
18
+//           { title: '0-0-0-1', key: '0-0-0-1' },
19
+//           { title: '0-0-0-2', key: '0-0-0-2' },
20
+//         ],
21
+//       },
22
+//       {
23
+//         title: '0-0-1',
24
+//         key: '0-0-1',
25
+//         children: [
26
+//           { title: '0-0-1-0', key: '0-0-1-0' },
27
+//           { title: '0-0-1-1', key: '0-0-1-1' },
28
+//           { title: '0-0-1-2', key: '0-0-1-2' },
29
+//         ],
30
+//       },
31
+//       {
32
+//         title: '0-0-2',
33
+//         key: '0-0-2',
34
+//       },
35
+//     ],
36
+//   },
37
+//   {
38
+//     title: '0-1',
39
+//     key: '0-1',
40
+//     children: [
41
+//       { title: '0-1-0-0', key: '0-1-0-0' },
42
+//       { title: '0-1-0-1', key: '0-1-0-1' },
43
+//       { title: '0-1-0-2', key: '0-1-0-2' },
44
+//     ],
45
+//   },
46
+//   {
47
+//     title: '0-2',
48
+//     key: '0-2',
49
+//   },
50
+// ];
51
+
52
+// class Demo extends React.Component {
53
+//   state = {
54
+//     expandedKeys: ['0-0-0', '0-0-1'],
55
+//     autoExpandParent: true,
56
+//     checkedKeys: ['0-0-0'],
57
+//     selectedKeys: [],
58
+//   };
59
+
60
+//   onExpand = expandedKeys => {
61
+//     console.log('onExpand', expandedKeys);
62
+//     // if not set autoExpandParent to false, if children expanded, parent can not collapse.
63
+//     // or, you can remove all expanded children keys.
64
+//     this.setState({
65
+//       expandedKeys,
66
+//       autoExpandParent: false,
67
+//     });
68
+//   };
69
+
70
+//   onCheck = checkedKeys => {
71
+//     console.log('onCheck', checkedKeys);
72
+//     this.setState({ checkedKeys });
73
+//   };
74
+
75
+//   onSelect = (selectedKeys, info) => {
76
+//     console.log('onSelect', info);
77
+//     this.setState({ selectedKeys });
78
+//   };
79
+
80
+//   renderTreeNodes = data =>
81
+//     data.map(item => {
82
+//       if (item.children) {
83
+//         return (
84
+//           <TreeNode title={item.title} key={item.key} dataRef={item}>
85
+//             {this.renderTreeNodes(item.children)}
86
+//           </TreeNode>
87
+//         );
88
+//       }
89
+//       return <TreeNode key={item.key} {...item} />;
90
+//     });
91
+
92
+//   render() {
93
+//     return (
94
+//       <Tree
95
+//         checkable
96
+//         onExpand={this.onExpand}
97
+//         expandedKeys={this.state.expandedKeys}
98
+//         autoExpandParent={this.state.autoExpandParent}
99
+//         onCheck={this.onCheck}
100
+//         checkedKeys={this.state.checkedKeys}
101
+//         onSelect={this.onSelect}
102
+//         selectedKeys={this.state.selectedKeys}
103
+//       >
104
+//         {this.renderTreeNodes(treeData)}
105
+//       </Tree>
106
+//     );
107
+//   }
108
+// }
109
+
110
+// export default Demo