index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <div class="box">
  3. <div class="box_wrapper">
  4. <SearchBoxVue :data="searchData" :type_name="type_name" @search="handleSearch" />
  5. <TableBoxVue :loading="loading" :data="tableData" :type_name="type_name" :search="searchData" :hospital_name="searchData.hospital_name" @export="handelExport" style="margin-top: -40px;" />
  6. <div style="overflow: hidden;">
  7. <el-pagination
  8. v-if="tableData && tableData.length !== 0"
  9. :total="paginationData.total"
  10. background
  11. class="table-pagination"
  12. :page-size="paginationData.limit"
  13. :current-page.sync="paginationData.page"
  14. layout="total, sizes, prev, pager, next, jumper"
  15. @size-change="SizeChangeEvent"
  16. @current-change="pageHasChanged"
  17. />
  18. </div>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. import SearchBoxVue from '../frontHome/components/SearchBox.vue'
  24. import TableBoxVue from '../frontHome/components/TableBox.vue'
  25. import { errorDataLCExport } from '@/api/excel'
  26. import { dateFormat, getDaysInMonth } from '@/utils'
  27. export default {
  28. components: {
  29. SearchBoxVue,
  30. TableBoxVue
  31. },
  32. data() {
  33. return {
  34. type_name:'lc',
  35. loading: false,
  36. searchData: {
  37. hospital_name:"",// 医院名称
  38. start_time: '',
  39. end_time: '',
  40. level: '',
  41. type: '',
  42. desc: '',
  43. field: '',
  44. },
  45. HospitalList: [], //医院名称列表
  46. tableData: [],
  47. paginationData: {
  48. total: 0,
  49. page: 1,
  50. limit: 10
  51. }
  52. }
  53. },
  54. created() {
  55. this.searchData.hospital_name = this.$route.query.hospital_name?this.$route.query.hospital_name:'';
  56. // 设置默认时间
  57. const currentYear = new Date().getFullYear()
  58. this.searchData.start_time = `${currentYear}0101`
  59. this.searchData.end_time = dateFormat(new Date(), 'YYYYMMDD')
  60. this.getList();
  61. },
  62. methods: {
  63. getList() {
  64. const {
  65. page,
  66. limit
  67. } = this.paginationData
  68. const {
  69. hospital_name,
  70. start_time,
  71. end_time,
  72. level,
  73. type,
  74. desc,
  75. field
  76. } = this.searchData
  77. const days = getDaysInMonth(end_time.slice(0, 4), end_time.slice(4, 6))
  78. const dayStr = days < 10 ? `0${days}` : days
  79. const params = {
  80. hospital_name,
  81. level,
  82. type,
  83. desc,
  84. field,
  85. start_time: start_time.length === 8 ? start_time : `${start_time}01`,
  86. end_time: `${end_time.slice(0, 4)}${end_time.slice(4, 6)}${dayStr}`,
  87. page,
  88. page_size: limit
  89. }
  90. this.$axios.post('/home_sz_quality/errorData', params).then(res => {
  91. this.tableData = res.data.list
  92. this.paginationData.total = res.data.count
  93. });
  94. },
  95. SizeChangeEvent(val) {
  96. this.paginationData.limit = val
  97. this.getList()
  98. },
  99. pageHasChanged(val) {
  100. this.paginationData.page = val
  101. this.getList()
  102. },
  103. handleSearch() {
  104. this.paginationData.page = 1
  105. this.getList()
  106. },
  107. handelExport() {
  108. errorDataLCExport({ ...this.searchData, is_export: 1}).then(res => {
  109. const content = res.data; // 后台返回二进制数据
  110. const blob = new Blob([content]);
  111. const fileName = `缺陷问题.csv`;
  112. if ('download' in document.createElement('a')) {
  113. // 非IE下载
  114. const elink = document.createElement('a');
  115. elink.download = fileName;
  116. elink.style.display = 'none';
  117. elink.href = URL.createObjectURL(blob);
  118. document.body.appendChild(elink);
  119. elink.click();
  120. URL.revokeObjectURL(elink.href); // 释放URL 对象
  121. document.body.removeChild(elink);
  122. } else {
  123. // IE10+下载
  124. navigator.msSaveBlob(blob, fileName);
  125. }
  126. });
  127. },
  128. }
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. .box {
  133. padding: 0 16px 16px 16px;
  134. .box_wrapper {
  135. padding: 16px;
  136. padding: 16px;
  137. background: #fff;
  138. border-radius: 5px;
  139. position: relative;
  140. }
  141. .table-pagination {
  142. float: right;
  143. }
  144. }
  145. </style>