|
|
@@ -9,16 +9,17 @@ import {List, Skeleton} from 'antd'
|
|
|
import PhonesItem from "../../components/PhonesItem";
|
|
|
import 'css/phones.css'
|
|
|
import {getStrValue, isObjEmpty} from "../../utils/common";
|
|
|
-import {fetchGet} from "../../utils/fetchRequest";
|
|
|
-import {API} from "../../configs/api.config";
|
|
|
+import {fetchGet, fetchPost} from "../../utils/fetchRequest";
|
|
|
+import {_baseURL, API} from "../../configs/api.config";
|
|
|
import {Toast, SearchBar} from "antd-mobile";
|
|
|
import RefreshLayout from "../../components/RefreshLayout";
|
|
|
-
|
|
|
+import {connect} from 'react-redux'
|
|
|
|
|
|
const mPageSize = 10
|
|
|
let mPageIndex = 0
|
|
|
+let mSearchKey = ''
|
|
|
|
|
|
-export default class PhonesList extends Component {
|
|
|
+class PhonesList extends Component {
|
|
|
|
|
|
constructor() {
|
|
|
super()
|
|
|
@@ -28,6 +29,9 @@ export default class PhonesList extends Component {
|
|
|
classTitle: '',
|
|
|
isLoading: true,
|
|
|
isRefreshing: false,
|
|
|
+ searchKey: '',
|
|
|
+ searchText: '',
|
|
|
+ searchHint: '',
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -38,8 +42,6 @@ export default class PhonesList extends Component {
|
|
|
this.mType = this.props.match.params.type
|
|
|
if (this.props.match.params.classId) {
|
|
|
this.classId = this.props.match.params.classId;
|
|
|
- } else {
|
|
|
- this.classId = 10001
|
|
|
}
|
|
|
if (this.title) {
|
|
|
this.setState({
|
|
|
@@ -47,19 +49,34 @@ export default class PhonesList extends Component {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- Toast.loading('', 0)
|
|
|
+ if (this.mType === 'teacher') {
|
|
|
+ this.setState({
|
|
|
+ searchHint: '搜索学生'
|
|
|
+ })
|
|
|
+ } else if (this.mType === 'parent') {
|
|
|
+ this.setState({
|
|
|
+ searchHint: '搜索老师'
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
+ Toast.loading('', 0)
|
|
|
mPageIndex = 0
|
|
|
this.loadPhones()
|
|
|
}
|
|
|
|
|
|
+ componentWillUnmount() {
|
|
|
+ Toast.hide()
|
|
|
+ }
|
|
|
+
|
|
|
render() {
|
|
|
- const {phonesList, classTitle, isLoading, isRefreshing} = this.state
|
|
|
+ const {phonesList, classTitle, isLoading, isRefreshing, searchHint, searchKey, searchText} = this.state
|
|
|
|
|
|
return (
|
|
|
- <div className='phone-select-root' style={{height:'100%',maxHeight:'100vh'}}>
|
|
|
+ <div className='phone-select-root' style={{height: '100%', maxHeight: '100vh'}}>
|
|
|
<div className='common-fixed-top'>
|
|
|
- <SearchBar placeholder="搜索家长" maxLength={20}/>
|
|
|
+ <SearchBar placeholder={searchHint} maxLength={20}
|
|
|
+ value={searchText} onSubmit={this.searchSubmit}
|
|
|
+ onChange={this.searchChange} onClear={this.searchClear}/>
|
|
|
<div className={isObjEmpty(classTitle) ? 'displayNone' : 'phones-list-header'}>{classTitle}</div>
|
|
|
<div className={isObjEmpty(classTitle) ? 'displayNone' : 'gray-line'} style={{height: '1px'}}></div>
|
|
|
</div>
|
|
|
@@ -81,6 +98,36 @@ export default class PhonesList extends Component {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+ searchChange = (value) => {
|
|
|
+ mSearchKey = value
|
|
|
+ this.setState({
|
|
|
+ searchText: value
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ searchClear = (e) => {
|
|
|
+ mPageIndex = 0
|
|
|
+ this.setState({
|
|
|
+ isLoading: true,
|
|
|
+ isRefreshing: false,
|
|
|
+ searchText: '',
|
|
|
+ searchKey: ''
|
|
|
+ }, () => {
|
|
|
+ this.loadPhones()
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ searchSubmit = (value) => {
|
|
|
+ mPageIndex = 0
|
|
|
+ this.setState({
|
|
|
+ isLoading: true,
|
|
|
+ isRefreshing: false,
|
|
|
+ searchKey: value
|
|
|
+ }, () => {
|
|
|
+ this.loadPhones()
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
loadPhones = () => {
|
|
|
try {
|
|
|
this.setState({
|
|
|
@@ -92,13 +139,13 @@ export default class PhonesList extends Component {
|
|
|
if (this.mType == 'parent') {
|
|
|
this.url = API.GET_TEACHER_PHONES
|
|
|
this.params = {
|
|
|
- stuId: this.classId
|
|
|
+ stuId: this.props.userInfo.user.student.stuId
|
|
|
}
|
|
|
this.getPhones()
|
|
|
} else if (this.mType == 'teacher') {
|
|
|
this.url = API.GET_PARENT_PHONES
|
|
|
this.params = {
|
|
|
- schId: this.classId
|
|
|
+ clazzId: this.classId
|
|
|
}
|
|
|
this.getPhones()
|
|
|
} else {
|
|
|
@@ -113,60 +160,55 @@ export default class PhonesList extends Component {
|
|
|
mPageIndex++
|
|
|
console.log(mPageIndex)
|
|
|
|
|
|
- const {phonesList} = this.state
|
|
|
+ const {phonesList, searchKey} = this.state
|
|
|
if (mPageIndex === 1) {
|
|
|
phonesList.length = 0
|
|
|
}
|
|
|
|
|
|
- fetchGet(this.url, {
|
|
|
+ fetchPost(this.url, {
|
|
|
pageIndex: mPageIndex,
|
|
|
pageSize: mPageSize,
|
|
|
+ selectKey: searchKey,
|
|
|
...this.params
|
|
|
}).then(response => {
|
|
|
Toast.hide();
|
|
|
|
|
|
if (response && response.data) {
|
|
|
if (this.mType == 'parent') {
|
|
|
- if (response.data.teachers && response.data.teachers.length > 0) {
|
|
|
- response.data.teachers.forEach((item, index) => {
|
|
|
- let phoneBean = new PhonesBean()
|
|
|
-
|
|
|
- phoneBean.icon = require('imgs/ic_head' + (index % 15 + 1) + '.png')
|
|
|
- phoneBean.name = getStrValue(item, 'userName')
|
|
|
- phoneBean.claName = this.title
|
|
|
- phoneBean.children = ['']
|
|
|
-
|
|
|
- phoneBean.phone = [getStrValue(item, 'UserPhone')]
|
|
|
- phonesList.push(phoneBean)
|
|
|
- })
|
|
|
- }
|
|
|
+ response.data.forEach((item, index) => {
|
|
|
+ let phoneBean = new PhonesBean()
|
|
|
+
|
|
|
+ phoneBean.icon = require('imgs/ic_head' + (index % 15 + 1) + '.png')
|
|
|
+ phoneBean.icon = _baseURL + getStrValue(item, 'teacherPhoto')
|
|
|
+ phoneBean.name = getStrValue(item, 'teacherName')
|
|
|
+ phoneBean.claName = this.title
|
|
|
+ phoneBean.children = ['']
|
|
|
+
|
|
|
+ phoneBean.phone = [getStrValue(item, 'userPhone')]
|
|
|
+ phonesList.push(phoneBean)
|
|
|
+ })
|
|
|
} else if (this.mType == 'teacher') {
|
|
|
- if (response.data.students && response.data.students.length > 0) {
|
|
|
- response.data.students.forEach((item, index) => {
|
|
|
- let phoneBean = new PhonesBean()
|
|
|
- let phones = []
|
|
|
- phoneBean.icon = require('imgs/ic_head' + (index % 15 + 1) + '.png')
|
|
|
- phoneBean.name = getStrValue(item, 'stuName')
|
|
|
- phoneBean.claName = this.title
|
|
|
-
|
|
|
- if (item.parents && item.parents.length > 0) {
|
|
|
- item.parents.forEach((ite, ind) => {
|
|
|
- phoneBean.children.push(getStrValue(ite, 'userName'))
|
|
|
- phones.push(getStrValue(ite, 'userPhone'))
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- // if (phones.length > 0) {
|
|
|
- phoneBean.phone = phones
|
|
|
- // }
|
|
|
-
|
|
|
- phonesList.push(phoneBean)
|
|
|
- })
|
|
|
- } else {
|
|
|
- if (mPageIndex > 1) {
|
|
|
- mPageIndex--
|
|
|
+ response.data.forEach((item, index) => {
|
|
|
+ let phoneBean = new PhonesBean()
|
|
|
+ let phones = []
|
|
|
+ phoneBean.icon = require('imgs/ic_head' + (index % 15 + 1) + '.png')
|
|
|
+ phoneBean.icon = _baseURL + getStrValue(item, 'stuPhoto')
|
|
|
+ phoneBean.name = getStrValue(item, 'stuName')
|
|
|
+ phoneBean.claName = this.title
|
|
|
+
|
|
|
+ if (item.parentsDOS && item.parentsDOS.length > 0) {
|
|
|
+ item.parentsDOS.forEach((ite, ind) => {
|
|
|
+ phoneBean.children.push(getStrValue(ite, 'parentsName'))
|
|
|
+ phones.push(getStrValue(ite, 'userPhone'))
|
|
|
+ })
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
+ // if (phones.length > 0) {
|
|
|
+ phoneBean.phone = phones
|
|
|
+ // }
|
|
|
+
|
|
|
+ phonesList.push(phoneBean)
|
|
|
+ })
|
|
|
}
|
|
|
} else {
|
|
|
if (mPageIndex > 1) {
|
|
|
@@ -197,4 +239,12 @@ export default class PhonesList extends Component {
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+let mapStateToProps = (state) => ({
|
|
|
+ userInfo: {...state.redUserInfo},
|
|
|
+})
|
|
|
+
|
|
|
+let mapDispatchToProps = (dispatch) => ({})
|
|
|
+
|
|
|
+export default connect(mapStateToProps, mapDispatchToProps)(PhonesList)
|