zlisen 4 年之前
父節點
當前提交
7736048927

+ 8
- 1
config/routes.js 查看文件

@@ -191,10 +191,17 @@ export default [
191 191
               },
192 192
               {
193 193
                 path: '/Live/LiveActivity/Edit',
194
-                name: '直播活动',
194
+                name: '编辑活动',
195 195
                 hideInMenu: true,
196 196
                 component: './Live/LiveActivity/Edit',
197 197
               },
198
+              {
199
+                path: '/Live/LiveActivity/add',
200
+                name: '新增活动',
201
+                hideInMenu: true,
202
+                component: './Live/LiveActivity/add',
203
+              },
204
+              
198 205
               // {
199 206
               //   path: '/staff/Staff/Edit',
200 207
               //   name: '编辑员工',

+ 150
- 106
src/pages/Live/LiveActivity/Edit/components/base.jsx 查看文件

@@ -1,5 +1,17 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Input, Button, Icon, Select, Tabs, Radio, DatePicker, message, Upload, InputNumber } from 'antd';
2
+import {
3
+  Form,
4
+  Input,
5
+  Button,
6
+  Icon,
7
+  Select,
8
+  Tabs,
9
+  Radio,
10
+  DatePicker,
11
+  message,
12
+  Upload,
13
+  InputNumber,
14
+} from 'antd';
3 15
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 16
 import moment from 'moment';
5 17
 import router from 'umi/router';
@@ -7,56 +19,58 @@ import styles from '../../../../style/GoodsList.less';
7 19
 import XForm, { FieldTypes, createForm } from '../../../../../components/XForm';
8 20
 import apis from '../../../../../services/apis';
9 21
 import BuildSelect2 from '../../../../../components/SelectButton/BuildSelect2';
10
-import LivePlatSelect from '../../../../../components/SelectButton/LivePlatSelect'
22
+import LivePlatSelect from '../../../../../components/SelectButton/LivePlatSelect';
11 23
 import CitySelect3 from '../../../../../components/SelectButton/CitySelect3';
12
-import ImageUpload from '../../../../../components/XForm/ImageUpload'
24
+import ImageUpload from '../../../../../components/XForm/ImageUpload';
13 25
 import request from '../../../../../utils/request';
14 26
 import Navigate from '@/components/Navigate';
15 27
 
16 28
 const { Option } = Select;
17 29
 const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
18 30
 
19
-let cityId = ''
31
+let cityId = '';
20 32
 
21 33
 const header = props => {
22
-  console.log(props)
23
-  const liveActivityId = props.liveActivityId.liveId
24
-  console.log(liveActivityId)
25
-  const [ liveActivityData, setLiveActivityData ] = useState({})
26
-  const [showHelp, setShowHelp] = useState(false)
34
+  console.log(props);
35
+  const liveActivityId = props.liveActivityId.liveId;
36
+  console.log(liveActivityId);
37
+  const [liveActivityData, setLiveActivityData] = useState({});
38
+  const [showHelp, setShowHelp] = useState(false);
27 39
 
28
-  if(liveActivityId){
29
-    useEffect(() => {
40
+  useEffect(() => {
41
+    if (liveActivityId) {
30 42
       getLiveActivityData(liveActivityId);
31
-    },[])
43
+    }
44
+  }, []);
32 45
 
33 46
   // 查询列表
34
-  const getLiveActivityData = (liveActivityId) => {
35
-    request({ ...apis.taliveActivity.getTaLiveActivity, urlData: {id: liveActivityId} }).then((data) => {
36
-        console.log(data, 'getLiveActivityData')
37
-        setLiveActivityData(data.data)
47
+  const getLiveActivityData = liveActivityId => {
48
+    request({ ...apis.taliveActivity.getTaLiveActivity, urlData: { id: liveActivityId } }).then(
49
+      data => {
50
+        console.log(data, 'getLiveActivityData');
51
+        setLiveActivityData(data.data);
38 52
         // if(data.qrCode == 'null'){
39 53
         //   message.error("暂时无法获取二维码")
40 54
         // }
41
-    })
42
-  }
43
-  }
55
+      },
56
+    );
57
+  };
44 58
 
45
-  const cancelPage = () =>{
59
+  const cancelPage = () => {
46 60
     router.push({
47 61
       pathname: '/activity/liveActivity/list/index',
48 62
     });
49
-  }
63
+  };
50 64
 
51 65
   //打开新页面
52 66
   const openIndexImg = () => {
53
-    const newWin=window.open('about:blank');
54
-    newWin.location.href="http://njcj.oss-cn-shanghai.aliyuncs.com/%E6%95%99%E7%A8%8B.png"
55
-  }
67
+    const newWin = window.open('about:blank');
68
+    newWin.location.href = 'http://njcj.oss-cn-shanghai.aliyuncs.com/%E6%95%99%E7%A8%8B.png';
69
+  };
56 70
 
57 71
   function highlightsTypeChange(e) {
58
-    console.log(e.target.value,"ee")
59
-    setTypeState(e.target.value)
72
+    console.log(e.target.value, 'ee');
73
+    setTypeState(e.target.value);
60 74
   }
61 75
 
