editPage.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <div class="body d-flex flex-column">
  3. <v-banner single-line sticky color="#FFF" >
  4. <div class="d-flex align-center">
  5. <v-btn text @click="goBack">
  6. <v-icon>mdi-chevron-left</v-icon>
  7. 返回
  8. </v-btn>
  9. {{ title }}
  10. </div>
  11. <template v-slot:actions>
  12. <v-btn class="ma-2 half-button" rounded @click="goBack">取消</v-btn>
  13. <v-btn color="primary" rounded class="half-button" @click="submit">保存</v-btn>
  14. </template>
  15. </v-banner>
  16. <div class="main">
  17. <feature-slide class="slide" :width="sideWidth" :items="items" @refresh="$emit('refresh-roles')" />
  18. <div class="content" :style="`padding-left: ${sideWidth}px`">
  19. <slot name="body" :data="items"></slot>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import cloneDeep from 'lodash/cloneDeep'
  26. import FeatureSlide from './featureSlide.vue'
  27. export default {
  28. components: { FeatureSlide },
  29. props: {
  30. roles: {
  31. type: Array,
  32. default: () => []
  33. },
  34. title: {
  35. type: String,
  36. default: ''
  37. }
  38. },
  39. data () {
  40. return {
  41. sideWidth: 300,
  42. items: [],
  43. component: []
  44. }
  45. },
  46. watch: {
  47. roles: {
  48. handler (val) {
  49. this.items = cloneDeep(this.roles)
  50. },
  51. immediate: true
  52. }
  53. },
  54. methods: {
  55. goBack () {
  56. this.$confirm('是否离开当前页面', '离开后不保留编辑内容')
  57. .then(() => {
  58. this.$router.go(-1)
  59. })
  60. .catch(e => {})
  61. },
  62. submit () {
  63. this.$emit('handleSubmit', this.items)
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .body {
  70. height: 100%;
  71. }
  72. .main {
  73. flex: 1;
  74. .slide {
  75. box-sizing: border-box;
  76. padding: 20px;
  77. height: 100%;
  78. position: fixed;
  79. top: 61px;
  80. border-right: 1px solid rgba(0, 0, 0, 0.12);
  81. }
  82. .content {
  83. &_box {
  84. padding: 30px;
  85. }
  86. }
  87. }
  88. </style>