Ver código fonte

食物新建完成后自动跳到食物营养素页面

wangyang 5 anos atrás
pai
commit
9802f3996b
1 arquivos alterados com 3 adições e 2 exclusões
  1. 3 2
      src/views/food/components/FoodDetail.vue

+ 3 - 2
src/views/food/components/FoodDetail.vue

@@ -156,10 +156,11 @@ export default {
       this.$refs['postForm'].validate((valid) => {
         if (valid) {
           const resultPromise = this.isEdit ? update(this.foodId, this.postForm) : create(this.postForm)
-          resultPromise.then(() => {
+          resultPromise.then((res) => {
             this.$notify.success('提交成功')
             this.loading = false
-            this.$router.push({ path: '/food' })
+            const nextPath = this.isEdit ? '/food' : `/food/${res.data}/nutrient`
+            this.$router.push({ path: nextPath })
           }).catch(res => {
             this.$message.error(res.data.message)
             this.loading = false