Procházet zdrojové kódy

表单按钮多次点击bug修复

FANGLH před 7 roky
rodič
revize
f03ded77ac

+ 7 - 0
frontend/wechat-web/src/modules/hiPages/field-trip/FieldTrip.js

@@ -196,6 +196,9 @@ class FieldTrip extends Component {
     }
     //提交
     doSaveClick = () => {
+        if(this.isRequesting == true){
+            return
+        }
         console.log('state', this.state)
         // console.log('startValue',this.state.startValue)
         if (this.state.tripType == null || this.state.tripType.length == 0) {
@@ -251,12 +254,15 @@ class FieldTrip extends Component {
         console.log('param', {
             oaString: params
         })
+        this.isRequesting = true
         fetchPost(API.oaCreate, {
             oaString: JSON.stringify(params)
         }, {})
             .then((response) => {
+                this.isRequesting = false
                 console.log('response', response)
                 if (response.success) {
+                    this.isRequesting = true
                     Toast.show(response.data, 1)
                     this.backTask = setTimeout(() => {
                         this.props.history.goBack()
@@ -264,6 +270,7 @@ class FieldTrip extends Component {
                 }
             })
             .catch((error) => {
+                this.isRequesting = false
                 console.log('error', error)
                 if (typeof error === 'string') {
                     Toast.fail(error, 2)

+ 7 - 0
frontend/wechat-web/src/modules/hiPages/res_apply/ResApply.js

@@ -209,6 +209,9 @@ class ResApply extends Component{
     }
     //提交
     doSaveClick =() =>{
+        if(this.isRequesting == true){
+            return
+        }
         console.log('state',this.state)
         if(this.state.resUser == null || this.state.resUser.trim().length == 0){
             Toast.show('请输入物品用途',1)
@@ -264,12 +267,15 @@ class ResApply extends Component{
         console.log('param',{
             oaString:params
         })
+        this.isRequesting = true
         fetchPost(API.oaCreate,{
             oaString:JSON.stringify(params)
         },{})
             .then((response)=>{
+                this.isRequesting = false
                 console.log('response',response)
                 if(response.success){
+                    this.isRequesting = true
                     Toast.show(response.data,1)
                     this.backTask = setTimeout(() => {
                         this.props.history.goBack()
@@ -277,6 +283,7 @@ class ResApply extends Component{
                 }
             })
             .catch((error) =>{
+                this.isRequesting = false
                 console.log('error',error)
             })
     }

+ 7 - 0
frontend/wechat-web/src/modules/hiPages/sendMeetting/SendMeet.js

@@ -188,6 +188,9 @@ class SendMeet extends Component {
     }
 
     doSaveClick = (event) => {
+        if(this.isRequesting == true){
+            return
+        }
         console.log('state', this.state)
         if (this.state.titleValue == null || this.state.titleValue.trim().length == 0) {
             Toast.fail('请填写会议主题...')
@@ -258,13 +261,16 @@ class SendMeet extends Component {
         console.log('params', params)
 
         Toast.loading("会议创建中...", 0)
+        this.isRequesting = true
         fetchPost(API.createMeeting, {
             jsonMeeting:JSON.stringify(params)
         }, {})
             .then((response) => {
+                this.isRequesting = false
                 Toast.hide()
                 console.log('response', response)
                 if (response.success) {
+                    this.isRequesting = true
                     clearListState()()
                     Toast.show('创建成功', 1)
 
@@ -274,6 +280,7 @@ class SendMeet extends Component {
                 }
             })
             .catch((error) => {
+                this.isRequesting = false
                 Toast.hide()
                 console.log('error', error)
                 console.log('error', error)

+ 7 - 0
frontend/wechat-web/src/modules/leave/LeaveAddCPage.js

@@ -136,6 +136,9 @@ class LeaveAddCPage extends Component {
     }
 
     onSubmitClick = (event) => {
+        if(this.isRequesting == true){
+            return
+        }
         console.log('state', this.state)
         console.log('state', this.state.leaveType)
         if (this.state.leaveType == null || this.state.leaveType == '') {
@@ -190,11 +193,14 @@ class LeaveAddCPage extends Component {
 
         }
         console.log('param', params)
+        this.isRequesting = true
         fetchPost(API.oaCreate, {
             oaString:JSON.stringify(params)
         }, {}).then((response) => {
             console.log('response', response)
+            this.isRequesting = false
             if (response.success) {
+                this.isRequesting = true
                 Toast.show(response.data, 1)
                 // this.props.history.push("/leaveList/" + this.props.match.params.role)
                 // this.props.history.push("/homePage")
@@ -203,6 +209,7 @@ class LeaveAddCPage extends Component {
                 }, 1000)
             }
         }).catch((error) => {
+            this.isRequesting = false
             console.log('error', error)
             if (typeof error === 'string') {
                 Toast.fail(error, 2)

+ 7 - 1
frontend/wechat-web/src/modules/leave/LeaveAddPage.js

@@ -115,7 +115,9 @@ class LeaveAddPage extends Component{
     }
     onSubmitClick = (event) => {
         console.log('state', this.state)
-
+        if (this.isRequesting == true) {
+            return
+        }
         if (this.state.startValue == null || this.state.startValue == '') {
             Toast.fail('请输入请假开始时间')
             return
@@ -165,11 +167,14 @@ class LeaveAddPage extends Component{
             lvFiles:JSON.stringify(approveFiles),
         }
         console.log('param', params)
+        this.isRequesting = true
         fetchPost(API.leaveCreate, {
             leaveString:JSON.stringify(params)
         }, {}).then((response) => {
             console.log('response', response)
+            this.isRequesting = false
             if (response.success) {
+                this.isRequesting = true
                 Toast.show(response.data, 1)
                 // this.props.history.push("/leaveList/" + this.props.match.params.role)
                 // this.props.history.push("/homePage")
@@ -178,6 +183,7 @@ class LeaveAddPage extends Component{
                 }, 1000)
             }
         }).catch((error) => {
+            this.isRequesting = false
             console.log('error', error)
             if (typeof error === 'string') {
                 Toast.fail(error, 2)