ProductSatisfaction.vue 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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="contract"
  9. @load="loading=true"
  10. @change="getDataList">
  11. <el-button
  12. class="export-button"
  13. type="primary"
  14. @click.native="exportClick">导出</el-button>
  15. </filtrate-handle-view>
  16. <div class="content">
  17. <div class="table-content">
  18. <el-table
  19. :data="list"
  20. :height="tableHeight"
  21. stripe
  22. border
  23. highlight-current-row
  24. @sort-change="({ prop, order }) => mixinSortFn(list, prop, order)">
  25. <el-table-column
  26. v-for="(item, index) in fieldList"
  27. :key="index"
  28. :prop="item.field"
  29. :label="item.name"
  30. sortable="custom"
  31. align="center"
  32. header-align="center"
  33. show-overflow-tooltip/>
  34. </el-table>
  35. </div>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. import SortMixin from '../mixins/Sort'
  41. import BaseMixin from '../mixins/Base'
  42. import { biCustomerProductSatisfactionTableAPI, biCustomerProductSatisfactionExportAPI } from '@/api/bi/customer'
  43. import FiltrateHandleView from '../components/FiltrateHandleView'
  44. export default {
  45. /** 产品满意度分析 */
  46. name: 'ProductSatisfaction',
  47. components: {
  48. FiltrateHandleView
  49. },
  50. mixins: [BaseMixin, SortMixin],
  51. data() {
  52. return {
  53. loading: false,
  54. tableHeight: document.documentElement.clientHeight - 200,
  55. postParams: {}, // 筛选参数
  56. list: [],
  57. fieldList: []
  58. }
  59. },
  60. computed: {},
  61. mounted() {
  62. /** 控制table的高度 */
  63. window.onresize = () => {
  64. this.tableHeight = document.documentElement.clientHeight - 200
  65. }
  66. },
  67. methods: {
  68. getDataList(params) {
  69. this.postParams = params
  70. this.loading = true
  71. biCustomerProductSatisfactionTableAPI(params)
  72. .then(res => {
  73. const list = res.data || []
  74. if (this.fieldList.length == 0 && list.length > 0) {
  75. const firstItem = list[0]
  76. const baseFields = [
  77. { field: 'productName', name: '产品名称' },
  78. { field: 'visitNum', name: '回访次数' }
  79. ]
  80. const otherFields = []
  81. for (const key in firstItem) {
  82. if (key !== 'productName' && key !== 'visitNum') {
  83. otherFields.push({ field: key, name: key })
  84. }
  85. }
  86. this.fieldList = baseFields.concat(otherFields)
  87. }
  88. this.list = list
  89. this.loading = false
  90. })
  91. .catch(() => {
  92. this.loading = false
  93. })
  94. },
  95. /**
  96. * 导出点击
  97. */
  98. exportClick() {
  99. this.requestExportInfo(biCustomerProductSatisfactionExportAPI, this.postParams, 'productSatisfaction')
  100. }
  101. }
  102. }
  103. </script>
  104. <style rel="stylesheet/scss" lang="scss" scoped>
  105. @import '../styles/detail.scss';
  106. .content-title {
  107. padding-bottom: 15px;
  108. .special {
  109. font-weight: bold;
  110. margin-right: 3px;
  111. }
  112. }
  113. </style>