index.vue 5.9 KB

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