CardAction.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <section id="card-actions">
  3. <b-row>
  4. <b-col cols="12">
  5. <b-card-actions ref="cardAction" title="ability test" @refresh="refreshStop('cardAction')">
  6. <b-row>
  7. <b-col cols="12">
  8. <div v-if="checkAbility">
  9. <b-table responsive :items="messages" bordered>
  10. <template #cell(ICON)="data" class="text-center">
  11. <div class="text-center">
  12. <feather-icon :icon="data.value" />
  13. </div>
  14. </template>
  15. </b-table>
  16. </div>
  17. <div v-else>沒權限</div>
  18. </b-col>
  19. </b-row>
  20. </b-card-actions>
  21. </b-col>
  22. <b-col md="6" v-for="message in messages" :key="message.id">
  23. <b-card :img-src="require('@/assets/images/slider/01.jpg')" img-alt="Card image" img-top no-body>
  24. <!-- body -->
  25. <b-card-body>
  26. <b-card-title>{{ message.title }}</b-card-title>
  27. <b-card-text>
  28. {{ message.content }}
  29. </b-card-text>
  30. </b-card-body>
  31. <!-- card links -->
  32. <b-card-body>
  33. <b-card-text>
  34. {{ message.name }} - {{ message.updated_at }}
  35. </b-card-text>
  36. <b-link class="card-link">
  37. 詳細內容
  38. </b-link>
  39. </b-card-body>
  40. </b-card>
  41. </b-col>
  42. <b-col md="6" lg="6">
  43. <b-card :img-src="require('@/assets/images/slider/01.jpg')" img-alt="Card image" img-top no-body>
  44. <!-- body -->
  45. <b-card-body>
  46. <b-card-title>Card title</b-card-title>
  47. <b-card-text>
  48. Some quick example text to build on the card title.
  49. </b-card-text>
  50. </b-card-body>
  51. <!-- kitchen sink link -->
  52. <b-list-group flush>
  53. <b-list-group-item v-for="data in kitchenSinkList" :key="data.text">
  54. {{ data.text }}
  55. </b-list-group-item>
  56. </b-list-group>
  57. <!-- card links -->
  58. <b-card-body>
  59. <b-link class="card-link">
  60. Card link
  61. </b-link>
  62. <b-link class="card-link">
  63. Another link
  64. </b-link>
  65. </b-card-body>
  66. </b-card>
  67. </b-col>
  68. <!-- card collapsible -->
  69. <b-col md="6">
  70. <b-card-actions title="Collapsible" action-collapse>
  71. <b-card-text>
  72. <span>You can create a collapsible content by adding </span>
  73. <code>actionCollapse</code>
  74. <span> prop in </span>
  75. <code>&lt;b-card-actions&gt;</code>
  76. </b-card-text>
  77. <b-card-text>
  78. <span>Click on </span>
  79. <feather-icon icon="ChevronDownIcon" />
  80. <span> to see card collapse in action.</span>
  81. </b-card-text>
  82. </b-card-actions>
  83. </b-col>
  84. <!-- card refresh -->
  85. <b-col md="6">
  86. <b-card-actions ref="refreshCard" title="Refresh Content" action-refresh
  87. @refresh="refreshStop('refreshCard')">
  88. <b-card-text>
  89. To create a card with refresh action use <code>actionRefresh</code> prop along with
  90. <code>&lt;b-card-actions&gt;</code>
  91. </b-card-text>
  92. <b-card-text>
  93. <span>Click on </span>
  94. <feather-icon icon="RotateCwIcon" />
  95. <span> icon to see refresh card content in action.</span>
  96. </b-card-text>
  97. </b-card-actions>
  98. </b-col>
  99. <!-- card remove -->
  100. <b-col md="6">
  101. <b-card-actions title="Remove Card" action-close>
  102. <b-card-text>
  103. You can create a closeable card by using <code>actionClose</code> prop along with
  104. <code>&lt;b-card-actions&gt;</code>
  105. </b-card-text>
  106. <b-card-text>
  107. <span>Click on </span>
  108. <feather-icon icon="XIcon" />
  109. <span> icon to see closeable card in action.</span>
  110. </b-card-text>
  111. </b-card-actions>
  112. </b-col>
  113. </b-row>
  114. </section>
  115. </template>
  116. <script>
  117. import BCardActions from '@core/components/b-card-actions/BCardActions.vue'
  118. import {
  119. BTable, BRow, BCol, BCard, BCardText, BLink, BListGroup, BListGroupItem, BCardTitle, BCardBody,
  120. } from 'bootstrap-vue'
  121. import useJwt from '@/auth/jwt/useJwt'
  122. import ability from '../libs/acl/ability'
  123. export default {
  124. components: {
  125. BCardActions,
  126. BTable,
  127. BRow,
  128. BCol,
  129. BCard,
  130. BCardText,
  131. BLink,
  132. BCardTitle,
  133. BListGroup,
  134. BListGroupItem,
  135. BCardBody,
  136. },
  137. data() {
  138. return {
  139. fields: [
  140. 'ACTION',
  141. { key: 'ICON', label: 'ICON' },
  142. 'DETAILS',
  143. ],
  144. show: false,
  145. messages: [],
  146. kitchenSinkList: [
  147. { text: 'Cras justo odio' },
  148. { text: 'Vestibulum at eros' },
  149. ],
  150. }
  151. },
  152. computed: {
  153. checkAbility() {
  154. return ability.can('read', 'management')
  155. },
  156. },
  157. created() {
  158. useJwt.getMessages({ number: 2 })
  159. .then(res => {
  160. this.messages = res.data
  161. })
  162. },
  163. methods: {
  164. // stop refreshing card in 3 sec
  165. refreshStop(cardName) {
  166. setTimeout(() => {
  167. this.$refs[cardName].showLoading = false
  168. }, 3000)
  169. },
  170. },
  171. }
  172. </script>