zoukankan      html  css  js  c++  java
  • 数据扩样处理

    1.html:

    1  <ul class="search-content">
    2             <li>
    3               <span class="name" (click)="selectorChange('扩样数据', true)">扩样数据</span>
    4             </li>
    5             <li>
    6               <span class="name" (click)="selectorChange('原始数据', false)">原始数据</span>
    7             </li>
    8           </ul>

    1.ts:

    import { CommonService } from './../../service/common.service';
    
     dataType = this.commonService.expandName;
      isShowList: boolean = false;
    
     selectorChange(item, isExpand) {
        if (this.commonService.expand !== isExpand) {
          this.isShowList = false;
          this.commonService.expandName = item;
          this.dataType = item;
          this.commonService.expand = isExpand;
          this.commonService.expandType.next(isExpand);
        }
      }

    common.service.ts:

    import { of, Subject, Subscription } from 'rxjs'; 
    
    expandType = new Subject();
    expand: boolean = true;
    expandName: string = '扩样数据';
    
      // 数据扩样处理
      HandleData(data) {
        if (this.expand) {
          if (typeof data === 'number') {
            //
            data = Math.round((data / 0.73) / 0.9165);
          } else if (!(data instanceof Array)) {
            // 对象
            if (data['subscriberCounts']) {
              data['subscriberCounts'].forEach((item, index) => {
                if (item['countList']) {
                  item['countList'].forEach((item1, index1) => {
                    data['subscriberCounts'][index]['countList'][index1] = Math.round((item1 / 0.73) / 0.9165);
                  });
                }
              });
            } else if (data['countList']) {
              data['countList'].forEach((item, index) => {
                data['countList'][index] = Math.round((item / 0.73) / 0.9165);
              });
            } else if (data['populations']) {
              data['populations'].forEach((item, index) => {
                if (item['countList']) {
                  item['countList'].forEach((item1, index1) => {
                    data['populations'][index]['countList'][index1] = Math.round((item1 / 0.73) / 0.9165);
                  });
                }
              });
            }
          } else {
            // 数组
            data.forEach(item => {
              if (item.subscriberCount) {
                item.subscriberCount = Math.round((item.subscriberCount / 0.73) / 0.9165);
              } else if (item['currentCount']) {
                item.currentCount = Math.round((item.currentCount / 0.73) / 0.9165);
              }else {
                item.populations = Math.round((item.populations / 0.73) / 0.9165);
              }
            });
    
          }
        }
        return data;
      }
  • 相关阅读:
    visual studio code for mac 的对齐快捷键
    ios 抓取真机的网络包
    iOS 引入framework的常见问题和原理
    iOS 4种开发者身份的官方说明
    iOS NSObject 的 isa 属性的类型 Class
    iOS 子类初始化方法中 为什么要使用 self = [super init] 对self进行赋值
    Linux和windows下修改tomcat内存
    idea将项目打成war包
    web.xml引入 xml (tomcat 7.0.52) 以上版本报错
    ideal 切换git和svn
  • 原文地址:https://www.cnblogs.com/a1-top/p/14047180.html
Copyright © 2011-2022 走看看