admin
2024-02-05 e25a0bad090c444970b48df2713f02d691666b08
kp_html/kp/js/code_list.js
@@ -30,6 +30,7 @@
      data: {
         code: "000000",
         code_name: "测试代码",
         origin_code:null,
         trade_data: {},
         trade_record: {
            open_limit_up: "",
@@ -50,12 +51,38 @@
         l2_colors_class: ["color-single-start", "color-single-exec", "color-cancel",
            "color-real-order"
         ],
         kpl_code_info: null,
         l_up_cancel_indexes: [],
         l_down_cancel_indexes: [],
         h_cancel_indexes: [],
         buy_single_indexes: [],
         l2_code_name: '',
         operate_index: -1
         operate_index: -1,
         // 已经委托的买代码信息
         delegated_buy_code_infos:[],
         layui_element:null,
         l2_cant_buy_reasons:[],
      },
      watch:{
         delegated_buy_code_infos:function(){
            if(app.layui_element){
               setTimeout(()=>{
                  app.layui_element.render();
               })
            }
         }
      },
      mounted:function(){
          layui.use('element', function(){
             var element = layui.element;
            app.layui_element=element;
           });
         setInterval(function(){
            if(is_trade_time()){
               app.get_delegated_buy_code_infos();
            }
         },1000*5);
      },
      methods: {
         change_data_type: function(type) {
@@ -122,7 +149,7 @@
               if (res.code == 0) {
                  var real_order_index = -1;
                  var buy_singles = [];
                  res.data.forEach(function(e) {
                  res.data.data.forEach(function(e) {
                     if (e[1] != null) {
                        if (e[1][0] == 3) {
                           //真实下单位置
@@ -139,9 +166,10 @@
                  });
                  console.log("最近真实下单位置:", real_order_index);
                  app.latest_real_order_index = real_order_index;
                  app.l2_datas = res.data;
                  app.l2_code_name = app.code_name.slice(0, app.code_name.indexOf(
                     " "))
                  app.l2_datas = res.data.data;
                  var code_name = res.data.code_name;
                  var code_ = res.data.code;
                  app.l2_code_name = code_ + " " + code_name;
                  // 清除成交进度,L撤, H撤
                  app.trade_progress_index = -1;
                  app.l_up_cancel_indexes = [];
@@ -154,6 +182,24 @@
            });
         },
         get_delegated_buy_code_infos:function(){
            // 获取数据
            http_util.get_delegated_buy_code_infos(function(result){
               if (result.code == 0) {
                  console.log("已挂买单数据:",result.data);
                  result.data.forEach(function(e){
                     if(e.total_num>0){
                        e.percent = e.finish_num*100/e.total_num;
                     }else{
                        e.percent = 0;
                     }
                  });
                  app.delegated_buy_code_infos = result.data
               }
            });
         },
         clear_cancel_mark: function() {
            //清除撤单标记
            app.l_up_cancel_indexes = [];
@@ -259,6 +305,7 @@
               console.log("处理出错")
               console.log(e)
            }
             app.get_l2_cant_buy_reasons(code);
         },
         show_more_records: function(items) {
            var str_ = ""
@@ -268,8 +315,41 @@
            });
            alert(str_);
         },
         test: function() {
         set_real_place_order_index: function() {
            // 设置真实下单位
            if(app.code){
               layer.prompt({
                 formType: 0,
                 value: '',
                 title: '设置真实下单位-'+app.code,
                 area: ['800px', '350px'] //自定义文本域宽高
               }, function(value, index, elem){
                  try{
                     if(isNaN(value)){
                        layer.msg("请输入数字");
                        return;
                     }else{
                        http_util.set_real_place_order_index(app.code,parseInt(value),function(res){
                           // 获取到结果
                           console.log(res);
                           if(res.code!=0){
                              layer.msg(res.msg,{icon: 5});
                           }else{
                              layer.msg("设置成功",{icon: 1});
                           }
                        })
                     }
                  }catch(e){
                  }
                  layer.close(index);
               });
               //set_real_place_order_index
            }else{
               layer.msg("请先加载数据");
            }
         },
         need_show:function(item){
            if(app.hidden_canceled&&(item[2][6].indexOf('买撤')>=0||(item[2][8]!=null&&item[2][8].indexOf("-")>0))){
@@ -330,14 +410,28 @@
         set_target_code: function(code) {
            console.log("设置目标代码", code);
            app.origin_code = code;
            app.code = code;
            app.code_name = code;
         },
         load_data:function(){
            if(app.code){
               app.get_score_data(app.code,null,null);
            if(app.origin_code){
               app.get_score_data(app.origin_code,null,null);
                app.get_l2_cant_buy_reasons(app.origin_code);
            }
         },
         cancel_order:function(code){
            http_util.cancel_order(code,function(res){
               layer.msg("撤单成功");
            });
         },
         get_l2_cant_buy_reasons:function(code){
            http_util.get_l2_cant_buy_reasons(code,function(res){
               res = JSON.parse(res);
               if(res.code==0){
                  app.l2_cant_buy_reasons = res.data;
               }else{
                  app.l2_cant_buy_reasons =[]
               }
            });
         }
      }
   })