Просмотр исходного кода

save已发布信息修改校验

cyy 1 год назад
Родитель
Сommit
4804ef7c8b
2 измененных файлов с 38 добавлено и 25 удалено
  1. 22 17
      src/utils/request.js
  2. 16 8
      src/views/platform/notice/edit.vue

+ 22 - 17
src/utils/request.js

@@ -133,9 +133,11 @@ service.interceptors.request.use(async config => {
  * 响应(respone)拦截器
  * 响应(respone)拦截器
  */
  */
 service.interceptors.response.use(response => {
 service.interceptors.response.use(response => {
+  console.log(response)
   tryHideFullScreenLoading()
   tryHideFullScreenLoading()
   const dataAxios = response.data
   const dataAxios = response.data
   const { state, message, cause } = dataAxios
   const { state, message, cause } = dataAxios
+
   if (response.config.responseType === 'arraybuffer') {
   if (response.config.responseType === 'arraybuffer') {
     // 刷新tonken
     // 刷新tonken
     return response
     return response
@@ -217,29 +219,32 @@ service.interceptors.response.use(response => {
   } else { // 错误处理
   } else { // 错误处理
     let errorMsg = ''
     let errorMsg = ''
     if (Utils.isNotEmpty(message)) { // 有错误消息
     if (Utils.isNotEmpty(message)) { // 有错误消息
-      errorMsg = '错误原因:用户名或密码错误'
-      // errorMsg = Utils.isNotEmpty(dataAxios.cause) ? I18n.t('error.messageCause', {
-      //   message,
-      //   cause: dataAxios.cause
-      // }) : I18n.t('error.message', {
-      //   message
-      // })
+      // errorMsg = '错误原因:用户名或密码错误'
+      errorMsg = Utils.isNotEmpty(dataAxios.cause) ? I18n.t('error.messageCause', {
+        message,
+        cause: dataAxios.cause
+      }) : I18n.t('error.message', {
+        message
+      })
     } else if (Utils.isNotEmpty(cause)) { // 只有错误原因
     } else if (Utils.isNotEmpty(cause)) { // 只有错误原因
-      errorMsg = '错误原因:用户名或密码错误'
+      // errorMsg = '错误原因:用户名或密码错误'
 
 
-      // errorMsg = I18n.t('error.cause', {
-      //   cause
-      // })
+      errorMsg = I18n.t('error.cause', {
+        cause
+      })
     } else if (I18n.te('error.status.' + state)) { // 有错误编码
     } else if (I18n.te('error.status.' + state)) { // 有错误编码
-      errorMsg = '错误原因:用户名或密码错误'
+      // errorMsg = '错误原因:用户名或密码错误'
 
 
-      // errorMsg = I18n.t('error.status.' + state)
+      errorMsg = I18n.t('error.status.' + state)
     } else { // 未知
     } else { // 未知
-      errorMsg = '错误原因:用户名或密码错误'
+      // errorMsg = '错误原因:用户名或密码错误'
 
 
-      // errorMsg = message || I18n.t('error.unknown', {
-      //   state
-      // })
+      errorMsg = message || I18n.t('error.unknown', {
+        state
+      })
+    }
+    if (response.config.url === '/oauth2/v3/user/login/apply') {
+      errorMsg = '错误原因:用户名或密码错误'
     }
     }
     Toast({
     Toast({
       message: `${errorMsg}`,
       message: `${errorMsg}`,

+ 16 - 8
src/views/platform/notice/edit.vue

@@ -387,9 +387,9 @@ export default {
         })
         })
         return
         return
       }
       }
-      // console.log(this.form, this.id)
+      console.log(this.form, this.id)
       // this.form.id = '1288815885233946624'
       // this.form.id = '1288815885233946624'
-      // // this.form.userId = '1166765336603656192'
+      // this.form.userId = '1166765336603656192'
       // this.form.status = 'publish'
       // this.form.status = 'publish'
       if (!this.$utils.isEmpty(this.id)) {
       if (!this.$utils.isEmpty(this.id)) {
         if (this.form.userId !== this.$store.getters.userId) {
         if (this.form.userId !== this.$store.getters.userId) {
@@ -398,13 +398,14 @@ export default {
             message: '非当前人员公告!'
             message: '非当前人员公告!'
           })
           })
           return
           return
-        } else if (this.form.status === 'publish' || this.form.status === 'expired') {
-          this.$notify({
-            type: 'warning',
-            message: '已发布,无法再次发布!'
-          })
-          return
         }
         }
+        // else if (this.form.status === 'publish' || this.form.status === 'expired') {
+        //   this.$notify({
+        //     type: 'warning',
+        //     message: '已发布,无法再次发布!'
+        //   })
+        //   return
+        // }
       }
       }
       if (this.$utils.isNotEmpty(data.publicDate)) {
       if (this.$utils.isNotEmpty(data.publicDate)) {
         data.publicDate += ' 00:00:00'
         data.publicDate += ' 00:00:00'
@@ -436,6 +437,13 @@ export default {
       this.$refs.form
       this.$refs.form
         .validate()
         .validate()
         .then(() => {
         .then(() => {
+          if (this.form.status === 'publish' || this.form.status === 'expired') {
+            this.$notify({
+              type: 'warning',
+              message: '已发布,无法再次发布!'
+            })
+            return
+          }
           this.form.status = 'publish'
           this.form.status = 'publish'
           this.onSave()
           this.onSave()
         })
         })