王震
2023-08-28 62b5cdb9d4b5f34f10b517a3476806bec133fb2f
src/views/experiment/checkTheReport/index.vue
@@ -57,10 +57,10 @@
        :visible.sync="dialogVisible"
        width="60%">
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" size="small" @click="printFun()">打印</el-button>
          <el-button type="primary" @click="printFun()">打印</el-button>
        </span>
        <div class="printStyle">
          <preview id="printDiv"></preview>
          <preview id="printDiv" :reportData="reportData"></preview>
        </div>
      </el-dialog>
      <div class="table-box">
@@ -93,14 +93,14 @@
            </template></el-table-column
          >
          <el-table-column
            prop="materialCode"
            prop="reportCode"
            label="报告单号"
            sortable
            min-width="10%"
          >
            <template slot-scope="scope">
              <span style="color: #409eff;">
                  {{ scope.row.materialCode }}
                  {{ scope.row.reportCode }}
              </span>
            </template></el-table-column
          >
@@ -179,12 +179,13 @@
</template>
<script>
import { selectAllReport } from "@/api/experiment/checkTheReport";
import { selectAllReport,getReportData } from "@/api/experiment/checkTheReport";
import Preview from "@/components/experiment/checkTheReport/index.vue";
import PrintJS from 'print-js'
export default {
  data() {
    return {
      reportData: [],
      searchData:{
        sample_code:'',
        reportCode:'',
@@ -203,25 +204,31 @@
    this.getData();
  },
  mounted(){
    // this.dialogVisible = true;
  },
  components:{
    Preview
  },
  methods: {
    //预览按钮
    previewFun(){
    async queryReportByRCode(code){
      const resp = await getReportData({code:code});
      this.reportData = resp.data;
      console.log(this.reportData);
    },
    //查看报告按钮
    previewFun(row){
      this.dialogVisible = true;
      this.queryReportByRCode(row.reportCode);
    },
    //打印按钮
    printFun(){
        PrintJS({
          printable: "printDiv",
          type: "html",
          // header: "原材料检测报告",
          targetStyles: ["*"],
          ignoreElements: ["no-ignore"],
        });
      this.dialogVisible = false;
      PrintJS({
        printable: "printDiv",
        type: "html",
        // header: "原材料检测报告",
        targetStyles: ["*"],
        ignoreElements: ["no-ignore"],
      });
    },
    // 状态按钮
    handleRadioChange() {