Examine.vue 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div
  3. v-loading="loading"
  4. class="main-container">
  5. <filtrate-handle-view
  6. title="审批分析"
  7. class="filtrate-bar"
  8. module-type="oa"
  9. @load="loading=true"
  10. @change="getDataList">
  11. <el-button
  12. class="export-button"
  13. type="primary"
  14. @click.native="exportExcel">导出</el-button>
  15. </filtrate-handle-view>
  16. <div class="content">
  17. <div class="table-content">
  18. <el-table
  19. v-if="showTable"
  20. :data="list"
  21. :height="tableHeight"
  22. :cell-style="cellStyle"
  23. stripe
  24. border
  25. show-overflow-tooltip
  26. highlight-current-row
  27. @row-click="handleRowClick"
  28. @sort-change="({ prop, order }) => mixinSortFn(list, prop, order)">
  29. <el-table-column
  30. v-for="(item, index) in fieldList"
  31. :key="index"
  32. :fixed="index==0"
  33. :formatter="fieldFormatter"
  34. :prop="item.field"
  35. :min-width="item.width"
  36. :label="item.name"
  37. sortable="custom"
  38. align="center"
  39. header-align="center"/>
  40. </el-table>
  41. </div>
  42. </div>
  43. <!-- 列表详情 -->
  44. <examine-list
  45. v-if="showList"
  46. :type="showType"
  47. :name="showTypeName"
  48. :request="indexRequest"
  49. :params="indexParams"
  50. @hide="showList = false"/>
  51. </div>
  52. </template>
  53. <script>
  54. import SortMixin from '../mixins/Sort'
  55. import {
  56. biExamineStatisticsAPI,
  57. biExamineExcelExportAPI,
  58. biExamineIndexAPI
  59. } from '@/api/bi/oa'
  60. import ExamineList from './components/ExamineList'
  61. import FiltrateHandleView from '../components/FiltrateHandleView'
  62. import { downloadExcelWithResData } from '@/utils'
  63. export default {
  64. /** 审批统计表 */
  65. name: 'ExamineStatistics',
  66. components: {
  67. FiltrateHandleView,
  68. ExamineList
  69. },
  70. mixins: [SortMixin],
  71. data() {
  72. return {
  73. loading: false,
  74. tableHeight: document.documentElement.clientHeight - 190,
  75. postParams: {},
  76. list: [],
  77. fieldList: [],
  78. // 列表详情
  79. typeList: [],
  80. indexParams: {},
  81. showType: '', // 标示类型
  82. showTypeName: '', // 类型名称
  83. showList: false
  84. }
  85. },
  86. computed: {
  87. // 列表详情请求
  88. indexRequest() {
  89. return biExamineIndexAPI
  90. }
  91. },
  92. mounted() {
  93. /** 控制table的高度 */
  94. window.onresize = () => {
  95. this.tableHeight = document.documentElement.clientHeight - 190
  96. }
  97. },
  98. methods: {
  99. /**
  100. * 列表数据
  101. */
  102. getDataList(params) {
  103. this.postParams = params
  104. this.loading = true
  105. biExamineStatisticsAPI(params)
  106. .then(res => {
  107. this.typeList = res.data.category_list || []
  108. this.fieldList = this.getFieldList(res.data.category_list || [])
  109. this.list = res.data.userList || []
  110. this.loading = false
  111. })
  112. .catch(() => {
  113. this.loading = false
  114. })
  115. },
  116. /**
  117. * 表头
  118. */
  119. getFieldList(list) {
  120. return [
  121. {
  122. name: '员工',
  123. width: 100,
  124. field: 'realname'
  125. }
  126. ].concat(
  127. list.map(item => {
  128. var width = 0
  129. if (item.title && item.title.length <= 6) {
  130. width = item.title.length * 15 + 45
  131. } else {
  132. width = 140
  133. }
  134. return {
  135. name: item.title,
  136. width: width,
  137. field: `count_${item.category_id}`
  138. }
  139. })
  140. )
  141. },
  142. /**
  143. * 格式化字段
  144. */
  145. fieldFormatter(row, column) {
  146. return row[column.property] === '' || row[column.property] === null ? '--' : row[column.property]
  147. },
  148. /**
  149. * 通过回调控制style
  150. */
  151. cellStyle({ row, column, rowIndex, columnIndex }) {
  152. if (column.property !== 'realname' && parseInt(row[column.property])) {
  153. return { color: '#2362FB', cursor: 'pointer' }
  154. } else {
  155. return ''
  156. }
  157. },
  158. /**
  159. * 列表的点击
  160. */
  161. handleRowClick(row, column, event) {
  162. if (column.property !== 'realname' && parseInt(row[column.property])) {
  163. const propertys = column.property.split('_')
  164. const category_id = propertys.length > 1 ? propertys[1] : ''
  165. const params = {
  166. user_id: row.id,
  167. category_id: category_id
  168. }
  169. if (this.postParams.type) {
  170. params.type = this.postParams.type
  171. } else {
  172. params.start_time = this.postParams.start_time
  173. params.end_time = this.postParams.end_time
  174. }
  175. const typeObj = this.typeList.find(item => {
  176. return item.category_id == category_id
  177. })
  178. this.showType = typeObj.type
  179. this.showTypeName = typeObj.title
  180. this.indexParams = params
  181. this.showList = true
  182. }
  183. },
  184. /**
  185. * 导出
  186. */
  187. exportExcel() {
  188. this.loading = true
  189. biExamineExcelExportAPI(this.postParams)
  190. .then(res => {
  191. this.loading = false
  192. downloadExcelWithResData(res)
  193. })
  194. .catch(() => {
  195. this.loading = false
  196. })
  197. }
  198. }
  199. }
  200. </script>
  201. <style rel="stylesheet/scss" lang="scss" scoped>
  202. @import '../styles/detail.scss';
  203. </style>