林凡 5 年之前
父節點
當前提交
c1d65ba470

+ 63
- 0
src/components/SelectButton/CitySelect2.jsx 查看文件

1
+import React, { useState, useEffect } from 'react';
2
+import { Select } from 'antd';
3
+
4
+import request from '../../utils/request'
5
+
6
+const { Option } = Select;
7
+
8
+/**
9
+ *
10
+ *
11
+ * @param {*} props
12
+ * @returns
13
+ */
14
+const CitySelect = (props) => {
15
+  const [ data, setData ] = useState([])
16
+
17
+  useEffect(() => {
18
+    getCityList();
19
+  },[props.value])
20
+
21
+  const getCityList = (e) => {
22
+    request({
23
+        url: '/api/admin/tdCityList/tdCity',
24
+        method: 'GET',
25
+        params: {leveltype: 2, pageNum: 1,pageSize: 999},
26
+        action: 'select',
27
+    }).then((data) => {
28
+        setData(data)
29
+        getValue(data);
30
+        console.log('---123---')
31
+    })
32
+  }
33
+
34
+  /**
35
+   * 因为 有个需求是,如果这个城市被删除了,那么就直接展示为空,不能展示 cityId
36
+   */
37
+  const getValue = (data) => {
38
+    console.log(props.value)
39
+    if (props.value) {
40
+      const tempData = data.filter(f => f.id == props.value)
41
+      const va = (tempData.length > 0) ? props.value : undefined
42
+      props.onChange(va)
43
+    }
44
+  }
45
+
46
+  return (
47
+      <Select
48
+      showSearch
49
+      value={props.value}
50
+      style={{ width: '180px' }}
51
+      placeholder="请选择城市"
52
+      onChange={props.onChange}
53
+      filterOption={(input, option) =>
54
+        option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
55
+      }
56
+      >
57
+          {data.map(city => (
58
+            <Option key={city.id} value={city.id}>{city.name}</Option>
59
+          ))}
60
+      </Select>
61
+  )
62
+}
63
+export default CitySelect

+ 1
- 2
src/pages/carouselFigure/SelectH5.jsx 查看文件

24
       params: {
24
       params: {
25
         pageNum: 1,
25
         pageNum: 1,
26
         pageSize: 999,
26
         pageSize: 999,
27
-        isMiniapp: 1,
28
-        status: 1,
29
       },
27
       },
30
     }).then(data => {
28
     }).then(data => {
31
       setList(data.records || [])
29
       setList(data.records || [])
30
+
32
       updateGroup(value ? undefined : value);
31
       updateGroup(value ? undefined : value);
33
     })
32
     })
34
   }, []);
33
   }, []);

+ 1
- 1
src/pages/carouselFigure/SelectHelp.jsx 查看文件

21
   const updateHelp = val => setHelp({ helpId: val, helpName: getHelpTitle(val) })
21
   const updateHelp = val => setHelp({ helpId: val, helpName: getHelpTitle(val) })
22
 
22
 
23
   const buildingId = props.buildingId()
23
   const buildingId = props.buildingId()