62 76
   function disabledDate(current) {
@@ -64,30 +78,38 @@ const header = props => {
64 78
     return current && current < moment().endOf('day');
65 79
   }
66 80
 
67
-  function handleSubmit (e) {
81
+  function handleSubmit(e) {
68 82
     e.preventDefault();
69 83
     props.form.validateFields((err, values) => {
70 84
       console.log(values, 'values');
71
-      if (!err){
72
-        let {liveTime, ...submitValue} = values
73
-        if (submitValue.status == '已发布' || submitValue.status == '1'){
74
-          submitValue.status = 1
75
-        }else{
76
-          submitValue.status = 0
85
+      if (!err) {
86
+        let { liveTime, ...submitValue } = values;
87
+        if (submitValue.status == '已发布' || submitValue.status == '1') {
88
+          submitValue.status = 1;
89
+        } else {
90
+          submitValue.status = 0;
77 91
         }
78
-        if (values.liveStartDate > values.liveEndDate){
79
-          message.info("直播结束时间大于开始时间")
92
+        if (values.liveStartDate > values.liveEndDate) {
93
+          message.info('直播结束时间大于开始时间');
80 94
           return;
81 95
         }
82
-        submitValue.liveStartDate = moment(submitValue.liveStartDate._d).format('YYYY-MM-DD HH:mm:ss')
83
-        submitValue.liveEndDate = moment(submitValue.liveEndDate._d).format('YYYY-MM-DD HH:mm:ss')
84
-        console.log(submitValue)
85
-        request({ ...apis.taliveActivity.updateTaLiveActivity, urlData: {id: liveActivityId},data: submitValue, }).then((data) => {
86
-          message.info("保存成功")
87
-          cancelPage()
88
-        }).catch((err) => {
89
-          message.info(err.msg || err.message)
96
+        submitValue.liveStartDate = moment(submitValue.liveStartDate._d).format(
97
+          'YYYY-MM-DD HH:mm:ss',
98
+        );
99
+        submitValue.liveEndDate = moment(submitValue.liveEndDate._d).format('YYYY-MM-DD HH:mm:ss');
100
+        console.log(submitValue);
101
+        request({
102
+          ...apis.taliveActivity.updateTaLiveActivity,
103
+          urlData: { id: liveActivityId },
104
+          data: submitValue,
90 105
         })
106
+          .then(data => {
107
+            message.info('保存成功');
108
+            cancelPage();
109
+          })
110
+          .catch(err => {
111
+            message.info(err.msg || err.message);
112
+          });
91 113
       }
92 114
     });
93 115
   }
@@ -101,12 +123,12 @@ const header = props => {
101 123
           {getFieldDecorator('cityId', {
102 124
             initialValue: liveActivityData.cityId,
103 125
             rules: [{ required: true, message: ' 请输入所属城市' }],
104
-          })(<CitySelect3 buildingId={props.form.getFieldValue('buildingId')}/>)}
126
+          })(<CitySelect3 buildingId={props.form.getFieldValue('buildingId')} />)}
105 127
         </Form.Item>
106 128
         <Form.Item label="所属楼盘">
107 129
           {getFieldDecorator('buildingId', {
108 130
             initialValue: liveActivityData.buildingId,
109
-          })(<BuildSelect2 cityId={props.form.getFieldValue('cityId')}/>)}
131
+          })(<BuildSelect2 cityId={props.form.getFieldValue('cityId')} />)}
110 132
         </Form.Item>
111 133
         <Form.Item label="直播活动标题">
112 134
           {getFieldDecorator('liveActivityTitle', {
@@ -115,92 +137,114 @@ const header = props => {
115 137
           })(<Input maxLength={20} placeholder="给直播活动起个名字" />)}
116 138
         </Form.Item>
117 139
         <Form.Item label="直播开始时间">
118
-          {getFieldDecorator('liveStartDate', { initialValue : liveActivityData.liveStartDate ? moment(liveActivityData.liveStartDate, 'YYYY-MM-DD HH:mm:ss') : null,
119
-                rules: [
120
-                  {
121
-                    required: true,
122
-                    message: '请选择直播开始时间',
123
-                  },
124
-                ],
125
-              })(<DatePicker placeholder="预计开始时间" style={{ width: '500px' }}format="YYYY-MM-DD HH:mm:ss" showTime={{ format: 'HH:mm:ss' }}/>)}
140
+          {getFieldDecorator('liveStartDate', {
141
+            initialValue: liveActivityData.liveStartDate
142
+              ? moment(liveActivityData.liveStartDate, 'YYYY-MM-DD HH:mm:ss')
143
+              : null,
144
+            rules: [
145
+              {
146
+                required: true,
147
+                message: '请选择直播开始时间',
148
+              },
149
+            ],
150
+          })(
151
+            <DatePicker
152
+              placeholder="预计开始时间"
153
+              style={{ width: '500px' }}
154
+              format="YYYY-MM-DD HH:mm:ss"
155
+              showTime={{ format: 'HH:mm:ss' }}
156
+            />,
157
+          )}
126 158
         </Form.Item>
127 159
         <Form.Item label="直播结束时间">
128
-          {getFieldDecorator('liveEndDate', { initialValue : liveActivityData.liveEndDate ? moment(liveActivityData.liveEndDate, 'YYYY-MM-DD HH:mm:ss') : null,
129
-                rules: [
130
-                  {
131
-                    required: true,
132
-                    message: '请选择直播结束时间',
133
-                  },
134
-                ],
135
-              })(<DatePicker placeholder="预计结束时间" disabledDate={disabledDate} style={{ width: '500px' }}format="YYYY-MM-DD HH:mm:ss" showTime={{ format: 'HH:mm:ss' }}/>)}
160
+          {getFieldDecorator('liveEndDate', {
161
+            initialValue: liveActivityData.liveEndDate
162
+              ? moment(liveActivityData.liveEndDate, 'YYYY-MM-DD HH:mm:ss')
163
+              : null,
164
+            rules: [
165
+              {
166
+                required: true,
167
+                message: '请选择直播结束时间',
168
+              },
169
+            ],
170
+          })(
171
+            <DatePicker
172
+              placeholder="预计结束时间"
173
+              disabledDate={disabledDate}
174
+              style={{ width: '500px' }}
175
+              format="YYYY-MM-DD HH:mm:ss"
176
+              showTime={{ format: 'HH:mm:ss' }}
177
+            />,
178
+          )}
136 179
         </Form.Item>
137 180
         <Form.Item label="直播小程序">
138 181
           {getFieldDecorator('liveApp', {
139
-              initialValue: liveActivityData.liveApp,
140
-              rules: [{ required: true, message: '请选择直播小程序' }],
141
-            })(<LivePlatSelect />)}
182
+            initialValue: liveActivityData.liveApp,
183
+            rules: [{ required: true, message: '请选择直播小程序' }],
184
+          })(<LivePlatSelect />)}
142 185
         </Form.Item>
143 186
         <Form.Item label="房间参数">
144 187
           {getFieldDecorator('liveRoomParam', {
145 188
             initialValue: liveActivityData.liveRoomParam,
146 189
             rules: [{ required: true, message: '请输入房间参数' }],
147
-          })(<Input maxLength={1000} placeholder="点击右侧按钮查看如何获取房间参数" style={{width:'680px'}}/>)}
190
+          })(
191
+            <Input
192
+              maxLength={1000}
193
+              placeholder="点击右侧按钮查看如何获取房间参数"
194
+              style={{ width: '680px' }}
195
+            />,
196
+          )}
148 197
           <Navigate onClick={openIndexImg}>不知道怎么填?查看说明</Navigate>
149 198
         </Form.Item>
150
-        <Form.Item label="封面图1" help="建议尺寸:750px*420px,比例16:9,格式:jpg,用于:活动列表">
151
-              {getFieldDecorator('listImg', {
152
-                  initialValue: liveActivityData.listImg,
153
-                  rules: [{ required: true, message: '请上传封面图1' }],
154
-              })(
155
-                <ImageUpload />,
156
-              )}
157
-        </Form.Item>  
199
+        <Form.Item
200
+          label="封面图1"
201
+          help="建议尺寸:750px*420px,比例16:9,格式:jpg,用于:活动列表"
202
+        >
203
+          {getFieldDecorator('listImg', {
204
+            initialValue: liveActivityData.listImg,
205
+            rules: [{ required: true, message: '请上传封面图1' }],
206
+          })(<ImageUpload />)}
207
+        </Form.Item>
158 208
         <Form.Item label="封面图2" help="建议尺寸:750*250px,比例3:1,格式:jpg,用于:项目详情页">
159
-              {getFieldDecorator('detailImg', {
160
-                  initialValue: liveActivityData.detailImg,
161
-                  rules: [{ required: true, message: '请上传封面图2' }],
162
-              })(
163
-                <ImageUpload />,
164
-              )}
165
-        </Form.Item>  
209
+          {getFieldDecorator('detailImg', {
210
+            initialValue: liveActivityData.detailImg,
211
+            rules: [{ required: true, message: '请上传封面图2' }],
212
+          })(<ImageUpload />)}
213
+        </Form.Item>
166 214
         <Form.Item label="详情图" help="格式:jpg,用于:直播活动详情页,点击可跳转到直播间">
167
-              {getFieldDecorator('detailTypeImg', {
168
-                  initialValue: liveActivityData.detailTypeImg,
169
-                  rules: [{ required: true, message: '请上传详情图' }],
170
-              })(
171
-                <ImageUpload style={{width:'300px',height:'600px'}}/>,
172
-              )}
173
-        </Form.Item>      
215
+          {getFieldDecorator('detailTypeImg', {
216
+            initialValue: liveActivityData.detailTypeImg,
217
+            rules: [{ required: true, message: '请上传详情图' }],
218
+          })(<ImageUpload style={{ width: '300px', height: '600px' }} />)}
219
+        </Form.Item>
174 220
         <Form.Item label="权重">
175
-              {getFieldDecorator('weight', {
176
-                  initialValue: liveActivityData.weight,
177
-                  rules: [{ required: true, message: '请设置权重' }],
178
-              })(
179
-                <InputNumber placeholder="权重越大越靠前" style={{width:'150px'}}/>
180
-              )}
221
+          {getFieldDecorator('weight', {
222
+            initialValue: liveActivityData.weight,
223
+            rules: [{ required: true, message: '请设置权重' }],
224
+          })(<InputNumber placeholder="权重越大越靠前" style={{ width: '150px' }} />)}
181 225
         </Form.Item>
