Explorar el Código

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

魏熙美 hace 5 años
padre
commit
f0501292ad
Se han modificado 2 ficheros con 167 adiciones y 207 borrados
  1. 60
    159
      src/pages/staff/list/StaffList.jsx
  2. 107
    48
      src/pages/staff/list/editStaff.jsx

+ 60
- 159
src/pages/staff/list/StaffList.jsx Ver fichero

@@ -11,125 +11,45 @@ import Styles from './style.less';
11 11
 const { Meta } = Card;
12 12
 const { Option } = Select;
13 13
 const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
14
-//标签颜色
15
-const colors = {
16
-  金牌顾问: '#E34B59',
17
-  销售冠军: '#E8747E',
18
-  优选顾问: '#EEC37E',
19
-  人气顾问: '#FDDA9F',
20
-}
21
-// 提交事件
22
-function handleSubmit (e, props) {
23
-  e.preventDefault();
24
-  props.form.validateFields((err, values) => {
25
-    if (!err) {
26
-      console.log('提交数据: ', values)
27
-    }
28
-  });
29
-}
30
-// Change 事件
31
-function handleSelectChange (props) {
32
-  console.log(props)
33
-}
34 14
 
35
-// 分页
36
-function onChange (pageNumber) {
37
-  console.log('Page: ', pageNumber);
38
-}
39 15
 // 跳转到编辑商品
