|
@@ -1,4 +1,4 @@
|
1
|
|
-import React, { useState, useEffect } from 'react';
|
|
1
|
+import React, { useState, useEffect, useRef } from 'react';
|
2
|
2
|
import { Modal, message } from 'antd';
|
3
|
3
|
import { FormattedMessage } from 'umi-plugin-react/locale';
|
4
|
4
|
import styles from '../style/GoodsList.less';
|
|
@@ -23,7 +23,7 @@ import LiveGroup from './LiveGroup';
|
23
|
23
|
* @param {*} props
|
24
|
24
|
* @returns
|
25
|
25
|
*/
|
26
|
|
- const createEditor = () => {
|
|
26
|
+const createEditor = () => {
|
27
|
27
|
let contentVisible = false
|
28
|
28
|
let activityVisible = false
|
29
|
29
|
let newsVisible = false
|
|
@@ -34,22 +34,22 @@ import LiveGroup from './LiveGroup';
|
34
|
34
|
let h5Visible = false
|
35
|
35
|
let buildingId = ''
|
36
|
36
|
let cityId = ''
|
37
|
|
- let isHaveActive=false
|
38
|
|
- let isCanChoose=true
|
|
37
|
+ let isHaveActive = false
|
|
38
|
+ let isCanChoose = true
|
39
|
39
|
let isHavePosition = false
|
40
|
40
|
|
41
|
41
|
const setExtraData = (data) => {
|
42
|
|
- if(data.isHaveActive!=undefined){
|
43
|
|
- isHaveActive=data.isHaveActive
|
44
|
|
- if(!isHaveActive) {
|
|
42
|
+ if (data.isHaveActive != undefined) {
|
|
43
|
+ isHaveActive = data.isHaveActive
|
|
44
|
+ if (!isHaveActive) {
|
45
|
45
|
// data.contentType=null
|
46
|
|
- data.buildingId=null
|
|
46
|
+ data.buildingId = null
|
47
|
47
|
}
|
48
|
48
|
}
|
49
|
49
|
|
50
|
|
- if (data.showPosition == 'index'){
|
|
50
|
+ if (data.showPosition == 'index') {
|
51
|
51
|
isHavePosition = true;
|
52
|
|
- }else{
|
|
52
|
+ } else {
|
53
|
53
|
isHavePosition = false;
|
54
|
54
|
}
|
55
|
55
|
|
|
@@ -62,16 +62,16 @@ import LiveGroup from './LiveGroup';
|
62
|
62
|
liveVisible = data.contentType === 'live';
|
63
|
63
|
h5Visible = data.contentType === 'h5';
|
64
|
64
|
|
65
|
|
- cityId=data.cityId
|
|
65
|
+ cityId = data.cityId
|
66
|
66
|
buildingId = data.buildingId
|
67
|
67
|
}
|
68
|
68
|
|
69
|
69
|
const setExtraData1 = (data) => {
|
70
|
|
- console.log(data.buildingId,"data.buildingIddata.buildingId2")
|
71
|
|
- if((data.contentType=='h5' && data.buildingId == null) || data.contentType==''||data.contentType=='nothing' || (data.contentType=='live' && data.buildingId == null)){
|
72
|
|
- isHaveActive=false
|
73
|
|
- }else{
|
74
|
|
- isHaveActive=true
|
|
70
|
+ console.log(data.buildingId, "data.buildingIddata.buildingId2")
|
|
71
|
+ if ((data.contentType == 'h5' && data.buildingId == null) || data.contentType == '' || data.contentType == 'nothing' || (data.contentType == 'live' && data.buildingId == null)) {
|
|
72
|
+ isHaveActive = false
|
|
73
|
+ } else {
|
|
74
|
+ isHaveActive = true
|
75
|
75
|
}
|
76
|
76
|
|
77
|
77
|
contentVisible = data.contentType === 'other';
|
|
@@ -86,34 +86,34 @@ import LiveGroup from './LiveGroup';
|
86
|
86
|
}
|
87
|
87
|
|
88
|
88
|
const handleFormValueChange = (props, changedValues, allValues) => {
|
89
|
|
- setExtraData(allValues)
|
|
89
|
+ setExtraData(allValues)
|
90
|
90
|
}
|
91
|
91
|
|
92
|
92
|
const XForm = createForm({ onValuesChange: handleFormValueChange })
|
93
|
93
|
|
94
|
94
|
return (props) => {
|
95
|
|
- const [ tab, changeTab ] = useState('basic')
|
|
95
|
+ const [tab, changeTab] = useState('basic')
|
96
|
96
|
const contentId = props.location.query.contentId
|
97
|
|
- const [ data, setData ] = useState({})
|
|
97
|
+ const [data, setData] = useState({})
|
|
98
|
+ const formRef = useRef(null);
|
98
|
99
|
|
99
|
|
- if(contentId){
|
100
|
|
- isCanChoose=false
|
101
|
|
- useEffect(() => {
|
|
100
|
+ // 查询列表
|
|
101
|
+ const getDetail = contentId => {
|
|
102
|
+ request({ ...apis.carsuseFigure.getExtendContent, urlData: { id: contentId } }).then((data) => {
|
|
103
|
+ setExtraData1(data)
|
|
104
|
+ setData(data)
|
|
105
|
+ })
|
|
106
|
+ }
|
|
107
|
+ useEffect(() => {
|
|
108
|
+ if (contentId) {
|
|
109
|
+ isCanChoose = false
|
102
|
110
|
getDetail(contentId);
|
103
|
|
- },[])
|
104
|
|
-
|
105
|
|
- // 查询列表
|
106
|
|
- const getDetail = (contentId) => {
|
107
|
|
- request({ ...apis.carsuseFigure.getExtendContent,urlData:{id: contentId}}).then((data) => {
|
108
|
|
- setExtraData1(data)
|
109
|
|
- setData(data)
|
110
|
|
- })
|
|
111
|
+ } else {
|
|
112
|
+ isCanChoose = true
|
111
|
113
|
}
|
112
|
|
- }else{
|
113
|
|
- isCanChoose=true
|
114
|
|
- }
|
|
114
|
+ }, [])
|
115
|
115
|
|
116
|
|
- const cancelPage = () =>{
|
|
116
|
+ const cancelPage = () => {
|
117
|
117
|
router.push({
|
118
|
118
|
pathname: '/carouselFigure/advertisingList',
|
119
|
119
|
});
|
|
@@ -124,17 +124,26 @@ import LiveGroup from './LiveGroup';
|
124
|
124
|
label: '是否关联项目',
|
125
|
125
|
name: 'isHaveActive',
|
126
|
126
|
type: FieldTypes.Switch,
|
127
|
|
- value:isHaveActive,
|
|
127
|
+ value: isHaveActive,
|
128
|
128
|
hidden: () => !isCanChoose,
|
|
129
|
+ props: {
|
|
130
|
+ onChange: () => {
|
|
131
|
+ const type = formRef.current.props.form.getFieldValue('contentType')
|
|
132
|
+ if (formRef.current && (type !== 'live' && type !== 'h5' )) {
|
|
133
|
+ console.log(formRef.current.props.form.getFieldValue('contentType'), '2222')
|
|
134
|
+ formRef.current.props.form.resetFields(['contentType', []]);
|
|
135
|
+ }
|
|
136
|
+ },
|
|
137
|
+ },
|
129
|
138
|
rules: [
|
130
|
|
- { required: true,message: '是否城市活动' },
|
|
139
|
+ { required: true, message: '是否城市活动' },
|
131
|
140
|
],
|
132
|
141
|
},
|
133
|
142
|
{
|
134
|
143
|
label: '发布位置',
|
135
|
144
|
name: 'showPosition',
|
136
|
145
|
type: FieldTypes.Select,
|
137
|
|
- value:isHaveActive,
|
|
146
|
+ value: isHaveActive,
|
138
|
147
|
dict: [{
|
139
|
148
|
label: '首页',
|
140
|
149
|
value: 'index',
|
|
@@ -249,13 +258,13 @@ import LiveGroup from './LiveGroup';
|
249
|
258
|
],
|
250
|
259
|
},
|
251
|
260
|
{
|
252
|
|
- label: '是否发布H5',
|
|
261
|
+ label: '是否发布H5活动',
|
253
|
262
|
name: 'targetId',
|
254
|
263
|
render: <SelectH5 buildingId={() => buildingId} />,
|
255
|
264
|
hidden: () => !h5Visible,
|
256
|
265
|
value: data.targetId,
|
257
|
266
|
rules: [
|
258
|
|
- { required: false, message: '请选择发布H5' },
|
|
267
|
+ { required: true, message: '请选择发布H5' },
|
259
|
268
|
],
|
260
|
269
|
},
|
261
|
270
|
{
|
|
@@ -346,22 +355,22 @@ import LiveGroup from './LiveGroup';
|
346
|
355
|
|
347
|
356
|
const handleSubmit = val => {
|
348
|
357
|
val.showType = 'screen'
|
349
|
|
- if(!isHaveActive&&val.targetId) {
|
350
|
|
- if(!val.contentType){
|
351
|
|
- val.contentType='h5'
|
352
|
|
- }
|
|
358
|
+ if (!isHaveActive && val.targetId) {
|
|
359
|
+ if (!val.contentType) {
|
|
360
|
+ val.contentType = 'h5'
|
|
361
|
+ }
|
353
|
362
|
}
|
354
|
|
- if(!isHaveActive&&!val.targetId){
|
355
|
|
- val.contentType=''
|
|
363
|
+ if (!isHaveActive && !val.targetId) {
|
|
364
|
+ val.contentType = ''
|
356
|
365
|
}
|
357
|
|
- if(contentId){
|
358
|
|
- request({ ...apis.carsuseFigure.updataExtendContent,urlData:{id: contentId}, data: val,}).then((data) => {
|
|
366
|
+ if (contentId) {
|
|
367
|
+ request({ ...apis.carsuseFigure.updataExtendContent, urlData: { id: contentId }, data: val, }).then((data) => {
|
359
|
368
|
cancelPage()
|
360
|
369
|
}).catch((err) => {
|
361
|
370
|
message.info(err.msg || err.message)
|
362
|
371
|
})
|
363
|
|
- }else{
|
364
|
|
- request({ ...apis.carsuseFigure.addExtendContent, data: val,}).then((data) => {
|
|
372
|
+ } else {
|
|
373
|
+ request({ ...apis.carsuseFigure.addExtendContent, data: val, }).then((data) => {
|
365
|
374
|
cancelPage()
|
366
|
375
|
}).catch((err) => {
|
367
|
376
|
message.info(err.msg || err.message)
|
|
@@ -371,9 +380,9 @@ import LiveGroup from './LiveGroup';
|
371
|
380
|
|
372
|
381
|
|
373
|
382
|
return (
|
374
|
|
- <XForm onSubmit={handleSubmit} onCancel={cancelPage} onValuesChange={handleFormValueChange} fields={fields}></XForm>
|
|
383
|
+ <XForm wrappedComponentRef={formRef} onSubmit={handleSubmit} onCancel={cancelPage} onValuesChange={handleFormValueChange} fields={fields}></XForm>
|
375
|
384
|
);
|
376
|
|
- }
|
377
|
|
- }
|
|
385
|
+ }
|
|
386
|
+}
|
378
|
387
|
|
379
|
388
|
export default createEditor()
|