更新时间:2019-01-10 来源:黑马程序员 浏览量:
1 2 | import page_edit from '@ / module / cms / page / page_edit.vue'; { path : ' / cms / page / edit / : pageId' , name : '修改页面' , component : page_edit , hidden : true } , |
1 2 3 4 5 6 7 | < el‐table‐ column label = "操作" width = "80" > < template slot‐scope = "page" > < el‐ button size = "small" type = "text" @click = "edit(page.row.pageId)" > 编辑 < / el‐ button > < / template > < / el‐table‐ column > |
1 2 3 4 5 6 | / / 修改 edit : function ( pageId ) { this.$router.push ( { path : ' / cms / page / edit / ' + pageId , query : { page : this.params.page , siteId : this.params.siteId } } ) } |
1 2 3 | / * 页面查询 * / export const page_get = id = > { return http.requestQuickGet ( apiUrl + ' / cms / page / get / ' + id ) } |
1 2 3 4 5 6 7 8 | data ( ) { return { ...... / / 页面 id pageId : '' , ...... } } |
01 02 03 04 05 06 07 08 09 10 11 | created : function ( ) { / / 页面参数通过路由传入,这里通过this.$route.params来获取 this.pageId = this.$route.params.pageId; / / 根据主键查询页面信息 cmsApi.page_get ( this.pageId ) . then ( ( res ) = > { console. log ( res ) ; if ( res.success ) { this.pageForm = res.cmsPage; } } ) ; } |
1 2 3 4 | / * 页面修改, 采用put方法 * / export const page_edit = ( id , params ) = > { return http.requestPut ( apiUrl + ' / cms / page / edit / ' + id , params ) } |
1 | < el‐ button type = "primary" @click = "editSubmit" > 提交 < / el‐ button > |
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 | editSubmit ( ) { this.$refs.pageForm.validate ( ( valid ) = > { if ( valid ) { this.$confirm ( '确认提交吗?' , '提示' , { } ) . then ( ( ) = > { cmsApi.page_edit ( this.pageId , this.pageForm ) . then ( ( res ) = > { console. log ( res ) ; if ( res.success ) { this.$ message ( { message : '修改成功' , type : 'success' } ) ; / / 自动返回 this.go_back ( ) ; } else { this.$ message . error ( '修改失败' ) ; } } ) ; } ) ; } } ) ; } |