DelEDBTable.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <div class="del-table-wrap">
  3. <div>
  4. <img src="~@/assets/img/data_m/set_icon.png" alt="" style="cursor: pointer;float:right" @click="showSetTableCols=true">
  5. </div>
  6. <el-table
  7. v-loading="tableLoading"
  8. ref="tableIns"
  9. :data="tableData"
  10. border
  11. @sort-change="handleTableSortChange"
  12. >
  13. <el-table-column
  14. v-for="col in tableColOpts"
  15. :key="col.ColumnKey"
  16. :column-key="col.ColumnKey"
  17. :label="col.ColumnName"
  18. :prop="col.ColumnKey"
  19. :sortable="col.IsSort===1?'custom':false"
  20. align="center"
  21. :width="getColWidth(col.ColumnKey)"
  22. >
  23. <template slot="header" slot-scope="scope">
  24. <span>{{col.ColumnName}}</span>
  25. <el-tooltip
  26. effect="dark"
  27. :content="getTableHeadTips(col.ColumnKey)"
  28. placement="top-start"
  29. >
  30. <i class="el-icon-info" v-if="tipsKeysArr.includes(col.ColumnKey)"></i>
  31. </el-tooltip>
  32. </template>
  33. </el-table-column>
  34. <div slot="empty">
  35. <tableNoData text="暂无数据"/>
  36. </div>
  37. </el-table>
  38. <el-pagination
  39. layout="total,prev,pager,next,jumper"
  40. background
  41. @current-change="handleCurrentChange"
  42. :page-size="pageSize"
  43. :total="total"
  44. style="float: right;margin-top:20px"
  45. />
  46. <!-- 自定义列表 -->
  47. <SetTableCols v-model="showSetTableCols" :ColumnType="3" @change="handleTableColChange"/>
  48. </div>
  49. </template>
  50. <script>
  51. import {apiDataSource} from '@/api/modules/dataSource'
  52. import SetTableCols from './SetTableCols.vue'
  53. export default {
  54. components:{SetTableCols},
  55. data() {
  56. return {
  57. tipsKeysArr:['EdbNameSource','ErDataUpdateDate'],
  58. tableLoading:false,
  59. tableColOpts:[],
  60. tableData:[],
  61. pageSize:15,
  62. page:1,
  63. total:0,
  64. filterState:{
  65. sortKey:'',
  66. sortType:'',
  67. },
  68. showSetTableCols:false,
  69. }
  70. },
  71. created() {
  72. this.getTableColOpts()
  73. },
  74. methods: {
  75. //获取表格数据
  76. getTableList(){
  77. this.tableLoading=true
  78. apiDataSource.GLDelTableList({
  79. CurrentIndex:this.page,
  80. PageSize:this.pageSize,
  81. SortParam:this.filterState.sortKey,
  82. SortType:this.filterState.sortType,
  83. CreateTime:''
  84. }).then(res=>{
  85. this.tableLoading=false
  86. if(res.Ret===200){
  87. const arr=res.Data.List||[]
  88. this.tableData=arr
  89. this.total=res.Data.Paging.Totals
  90. }
  91. })
  92. },
  93. handleCurrentChange(e){
  94. this.page=e
  95. this.getTableList()
  96. },
  97. // 获取表格列配置项
  98. getTableColOpts(){
  99. this.tableColOpts=[]
  100. this.tableLoading=true
  101. apiDataSource.GLTableColOpts({ColumnType:3}).then(res=>{
  102. if(res.Ret===200){
  103. const arr=res.Data.List||[]
  104. this.tableColOpts=arr.filter(item=>item.IsShow===1)
  105. this.$nextTick(()=>{
  106. // this.$refs.tableIns.doLayout()
  107. this.tableLoading=false
  108. })
  109. this.getTableList()
  110. }
  111. })
  112. },
  113. handleTableColChange(){
  114. this.getTableColOpts()
  115. },
  116. handleShowSetTableCol(){
  117. this.showSetTableCols=true
  118. },
  119. // 筛选项刷新列表
  120. handleRefreshList(){
  121. this.page=1
  122. this.getTableList()
  123. },
  124. // 排序
  125. handleTableSortChange({column, prop, order}){
  126. console.log(column, prop, order);
  127. this.filterState.sortKey=prop
  128. this.filterState.sortType=order==='descending'?'desc':order==='ascending'?'asc':''
  129. this.handleRefreshList()
  130. },
  131. // table说明文案
  132. getTableHeadTips(key){
  133. const tipsMap={
  134. EdbNameSource:'指标在数据源的全称',
  135. ErDataUpdateDate:'指标数据发生变化的最早日期',
  136. }
  137. return tipsMap[key]
  138. },
  139. // 设置列的宽度
  140. getColWidth(key){
  141. const widthMap={
  142. DataUpdateTime:'150px',
  143. ErDataUpdateDate:'200px',
  144. StartDate:'150px',
  145. LatestDate:'150px',
  146. CreateTime:'150px'
  147. }
  148. return widthMap[key]
  149. }
  150. },
  151. }
  152. </script>
  153. <style lang="scss" scoped>
  154. .del-table-wrap{
  155. .top-wrap{
  156. display: flex;
  157. justify-content: flex-end;
  158. margin-bottom: 30px;
  159. .set-icon{
  160. width: 40px;
  161. cursor: pointer;
  162. }
  163. }
  164. }
  165. </style>