zouyu
2023-08-26 c81bf2132d6d3b7246075c6faa1382365d5f17e2
src/views/experiment/checkTheReport/index.vue
@@ -51,6 +51,18 @@
          >
        </div>
      </div>
      <el-dialog
        top="10vh"
        title="报告预览"
        :visible.sync="dialogVisible"
        width="60%">
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" size="small" @click="printFun()">打印</el-button>
        </span>
        <div class="printStyle">
          <preview id="printDiv"></preview>
        </div>
      </el-dialog>
      <div class="table-box">
        <el-table
          ref="reportTable"
@@ -143,10 +155,9 @@
              <el-button
                type="text"
                size="small"
                @click="handleClick(scope.row)"
                @click="previewFun(scope.row)"
                >预览</el-button
              >
              <el-button type="text" size="small">打印</el-button>
            </template>
          </el-table-column>
        </el-table>
@@ -169,6 +180,8 @@
<script>
import { selectAllReport } from "@/api/experiment/checkTheReport";
import Preview from "@/components/experiment/checkTheReport/index.vue";
import PrintJS from 'print-js'
export default {
  data() {
    return {
@@ -183,12 +196,33 @@
      total: 0,
      pageSize: 10,
      checked: true,
      dialogVisible: false,
    };
  },
  created() {
    this.getData();
  },
  mounted(){
    // this.dialogVisible = true;
  },
  components:{
    Preview
  },
  methods: {
    //预览按钮
    previewFun(){
      this.dialogVisible = true;
    },
    //打印按钮
    printFun(){
        PrintJS({
          printable: "printDiv",
          type: "html",
          // header: "原材料检测报告",
          targetStyles: ["*"],
          ignoreElements: ["no-ignore"],
        });
    },
    // 状态按钮
    handleRadioChange() {
      this.getData();
@@ -227,6 +261,7 @@
      };
      const { data } = await selectAllReport(params);
      this.reportTable = data.row;
      console.log(data.row);
      this.total = data.total;
    },
  },
@@ -280,5 +315,14 @@
      margin: 10px 0;
    }
  }
  .printStyle{
    overflow: scroll;
    height:600px;
    .el-button{
      position: absolute;
      top: 10vh;
      left: 90%;
    }
  }
}
</style>