40
-function toEditStaff () {
16
+const toEditStaff = (userId) => () => {
41 17
   router.push({
42 18
     pathname: '/staff/editStaff',
43
-    // query: {
44
-    //   a: 'b',
45
-    // },
46
-  });
47
-}
48
-function confirm () {
49
-  Modal.confirm({
50
-    title: '确认停用该角色?',
51
-    okText: '确认',
52
-    cancelText: '取消',
53
-    onOk () {
54
-      console.log('OK');
55
-    },
56
-    onCancel () {
57
-      console.log('Cancel');
19
+    query: {
20
+      userId
58 21
     },
59 22
   });
60
-
61 23
 }
62
-/**
63
- *
64
- *
65
- * 
66
- */
67
-
68
-// 假数据
69
-const tempData = [
70
-  {
71
-    name: '吴媛',
72
-    status: '1',// 启用
73
-    tel: '133 333 222',
74
-    avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
75
-    labels: ['金牌顾问', '销售冠军'],
76
-  },
77
-  {
78
-    name: '吴媛',
79
-    status: '1',// 启用
80
-    tel: '133 333 333',
81
-    avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
82
-    labels: ['金牌顾问', '销售冠军'],
83
-  },
84
-  {
85
-    name: '吴媛',
86
-    status: '1',// 启用
87
-    tel: '133 333 444',
88
-    avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
89
-    labels: ['金牌顾问', '销售冠军'],
90
-  },
91
-  {
92
-    name: '吴媛',
93
-    status: '1',// 启用
94
-    tel: '133 333 555',
95
-    avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
96
-    labels: ['金牌顾问', '销售冠军'],
97
-  },
98
-  {
99
-    name: '吴媛',
100
-    status: '0',
101
-    tel: '133 333 555',
102
-    avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
103
-    labels: ['金牌顾问', '销售冠军'],
104
-  },
105
-  {
106
-    name: '吴媛',
107
-    status: '1',// 启用
108
-    tel: '133 333 555',
109
-    avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
110
-    labels: ['金牌顾问'],
111
-  },
112
-
113
-
114
-
115
-]
116
-
117 24
 
118 25
 /**
119 26
  *卡片
120 27
  *
121 28
  * @returns
122 29
  */
123
-function CartBody (props) {
30
+const CartBody = (props) => {
124 31
   const { data } = props
125
-
32
+    
33
+  const confirm = () => {
34
+    Modal.confirm({
35
+      title: '确认停用该角色?',
36
+      okText: '确认',
37
+      cancelText: '取消',
38
+      onOk () {
39
+        console.log('OK');
40
+      },
41
+      onCancel () {
42
+        console.log('Cancel');
43
+      },
44
+    });
45
+  }
126 46
   return (
127 47
 
128 48
     <Card className={Styles.card}>
129 49
       <div>
130 50
 
131 51
         <Avatar src={data.avatar} style={{ width: 94, height: 94 }} />
132
-        <span className={Styles.ediText} style={{ marginLeft: '20px' }} onClick={toEditStaff}>
52
+        <span className={Styles.ediText} style={{ marginLeft: '20px' }} onClick={toEditStaff(data.userId)}>
133 53
           编辑
134 54
                 <Icon type="form" style={{ color: '#C0C4CC', marginLeft: '10px' }} />
135 55
         </span>
@@ -143,29 +63,20 @@ function CartBody (props) {
143 63
 
144 64
         <span>
145 65
           {
146
-            data.labels.map((item, index) => {
147
-              const color = colors[item];
148
-              console.log(color, '------');
149
-              return <Tag className={Styles.cardTag} color={color}>{item}</Tag>
66
+            data.taTagsList.map((item, index) => {
67
+              return <Tag className={Styles.cardTag} color={item.tagColor}>{item.tagName}</Tag>
150 68
             })
151 69
           }
152 70
         </span>
153
-        {/* {
154
-           data.label.map((item, index) => (
155
-              
156
-                <Tag className={Styles.cardTag}>{item}</Tag>
157
-          
158
-            ))
159
-            } */}
160 71
 
161 72
         <p className={Styles.cardText} style={{ width: '300px' }}>
162
-          <span>姓名:{data.name}</span>
73
+          <span>姓名:{data.userName}</span>
163 74
 
164 75
           <span style={{ float: "right" }}>状态:{data.status === '1' ? '启用' : '停用'}</span>
165 76
 
166 77
         </p>
167 78
         <p className={Styles.cardText} style={{ width: '300px' }}>
168
-          <span>电话:{data.tel}</span>
79
+          <span>电话:{data.phone}</span>
169 80
         </p>
170 81
       </div>
171 82
 
@@ -175,29 +86,37 @@ function CartBody (props) {
175 86
 
176 87
 
177 88
 const header = (props) => {
178
-  const [data, setData] = useState({})
179
-  //   const [page, changePage] = useState({})
180
-
181
-  // useEffect(() => {
182
-  //   request({
183
-  //       url: '/api/admin/iBuildingDynamicList',
184
-  //       method: 'GET',
185
-  //       params: {pageNum: 1,pageSize: 10},
186
-  //   }).then((data) => {
187
-  //       console.log(data)
188
-  //       setData(data)
189
-  //   })
190
-  // })
191
-
192
-  // const getList = (e) => {
193
-  //   request({
194
-  //       url: '/api/xxx',
195
-  //       method: 'GET',
196
-  //       params: {},
197
-  //   }).then((data) => {
198
-  //       setData(data)
199
-  //   })
200
-  // }
89
+  const [tempData,setTempData] = useState([])
90
+  useEffect(() => {
91
+    getList({ pageNum: 1, pageSize: 10 });
92
+  },[])
93
+
94
+  const getList = (params) => {
95
+    request({
96
+      url: '/api/admin/taUser',
97
+      method: 'GET',
98
+      params: { ...params },
99
+    }).then((data) => {
100
+        console.log(data,"listData")
101
+        setTempData(data.records)
102
+    })
103
+  }
104
+
105
+  // 分页
106
+  const onChange = (pageNumber) => {
107
+    getList({ pageNum: pageNumber, pageSize: 10 });
108
+  }
109
+
110
+  // 提交事件
111
+const handleSubmit = (e, props) => {
112
+  e.preventDefault();
113
+  props.form.validateFields((err, values) => {
114
+    if (!err) {
115
+      console.log('提交数据: ', values)
116
+      getList({ pageNum: 1, pageSize: 10, ...values })
117
+    }
118
+  });
119
+}
201 120
 
202 121
   const { getFieldDecorator } = props.form
203 122
   return (
@@ -205,7 +124,7 @@ const header = (props) => {
205 124
     <>
206 125
       <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
207 126
         <Form.Item>
208
-          {getFieldDecorator('name')(
127
+          {getFieldDecorator('userName')(
209 128
             <Input
210 129
               prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
211 130
               placeholder="姓名"
@@ -213,7 +132,7 @@ const header = (props) => {
213 132
           )}
214 133
         </Form.Item>
215 134
         <Form.Item>
216
-          {getFieldDecorator('tel')(
135
+          {getFieldDecorator('phone')(
217 136
             <Input
218 137
               prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
219 138
               placeholder="电话"
@@ -223,30 +142,13 @@ const header = (props) => {
223 142
 
224 143
         <Form.Item>
225 144
 
226
-          {getFieldDecorator('goodState')(
227
-            <Select style={{ width: '180px' }} placeholder="状态" onChange={handleSelectChange}>
145
+          {getFieldDecorator('status')(
146
+            <Select style={{ width: '180px' }} placeholder="状态" >
228 147
               <Option value="1">启用</Option>
229 148
               <Option value="0">停用</Option>
230 149
             </Select>,
231 150
           )}
232 151
         </Form.Item>
233
-        <Form.Item>
234
-          {getFieldDecorator('isMain')(
235
-            <Select style={{ width: '180px' }} placeholder="请选择" onChange={handleSelectChange}>
236
-              <Option value="1">职业顾问</Option>
237
-              <Option value="0">其他</Option>
238
-            </Select>,
239
-          )}
240
-        </Form.Item>
241
-        <Form.Item>
242
-          {getFieldDecorator('name')(
243
-            <Input
244
-              prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
245
-              placeholder="标签"
246
-            />,
247
-          )}
248
-        </Form.Item>
249
-
250 152
 
251 153
         <Form.Item>
252 154
           <Button type="primary" htmlType="submit" className={styles.searchBtn}>
@@ -254,7 +156,7 @@ const header = (props) => {
254 156
           </Button>
255 157
         </Form.Item>
256 158
       </Form>
257
-      <Button type="danger" className={styles.addBtn} onClick={toEditStaff}>新增</Button>
159
+      <Button type="danger" className={styles.addBtn} onClick={toEditStaff()}>新增</Button>
258 160
 
259 161
       <Row style={{ padding: ' 0 10px' }}>
260 162
         {
@@ -266,10 +168,9 @@ const header = (props) => {
266 168
         }
267 169
       </Row>
268 170
 
269
-      {/* <Table dataSource={data.records} columns={columns} /> */}
270 171
       {/* 分页  */}
271 172
       <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
272
-        <Pagination showQuickJumper defaultCurrent={1} total={500} onChange={onChange} />
173
+        <Pagination showQuickJumper defaultCurrent={1} total={tempData.total} onChange={onChange} />
273 174
       </div>
274 175
     </>
275 176
   )

+ 107
- 48
src/pages/staff/list/editStaff.jsx Ver fichero

@@ -1,15 +1,18 @@
1
-import React, { useState } from 'react';
1
+import React, { useState, useEffect } from 'react';
2 2
 
3 3
 import { Input, Menu, Dropdown, Button, Icon, message, Table, Tooltip, Tabs, Radio, Divider, Tag, Select, Form, Alert } from 'antd';
4 4
 import { FormattedMessage } from 'umi-plugin-react/locale';
5
+import BuildSelect from '../../../components/SelectButton/BuildSelect'
6
+import router from 'umi/router';
5 7
 import styles from '../../style/GoodsList.less';
6 8
 import XForm, { FieldTypes } from '../../../components/XForm';
7 9
 import Wangedit from '../../../components/Wangedit/Wangedit'
8 10
 import channels from './channelList.less';
9
-
10 11
 import Tagss from '../components/Tagss.jsx';
12
+import request from '../../../utils/request'
11 13
 
12 14
 const { TextArea } = Input;
15
+const { Option } = Select;
13 16
 
14 17
 
15 18
 /**
@@ -19,109 +22,165 @@ const { TextArea } = Input;
19 22
  * @returns
20 23
  */
21 24
 const Edit = (props) => {
25
+  const userId = props.location.query.userId
26
+  const [userData, setUserData] = useState({})
27
+  const [tagData, setTagData] = useState([])
28
+
29
+  console.log(userData,"user----》")
30
+
31
+  const getTagList = () => {
32
+    request({
33
+      url: '/api/admin/taTags',
34
+      method: 'GET',
35
+      params: {pageNum:1,pageSize:999}
36
+    }).then((data) => {
37
+      setTagData(data.records)
38
+    })
39
+  }
40
+
41
+  // 查询列表
42
+  const getUserData = (userId) => {
43
+    request({
44
+      url: '/api/admin/taUser/'+userId,
45
+      method: 'GET',
46
+    }).then((data) => {
47
+      console.log(data,"tauser")
48
+      setUserData(data)
49
+    })
50
+  }
51
+
52
+  useEffect(() => {
53
+    getTagList();
54
+    if (userId) {
55
+      getUserData(userId);
56
+    }
57
+  }, [])
58
+
59
+  const tagsChange = (value) => {
60
+    console.log(`selected ${value}`);
61
+  }
62
+
63
+  const handleSubmit = val => {
64
+    window.console.log('submit data --->', val)
65
+    if(userId){
66
+      request({
67
+        url: '/api/admin/taUser/' + userId,
68
+        method: 'PUT',
69
+        data: val,
70
+      }).then((data) => {
71
+        console.log(data,"tauser")
72
+        message.info("保存成功")
73
+        router.go(-1)
74
+      })
75
+    }else{
76
+      request({
77
+        url: '/api/admin/taUser',
78
+        method: 'POST',
79
+        data: val,
80
+      }).then((data) => {
81
+        console.log(data,"tauser")
82
+        message.info("保存成功")
83
+        router.go(-1)
84
+      })
85
+    }
86
+  }
22 87
 
23 88
   const fields = [
24 89
     {
25 90
       label: '名称',
26
-      name: 'staffName',
91
+      name: 'userName',
27 92
       type: FieldTypes.Text,
28
-      // placeholder: '名称',
29
-      value: ''
93
+      value: userData.userName
30 94
     },
31 95
     {
32 96
       label: '公司',
33
-      name: 'staffCompany',
97
+      name: 'orgName',
34 98
       type: FieldTypes.Text,
35 99
       placeholder: '请输入公司名称',
36
-      value: ''
100
+      value: userData.orgName
37 101
     },
38 102
     {
39 103
       label: '部门',
40
-      name: 'staffDepartment',
104
+      name: 'department',
41 105
       type: FieldTypes.Text,
42 106
       placeholder: '请输入部门',
43
-      value: ''
107
+      value: userData.department
44 108
     },
45 109
     {
46 110
       label: '职位',
47
-      name: 'staffPosition',
111
+      name: 'position',
48 112
       type: FieldTypes.Text,
49 113
       placeholder: '请输入职位',
50
-      value: ''
114
+      value: userData.position
51 115
     },
52 116
     {
53 117
       label: '电话',
54
-      name: 'staffTel',
118
+      name: 'phone',
55 119
       type: FieldTypes.Text,
56 120
       placeholder: '请输入电话号码',
57
-      value: ''
58
-      // rules: [
59
-      //   { message: '请输入电话号码'}
60
-      // ]
121
+      value: userData.phone,
61 122
     },
62 123
     {
63 124
       label: '标签',
64
-      name: 'staffTag',
65
-      render: 
66
-      <Tagss/>
67
-     
68
-   
125
+      name: 'taTags',
126
+      render: <Select
127
+                mode="multiple"
128
+                style={{ width: '100%' }}
129
+                placeholder="请选择标签"
130
+                onChange={tagsChange} >
131
+                  {tagData.map(item => (
132
+                    <Select.Option key={item.tagId} value={item.tagId}>
133
+                      {item.tagName}
134
+                    </Select.Option>
135
+                  ))}
136
+              </Select>,
137
+      value: userData.taTags,
69 138
     },
70 139
     {
71 140
       label: '地址',
72
-      name: 'staffAddress',
141
+      name: 'address',
73 142
       type: FieldTypes.Text,
74 143
       placeholder: '请输入地址',
75
-      value: ''
144
+      value: userData.address
76 145
 
77 146
     },
78 147
     {
79 148
       label: '授权项目',
80
-      name: 'staffProject',
81
-      type: FieldTypes.Select,
82
-      placeholder: '请选择',
83
-      value: ''
149
+      name: 'buildingId',
150
+      render: <BuildSelect />,
151
+      value: userData.buildingId,
152
+      rules: [
153
+        { required: true, message: '请选择所属项目' },
154
+      ],
84 155
     },
85
-
86
-    // {
87
-    //   label: '授权项目',
88
-    //   name: 'staffProject',
89
-    //   type: FieldTypes.Text,
90
-    //   placeholder: '请选择'
91
-    // },
92
-
93 156
     {
94 157
       label: '图片',
95
-      name: 'staffImage',
158
+      name: 'photo',
96 159
       type: FieldTypes.ImageUploader,
97 160
       extra: '建议图片大小 640 * 640',
98
-      value: ''
161
+      value: userData.photo
99 162
     },
100 163
 
101 164
 
102 165
     {
103 166
       label: '简介',
104
-      name: 'staffIntroduction',
167
+      name: 'description',
105 168
       render: <TextArea className={channels.inpuitTxt} ></TextArea>,
106
-      value: ''
169
+      value: userData.description
107 170
 
108 171
     },
109 172
     {
110 173
       label: '状态',
111
-      name: 'staffstate',
174
+      name: 'status',
112 175
       render: <Radio.Group>
113
-        <Radio.Button style={{background:'#f0f0f0'}} value="a">禁用</Radio.Button>
114
-        <Radio.Button style={{background:'#f0f0f0',color:'#ff7e48'}} value="b">启用</Radio.Button>
176
+        <Radio.Button style={{background:'#f0f0f0'}} value="0">禁用</Radio.Button>
177
+        <Radio.Button style={{background:'#f0f0f0',color:'#ff7e48'}} value="1">启用</Radio.Button>
115 178
       </Radio.Group>,
116
-      value: 'b'
179
+      value: null != userData.status ? userData.status : '1'
117 180
     },
118
-
119 181
   ]
120 182
 
121
-  const handleSubmit = val => {
122
-    window.console.log('submit data --->', val)
123
-  }
124
-  return <XForm onSubmit={handleSubmit} fields={fields} push={8}></XForm>
183
+  return <XForm onSubmit={handleSubmit} fields={fields}></XForm>
125 184
 
126 185
 
127 186