| | |
| | | import {hiprint} from "vue-plugin-hiprint"; |
| | | import QueuePrinter from "@/hook/queue" |
| | | import TagStyleSet from "@/hook/tagStyleSet"; |
| | | import {createTemplate} from "@/hook/createTemplateTag"; |
| | | |
| | | const company = companyInfo() |
| | | |
| | |
| | | const xGrid = ref(null) |
| | | const xGridDetail = ref(null) |
| | | |
| | | const tags = ref([]) |
| | | |
| | | |
| | | const tagType = ref() |
| | | |
| | |
| | | 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, |
| | |
| | | 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') |
| | | |
| | |
| | | |
| | | const getTags = () => { |
| | | request.get('tagStyle/getTagList').then(res => { |
| | | res.data.forEach(item => { |
| | | item.value = JSON.parse(item.value) |
| | | }) |
| | | tags.value = res.data |
| | | }) |
| | | } |
| | |
| | | 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) |
| | |
| | | }, |
| | | { |
| | | field: 'stock_id', |
| | | title: '版图号', |
| | | title: t('processCard.layoutNumber'), |
| | | filters: [{data: ''}], |
| | | slots: {filter: 'num1_filter'}, |
| | | filterMethod: filterChanged |
| | |
| | | toolbarConfig: { |
| | | buttons: [ |
| | | {code: 'printLabel3', name: t('basicData.print'), status: 'primary'}, |
| | | {code: 'printSmallPiece', name: t('小片打印'), status: 'primary'}, |
| | | ], |
| | | zoom: true, |
| | | custom: true |
| | |
| | | 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 |
| | |
| | | } |
| | | 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(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> |
| | |
| | | <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" |
| | |
| | | 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" |