|
@@ -1,46 +1,67 @@
|
1
|
1
|
import React, { useState, useEffect } from 'react';
|
2
|
|
-import { Form, Input, Button, Icon, Select, Tabs, Radio, DatePicker,message } from 'antd';
|
|
2
|
+import { Modal, message } from 'antd';
|
3
|
3
|
import { FormattedMessage } from 'umi-plugin-react/locale';
|
4
|
4
|
import styles from '../style/GoodsList.less';
|
5
|
5
|
import moment from 'moment';
|
6
|
6
|
import router from 'umi/router';
|
7
|
7
|
import BuildSelect from '../../components/SelectButton/BuildSelect'
|
8
|
|
-import XForm, { FieldTypes } from '../../components/XForm';
|
9
|
|
-import Wangedit from '../../components/Wangedit/Wangedit'
|
|
8
|
+import { FieldTypes, createForm } from '../../components/XForm';
|
|
9
|
+import Wangedit from '../../components/Wangedit/Wangedit';
|
|
10
|
+import SelectActivity from './SelectActivity';
|
|
11
|
+import SelectNews from './SelectNews';
|
10
|
12
|
import apis from '../../services/apis';
|
11
|
13
|
import request from '../../utils/request'
|
12
|
14
|
|
13
|
|
-const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
|
14
|
15
|
/**
|
15
|
16
|
*
|
16
|
17
|
*
|
17
|
18
|
* @param {*} props
|
18
|
19
|
* @returns
|
19
|
20
|
*/
|
20
|
|
- const Edit = (props) => {
|
21
|
|
- const [ tab, changeTab ] = useState('basic')
|
22
|
|
- const contentId = props.location.query.contentId
|
23
|
|
- const [ data, setData ] = useState({})
|
24
|
|
- if(contentId){
|
25
|
|
- useEffect(() => {
|
26
|
|
- getDetail(contentId);
|
27
|
|
- },[])
|
|
21
|
+ const createEditor = () => {
|
|
22
|
+ let contentVisible = false
|
|
23
|
+ let activityVisible = false
|
|
24
|
+ let newsVisible = false
|
|
25
|
+ let buildingId = ''
|
28
|
26
|
|
29
|
|
- // 查询列表
|
30
|
|
- const getDetail = (contentId) => {
|
31
|
|
- request({ ...apis.carsuseFigure.getExtendContent,urlData:{id: contentId}}).then((data) => {
|
32
|
|
- console.log(data)
|
33
|
|
- setData(data)
|
34
|
|
- })
|
|
27
|
+ const setExtraData = (data) => {
|
|
28
|
+ contentVisible = data.contentType === 'other';
|
|
29
|
+ activityVisible = data.contentType === 'activity';
|
|
30
|
+ newsVisible = data.contentType === 'news';
|
|
31
|
+ buildingId = data.buildingId
|
35
|
32
|
}
|
|
33
|
+
|
|
34
|
+ const handleFormValueChange = (props, changedValues, allValues) => {
|
|
35
|
+ setExtraData(allValues)
|
36
|
36
|
}
|
37
|
37
|
|
38
|
|
- const cancelPage = () =>{
|
39
|
|
- router.push({
|
40
|
|
- pathname: '/carouselFigure/advertisingList',
|
41
|
|
- });
|
42
|
|
- }
|
43
|
|
-
|
|
38
|
+ const XForm = createForm({ onValuesChange: handleFormValueChange })
|
|
39
|
+
|
|
40
|
+ return (props) => {
|
|
41
|
+ const [ tab, changeTab ] = useState('basic')
|
|
42
|
+ const contentId = props.location.query.contentId
|
|
43
|
+ const [ data, setData ] = useState({})
|
|
44
|
+
|
|
45
|
+ if(contentId){
|
|
46
|
+ useEffect(() => {
|
|
47
|
+ getDetail(contentId);
|
|
48
|
+ },[])
|
|
49
|
+
|
|
50
|
+ // 查询列表
|
|
51
|
+ const getDetail = (contentId) => {
|
|
52
|
+ request({ ...apis.carsuseFigure.getExtendContent,urlData:{id: contentId}}).then((data) => {
|
|
53
|
+ setExtraData(data)
|
|
54
|
+ setData(data)
|
|
55
|
+ })
|
|
56
|
+ }
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ const cancelPage = () =>{
|
|
60
|
+ router.push({
|
|
61
|
+ pathname: '/carouselFigure/advertisingList',
|
|
62
|
+ });
|
|
63
|
+ }
|
|
64
|
+
|
44
|
65
|
const fields = [
|
45
|
66
|
{
|
46
|
67
|
label: '所属项目',
|
|
@@ -60,20 +81,6 @@ const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
|
60
|
81
|
type: FieldTypes.Text,
|
61
|
82
|
value: data.title,
|
62
|
83
|
},
|
63
|
|
- // {
|
64
|
|
- // label: '发布位置',
|
65
|
|
- // name: 'showPosition',
|
66
|
|
- // type: FieldTypes.Select,
|
67
|
|
- // dict: [{
|
68
|
|
- // label: '首页',
|
69
|
|
- // value: 'index'
|
70
|
|
- // },
|
71
|
|
- // {
|
72
|
|
- // label: '商城',
|
73
|
|
- // value: 'mall'
|
74
|
|
- // }],
|
75
|
|
- // value: data.showPosition,
|
76
|
|
- // },
|
77
|
84
|
{
|
78
|
85
|
label: '类型',
|
79
|
86
|
name: 'contentType',
|
|
@@ -96,12 +103,27 @@ const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
|
96
|
103
|
}],
|
97
|
104
|
value: data.contentType,
|
98
|
105
|
},
|
99
|
|
- // {
|
100
|
|
- // label: '发布内容',
|
101
|
|
- // name: 'content',
|
102
|
|
- // render: <Wangedit />,
|
103
|
|
- // value: data.content,
|
104
|
|
- // },
|
|
106
|
+ {
|
|
107
|
+ label: '发布活动',
|
|
108
|
+ name: 'targetId',
|
|
109
|
+ render: <SelectActivity buildingId={() => buildingId} />,
|
|
110
|
+ hidden: () => !activityVisible,
|
|
111
|
+ value: data.targetId,
|
|
112
|
+ },
|
|
113
|
+ {
|
|
114
|
+ label: '发布资讯',
|
|
115
|
+ name: 'targetId',
|
|
116
|
+ render: <SelectNews buildingId={() => buildingId} />,
|
|
117
|
+ hidden: () => !newsVisible,
|
|
118
|
+ value: data.targetId,
|
|
119
|
+ },
|
|
120
|
+ {
|
|
121
|
+ label: '发布内容',
|
|
122
|
+ name: 'content',
|
|
123
|
+ render: <Wangedit />,
|
|
124
|
+ value: data.content,
|
|
125
|
+ hidden: () => !contentVisible,
|
|
126
|
+ },
|
105
|
127
|
{
|
106
|
128
|
label: '状态',
|
107
|
129
|
name: 'status',
|
|
@@ -117,7 +139,7 @@ const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
|
117
|
139
|
value: data.status != null ? data.status : 1,
|
118
|
140
|
},
|
119
|
141
|
]
|
120
|
|
-
|
|
142
|
+
|
121
|
143
|
const handleSubmit = val => {
|
122
|
144
|
val.showType = 'screen'
|
123
|
145
|
if(contentId){
|
|
@@ -134,12 +156,12 @@ const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
|
134
|
156
|
})
|
135
|
157
|
}
|
136
|
158
|
}
|
137
|
|
-
|
138
|
|
- return (
|
139
|
|
- <XForm onSubmit={handleSubmit} onCancel={cancelPage} fields={fields}></XForm>
|
140
|
|
- );
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+ return (
|
|
162
|
+ <XForm onSubmit={handleSubmit} onCancel={cancelPage} onValuesChange={handleFormValueChange} fields={fields}></XForm>
|
|
163
|
+ );
|
|
164
|
+ }
|
141
|
165
|
}
|
142
|
|
-
|
143
|
|
-
|
144
|
|
-
|
145
|
|
-export default Edit
|
|
166
|
+
|
|
167
|
+export default createEditor()
|