Link.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div>
  3. <el-card>
  4. <div slot="header" class="clearfix">
  5. <span>外部应用导航</span>
  6. <el-button class="header-more-btn" type="text" @click="showMore">更多<i class="el-icon-arrow-right" /></el-button>
  7. </div>
  8. <div class="link-content">
  9. <div class="link-box">
  10. <div class="link-item-box">
  11. <a v-for="item in tableData" :key="item.id" class="link-item" :href="item.url" target="_blank">
  12. {{ item.designation }}
  13. </a>
  14. </div>
  15. </div>
  16. <div class="link-btn">
  17. <el-button type="text" @click="showAdd">添加</el-button>
  18. </div>
  19. </div>
  20. </el-card>
  21. <link-add ref="linkAdd" @refreshData="getTablelist" />
  22. <link-list ref="linkList" />
  23. </div>
  24. </template>
  25. <script>
  26. import { fetchLinkList } from '@/api/link'
  27. import { hasValidRecords } from '@/utils/convert'
  28. import LinkAdd from './components/LinkAdd'
  29. import LinkList from './components/LinkList'
  30. export default {
  31. name: 'HomeLink',
  32. components: {
  33. LinkAdd,
  34. LinkList
  35. },
  36. data() {
  37. return {
  38. // table
  39. tableData: [],
  40. loading: false
  41. }
  42. },
  43. created() {
  44. this.getTablelist()
  45. },
  46. methods: {
  47. // 获取table数据
  48. getTablelist() {
  49. this.loading = true
  50. const params = {
  51. page: 1,
  52. size: 6,
  53. order: 'create_time',
  54. params: {
  55. delFlag: 0
  56. }
  57. }
  58. fetchLinkList(params).then(response => {
  59. this.loading = false
  60. if (hasValidRecords(response)) {
  61. this.tableData = response.data.records
  62. } else {
  63. this.tableData = []
  64. }
  65. }).catch(error => {
  66. console.log(error)
  67. this.loading = false
  68. this.$message({
  69. type: 'error',
  70. duration: 0,
  71. showClose: true,
  72. message: '获取消息列表出错: ' + error.message
  73. })
  74. })
  75. },
  76. showAdd() {
  77. this.$refs['linkAdd'].open()
  78. },
  79. showMore() {
  80. this.$refs['linkList'].open()
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. .link-content {
  87. height: calc(100% - 40px) !important;
  88. margin: 20px 0;
  89. background-color: rgba(0,0,0,0.02);
  90. display: flex;
  91. align-items: center;
  92. }
  93. .link-box {
  94. width: calc(100% - 60px);
  95. height: 100%;
  96. display: inline-block;
  97. }
  98. .link-item-box {
  99. height: 100%;
  100. display: flex;
  101. justify-content: space-around;
  102. overflow: hidden;
  103. flex-wrap: wrap;
  104. }
  105. .link-item {
  106. display: flex;
  107. align-items: center;
  108. height: 100%;
  109. font-size: 14px;
  110. color: rgba(0,0,0,0.85);
  111. &+.link-item {
  112. margin-left: 20px;
  113. }
  114. }
  115. .link-btn {
  116. display: inline-block;
  117. width: 60px;
  118. text-align: center;
  119. }
  120. </style>