廖井涛
7 小时以前 f7a2fcdda7f1120498c5c5f75c5a99955fc54b43
north-glass-erp/northglass-erp/src/views/pp/processCard/PrintProjectDetails.vue
@@ -24,6 +24,7 @@
import {hiprint} from "vue-plugin-hiprint";
import QueuePrinter from "@/hook/queue"
import TagStyleSet from "@/hook/tagStyleSet";
import {createTemplate} from "@/hook/createTemplateTag";
const company = companyInfo()
@@ -48,7 +49,7 @@
const xGrid = ref(null)
const xGridDetail = ref(null)
const tags = ref([])
const tagType = ref()
@@ -80,15 +81,14 @@
onMounted(async () => {
  await getTags();
  await hiprint.init();
})
let hiprintTemplate = ref()
const changeTag = () => {
  hiprintTemplate.value = new hiprint.PrintTemplate({});
  const json = JSON.parse(tag.value.value)
  hiprintTemplate.value.update(json)
}
const tags = ref([])
const tag = ref({
  id: null,
@@ -100,6 +100,12 @@
  size: null
})
const changeTag = () => {
  hiprintTemplate.value = new hiprint.PrintTemplate({});
  hiprintTemplate.value.design("#hiprint-printTemplate2",{grid:true});
  const json = tag.value.value
  hiprintTemplate.value.update(json)
}
//标签类型
const lableType = ref('1')
@@ -129,6 +135,9 @@
const getTags = () => {
  request.get('tagStyle/getTagList').then(res => {
    res.data.forEach(item => {
      item.value = JSON.parse(item.value)
    })
    tags.value = res.data
  })
}
@@ -142,7 +151,7 @@
request.post(`/processCard/selectPrintProjectDetails/${projectNo}`).then((res) => {
  if (res.code == 200) {
    xGrid.value.loadData(res.data.data)
    xGrid.value.reloadData(res.data.data)
    gridOptions.loading = false
  } else {
    ElMessage.warning(res.msg)
@@ -209,7 +218,7 @@
    },
    {
      field: 'stock_id',
      title: '版图号',
      title: t('processCard.layoutNumber'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
@@ -226,6 +235,7 @@
  toolbarConfig: {
    buttons: [
      {code: 'printLabel3', name: t('basicData.print'), status: 'primary'},
      {code: 'printSmallPiece', name: t('小片打印'), status: 'primary'},
    ],
    zoom: true,
    custom: true
@@ -260,11 +270,11 @@
      switch (code) {
        case 'printLabel3': {
          if (selectRecords === null || selectRecords === '' || selectRecords.length === 0) {
            ElMessage.warning(t('请选择工程对应的版图号'))
            ElMessage.warning(t('processCard.projectMsg1'))
            return
          }
          if (tag.value.name == null || tag.value.name == '') {
            ElMessage.warning(t('请选择标签模板'))
            ElMessage.warning(t('processCard.projectMsg2'))
            return
          }
          let name = company.companyName
@@ -283,14 +293,57 @@
          }
          break
        }
        case 'printSmallPiece': {
          if (selectRecords === null || selectRecords === '' || selectRecords.length === 0) {
            ElMessage.warning(t('processCard.projectMsg1'))
            return
          }
          let stock_id=[]
          for (let i=0;i<selectRecords.length;i++){
              stock_id.push(selectRecords[i].stock_id)
          }
          console.log(stock_id)
          router.push({path: '/main/processCard/printProjectDetailSmallPiece', query: {projectNo: projectNo,stockId:JSON.stringify(stock_id)}})
          break
        }
      }
    }
  },
}
const printObjectProcess = () => {
  hiprintTemplate.value.print({table:lastList.value})
const printObjectProcess = (type) => {
  const list = tag.value.value
  list.panels[0].printElements.forEach(element => {
    element.options.fontFamily = 'Arial'
    if( element.options.field !== undefined){
      if(type===3 ){
        element.options.hideTitle = true
      }
    }
    if(type!==3){
      element.options.hideTitle = false
      if( element.options.field === undefined){
        element.options.hideTitle = true
      }
    }
  })
  //hiprintTemplate.value.update(list)
  let object =  JSON.parse(JSON.stringify(lastList.value))
  //判断是否为表格
  let columnsNum = null
  if(list.panels[0].printElements[0].options.field==='table'){
    object = {table:lastList.value}
    columnsNum = (list.panels[0].printElements[0].options.gridColumns || 1)
  }
  //判断是否有 嵌套自定义纸张
  if(tag.value.tagHeight && tag.value.tagWidth){
    const print =createTemplate(list,object,tag.value.tagWidth,tag.value.tagHeight)
    hiprintTemplate.value.update(print.template)
    object = print.printData
  }
  hiprintTemplate.value.print(object)
}
</script>
@@ -298,8 +351,8 @@
<template>
  <div class="main-div-customer">
    <div>
      标签模板:
      <el-select v-model="tag" placeholder="标签模板列表" style="width: 140px" @change="changeTag">
      <label>{{ $t('processCard.labelStyle') }}:</label>
      <el-select v-model="tag" :placeholder="$t('processCard.pleaseSelect')" style="width: 140px" @change="changeTag">
        <el-option
            v-for="(tag,index) in tags"
            :key="index"
@@ -371,10 +424,28 @@
        destroy-on-close
        style="width: 80%;height:75% ">
      <template #header="{ close, titleId, titleClass }">
        <el-button :icon="Printer" circle @click="printObjectProcess"/>
<!--        <el-button :icon="Printer" circle @click="printObjectProcess(1)"/>-->
<!--        <el-button @click="printObjectProcess(3)"  >{{ $t('processCard.noTitle') }}</el-button>-->
        <el-tooltip
            class="box-item"
            effect="dark"
            :content="$t('processCard.yesTitle')"
            placement="top"
        >
          <el-button :icon="Printer" circle @click="printObjectProcess(1)"/>
        </el-tooltip>
        <el-tooltip
            class="box-item"
            effect="dark"
            :content="$t('processCard.noTitle')"
            placement="top"
        >
          <el-button @click="printObjectProcess(3)">
            <i class="vxe-icon-print"></i>
          </el-button>
        </el-tooltip>
      </template>
      <print-custom-label-project id="childLabel"
                                  :detailType="labelRow.detailType"
                                  :faceOrientation="labelRow.faceOrientation"
                                  :lableType="labelRow.lableType"