zuozhengqing
2023-11-30 af9ae0806cdce3935d8c5ec9f4e4f085587353b6
src/views/overview/previewExcel.vue
@@ -20,19 +20,15 @@
  data() {
    return {
      excel: '',//excel文档地址
      cutWidth:200,
      cutAfterWidth:this.$route.params.cutAfterWidth,//裁剪后要减去的宽
    };
  },
  computed: {
  },
  created() {
    console.log(this.$route.params.baseOperationType,"看看")
    if(this.$route.params.baseOperationType!=undefined){
      this.excel=this.$route.params.url
      if(this.this.$route.params.baseOperationType===1){
        this.cutWidth=200
      }else if(this.this.$route.params.baseOperationType===2){
        this.cutWidth=315
      }
    }
  },
  mounted() {
@@ -52,14 +48,14 @@
      const canvas = await html2canvas(elementToCrop);
      const croppedCanvas = document.createElement("canvas");
      const croppedContext = croppedCanvas.getContext("2d");
      croppedCanvas.width = canvas.width - this.cutWidth; // 去掉左右各100px
      croppedCanvas.width = canvas.width ; //裁剪前
      croppedCanvas.height = canvas.height - 100; // 去掉上下各100px
      // 在新的Canvas上绘制裁剪后的图像
      croppedContext.drawImage(
        canvas,
        50, // 开始裁剪的左侧位置
        20, // 开始裁剪的上侧位置
        croppedCanvas.width, // 裁剪后的宽度
        croppedCanvas.width-this.cutAfterWidth, // 裁剪后的宽度
        croppedCanvas.height-300, // 裁剪后的高度
        0, // 新Canvas中绘制的左侧位置
        0, // 新Canvas中绘制的上侧位置