新增页面保存后,跳转为详情页,同时关闭新增页。(即路由detail/1?type=1,变为detail/2/2?type=2&id=2)

新增页面保存后,跳转为详情页,同时关闭新增页。

如若依系统,路由 detail/1?type=1,变为 detail/2/1?type=2&id=1

      refreshView() {
        // In order to make the cached page re-rendered
        this.$store.dispatch('tagsView/delCachedView', this.$route).then(() => {
          const { fullPath } = this.$route
          this.$nextTick(() => {
            this.$router.replace({
              path: '/redirect' + fullPath
            })
          })
        })
      },
      // 调用保存接口
      handleSave() {
        const params = this.handleParams()
        this.loading = true
        saveApply(params).then(res => {
          if (res.code === 200) {
            const applyId = res.data?.id || null
            this.loading = false
            if (this.routeType === '1') { // 新增页,保存后,需关闭新增页,跳转至详情页
              this.refreshView()
              // 调用全局挂载的方法,关闭当前页
              this.$store.dispatch('tagsView/delView', this.$route)
              this.$nextTick(() => {
                this.toDetail(applyId) // 跳转至详情页
              })
            } else {
              this.getDetail() // 详情页再次编辑,保存后直接刷新数据
            }
          } else {
            this.$message.error(res.msg)
          }
        }).catch(() => {
        }).finally(() => {
          this.loading = false
        })
      },

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值