statList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <div id="statList">
  3. <el-row>
  4. <el-col :span="24" class="index">
  5. <el-col :span="24" class="top">
  6. <topInfo :topTitle="pageTitle"></topInfo>
  7. </el-col>
  8. </el-col>
  9. <el-col :span="24" class="add" style="text-align:right">
  10. <el-button size="mini" type="primary" @click="excelBtn()" icon="el-icon-plus">导出</el-button>
  11. </el-col>
  12. <el-col :span="24" class="info">
  13. <data-table :fields="fields" :data="list" :opera="opera" :total="total" @query="searchInfo"></data-table>
  14. </el-col>
  15. </el-row>
  16. </div>
  17. </template>
  18. <script>
  19. import topInfo from '@/layout/public/top.vue';
  20. import dataTable from '@/components/data-table.vue';
  21. import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
  22. const { mapActions: lookuser } = createNamespacedHelpers('lookuser');
  23. export default {
  24. name: 'statList',
  25. props: {},
  26. components: {
  27. topInfo,
  28. dataTable,
  29. },
  30. data: () => ({
  31. opera: [],
  32. fields: [
  33. { label: '房间号', prop: 'roomname' },
  34. { label: '观看用户', prop: 'username' },
  35. { label: '身份证号', prop: 'idnumber' },
  36. { label: '年龄', prop: 'age' },
  37. { label: '性别', prop: 'gender' },
  38. { label: '手机号', prop: 'phone' },
  39. { label: '所在地', prop: 'address' },
  40. { label: '医院', prop: 'hosname' },
  41. { label: '科室', prop: 'deptname' },
  42. { label: '职务', prop: 'level' },
  43. { label: '专业', prop: 'major' },
  44. { label: '是否基层', prop: 'isjc' },
  45. { label: '是否授予学分', prop: 'isxf' },
  46. { label: '观看时间', prop: 'createtime' },
  47. ],
  48. list: [],
  49. total: 0,
  50. }),
  51. created() {
  52. this.searchInfo();
  53. },
  54. methods: {
  55. ...lookuser(['query']),
  56. async searchInfo({ skip = 0, limit = 10, ...info } = {}) {
  57. const res = await this.query({ skip, limit, roomname: this.name, ...info });
  58. if (this.$checkRes(res)) {
  59. this.$set(this, `list`, res.data);
  60. this.$set(this, `total`, res.total);
  61. }
  62. },
  63. // 导出
  64. excelBtn() {
  65. require.ensure([], () => {
  66. const { export_json_to_excel } = require('@/excel/Export2Excel');
  67. const tHeader = [
  68. '房间号',
  69. '观看用户',
  70. '身份证号',
  71. '年龄',
  72. '性别',
  73. '手机号',
  74. '所在地',
  75. '医院',
  76. '科室',
  77. '职务',
  78. '专业',
  79. '是否基层',
  80. '是否授予学分',
  81. '观看时间',
  82. ];
  83. const filterVal = [
  84. 'roomname',
  85. 'username',
  86. 'idnumber',
  87. 'age',
  88. 'gender',
  89. 'phone',
  90. 'address',
  91. 'hosname',
  92. 'deptname',
  93. 'level',
  94. 'major',
  95. 'isjc',
  96. 'isxf',
  97. 'createtime',
  98. ];
  99. const list = this.list;
  100. const data = this.formatJson(filterVal, list);
  101. export_json_to_excel(tHeader, data);
  102. });
  103. },
  104. formatJson(filterVal, jsonData) {
  105. return jsonData.map(v => filterVal.map(j => v[j]));
  106. },
  107. },
  108. computed: {
  109. ...mapState(['user']),
  110. id() {
  111. return this.$route.query.id;
  112. },
  113. name() {
  114. return this.$route.query.name;
  115. },
  116. pageTitle() {
  117. return `${this.$route.meta.title}`;
  118. },
  119. },
  120. metaInfo() {
  121. return { title: this.$route.meta.title };
  122. },
  123. };
  124. </script>
  125. <style lang="less" scoped>
  126. .add {
  127. height: 40px;
  128. line-height: 35px;
  129. padding: 0 15px;
  130. }
  131. </style>