Commit 3828a0ec by 姜雷

修改列表请求

parent 6508463b
......@@ -69,6 +69,17 @@ class PublicCarApply extends Component {
}
return true;
};
resetForm = () => {
this.setState({
createDate: formatDate(new Date(), 'yyyy-MM-dd'),
categoryId: '',
userCount: '',
beginDate: '',
endDate: '',
lineDescription: '',
showAllCategory: false,
});
};
onSubmit = () => {
if (!this.validateForm()) {
return;
......@@ -84,8 +95,8 @@ class PublicCarApply extends Component {
department: this.state.department,
name: this.state.name,
categoryName: categoryName,
beginDate: this.state.beginDate,
endDate: this.state.endDate,
beginDate: formatDate(this.state.beginDate, 'yyyy-MM-dd hh:mm:ss'),
endDate: formatDate(this.state.endDate, 'yyyy-MM-dd hh:mm:ss'),
lineDescription: this.state.lineDescription,
userCount: this.state.userCount,
};
......@@ -93,20 +104,12 @@ class PublicCarApply extends Component {
.then(res => {
console.log('res: ' + res);
Toast.success(res.msg);
this.resetForm();
})
.catch(err => {
console.log('err: ' + err);
Toast.fail(err.msg || '提交失败!');
});
// sendMsg({
// cellphone: '18108096099',
// })
// .then(res => {
// console.log(res);
// Toast.success('发送成功!');
// })
// .catch(err => {
// console.log(err);
// });
};
render() {
const {
......
......@@ -30,22 +30,47 @@ class PublicCarList extends Component {
}),
0
);
this.fetchList();
}
fetchList = fetchMore => {
const { pagination } = this.state;
const nowDate = new Date().toISOString();
fetchPublicCarList({
...pagination,
nowDate,
})
const entity = fetchMore
? {
...pagination,
pageNum: pagination.pageNum + 1,
}
: {
...pagination,
pageNum: 1,
nowDate,
};
fetchPublicCarList(entity)
.then(res => {
console.log(res);
this.setState(({ pagination }) => ({
list: res.data,
pagination: {
...pagination,
nowDate,
},
refreshing: false,
}));
this.setState(
({ list, pagination }) =>
fetchMore
? res.data.length
? {
list: [...list, ...res.data],
pagination: {
...pagination,
pageNum: pagination.pageNum + 1,
},
refreshing: false,
}
: {
refreshing: false,
}
: {
list: res.data,
pagination: {
...pagination,
nowDate,
},
refreshing: false,
}
);
})
.catch(err => {
Toast.fail(err.msg || '请求失败!');
......@@ -53,49 +78,9 @@ class PublicCarList extends Component {
refreshing: false,
});
});
}
fetchList = () => {
const { pagination } = this.state;
return fetchPublicCarList({ ...pagination })
.then(res => {
console.log(res);
if (res.data) {
this.setState(({ pagination }) => ({
list: res.data,
pagination: {
...pagination,
},
}));
}
})
.catch(err => {
console.log(err);
});
};
refreshHandle = () => {
this.setState({ refreshing: true });
const { pagination } = this.state;
fetchPublicCarList({
...pagination,
pageNum: pagination.pageNum + 1,
})
.then(res => {
console.log(res);
this.setState(({ pagination }) => ({
list: res.data,
pagination: {
...pagination,
pageNum: pagination.pageNum + 1,
},
refreshing: false,
}));
})
.catch(err => {
Toast.fail(err.msg || '请求失败!');
this.setState({
refreshing: false,
});
});
this.fetchList(true);
};
render() {
return (
......
import React, { Component } from 'react';
import styles from './style.css';
import titleIcon from '../../Repair/images/dropdown_icon@2x.png';
import { formatDate } from '../../../utils/index';
class PublicCarItem extends Component {
constructor(props) {
......@@ -58,9 +57,7 @@ class PublicCarItem extends Component {
? [
<div key="time" className={styles.listLine}>
<div className={styles.listLabel}>用车时间:</div>
<div className={styles.listValue}>
{formatDate(new Date(data.createDate), 'yyyy-MM-dd')}
</div>
<div className={styles.listValue}>{data.createDate}</div>
</div>,
<div key="type" className={styles.listLine}>
<div className={styles.listLabel}>用车类型:</div>
......@@ -84,15 +81,11 @@ class PublicCarItem extends Component {
</div>,
<div key="beginDate" className={styles.listLine}>
<div className={styles.listLabel}>开始时间:</div>
<div className={styles.listValue}>
{formatDate(new Date(data.beginDate), 'yyyy-MM-dd hh:mm')}
</div>
<div className={styles.listValue}>{data.beginDate}</div>
</div>,
<div key="endDate" className={styles.listLine}>
<div className={styles.listLabel}>结束时间:</div>
<div className={styles.listValue}>
{formatDate(new Date(data.endDate), 'yyyy-MM-dd hh:mm')}
</div>
<div className={styles.listValue}>{data.endDate}</div>
</div>,
<div
key="dealName"
......@@ -146,9 +139,7 @@ class PublicCarItem extends Component {
: [
<div key="time" className={styles.listLine}>
<div className={styles.listLabel}>用车时间:</div>
<div className={styles.listValue}>
{formatDate(new Date(data.createDate), 'yyyy-MM-dd')}
</div>
<div className={styles.listValue}>{data.createDate}</div>
</div>,
<div key="type" className={styles.listLine}>
<div className={styles.listLabel}>用车类型:</div>
......
......@@ -11,6 +11,7 @@ import {
import SelectIcon from './images/more_item_btn@2x.png';
import offCheckIcon from '../../images/Check/radio_off_btn@2x.png';
import onCheckIcon from '../../images/Check/radio_on_btn@2x.png';
import UserInfoContext from '../../context/userinfo-context';
class PublicCarDeal extends Component {
constructor(props) {
......@@ -35,45 +36,48 @@ class PublicCarDeal extends Component {
};
}
componentDidMount() {
const { pagination } = this.state;
const nowDate = new Date().toISOString();
fetchApplyPublicCarList({
...pagination,
nowDate,
})
.then(res => {
this.setState(({ pagination }) => ({
list: res.data,
pagination: {
...pagination,
nowDate,
},
refreshing: false,
}));
})
.catch(err => {
Toast.fail(err.msg || '请求失败!');
this.setState({
refreshing: false,
});
});
this.fetchList();
}
fetchList = fetchMore => {
this.setState({ refreshing: true });
const { pagination } = this.state;
fetchApplyPublicCarList({
...pagination,
pageNum: pagination.pageNum + 1,
})
const nowDate = new Date().toISOString();
const entity = fetchMore
? {
...pagination,
pageNum: pagination.pageNum + 1,
}
: {
...pagination,
pageNum: 1,
nowDate,
};
fetchApplyPublicCarList(entity)
.then(res => {
this.setState(({ pagination }) => ({
list: res.data,
pagination: {
...pagination,
pageNum: pagination.pageNum + 1,
},
refreshing: false,
}));
this.setState(
({ list, pagination }) =>
fetchMore
? res.data.length
? {
list: [...list, ...res.data],
pagination: {
...pagination,
pageNum: pagination.pageNum + 1,
},
refreshing: false,
}
: {
refreshing: false,
}
: {
list: res.data,
pagination: {
...pagination,
nowDate,
},
refreshing: false,
}
);
})
.catch(err => {
Toast.fail(err.msg || '请求失败!');
......@@ -83,33 +87,7 @@ class PublicCarDeal extends Component {
});
};
refreshHandle = () => {
this.setState({ refreshing: true });
const { pagination } = this.state;
fetchApplyPublicCarList({
...pagination,
pageNum: pagination.pageNum + 1,
})
.then(res => {
this.setState(({ list, pagination }) => ({
list: [...list, ...res.data],
pagination: {
...pagination,
pageNum: pagination.pageNum + 1,
},
refreshing: false,
}));
})
.catch(err => {
Toast.fail(err.msg || '请求失败!');
this.setState({
refreshing: false,
});
});
};
toggleSelectedState = val => {
this.setState({
selected: val,
});
this.fetchList(true);
};
dealHandle = id => {
if (this.state.carPlateList.length === 0) {
......@@ -161,7 +139,7 @@ class PublicCarDeal extends Component {
Toast.fail('请选择处理结果!');
return false;
}
if (value === 1) {
if (value === 2) {
if (!carPlate) {
Toast.fail('请选择派车!');
return false;
......@@ -176,15 +154,18 @@ class PublicCarDeal extends Component {
const {
selected: { id, value, carPlate, dealOpinion },
} = this.state;
const { userinfo } = this.props;
const entity =
value === 1
value === 2
? {
id: id,
dealName: userinfo.name,
dealResult: value,
carPlate: carPlate,
}
: {
id: id,
dealName: userinfo.name,
dealResult: value,
dealOpinion: dealOpinion
? `不同意 - ${dealOpinion}`
......@@ -193,6 +174,7 @@ class PublicCarDeal extends Component {
dealPublicCar(entity)
.then(res => {
this.resetDialog();
this.fetchList();
Toast.success(res.msg || '处理成功!');
})
.catch(err => {
......@@ -263,10 +245,10 @@ class PublicCarDeal extends Component {
<div key="radio" className={styles.alertInfo}>
<div
className={styles.radioBox}
onClick={() => this.toggleSelectedState(1)}
onClick={() => this.toggleSelectedState(2)}
>
<span className={styles.checkLabel}>
{value === 1 ? (
{value === 2 ? (
<img src={onCheckIcon} alt="" />
) : (
<img src={offCheckIcon} alt="" />
......@@ -276,10 +258,10 @@ class PublicCarDeal extends Component {
</div>
<div
className={styles.radioBox}
onClick={() => this.toggleSelectedState(2)}
onClick={() => this.toggleSelectedState(3)}
>
<span className={styles.checkLabel}>
{value === 2 ? (
{value === 3 ? (
<img src={onCheckIcon} alt="" />
) : (
<img src={offCheckIcon} alt="" />
......@@ -288,7 +270,7 @@ class PublicCarDeal extends Component {
<span>不同意</span>
</div>
</div>
{value === 1 ? (
{value === 2 ? (
<div key="agree" className={styles.agree}>
<span className={styles.dialogAgreeLabel}>派车车牌</span>
<div className={styles.selectWrap}>
......@@ -301,21 +283,14 @@ class PublicCarDeal extends Component {
onChange={this.onSelectHandle}
>
{carPlateList.map(i => (
<option key={i.value} value={i.value}>
<option key={i.value} value={i.lable}>
{i.lable}
</option>
))}
</select>
</div>
{/* <Select
placeholder="请选择"
data={carPlateList}
cols={1}
onChange={this.onSelectHandle}
/> */}
</div>
) : value === 2 ? (
) : value === 3 ? (
<div key="notAgree" className={styles.notAgree}>
<span className={styles.dialogLabel}>处理结果</span>
<TextareaItem
......@@ -335,4 +310,8 @@ class PublicCarDeal extends Component {
}
}
export default PublicCarDeal;
export default props => (
<UserInfoContext.Consumer>
{({ userinfo }) => <PublicCarDeal userinfo={userinfo} {...props} />}
</UserInfoContext.Consumer>
);
......@@ -8,14 +8,14 @@ import Perview from '../../components/Perview/Perview';
class RepairList extends Component {
constructor(props) {
super(props);
const getSectionData = (dataBlob, sectionID) => dataBlob[sectionID];
const getRowData = (dataBlob, sectionID, rowID) => dataBlob[rowID];
const list = new ListView.DataSource({
getRowData,
getSectionHeaderData: getSectionData,
rowHasChanged: (row1, row2) => row1 !== row2,
sectionHeaderHasChanged: (s1, s2) => s1 !== s2,
});
// const getSectionData = (dataBlob, sectionID) => dataBlob[sectionID];
// const getRowData = (dataBlob, sectionID, rowID) => dataBlob[rowID];
// const list = new ListView.DataSource({
// getRowData,
// getSectionHeaderData: getSectionData,
// rowHasChanged: (row1, row2) => row1 !== row2,
// sectionHeaderHasChanged: (s1, s2) => s1 !== s2,
// });
this.state = {
refreshing: false,
down: true,
......@@ -25,7 +25,7 @@ class RepairList extends Component {
pageNum: 1,
pageSize: 50,
},
list: list,
list: [],
perviewVisibility: false,
selectedImgList: [],
perviewIndex: 0,
......@@ -41,21 +41,47 @@ class RepairList extends Component {
}),
0
);
this.fetchList();
}
fetchList = fetchMore => {
const { pagination } = this.state;
const nowDate = new Date().toISOString();
fetchRepairList({
...pagination,
nowDate,
})
const entity = fetchMore
? {
...pagination,
pageNum: pagination.pageNum + 1,
}
: {
...pagination,
pageNum: 1,
nowDate,
};
fetchRepairList(entity)
.then(res => {
console.log(res);
this.setState(({ pagination }) => ({
list: res.data,
pagination: {
...pagination,
nowDate,
},
}));
this.setState(
({ list, pagination }) =>
fetchMore
? res.data.length
? {
list: [...list, ...res.data],
pagination: {
...pagination,
pageNum: pagination.pageNum + 1,
},
refreshing: false,
}
: {
refreshing: false,
}
: {
list: res.data,
pagination: {
...pagination,
nowDate,
},
refreshing: false,
}
);
})
.catch(err => {
Toast.fail(err.msg || '请求失败!');
......@@ -63,37 +89,9 @@ class RepairList extends Component {
refreshing: false,
});
});
}
};
refreshHandle = () => {
this.setState({ refreshing: true });
const { pagination } = this.state;
fetchRepairList({
...pagination,
pageNum: pagination.pageNum + 1,
})
.then(res => {
console.log(res);
if (res.data.length) {
this.setState(({ list, pagination }) => ({
refreshing: false,
list: [...list, ...res.data],
pagination: {
...pagination,
pageNum: pagination.pageNum + 1,
},
}));
} else {
this.setState({
refreshing: false,
});
}
})
.catch(err => {
Toast.fail(err.msg || '请求失败!');
this.setState({
refreshing: false,
});
});
this.fetchList(true);
};
showViewHandle = (list, index) => {
this.setState({
......
......@@ -22,47 +22,48 @@ class RepairDeal extends Component {
};
}
componentDidMount() {
const { pagination } = this.state;
const nowDate = new Date().toISOString();
fetchReportRepairList({
...pagination,
nowDate,
})
.then(res => {
console.log(res);
this.setState(({ pagination }) => ({
list: res.data,
pagination: {
...pagination,
nowDate,
},
refreshing: false,
}));
})
.catch(err => {
Toast.fail(err.msg || '请求失败!');
this.setState({
refreshing: false,
});
});
this.fetchList();
}
fetchList = () => {
fetchList = fetchMore => {
this.setState({ refreshing: true });
const { pagination } = this.state;
const nowDate = new Date().toISOString();
fetchReportRepairList({
...pagination,
nowDate,
})
const entity = fetchMore
? {
...pagination,
pageNum: pagination.pageNum + 1,
}
: {
...pagination,
pageNum: 1,
nowDate,
};
fetchReportRepairList(entity)
.then(res => {
console.log(res);
this.setState(({ pagination }) => ({
list: res.data,
pagination: {
...pagination,
nowDate,
},
refreshing: false,
}));
this.setState(
({ list, pagination }) =>
fetchMore
? res.data.length
? {
list: [...list, ...res.data],
pagination: {
...pagination,
pageNum: pagination.pageNum + 1,
},
refreshing: false,
}
: {
refreshing: false,
}
: {
list: res.data,
pagination: {
...pagination,
nowDate,
},
refreshing: false,
}
);
})
.catch(err => {
Toast.fail(err.msg || '请求失败!');
......@@ -72,35 +73,7 @@ class RepairDeal extends Component {
});
};
refreshHandle = () => {
this.setState({ refreshing: true });
const { pagination } = this.state;
fetchReportRepairList({
...pagination,
pageNum: pagination.pageNum + 1,
})
.then(res => {
console.log(res);
if (res.data.length) {
this.setState(({ list, pagination }) => ({
refreshing: false,
list: [...list, ...res.data],
pagination: {
...pagination,
pageNum: pagination.pageNum + 1,
},
}));
} else {
this.setState({
refreshing: false,
});
}
})
.catch(err => {
Toast.fail(err.msg || '请求失败!');
this.setState({
refreshing: false,
});
});
this.fetchList(true);
};
dealHandle = id => {
console.log('in date');
......@@ -121,6 +94,7 @@ class RepairDeal extends Component {
id: id,
})
.then(res => {
this.fetchList();
Toast.fail(res.msg || '处理成功!');
})
.catch(err => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment