xlsx使用小计

upload_excel(e) {
      let fileReader = new FileReader();
      fileReader.onload = async (event) => {
        var workbook = XLSX.read(event.target.result, { type: 'binary' });
        console.log(workbook);
        let json = XLSX.utils.sheet_to_json(workbook.Sheets.Sheet1, { range: 1, dateNF: 'FMT 22' });
        console.log(this);
        let data = json.map((temp) => {
          switch (temp['号牌种类']) {
            case '大型汽车':
              var type = '01';
              break;
            case '挂车':
              var type = '15';
              break;
            case '小型汽车':
              var type = '02';
              break;
          }
          switch (temp['是否处理']) {
            case '未处理':
              var handle = '1';
              break;
            case '已处理':
              var handle = '3';
              break;
          }
          return {
            type: type,
            chepai: temp['号牌号码'],
            wf_time: this.formatDate(temp['违法时间']),
            wf_address: temp['违法地点'],
            content: temp['违法行为'],
            handle: handle,
            pay_type: temp['缴款状态'] == '未交款' ? 0 : 1,
          };
        });
        let result = await create({ data: data });
        if (result.err == 0) {
          this.tableRef.current.reload();
          message.success(result.msg);
        } else {
          message.success(result.msg);
        }
      };
      fileReader.readAsBinaryString(e.file); //二进制
  }

你可能感兴趣的