林凡 5 gadus atpakaļ
vecāks
revīzija
16068d4ad0

+ 11
- 0
config/routes.js Parādīt failu

@@ -419,6 +419,17 @@ export default [
419 419
                 hideInMenu: true,
420 420
                 component: './carouselFigure/editAdvertising',
421 421
               },
422
+              {
423
+                path: '/carouselFigure/propagandaList',
424
+                name: '宣传位',
425
+                component: './carouselFigure/propagandaList',
426
+              },
427
+              {
428
+                path: '/carouselFigure/propaganda',
429
+                name: '宣传位编辑',
430
+                hideInMenu: true,
431
+                component: './carouselFigure/propaganda',
432
+              },
422 433
               {
423 434
                 path: '/carouselFigure/customImg/list',
424 435
                 name: '其他',

+ 291
- 0
src/pages/carouselFigure/propaganda.jsx Parādīt failu

@@ -0,0 +1,291 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Modal, message } from 'antd';
3
+import { FormattedMessage } from 'umi-plugin-react/locale';
4
+import styles from '../style/GoodsList.less';
5
+import moment from 'moment';
6
+import router from 'umi/router';
7
+import BuildSelect from '../../components/SelectButton/BuildSelect'
8
+import CitySelect from '../../components/SelectButton/CitySelect2'
9
+import { FieldTypes, createForm } from '../../components/XForm';
10
+import Wangedit from '../../components/Wangedit/Wangedit';
11
+import SelectActivity from './SelectActivity';
12
+import SelectNews from './SelectNews';
13
+import apis from '../../services/apis';
14
+import request from '../../utils/request'
15
+import SelectHelp from './SelectHelp';
16
+import SelectGroup from './SelectGroup';
17
+import SelectH5 from './SelectH5';
18
+/**
19
+ *
20
+ *
21
+ * @param {*} props
22
+ * @returns
23
+ */
24
+ const createEditor = () => {
25
+  let contentVisible = false
26
+  let activityVisible = false
27
+  let newsVisible = false
28
+  let helpVisible = false
29
+  let groupVisible = false
30
+  let buildingId = ''
31
+  let cityId = ''
32
+  let isHaveActive=false
33
+  let isCanChoose=true
34
+
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
+
44
+    contentVisible = data.contentType === 'other';
45
+    activityVisible = data.contentType === 'activity';
46
+    newsVisible = data.contentType === 'news';
47
+    helpVisible = data.contentType === 'help';
48
+    groupVisible = data.contentType === 'group';
49
+    cityId=data.cityId
50
+    buildingId = data.buildingId
51
+  }
52
+
53
+  const setExtraData1 = (data) => {
54
+    if(data.contentType=='h5'||data.contentType==''||data.contentType=='nothing'){
55
+       isHaveActive=false
56
+    }else{
57
+       isHaveActive=true
58
+    }
59
+
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
+  }
67
+
68
+  const handleFormValueChange = (props, changedValues, allValues) => {
69
+      setExtraData(allValues)
70
+  }
71
+
72
+  const XForm = createForm({ onValuesChange: handleFormValueChange })
73
+
74
+  return (props) => {
75
+    const [ tab, changeTab ] = useState('basic')
76
+    const contentId = props.location.query.contentId
77
+    const [ data, setData ] = useState({})
78
+
79
+    if(contentId){
80
+      isCanChoose=false
81
+      useEffect(() => {
82
+        getDetail(contentId);
83
+      },[])
84
+
85
+      // 查询列表
86
+      const getDetail = (contentId) => {
87
+        request({ ...apis.carsuseFigure.getExtendContent,urlData:{id: contentId}}).then((data) => {
88
+          setExtraData1(data)
89
+          setData(data)
90
+        })
91
+      }
92
+    }else{
93
+      isCanChoose=true
94
+    }
95
+
96
+    const cancelPage = () =>{
97
+      router.push({
98
+        pathname: '/carouselFigure/propagandaList',
99
+      });
100
+    }
101
+
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
+      },
113
+      {
114
+        label: '所属项目',
115
+        name: 'buildingId',
116
+        render: <BuildSelect />,
117
+        value: data.buildingId,
118
+        hidden: () => !isHaveActive,
119
+        rules: [
120
+          { required: true, message: '请选择所属项目' },
121
+        ],
122
+      },
123
+      {
124
+        label: '展示城市',
125
+        name: 'cityId',
126
+        render: <CitySelect />,
127
+        hidden: () => isHaveActive,
128
+        value: data.cityId,
129
+        rules: [
130
+          { required: true, message: '请选择展示城市' },
131
+        ],
132
+      },
133
+      {
134
+        label: '开屏广告',
135
+        name: 'image',
136
+        type: FieldTypes.ImageUploader,
137
+        value: data.image,
138
+        help: '建议图片尺寸:640*960px,比例2:3,格式:jpg,用于开屏广告',
139
+        rules: [
140
+          { required: true, message: '请上传图片' },
141
+        ],
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
+      },
153
+      {
154
+        label: '标题',
155
+        name: 'title',
156
+        type: FieldTypes.Text,
157
+        hidden: true,
158
+        value: data.title,
159
+        rules: [
160
+          { required: true, message: '请输入标题' },
161
+        ],
162
+      },
163
+      {
164
+        label: '类型',
165
+        name: 'contentType',
166
+        hidden: () => !isHaveActive,
167
+        type: FieldTypes.Select,
168
+        dict: [{
169
+          label: '常规活动',
170
+          value: 'activity'
171
+        },
172
+        {
173
+          label: '项目',
174
+          value: 'project'
175
+        },
176
+        {
177
+          label: '资讯',
178
+          value: 'news'
179
+        },
180
+        {
181
+          label: '拼团',
182
+          value: 'group'
183
+        },
184
+        {
185
+          label: '助力',
186
+          value: 'help'
187
+        }],
188
+        value: data.contentType,
189
+        rules: [
190
+          { required: true, message: '请选择类型' },
191
+        ],
192
+      },
193
+      {
194
+        label: '发布活动',
195
+        name: 'targetId',
196
+        render: <SelectActivity buildingId={() => buildingId} />,
197
+        hidden: () => !activityVisible,
198
+        value: data.targetId,
199
+        rules: [
200
+          { required: true, message: '请选择发布活动' },
201
+        ],
202
+      },
203
+      {
204
+        label: '发布资讯',
205
+        name: 'targetId',
206
+        render: <SelectNews buildingId={() => buildingId} />,
207
+        hidden: () => !newsVisible,
208
+        value: data.targetId,
209
+        rules: [
210
+          { required: true, message: '请选择发布资讯' },
211
+        ],
212
+      },
213
+      {
214
+        label: '发布内容',
215
+        name: 'content',
216
+        render: <Wangedit />,
217
+        value: data.content,
218
+        hidden: () => !contentVisible,
219
+        rules: [
220
+          { required: true, message: '请选择发布内容' },
221
+        ],
222
+      },
223
+      {
224
+        label: '发布助力',
225
+        name: 'targetId',
226
+        render: <SelectHelp buildingId={() => buildingId} />,
227
+        hidden: () => !helpVisible,
228
+        value: data.targetId,
229
+        rules: [
230
+          { required: true, message: '请选择发布助力' },
231
+        ],
232
+      },
233
+      {
234
+        label: '发布拼团',
235
+        name: 'targetId',
236
+        render: <SelectGroup buildingId={() => buildingId} />,
237
+        hidden: () => !groupVisible,
238
+        value: data.targetId,
239
+        rules: [
240
+          { required: true, message: '请选择发布拼团' },
241
+        ],
242
+      },
243
+      {
244
+        label: '状态',
245
+        name: 'status',
246
+        type: FieldTypes.Select,
247
+        dict: [{
248
+          label: "上架",
249
+          value: 1
250
+        },
251
+        {
252
+          label: "下架",
253
+          value: 0
254
+        },],
255
+        value: data.status != null ? data.status : 1,
256
+      },
257
+    ]
258
+
259
+    const handleSubmit = val => {
260
+      val.showType = 'propaganda'
261
+      if(!val.isHaveActive&&val.targetId) {
262
+          if(!val.contentType){
263
+            val.contentType='h5'
264
+          }
265
+      }
266
+      if(!val.isHaveActive&&!val.targetId){
267
+        val.contentType=''
268
+      }
269
+      if(contentId){
270
+        request({ ...apis.carsuseFigure.updataExtendContent,urlData:{id: contentId}, data: val,}).then((data) => {
271
+          cancelPage()
272
+        }).catch((err) => {
273
+          message.info(err.msg || err.message)
274
+        })
275
+      }else{
276
+        request({ ...apis.carsuseFigure.addExtendContent, data: val,}).then((data) => {
277
+          cancelPage()
278
+        }).catch((err) => {
279
+          message.info(err.msg || err.message)
280
+        })
281
+      }
282
+    }
283
+
284
+
285
+    return (
286
+      <XForm onSubmit={handleSubmit} onCancel={cancelPage} onValuesChange={handleFormValueChange} fields={fields}></XForm>
287
+    );
288
+   }
289
+ }
290
+
291
+export default createEditor()

