展示表格数据

获取text文件接口


  // 获取指定样式文件
  isStyleExist(areacode: number, name: string, filename: string): Promise<boolean> {
    let url = `${this.url}/style/${name}/${areacode}/${filename}`;
    let options: Object = {
      responseType: 'text'
    };
    return this.http.get<string>(url, options).toPromise().then(() => {
      return true;
    }).catch(() => {
      return false;
    })
  }
  // 获取指定样式文件
  getStyle(styleName: string): Observable<Array<Stop>> {
    let url = `${this.url}/style/${"style-eco.stl"}`;
    let options: Object = {
      responseType: 'text'
    };

    return this.http.get<string>(url, options).pipe(map((result: string) => {
      let stops: Array<Stop> = [];
      let obj = this.ngxXml2jsonService.xmlToJson(new DOMParser().parseFromString(result, 'text/xml'));

      obj["Map"].Style.forEach(style => {
        if (style["@attributes"].name == styleName) {
          style.Rule.RasterSymbolizer.RasterColorizer.stop.forEach(stop => {
            stops.push(new Stop(stop["@attributes"].color, stop["@attributes"].value, stop["@attributes"].text, stop["@attributes"].label));
          });
        }
      });
      return stops;
    }));
  }

获取表格数据接口

getCsvData(fileName: string): Observable<string> {
        let url = this.url + '/product/image/' + fileName;

        let options: Object = {
            headers: this.jwt(),
            responseType: 'text'
        };

        return this.http.get<string>(url, options);
    }

在这里插入图片描述

表格添加数据

 statistics(taskExecution, type: string) {
    this.type = type == "area" ? '1' : '0';
    let statisticsData
    this.settings = [];
    this.isCount = true;
    this.productServ.getCsvData(this.task.initGridInfoName("csv", type, taskExecution.arguments[0])).toPromise().then(GridInfo => {
      statisticsData = GridInfo;
      // console.log(GridInfo)
      GridInfo.split("\r\n").forEach((info, i) => {
        //拼接表格标题栏
        if (i == 0) {
          for (let key = 0; key < info.split(",").length; key++) {
            if (info.split(",")[key] == "要素类型" || info.split(",")[key] == "分辨率" || info.split(",")[key] == "年份" || info.split(",")[key] == "月份") {
              continue;
            }
            this.settings.push({
              headerName: info.split(",")[key],
              field: key.toString(),
              sort: null
            })
          }
          return
        }
      })
    }).catch(() => {
      this.isCount = false;
      this.message.error(this.type + "数据获取失败");
      return;
    }).then(() => {
      if (statisticsData == undefined) return
      this.source = [];
      this.selTaskExecution = taskExecution;
      this.task.analysisTaskParam(this.selTaskExecution.arguments[0]);
      //拼接表格body
      statisticsData.split("\r\n").forEach((info, i) => {
        if (i != 0) {
          let item: {} = []
          for (let key = 0; key < info.split(",").length; key++) {
            item[key] = info.split(",")[key]
          }
          this.source.push(item)
        }
      })
      this.isCount = false;
      this.source.pop()
    })
  }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值