index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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: 'cover',
  39. name: '封面',
  40. width: this.$col.b,
  41. render: (h, { row }) =>
  42. h('img', {
  43. style: {
  44. width: '160px',
  45. height: '90px'
  46. },
  47. class: 'pre-img',
  48. attrs: {
  49. src: row.cover
  50. },
  51. on: {
  52. click: () =>
  53. this.$AdvanceViewImageModal({
  54. items: [{ src: row.cover }]
  55. })
  56. }
  57. })
  58. },
  59. {
  60. key: 'name',
  61. name: '活动名称',
  62. minWidth: this.$col.b
  63. },
  64. {
  65. key: 'createBy',
  66. name: '创建者',
  67. width: this.$col.m
  68. },
  69. {
  70. key: 'time',
  71. name: '活动时间',
  72. width: this.$col.auto(260),
  73. render: (h, { row }) =>
  74. h('span', `${row.eventStartDate}~${row.eventEndDate}`)
  75. },
  76. {
  77. key: 'isShow',
  78. name: '状态',
  79. width: this.$col.s,
  80. type: 'tag',
  81. fetchTagType: val => (val ? 'success' : 'info'),
  82. tagName: row => (row.isShow ? '显示' : '隐藏')
  83. },
  84. {
  85. key: 'action',
  86. name: '操作',
  87. width: '120',
  88. render: (h, { row }) => {
  89. const action = [];
  90. action.push(
  91. h(
  92. 'el-button',
  93. {
  94. props: {
  95. type: 'text'
  96. },
  97. on: {
  98. click: () =>
  99. this.$ActivityItemModal({
  100. id: row.id
  101. })
  102. }
  103. },
  104. '编辑'
  105. )
  106. );
  107. action.push(
  108. h(
  109. 'BaseBtn',
  110. {
  111. props: {
  112. popip: true,
  113. txt: '删除',
  114. type: 'text'
  115. },
  116. class: 'ml-10',
  117. on: {
  118. ok: () => this.handleDelItem(row)
  119. }
  120. },
  121. '删除'
  122. )
  123. );
  124. return h('div', action);
  125. }
  126. }
  127. ]
  128. };
  129. },
  130. created() {
  131. this.$g_on('activity_reload', this.reload);
  132. },
  133. beforeDestroy() {
  134. this.$g_off('activity_reload', this.reload);
  135. },
  136. methods: {
  137. handleAdd() {
  138. this.$ActivityItemModal();
  139. },
  140. async handleDelItem(item) {
  141. const { success, msg } = await delItem({
  142. id: item.id
  143. });
  144. if (success) {
  145. this.$success('删除成功!');
  146. this.$g_emit('activity_reload');
  147. }
  148. }
  149. }
  150. };
  151. </script>
  152. <style type="scss" scoped></style>