+ 282
- 0
src/pages/carouselFigure/propagandaList.jsx Parādīt failu

@@ -0,0 +1,282 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, DatePicker } from 'antd';
3
+import { FormattedMessage } from 'umi-plugin-react/locale';
4
+import styles from '../style/GoodsList.less';
5
+import router from 'umi/router';
6
+import moment from 'moment';
7
+import SelectCity from '../../components/SelectButton/CitySelect'
8
+import BuildSelect from '../../components/SelectButton/BuildSelect'
9
+import apis from '../../services/apis';
10
+import request from '../../utils/request';
11
+import AuthButton from '@/components/AuthButton';
12
+
13
+const { Option } = Select;
14
+const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
15
+
16
+const header = (props) => {
17
+  const [ data, setData ] = useState({})
18
+//   const [page, changePage] = useState({})
19
+
20
+  useEffect(() => {
21
+    getList({ pageNum: 1, pageSize: 10, showType: 'propaganda' });
22
+  },[])
23
+
24
+  // 查询列表
25
+  const getList = (params) => {
26
+    request({ ...apis.carsuseFigure.extendContent, params: { ...params },}).then((data) => {
27
+        console.log(data)
28
+        setData(data)
29
+    })
30
+  }
31
+
32
+  
33
+// 跳转到编辑商品
34
+const toEdit = (contentId) => () => {
35
+    router.push({
36
+      pathname: '/carouselFigure/propaganda',
37
+      query: {
38
+        contentId
39
+      },
40
+    });
41
+  }
42
+  
43
+  const columns = [
44
+    {
45
+      title: '主图',
46
+      dataIndex: 'image',
47
+      key: 'image',
48
+      align: 'center',
49
+      render: (image) => <img src={image} className={styles.imgSmall} />,
50
+    },
51
+    {
52
+      title: '发布城市',
53
+      dataIndex: 'cityName',
54
+      key: 'cityName',
55
+      align: 'center',
56
+    },
57
+    {
58
+      title: '关联项目',
59
+      dataIndex: 'buildingName',
60
+      key: 'buildingName',
61
+      align: 'center',
62
+      render: (buildingName) => <span>{ buildingName === null ? '无' : buildingName }</span>
63
+    },
64
+    {
65
+      title: '关联内容类型',
66
+      dataIndex: 'contentType',
67
+      key: 'contentType',
68
+      align: 'center',
69
+      render: (contentType) => <span>{ contentType === 'project' ? '项目' : contentType === 'activity' ? '活动' : contentType === 'news' ? '资讯' : contentType === 'other' ? '其他' : contentType === 'help' ? '助力' : contentType === 'group' ? '拼团' : contentType === 'h5' ? 'H5活动' : '无' }</span>
70
+    },
71
+    // {
72
+    //   title: '发布位置',
73
+    //   dataIndex: 'showPosition',
74
+    //   key: 'showPosition',
75
+    //   align: 'center',
76
+    //   render: (showPosition) => <span>{ showPosition === 'index' ? '首页' : showPosition === 'mall' ? '商城' : '' }</span>
77
+    // },
78
+    {
79
+      title: '发布时间',
80
+      dataIndex: 'createDate',
81
+      key: 'createDate',
82
+      align: 'center',
83
+      render: (x, row) => <><span>{moment(row.createDate).format('YYYY-MM-DD')}</span></>
84
+    },
85
+    {
86
+      title: '状态',
87
+      dataIndex: 'status',
88
+      key: 'status',
89
+      align: 'center',
90
+      render: (status)=> <><span>{status == 1 ? '上架' : '下架'}</span></>
91
+    },
92
+    {
93
+      title: '操作',
94
+      dataIndex: 'handle',
95
+      key: 'handle',
96
+      align: 'center',
97
+      render: (x,row) => (
98
+        <>
99
+          <AuthButton name="admin.advert.publish" noRight={null}>
100
+            <span style={{ color: '#1990FF', marginRight: '20px',cursor: 'pointer' }} onClick={changeStatus(row)}>{ row.status === 1 ? '下架' : '上架' }<Icon type="vertical-align-top" className={styles.edit} /></span>
101
+          </AuthButton>
102
+          <AuthButton name="admin.advert.put" noRight={null}>
103
+            <span style={{ color: '#FF925C', marginRight: '20px', cursor: 'pointer' }} onClick={toEdit(row.contentId)}>编辑<Icon type="form" className={styles.edit} /></span>
104
+          </AuthButton>
105
+          <AuthButton name="admin.advert.delete" noRight={null}>
106
+            <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={deleteCarouse(row.contentId)}>删除<Icon type="vertical-align-top" className={styles.edit} /></span>
107
+          </AuthButton>
108
+        </>
109
+      )
110
+    },
111
+  ];
112
+  
113
+  const finishDynamic = (row) => {
114
+      Modal.confirm({
115
+          title: '结束以后将无法编辑, 是否继续?',
116
+          okText: '确定',
117
+          cancelText: '取消',
118
+          onOk() {
119
+              request({ ...apis.carsuseFigure.finish, data: {dynamicId: row.dynamicId, top: ""},}).then((data) => {
120
+                  console.log(data)
121
+                  message.info('操作成功!')
122
+                  getList({ pageNum: 1, pageSize: 10, showType: 'propaganda' })
123
+              }).catch((err) => {
124
+                  console.log(err)
125
+                  message.info(err.msg || err.message)
126
+              })
127
+          },
128
+        });
129
+  }
130
+  
131
+  //删除
132
+const deleteCarouse = (contentId) => () =>{
133
+  Modal.confirm({
134
+    title: '确认删除此数据?',
135
+    okText: '确定',
136
+    cancelText: '取消',
137
+    onOk() {
138
+      request({ ...apis.carsuseFigure.deleteExtendContent,urlData:{id: contentId}}).then((data) => {
139
+            message.info('操作成功!')
140
+            getList({ pageNum: 1, pageSize: 10, showType: 'propaganda' })
141
+        }).catch((err) => {
142
+            console.log(err)
143
+            message.info(err.msg || err.message)
144
+        })
145
+    },
146
+  });
147
+}
148
+
149
+//   停用启用
150
+  const changeStatus = (row) => () => {
151
+      console.log(row)
152
+      if(row.status === 0) {
153
+        
154
+        Modal.confirm({
155
+          title: '确认发布此数据?',
156
+          okText: '确定',
157
+          cancelText: '取消',
158
+          onOk() {
159
+            row.status = 1
160
+              request({ ...apis.carsuseFigure.updataExtendContent,urlData:{id: row.contentId}, data: row,}).then((data) => {
161
+                  message.info('操作成功!')
162
+                  getList({ pageNum: 1, pageSize: 10, showType: 'propaganda' })
163
+              }).catch((err) => {
164
+                  console.log(err)
165
+                  message.info(err.msg || err.message)
166
+              })
167
+          },
168
+        });
169
+      }else if(row.status === 1){
170
+        
171
+        Modal.confirm({
172
+          title: '停用后不会再显示在小程序端',
173
+          okText: '确定',
174
+          cancelText: '取消',
175
+          onOk() {
176
+            row.status = 0
177
+              request({ ...apis.carsuseFigure.updataExtendContent,urlData:{id: row.contentId}, data: row,}).then((data) => {
178
+                  message.info('操作成功!')
179
+                  getList({ pageNum: 1, pageSize: 10, showType: 'propaganda' })
180
+              }).catch((err) => {
181
+                  console.log(err)
182
+                  message.info(err.msg || err.message)
183
+              })
184
+          },
185
+        });
186
+      }
187
+
188
+  }
189
+  
190
+  const changePageNum = (pageNumber, props) => {
191
+    props.form.validateFields((err, values) => {
192
+      if (!err) {
193
+        getList({ pageNum: pageNumber, pageSize: 10, ...values, showType: 'propaganda' })
194
+      }
195
+    });
196
+  }
197
+
198
+  // 提交事件
199
+const handleSubmit = (e, props) => {
200
+    e.preventDefault();
201
+    props.form.validateFields((err, values) => {
202
+      if (!err) {
203
+        console.log('提交数据: ', values)
204
+        getList({ pageNum: 1, pageSize: 10, ...values, showType: 'propaganda' })
205
+      }
206
+    });
207
+  }
208
+
209
+   //重置搜索
210
+   function handleReset() {
211
+    props.form.resetFields();
212
+  }
213
+
214
+
215
+  const { getFieldDecorator } = props.form
216
+  return (
217
+
218
+    <>
219
+      <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
220
+      <Form.Item>
221
+          {getFieldDecorator('cityId')(
222
+             <SelectCity />,
223
+          )}
224
+        </Form.Item>
225
+        <Form.Item>
226
+          {getFieldDecorator('buildingId')(
227
+            <BuildSelect />,
228
+          )}
229
+        </Form.Item>
230
+        <Form.Item>
231
+          {getFieldDecorator('contentType')(
232
+            <Select style={{ width: '180px' }} placeholder="类型">
233
+              <Option value="activity">活动</Option>
234
+              <Option value="project">项目</Option>
235
+              <Option value="news">资讯</Option>
236
+              <Option value="help">助力</Option>
237
+              <Option value="group">拼团</Option>
238
+              <Option value="h5">H5</Option>
239
+              <Option value="nothing">无</Option>
240
+            </Select>,
241
+          )}
242
+        </Form.Item>
243
+        {/* <Form.Item>
244
+          {getFieldDecorator('showPosition')(
245
+            <Select style={{ width: '180px' }} placeholder="发布位置">
246
+              <Option value="mall">商城</Option>
247
+              <Option value="index">首页</Option>
248
+            </Select>,
249
+          )}
250
+        </Form.Item> */}
251
+        <Form.Item>
252
+          {getFieldDecorator('status')(
253
+            <Select style={{ width: '180px' }} placeholder="状态">
254
+              <Option value="1">已上架</Option>
255
+              <Option value="0">已下架</Option>
256
+            </Select>,
257
+          )}
258
+        </Form.Item>
259
+        <Form.Item>
260
+        <AuthButton name="admin.advert.search" noRight={null}>
261
+          <Button type="primary" htmlType="submit" className={styles.searchBtn}>
262
+            搜索
263
+          </Button>
264
+          </AuthButton>
265
+          <Button style={{ marginLeft: 8 }} onClick={handleReset}>
266
+              重置
267
+            </Button>
268
+        </Form.Item>
269
+      </Form>
270
+      <AuthButton name="admin.advert.post" noRight={null}>
271
+        <Button type="danger" className={styles.addBtn} onClick={toEdit()}>新增</Button>
272
+      </AuthButton>
273
+      <Table dataSource={data.records} columns={columns} pagination={false} rowKey="advertisingList"/>
274
+      <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
275
+        <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={e => changePageNum(e,props)} current={data.current}/>
276
+      </div>
277
+    </>
278
+  )
279
+}
280
+const WrappedHeader = Form.create({ name: 'header' })(header);
281
+
282
+export default WrappedHeader