更新時(shí)間: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 ( ) { / / 頁面參數(shù)通過路由傳入,這里通過this.$route.params來獲取 this.pageId = this.$route.params.pageId; / / 根據(jù)主鍵查詢頁面信息 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 ( '確認(rèn)提交嗎?' , '提示' , { } ) . then ( ( ) = > { cmsApi.page_edit ( this.pageId , this.pageForm ) . then ( ( res ) = > { console. log ( res ) ; if ( res.success ) { this.$ message ( { message : '修改成功' , type : 'success' } ) ; / / 自動(dòng)返回 this.go_back ( ) ; } else { this.$ message . error ( '修改失敗' ) ; } } ) ; } ) ; } } ) ; } |