index.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <div class="demo">
  3. <div v-if="btns.length" class="contens1 btns">
  4. <div class="btns flex-wrap">
  5. <div v-for="(item,index) in btns" :key="index">
  6. <template v-if="item.show_type == 1">
  7. <el-button @click="handleClick(item)">{{ item.auth_name }}</el-button>
  8. </template>
  9. <template v-else-if="item.show_type == 2">
  10. <el-button :icon="item.show_icon" @click="handleClick(item)"></el-button>
  11. </template>
  12. <template v-else-if="item.show_type == 3">
  13. <el-button :icon="item.show_icon" @click="handleClick(item)">{{ item.auth_name }}</el-button>
  14. </template>
  15. </div>
  16. </div>
  17. </div>
  18. <div v-if="flag" :style="{ height:btns.length ? 'calc(100% - 60px)' : '100%' }" class="contents2">
  19. <Table />
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import { getAuthData } from '@/utils/validate'
  25. import Table from '../table/index.vue'
  26. export default {
  27. name: 'Demo',
  28. components: { Table },
  29. data () {
  30. return {
  31. type: null,
  32. title: '',
  33. btns: [],
  34. flag: false
  35. }
  36. },
  37. created () {
  38. const { title, auth_id } = this.$route.meta
  39. const { type, arrs } = getAuthData(auth_id)
  40. const table = arrs.filter(item => item.auth_type == 4)
  41. const btns = arrs.filter(item => item.auth_type != 4)
  42. this.type = type
  43. if (btns && btns.length) {
  44. this.btns = btns
  45. }
  46. if (table && table.length) {
  47. this.flag = true
  48. }
  49. this.title = title
  50. },
  51. methods: {
  52. handleClick (item) {
  53. switch (item.open_method) {
  54. case '1':
  55. this.$message.success('平铺')
  56. break;
  57. case '2':
  58. this.$router.push(item.route_info)
  59. break;
  60. case '3':
  61. this.$message.success('弹框')
  62. break;
  63. default:
  64. break;
  65. }
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. .demo {
  72. padding: 24px;
  73. height: calc(100vh - 100px);
  74. .btns {
  75. margin-bottom: 20px;
  76. > div {
  77. margin-right: 20px;
  78. }
  79. }
  80. }
  81. </style>