chinaFinancialFutures.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div class="exchangedata-wrap">
  3. <span
  4. class="slide-btn-icon"
  5. :class="{'slide-left':isLeftWrapShow,'slide-right':!isLeftWrapShow}"
  6. @click="isLeftWrapShow = !isLeftWrapShow"
  7. >
  8. <i :class="{'el-icon-d-arrow-left':isLeftWrapShow,'el-icon-d-arrow-right':!isLeftWrapShow}"></i>
  9. </span>
  10. <div class="left-wrap box" v-show="isLeftWrapShow">
  11. <el-date-picker
  12. style="width:100%"
  13. v-model="time"
  14. type="date"
  15. placeholder="选择日期"
  16. value-format="yyyy-MM-dd"
  17. :clearable="false"
  18. @change="handleTimeChange"
  19. >
  20. </el-date-picker>
  21. <ul>
  22. <li
  23. :class="type===item&&'type-active'"
  24. v-for="item in typeList"
  25. :key="item"
  26. @click="handleChangeType(item)"
  27. >{{item}}</li>
  28. </ul>
  29. </div>
  30. <div class="right-wrap box" v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading">
  31. <div class="content" v-if="list.length>0">
  32. <table width="auto" border="0" v-for="item in list" :key="item.Code">
  33. <thead>
  34. <tr>
  35. <td :colspan="Object.keys(labelArr).length" style="background:#ECF5FF">合约代码:{{item.Code}}</td>
  36. </tr>
  37. <tr>
  38. <td colspan="5" style="background:#ECF5FF">成交量排名</td>
  39. <td colspan="4" style="background:#ECF5FF">持买单量排名</td>
  40. <td colspan="4" style="background:#ECF5FF">持卖单量排名</td>
  41. </tr>
  42. <tr>
  43. <td v-for="(val,index) in labelArr" :key="`${item.Code}_${index}`">
  44. {{ val }}
  45. </td>
  46. </tr>
  47. </thead>
  48. <tbody>
  49. <tr v-for="item2 in item.Item" :key="item2.Rank">
  50. <td v-for="(val, key) in labelArr" :key="`${item.Code}_${item2.Rank}_${key}`">
  51. {{item2.Rank==999&&key=='Rank'?'合计':item2[key]}}
  52. </td>
  53. </tr>
  54. </tbody>
  55. <!-- <tfoot>
  56. <tr>
  57. <td v-for="(val,key) in labelArr" :key="val">
  58. {{
  59. val === "名次"
  60. ? "合计"
  61. : val === "会员简称" || val === "指标ID"
  62. ? ""
  63. : handleValCount(item.Item,key)
  64. }}
  65. </td>
  66. </tr>
  67. </tfoot> -->
  68. </table>
  69. </div>
  70. <div class="empty-wrap" v-else>
  71. <tableNoData text="没有此日期的数据,请重新选择查询日期"/>
  72. </div>
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. // 中国金融期货交易所
  78. import { dataInterence } from "@/api/api.js";
  79. import http from "@/api/http.js";
  80. export default {
  81. name:"chinaFinancialFutures",
  82. data() {
  83. return {
  84. isLeftWrapShow:true,
  85. labelArr: {
  86. Rank: "名次",
  87. DealShortName: "会员简称",
  88. DealCode: "指标ID",
  89. DealValue: "成交量(手)",
  90. DealChange: "增减量",
  91. BuyShortName: "会员简称",
  92. BuyCode: "指标ID",
  93. BuyValue: "持买仓量",
  94. BuyChange: "增减量",
  95. SoldShortName: "会员简称",
  96. SoldCode: "指标ID",
  97. SoldValue: "持卖仓量",
  98. SoldChange: "增减量",
  99. },
  100. time: '',
  101. type:'',
  102. typeList:[],
  103. list:[],
  104. loading:false
  105. };
  106. },
  107. created () {
  108. // this.getLastWorkDay()
  109. this.getClassifyList()
  110. },
  111. methods: {
  112. // 获取上个工作日
  113. getLastWorkDay(){
  114. const today=new Date()
  115. let lastWorkDay=http.dateFormatter(new Date(today.getTime()-86400000),false).replace(/\./g,'-') //默认昨天
  116. if(today.getDay()===0){//周日
  117. lastWorkDay=http.dateFormatter(new Date(today.getTime()-86400000 * 2),false).replace(/\./g,'-')
  118. }else if(today.getDay()===6){//周六
  119. lastWorkDay=http.dateFormatter(new Date(today.getTime()-86400000 ),false).replace(/\./g,'-')
  120. }else if(today.getDay()===1){//周一
  121. lastWorkDay=http.dateFormatter(new Date(today.getTime()-86400000*3 ),false).replace(/\./g,'-')
  122. }
  123. this.time=lastWorkDay
  124. },
  125. handleChangeType(e){
  126. this.type=e
  127. this.getData()
  128. },
  129. // 时间切换
  130. handleTimeChange(){
  131. this.getData();
  132. },
  133. handleValCount(list,key){
  134. let count=0
  135. list&&list.forEach(item=>{
  136. count=count+Number(item[key])
  137. })
  138. return count
  139. },
  140. // 获取分类
  141. async getClassifyList(){
  142. const res=await dataInterence.getResearcherClassifyList({
  143. Exchange:'cffex'
  144. })
  145. if(res.Ret===200){
  146. this.typeList=res.Data&&res.Data[0]||[]
  147. this.time=res.Data&&res.Data[1][0]||''
  148. this.type=this.typeList[0]
  149. this.getData()
  150. }
  151. },
  152. async getData(){
  153. $('.content').animate({scrollTop:0},0)
  154. this.loading=true
  155. const res=await dataInterence.getChinaFuturesData({
  156. Date: this.time,
  157. ClassifyName:this.type
  158. })
  159. setTimeout(() => {
  160. this.loading=false
  161. }, 200);
  162. if(res.Ret===200){
  163. this.list=res.Data&&res.Data[0].ItemList||[]
  164. }
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. @import "../css/exchangedata.scss";
  171. </style>