index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <!--
  2. @name:数据预览弹窗
  3. @description:
  4. @author: liu.shiyi
  5. @time:
  6. -->
  7. <template>
  8. <div class="bs-data-view-dialog">
  9. <el-dialog
  10. :close-on-click-modal="false"
  11. title="数据查看"
  12. :visible.sync="formVisible"
  13. :append-to-body="false"
  14. class="bs-dialog-wrap bs-el-dialog"
  15. >
  16. <el-table
  17. ref="table"
  18. v-loading="loading"
  19. class="bs-table bs-el-table"
  20. height="300"
  21. :data="dataList"
  22. >
  23. <el-table-column
  24. v-for="(col,index) in columnData"
  25. :key="index"
  26. show-overflow-tooltip
  27. :prop="col.alias"
  28. :label="getLabel(col)"
  29. align="center"
  30. />
  31. </el-table>
  32. <div
  33. slot="footer"
  34. class="dialog-footer"
  35. >
  36. <el-button
  37. type="primary"
  38. :loading="sureLoading"
  39. @click="exportHandler"
  40. >
  41. 导出数据
  42. </el-button>
  43. </div>
  44. </el-dialog>
  45. </div>
  46. </template>
  47. <script>
  48. import { getChatInfo, getUpdateChartInfo } from 'data-room-ui/js/api/bigScreenApi'
  49. import { mapState } from 'vuex'
  50. export default {
  51. name: 'DataViewDialog',
  52. components: {},
  53. props: {
  54. },
  55. data () {
  56. return {
  57. formVisible: false,
  58. sureLoading: false,
  59. loading: false,
  60. dataList: [],
  61. columnData: []
  62. }
  63. },
  64. computed: {
  65. ...mapState({
  66. pageCode: state => state.bigScreen.pageInfo.code
  67. })
  68. },
  69. watch: {},
  70. created () {
  71. },
  72. mounted () {
  73. },
  74. methods: {
  75. init (config) {
  76. this.resetData()
  77. this.formVisible = true
  78. this.getDataList(config)
  79. },
  80. // 获取数据列表
  81. getDataList (config) {
  82. this.loading = true
  83. if (config.type === 'customComponent' && (!config.dataSource.businessKey)) {
  84. const list = config.option.data
  85. this.columnData = (Object.keys(list[0])).map((key) => {
  86. return {
  87. aggregate: '',
  88. alias: key,
  89. originalColumn: key,
  90. remark: key,
  91. tableName: '',
  92. type: 'varchar'
  93. }
  94. })
  95. this.dataList = list
  96. this.loading = false
  97. } else {
  98. const params = {
  99. chart: {
  100. ...config,
  101. option: undefined
  102. },
  103. current: 1,
  104. pageCode: this.pageCode,
  105. type: config.type
  106. }
  107. getUpdateChartInfo(params).then(res => {
  108. this.loading = false
  109. this.dataList = res.data || []
  110. this.columnData = res.columnData || []
  111. }).catch(err => { console.log(err) }).finally(() => {
  112. this.loading = false
  113. })
  114. }
  115. },
  116. getLabel (col) {
  117. return col.remark || col.originalColumn
  118. },
  119. // 数据重置
  120. resetData () {
  121. this.columnData = []
  122. this.dataList = []
  123. },
  124. // 导出数据
  125. exportHandler () {
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. .bs-data-view-dialog{
  132. /deep/.el-dialog__body{
  133. background-color: var(--bs-background-2) !important;
  134. }
  135. .el-table th.el-table__cell.is-leaf, .el-table /deep/td.el-table__cell{
  136. border-bottom:none;
  137. }
  138. }
  139. </style>