diff --git a/src/common/axios/index.js b/src/common/axios/index.js index 82c0c5fe3..6d9d0f0fb 100644 --- a/src/common/axios/index.js +++ b/src/common/axios/index.js @@ -536,5 +536,53 @@ export default { }).catch(err => { exeFun.call(this, err) }) - } + }, + + _getData (url, params, config = {}) { + return new Promise((resolve,reject)=>{ + // 参数包含this + let _this = config._this || false + // 参数包含loading + let loading = config.loading || false + if (_this && loading) { + _this[loading] = true + } + + _axios.get(api() + url + '?_t=' + new Date().getTime(), { params }).then(res => { + resolve(res.data) + }).catch(err => { + reject(err) + }).finally(()=>{ + if (_this && loading) { _this[loading] = false } + }) + }) + }, + + _postData (url, param, config = {}) { + return new Promise((resolve,reject) => { + var _formData = formData(param) + // 参数包含this + let _this = config._this || false + // 参数包含loading + let loading = config.loading || false + // 是否显示操作提示 + let showTips = config.showTips === undefined ? true : config.showTips + if (_this && loading) { _this[loading] = true } + + _axios.post(api() + url + '?' + new Date().getTime(), _formData).then(res => { + if (res.data.ok !== undefined && showTips) { + let type = res.data.ok ? 'success' : 'warning' + if (_this && res.data.message !== '' && res.data.message !== null) { + Message[type](res.data.message) + } + } + resolve(res.data) + }).catch(err => { + reject(err) + }).finally(()=>{ + if (_this && loading) { _this[loading] = false } + }) + }) + }, + } diff --git a/src/pages/home2/components/releaseQA2/index.vue b/src/pages/home2/components/releaseQA2/index.vue index d148dfa74..52d4f1b93 100644 --- a/src/pages/home2/components/releaseQA2/index.vue +++ b/src/pages/home2/components/releaseQA2/index.vue @@ -124,26 +124,35 @@ export default { }, methods: { getDate(){ - this.loading = true + // this.loading = true let form = this.form form.userId = this.$store.getters.userInfo.account form.pageSize = this.pageSize form.page = this.currentPage - return new Promise((resolve,reject)=>{ - this.$http.get('lawss/AskQuestions/getAskQuestionsPage', form, {_this: this }, res => { - if(res.data){ - const data = res.data - this.data = data.records - this.total = data.total - this.currentPage = data.current - this.pageSize = data.size - } - this.loading = false - resolve(res) - }, e => { - this.loading = false - reject(e) - }) + // return new Promise((resolve,reject)=>{ + // this.$http.get('lawss/AskQuestions/getAskQuestionsPage', form, {_this: this }, res => { + // if(res.data){ + // const data = res.data + // this.data = data.records + // this.total = data.total + // this.currentPage = data.current + // this.pageSize = data.size + // } + // this.loading = false + // resolve(res) + // }, e => { + // this.loading = false + // reject(e) + // }) + // }) + this.$http._getData('lawss/AskQuestions/getAskQuestionsPage', form, {_this: this, loading: 'loading' }).then(res => { + if(res.data){ + const data = res.data + this.data = data.records + this.total = data.total + this.currentPage = data.current + this.pageSize = data.size + } }) }, onSubmit(){ diff --git a/src/pages/personal/pages/my-questions/index.vue b/src/pages/personal/pages/my-questions/index.vue index 3447d6e1e..65ee3d817 100644 --- a/src/pages/personal/pages/my-questions/index.vue +++ b/src/pages/personal/pages/my-questions/index.vue @@ -1984,17 +1984,24 @@ export default { { _this: this }, val => { - this.$http.post('lawss/activiti/completeTask',{ - taskIds: val.data, - userId : this.$store.getters.userInfo.userId, - json: JSON.stringify(res.data), - }, - { - _this: this - }, res => { - this.submitGetData(); - }, e => { - }) + // this.$http.post('lawss/activiti/completeTask',{ + // taskIds: val.data, + // userId : this.$store.getters.userInfo.userId, + // json: JSON.stringify(res.data), + // }, + // { + // _this: this + // }, res => { + // this.submitGetData(); + // }, e => { + // }) + this.$http._postData('lawss/activiti/completeTask',{ + taskIds: val.data, + userId : this.$store.getters.userInfo.userId, + json: JSON.stringify(res.data), + }).then(res => { + this.submitGetData(); + }) }, e => { }) }, e => {