indexContent.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <div class="index-content-wrap">
  3. <div class="top-box">
  4. <span style="margin-right:20px">{{num}}{{$t('ToolBox.PositionAnalysis.variety')}}</span>
  5. <span>{{time}}</span>
  6. </div>
  7. <div class="list-wrap">
  8. <div class="item" v-for="item in clist" :key="item.ClassifyName">
  9. <div class="label">{{item.ClassifyName}}</div>
  10. <div style="margin-top:20px;">
  11. <div
  12. class="opt" :class="{'active':$route.query.classify_type===_item.ClassifyType}"
  13. v-for="_item in item.Items"
  14. :key="_item.ClassifyType"
  15. @click="goDetail(_item,item)"
  16. >{{_item.ClassifyType}}</div>
  17. </div>
  18. </div>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. props: {
  25. num:Number,
  26. time:String,
  27. exchange:String,
  28. now:String,
  29. list:null,
  30. isHistory:Boolean
  31. },
  32. computed: {
  33. clist() {
  34. if(this.isHistory){
  35. /* console.log('看历史'); */
  36. return this.list
  37. }
  38. const now=this.$moment(this.now).format('YYMM')//当前时间
  39. const arr=this.list?JSON.parse(JSON.stringify(this.list)):[]
  40. let resArr=[]
  41. if(this.exchange!='郑商所'){
  42. resArr=arr.map(item=>{
  43. item.Items=item.Items.filter(_item=>{
  44. const t=_item.ClassifyType.substr(-4)
  45. //15号之后过滤非当月合约
  46. return Number(this.now.substr(-2)) <= 15 ? Number(t)>=now : Number(t)>now;
  47. })
  48. return item
  49. })
  50. }else{
  51. resArr=arr.map(item=>{
  52. item.Items=item.Items.filter(_item=>{
  53. // 如果合约编号没有含日期 肯定是少于4位的 因为至少为一个字母加三位数的日期
  54. if(_item.ClassifyType.length<4) return true
  55. const t=2+_item.ClassifyType.substr(-3)
  56. return Number(this.now.substr(-2)) <= 15 ? Number(t)>=now : Number(t)>now;
  57. })
  58. return item
  59. })
  60. }
  61. return resArr
  62. }
  63. },
  64. data() {
  65. return {
  66. }
  67. },
  68. methods: {
  69. goDetail(_item,item){
  70. this.$router.push({
  71. path:"/positionAnalysisDetail",
  72. query:{
  73. classify_name:item.ClassifyName,
  74. classify_type:_item.ClassifyType,
  75. exchange:this.exchange,
  76. isHistory:this.isHistory
  77. }
  78. })
  79. }
  80. },
  81. mounted() {
  82. }
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. @import '~@/styles/theme-vars.scss';
  87. .index-content-wrap{
  88. display: flex;
  89. flex-direction: column;
  90. .top-box{
  91. background: #e6eefb;
  92. padding: 15px 30px;
  93. span{
  94. display: inline-block;
  95. }
  96. }
  97. .list-wrap{
  98. padding: 30px;
  99. height: 958px;
  100. box-sizing: border-box;
  101. overflow-y: auto;
  102. .item{
  103. margin-bottom: 30px;
  104. /* display: flex; */
  105. .label{
  106. color: #666;
  107. width: 100px;
  108. padding-top: 10px;
  109. font-size: 14px;
  110. }
  111. .opt{
  112. padding: 6px 10px;
  113. min-width: 100px;
  114. text-align: center;
  115. display: inline-block;
  116. margin-right: 20px;
  117. margin-bottom: 20px;
  118. background: #e6eefb;
  119. border: 1px solid $theme-color;
  120. border-radius: 4px;
  121. cursor: pointer;
  122. &:hover,&.active{
  123. background-color: #0052D9;
  124. color: #FFFFFF;
  125. }
  126. }
  127. }
  128. }
  129. }
  130. </style>