iframe中,修改列表中一项,保存后跳转回列表页

跳转回列表页

top.frames[0].locationj.href = "/page/supplier_store";     // js跳转的知识 

或者

this.$router.back();     //vue router里的知识

提交成功后不跳转在本页面刷新

window.location.href = "/page/supplier_store";
this.$router.go(0);

项目场景是这样的:

image.png
image.png

添加和修改的click事件绑定的同一个,但是以ID 为判断条件走不同的接口

view 代码:

<el-button type="primary"  class="btn btnsubmit" @click="addSupplier('back')">保存</el-button>
<el-button type="primary" class="btn" @click="addSupplier('next')" v-show="revisable">保存录入下一条</el-button>

js代码

addSupplier(p){
                this.$refs.ruleForm.validate(async (valid) => {
                    if (valid) {
                        this.ruleForm2 = JSON.stringify(this.ruleForm);
                        this.ruleForm2 = JSON.parse(this.ruleForm2);
                        this.ruleForm2.categoryIds =  this.ruleForm.categoryIds.join(',');
                        try {
                            if(this.supplierId){
//                                如果有id则证明是编辑
                                this.ruleForm2.id = this.supplierId;
                                const {data:{code,msg}} = await srmServices.updateSupplier(this.ruleForm2);
                                this.code = code;
                                this.msg = msg;
                            }else{
//                                否则为新增
                                const {data:{code,msg}} = await srmServices.addSupplier(this.ruleForm2);
                                this.code = code;
                                this.msg = msg;
                            }
                        } catch (e) {
                            alert(e);
                        }
                    }
                    if(this.code == 0){
                        alert('保存成功!');
                    }else{
                        alert(this.msg);
                    }

                    if(p == 'back'){
                        this.$router.back();
//                        top.frames[0].location.href = "/page/supplier_store";
                    }else if(p == 'next'){
//                        this.$router.go(0);
                        window.location.href ="/page/add_supplier";
                    }


                });
            },
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 176,368评论 25 709
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,714评论 4 61
  • 如果有缘,错过了还会重来;如果无缘,相遇了也会离开。聚有聚的理由,离有离的借口,人生没有如果,只有后果结果。
    小沐童阅读 1,198评论 0 2
  • 2016/02/14 『养蚕』 姐姐说,我命中会存一笔小财。我相信万分。其实,或者是说,我在给自己一个希望,✘,是...
    蒙奇奇_阿蒙蛮好的阅读 1,441评论 0 1
  • sublime在linux下无法输入中文好像是通病,但是解决方法貌似都一样的 保存下面的代码在任意目录,命名为su...
    gaikin阅读 5,806评论 1 0

友情链接更多精彩内容