index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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">新增</el-button>
  6. <base-table
  7. :columns="columns"
  8. :items="items"
  9. :pagination="pagination"
  10. :page-change="pageChange"
  11. />
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import toolbar from './toolbar';
  17. import mxFilterList from '@/mixins/filterList';
  18. import { getPage, delItem, sendCode } from '@/api/scene';
  19. export default {
  20. name: 'SceneList',
  21. components: { toolbar },
  22. mixins: [
  23. mxFilterList({
  24. fetchList: getPage, // 在下方data再声明一个 fetchList: iGetList 同等效果
  25. internalFilterObj: {
  26. isDel: false,
  27. auditStatus: 1
  28. }
  29. })
  30. ],
  31. data() {
  32. return {
  33. columns: [
  34. {
  35. key: 'name',
  36. name: '机构名称',
  37. width: this.$col.b
  38. },
  39. {
  40. key: 'logo',
  41. name: 'Logo',
  42. width: this.$col.b,
  43. render: (h, { row }) =>
  44. h('img', {
  45. style: {
  46. width: '120px',
  47. height: '90px'
  48. },
  49. class: 'pre-img',
  50. attrs: {
  51. src: row.logo
  52. },
  53. on: {
  54. click: () =>
  55. this.$AdvanceViewImageModal({
  56. items: [{ src: row.logo }]
  57. })
  58. }
  59. })
  60. },
  61. {
  62. key: 'region',
  63. name: '所在地区',
  64. minWidth: this.$col.auto(200),
  65. render: (h, { row }) =>
  66. h('span', `${row.province}/${row.city}/${row.area}`)
  67. },
  68. {
  69. key: 'type',
  70. name: '机构类型',
  71. width: this.$col.b
  72. },
  73. {
  74. key: 'realName',
  75. name: '申请人',
  76. width: this.$col.m
  77. },
  78. {
  79. key: 'phonenumber',
  80. name: '办公号码',
  81. width: this.$col.b
  82. },
  83. {
  84. key: 'isShow',
  85. name: '状态',
  86. width: this.$col.s,
  87. type: 'tag',
  88. fetchTagType: val => (val ? 'success' : 'info'),
  89. tagName: row => (row.isShow ? '显示' : '隐藏')
  90. },
  91. {
  92. key: 'action',
  93. name: '操作',
  94. width: '180',
  95. render: (h, { row }) => {
  96. const action = [];
  97. action.push(
  98. h(
  99. 'el-button',
  100. {
  101. props: {
  102. type: 'text'
  103. },
  104. on: {
  105. click: () =>
  106. this.$SceneItemModal({
  107. id: row.id
  108. })
  109. }
  110. },
  111. '编辑'
  112. )
  113. );
  114. action.push(
  115. h(
  116. 'el-button',
  117. {
  118. props: {
  119. type: 'text'
  120. },
  121. on: {
  122. click: () =>
  123. this.handleSend({
  124. id: row.id
  125. })
  126. }
  127. },
  128. '发送邮件'
  129. )
  130. );
  131. action.push(
  132. h(
  133. 'BaseBtn',
  134. {
  135. props: {
  136. popip: true,
  137. txt: '删除',
  138. type: 'text'
  139. },
  140. class: 'ml-10',
  141. on: {
  142. ok: () => this.handleDelItem(row)
  143. }
  144. },
  145. '删除'
  146. )
  147. );
  148. return h('div', action);
  149. }
  150. }
  151. ]
  152. };
  153. },
  154. created() {
  155. this.$g_on('scene_reload', this.reload);
  156. },
  157. beforeDestroy() {
  158. this.$g_off('scene_reload', this.reload);
  159. },
  160. methods: {
  161. handleAdd() {
  162. this.$SceneItemModal();
  163. },
  164. async handleSend(item) {
  165. console.log(item.id);
  166. const { success, msg } = await sendCode({
  167. id: item.id
  168. });
  169. if (success) {
  170. this.$success('发送成功!');
  171. }
  172. },
  173. async handleDelItem(item) {
  174. const { success, msg } = await delItem({
  175. id: item.id
  176. });
  177. if (success) {
  178. this.$success('删除成功!');
  179. this.$g_emit('scene_reload');
  180. }
  181. }
  182. }
  183. };
  184. </script>
  185. <style type="scss" scoped></style>