index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <div class="">
  3. <div class="m-10 bg-w p-20 br-10">
  4. <div class="f-sa-s">
  5. <div class="f-fs-c f-col">
  6. <div style="font-size: 16px;">总量</div>
  7. <div class="mt-4" style="font-weight: bold; font-size: 18px;">
  8. {{ statistics.all }}
  9. </div>
  10. </div>
  11. <div class="f-fs-c f-col">
  12. <div style="font-size: 16px;">月新增</div>
  13. <div class="mt-4" style="font-weight: bold; font-size: 18px;">
  14. {{ statistics.month }}
  15. </div>
  16. </div>
  17. <div class="f-fs-c f-col">
  18. <div style="font-size: 16px;">周新增</div>
  19. <div class="mt-4" style="font-weight: bold; font-size: 18px;">
  20. {{ statistics.week }}
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. <toolbar @on-filter="filterData" @on-reset="filterData" />
  26. <div class="m-10 bg-w p-20 br-10">
  27. <el-button type="primary" icon="el-icon-plus" @click="handleAdd"
  28. >新增</el-button
  29. >
  30. <base-table
  31. :columns="columns"
  32. :items="items"
  33. :pagination="pagination"
  34. :page-change="pageChange"
  35. />
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. import toolbar from './toolbar';
  41. import mxFilterList from '@/mixins/filterList';
  42. import { getPage, getCount, delItem, sendCode } from '@/api/scene';
  43. export default {
  44. name: 'SceneList',
  45. components: { toolbar },
  46. mixins: [
  47. mxFilterList({
  48. fetchList: getPage, // 在下方data再声明一个 fetchList: iGetList 同等效果
  49. internalFilterObj: {
  50. isDel: false,
  51. auditStatus: 1
  52. }
  53. })
  54. ],
  55. data() {
  56. return {
  57. statistics: {},
  58. columns: [
  59. {
  60. key: 'name',
  61. name: '机构名称',
  62. width: this.$col.b
  63. },
  64. {
  65. key: 'logo',
  66. name: 'Logo',
  67. width: this.$col.b,
  68. render: (h, { row }) =>
  69. h('img', {
  70. style: {
  71. width: '120px',
  72. height: '90px'
  73. },
  74. class: 'pre-img',
  75. attrs: {
  76. src: row.logo
  77. },
  78. on: {
  79. click: () =>
  80. this.$AdvanceViewImageModal({
  81. items: [{ src: row.logo }]
  82. })
  83. }
  84. })
  85. },
  86. {
  87. key: 'region',
  88. name: '所在地区',
  89. minWidth: this.$col.auto(200),
  90. render: (h, { row }) =>
  91. h('span', `${row.province}/${row.city}/${row.area}`)
  92. },
  93. {
  94. key: 'type',
  95. name: '机构类型',
  96. width: this.$col.b
  97. },
  98. {
  99. key: 'realName',
  100. name: '申请人',
  101. width: this.$col.m
  102. },
  103. {
  104. key: 'phonenumber',
  105. name: '办公号码',
  106. width: this.$col.m
  107. },
  108. {
  109. key: 'isShow',
  110. name: '状态',
  111. width: this.$col.s,
  112. type: 'tag',
  113. fetchTagType: val => (val ? 'success' : 'info'),
  114. tagName: row => (row.isShow ? '显示' : '隐藏')
  115. },
  116. {
  117. key: 'action',
  118. name: '操作',
  119. width: '180',
  120. render: (h, { row }) => {
  121. const action = [];
  122. action.push(
  123. h(
  124. 'el-button',
  125. {
  126. props: {
  127. type: 'text'
  128. },
  129. on: {
  130. click: () =>
  131. this.$SceneItemModal({
  132. id: row.id
  133. })
  134. }
  135. },
  136. '编辑'
  137. )
  138. );
  139. action.push(
  140. h(
  141. 'el-button',
  142. {
  143. props: {
  144. type: 'text'
  145. },
  146. on: {
  147. click: () =>
  148. this.handleSend({
  149. id: row.id
  150. })
  151. }
  152. },
  153. '发送邮件'
  154. )
  155. );
  156. action.push(
  157. h(
  158. 'BaseBtn',
  159. {
  160. props: {
  161. popip: true,
  162. txt: '删除',
  163. type: 'text'
  164. },
  165. class: 'ml-10',
  166. on: {
  167. ok: () => this.handleDelItem(row)
  168. }
  169. },
  170. '删除'
  171. )
  172. );
  173. return h('div', action);
  174. }
  175. }
  176. ]
  177. };
  178. },
  179. created() {
  180. this.$g_on('scene_reload', this.reload);
  181. },
  182. beforeDestroy() {
  183. this.$g_off('scene_reload', this.reload);
  184. },
  185. methods: {
  186. handleAdd() {
  187. this.$SceneItemModal();
  188. },
  189. async handleSend(item) {
  190. const { success, msg } = await sendCode({
  191. id: item.id
  192. });
  193. if (success) {
  194. this.$success('发送成功!');
  195. }
  196. },
  197. async handleDelItem(item) {
  198. const { success, msg } = await delItem({
  199. id: item.id
  200. });
  201. if (success) {
  202. this.$success('删除成功!');
  203. this.$g_emit('scene_reload');
  204. }
  205. },
  206. async pageChange(page) {
  207. this.pagination.page = page;
  208. const inParams = {
  209. ...this.filter,
  210. ...this.internalFilterObj,
  211. limit: this.pagination.pageSize,
  212. start: this.pagination.page
  213. };
  214. const { data, msg } = await this.apiList(inParams);
  215. const res2 = await getCount(inParams);
  216. this.statistics = res2.data;
  217. if ('data' in data) {
  218. const items = data.data;
  219. if (items.length === 0 && this.pagination.page > 1) {
  220. this.pageChange(1);
  221. } else {
  222. this.items = items;
  223. this.pagination.total = data.total;
  224. }
  225. this.loadCallBack(data);
  226. }
  227. }
  228. }
  229. };
  230. </script>
  231. <style type="scss" scoped></style>