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

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

傅行帆 преди 5 години
родител
ревизия
1730a2a1cd

+ 18
- 0
src/app.js Целия файл

@@ -1,3 +1,21 @@
1
+// (function (doc, win) {
2
+//   var docEl = doc.documentElement,
3
+//     resizeEvt = 'onorientationchange' in window ? 'onorientationchange' : 'resize',
4
+//     recalc = function () {
5
+//       var clientWidth = docEl.clientWidth;
6
+//       if (!clientWidth) return;
7
+//       if (clientWidth >= 750) {
8
+//         docEl.style.fontSize = '100px';
9
+//       } else {
10
+//         docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
11
+//       }
12
+//     };
13
+
14
+//   if (!doc.addEventListener) return;
15
+//   win.addEventListener(resizeEvt, recalc, false);
16
+//   doc.addEventListener('DOMContentLoaded', recalc, false);
17
+// })(document, window);
18
+
1 19
 export const dva = {
2 20
   config: {
3 21
     onError(e) {

+ 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/global.less Целия файл

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

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

+ 2
- 1
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
     })
@@ -104,7 +105,7 @@ function AddBuilding(props) {
104 105
           <Form.Item label="均价" hasFeedback>
105 106
             {getFieldDecorator('price')(<Input />)}
106 107
           </Form.Item>
107
-          <Form.Item label="开盘时间" hasFeedback>
108
+          <Form.Item label="开盘时间"  hasFeedback>
108 109
             {getFieldDecorator('openingDate')(<DatePicker format="YYYY/MM/DD" />)}
109 110
           </Form.Item>
110 111
           <Form.Item label="电话" hasFeedback>

+ 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()} />

+ 4
- 4
src/pages/building/type/index.jsx Целия файл

@@ -20,7 +20,7 @@ function body() {
20 20
       title: '类型名称',
21 21
       dataIndex: 'buildingTypeName',
22 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 26
       title: '创建时间',
@@ -35,9 +35,9 @@ function body() {
35 35
       render: (_, record) => (
36 36
         <span onClick={() => deleteType(record)}>
37 37
           <span style={{
38
-              color: '#FF4A4A', right: '0',
38
+            color: '#FF4A4A', right: '0',
39 39
           }} >
40
-              删除
40
+            删除
41 41
           <Icon type="rest" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
42 42
           </span>
43 43
         </span>
@@ -97,7 +97,7 @@ function body() {
97 97
   return (
98 98
     <>
99 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 102
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
103 103
         <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={onChange} />

+ 31
- 31
src/pages/staff/list/StaffList.jsx Целия файл

@@ -29,16 +29,16 @@ const toEditStaff = (userId) => () => {
29 29
  */
30 30
 const CartBody = (props) => {
31 31
   const { data } = props
32
-    
32
+
33 33
   const confirm = () => {
34 34
     Modal.confirm({
35 35
       title: '确认停用该角色?',
36 36
       okText: '确认',
37 37
       cancelText: '取消',
38
-      onOk () {
38
+      onOk() {
39 39
         console.log('OK');
40 40
       },
41
-      onCancel () {
41
+      onCancel() {
42 42
         console.log('Cancel');
43 43
       },
44 44
     });
@@ -49,14 +49,18 @@ const CartBody = (props) => {
49 49
       <div>
50 50
 
51 51
         <Avatar src={data.avatar} style={{ width: 94, height: 94 }} />
52
-        <span className={Styles.ediText} style={{ marginLeft: '20px' }} onClick={toEditStaff(data.userId)}>
52
+        <Button type="link" style={{ marginLeft: '10px', color: '#FF925C', fontSize: '18px' }} onClick={toEditStaff(data.userId)}>
53 53
           编辑
54
-                <Icon type="form" style={{ color: '#C0C4CC', marginLeft: '10px' }} />
55
-        </span>
56
-        <span className={Styles.ediText} style={{ marginLeft: '50px' }} onClick={confirm}>
54
+                <Icon type="form" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
55
+        </Button>
56
+        <Button type="link" style={{ fontSize: '18px', color: '#cacaca', position: 'absolute', top: '50px', right: '0' }} onClick={confirm}>
57 57
           停用
58
-                <Icon type="close-circle" style={{ color: '#C0C4CC', marginLeft: '10px' }} />
59
-        </span>
58
+                <Icon type="close-circle" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
59
+        </Button>
60
+        <Button type="link" style={{ fontSize: '18px', color: '#FF925C', position: 'absolute', top: '50px', right: '0' }} onClick={confirm}>
61
+          启用
62
+                <Icon type="form" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
63
+        </Button>
60 64
 
61 65
       </div>
62 66
       <div>
@@ -69,14 +73,11 @@ const CartBody = (props) => {
69 73
           }
70 74
         </span>
71 75
 
72
-        <p className={Styles.cardText} style={{ width: '300px' }}>
73
-          <span>姓名:{data.userName}</span>
74
-
75
-          <span style={{ float: "right" }}>状态:{data.status === '1' ? '启用' : '停用'}</span>
76
-
76
+        <p className={Styles.cardText} >姓名:{data.userName}
77 77
         </p>
78
-        <p className={Styles.cardText} style={{ width: '300px' }}>
79
-          <span>电话:{data.phone}</span>
78
+        <p className={Styles.statusText} > 状态:{data.status === '1' ? '启用' : '停用'} </p>
79
+        <p className={Styles.phoneText} >
80
+          电话:{data.phone}
80 81
         </p>
81 82
       </div>
82 83
 
@@ -86,10 +87,10 @@ const CartBody = (props) => {
86 87
 
87 88
 
88 89
 const header = (props) => {
89
-  const [tempData,setTempData] = useState([])
90
+  const [tempData, setTempData] = useState([])
90 91
   useEffect(() => {
91 92
     getList({ pageNum: 1, pageSize: 10 });
92
-  },[])
93
+  }, [])
93 94
 
94 95
   const getList = (params) => {
95 96
     request({
@@ -97,8 +98,8 @@ const header = (props) => {
97 98
       method: 'GET',
98 99
       params: { ...params },
99 100
     }).then((data) => {
100
-        console.log(data,"listData")
101
-        setTempData(data.records)
101
+      console.log(data, "listData")
102
+      setTempData(data.records)
102 103
     })
103 104
   }
104 105
 
@@ -108,15 +109,15 @@ const header = (props) => {
108 109
   }
109 110
 
110 111
   // 提交事件
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
-}
112
+  const handleSubmit = (e, props) => {
113
+    e.preventDefault();
114
+    props.form.validateFields((err, values) => {
115
+      if (!err) {
116
+        console.log('提交数据: ', values)
117
+        getList({ pageNum: 1, pageSize: 10, ...values })
118
+      }
119
+    });
120
+  }
120 121
 
121 122
   const { getFieldDecorator } = props.form
122 123
   return (
@@ -156,8 +157,7 @@ const handleSubmit = (e, props) => {
156 157
           </Button>
157 158
         </Form.Item>
158 159
       </Form>
159
-      <Button type="danger" className={styles.addBtn} onClick={toEditStaff()}>新增</Button>
160
-
160
+      <Button type="danger" style={{ margin: '20px 0', padding: '2px 36px' }} onClick={toEditStaff()}>新增</Button>
161 161
       <Row style={{ padding: ' 0 10px' }}>
162 162
         {
163 163
           tempData.map((item, index) => (

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

@@ -59,7 +59,6 @@ const Edit = (props) => {
59 59
   }
60 60
 
61 61
   const handleSubmit = val => {
62
-    window.console.log('submit data --->', val)
63 62
     if(userId){
64 63
       request({
65 64
         url: '/api/admin/taUser/' + userId,
@@ -146,10 +145,7 @@ const Edit = (props) => {
146 145
       label: '授权项目',
147 146
       name: 'buildingId',
148 147
       render: <BuildSelect />,
149
-      value: userData.buildingId,
150
-      rules: [
151
-        { required: true, message: '请选择所属项目' },
152
-      ],
148
+      value: userData.buildingId
153 149
     },
154 150
     {
155 151
       label: '图片',
@@ -178,11 +174,9 @@ const Edit = (props) => {
178 174
     },
179 175
   ]
180 176
 
181
-  return <XForm onSubmit={handleSubmit} fields={fields}></XForm>
182
-
183
-
184
-
177
+  console.log('--------->', fields)
185 178
 
179
+  return <XForm onSubmit={handleSubmit} fields={fields}></XForm>
186 180
 }
187 181
 
188 182
 

+ 22
- 30
src/pages/staff/list/style.less Целия файл

@@ -11,33 +11,37 @@
11 11
   border: 1px solid #dbdbdb;
12 12
 }
13 13
 
14
-.addButton {
15
-  // background: #50be00;
16
-  border-radius: 4px;
17
-  border: 0px;
18
-  margin: 10px 0px;
19
-}
20 14
 
21 15
 .card {
22
-  width: 348px;
16
+  min-width: 330px;
17
+  margin-right: 2vw;
23 18
   height: 244px;
24 19
   background: rgba(255, 255, 255, 1);
25 20
   box-shadow: 0px 0px 16px 2px rgba(0, 0, 0, 0.12);
26 21
   border-radius: 12px;
27 22
   margin-bottom: 40px;
28
-
23
+  position: relative;
29 24
 }
30 25
 
31
-.cardText {
32 26
 
33
-  height: 28px;
27
+.cardText {
34 28
   font-size: 20px;
35
-  font-weight: 400;
36 29
   color: rgba(102, 102, 102, 1);
37
-  line-height: 28px;
38
-  margin-top: 10px;
39
-  margin-bottom: 0;
40
-
30
+  position: absolute;
31
+  bottom:36px;
32
+}
33
+.statusText {
34
+  font-size: 20px;
35
+  color: rgba(102, 102, 102, 1);
36
+  position: absolute;
37
+  bottom:36px;
38
+  right: 20px;
39
+}
40
+.phoneText{
41
+  font-size: 20px;
42
+  color: rgba(102, 102, 102, 1);
43
+  position: absolute;
44
+  bottom:0px;
41 45
 }
42 46
 
43 47
 .cardItem {
@@ -49,26 +53,15 @@
49 53
   align-items: center;
50 54
 }
51 55
 
52
-.ediText {
53
-  width: 36px;
54
-  height: 25px;
55
-  font-size: 18px;
56
-
57
-  font-weight: 400;
58
-  color: rgba(255, 146, 92, 1);
59
-  line-height: 25px;
60
-
61
-}
62 56
 
63 57
 .cardTag {
64
-  height: 18px;
65 58
   font-size: 10px;
66
-  // background: #fdce22;
67 59
   border-radius: 4px;
68 60
   color: #ffffff;
69
-  line-height: 14px;
61
+  line-height: 16px;
70 62
   margin-top: 10px;
71 63
   padding: 1px 3px;
64
+
72 65
 }
73 66
 
74 67
 .title {
@@ -76,13 +69,12 @@
76 69
   width: 84px;
77 70
   justify-content: space-between;
78 71
   text-align: justify;
79
-  text-align-last: justify
72
+  text-align-last: justify;
80 73
 }
81 74
 
82 75
 
83 76
 .roletext {
84 77
   font-size: 20px;
85
-
86 78
   font-weight: 400;
87 79
   color: rgba(51, 51, 51, 1);
88 80
   line-height: 28px;

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

+ 1
- 1
src/utils/mixStr.js Целия файл

@@ -12,7 +12,7 @@ const fill2Len = (str, len) => {
12 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 17
 const strXOR = (str, mix) => {
18 18
   if (!str) return str

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