182 226
         <Form.Item label="发布状态">
183 227
           {getFieldDecorator('status', {
184
-              initialValue: liveActivityData.status == 1 ? '已发布' : '未发布',
185
-              rules: [{ required: true, message: '请选择发布状态' }],
186
-            })(<Select placeholder="发布状态" style={{ width: '300px' }}>
187
-            <Option value="0">未发布</Option>
188
-            <Option value="1">已发布</Option>
189
-          </Select>)}
228
+            initialValue: liveActivityData.status == 1 ? '已发布' : '未发布',
229
+            rules: [{ required: true, message: '请选择发布状态' }],
230
+          })(
231
+            <Select placeholder="发布状态" style={{ width: '300px' }}>
232
+              <Option value="0">未发布</Option>
233
+              <Option value="1">已发布</Option>
234
+            </Select>,
235
+          )}
190 236
         </Form.Item>
191 237
         <Form.Item wrapperCol={{ span: 15, offset: 7 }}>
192
-          <Button type="primary" htmlType="submit"style={{marginRight:'20px'}}>
238
+          <Button type="primary" htmlType="submit" style={{ marginRight: '20px' }}>
193 239
             确定
194 240
           </Button>
195
-          <Button onClick={() => router.go(-1)}>
196
-            取消
197
-          </Button>
241
+          <Button onClick={() => router.go(-1)}>取消</Button>
198 242
         </Form.Item>
199 243
       </Form>
200 244
     </>
201
-  )
202
-}
245
+  );
246
+};
203 247
 
204 248
 const Base = Form.create({ name: 'header' })(header);
205 249
 
206
-export default Base
250
+export default Base;

+ 58
- 31
src/pages/Live/LiveActivity/Edit/index.jsx 查看文件

@@ -1,19 +1,34 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Radio, Tag, Tooltip, Tabs, notification } from 'antd';
2
+import {
3
+  Form,
4
+  Input,
5
+  Button,
6
+  DatePicker,
7
+  Select,
8
+  Card,
9
+  Row,
10
+  Col,
11
+  Pagination,
12
+  Alert,
13
+  Radio,
14
+  Tag,
15
+  Tooltip,
16
+  Tabs,
17
+  notification,
18
+} from 'antd';
3 19
 import moment from 'moment';
4 20
 import request from '../../../../utils/request';
5 21
 import apis from '../../../../services/apis';
6 22
 import { router } from 'umi';
7 23
 
8
-import Base from './components/base'
9
-import Poster from './components/poster'
10
-import Share from './components/share'
11
-import ShareRecord from './components/shareRecord'
12
-import VisitRecord from './components/visitRecord'
24
+import Base from './components/base';
25
+import Poster from './components/poster';
26
+import Share from './components/share';
27
+import ShareRecord from './components/shareRecord';
28
+import VisitRecord from './components/visitRecord';
13 29
 import Prompt from 'umi/prompt';
14 30
 
15
-
16
-const { Option } = Select
31
+const { Option } = Select;
17 32
 const { TabPane } = Tabs;
18 33
 
19 34
 const formItemLayout = {
@@ -30,37 +45,53 @@ const formItemLayout = {
30 45
 function openNotificationWithIcon(type, message) {
31 46
   notification[type]({
32 47
     message,
33
-    description:
34
-      '',
48
+    description: '',
35 49
   });
36 50
 }
37 51
 
38 52
 function EditHouse(props) {
39
-  const {liveActivityId} = props.location.query;
40
-  console.log(props.location.query.id)
41
-  const [tab, setTab] = useState('base')
42
-  const [liveActivity, setLiveActivity] = useState({ liveActivityId: undefined })
43
-  const [houseId, setHouseId] = useState('')
53
+  const { liveActivityId } = props.location.query;
54
+  console.log(props.location.query.id);
55
+  const [tab, setTab] = useState('base');
56
+  const [liveActivity, setLiveActivity] = useState({ liveActivityId: undefined });
57
+  const [houseId, setHouseId] = useState('');
44 58
 
45 59
   function tabsCallback(e) {
46
-    setTab(e.target.value)
60
+    setTab(e.target.value);
47 61
   }
48 62
 
49 63
   // building 回调
50 64
   function buildingOnSuccess(e) {
51
-    setBuildingData(e)
65
+    setBuildingData(e);
52 66
   }
53 67
 
54 68
   function housTabChange(e) {
55
-    setHouseId(e.houseId)
56
-    setTab('preselectionRecord')
69
+    setHouseId(e.houseId);
70
+    setTab('preselectionRecord');
57 71
   }
58 72
 
59
-  const liveId = liveActivity.liveActivityId || (props.location.query && props.location.query.id)
60
-  console.log(liveId)
73
+  const liveId = liveActivity.liveActivityId || (props.location.query && props.location.query.id);
74
+  console.log(liveId, 'liveId');
61 75
   return (
62
-    <>
63
-      <Radio.Group value={ tab } buttonStyle="solid" onChange={e => tabsCallback(e)}>
76
+    <Card>
77
+      <Tabs defaultActiveKey="1">
78
+        <TabPane tab="基本信息" key="1">
79
+          <Base liveActivityId={{ liveId }} onSuccess={e => buildingOnSuccess(e)} />
80
+        </TabPane>
81
+        <TabPane tab="海报设置" key="2">
82
+          <Poster liveActivityId={{ liveId }} />
83
+        </TabPane>
84
+        <TabPane tab="分享设置" key="3">
85
+          <Share liveActivityId={{ liveId }} />
86
+        </TabPane>
87
+        <TabPane tab="分享记录" key="4">
88
+          <ShareRecord liveActivityId={{ liveId }} />
89
+        </TabPane>
90
+        <TabPane tab="分享访问记录" key="5">
91
+          <VisitRecord liveActivityId={{ liveId }} />
92
+        </TabPane>
93
+      </Tabs>
94
+      {/* <Radio.Group value={ tab } buttonStyle="solid" onChange={e => tabsCallback(e)}>
64 95
         <Radio.Button value="base">基本信息</Radio.Button>
65 96
         <Radio.Button value="poster">海报设置</Radio.Button>
66 97
         <Radio.Button value="share">分享设置</Radio.Button>
@@ -73,15 +104,11 @@ function EditHouse(props) {
73 104
         { (tab === 'share' && <Share liveActivityId={{ liveId }}/>)}
74 105
         { (tab === 'shareRecord' && <ShareRecord liveActivityId={{ liveId }}/>)}
75 106
         { (tab === 'visitRecord' && <VisitRecord liveActivityId={{ liveId }}/>)}
76
-      </div>
77
-      <Prompt message={location =>
78
-        location.pathname.startsWith("/activity/liveActivity")
79
-          ? true
80
-          : localStorage.removeItem("liveActivePageParams")} />
81
-    </>
82
-  )
107
+      </div> */}
108
+    </Card>
109
+  );
83 110
 }
84 111
 
85 112
 const WrappedEditHouseForm = Form.create({ name: 'editHouse' })(EditHouse);
86 113
 
87
-export default WrappedEditHouseForm
114
+export default WrappedEditHouseForm;

+ 137
- 106
src/pages/Live/LiveActivity/List/index.jsx 查看文件

@@ -1,13 +1,25 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Input, Button, Icon, Select, message, Table, Pagination, Modal, Card, notification } from 'antd';
2
+import {
3
+  Form,
4
+  Input,
5
+  Button,
6
+  Icon,
7
+  Select,
8
+  message,
9
+  Table,
10
+  Pagination,
11
+  Modal,
12
+  Card,
13
+  notification,
14
+} from 'antd';
3 15
 import router from 'umi/router';
4 16
 import moment from 'moment';
5 17
 import AuthButton from '@/components/AuthButton';
6 18
 import Prompt from 'umi/prompt';
7 19
 import withActions from '@/components/ActionList';
8 20
 import EditIcon from '@/components/EditIcon';
9
-import SelectCity from '@/components/SelectButton/CitySelect'
10
-import BuildSelect from '@/components/SelectButton/BuildSelect'
21
+import SelectCity from '@/components/SelectButton/CitySelect';
22
+import BuildSelect from '@/components/SelectButton/BuildSelect';
11 23
 import apis from '@/services/apis';
12 24
 import request from '@/utils/request';
13 25
 import Navigate from '@/components/Navigate';
@@ -17,86 +29,80 @@ const { Option } = Select;
17 29
 
18 30
 const header = props => {
19 31
   // eslint-disable-next-line react-hooks/rules-of-hooks
20
-  const [data, setData] = useState({ list: [], total: 0 })
32
+  const [data, setData] = useState({ list: [], total: 0 });
21 33
   //   const [page, changePage] = useState({})
22
-  const [liveIdList, setLiveIdList] = useState([])
23
-  const [time, setTime] = useState('')
24
-  const [showHelp, setShowHelp] = useState(false)
34
+  const [liveIdList, setLiveIdList] = useState([]);
35
+  const [time, setTime] = useState('');
36
+  const [showHelp, setShowHelp] = useState(false);
25 37
 
26 38
   // 查询列表
27 39
   const getList = params => {
28 40
     request({ ...apis.taliveActivity.taLiveActivity, params: { ...params } }).then(data => {
29
-      console.log(data)
30
-      setData(data)
31
-    })
32
-  }
41
+      console.log(data);
42
+      setData(data);
43
+    });
44
+  };
33 45
 
