Преглед на файлове

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

wangyang преди 5 години
родител
ревизия
9802f3996b
променени са 1 файла, в които са добавени 3 реда и са изтрити 2 реда
  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