index.vue 5.0 KB

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