From c5a7f5f718500da7a633eb35f212cc941841e2c1 Mon Sep 17 00:00:00 2001 From: jiangyy Date: Wed, 29 Sep 2021 10:39:38 +0800 Subject: [PATCH] =?UTF-8?q?bug=20=E4=BF=AE=E6=94=B91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/index.js | 13 +- src/views/form/statistics/list.vue | 613 +++++++++++++++-------------- src/views/form/write/index.vue | 40 +- 3 files changed, 343 insertions(+), 323 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index fe2f482..baaf02a 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -69,7 +69,7 @@ api.interceptors.response.use( */ let errCodes = [500, 405, 403] const res = response.data - if (res.code === 200) { + if (res.code === 0) { return Promise.resolve(res) } else if (errCodes.includes(res.code)) { // 这里做错误提示,如果使用了 element ui 则可以使用 Message 进行提示 @@ -112,8 +112,15 @@ api.interceptors.response.use( result = await api.request(response.config) }) return Promise.resolve(result) - } - return Promise.resolve(res) + }else { + Message({ + message: res.msg || 'Error', + type: 'error', + duration: 5 * 1000 + }) + return Promise.reject(res) + } + // return Promise.resolve(res) }, error => { Message({ diff --git a/src/views/form/statistics/list.vue b/src/views/form/statistics/list.vue index 8d8561f..dc0e9f9 100644 --- a/src/views/form/statistics/list.vue +++ b/src/views/form/statistics/list.vue @@ -1,332 +1,342 @@ @@ -386,5 +396,4 @@ export default { ::v-deep .el-drawer__container ::-webkit-scrollbar { display: none; } - diff --git a/src/views/form/write/index.vue b/src/views/form/write/index.vue index cdbb865..3b65377 100644 --- a/src/views/form/write/index.vue +++ b/src/views/form/write/index.vue @@ -47,6 +47,7 @@ import loadWXJs from '@/utils/loadWxSdk' import defaultValue from '@/utils/defaultValue' import { getQueryString } from '@/utils' import constants from '@/utils/constants' +import ELEMENT from 'element-ui' const uaParser = require('ua-parser-js') const ua = uaParser(navigator.userAgent) @@ -288,10 +289,18 @@ export default { let projectKey = this.projectConfig.projectKey this.$router.replace({ path: '/project/public/result', query: { projectKey } }) }, - submitForm (data) { + async submitForm (data) { + const loading = ELEMENT.Loading.service({ + fullscreen: true, + lock: true, + text: '提交中', + spinner: 'el-icon-loading', + background: 'rgba(255, 255, 255, 0.5)' + }) + // 完成时间 let inActiveTime = document.getElementById('inActiveTime').innerText - this.$api.post(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/create?access_key=${this.accessKey}`, { + await this.$api.post(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/create?access_key=${this.accessKey}`, { 'completeTime': inActiveTime, 'projectKey': this.projectConfig.projectKey, 'submitOs': ua.os.name, @@ -309,24 +318,19 @@ export default { //'accessKey':this.accessKey }).then((res) => { - if (res.code !== 0) { - this.$message( - { - message: res.msg, - type: 'warning' - } - ) - } else { - this.writeStatus = 2 - if (this.userProjectSetting.submitJumpUrl) { - setTimeout(() => { - window.location.replace(this.userProjectSetting.submitJumpUrl) - }, 1000) - } + this.writeStatus = 2 + if (this.userProjectSetting.submitJumpUrl) { + setTimeout(() => { + window.location.replace(this.userProjectSetting.submitJumpUrl) + }, 1000) } - - }) + }, + (msg) => { + // debugger + }) + // debugger + loading.close() } } }