Browse Source

编辑项目-项目类型

魏熙美 5 years ago
parent
commit
36cb5ebfd0

+ 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/global.less View File

79
 .ant-menu-vertical-left .ant-menu-submenu-title,
79
 .ant-menu-vertical-left .ant-menu-submenu-title,
80
 .ant-menu-vertical-right .ant-menu-submenu-title,
80
 .ant-menu-vertical-right .ant-menu-submenu-title,
81
 .ant-menu-inline .ant-menu-submenu-title,
81
 .ant-menu-inline .ant-menu-submenu-title,
82
-.ant-input ,.ant-btn{
82
+.ant-input ,.ant-btn,.ant-select,.ant-table {
83
   font-size: 16px;
83
   font-size: 16px;
84
 }
84
 }
85
 .ant-breadcrumb{
85
 .ant-breadcrumb{

+ 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
- 1
src/pages/building/list/add/components/base.jsx View File

105
           <Form.Item label="均价" hasFeedback>
105
           <Form.Item label="均价" hasFeedback>
106
             {getFieldDecorator('price')(<Input />)}
106
             {getFieldDecorator('price')(<Input />)}
107
           </Form.Item>
107
           </Form.Item>
108
-          <Form.Item label="开盘时间" hasFeedback>
108
+          <Form.Item label="开盘时间"  hasFeedback>
109
             {getFieldDecorator('openingDate')(<DatePicker format="YYYY/MM/DD" />)}
109
             {getFieldDecorator('openingDate')(<DatePicker format="YYYY/MM/DD" />)}
110
           </Form.Item>
110
           </Form.Item>
111
           <Form.Item label="电话" hasFeedback>
111
           <Form.Item label="电话" hasFeedback>

+ 4
- 4
src/pages/building/type/index.jsx View File

20
       title: '类型名称',
20
       title: '类型名称',
21
       dataIndex: 'buildingTypeName',
21
       dataIndex: 'buildingTypeName',
22
       key: 'buildingTypeName',
22
       key: 'buildingTypeName',
23
-      render: (_, record) => <Tag color="blue" onClick={() => toEdi(record.buildingTypeId)}>{ record.buildingTypeName }</Tag>,
23
+      render: (_, record) => <Tag color="blue" onClick={() => toEdi(record.buildingTypeId)}>{record.buildingTypeName}</Tag>,
24
     },
24
     },
25
     {
25
     {
26
       title: '创建时间',
26
       title: '创建时间',
35
       render: (_, record) => (
35
       render: (_, record) => (
36
         <span onClick={() => deleteType(record)}>
36
         <span onClick={() => deleteType(record)}>
37
           <span style={{
37
           <span style={{
38
-              color: '#FF4A4A', right: '0',
38
+            color: '#FF4A4A', right: '0',
39
           }} >
39
           }} >
40
-              删除
40
+            删除
41
           <Icon type="rest" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
41
           <Icon type="rest" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
42
           </span>
42
           </span>
43
         </span>
43
         </span>
97
   return (
97
   return (
98
     <>
98
     <>
99
       <Button type="danger" onClick={() => toEdi()}>新增类型</Button>
99
       <Button type="danger" onClick={() => toEdi()}>新增类型</Button>
100
-      <Table style={{marginTop:'30px'}} dataSource={data.records} columns={columns} pagination={false}/>
100
+      <Table style={{ marginTop: '30px' }} dataSource={data.records} columns={columns} pagination={false} />
101
       {/* 分页 */}
101
       {/* 分页 */}
102
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
102
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
103
         <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={onChange} />
103
         <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={onChange} />

+ 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: {

+ 1
- 1
src/utils/mixStr.js View File

12
   return str.repeat(Math.floor(len / orginLen)) + str.substr(0, len % orginLen)
12
   return str.repeat(Math.floor(len / orginLen)) + str.substr(0, len % orginLen)
13
 }
13
 }
14
 
14
 
15
-const mixChars = window.navigator.userAgent + (new Date).toUTCString().replace(/\d{2}:\d{2}:\d{2}/, '')
15
+const mixChars = window.navigator.userAgent // + (new Date).toUTCString().replace(/\d{2}:\d{2}:\d{2}/, '')
16
 
16
 
17
 const strXOR = (str, mix) => {
17
 const strXOR = (str, mix) => {
18
   if (!str) return str
18
   if (!str) return str

+ 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,