瀏覽代碼

Merge branch 'master' of http://git.ycjcjy.com/zhiyuxing/estateagents-admin-manager

许静 5 年之前
父節點
當前提交
e77e544868
共有 4 個文件被更改,包括 272 次插入18 次删除
  1. 6
    1
      config/config.js
  2. 103
    16
      src/pages/activity/editActivity.jsx
  3. 1
    1
      src/pages/staff/list/RoleList.jsx
  4. 162
    0
      src/pages/staff/list/addRole.jsx

+ 6
- 1
config/config.js 查看文件

@@ -346,7 +346,12 @@ export default {
346 346
                   hideInMenu: true,
347 347
                   component: './staff/list/editRole',
348 348
                 },
349
-
349
+                {
350
+                  path: '/staff/list/addRole',
351
+                  name: '添加角色',
352
+                  hideInMenu: true,
353
+                  component: './staff/list/addRole',
354
+                },  
350 355
               ],
351 356
             },
352 357
             {

+ 103
- 16
src/pages/activity/editActivity.jsx 查看文件

@@ -148,6 +148,7 @@ const Edit = (props) => {
148 148
           method: 'PUT',
149 149
           data: submitValue,
150 150
         }).then((data) => {
151
+          message.info("保存成功")
151 152
           cancelPage()
152 153
         }).catch((err) => {
153 154
           message.info(err.msg || err.message)
@@ -158,6 +159,7 @@ const Edit = (props) => {
158 159
           method: 'POST',
159 160
           data: submitValue,
160 161
         }).then((data) => {
162
+          message.info("保存成功")
161 163
           cancelPage()
162 164
         }).catch((err) => {
163 165
           message.info(err.msg || err.message)
@@ -172,12 +174,55 @@ const Edit = (props) => {
172 174
     const [inputValue, changeInput] = useState('')
173 175
     const [textAreaValue, changeTextArea] = useState('')
174 176
     const [imgValue, changeImg] = useState('')
177
+    const [posterId, setPosterId] = useState('')
178
+
179
+    if(dynamicId){
180
+      useEffect(() => {
181
+        request({
182
+          url: '/api/admin/poster',
183
+          method: 'GET',
184
+          params: {targetId: dynamicId,targetType: 'activity'},
185
+        }).then((data) => {
186
+          console.log(data,"2222")
187
+          if(data.length > 0){
188
+            setPosterId(data[0].posterId)
189
+            changeImg(data[0].posterImg)
190
+            changeTextArea(data[0].posterDescription)
191
+            changeInput(data[0].posterTitle)
192
+          }
193
+        }).catch((err) => {
194
+          message.info(err.msg || err.message)
195
+        })
196
+      }, [])
197
+    }
175 198
 
176 199
     const submitPoster  = () => {
177
-      console.log(inputValue)
178
-      console.log(textAreaValue)
179
-      console.log(imgValue)
180
-      console.log(dynamicId)
200
+       if(dynamicId){
201
+        if(posterId){
202
+          request({
203
+            url: '/api/admin/poster/'+posterId,
204
+            method: 'PUT',
205
+            data: {targetId: dynamicId,targetType: 'activity',posterImg: imgValue,posterTitle: inputValue,posterDescription: textAreaValue},
206
+          }).then((data) => {
207
+            message.info("保存成功")
208
+          }).catch((err) => {
209
+            message.info(err.msg || err.message)
210
+          })
211
+         }else{
212
+          request({
213
+            url: '/api/admin/poster',
214
+            method: 'POST',
215
+            data: {targetId: dynamicId,targetType: 'activity',posterImg: imgValue,posterTitle: inputValue,posterDescription: textAreaValue},
216
+          }).then((data) => {
217
+            setPosterId(data.posterId)
218
+            message.info("保存成功")
219
+          }).catch((err) => {
220
+            message.info(err.msg || err.message)
221
+          })
222
+         }
223
+       }else{
224
+        message.warn("请先保存基本信息数据")
225
+       }
181 226
     }
182 227
 
183 228
     return <div>
@@ -217,15 +262,15 @@ const Edit = (props) => {
217 262
         <div >
218 263
           <div style={{ display: 'flex', width: '100%', margin: '60px 0' }}>
219 264
             <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报图片</p>
220
-            <ImageUploader onChange={e => changeImg(e)} />
265
+            <ImageUploader value={imgValue} onChange={e => changeImg(e)} />
221 266
           </div>
222 267
           <div style={{ display: 'flex', alignItems: 'center', width: '100%', marginBottom: '60px' }}>
223 268
             <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报标题</p>
224
-            <Input style={{ width: '20vw' }} placeholder="请输入海报标题" onChange={e => changeInput(e.target.value)} />
269
+            <Input style={{ width: '20vw' }} value={inputValue} placeholder="请输入海报标题" onChange={e => changeInput(e.target.value)} />
225 270
           </div>
226 271
           <div style={{ display: 'flex', margin: '10px 0 40px 0', width: '100%' }}>
227 272
             <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报描述</p>
228
-            <TextArea rows={5} onChange={e => changeTextArea(e.target.value)} />
273
+            <TextArea rows={5} value={textAreaValue} onChange={e => changeTextArea(e.target.value)} />
229 274
           </div>
230 275
 
231 276
         </div>
@@ -241,13 +286,55 @@ const Edit = (props) => {
241 286
   const Share = (props) => {
242 287
     const [inputValue, changeInput] = useState('')
243 288
     const [imgValue, changeImg] = useState('')
244
-    // const changeInputValue = e => {
245
-    //   changeInput(e.target.value)
246
-    // }
247
-
248
-    // const handleSubmit = (values) => {
289
+    const [shareContentId, setShareContentId] = useState('')
290
+    
291
+    if(dynamicId){
292
+      useEffect(() => {
293
+        request({
294
+          url: '/api/admin/shareContent',
295
+          method: 'GET',
296
+          params: {targetId: dynamicId,targetType: 'activity'},
297
+        }).then((data) => {
298
+          console.log(data,"2222")
299
+          if(data.length > 0){
300
+            setShareContentId(data[0].shareContentId)
301
+            changeImg(data[0].shareContentImg)
302
+            changeInput(data[0].shareContentTitle)
303
+          }
304
+        }).catch((err) => {
305
+          message.info(err.msg || err.message)
306
+        })
307
+      }, [])
308
+    }
249 309
 
250
-    // }
310
+    const submitShare = () => {
311
+      if(dynamicId){
312
+        if(shareContentId){
313
+          request({
314
+            url: '/api/admin/shareContent/'+shareContentId,
315
+            method: 'PUT',
316
+            data: {targetId: dynamicId,shareContentType: 'activity',shareContentImg: imgValue,shareContentTitle: inputValue},
317
+          }).then((data) => {
318
+            message.info("保存成功")
319
+          }).catch((err) => {
320
+            message.info(err.msg || err.message)
321
+          })
322
+         }else{
323
+          request({
324
+            url: '/api/admin/shareContent',
325
+            method: 'POST',
326
+            data: {targetId: dynamicId,shareContentType: 'activity',shareContentImg: imgValue,shareContentTitle: inputValue},
327
+          }).then((data) => {
328
+            setShareContentId(data.shareContentId)
329
+            message.info("保存成功")
330
+          }).catch((err) => {
331
+            message.info(err.msg || err.message)
332
+          })
333
+         }
334
+       }else{
335
+        message.warn("请先保存基本信息数据")
336
+       }
337
+    }
251 338
 
252 339
     return <div style={{ padding: '20px' }}>
253 340
       <div style={{ display: 'flex', margin: '10px 0 40px 0', width: '100%' }}>
@@ -260,13 +347,13 @@ const Edit = (props) => {
260 347
       </div>
261 348
       <div style={{ display: 'flex', alignItems: 'center', width: '100%' }}>
262 349
         <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报标题</p>
263
-        <Input placeholder="请输入海报标题" onChange={e => changeInput(e.target.value)} />
350
+        <Input placeholder="请输入海报标题" value={inputValue} onChange={e => changeInput(e.target.value)} />
264 351
       </div>
265 352
       <div style={{ display: 'flex', width: '100%', marginTop: '40px' }}>
266 353
         <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>分享图片</p>
267
-        <ImageUploader onChange={e => changeImg(e)} />
354
+        <ImageUploader value={imgValue} onChange={e => changeImg(e)} />
268 355
       </div>
269
-      <Button type="primary" htmlType="submit" style={{ margin: '40px 40px 40px 220px' }}> 确定</Button>
356
+      <Button type="primary" htmlType="submit" onClick={submitShare} style={{ margin: '40px 40px 40px 220px' }}> 确定</Button>
270 357
       <Button onClick={() => router.go(-1)}>取消</Button>
271 358
     </div>
272 359
   }

+ 1
- 1
src/pages/staff/list/RoleList.jsx 查看文件

@@ -25,7 +25,7 @@ function confirm() {
25 25
 }
26 26
 function toEditRole() {
27 27
   router.push({
28
-    pathname: '/staff/editRole',
28
+    pathname: '/staff/list/addRole',
29 29
     query: {
30 30
       a: 'b',
31 31
     },

+ 162
- 0
src/pages/staff/list/addRole.jsx 查看文件

@@ -0,0 +1,162 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Checkbox, Input, Card } from 'antd';
3
+import { connect } from 'dva';
4
+import XForm, { FieldTypes } from '../../../components/XForm';
5
+import request from '../../../utils/request';
6
+import channels from './channelList.less';
7
+
8
+const { TextArea } = Input;
9
+
10
+
11
+/**
12
+ *
13
+ *
14
+ * @param {*} props
15
+ * @returns
16
+ */
17
+const Edit = props => {
18
+  console.log('props,props', props.user.currentUser)
19
+  const userMenus = props.user.currentUser.menus;
20
+  const userBtns = props.user.currentUser.buttons;
21
+
22
+
23
+  const [data, setData] = useState({ data: [] })
24
+ // 获取当前所有菜单
25
+  useEffect(() => {
26
+    localStorage.removeItem('value');
27
+    menuList({ pageNum: 1, pageSize: 100 })
28
+  }, [])
29
+
30
+  function menuList(params) {
31
+    request({
32
+      url: '/api/admin/menuList',
33
+      method: 'GET',
34
+      params: { ...params },
35
+  // eslint-disable-next-line no-shadow
36
+  }).then(data => {
37
+      console.log(data)
38
+      setData(data)
39
+  })
40
+  }
41
+
42
+  // function SuBmenu(params) {
43
+  //  return Array.from(userMenus).map(Item =>
44
+  //  <Checkbox value={ Item.menuId }> { Item.name }</Checkbox>)
45
+  // }
46
+  // const [tab, changeTab] = useState('basic')
47
+
48
+  const Permission = [
49
+    '项目管理',
50
+    '员工管理',
51
+    '客户管理',
52
+    '系统管理',
53
+    '渠道管理',
54
+    '轮播图管理',
55
+    '资讯管理',
56
+    '活动管理',
57
+    '积分商城',
58
+    '首页数据',
59
+  ]
60
+
61
+  const Poster = props => {
62
+    const dataSource = [
63
+      {
64
+        name: '员工管理',
65
+        per: [
66
+          '111111',
67
+          '22222',
68
+          '33333',
69
+        ],
70
+      },
71
+      {
72
+        name: '角色管理',
73
+        per: [
74
+          '444',
75
+          '555',
76
+          '666',
77
+        ],
78
+      },
79
+    ];
80
+
81
+
82
+    const gridStyle1 = {
83
+      width: '20%',
84
+      textAlign: 'left',
85
+    };
86
+    const gridStyle2 = {
87
+      width: '80%',
88
+      textAlign: 'left',
89
+      height: '69px',
90
+    };
91
+
92
+    return (
93
+    <>
94
+      <div style={{}}>
95
+        {userMenus.map(item => (
96
+          <Card title={<Checkbox>{item.name}</Checkbox>} bordered style={{ width: '100%' }}>
97
+              {
98
+                   userMenus.map(menu => (
99
+
100
+                    (item.menuId === menu.menuRoot && item.menuId !== menu.menuId) &&
101
+                    <>
102
+                      <Card.Grid style={gridStyle1} >
103
+                          <Checkbox>{menu.name}</Checkbox>
104
+                      </Card.Grid>
105
+                      <Card.Grid style={gridStyle2}>
106
+                        {userBtns.map(btn => (
107
+                          <>
108
+                            {
109
+                              btn.menuId === menu.menuId &&
110
+                              <Checkbox>{btn.name}</Checkbox>
111
+                            }
112
+                          </>
113
+                        ))}
114
+                      </Card.Grid>
115
+                   </>
116
+                   ))
117
+              }
118
+          </Card>
119
+        ))}
120
+      </div>
121
+    </>
122
+    )
123
+  }
124
+
125
+  const fields = [
126
+    {
127
+      label: '角色名称',
128
+      name: 'roleName',
129
+      type: FieldTypes.Text,
130
+      // placeholder: '名称',
131
+      value: ''
132
+    },
133
+    {
134
+      label: '简介',
135
+      name: 'roleIntroduction',
136
+      render: <TextArea className={channels.inpuitTxt} ></TextArea>,
137
+      value: ''
138
+
139
+    },
140
+
141
+    {
142
+      label: '菜单权限',
143
+      name: 'rolePermission',
144
+      render:
145
+        <>
146
+          <div>
147
+
148
+            <Poster />
149
+          </div>
150
+        </>,
151
+    },
152
+
153
+  ]
154
+
155
+  const handleSubmit = val => {
156
+    window.console.log('submit data --->', val)
157
+  }
158
+  return <XForm onSubmit={handleSubmit} fields={fields}></XForm>
159
+}
160
+
161
+
162
+export default connect(({ user }) => ({ user }))(Edit);