com-list-page.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template id="com-list-page">
  2. <div id="app">
  3. <el-card class="card-breadcrumb" v-if="crumbs.length > 0">
  4. <el-breadcrumb separator="/">
  5. <el-breadcrumb-item v-for="(item, index) in crumbs" :key="index">
  6. <span
  7. v-if="item.router"
  8. style="color: #409EFF;cursor: pointer"
  9. @click="$navigate(getNavigateParams(item))"
  10. >
  11. {{ item.title }}
  12. </span>
  13. <template v-else>{{ item.title }}</template>
  14. </el-breadcrumb-item>
  15. </el-breadcrumb>
  16. </el-card>
  17. <el-card class="card-body">
  18. <slot></slot>
  19. </el-card>
  20. </div>
  21. </template>
  22. <script>
  23. Vue.component('com-list-page', {
  24. template: '#com-list-page',
  25. props: {
  26. crumbs: {
  27. type: Array,
  28. default: () => {
  29. return []
  30. }
  31. },
  32. },
  33. data() {
  34. return {
  35. }
  36. },
  37. computed: {
  38. getNavigateParams() {
  39. return function (item) {
  40. let obj = {
  41. r: item.router,
  42. }
  43. if (
  44. item.params &&
  45. typeof item.params === 'object' &&
  46. Object.keys(item.params).length > 0
  47. ) {
  48. obj = {...obj, ...item.params}
  49. }
  50. return obj
  51. }
  52. }
  53. }
  54. })
  55. </script>
  56. <style>
  57. #application {
  58. display: flex;
  59. flex-direction: column;
  60. height: 100%;
  61. }
  62. #application .card-breadcrumb {
  63. margin-bottom: 10px;
  64. }
  65. #application .page-body {
  66. display: flex;
  67. }
  68. #application .card-body {
  69. flex: 1;
  70. }
  71. #application .card-body .el-card__body {
  72. height: 100%;
  73. padding: 10px 20px;
  74. }
  75. .el-main {
  76. padding: 10px;
  77. }
  78. </style>