34 46
   // eslint-disable-next-line react-hooks/rules-of-hooks
35 47
   useEffect(() => {
36
-
37
-      getList({ pageNum: 1, pageSize: 10 });
38
-    
39
-   
40
-  }, [])
48
+    getList({ pageNum: 1, pageSize: 10 });
49
+  }, []);
41 50
 
42 51
   // 跳转到编辑
43 52
   const toAddLive = rowData => () => {
44
-    if(rowData) {
53
+    if (rowData) {
45 54
       router.push({
46
-      pathname: '/Live/LiveActivity/Edit',
47
-      query: {
48
-        id: rowData.liveActivityId,
49
-        buildingId: rowData.buildingId,
50
-      },
51
-    });
52
-      return
55
+        pathname: '/Live/LiveActivity/Edit',
56
+        query: {
57
+          id: rowData.liveActivityId,
58
+          buildingId: rowData.buildingId,
59
+        },
60
+      });
61
+      return;
53 62
     }
54 63
     router.push({
55
-      pathname: '/Live/LiveActivity/Edit',
64
+      pathname: '/Live/LiveActivity/add',
56 65
     });
57
-  }
66
+  };
58 67
 
59 68
   const toDataReacord = rowData => () => {
60
-  
61
-      router.push({
69
+    router.push({
62 70
       pathname: '/activity/liveActivity/liveActivityRecord',
63 71
       query: {
64 72
         id: rowData.liveActivityId,
65 73
       },
66 74
     });
67
-  }
75
+  };
68 76
 
69 77
   function openNotificationWithIcon(type, message) {
70 78
     notification[type]({
71 79
       message,
72
-      description:
73
-        '',
80
+      description: '',
74 81
     });
75 82
   }
76 83
 
77
-  
78
-  const toDelLiveActivity = rowData => () =>{
79
-    console.log(liveIdList, 'liveIdListliveIdList')
80
-    if(liveIdList.length < 1){
81
-      openNotificationWithIcon('error', '请先选择需要删除的直播活动')
82
-      return
84
+  const toDelLiveActivity = rowData => () => {
85
+    console.log(liveIdList, 'liveIdListliveIdList');
86
+    if (liveIdList.length < 1) {
87
+      openNotificationWithIcon('error', '请先选择需要删除的直播活动');
88
+      return;
83 89
     }
84 90
     Modal.confirm({
85 91
       title: '删除后当前直播活动关联的小程序端开屏图、banner图等也会自动下架',
86 92
       okText: '确定',
87 93
       cancelText: '取消',
88
-      onOk () {
89
-        request({ ...apis.taliveActivity.deleteTaLiveActivity, data: liveIdList, }).then((data) => {
90
-          message.info("操作成功")
91
-          getList({ pageNum: 1, pageSize: 10 });
92
-        }).catch((err) => {
93
-          // message.info(err.msg)
94
-        })
94
+      onOk() {
95
+        request({ ...apis.taliveActivity.deleteTaLiveActivity, data: liveIdList })
96
+          .then(data => {
97
+            message.info('操作成功');
98
+            getList({ pageNum: 1, pageSize: 10 });
99
+          })
100
+          .catch(err => {
101
+            // message.info(err.msg)
102
+          });
95 103
       },
96 104
     });
97
-
98
-    
99
-  }
105
+  };
100 106
 
101 107
   /**
102 108
    *
@@ -110,7 +116,7 @@ const header = props => {
110 116
       dataIndex: 'liveActivityTitle',
111 117
       key: 'liveActivityTitle',
112 118
       align: 'center',
113
-      render:  (x, row) => <Navigate onClick={toAddLive(row)}>{row.liveActivityTitle}</Navigate>,
119
+      render: (x, row) => <Navigate onClick={toAddLive(row)}>{row.liveActivityTitle}</Navigate>,
114 120
     },
115 121
     {
116 122
       title: '所属城市',
@@ -129,14 +135,22 @@ const header = props => {
129 135
       dataIndex: 'liveStartDate',
130 136
       key: 'liveStartDate',
131 137
       align: 'center',
132
-      render: (x, row) => <><span>{`${moment(row.liveStartDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
138
+      render: (x, row) => (
139
+        <>
140
+          <span>{`${moment(row.liveStartDate).format('YYYY-MM-DD HH:mm:ss')}`}</span>
141
+        </>
142
+      ),
133 143
     },
134 144
     {
135 145
       title: '直播结束时间',
136 146
       dataIndex: 'liveEndDate',
137 147
       key: 'liveEndDate',
138 148
       align: 'center',
139
-      render: (x, row) => <><span>{`${moment(row.liveEndDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
149
+      render: (x, row) => (
150
+        <>
151
+          <span>{`${moment(row.liveEndDate).format('YYYY-MM-DD HH:mm:ss')}`}</span>
152
+        </>
153
+      ),
140 154
     },
141 155
     {
142 156
       title: '权重',
@@ -149,7 +163,11 @@ const header = props => {
149 163
       dataIndex: 'status',
150 164
       key: 'status',
151 165
       align: 'center',
152
-      render: status => <><span>{status == 0 ? '未发布' : '已发布'}</span></>,
166
+      render: status => (
167
+        <>
168
+          <span>{status == 0 ? '未发布' : '已发布'}</span>
169
+        </>
170
+      ),
153 171
     },
154 172
     {
155 173
       title: '新增人',
@@ -162,7 +180,11 @@ const header = props => {
162 180
       dataIndex: 'createDate',
163 181
       key: 'createDate',
164 182
       align: 'center',
165
-      render: (x, row) => <><span>{`${moment(row.createDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
183
+      render: (x, row) => (
184
+        <>
185
+          <span>{`${moment(row.createDate).format('YYYY-MM-DD HH:mm:ss')}`}</span>
186
+        </>
187
+      ),
166 188
     },
167 189
     {
168 190
       title: '修改人',
@@ -175,17 +197,21 @@ const header = props => {
175 197
       dataIndex: 'updateDate',
176 198
       key: 'updateDate',
177 199
       align: 'center',
178
-      render: (x, row) => <><span>{`${moment(row.updateDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
200
+      render: (x, row) => (
201
+        <>
202
+          <span>{`${moment(row.updateDate).format('YYYY-MM-DD HH:mm:ss')}`}</span>
203
+        </>
204
+      ),
179 205
     },
180 206
     {
181 207
       title: '操作',
182 208
       align: 'center',
183 209
       width: 240,
184
-      render: withActions((text, record) => [    
185
-        <AuthButton name="admin.liveActivity.dataRecord" noRight={null}>
186
-          <EditIcon type="record" text="数据记录" onClick={toDataReacord(record)} />
187
-        </AuthButton>,
188
- 
210
+      render: withActions((text, record) => [
211
+        // <AuthButton name="admin.liveActivity.dataRecord" noRight={null}>
212
+        //   <EditIcon type="record" text="数据记录" onClick={toDataReacord(record)} />
213
+        // </AuthButton>,
214
+
189 215
         <AuthButton name="admin.live.detail.get" noRight={null}>
190 216
           <EditIcon type="look" text="查看详情" onClick={toAddLive(record)} />
191 217
         </AuthButton>,
@@ -199,17 +225,16 @@ const header = props => {
199 225
         dynamicId,
200 226
       },
201 227
     });
202
-  }
228
+  };
203 229
 
204 230
   const changePageNum = pageNumber => {
205
-
206
-    getList({ pageNum: pageNumber, pageSize: 10, ...props.form.getFieldsValue() })
207
-  }
231
+    getList({ pageNum: pageNumber, pageSize: 10, ...props.form.getFieldsValue() });
232
+  };
208 233
 
209 234
   const rowSelection = {
210 235
     onChange: (selectedRowKeys, selectedRows) => {
211 236
       console.log('selectedRowKeys:', selectedRowKeys, 'selectedRows: ', selectedRows);
212
-      setLiveIdList(selectedRows)
237
+      setLiveIdList(selectedRows);
213 238
     },
214 239
   };
215 240
 
@@ -218,93 +243,99 @@ const header = props => {
218 243
     e.preventDefault();
219 244
     props.form.validateFields((err, values) => {
220 245
       if (!err) {
221
-        console.log('提交数据: ', values)
246
+        console.log('提交数据: ', values);
222 247
         if (time) {
223
-          values.time = `${moment(time).format('YYYY-MM-DDT00:00:00.000')}Z`
248
+          values.time = `${moment(time).format('YYYY-MM-DDT00:00:00.000')}Z`;
224 249
         } else {
225
-          values.time = null
250
+          values.time = null;
226 251
         }
227
-      
228
-        getList({ pageNum: 1, pageSize: 10, ...values })
252
+
253
+        getList({ pageNum: 1, pageSize: 10, ...values });
229 254
       }
230 255
     });
231
-  }
256
+  };
232 257
 
233 258
   // 重置搜索
234
-  function handleReset () {
259
+  function handleReset() {
235 260
     props.form.resetFields();
236
-    setTime('')
261
+    setTime('');
237 262
 
238
-    getList({ pageNum: 1, pageSize: 10 })
263
+    getList({ pageNum: 1, pageSize: 10 });
239 264
   }
240 265
 
241 266
   // 时间回调
242 267
   function timeOnChange(date, dateString) {
243
-    console.log(date, dateString)
244
-    setTime(date)
268
+    console.log(date, dateString);
269
+    setTime(date);
245 270
   }
246 271
 
247
-
248
-  const { getFieldDecorator } = props.form
272
+  const { getFieldDecorator } = props.form;
249 273
   return (
250
-
251 274
     <Card>
252 275
       {/* style={{ display: 'none' }} */}
253 276
       <div id="qrcode"></div>
254 277
       <Form layout="inline" onSubmit={e => handleSubmit(e)}>
255 278
         <Form.Item>
256 279
           {getFieldDecorator('liveActivityTitle')(
257
-             <Input
258
-             prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
259
-             placeholder="直播活动标题"
260
-           />,
261
-          )}
262
-        </Form.Item>
263
-        <Form.Item>
264
-          {getFieldDecorator('cityId')(
265
-            <SelectCity />,
266
-          )}
267
-        </Form.Item>
268
-        <Form.Item>
269
-          {getFieldDecorator('buildingId')(
270
-            <BuildSelect />,
280
+            <Input
281
+              prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
282
+              placeholder="直播活动标题"
283
+            />,
271 284
           )}
272 285
         </Form.Item>
286
+        <Form.Item>{getFieldDecorator('cityId')(<SelectCity />)}</Form.Item>
287
+        <Form.Item>{getFieldDecorator('buildingId')(<BuildSelect />)}</Form.Item>
273 288
         <Form.Item>
274 289
           {getFieldDecorator('status')(
275 290
             <Select style={{ width: '180px' }} placeholder="发布状态">
276
-            <Option value="1">已发布</Option>
277
-            <Option value="0">未发布</Option>
278
-          </Select>,
291
+              <Option value="1">已发布</Option>
292
+              <Option value="0">未发布</Option>
293
+            </Select>,
279 294
           )}
280 295
         </Form.Item>
281 296
         <Form.Item>
282 297
           <AuthButton name="admin.buildingDynamic.search" noRight={null}>
283
-            <Button type="primary" htmlType="submit" >
298
+            <Button type="primary" htmlType="submit">
284 299
               搜索
285 300
             </Button>
286 301
           </AuthButton>
287 302
           <Button style={{ marginLeft: 8 }} onClick={handleReset}>
288 303
             重置
289
-            </Button>
304
+          </Button>
290 305
         </Form.Item>
291 306
       </Form>
292
-      
307
+
293 308
       <AuthButton name="admin.live.add.post" noRight={null}>
294
-        <Button type="danger" style={{margin:'20px 0'}}  onClick={toAddLive()}>新增</Button>
309
+        <Button type="danger" style={{ margin: '20px 0' }} onClick={toAddLive()}>
310
+          新增
311
+        </Button>
295 312
       </AuthButton>
296 313
       <AuthButton name="admin.live.del" noRight={null}>
297
-        <Button type="primary"  onClick={toDelLiveActivity()} style={{marginLeft:'30px'}}>删除</Button>
298
-      </AuthButton><br/>
314
+        <Button type="primary" onClick={toDelLiveActivity()} style={{ marginLeft: '30px' }}>
315
+          删除
316
+        </Button>
317
+      </AuthButton>
318
+      <br />
299 319
       <span>共筛选出{data.total}条记录</span>
300
-      <Table rowSelection={rowSelection}
301
-       dataSource={data.records} columns={columns} pagination={false} rowKey="activityList" />
320
+      <Table
321
+        rowSelection={rowSelection}
322
+        dataSource={data.records}
323
+        columns={columns}
324
+        pagination={false}
325
+        rowKey="activityList"
326
+      />
302 327
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
303
-        <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={e => changePageNum(e)} current={data.current}/>
328
+        <Pagination
329
+          showQuickJumper
330
+          defaultCurrent={1}
331
+          total={data.total}
332
+          onChange={e => changePageNum(e)}
333
+          current={data.current}
334
+        />
304 335
       </div>
305 336
     </Card>
306
-  )
307
-}
337
+  );
338
+};
308 339
 const WrappedHeader = Form.create({ name: 'header' })(header);
