浏览代码

15号之后过滤当月合约

Karsa 1 年之前
父节点
当前提交
43c976fc9a
共有 2 个文件被更改,包括 11 次插入5 次删除
  1. 10 4
      pages/positionAnalysis/components/indexContent.vue
  2. 1 1
      pages/positionAnalysis/index.vue

+ 10 - 4
pages/positionAnalysis/components/indexContent.vue

@@ -50,7 +50,10 @@ export default {
         },
         exchange:{
             default:''
-        }
+        },
+		  now: {
+			  default: ''
+		  }
     },
     computed:{
         clist(){
@@ -59,14 +62,16 @@ export default {
                 return this.list
             }
 
-            const now=dayjs().format('YYMM')//当前时间
+            const now=dayjs(this.now).format('YYMM')//当前时间
             const arr=this.list?JSON.parse(JSON.stringify(this.list)):[]
             let resArr=[]
             if(this.exchange!='郑商所'){
                 resArr=arr.map(item=>{
                     item.items=item.items.filter(_item=>{
                         const t=_item.classify_type.substr(-4)
-                        return Number(t)>=now
+								
+								//15号之后过滤非当月合约
+								return Number(this.now.substr(-2)) <= 15 ? Number(t)>=now : Number(t)>now;
                     })
                     return item
                 })
@@ -76,7 +81,8 @@ export default {
                         // 如果合约编号没有含日期 肯定是少于4位的 因为至少为一个字母加三位数的日期
                         if(_item.classify_type.length<4) return true
                         const t=2+_item.classify_type.substr(-3)
-                        return Number(t)>=now
+								//15号之后过滤非当月合约
+								return Number(this.now.substr(-2)) <= 15 ? Number(t)>=now : Number(t)>now;
                     })
                     return item
                 })

+ 1 - 1
pages/positionAnalysis/index.vue

@@ -15,7 +15,7 @@
                 :key="item.exchange"
                 :name="item.exchange"
             >
-                <indexContent :list="item.items" :num="item.num" :time="item.data_time" :exchange="item.exchange"/>
+                <indexContent :list="item.items" :num="item.num" :time="item.data_time" :exchange="item.exchange" :now="item.curr_date"/>
             </van-tab>
         </van-tabs>
     </view>