DatabankBase.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <!-- 数据宝页面 -->
  3. <div class="data-bank-base-wrap">
  4. <div class="select-box">
  5. <el-radio-group v-model="choosedSource" size="medium" @input="handleCurrentChange(1)">
  6. <el-radio-button v-for="source in sourceList"
  7. :key="source.EdbSourceId"
  8. :label="source.EdbSourceId">{{source.SourceName}}</el-radio-button>
  9. </el-radio-group>
  10. <el-select v-model="selectValue" @change="handleCurrentChange(1)"
  11. placeholder="请选择频度"
  12. clearable
  13. style="width:240px;margin-left: auto;">
  14. <el-option v-for="item in frequencyList"
  15. :key="item" :value="item" :label="item" />
  16. </el-select>
  17. <el-input v-model="inputValue" @input="handleCurrentChange(1)"
  18. placeholder="指标ID/指标名称"
  19. clearable
  20. prefix-icon="el-icon-search"
  21. style="width:240px;margin-left:30px;"></el-input>
  22. </div>
  23. <div class="table-box">
  24. <el-table :data="tableData" border @sort-change="sortChange"
  25. v-loading="tableLoading" element-loading-text="数据加载中...">
  26. <el-table-column v-for="column in tableColumnList"
  27. align="center"
  28. :key="column.key"
  29. :label="column.label"
  30. :prop="column.key"
  31. :min-width="column.minWidth"
  32. :sortable="column.sortable"></el-table-column>
  33. <div class="empty-box" slot="empty">
  34. <tableNoData text="暂无数据"/>
  35. </div>
  36. </el-table>
  37. </div>
  38. <div class="page-box">
  39. <el-pagination
  40. layout="total,prev,pager,next,jumper"
  41. background
  42. :current-page="pageNo"
  43. @current-change="handleCurrentChange"
  44. :page-size="pageSize"
  45. :total="total"
  46. >
  47. </el-pagination>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import { databankInterface } from "@/api/api.js";
  53. export default {
  54. data() {
  55. return {
  56. sourceList:[],//数据源列表
  57. choosedSource:'',//选择的数据源
  58. frequencyList:[],//频度列表
  59. selectValue:'',//选择的频度
  60. inputValue:'',//搜索框
  61. tableColumnList:[
  62. {
  63. key:'Code',
  64. label:'指标ID'
  65. },
  66. {
  67. key:'Name',
  68. label:'指标名称',
  69. minWidth:200,
  70. },
  71. {
  72. key:'Frequency',
  73. label:'频度'
  74. },
  75. {
  76. key:'Unit',
  77. label:'单位'
  78. },
  79. {
  80. key:'DateFirst',
  81. label:'指标开始时间',
  82. sortable:true,
  83. },
  84. {
  85. key:'DateLast',
  86. label:'指标最新时间',
  87. sortable:true
  88. },
  89. {
  90. key:'TimeLastUpdate',
  91. label:'更新时间',
  92. sortable:true
  93. }
  94. ],
  95. tableData:[],//表格数据
  96. pageNo:1,
  97. pageSize:15,
  98. total:0,
  99. SortField:0,
  100. SortRule:0,
  101. tableLoading:false,
  102. };
  103. },
  104. watch:{
  105. choosedSource(newVal){
  106. if(newVal){
  107. this.handleCurrentChange(1)
  108. }
  109. }
  110. },
  111. methods: {
  112. getFrequencyList(){
  113. databankInterface.getFrequencyList().then(res=>{
  114. if(res.Ret!==200) return
  115. this.frequencyList = res.Data||[]
  116. })
  117. },
  118. getSourceList(){
  119. databankInterface.getSourceList().then(res=>{
  120. if(res.Ret!==200) return
  121. this.sourceList = res.Data||[]
  122. this.choosedSource = this.sourceList[0].EdbSourceId
  123. })
  124. },
  125. getTableData(){
  126. this.tableLoading=true
  127. databankInterface.getDataList({
  128. Source:Number(this.choosedSource),
  129. CurrentIndex:this.pageNo,
  130. PageSize:this.pageSize,
  131. Frequency:this.selectValue,
  132. Keyword:this.inputValue,
  133. SortField:this.SortField,
  134. SortRule:this.SortRule
  135. }).then(res=>{
  136. if(res.Ret!==200) return
  137. if(!res.Data) return
  138. this.tableData = res.Data.List
  139. this.total = res.Data.Paging.Totals
  140. this.tableLoading=false
  141. })
  142. },
  143. handleCurrentChange(page){
  144. this.pageNo = page
  145. this.getTableData()
  146. },
  147. sortChange({prop,order}){
  148. const propMap = {
  149. 'DateFirst':1,
  150. 'DateLast':2,
  151. 'TimeLastUpdate':3
  152. }
  153. const orderMap = {
  154. 'ascending':1,
  155. 'descending':2
  156. }
  157. this.SortRule = orderMap[order]||0
  158. this.SortField = propMap[prop]||0
  159. this.handleCurrentChange(1)
  160. }
  161. },
  162. mounted(){
  163. this.getSourceList()
  164. this.getFrequencyList()
  165. }
  166. };
  167. </script>
  168. <style scoped lang="scss">
  169. .data-bank-base-wrap{
  170. box-sizing: border-box;
  171. background-color: #fff;
  172. padding:20px 30px;
  173. border-radius: 4px;
  174. .select-box{
  175. display: flex;
  176. justify-content: space-between;
  177. align-items: center;
  178. }
  179. .table-box{
  180. margin:30px 0;
  181. }
  182. .page-box{
  183. text-align: right;
  184. }
  185. }
  186. </style>