309 340
 
310
-export default WrappedHeader
341
+export default WrappedHeader;

+ 176
- 0
src/pages/Live/LiveActivity/add/index.jsx 查看文件

@@ -0,0 +1,176 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, DatePicker, Radio, Upload, InputNumber } from 'antd';
3
+import { FormattedMessage } from 'umi-plugin-react/locale';
4
+import XForm, { FieldTypes } from '../../../../components/XForm';
5
+import router from 'umi/router';
6
+import moment from 'moment';
7
+import styles from '../../../style/GoodsList.less';
8
+import SelectCity from '../../../../components/SelectButton/CitySelect'
9
+import BuildSelect2 from '../../../../components/SelectButton/BuildSelect2'
10
+import LivePlatSelect from '../../../../components/SelectButton/LivePlatSelect'
11
+import CitySelect3 from '../../../../components/SelectButton/CitySelect3'
12
+import ImageUpload from '../../../../components/XForm/ImageUpload'
13
+import Wangedit from '../../../../components/Wangedit/Wangedit'
14
+import Navigate from '@/components/Navigate';
15
+import apis from '../../../../services/apis';
16
+import request from '../../../../utils/request';
17
+import AuthButton from '@/components/AuthButton';
18
+import Prompt from 'umi/prompt';
19
+
20
+const { Option } = Select;
21
+const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
22
+
23
+let cityId = ''
24
+
25
+const header = props => {
26
+  const { salesBatchId } = props.location.query
27
+  console.log(salesBatchId)
28
+  const [ saleBatchData, setSaleBatchData ] = useState({})
29
+  const [showHelp, setShowHelp] = useState(false)
30
+
31
+  const cancelPage = () =>{
32
+    router.push({
33
+      pathname: '/activity/liveActivity/list',
34
+    });
35
+  }
36
+
37
+   //打开新页面
38
+   const openIndexImg = () => {
39
+    const newWin=window.open('about:blank');
40
+    newWin.location.href="http://njcj.oss-cn-shanghai.aliyuncs.com/%E6%95%99%E7%A8%8B.png"
41
+  }
42
+
43
+  function highlightsTypeChange(e) {
44
+    console.log(e.target.value,"ee")
45
+    setTypeState(e.target.value)
46
+  }
47
+
48
+  function disabledDate(current) {
49
+    // Can not select days before today and today
50
+    return current && current < moment().endOf('day');
51
+  }
52
+
53
+  function handleSubmit (e) {
54
+    e.preventDefault();
55
+    props.form.validateFields((err, values) => {
56
+      if (!err){
57
+        let {liveTime, ...submitValue} = values
58
+        submitValue.liveStartDate = moment(submitValue.liveStartDate._d).format('YYYY-MM-DD HH:mm:ss')
59
+        submitValue.liveEndDate = moment(submitValue.liveEndDate._d).format('YYYY-MM-DD HH:mm:ss')
60
+        
61
+        if (values.liveStartDate > values.liveEndDate){
62
+          message.info("直播结束时间大于开始时间")
63
+          return;
64
+        }
65
+
66
+        request({ ...apis.taliveActivity.addTaLiveActivity, data: { ...submitValue },}).then((data) => {
67
+          message.info("保存成功")
68
+          console.log(data,"datattttttt")
69
+          router.go('-1');
70
+        }).catch((err) => {
71
+          message.info(err.msg || err.message)
72
+        })
73
+      }
74
+    });
75
+  }
76
+
77
+  const { getFieldDecorator } = props.form;
78
+
79
+  return (
80
+    <>
81
+      <Form labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} onSubmit={handleSubmit}>
82
+        <Form.Item label="所属城市">
83
+          {getFieldDecorator('cityId', {
84
+            rules: [{ required: true, message: ' 请输入所属城市' }],
85
+          })(<CitySelect3 buildingId={props.form.getFieldValue('buildingId')}/>)}
86
+        </Form.Item>
87
+        <Form.Item label="所属楼盘">
88
+          {getFieldDecorator('buildingId')(<BuildSelect2 cityId={props.form.getFieldValue('cityId')}/>)}
89
+        </Form.Item>
90
+        <Form.Item label="直播活动标题">
91
+          {getFieldDecorator('liveActivityTitle', {
92
+            rules: [{ required: true, message: '请输入直播活动标题' }],
93
+          })(<Input maxLength={20} placeholder="给直播活动起个名字" />)}
94
+        </Form.Item>
95
+        <Form.Item label="直播开始时间">
96
+          {getFieldDecorator('liveStartDate', {
97
+                rules: [
98
+                  {
99
+                    required: true,
100
+                    message: '请选择直播开始时间',
101
+                  },
102
+                ],
103
+              })(<DatePicker placeholder="预计开始时间"style={{ width: '500px' }}format="YYYY-MM-DD HH:mm:ss" showTime={{ format: 'HH:mm:ss' }}/>)}
104
+        </Form.Item>
105
+        <Form.Item label="直播结束时间">
106
+          {getFieldDecorator('liveEndDate', {
107
+                rules: [
108
+                  {
109
+                    required: true,
110
+                    message: '请选择直播结束时间',
111
+                  },
112
+                ],
113
+              })(<DatePicker placeholder="预计结束时间" disabledDate={disabledDate} style={{ width: '500px' }}format="YYYY-MM-DD HH:mm:ss" showTime={{ format: 'HH:mm:ss' }}/>)}
114
+        </Form.Item>
115
+        <Form.Item label="直播小程序">
116
+          {getFieldDecorator('liveApp', {
117
+              rules: [{ required: true, message: '请选择直播小程序' }],
118
+            })((<LivePlatSelect />))}
119
+        </Form.Item>
120
+        <Form.Item label="房间参数">
121
+          {getFieldDecorator('liveRoomParam', {
122
+            rules: [{ required: true, message: '请输入房间参数' }],
123
+          })(<Input maxLength={1000} placeholder="点击右侧按钮查看如何获取房间参数" style={{width:'680px'}}/>)}<Navigate onClick={openIndexImg}>不知道怎么填?查看说明</Navigate>
124
+        </Form.Item>
125
+        <Form.Item label="封面图1" help="建议尺寸:750px*420px,比例16:9,格式:jpg,用于:活动列表">
126
+              {getFieldDecorator('listImg', {
127
+                  rules: [{ required: true, message: '请上传封面图1' }],
128
+              })(
129
+                <ImageUpload />,
130
+              )}
131
+        </Form.Item>  
132
+        <Form.Item label="封面图2" help="建议尺寸:750*250px,比例3:1,格式:jpg,用于:项目详情页">
133
+              {getFieldDecorator('detailImg', {
134
+                  rules: [{ required: true, message: '请上传封面图2' }],
135
+              })(
136
+                <ImageUpload />,
137
+              )}
138
+        </Form.Item>  
139
+        <Form.Item label="详情图" help="格式:jpg,用于:直播活动详情页,点击可跳转到直播间">
140
+              {getFieldDecorator('detailTypeImg', {
141
+                  rules: [{ required: true, message: '请上传详情图' }],
142
+              })(
143
+                <ImageUpload />,
144
+              )}
145
+        </Form.Item>      
146
+        <Form.Item label="权重">
147
+              {getFieldDecorator('weight', {
148
+                  rules: [{ required: true, message: '请设置权重' }],
149
+              })(
150
+                <InputNumber placeholder="权重越大越靠前" style={{width:'150px'}}/>
151
+              )}
152
+        </Form.Item>
153
+        <Form.Item label="发布状态">
154
+          {getFieldDecorator('status', {
155
+              rules: [{ required: true, message: '请选择发布状态' }],
156
+            })(<Select placeholder="发布状态" style={{ width: '300px' }}>
157
+            <Option value="0">否</Option>
158
+            <Option value="1">是</Option>
159
+          </Select>)}
160
+        </Form.Item>
161
+        <Form.Item wrapperCol={{ span: 15, offset: 7 }}>
162
+          <Button type="primary" htmlType="submit"style={{marginRight:'20px'}}>
163
+            确定
164
+          </Button>
165
+          <Button onClick={() => router.go(-1)}>
166
+            取消
167
+          </Button>
168
+        </Form.Item>
169
+      </Form>
170
+    </>
171
+  )
172
+}
173
+
174
+const WrappedHeader = Form.create({ name: 'header' })(header);
175
+
176
+export default WrappedHeader

