DatabankBase.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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:'Id',
  64. label:'指标ID'
  65. },
  66. {
  67. key:'Code',
  68. label:'指标编码'
  69. },
  70. {
  71. key:'Name',
  72. label:'指标名称',
  73. minWidth:170,
  74. },
  75. {
  76. key:'Frequency',
  77. label:'频度'
  78. },
  79. {
  80. key:'Unit',
  81. label:'单位'
  82. },
  83. {
  84. key:'DateFirst',
  85. label:'指标开始时间',
  86. sortable:true,
  87. },
  88. {
  89. key:'DateLast',
  90. label:'指标最新时间',
  91. sortable:true
  92. },
  93. {
  94. key:'TimeLastUpdate',
  95. label:'更新时间',
  96. sortable:true
  97. }
  98. ],
  99. tableData:[],//表格数据
  100. pageNo:1,
  101. pageSize:15,
  102. total:0,
  103. SortField:0,
  104. SortRule:0,
  105. tableLoading:false,
  106. };
  107. },
  108. watch:{
  109. choosedSource(newVal){
  110. if(newVal){
  111. this.handleCurrentChange(1)
  112. }
  113. }
  114. },
  115. methods: {
  116. getFrequencyList(){
  117. databankInterface.getFrequencyList().then(res=>{
  118. if(res.Ret!==200) return
  119. this.frequencyList = res.Data||[]
  120. })
  121. },
  122. getSourceList(){
  123. databankInterface.getSourceList().then(res=>{
  124. if(res.Ret!==200) return
  125. this.sourceList = res.Data||[]
  126. this.choosedSource = this.sourceList[0].EdbSourceId
  127. })
  128. },
  129. getTableData(){
  130. this.tableLoading=true
  131. databankInterface.getDataList({
  132. Source:Number(this.choosedSource),
  133. CurrentIndex:this.pageNo,
  134. PageSize:this.pageSize,
  135. Frequency:this.selectValue,
  136. Keyword:this.inputValue,
  137. SortField:this.SortField,
  138. SortRule:this.SortRule
  139. }).then(res=>{
  140. if(res.Ret!==200) return
  141. if(!res.Data) return
  142. this.tableData = res.Data.List
  143. this.total = res.Data.Paging.Totals
  144. this.tableLoading=false
  145. })
  146. },
  147. handleCurrentChange(page){
  148. this.pageNo = page
  149. this.getTableData()
  150. },
  151. sortChange({prop,order}){
  152. const propMap = {
  153. 'DateFirst':1,
  154. 'DateLast':2,
  155. 'TimeLastUpdate':3
  156. }
  157. const orderMap = {
  158. 'ascending':1,
  159. 'descending':2
  160. }
  161. this.SortRule = orderMap[order]||0
  162. this.SortField = propMap[prop]||0
  163. this.handleCurrentChange(1)
  164. }
  165. },
  166. mounted(){
  167. this.getSourceList()
  168. this.getFrequencyList()
  169. }
  170. };
  171. </script>
  172. <style scoped lang="scss">
  173. .data-bank-base-wrap{
  174. box-sizing: border-box;
  175. background-color: #fff;
  176. padding:20px 30px;
  177. border-radius: 4px;
  178. .select-box{
  179. display: flex;
  180. justify-content: space-between;
  181. align-items: center;
  182. }
  183. .table-box{
  184. margin:30px 0;
  185. }
  186. .page-box{
  187. text-align: right;
  188. }
  189. }
  190. </style>