zhouwx
2024-08-20 31ab2edfa500364818d2cc2c30acc1f4ae5b8dac
src/views/hazardousChemicals/warehouseManage/components/printCode.vue
@@ -3,7 +3,7 @@
    <el-dialog
        v-model="dialogVisible"
        :title="title == 'pro' ? '成品二维码打印' : '危化品二维码打印'"
        width="600px"
        width="650px"
        :before-close="handleClose"
        :close-on-press-escape="false"
        :close-on-click-modal="false"
@@ -63,8 +63,8 @@
import {addWarehouse, checkName, editWarehouse} from "@/api/hazardousChemicals/warehouse";
import {verifyPhone} from "@/utils/validate";
import {checkBasicName} from "@/api/hazardousChemicals/basicInfo";
import {getProDetail, getProductRecord} from "@/api/hazardousChemicals/productRecord";
import {getRawDetail} from "@/api/hazardousChemicals/rawRecord";
import {getProDetail, getProductRecord, getWhProDetail} from "@/api/hazardousChemicals/productRecord";
import {getRawDetail, getWhRawDetail} from "@/api/hazardousChemicals/rawRecord";
const dialogVisible = ref(false);
const title = ref("");
@@ -79,8 +79,9 @@
  queryParams:{
    pageNum: 1,
    pageSize: 5,
    warehouseId: null,
    basicId: null,
    // warehouseId: null,
    // basicId: null,
    entryId: null,
    code: ''
  },
  chooseList: []
@@ -89,8 +90,9 @@
const originalList = ref([])
const openDialog = async (type,value) => {
  state.queryParams.warehouseId =value.warehouseId
  state.queryParams.basicId =value.basicId
  // state.queryParams.warehouseId =value.warehouseId
  // state.queryParams.basicId =value.basicId
  state.queryParams.entryId = value.id
  title.value = type;
  await getList()
@@ -120,8 +122,7 @@
  state.queryParams = {
    pageNum: 1,
    pageSize: 5,
    warehouseId: null,
    basicId: null,
    entryId: null,
    code: ''
  }
  state.total = 0
@@ -129,7 +130,7 @@
}
const getList = async () => {
  if(title.value == 'pro'){
    const res = await getProDetail(state.queryParams)
    const res = await getWhProDetail(state.queryParams)
    if(res.code == 200){
      state.dataList = res.data.list.map(item => {
       return{
@@ -144,7 +145,7 @@
      ElMessage.warning(res.message)
    }
  }else {
    const res = await getRawDetail(state.queryParams)
    const res = await getWhRawDetail(state.queryParams)
    if(res.code == 200){
      state.dataList = res.data.list.map(item => {
        return{
@@ -178,6 +179,7 @@
  }
  const printContent=document.createElement('div')
  printContent.innerHTML=qrCodes
  //创建一个新的隐藏的iframe元素
  const printFrame =document.createElement('iframe')
  printFrame.style.display='none'
@@ -202,6 +204,7 @@
  `)
  printDocument.close()
  //在打印窗口中调用打印功能
  console.log('printFrame.contentWindow.document.body.style',printFrame.contentWindow.document.body.style)
  printFrame.contentWindow.print()
  //移除隐藏的iframe元素
  document.body.removeChild(printFrame)