24
-
24
+  
25
   useEffect(() => {
25
   useEffect(() => {
26
     getHelpList({
26
     getHelpList({
27
       params: {
27
       params: {

+ 57
- 20
src/pages/carouselFigure/editAdvertising.jsx 查看文件

5
 import moment from 'moment';
5
 import moment from 'moment';
6
 import router from 'umi/router';
6
 import router from 'umi/router';
7
 import BuildSelect from '../../components/SelectButton/BuildSelect'
7
 import BuildSelect from '../../components/SelectButton/BuildSelect'
8
-import CitySelect from '../../components/SelectButton/CitySelect'
8
+import CitySelect from '../../components/SelectButton/CitySelect2'
9
 import { FieldTypes, createForm } from '../../components/XForm';
9
 import { FieldTypes, createForm } from '../../components/XForm';
10
 import Wangedit from '../../components/Wangedit/Wangedit';
10
 import Wangedit from '../../components/Wangedit/Wangedit';
11
 import SelectActivity from './SelectActivity';
11
 import SelectActivity from './SelectActivity';
27
   let newsVisible = false
27
   let newsVisible = false
28
   let helpVisible = false
28
   let helpVisible = false
29
   let groupVisible = false
29
   let groupVisible = false
30
-  let h5Visible = false
31
   let buildingId = ''
30
   let buildingId = ''
32
   let cityId = ''
31
   let cityId = ''
32
+  let isHaveActive=false
33
+  let isCanChoose=true
33
 
34
 
34
   const setExtraData = (data) => {
35
   const setExtraData = (data) => {
36
+    if(data.isHaveActive!=undefined){
37
+      isHaveActive=data.isHaveActive
38
+      if(!isHaveActive) {
39
+        data.contentType=null
40
+        data.buildingId=null
41
+      }
42
+    }
43
+
35
     contentVisible = data.contentType === 'other';
44
     contentVisible = data.contentType === 'other';
36
     activityVisible = data.contentType === 'activity';
45
     activityVisible = data.contentType === 'activity';
37
     newsVisible = data.contentType === 'news';
46
     newsVisible = data.contentType === 'news';
38
     helpVisible = data.contentType === 'help';
47
     helpVisible = data.contentType === 'help';
39
     groupVisible = data.contentType === 'group';
48
     groupVisible = data.contentType === 'group';
40
-    h5Visible = data.contentType === 'h5';
41
     cityId=data.cityId
49
     cityId=data.cityId
42
     buildingId = data.buildingId
50
     buildingId = data.buildingId
43
   }
51
   }
44
 
52
 
53
+  const setExtraData1 = (data) => {
54
+     if(data.title){
55
+         isHaveActive=true
56
+     }else{
57
+        isHaveActive=false
58
+     }
59
+      debugger
60
+    contentVisible = data.contentType === 'other';
61
+    activityVisible = data.contentType === 'activity';
62
+    newsVisible = data.contentType === 'news';
63
+    helpVisible = data.contentType === 'help';
64
+    groupVisible = data.contentType === 'group';
65
+    buildingId = data.buildingId
66
+  }
45
 
67
 
46
   const handleFormValueChange = (props, changedValues, allValues) => {
68
   const handleFormValueChange = (props, changedValues, allValues) => {
47
       setExtraData(allValues)
69
       setExtraData(allValues)
55
     const [ data, setData ] = useState({})
77
     const [ data, setData ] = useState({})
56
 
78
 
57
     if(contentId){
79
     if(contentId){
80
+      isCanChoose=false
58
       useEffect(() => {
81
       useEffect(() => {
59
         getDetail(contentId);
82
         getDetail(contentId);
60
       },[])
83
       },[])
62
       // 查询列表
85
       // 查询列表
63
       const getDetail = (contentId) => {
86
       const getDetail = (contentId) => {
64
         request({ ...apis.carsuseFigure.getExtendContent,urlData:{id: contentId}}).then((data) => {
87
         request({ ...apis.carsuseFigure.getExtendContent,urlData:{id: contentId}}).then((data) => {
65
-          setExtraData(data)
66
           setData(data)
88
           setData(data)
89
+          setExtraData1(data)
67
         })
90
         })
68
       }
91
       }
92
+    }else{
93
+      isCanChoose=true
69
     }
94
     }
70
 
95
 
71
     const cancelPage = () =>{
96
     const cancelPage = () =>{
75
     }
100
     }
76
 
101
 
77
     const fields = [
102
     const fields = [
103
+      {
104
+        label: '是否关联项目',
105
+        name: 'isHaveActive',
106
+        type: FieldTypes.Switch,
107
+        value:isHaveActive,
108
+        hidden: () => !isCanChoose,
109
+        rules: [
110
+          { required: true,message: '是否城市活动' },
111
+        ],
112
+      },
78
       {
113
       {
79
         label: '所属项目',
114
         label: '所属项目',
80
         name: 'buildingId',
115
         name: 'buildingId',
81
         render: <BuildSelect />,
116
         render: <BuildSelect />,
82
         value: data.buildingId,
117
         value: data.buildingId,
118
+        hidden: () => !isHaveActive,
83
         rules: [
119
         rules: [
84
           { required: true, message: '请选择所属项目' },
120
           { required: true, message: '请选择所属项目' },
85
         ],
121
         ],
88
         label: '展示城市',
124
         label: '展示城市',
89
         name: 'cityId',
125
         name: 'cityId',
90
         render: <CitySelect />,
126
         render: <CitySelect />,
127
+        hidden: () => isHaveActive,
91
         value: data.cityId,
128
         value: data.cityId,
92
         rules: [
129
         rules: [
93
           { required: true, message: '请选择展示城市' },
130
           { required: true, message: '请选择展示城市' },
103
           { required: true, message: '请上传图片' },
140
           { required: true, message: '请上传图片' },
104
         ],
141
         ],
105
       },
142
       },
143
+      {
144
+        label: '是否发布H5',
145
+        name: 'targetId',
146
+        render: <SelectH5/>,
147
+        hidden: () => isHaveActive,
148
+        value: data.targetId,
149
+        rules: [
150
+          { required: false, message: '请选择发布H5' },
151
+        ],
152
+      },
106
       {
153
       {
107
         label: '标题',
154
         label: '标题',
108
         name: 'title',
155
         name: 'title',
109
         type: FieldTypes.Text,
156
         type: FieldTypes.Text,
110
-        hidden: true,
157
+        hidden: () => !isHaveActive,
111
         value: data.title,
158
         value: data.title,
112
         rules: [
159
         rules: [
113
           { required: true, message: '请输入标题' },
160
           { required: true, message: '请输入标题' },
116
       {
163
       {
117
         label: '类型',
164
         label: '类型',
118
         name: 'contentType',
165
         name: 'contentType',
166
+        hidden: () => !isHaveActive,
119
         type: FieldTypes.Select,
167
         type: FieldTypes.Select,
120
         dict: [{
168
         dict: [{
121
           label: '常规活动',
169
           label: '常规活动',
140
         {
188
         {
141
           label: '助力',
189
           label: '助力',
142
           value: 'help'
190
           value: 'help'
143
-        },
144
-        {
145
-          label: 'H5',
146
-          value: 'h5'
147
         }],
191
         }],
148
         value: data.contentType,
192
         value: data.contentType,
149
         rules: [
193
         rules: [
150
-          { required: false, message: '请选择类型' },
194
+          { required: true, message: '请选择类型' },
151
         ],
195
         ],
152
       },
196
       },
153
       {
197
       {
200
           { required: true, message: '请选择发布拼团' },
244
           { required: true, message: '请选择发布拼团' },
201
         ],
245
         ],
202
       },
246
       },
203
-      {
204
-        label: '发布H5',
205
-        name: 'targetId',
206
-        render: <SelectH5/>,
207
-        hidden: () => !h5Visible,
208
-        value: data.targetId,
209
-        rules: [
210
-          { required: true, message: '请选择发布H5' },
211
-        ],
212
-      },
213
       {
247
       {
214
         label: '状态',
248
         label: '状态',
215
         name: 'status',
249
         name: 'status',
235
           message.info(err.msg || err.message)
269
           message.info(err.msg || err.message)
236
         })
270
         })
237
       }else{
271
       }else{
272
+        if(!val.isHaveActive&&val.targetId) {
273
+          val.contentType='h5'
274
+        }
238
         request({ ...apis.carsuseFigure.addExtendContent, data: val,}).then((data) => {
275
         request({ ...apis.carsuseFigure.addExtendContent, data: val,}).then((data) => {
239
           cancelPage()
276
           cancelPage()
240
         }).catch((err) => {
277
         }).catch((err) => {

+ 63
- 22
src/pages/carouselFigure/editCarousel.jsx 查看文件

5
 import router from 'umi/router';
5
 import router from 'umi/router';
6
 import styles from '../style/GoodsList.less';
6
 import styles from '../style/GoodsList.less';
7
 import BuildSelect from '../../components/SelectButton/BuildSelect'
7
 import BuildSelect from '../../components/SelectButton/BuildSelect'
8
-import CitySelect from '../../components/SelectButton/CitySelect'
8
+import CitySelect from '../../components/SelectButton/CitySelect2'
9
 import { createForm, FieldTypes } from '../../components/XForm';
9
 import { createForm, FieldTypes } from '../../components/XForm';
10
 import Wangedit from '../../components/Wangedit/Wangedit'
10
 import Wangedit from '../../components/Wangedit/Wangedit'
11
 import apis from '../../services/apis';
11
 import apis from '../../services/apis';
29
   let newsVisible = false
29
   let newsVisible = false
30
   let helpVisible = false
30
   let helpVisible = false
31
   let groupVisible = false
31
   let groupVisible = false
32
-  let h5Visible=false
33
   let buildingId = ''
32
   let buildingId = ''
34
   let cityId=''
33
   let cityId=''
35
   let locationType = false
34
   let locationType = false
35
+  let isHaveActive=false
36
+  let isCanChoose=true
36
 
37
 
37
   const setExtraData = (data) => {
38
   const setExtraData = (data) => {
38
     console.log(data, 'data');
39
     console.log(data, 'data');
40
+    if(data.isHaveActive!=undefined){
41
+      isHaveActive=data.isHaveActive
42
+      if(!isHaveActive) {
43
+        data.contentType=null
44
+        data.buildingId=null
45
+      }
46
+    }
39
 
47
 
40
     contentVisible = data.contentType === 'other';
48
     contentVisible = data.contentType === 'other';
41
     activityVisible = data.contentType === 'activity';
49
     activityVisible = data.contentType === 'activity';
42
     newsVisible = data.contentType === 'news';
50
     newsVisible = data.contentType === 'news';
43
     helpVisible = data.contentType === 'help';
51
     helpVisible = data.contentType === 'help';
44
     groupVisible = data.contentType === 'group';
52
     groupVisible = data.contentType === 'group';
45
-    h5Visible = data.contentType === 'h5';
46
 
53
 
47
     cityId=data.cityId
54
     cityId=data.cityId
48
     buildingId = data.buildingId
55
     buildingId = data.buildingId
50
     console.log(locationType, 'locationType');
57
     console.log(locationType, 'locationType');
51
   }
58
   }
52
 
59
 
60
+  const setExtraData1 = (data) => {
61
+     if(data.title){
62
+        isHaveActive=true
63
+     }else{
64
+        isHaveActive=false
65
+     }
66
+     debugger
67
+    contentVisible = data.contentType === 'other';
68
+    activityVisible = data.contentType === 'activity';
69
+    newsVisible = data.contentType === 'news';
70
+    helpVisible = data.contentType === 'help';
71
+    groupVisible = data.contentType === 'group';
72
+    buildingId = data.buildingId
73
+    locationType = data.showPosition === 'mall';
74
+    console.log(locationType, 'locationType');
75
+  }
76
+
77
+
53
   const handleFormValueChange = (props, changedValues, allValues) => {
78
   const handleFormValueChange = (props, changedValues, allValues) => {
54
       setExtraData(allValues)
79
       setExtraData(allValues)
55
   }
80
   }
62
     const [data, setData] = useState({})
87
     const [data, setData] = useState({})
63
 
88
 
64
     if (contentId) {
89
     if (contentId) {
90
+      isCanChoose=false
65
       // eslint-disable-next-line react-hooks/rules-of-hooks
91
       // eslint-disable-next-line react-hooks/rules-of-hooks
66
       useEffect(() => {
92
       useEffect(() => {
67
         getDetail(contentId);
93
         getDetail(contentId);
71
       const getDetail = contentId => {
97
       const getDetail = contentId => {
72
         request({ ...apis.carsuseFigure.getExtendContent, urlData: { id: contentId } }).then(data => {
98
         request({ ...apis.carsuseFigure.getExtendContent, urlData: { id: contentId } }).then(data => {
73
             console.log(data)
99
             console.log(data)
74
-            setExtraData(data)
100
+            setExtraData1(data)
75
             setData(data)
101
             setData(data)
76
         })
102
         })
77
       }
103
       }
104
+    }else{
105
+      isCanChoose=true
78
     }
106
     }
79
 
107
 
80
     const cancelPage = () => {
108
     const cancelPage = () => {
84
     }
112
     }
85
 
113
 
86
       const fields = [
114
       const fields = [
115
+        {
116
+          label: '是否关联项目',
117
+          name: 'isHaveActive',
118
+          type: FieldTypes.Switch,
119
+          value:isHaveActive,
120
+          hidden: () => !isCanChoose,
121
+          rules: [
122
+            { required: true,message: '是否城市活动' },
123
+          ],
124
+        },
87
         {
125
         {
88
           label: '所属项目',
126
           label: '所属项目',
89
           name: 'buildingId',
127
           name: 'buildingId',
90
-          render: <BuildSelect/>,
128
+          render: <BuildSelect />,
129
+          hidden: () => !isHaveActive,
91
           value: data.buildingId,
130
           value: data.buildingId,
92
           rules: [
131
           rules: [
93
             { required: true, message: '请选择所属项目' },
132
             { required: true, message: '请选择所属项目' },
96
         {
135
         {
97
           label: '展示城市',
136
           label: '展示城市',
98
           name: 'cityId',
137
           name: 'cityId',
99
-          render: <CitySelect/>,
138
+          render: <CitySelect />,
139
+          hidden: () => isHaveActive,
100
           value: data.cityId,
140
           value: data.cityId,
101
           rules: [
141
           rules: [
102
             { required: true, message: '请选择展示城市' },
142
             { required: true, message: '请选择展示城市' },
129
             { required: true, message: '请上传轮播图' },
169
             { required: true, message: '请上传轮播图' },
130
           ],
170
           ],
131
         },
171
         },
172
+        {
173
+          label: '是否发布H5',
174
+          name: 'targetId',
175
+          render: <SelectH5/>,
176
+          hidden: () => isHaveActive,
177
+          value: data.targetId,
178
+          rules: [
179
+            { required: false, message: '请选择发布H5' },
180
+          ],
181
+        },
132
         {
182
         {
133
           label: '标题',
183
           label: '标题',
134
           name: 'title',
184
           name: 'title',
135
           type: FieldTypes.Text,
185
           type: FieldTypes.Text,
136
           value: data.title,
186
           value: data.title,
137
-          hidden: true,
187
+          hidden: () => !isHaveActive,
138
           rules: [
188
           rules: [
139
             { required: true, message: '请输入标题' },
189
             { required: true, message: '请输入标题' },
140
           ],
190
           ],
143
           label: '类型',
193
           label: '类型',
144
           name: 'contentType',
194
           name: 'contentType',
145
           type: FieldTypes.Select,
195
           type: FieldTypes.Select,
196
+          hidden: () => !isHaveActive,
146
           dict: [{
197
           dict: [{
147
             label: '常规活动',
198
             label: '常规活动',
148
             value: 'activity',
199
             value: 'activity',
166
           {
217
           {
167
             label: '助力',
218
             label: '助力',
168
             value: 'help',
219
             value: 'help',
169
-          },
170
-          {
171
-            label: 'H5',
172
-            value: 'h5',
173
           }],
220
           }],
174
           value: data.contentType,
221
           value: data.contentType,
175
           rules: [
222
           rules: [
176
-            { required: false, message: '请选择类型' },
223
+            { required: true, message: '请选择类型' },
177
           ],
224
           ],
178
         },
225
         },
179
         {
226
         {
226
             { required: true, message: '请选择发布拼团' },
273
             { required: true, message: '请选择发布拼团' },
227
           ],
274
           ],
228
         },
275
         },
229
-        {
230
-          label: '发布H5',
231
-          name: 'targetId',
232
-          render: <SelectH5/>,
233
-          hidden: () => !h5Visible,
234
-          value: data.targetId,
235
-          rules: [
236
-            { required: true, message: '请选择发布H5' },
237
-          ],
238
-        },
239
         {
276
         {
240
           label: '状态',
277
           label: '状态',
241
           name: 'status',
278
           name: 'status',
253
       ]
290
       ]
254
 
291
 
255
       const handleSubmit = val => {
292
       const handleSubmit = val => {
293
+        debugger
256
         val.showType = 'banner'
294
         val.showType = 'banner'
257
         if (contentId) {
295
         if (contentId) {
258
           request({ ...apis.carsuseFigure.updataExtendContent, urlData: { id: contentId }, data: val }).then(data => {
296
           request({ ...apis.carsuseFigure.updataExtendContent, urlData: { id: contentId }, data: val }).then(data => {
261
             message.info(err.msg || err.message)
299
             message.info(err.msg || err.message)
262
           })
300
           })
263
         } else {
301
         } else {
302
+          if(!val.isHaveActive&&val.targetId) {
303
+            val.contentType='h5'
304
+          }
264
           request({ ...apis.carsuseFigure.addExtendContent, data: val }).then(data => {
305
           request({ ...apis.carsuseFigure.addExtendContent, data: val }).then(data => {
265
             cancelPage()
306
             cancelPage()
266
           }).catch(err => {
307
           }).catch(err => {