Преглед на файлове

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

许静 преди 5 години
родител
ревизия
ad869ef92d

+ 1
- 1
config/config.js Целия файл

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

+ 15
- 2
src/components/SelectButton/BuildSelect.jsx Целия файл

@@ -1,10 +1,18 @@
1
-import React, { useState, useEffect } from 'react';
1
+import React, { useState, useEffect, useRef } from 'react';
2 2
 import { Select } from 'antd';
3 3
 
4 4
 import request from '../../utils/request'
5 5
 
6 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,7 +21,12 @@ const { Option } = Select;
13 21
  */
14 22
 const BuildingSelect = (props) => {
15 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 31
   useEffect(() => {
19 32
     getCityList();

+ 1
- 1
src/models/login.js Целия файл

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

+ 1
- 0
src/pages/building/list/add/components/base.jsx Целия файл

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

+ 18
- 35
src/pages/building/list/add/components/buildingProjectType.jsx Целия файл

@@ -119,10 +119,7 @@ class ProjectTypeBody extends React.Component {
119 119
   }
120 120
 
121 121
   onSuccess = (values, item) => {
122
-    console.log('values: ', values)
123
-    console.log('data: ', this.state.data, 'item: ', item)
124 122
     const newData = this.getNewProjectType(values)
125
-    console.log('newData: ', newData)
126 123
     this.setState({ data: newData })
127 124
     if (typeof this.props.onChange === 'function') {
128 125
       this.props.onChange(newData)
@@ -130,14 +127,13 @@ class ProjectTypeBody extends React.Component {
130 127
   }
131 128
 
132 129
   onCheckboxChange = checkedValues => {
130
+      // console.log('checkedValues: ', checkedValues)
133 131
       const checked = (`${checkedValues}` || '').split(',')
134 132
       const { projectType } = this.state
135 133
       const buildingType = projectType.filter(item => checked.includes(`${item.buildingTypeId}`))
136 134
 
137
-      // 这里会把值替换掉
138
-
139 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 137
       console.log('updateProjectDate: ', updateProjectDate)
142 138
       this.setState({ data: updateProjectDate })
143 139
   }
@@ -145,7 +141,6 @@ class ProjectTypeBody extends React.Component {
145 141
   onClose = e => {
146 142
     const { data } = this.state
147 143
     const buildingType = data.filter(item => e.buildingTypeId !== item.buildingTypeId)
148
-    console.log('buildingType: ', buildingType)
149 144
     this.setState({ data: buildingType })
150 145
     this.setState({ defaultCheckboxValue: buildingType.map(item => item.buildingTypeId) })
151 146
   }
@@ -153,7 +148,6 @@ class ProjectTypeBody extends React.Component {
153 148
   getNewProjectType = values => {
154 149
     const data = []
155 150
     this.state.data.map(item => {
156
-      console.log('item: ', item)
157 151
       if (item.buildingTypeId === values.buildingTypeId) {
158 152
         data.push(values)
159 153
       } else {
@@ -165,18 +159,22 @@ class ProjectTypeBody extends React.Component {
165 159
   }
166 160
 
167 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 180
   getList = params => {
@@ -196,11 +194,7 @@ class ProjectTypeBody extends React.Component {
196 194
       tempData = value
197 195
       tempCheckboxValue = tempData.map(item => item.buildingTypeId)
198 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,17 +223,6 @@ class ProjectTypeBody extends React.Component {
229 223
   }
230 224
 
231 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 226
     return (
244 227
       <>
245 228
         <Button type="primary" icon="plus" size="large" onClick={() => this.showMadel()} />

+ 3
- 11
src/pages/staff/list/editStaff.jsx Целия файл

@@ -26,8 +26,6 @@ const Edit = (props) => {
26 26
   const [userData, setUserData] = useState({})
27 27
   const [tagData, setTagData] = useState([])
28 28
 
29
-  console.log(userData,"user----》")
30
-
31 29
   const getTagList = () => {
32 30
     request({
33 31
       url: '/api/admin/taTags',
@@ -61,7 +59,6 @@ const Edit = (props) => {
61 59
   }
62 60
 
63 61
   const handleSubmit = val => {
64
-    window.console.log('submit data --->', val)
65 62
     if(userId){
66 63
       request({
67 64
         url: '/api/admin/taUser/' + userId,
@@ -148,10 +145,7 @@ const Edit = (props) => {
148 145
       label: '授权项目',
149 146
       name: 'buildingId',
150 147
       render: <BuildSelect />,
151
-      value: userData.buildingId,
152
-      rules: [
153
-        { required: true, message: '请选择所属项目' },
154
-      ],
148
+      value: userData.buildingId
155 149
     },
156 150
     {
157 151
       label: '图片',
@@ -180,11 +174,9 @@ const Edit = (props) => {
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 Целия файл

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

+ 4
- 3
src/utils/request.js Целия файл

@@ -33,15 +33,16 @@ const replaceURLParams = (url, params = {}) => {
33 33
 }
34 34
 
35 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 37
   const apiURL = urlData ? replaceURLParams(url, urlData) : url
38 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 41
     window.localStorage.removeItem('test-foobar')
43 42
   }
44 43
 
44
+  const authHeader = !login ? { Authorization: `Bearer ${token}` } : {}
45
+
45 46
   return (
46 47
     {
47 48
       url: apiURL,