Vue2集成Lodop插件實(shí)現(xiàn)在線打印功能
一、案例截圖
點(diǎn)擊打印按鈕,可以在線發(fā)送給打印機(jī)打印。

打印預(yù)覽頁(yè)面:

二、官方網(wǎng)站
這是地址:下載中心 - Lodop和C-Lodop官網(wǎng)主站

直接點(diǎn)擊下載就行,主要用到的就是官方提供的2個(gè)文件,分別是LodopFuncs.js和CLodop_Setup_for_Win32NT,就可以實(shí)現(xiàn)在線打印了。
三、安裝CLodop_Setup_for_Win32NT
雙擊無(wú)腦點(diǎn)擊下一步就行了。

安裝成功頁(yè)面:

四、LodopFuncs.js
工具類(lèi)我統(tǒng)一放在了這里,僅供參考:

官方的拿過(guò)來(lái)不能直接使用,會(huì)報(bào)錯(cuò),我微調(diào)了如下:
1、這里需要對(duì)外開(kāi)放getLodop方法。

2、其次修改了這里。

否則會(huì)報(bào)如下錯(cuò)誤:checkOrTryHttp is not defined ReferenceError: checkOrTryHttp is not defined at <anonymous>:1:1

下面是我調(diào)整好的代碼,直接一鍵復(fù)制使用即可。
完整代碼:
//==本JS是加載Lodop插件或Web打印服務(wù)CLodop/Lodop7的綜合示例,可直接使用,建議理解后融入自己程序==
//用雙端口加載主JS文件Lodop.js(或CLodopfuncs.js兼容老版本)以防其中某端口被占:
var MainJS ="CLodopfuncs.js",
URL_WS1 = "ws://localhost:8000/"+MainJS, //ws用8000/18000
URL_WS2 = "ws://localhost:18000/"+MainJS,
URL_HTTP1 = "http://localhost:8000/"+MainJS, //http用8000/18000
URL_HTTP2 = "http://localhost:18000/"+MainJS,
URL_HTTP3 = "https://localhost.lodop.net:8443/"+MainJS; //https用8000/8443
var CreatedOKLodopObject, CLodopIsLocal, LoadJsState;
//==判斷是否需要CLodop(那些不支持插件的瀏覽器):==
function needCLodop() {
try {
var ua = navigator.userAgent;
if (ua.match(/Windows\sPhone/i) ||
ua.match(/iPhone|iPod|iPad/i) ||
ua.match(/Android/i) ||
ua.match(/Edge\D?\d+/i))
return true;
var verTrident = ua.match(/Trident\D?\d+/i);
var verIE = ua.match(/MSIE\D?\d+/i);
var verOPR = ua.match(/OPR\D?\d+/i);
var verFF = ua.match(/Firefox\D?\d+/i);
var x64 = ua.match(/x64/i);
if ((!verTrident) && (!verIE) && (x64)) return true;
else if (verFF) {
verFF = verFF[0].match(/\d+/);
if ((verFF[0] >= 41) || (x64)) return true;
} else if (verOPR) {
verOPR = verOPR[0].match(/\d+/);
if (verOPR[0] >= 32) return true;
} else if ((!verTrident) && (!verIE)) {
var verChrome = ua.match(/Chrome\D?\d+/i);
if (verChrome) {
verChrome = verChrome[0].match(/\d+/);
if (verChrome[0] >= 41) return true;
}
}
return false;
} catch (err) {
return true;
}
}
//==檢查加載成功與否,如沒(méi)成功則用http(s)再試==
//==低版本CLODOP6.561/Lodop7.043及前)用本方法==
function checkOrTryHttp() {
if (window.getCLodop) {
LoadJsState = "complete";
return true;
}
if (LoadJsState == "loadingB" || LoadJsState == "complete") return;
LoadJsState = "loadingB";
var head = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
var JS1 = document.createElement("script")
,JS2 = document.createElement("script")
,JS3 = document.createElement("script");
JS1.src = URL_HTTP1;
JS2.src = URL_HTTP2;
JS3.src = URL_HTTP3;
JS1.onload = JS2.onload = JS3.onload = JS2.onerror = JS3.onerror=function(){LoadJsState = "complete";}
JS1.onerror = function(e) {
if (window.location.protocol !== 'https:')
head.insertBefore(JS2, head.firstChild); else
head.insertBefore(JS3, head.firstChild);
}
head.insertBefore(JS1,head.firstChild);
}
//==加載Lodop對(duì)象的主過(guò)程:==
(function loadCLodop(){
if (!needCLodop()) return;
CLodopIsLocal = !!((URL_WS1 + URL_WS2).match(/\/\/localho|\/\/127.0.0./i));
LoadJsState = "loadingA";
if (!window.WebSocket && window.MozWebSocket) window.WebSocket=window.MozWebSocket;
//ws方式速度快(小于200ms)且可避免CORS錯(cuò)誤,但要求Lodop版本足夠新:
try {
var WSK1=new WebSocket(URL_WS1);
WSK1.onopen = function(e) { setTimeout(checkOrTryHttp,200); }
WSK1.onmessage = function(e) {if (!window.getCLodop) eval(e.data);}
WSK1.onerror = function(e) {
var WSK2=new WebSocket(URL_WS2);
WSK2.onopen = function(e) {setTimeout(checkOrTryHttp,200);}
WSK2.onmessage = function(e) {if (!window.getCLodop) eval(e.data);}
WSK2.onerror= function(e) {checkOrTryHttp();}
}
} catch(e){
checkOrTryHttp();
}
})();
//==獲取LODOP對(duì)象主過(guò)程,判斷是否安裝、需否升級(jí):==
function getLodop(oOBJECT, oEMBED) {
var strFontTag = "<br><font color='#FF00FF'>打印控件";
var strLodopInstall = strFontTag + "未安裝!點(diǎn)擊這里<a href='install_lodop32.exe' target='_self'>執(zhí)行安裝</a>";
var strLodopUpdate = strFontTag + "需要升級(jí)!點(diǎn)擊這里<a href='install_lodop32.exe' target='_self'>執(zhí)行升級(jí)</a>";
var strLodop64Install = strFontTag + "未安裝!點(diǎn)擊這里<a href='install_lodop64.exe' target='_self'>執(zhí)行安裝</a>";
var strLodop64Update = strFontTag + "需要升級(jí)!點(diǎn)擊這里<a href='install_lodop64.exe' target='_self'>執(zhí)行升級(jí)</a>";
var strCLodopInstallA = "<br><font color='#FF00FF'>Web打印服務(wù)CLodop未安裝啟動(dòng),點(diǎn)擊這里<a href='CLodop_Setup_for_Win32NT.exe' target='_self'>下載執(zhí)行安裝</a>";
var strCLodopInstallB = "<br>(若此前已安裝過(guò),可<a href='CLodop.protocol:setup' target='_self'>點(diǎn)這里直接再次啟動(dòng)</a>)";
var strCLodopUpdate = "<br><font color='#FF00FF'>Web打印服務(wù)CLodop需升級(jí)!點(diǎn)擊這里<a href='CLodop_Setup_for_Win32NT.exe' target='_self'>執(zhí)行升級(jí)</a>";
var strLodop7FontTag = "<br><font color='#FF00FF'>Web打印服務(wù)Lodop7";
var strLodop7HrefX86 = "點(diǎn)擊這里<a href='Lodop7_Linux_X86_64.tar.gz' target='_self'>下載安裝</a>(下載后解壓,點(diǎn)擊lodop文件開(kāi)始執(zhí)行)";
var strLodop7HrefARM = "點(diǎn)擊這里<a href='Lodop7_Linux_ARM64.tar.gz' target='_self'>下載安裝</a>(下載后解壓,點(diǎn)擊lodop文件開(kāi)始執(zhí)行)";
var strLodop7Install_X86 = strLodop7FontTag + "未安裝啟動(dòng)," + strLodop7HrefX86;
var strLodop7Install_ARM = strLodop7FontTag + "未安裝啟動(dòng)," + strLodop7HrefARM;
var strLodop7Update_X86 = strLodop7FontTag + "需升級(jí)," + strLodop7HrefX86;
var strLodop7Update_ARM = strLodop7FontTag + "需升級(jí)," + strLodop7HrefARM;
var strInstallOK = ",成功后請(qǐng)刷新本頁(yè)面或重啟瀏覽器。</font>";
var LODOP;
try {
var isWinIE = (/MSIE/i.test(navigator.userAgent)) || (/Trident/i.test(navigator.userAgent));
var isWinIE64 = isWinIE && (/x64/i.test(navigator.userAgent));
var isLinuxX86 = (/Linux/i.test(navigator.platform)) && (/x86/i.test(navigator.platform));
var isLinuxARM = (/Linux/i.test(navigator.platform)) && (/aarch/i.test(navigator.platform));
if (needCLodop() || isLinuxX86 || isLinuxARM) {
try {
LODOP = window.getCLodop();
} catch (err) {}
if (!LODOP && LoadJsState !== "complete") {
if (!LoadJsState)
alert("未曾加載Lodop主JS文件,請(qǐng)先調(diào)用loadCLodop過(guò)程."); else
alert("網(wǎng)頁(yè)還沒(méi)下載完畢,請(qǐng)稍等一下再操作.");
return;
}
var strAlertMessage;
if (!LODOP) {
if (isLinuxX86)
strAlertMessage = strLodop7Install_X86;
else if (isLinuxARM)
strAlertMessage = strLodop7Install_ARM;
else
strAlertMessage = strCLodopInstallA + (CLodopIsLocal ? strCLodopInstallB : "");
document.body.innerHTML = strAlertMessage + strInstallOK + document.body.innerHTML;
return;
} else {
if (isLinuxX86 && LODOP.CVERSION < "7.1.0.1")
strAlertMessage = strLodop7Update_X86;
else if (isLinuxARM && LODOP.CVERSION < "7.1.0.1")
strAlertMessage = strLodop7Update_ARM;
else if (CLODOP.CVERSION < "6.6.2.1")
strAlertMessage = strCLodopUpdate;
if (strAlertMessage)
document.body.innerHTML = strAlertMessage + strInstallOK + document.body.innerHTML;
}
} else {
//==如果頁(yè)面有Lodop插件就直接使用,否則新建:==
if (oOBJECT || oEMBED) {
if (isWinIE)
LODOP = oOBJECT;
else
LODOP = oEMBED;
} else if (!CreatedOKLodopObject) {
LODOP = document.createElement("object");
LODOP.setAttribute("width", 0);
LODOP.setAttribute("height", 0);
LODOP.setAttribute("style", "position:absolute;left:0px;top:-100px;width:0px;height:0px;");
if (isWinIE)
LODOP.setAttribute("classid", "clsid:2105C259-1E0C-4534-8141-A753534CB4CA");
else
LODOP.setAttribute("type", "application/x-print-lodop");
document.documentElement.appendChild(LODOP);
CreatedOKLodopObject = LODOP;
} else
LODOP = CreatedOKLodopObject;
//==Lodop插件未安裝時(shí)提示下載地址:==
if ((!LODOP) || (!LODOP.VERSION)) {
document.body.innerHTML = (isWinIE64 ? strLodop64Install : strLodopInstall) + strInstallOK + document.body.innerHTML;
return LODOP;
}
if (LODOP.VERSION < "6.2.2.6") {
document.body.innerHTML = (isWinIE64 ? strLodop64Update : strLodopUpdate) + strInstallOK + document.body.innerHTML;
}
}
//===如下空白位置適合調(diào)用統(tǒng)一功能(如注冊(cè)語(yǔ)句、語(yǔ)言選擇等):=======================
//===============================================================================
return LODOP;
} catch (err) {
alert("getLodop出錯(cuò):" + err);
}
}
export { getLodop }五、實(shí)現(xiàn)打印
這里我預(yù)先安裝了Element-UI組件,沒(méi)有安裝的看官方文檔:Element - The world's most popular Vue UI framework
1、先引入JS方法。
import { getLodop } from "@/utils/LodopFuncs"2、打印功能的關(guān)鍵代碼。
printTable(){
let LODOP = getLodop();
if(!LODOP){
this.$message.error("未安裝打印插件");
return;
}
LODOP.SET_SHOW_MODE('LANDSCAPE_DEFROTATED', 1)
LODOP.SET_PRINT_PAGESIZE(2, 0, 0, 'A4')
LODOP.ADD_PRINT_HTM(15,0,'100%', '100%', document.getElementById('form').innerHTML)
LODOP.SET_PRINT_MODE('PRINT_PAGE_PERCENT', 'Width:100%;Height:100%')
LODOP.PREVIEW();
this.$message.success('已發(fā)送至打印機(jī)');
},3、完整代碼
<template>
<div>
<el-button type="danger" @click="printTable">打印</el-button>
<div id="form">
<h2 style="text-align: center">合同信息</h2>
<table border="1" style="border-collapse: collapse; width: 100%;">
<thead>
<tr>
<th>合同編號(hào)</th>
<th>合同名稱(chēng)</th>
<th>合同類(lèi)型</th>
<th>合同金額</th>
<th>合同簽署時(shí)間</th>
<th>簽署人</th>
<th>合同狀態(tài)</th>
<th>合同有效期</th>
<th>文件名</th>
<th>備注</th>
</tr>
</thead>
<tbody>
<tr v-for="contract in contracts" :key="contract.id">
<td>{{ contract.contractNumber }}</td>
<td>{{ contract.contractName }}</td>
<td>{{ contract.contractType }}</td>
<td>{{ contract.contractAmount }}</td>
<td>{{ contract.signingDate }}</td>
<td>{{ contract.signer }}</td>
<td>{{ contract.status }}</td>
<td>{{ contract.validityPeriod }}</td>
<td>{{ contract.fileName }}</td>
<td>{{ contract.notes }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</template>
<script>
import { getLodop } from "@/utils/LodopFuncs"
export default {
name: 'HomeView',
data() {
return {
contracts: [
{
id: 1, contractNumber: 'H001', contractName: '服務(wù)合同A', contractType: '服務(wù)', contractAmount: '5000',
signingDate: '2025-01-15', signer: '張三', status: '有效', validityPeriod: '2025-12-31', fileName: 'contract_A.pdf', notes: '無(wú)'
},
{
id: 2, contractNumber: 'H002', contractName: '產(chǎn)品采購(gòu)B', contractType: '采購(gòu)', contractAmount: '15000',
signingDate: '2025-01-20', signer: '李四', status: '有效', validityPeriod: '2026-01-20', fileName: 'contract_B.pdf', notes: '急需'
},
{
id: 3, contractNumber: 'H003', contractName: '合作協(xié)議C', contractType: '合作', contractAmount: '8000',
signingDate: '2025-02-05', signer: '王五', status: '有效', validityPeriod: '2025-12-31', fileName: 'contract_C.pdf', notes: '審核中'
},
{
id: 4, contractNumber: 'H004', contractName: '租賃合同D', contractType: '租賃', contractAmount: '20000',
signingDate: '2025-02-10', signer: '趙六', status: '有效', validityPeriod: '2026-02-10', fileName: 'contract_D.pdf', notes: '續(xù)租'
},
{
id: 5, contractNumber: 'H005', contractName: '咨詢(xún)合同E', contractType: '咨詢(xún)', contractAmount: '3000',
signingDate: '2025-02-15', signer: '錢(qián)七', status: '有效', validityPeriod: '2025-12-15', fileName: 'contract_E.pdf', notes: '無(wú)'
},
{
id: 6, contractNumber: 'H006', contractName: '服務(wù)合同F(xiàn)', contractType: '服務(wù)', contractAmount: '6000',
signingDate: '2025-02-20', signer: '孫八', status: '有效', validityPeriod: '2026-02-20', fileName: 'contract_F.pdf', notes: '定期檢查'
},
{
id: 7, contractNumber: 'H007', contractName: '采購(gòu)合同G', contractType: '采購(gòu)', contractAmount: '25000',
signingDate: '2025-03-01', signer: '周九', status: '有效', validityPeriod: '2026-03-01', fileName: 'contract_G.pdf', notes: '緊急訂單'
},
{
id: 8, contractNumber: 'H008', contractName: '協(xié)議合同H', contractType: '協(xié)議', contractAmount: '7000',
signingDate: '2025-03-05', signer: '吳十', status: '有效', validityPeriod: '2025-09-05', fileName: 'contract_H.pdf', notes: '待續(xù)簽'
},
{
id: 9, contractNumber: 'H009', contractName: '建設(shè)合同I', contractType: '建設(shè)', contractAmount: '100000',
signingDate: '2025-03-10', signer: '鄭十一', status: '有效', validityPeriod: '2027-03-10', fileName: 'contract_I.pdf', notes: '需監(jiān)理'
},
{
id: 10, contractNumber: 'H010', contractName: '開(kāi)發(fā)合同J', contractType: '開(kāi)發(fā)', contractAmount: '40000',
signingDate: '2025-03-15', signer: '馮十二', status: '有效', validityPeriod: '2026-03-15', fileName: 'contract_J.pdf', notes: '階段性支付'
},
{
id: 11, contractNumber: 'H011', contractName: '許可協(xié)議K', contractType: '許可', contractAmount: '9500',
signingDate: '2025-03-16', signer: '陳十三', status: '有效', validityPeriod: '2025-11-16', fileName: 'contract_K.pdf', notes: '無(wú)'
},
{
id: 12, contractNumber: 'H012', contractName: '保密合同L', contractType: '保密', contractAmount: '3000',
signingDate: '2025-03-17', signer: '蔡十四', status: '有效', validityPeriod: '2025-12-17', fileName: 'contract_L.pdf', notes: '無(wú)'
},
{
id: 13, contractNumber: 'H013', contractName: '轉(zhuǎn)讓協(xié)議M', contractType: '轉(zhuǎn)讓', contractAmount: '12000',
signingDate: '2025-03-18', signer: '杜十五', status: '有效', validityPeriod: '2026-03-18', fileName: 'contract_M.pdf', notes: '待確認(rèn)'
},
{
id: 14, contractNumber: 'H014', contractName: '委托合同N', contractType: '委托', contractAmount: '5000',
signingDate: '2025-03-19', signer: '李十六', status: '有效', validityPeriod: '2025-11-19', fileName: 'contract_N.pdf', notes: '無(wú)'
},
{
id: 15, contractNumber: 'H015', contractName: '資產(chǎn)購(gòu)買(mǎi)合同O', contractType: '購(gòu)買(mǎi)', contractAmount: '200000',
signingDate: '2025-03-20', signer: '沈十七', status: '有效', validityPeriod: '2028-03-20', fileName: 'contract_O.pdf', notes: '融資中'
},
{
id: 16, contractNumber: 'H016', contractName: '融資協(xié)議P', contractType: '融資', contractAmount: '50000',
signingDate: '2025-03-21', signer: '馮十八', status: '有效', validityPeriod: '2026-03-21', fileName: 'contract_P.pdf', notes: '審計(jì)中'
},
{
id: 17, contractNumber: 'H017', contractName: '市場(chǎng)推廣合同Q', contractType: '推廣', contractAmount: '7000',
signingDate: '2025-03-22', signer: '朱十九', status: '有效', validityPeriod: '2026-03-22', fileName: 'contract_Q.pdf', notes: '待溝通'
},
{
id: 18, contractNumber: 'H018', contractName: '財(cái)務(wù)顧問(wèn)合同R', contractType: '顧問(wèn)', contractAmount: '5000',
signingDate: '2025-03-23', signer: '巴二十', status: '有效', validityPeriod: '2025-09-23', fileName: 'contract_R.pdf', notes: '無(wú)'
},
{
id: 19, contractNumber: 'H019', contractName: '法律顧問(wèn)合同S', contractType: '顧問(wèn)', contractAmount: '15000',
signingDate: '2025-03-24', signer: '許二一', status: '有效', validityPeriod: '2026-03-24', fileName: 'contract_S.pdf', notes: '無(wú)'
},
{
id: 20, contractNumber: 'H020', contractName: '跨國(guó)采購(gòu)合同T', contractType: '采購(gòu)', contractAmount: '18000',
signingDate: '2025-03-25', signer: '何二二', status: '有效', validityPeriod: '2026-03-25', fileName: 'contract_T.pdf', notes: '無(wú)'
},
{
id: 21, contractNumber: 'H001', contractName: '服務(wù)合同A', contractType: '服務(wù)', contractAmount: '5000',
signingDate: '2025-01-15', signer: '張三', status: '有效', validityPeriod: '2025-12-31', fileName: 'contract_A.pdf', notes: '無(wú)'
},
{
id: 22, contractNumber: 'H002', contractName: '產(chǎn)品采購(gòu)B', contractType: '采購(gòu)', contractAmount: '15000',
signingDate: '2025-01-20', signer: '李四', status: '有效', validityPeriod: '2026-01-20', fileName: 'contract_B.pdf', notes: '急需'
},
{
id: 23, contractNumber: 'H003', contractName: '合作協(xié)議C', contractType: '合作', contractAmount: '8000',
signingDate: '2025-02-05', signer: '王五', status: '有效', validityPeriod: '2025-12-31', fileName: 'contract_C.pdf', notes: '審核中'
},
{
id: 24, contractNumber: 'H004', contractName: '租賃合同D', contractType: '租賃', contractAmount: '20000',
signingDate: '2025-02-10', signer: '趙六', status: '有效', validityPeriod: '2026-02-10', fileName: 'contract_D.pdf', notes: '續(xù)租'
},
{
id: 25, contractNumber: 'H005', contractName: '咨詢(xún)合同E', contractType: '咨詢(xún)', contractAmount: '3000',
signingDate: '2025-02-15', signer: '錢(qián)七', status: '有效', validityPeriod: '2025-12-15', fileName: 'contract_E.pdf', notes: '無(wú)'
},
{
id: 26, contractNumber: 'H006', contractName: '服務(wù)合同F(xiàn)', contractType: '服務(wù)', contractAmount: '6000',
signingDate: '2025-02-20', signer: '孫八', status: '有效', validityPeriod: '2026-02-20', fileName: 'contract_F.pdf', notes: '定期檢查'
},
{
id: 27, contractNumber: 'H007', contractName: '采購(gòu)合同G', contractType: '采購(gòu)', contractAmount: '25000',
signingDate: '2025-03-01', signer: '周九', status: '有效', validityPeriod: '2026-03-01', fileName: 'contract_G.pdf', notes: '緊急訂單'
},
{
id: 28, contractNumber: 'H008', contractName: '協(xié)議合同H', contractType: '協(xié)議', contractAmount: '7000',
signingDate: '2025-03-05', signer: '吳十', status: '有效', validityPeriod: '2025-09-05', fileName: 'contract_H.pdf', notes: '待續(xù)簽'
},
{
id: 29, contractNumber: 'H009', contractName: '建設(shè)合同I', contractType: '建設(shè)', contractAmount: '100000',
signingDate: '2025-03-10', signer: '鄭十一', status: '有效', validityPeriod: '2027-03-10', fileName: 'contract_I.pdf', notes: '需監(jiān)理'
},
{
id: 30, contractNumber: 'H010', contractName: '開(kāi)發(fā)合同J', contractType: '開(kāi)發(fā)', contractAmount: '40000',
signingDate: '2025-03-15', signer: '馮十二', status: '有效', validityPeriod: '2026-03-15', fileName: 'contract_J.pdf', notes: '階段性支付'
},
{
id: 31, contractNumber: 'H011', contractName: '許可協(xié)議K', contractType: '許可', contractAmount: '9500',
signingDate: '2025-03-16', signer: '陳十三', status: '有效', validityPeriod: '2025-11-16', fileName: 'contract_K.pdf', notes: '無(wú)'
},
{
id: 32, contractNumber: 'H012', contractName: '保密合同L', contractType: '保密', contractAmount: '3000',
signingDate: '2025-03-17', signer: '蔡十四', status: '有效', validityPeriod: '2025-12-17', fileName: 'contract_L.pdf', notes: '無(wú)'
},
{
id: 33, contractNumber: 'H013', contractName: '轉(zhuǎn)讓協(xié)議M', contractType: '轉(zhuǎn)讓', contractAmount: '12000',
signingDate: '2025-03-18', signer: '杜十五', status: '有效', validityPeriod: '2026-03-18', fileName: 'contract_M.pdf', notes: '待確認(rèn)'
},
{
id: 34, contractNumber: 'H014', contractName: '委托合同N', contractType: '委托', contractAmount: '5000',
signingDate: '2025-03-19', signer: '李十六', status: '有效', validityPeriod: '2025-11-19', fileName: 'contract_N.pdf', notes: '無(wú)'
},
{
id: 35, contractNumber: 'H015', contractName: '資產(chǎn)購(gòu)買(mǎi)合同O', contractType: '購(gòu)買(mǎi)', contractAmount: '200000',
signingDate: '2025-03-20', signer: '沈十七', status: '有效', validityPeriod: '2028-03-20', fileName: 'contract_O.pdf', notes: '融資中'
},
{
id: 36, contractNumber: 'H016', contractName: '融資協(xié)議P', contractType: '融資', contractAmount: '50000',
signingDate: '2025-03-21', signer: '馮十八', status: '有效', validityPeriod: '2026-03-21', fileName: 'contract_P.pdf', notes: '審計(jì)中'
},
{
id: 37, contractNumber: 'H017', contractName: '市場(chǎng)推廣合同Q', contractType: '推廣', contractAmount: '7000',
signingDate: '2025-03-22', signer: '朱十九', status: '有效', validityPeriod: '2026-03-22', fileName: 'contract_Q.pdf', notes: '待溝通'
},
{
id: 38, contractNumber: 'H018', contractName: '財(cái)務(wù)顧問(wèn)合同R', contractType: '顧問(wèn)', contractAmount: '5000',
signingDate: '2025-03-23', signer: '巴二十', status: '有效', validityPeriod: '2025-09-23', fileName: 'contract_R.pdf', notes: '無(wú)'
},
{
id: 39, contractNumber: 'H019', contractName: '法律顧問(wèn)合同S', contractType: '顧問(wèn)', contractAmount: '15000',
signingDate: '2025-03-24', signer: '許二一', status: '有效', validityPeriod: '2026-03-24', fileName: 'contract_S.pdf', notes: '無(wú)'
},
{
id: 40, contractNumber: 'H020', contractName: '跨國(guó)采購(gòu)合同T', contractType: '采購(gòu)', contractAmount: '18000',
signingDate: '2025-03-25', signer: '何二二', status: '有效', validityPeriod: '2026-03-25', fileName: 'contract_T.pdf', notes: '無(wú)'
}
]
};
},
methods:{
printTable(){
let LODOP = getLodop();
if(!LODOP){
this.$message.error("未安裝打印插件");
return;
}
LODOP.SET_SHOW_MODE('LANDSCAPE_DEFROTATED', 1)
LODOP.SET_PRINT_PAGESIZE(2, 0, 0, 'A4')
LODOP.ADD_PRINT_HTM(15,0,'100%', '100%', document.getElementById('form').innerHTML)
LODOP.SET_PRINT_MODE('PRINT_PAGE_PERCENT', 'Width:100%;Height:100%')
LODOP.PREVIEW();
this.$message.success('已發(fā)送至打印機(jī)');
},
}
}
</script>以上就是Vue2集成Lodop插件實(shí)現(xiàn)在線打印功能的詳細(xì)內(nèi)容,更多關(guān)于Vue Lodop在線打印的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
vue-cli中的babel配置文件.babelrc實(shí)例詳解
Babel是一個(gè)廣泛使用的轉(zhuǎn)碼器,可以將ES6代碼轉(zhuǎn)為ES5代碼,從而在現(xiàn)有環(huán)境執(zhí)行。本文介紹vue-cli腳手架工具根目錄的babelrc配置文件,感興趣的朋友一起看看吧2018-02-02
vue-cli 為項(xiàng)目設(shè)置別名的方法
這篇文章主要介紹了vue-cli 為項(xiàng)目設(shè)置別名的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10
element-ui中樣式覆蓋問(wèn)題的方法總結(jié)
我們?cè)谑褂胑lement-ui的時(shí)候經(jīng)常會(huì)遇到需要修改組件默認(rèn)樣式,下面這篇文章主要給大家介紹了關(guān)于element-ui中樣式覆蓋問(wèn)題的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-03-03
vue路由攔截及頁(yè)面跳轉(zhuǎn)的設(shè)置方法
這篇文章主要介紹了vue路由攔截及頁(yè)面跳轉(zhuǎn)的設(shè)置方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-05-05
Vue + OpenLayers 快速入門(mén)學(xué)習(xí)教程
大家都知道使用 Openlayers可以很靈活自由的做出各種地圖和空間數(shù)據(jù)的展示。而且這個(gè)框架是完全免費(fèi)和開(kāi)源的,本文記錄下 Vue 使用 OpenLayers 入門(mén),使用 OpenLayers 創(chuàng)建地圖組件的相關(guān)知識(shí),需要的朋友一起學(xué)習(xí)下吧2021-09-09
Vue報(bào)錯(cuò):TypeError:?Cannot?create?property?‘xxxx‘?on的解決
這篇文章主要介紹了Vue報(bào)錯(cuò):TypeError:?Cannot?create?property?‘xxxx‘?on的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-06-06
vue如何搭建多頁(yè)面多系統(tǒng)應(yīng)用
這篇文章主要為大家詳細(xì)介紹了vue搭建多頁(yè)面多系統(tǒng)應(yīng)用的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-06-06