+ 2
- 1
src/pages/Live/liveActivity copy/edit/components/shareRecord.jsx 查看文件

@@ -26,7 +26,8 @@ const header = (props) => {
26 26
     request({ ...apis.taliveActivity.taLiveShare, params: { ...params },}).then((data) => {
27 27
         console.log(data)
28 28
         setData(data)
29
-    })
29
+    }).catch(e=>
30
+      console.error(e))
30 31
   }
31 32
   
32 33
   const columns = [

+ 2
- 2
src/pages/staff/staff/Edit/index.jsx 查看文件

@@ -234,7 +234,7 @@ const StaffEdit = (props) => {
234 234
       value: userData.roleIds,
235 235
     },
236 236
     {
237
-      label: '授权项目',
237
+      label: '授权项目', //改成组织机构
238 238
       name: 'buildingId',
239 239
       render: <BuildingSelection userData={userData} />,
240 240
       value: userData.buildingId,
@@ -306,7 +306,7 @@ const StaffEdit = (props) => {
306 306
 
307 307
 
308 308
   return <Card>
309
-            <XForm onChange={console.log} onSubmit={handleSubmit} fields={fields.filter(Boolean)} onCancel={() => router.go(-1)}></XForm>
309
+            <XForm  onSubmit={handleSubmit} fields={fields.filter(Boolean)} onCancel={() => router.go(-1)}></XForm>
310 310
 
311 311
         </Card>
312 312
 }

+ 317
- 0
src/pages/staff/staff/Edit/index1.jsx 查看文件

@@ -0,0 +1,317 @@
1
+import React, { useState, useEffect } from 'react';
2
+
3
+import { Input, Card, message, Radio, Select, Modal } from 'antd';
4
+import { FormattedMessage } from 'umi-plugin-react/locale';
5
+import BuildSelect from '@/components/SelectButton/BuildSelect'
6
+import router from 'umi/router';
7
+import { FieldTypes, createForm } from '@/components/XForm';
8
+import Wangedit from '@/components/Wangedit/Wangedit'
9
+// import channels from './channelList.less';
10
+// import Tagss from '../components/Tagss.jsx';
11
+import apis from '@/services/apis';
12
+import request from '@/utils/request'
13
+import BuildingSelection from '../components/BuildingSelection'
14
+
15
+const { TextArea } = Input;
16
+const { Option } = Select;
17
+let consultantChecked = false;
18
+
19
+const setExtraData = (data) => {
20
+  consultantChecked = data.isConsultant
21
+}
22
+
23
+const handleFormValueChange = (props, changedValues, allValues) => {
24
+    setExtraData(allValues)
25
+}
26
+
27
+const XForm = createForm({ onValuesChange: handleFormValueChange })
28
+
29
+/**
30
+ *
31
+ *
32
+ * @param {*} props
33
+ * @returns
34
+ */
35
+const StaffEdit = (props) => {
36
+  const userId = props.location.query.userId
37
+  const [userData, setUserData] = useState({})
38
+  const [tagData, setTagData] = useState([])
39
+  const [roleData, setRoleData] = useState([])
40
+  const [buildData, setBuildData] = useState([])
41
+  const [visible, setVisible] = useState(false)
42
+
43
+  const getTagList = () => {
44
+    request({ ...apis.staff.taTags, params: { pageNum: 1, pageSize: 999 } }).then((data) => {
45
+      setTagData(data.records)
46
+    })
47
+  }
48
+
49
+  const getRoleList = () => {
50
+    request({ ...apis.role.getRoleList, params: { pageNum: 1, pageSize: 999 } }).then((data) => {
51
+      console.log(data)
52
+      setRoleData(data.records)
53
+    })
54
+  }
55
+
56
+  //获取项目列表
57
+  const getBuildList = e => {
58
+    request({ ...apis.building.buildingSelect, params: { pageNum: 1, pageSize: 999 } }).then(data => {
59
+        setBuildData(data)
60
+    })
61
+  }
62
+
63
+  // 查询列表
64
+  const getUserData = (userId) => {
65
+    request({ ...apis.staff.getTaUser, urlData: { id: userId } }).then((data) => {
66
+      consultantChecked = data.isConsultant
67
+      setUserData(data)
68
+    })
69
+  }
70
+
71
+  if(userData.buildingIds && buildData.length > 0 && !consultantChecked){
72
+      const newBuildings = userData.buildingIds.filter(x => buildData.filter(it => it.buildingId === x)[0])
73
+      userData.buildingIds = newBuildings
74
+  }
75
+
76
+  if(userData.roleIds && roleData.length > 0){
77
+    const newRoleIds = userData.roleIds.filter(x => roleData.filter(it => it.roleId === x)[0])
78
+      userData.roleIds = newRoleIds
79
+  }
80
+
81
+  useEffect(() => {
82
+    getTagList();
83
+    getRoleList();
84
+    getBuildList();
85
+    if (userId) {
86
+      getUserData(userId);
87
+    }
88
+  }, [])
89
+
90
+  const tagsChange = (value) => {
91
+    console.log(`selected ${value}`);
92
+  }
93
+
94
+  const handleSubmit = val => {
95
+    if (userId) {
96
+      request({ ...apis.staff.updateTaUser, urlData: { id: userId }, data: val, }).then((data) => {
97
+        console.log(data, "tauser")
98
+        message.info("保存成功")
99
+        router.go(-1)
100
+      }).catch(error => {
101
+        // message.info(error.message)
102
+      })
103
+    } else {
104
+      request({ ...apis.staff.addTaUser, data: val, }).then((data) => {
105
+        console.log(data, "tauser")
106
+        message.info("保存成功")
107
+        router.go(-1)
108
+      }).catch(error => {
109
+        // message.info(error.message)
110
+      })
111
+    }
112
+  }
113
+
114
+  const photoBeforeUpload = (file) => {
115
+    // const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
116
+    // if (!isJpgOrPng) {
117
+    //   message.error('请上传 JPG/PNG 格式的图片!');
118
+    // }
119
+    console.log(file.size, file.size / 1024)
120
+    const isLt100k = (file.size / 1024) < 100;
121
+    if (!isLt100k) {
122
+      message.error('请上传小于100k的图片!');
123
+    }
124
+    return isLt100k;
125
+  }
126
+
127
+  //授权项目改变
128
+  const consultantBuildingChange =(e) => {
129
+    if(userData.isConsultant){
130
+      request({ ...apis.staff.check, params: { userId: userData.userId, personId: userData.consultantPersonId, buildingId: userData.buildingId } }).then(res => {
131
+        if(res.length > 0){
132
+          Modal.confirm({
133
+            title: '此置业顾问下有私客,是否转移私客?',
134
+            okText: '确认',
135
+            cancelText: '取消',
136
+            onOk () {
137
+              setVisible(true)
138
+            },
139
+          });
140
+        }
141
+     })
142
+    }
143
+  }
144
+
145
+   //迁移私客成功回调
146
+   const moveSuccess = (e) => {
147
+    setVisible(false)
148
+  }
149
+
150
+  const fields = [
151
+
152
+
153
+    
154
+    // {
155
+    //   label: '姓名',
156
+    //   name: 'userName',
157
+    //   type: FieldTypes.Text,
158
+    //   value: userData.userName,
159
+    //   rules: [
160
+    //     { required: true, message: '请输入姓名' },
161
+    //   ]
162
+    // },
163
+    // {
164
+    //   label: '公司',
165
+    //   name: 'orgName',
166
+    //   type: FieldTypes.Text,
167
+    //   placeholder: '请输入公司名称',
168
+    //   value: userData.orgName,
169
+    //   rules: [
170
+    //     { required: true, message: '请输入公司名称' },
171
+    //   ]
172
+    // },
173
+    // {
174
+    //   label: '部门',
175
+    //   name: 'department',
176
+    //   type: FieldTypes.Text,
177
+    //   placeholder: '请输入部门',
178
+    //   value: userData.department,
179
+    //   rules: [
180
+    //     { required: true, message: '请输入部门' },
181
+    //   ]
182
+    // },
183
+    // {
184
+    //   label: '职位',
185
+    //   name: 'position',
186
+    //   type: FieldTypes.Text,
187
+    //   placeholder: '请输入职位',
188
+    //   value: userData.position,
189
+    //   rules: [
190
+    //     { required: true, message: '请输入职位' },
191
+    //   ]
192
+    // },
193
+    // {
194
+    //   label: '是否置业顾问',
195
+    //   name: 'isConsultant',
196
+    //   type: FieldTypes.Switch,
197
+    //   value: userData.isConsultant,
198
+    //   props: {disabled: userData.isConsultant},
199
+    // },
200
+    // {
201
+    //   label: '电话',
202
+    //   name: 'phone',
203
+    //   type: FieldTypes.Text,
204
+    //   placeholder: '请输入电话号码',
205
+    //   value: userData.phone,
206
+    //   rules: [
207
+    //     {
208
+    //         required: true,
209
+    //         pattern: new RegExp('^1[0-9]{10}$'),
210
+    //         message: '请输入正确的电话号码',
211
+    //     },
212
+    //   ]
213
+    // },
214
+    // {
215
+    //   label: '登录名',
216
+    //   name: 'loginName',
217
+    //   type: FieldTypes.Text,
218
+    //   placeholder: '请输入登录名',
219
+    //   value: userData.loginName,
220
+    //   // hidden: () => consultantChecked,
221
+    //   help: '默认密码:123456',
222
+    // },
223
+    // {
224
+    //   label: '角色',
225
+    //   name: 'roleIds',
226
+    //   render: <Select
227
+    //     mode="multiple"
228
+    //     style={{ width: '100%' }}
229
+    //     placeholder="请选择标签"
230
+    //     onChange={tagsChange} >
231
+    //     {roleData.map(item => (
232
+    //       <Select.Option key={item.roleId} value={item.roleId}>
233
+    //         {item.roleName}
234
+    //       </Select.Option>
235
+    //     ))}
236
+    //   </Select>,
237
+    //   value: userData.roleIds,
238
+    // },
239
+    // {
240
+    //   label: '授权项目',
241
+    //   name: 'buildingId',
242
+    //   render: <BuildingSelection userData={userData} />,
243
+    //   value: userData.buildingId,
244
+    //   hidden: () => !consultantChecked,
245
+    //   rules: [
246
+    //     { required: true, message: '请选择授权项目' },
247
+    //   ]
248
+    // },
249
+    // {
250
+    //   label: '授权项目',
251
+    //   name: 'buildingIds',
252
+    //   render: <Select
253
+    //     mode="multiple"
254
+    //     showSearch
255
+    //     style={{ width: '100%' }}
256
+    //     placeholder="请选择授权项目"
257
+    //     filterOption={(input, option) =>
258
+    //       option.props.children && option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
259
+    //     }
260
+    //     >
261
+    //     {buildData.map(item => (
262
+    //       <Select.Option key={item.buildingId} value={item.buildingId}>
263
+    //         {item.buildingName}
264
+    //       </Select.Option>
265
+    //     ))}
266
+    //   </Select>,
267
+    //   value: userData.buildingIds,
268
+    //   hidden: () => consultantChecked,
269
+    //   rules: [
270
+    //     { required: true, message: '请选择授权项目' },
271
+    //   ]
272
+    // },
273
+    // {
274
+    //   label: '置业顾问头像',
275
+    //   name: 'photo',
276
+    //   type: FieldTypes.ImageUploader,
277
+    //   extra: '建议图片尺寸:320*320px,比例1:1,格式:jpg,用于置业顾问头像,限制大小:100k',
278
+    //   value: userData.photo,
279
+    //   beforeUpload: (e) => photoBeforeUpload(e),
280
+    //   rules: [
281
+    //     { required: true, message: '请选择头像' },
282
+    //   ]
283
+    // },
284
+    // {
285
+    //   label: '简介',
286
+    //   name: 'description',
287
+    //   render: <TextArea  ></TextArea>,
288
+    //   value: userData.description
289
+    //   // className={channels.inpuitTxt}
290
+    // },
291
+    // {
292
+    //   label: '状态',
293
+    //   name: 'status',
294
+    //   render: <Radio.Group initialValue="1" buttonStyle="solid">
295
+    //     <Radio.Button value="9">禁用</Radio.Button>
296
+    //     <Radio.Button value="1">启用</Radio.Button>
297
+    //   </Radio.Group>,
298
+    //   value: userData.status != null ? userData.status.toString() : "1"
299
+    // },
300
+    // {
301
+    //   label: '权重',
302
+    //   name: 'weight',
303
+    //   type: FieldTypes.Number,
304
+    //   render: <Input type="number" style={{ width: 150}} />,
305
+    //   value: userData.weight,
306
+    //   help: '数字越大越靠前',
307
+    // },
308
+  ]
309
+
310
+
311
+  return <Card>
312
+            <XForm  onSubmit={handleSubmit} fields={fields} onCancel={() => router.go(-1)}></XForm>
313
+
314
+        </Card>
315
+}
316
+
317
+export default StaffEdit

+ 5
- 1
src/utils/request.js 查看文件

@@ -68,6 +68,7 @@ request.interceptors.request.use((url, options) => {
68 68
 });
69 69
 
70 70
 request.interceptors.response.use(async (response, options) => {
71
+  
71 72
   if (response && response.status) {
72 73
     if (response.status != 200) {
73 74
       const errorText = codeMessage[response.status] || response.statusText;
@@ -81,6 +82,7 @@ request.interceptors.response.use(async (response, options) => {
81 82
     } else {
82 83
       // console.log('response.headers: ', response.headers)
83 84
       // console.log('response.headers.Content-Type: ', response.headers.get('Content-Type'))
85
+      console.log(response,'response')
84 86
       if (response.headers.get('Content-Type') === 'application/octet-stream;charset=utf-8') {
85 87
         return await response.clone().blob();
86 88
       }
@@ -89,8 +91,9 @@ request.interceptors.response.use(async (response, options) => {
89 91
       if (response.url.indexOf('gaode_amap') !== -1) {
90 92
         return await response.clone().json();
91 93
       }
92
-
94
+      console.log(response,'response')
93 95
       const { code, data, message } = await response.clone().json();
96
+     
94 97
       if (code != 1000) {
95 98
         if (code === 1001) {
96 99
           // notification.error({
@@ -99,6 +102,7 @@ request.interceptors.response.use(async (response, options) => {
99 102
           // });
100 103
           // throw new Error('请登录系统');
101 104
         } else {
105
+          console.log(code, data, message ,'code, data, message ')
102 106
           notification.error({
103 107
             message: message || '请求错误',
104 108
             // description: message,