add blank judgement for forms; fixing setstate bug in detailframework
This commit is contained in:
@@ -80,10 +80,10 @@ export default class DetailFramework extends Component<
|
||||
}
|
||||
|
||||
const status = this.state.ticketInfo.status;
|
||||
this.setState({
|
||||
current: mapStatusStep.get(status) || 0,
|
||||
items: pt.get().ticketDetail.stepItems,
|
||||
});
|
||||
// this.setState({
|
||||
// current: mapStatusStep.get(status) || 0,
|
||||
// items: pt.get().ticketDetail.stepItems,
|
||||
// });
|
||||
|
||||
const elements: ShowElements = {
|
||||
device: this.props.isInfoShow['device'] ? (
|
||||
|
||||
@@ -152,14 +152,7 @@ export default class RepairPage extends Component<{}, RepairPageState> {
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.setState({
|
||||
isLoading: true,
|
||||
isDisable: true,
|
||||
});
|
||||
submitTicket(this);
|
||||
Taro.reLaunch({
|
||||
url: '/pages/repair/repair',
|
||||
});
|
||||
}
|
||||
|
||||
render(): ReactNode {
|
||||
|
||||
@@ -8,6 +8,7 @@ export interface ButtonText {
|
||||
submitText: {
|
||||
success: string;
|
||||
error: string;
|
||||
blank: string;
|
||||
};
|
||||
loginText: {
|
||||
success: string;
|
||||
@@ -29,6 +30,7 @@ export const buttonZhCn: ButtonText = {
|
||||
submitText: {
|
||||
success: '提交成功',
|
||||
error: '提交失败:',
|
||||
blank: '请填写完整!',
|
||||
},
|
||||
loginText: {
|
||||
success: '登录成功',
|
||||
@@ -50,6 +52,7 @@ export const buttonEnUs: ButtonText = {
|
||||
submitText: {
|
||||
success: 'Success',
|
||||
error: 'Error: ',
|
||||
blank: 'Please fill in the blanks!',
|
||||
},
|
||||
loginText: {
|
||||
success: 'Login Success',
|
||||
|
||||
@@ -8,8 +8,22 @@ const logInterval = 5000;
|
||||
|
||||
export function memberLogin(that: UserMemberPage) {
|
||||
that.setState({
|
||||
isDisable: true,
|
||||
isLoading: true,
|
||||
});
|
||||
if (that.state.stuid == '' || that.state.passwd == '') {
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.blank,
|
||||
type: 'error',
|
||||
});
|
||||
setTimeout(() => {
|
||||
that.setState({
|
||||
isDisable: false,
|
||||
isLoading: false,
|
||||
});
|
||||
}, logInterval);
|
||||
return;
|
||||
}
|
||||
Taro.request({
|
||||
url: getUrl('/member/login'),
|
||||
method: 'POST',
|
||||
@@ -43,7 +57,7 @@ export function memberLogin(that: UserMemberPage) {
|
||||
type: 'error',
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
that.setState({
|
||||
isDisable: false,
|
||||
});
|
||||
}, logInterval);
|
||||
@@ -85,7 +99,7 @@ export function memberLogout(that: UserMemberPage) {
|
||||
type: 'error',
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
that.setState({
|
||||
isDisable: false,
|
||||
});
|
||||
}, logInterval);
|
||||
|
||||
@@ -29,7 +29,8 @@ export function getMyTicketList(that: MyTicketPage) {
|
||||
item.device,
|
||||
item.deviceModel,
|
||||
item.status,
|
||||
moment(),
|
||||
moment(item.createdTime),
|
||||
item.isMember,
|
||||
),
|
||||
),
|
||||
});
|
||||
|
||||
@@ -3,10 +3,35 @@ import Taro from '@tarojs/taro';
|
||||
import pt from '@/plain-text';
|
||||
import { getUrl } from '.';
|
||||
|
||||
const submitInterval = 5000;
|
||||
|
||||
export function submitTicket(that: RepairPage) {
|
||||
that.setState({
|
||||
isLoading: true,
|
||||
});
|
||||
if (that.state.isDisable != true || that.state.isLoading != true) {
|
||||
that.setState({
|
||||
isDisable: true,
|
||||
isLoading: true,
|
||||
});
|
||||
}
|
||||
if (
|
||||
that.state.description == '' ||
|
||||
that.state.device == '' ||
|
||||
that.state.deviceModel == '' ||
|
||||
that.state.owner == '' ||
|
||||
that.state.phone == '' ||
|
||||
that.state.checkedList.length === 0
|
||||
) {
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.blank,
|
||||
type: 'error',
|
||||
});
|
||||
setTimeout(() => {
|
||||
that.setState({
|
||||
isDisable: false,
|
||||
isLoading: false,
|
||||
});
|
||||
}, submitInterval);
|
||||
return;
|
||||
}
|
||||
Taro.request({
|
||||
url: getUrl('/tickets/create'),
|
||||
method: 'POST',
|
||||
@@ -30,6 +55,9 @@ export function submitTicket(that: RepairPage) {
|
||||
message: pt.get().button.submitText.success,
|
||||
type: 'success',
|
||||
});
|
||||
Taro.reLaunch({
|
||||
url: '/pages/repair/repair',
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
@@ -41,4 +69,10 @@ export function submitTicket(that: RepairPage) {
|
||||
type: 'error',
|
||||
});
|
||||
});
|
||||
setTimeout(() => {
|
||||
that.setState({
|
||||
isDisable: false,
|
||||
isLoading: false,
|
||||
});
|
||||
}, submitInterval);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user