Browse Source

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

许静 5 years ago
parent
commit
ad869ef92d

+ 1
- 1
config/config.js View File

479
 
479
 
480
   proxy: {
480
   proxy: {
481
     '/api/': {
481
     '/api/': {
482
-      target: 'http://192.168.0.84:8080/',
482
+      target: 'http://localhost:8080/',
483
       changeOrigin: true,
483
       changeOrigin: true,
484
       // pathRewrite: { '^/server': '' },
484
       // pathRewrite: { '^/server': '' },
485
     },
485
     },

+ 15
- 2
src/components/SelectButton/BuildSelect.jsx View File

1
-import React, { useState, useEffect } from 'react';
1
+import React, { useState, useEffect, useRef } from 'react';
2
 import { Select } from 'antd';
2
 import { Select } from 'antd';
3
 
3
 
4
 import request from '../../utils/request'
4
 import request from '../../utils/request'
5
 
5
 
6
 const { Option } = Select;
6
 const { Option } = Select;
7
 
7
 
8
+function usePrevious(props) {
9
+  const ref = useRef();
10
+  useEffect(() => {
11
+    ref.current = props;
12
+  });
13
+  return ref.current;
14
+}
15
+
8
 /**
16
 /**
9
  *
17
  *
10
  *
18
  *
13
  */
21
  */
14
 const BuildingSelect = (props) => {
22
 const BuildingSelect = (props) => {
15
   const [ data, setData ] = useState([])
23
   const [ data, setData ] = useState([])
16
-  const [ value, setValue ] = useState(props.value)
24
+  const [ value, setValue ] = useState('')
25
+  const preProps = usePrevious(props)
26
+  
27
+  if ((!preProps || !preProps.value) && props.value && !value) {
28
+    setValue(props.value)
29
+  }
17
 
30
 
18
   useEffect(() => {
31
   useEffect(() => {
19
     getCityList();
32
     getCityList();

+ 1
- 1
src/models/login.js View File

50
     *logout(_, { put, call }) {
50
     *logout(_, { put, call }) {
51
       const { redirect } = getPageQuery(); // redirect
51
       const { redirect } = getPageQuery(); // redirect
52
 
52
 
53
-      yield call(signout, { logout: true });
53
+      yield call(signout);
54
 
54
 
55
       if (window.location.pathname !== '/user/login' && !redirect) {
55
       if (window.location.pathname !== '/user/login' && !redirect) {
56
         yield put(
56
         yield put(

+ 1
- 0
src/pages/building/list/add/components/base.jsx View File

79
     const api = data.buildingId === undefined ? apis.building.addBuilding : apis.building.updateBuilding
79
     const api = data.buildingId === undefined ? apis.building.addBuilding : apis.building.updateBuilding
80
     request({ ...api, data: { ...data } }).then(() => {
80
     request({ ...api, data: { ...data } }).then(() => {
81
       openNotificationWithIcon('success', '操作成功')
81
       openNotificationWithIcon('success', '操作成功')
82
+      router.go(-1)
82
     }).catch(err => {
83
     }).catch(err => {
83
       openNotificationWithIcon('error', err.message)
84
       openNotificationWithIcon('error', err.message)
84
     })
85
     })

+ 18
- 35
src/pages/building/list/add/components/buildingProjectType.jsx View File

119
   }
119
   }
120
 
120
 
121
   onSuccess = (values, item) => {
121
   onSuccess = (values, item) => {
122
-    console.log('values: ', values)
123
-    console.log('data: ', this.state.data, 'item: ', item)
124
     const newData = this.getNewProjectType(values)
122
     const newData = this.getNewProjectType(values)
125
-    console.log('newData: ', newData)
126
     this.setState({ data: newData })
123
     this.setState({ data: newData })
127
     if (typeof this.props.onChange === 'function') {
124
     if (typeof this.props.onChange === 'function') {
128
       this.props.onChange(newData)
125
       this.props.onChange(newData)
130
   }
127
   }
131
 
128
 
132
   onCheckboxChange = checkedValues => {
129
   onCheckboxChange = checkedValues => {
130
+      // console.log('checkedValues: ', checkedValues)
133
       const checked = (`${checkedValues}` || '').split(',')
131
       const checked = (`${checkedValues}` || '').split(',')
134
       const { projectType } = this.state
132
       const { projectType } = this.state
135
       const buildingType = projectType.filter(item => checked.includes(`${item.buildingTypeId}`))
133
       const buildingType = projectType.filter(item => checked.includes(`${item.buildingTypeId}`))
136
 
134
 
137
-      // 这里会把值替换掉
138
-
139
       const tempDate = buildingType.map(item => ({ buildingTypeId: item.buildingTypeId, buildingTypeName: item.buildingTypeName, price: '', decoration: '', rightsYear: '', status: '1' }))
135
       const tempDate = buildingType.map(item => ({ buildingTypeId: item.buildingTypeId, buildingTypeName: item.buildingTypeName, price: '', decoration: '', rightsYear: '', status: '1' }))
140
-      const updateProjectDate = this.updateProjectType(checkedValues)
136
+      const updateProjectDate = this.updateProjectType(tempDate)
141
       console.log('updateProjectDate: ', updateProjectDate)
137
       console.log('updateProjectDate: ', updateProjectDate)
142
       this.setState({ data: updateProjectDate })
138
       this.setState({ data: updateProjectDate })
143
   }
139
   }
145
   onClose = e => {
141
   onClose = e => {
146
     const { data } = this.state
142
     const { data } = this.state
147
     const buildingType = data.filter(item => e.buildingTypeId !== item.buildingTypeId)
143
     const buildingType = data.filter(item => e.buildingTypeId !== item.buildingTypeId)
148
-    console.log('buildingType: ', buildingType)
149
     this.setState({ data: buildingType })
144
     this.setState({ data: buildingType })
150
     this.setState({ defaultCheckboxValue: buildingType.map(item => item.buildingTypeId) })
145
     this.setState({ defaultCheckboxValue: buildingType.map(item => item.buildingTypeId) })
151
   }
146
   }
153
   getNewProjectType = values => {
148
   getNewProjectType = values => {
154
     const data = []
149
     const data = []
155
     this.state.data.map(item => {
150
     this.state.data.map(item => {
156
-      console.log('item: ', item)
157
       if (item.buildingTypeId === values.buildingTypeId) {
151
       if (item.buildingTypeId === values.buildingTypeId) {
158
         data.push(values)
152
         data.push(values)
159
       } else {
153
       } else {
165
   }
159
   }
166
 
160
 
167
   updateProjectType = values => {
161
   updateProjectType = values => {
168
-    const data = []
169
-    this.state.data.map(item => {
170
-      values.map(va => {
171
-        if (item.buildingTypeId === va.buildingTypeId) {
172
-          data.push(va)
173
-        } else {
174
-          data.push(item)
175
-        }
176
-      })
177
-    })
162
+    // 获取所有复选框选中的id
163
+    const valueIdArray = values.map(item => item.buildingTypeId)
164
+    // console.log('valueIdArray: ', valueIdArray)
178
 
165
 
179
-    return data
166
+    // 获取 data 中已经赋值的数据  交集
167
+    const valueData = this.state.data.filter(item => valueIdArray.includes(item.buildingTypeId))
168
+    // console.log('valueData: ', valueData)
169
+
170
+    // 获取 非 data中数据(也就是没有赋值),交集
171
+    const trueValueArr = valueData.map(item => item.buildingTypeId)
172
+    const trueValueData = values.filter(item => !trueValueArr.includes(item.buildingTypeId))
173
+
174
+    // console.log('trueValueData: ', trueValueData)
175
+
176
+    // 把两个 数组的值,合并返回
177
+    return valueData.concat(trueValueData)
180
   }
178
   }
181
 
179
 
182
   getList = params => {
180
   getList = params => {
196
       tempData = value
194
       tempData = value
197
       tempCheckboxValue = tempData.map(item => item.buildingTypeId)
195
       tempCheckboxValue = tempData.map(item => item.buildingTypeId)
198
       this.setState({ defaultCheckboxValue: tempCheckboxValue })
196
       this.setState({ defaultCheckboxValue: tempCheckboxValue })
199
-      this.setState({ data: tempData }, () => {
200
-        console.log("state: ", this.state.data)
201
-      })
202
-
203
-      console.log("tempData: ", tempData, "tempCheckboxValue: ", tempCheckboxValue, "value: ", value)
197
+      this.setState({ data: tempData })
204
     }
198
     }
205
   }
199
   }
206
 
200
 
229
   }
223
   }
230
 
224
 
231
   render () {
225
   render () {
232
-
233
-    // let tempData = []
234
-    // let tempCheckboxValue = []
235
-    // const { value } = this.props
236
-    // if (value !== undefined && value !== null) {
237
-    //   tempData = value
238
-    // } else {
239
-    //   tempData = this.state.data
240
-    // }
241
-
242
-    // tempCheckboxValue = tempData.map(item => item.buildingTypeId)
243
     return (
226
     return (
244
       <>
227
       <>
245
         <Button type="primary" icon="plus" size="large" onClick={() => this.showMadel()} />
228
         <Button type="primary" icon="plus" size="large" onClick={() => this.showMadel()} />

+ 3
- 11
src/pages/staff/list/editStaff.jsx View File

26
   const [userData, setUserData] = useState({})
26
   const [userData, setUserData] = useState({})
27
   const [tagData, setTagData] = useState([])
27
   const [tagData, setTagData] = useState([])
28
 
28
 
29
-  console.log(userData,"user----》")
30
-
31
   const getTagList = () => {
29
   const getTagList = () => {
32
     request({
30
     request({
33
       url: '/api/admin/taTags',
31
       url: '/api/admin/taTags',
61
   }
59
   }
62
 
60
 
63
   const handleSubmit = val => {
61
   const handleSubmit = val => {
64
-    window.console.log('submit data --->', val)
65
     if(userId){
62
     if(userId){
66
       request({
63
       request({
67
         url: '/api/admin/taUser/' + userId,
64
         url: '/api/admin/taUser/' + userId,
148
       label: '授权项目',
145
       label: '授权项目',
149
       name: 'buildingId',
146
       name: 'buildingId',
150
       render: <BuildSelect />,
147
       render: <BuildSelect />,
151
-      value: userData.buildingId,
152
-      rules: [
153
-        { required: true, message: '请选择所属项目' },
154
-      ],
148
+      value: userData.buildingId
155
     },
149
     },
156
     {
150
     {
157
       label: '图片',
151
       label: '图片',
180
     },
174
     },
181
   ]
175
   ]
182
 
176
 
183
-  return <XForm onSubmit={handleSubmit} fields={fields}></XForm>
184
-
185
-
186
-
177
+  console.log('--------->', fields)
187
 
178
 
179
+  return <XForm onSubmit={handleSubmit} fields={fields}></XForm>
188
 }
180
 }
189
 
181
 
190
 
182
 

+ 2
- 0
src/services/apis.js View File

19
     signin: {
19
     signin: {
20
       method: 'POST',
20
       method: 'POST',
21
       url: `${prefix}/taUser/signin`,
21
       url: `${prefix}/taUser/signin`,
22
+      login: true
22
     },
23
     },
23
     signout: {
24
     signout: {
24
       method: 'POST',
25
       method: 'POST',
25
       url: `${prefix}/taUser/signout`,
26
       url: `${prefix}/taUser/signout`,
27
+      logout: true
26
     },
28
     },
27
   },
29
   },
28
   building: {
30
   building: {

+ 4
- 3
src/utils/request.js View File

33
 }
33
 }
34
 
34
 
35
 request.interceptors.request.use((url, options) => {
35
 request.interceptors.request.use((url, options) => {
36
-  const { urlData, headers = {}, logout = false, data, ...opts } = options
36
+  const { urlData, headers = {}, logout = false, login = false, data, ...opts } = options
37
   const apiURL = urlData ? replaceURLParams(url, urlData) : url
37
   const apiURL = urlData ? replaceURLParams(url, urlData) : url
38
   const token = mixStr(window.localStorage.getItem('test-foobar'))
38
   const token = mixStr(window.localStorage.getItem('test-foobar'))
39
-  const authHeader = token ? { Authorization: `Bearer ${token}` } : {}
40
 
39
 
41
-  if (logout) {
40
+  if (login || logout) {
42
     window.localStorage.removeItem('test-foobar')
41
     window.localStorage.removeItem('test-foobar')
43
   }
42
   }
44
 
43
 
44
+  const authHeader = !login ? { Authorization: `Bearer ${token}` } : {}
45
+
45
   return (
46
   return (
46
     {
47
     {
47
       url: apiURL,
48
       url: apiURL,