index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div class="">
  3. <toolbar @on-filter="filterData" @on-reset="filterData" />
  4. <div class="m-10 bg-w p-20 br-10">
  5. <el-button type="primary" icon="el-icon-plus" @click="handleAdd"
  6. >新增</el-button
  7. >
  8. <base-table
  9. :columns="columns"
  10. :items="items"
  11. :pagination="pagination"
  12. :page-change="pageChange"
  13. />
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import toolbar from './toolbar';
  19. import mxFilterList from '@/mixins/filterList';
  20. import { getPage, delItem } from '@/api/activity';
  21. export default {
  22. name: 'EventsList',
  23. components: { toolbar },
  24. mixins: [
  25. mxFilterList({
  26. fetchList: getPage // 在下方data再声明一个 fetchList: iGetList 同等效果
  27. })
  28. ],
  29. data() {
  30. return {
  31. columns: [
  32. {
  33. key: 'kindergartenName',
  34. name: '场景',
  35. width: this.$col.b
  36. },
  37. {
  38. key: 'name',
  39. name: '活动名称',
  40. minWidth: this.$col.b
  41. },
  42. {
  43. key: 'cover',
  44. name: '封面',
  45. width: this.$col.b,
  46. render: (h, { row }) =>
  47. h('img', {
  48. style: {
  49. width: '160px',
  50. height: '90px'
  51. },
  52. class: 'pre-img',
  53. attrs: {
  54. src: row.cover
  55. },
  56. on: {
  57. click: () =>
  58. this.$AdvanceViewImageModal({
  59. items: [{ src: row.cover }]
  60. })
  61. }
  62. })
  63. },
  64. {
  65. key: 'time',
  66. name: '活动时间',
  67. width: this.$col.auto(260),
  68. render: (h, { row }) =>
  69. h('span', `${row.eventStartDate}~${row.eventEndDate}`)
  70. },
  71. {
  72. key: 'isShow',
  73. name: '状态',
  74. width: this.$col.s,
  75. type: 'tag',
  76. fetchTagType: val => (val ? 'success' : 'info'),
  77. tagName: row => (row.isShow ? '显示' : '隐藏')
  78. },
  79. {
  80. key: 'action',
  81. name: '操作',
  82. width: '120',
  83. render: (h, { row }) => {
  84. const action = [];
  85. action.push(
  86. h(
  87. 'el-button',
  88. {
  89. props: {
  90. type: 'text'
  91. },
  92. on: {
  93. click: () =>
  94. this.$ActivityItemModal({
  95. id: row.id
  96. })
  97. }
  98. },
  99. '编辑'
  100. )
  101. );
  102. action.push(
  103. h(
  104. 'BaseBtn',
  105. {
  106. props: {
  107. popip: true,
  108. txt: '删除',
  109. type: 'text'
  110. },
  111. class: 'ml-10',
  112. on: {
  113. ok: () => this.handleDelItem(row)
  114. }
  115. },
  116. '删除'
  117. )
  118. );
  119. return h('div', action);
  120. }
  121. }
  122. ]
  123. };
  124. },
  125. created() {
  126. this.$g_on('activity_reload', this.reload);
  127. },
  128. beforeDestroy() {
  129. this.$g_off('activity_reload', this.reload);
  130. },
  131. methods: {
  132. handleAdd() {
  133. this.$ActivityItemModal();
  134. },
  135. async handleDelItem(item) {
  136. const { success, msg } = await delItem({
  137. id: item.id
  138. });
  139. if (success) {
  140. this.$success('删除成功!');
  141. this.$g_emit('activity_reload');
  142. }
  143. }
  144. }
  145. };
  146. </script>
  147. <style type="scss" scoped></style>