|
@@ -1,4 +1,5 @@
|
|
|
import confirm from 'ant-design-vue/es/modal/confirm'
|
|
|
+import { Modal } from 'ant-design-vue'
|
|
|
import notification from 'ant-design-vue/es/notification'
|
|
|
import store from '@/store'
|
|
|
import { getLodop } from '@/libs/LodopFuncs'
|
|
@@ -13,6 +14,7 @@ export const JGPrintTag = function (html, width, height, data) {
|
|
|
okText: '立即下载',
|
|
|
okType: 'danger',
|
|
|
cancelText: '暂不打印',
|
|
|
+ zIndex: 100000,
|
|
|
onOk () {
|
|
|
var agent = navigator.userAgent.toLowerCase();
|
|
|
if (agent.indexOf("win32") >= 0 || agent.indexOf("wow32") >= 0) {
|
|
@@ -100,7 +102,8 @@ export const hdPrint = function (printerType, type, url, params, fileName, callb
|
|
|
if (type == 'export') { // 导出
|
|
|
downloadExcel(res, fileName)
|
|
|
} else { // 打印
|
|
|
- jGPrint(res, type, printerType, fileName)
|
|
|
+ const taskName = fileName+'-'+(params.sn||params.checkWarehouseSn||params.settleClientSn)+'-'
|
|
|
+ jGPrint(res, type, printerType, taskName)
|
|
|
}
|
|
|
}
|
|
|
callback()
|
|
@@ -144,6 +147,17 @@ export const getPrintList = function(){
|
|
|
}
|
|
|
return printList
|
|
|
}
|
|
|
+// 获取打印机状态
|
|
|
+export const getStatusValue = function (ValueType,ValueIndex,callback){
|
|
|
+ const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
|
|
|
+ if (LODOP.CVERSION) {
|
|
|
+ LODOP.On_Return=function(TaskID,Value){
|
|
|
+ callback(Value)
|
|
|
+ };
|
|
|
+ }
|
|
|
+ var strResult=LODOP.GET_VALUE(ValueType,ValueIndex);
|
|
|
+ if (!LODOP.CVERSION) return callback(strResult); else return callback('');
|
|
|
+ }
|
|
|
// pdf 直接打印
|
|
|
export const pdfPrint = function (data,index){
|
|
|
const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
|
|
@@ -151,7 +165,9 @@ export const pdfPrint = function (data,index){
|
|
|
// LODOP.SET_PRINT_MODE('POS_BASEON_PAPER', true) // 可使输出以纸张边缘为基点
|
|
|
// 开始打印
|
|
|
const dlen = data.length
|
|
|
- LODOP.PRINT_INIT(store.state.app.printTaskName +index+'-')
|
|
|
+ // 打印进入队列开始
|
|
|
+ store.commit('SET_printLoading',true)
|
|
|
+ LODOP.PRINT_INIT(store.state.app.printTaskName + (dlen>1 ? ('第'+(index+1)+'页') : ''))
|
|
|
//这个语句设置网络共享打印机连接不通时是否提示一下
|
|
|
LODOP.SET_PRINT_MODE("TRYLINKPRINTER_NOALERT",true);
|
|
|
//执行该语句之后,PRINT指令不再返回那个所谓“打印成功”,才能获取到打印状态
|
|
@@ -162,6 +178,9 @@ export const pdfPrint = function (data,index){
|
|
|
store.commit('SET_printTaskID',Value)
|
|
|
if(index+1 < dlen){
|
|
|
pdfPrint(data,index+1)
|
|
|
+ }else{
|
|
|
+ // 打印进入队列结束
|
|
|
+ store.commit('SET_printLoading',false)
|
|
|
}
|
|
|
};
|
|
|
// 指定打印机
|
|
@@ -170,7 +189,47 @@ export const pdfPrint = function (data,index){
|
|
|
LODOP.SET_PRINT_PAGESIZE(3, 2090, (index==dlen-1)?50:0, '')
|
|
|
LODOP.PRINT()
|
|
|
}
|
|
|
-
|
|
|
+// 判断当前单据是否已存在打印任务列表中
|
|
|
+ export const hasExitTaskByName = function(noCallback){
|
|
|
+ const printTaskID = store.state.app.printTaskID
|
|
|
+ const printLoading = store.state.app.printLoading
|
|
|
+ if(printLoading){
|
|
|
+ Modal.info({
|
|
|
+ title: '提示',
|
|
|
+ content: '打印机正在打印中...',
|
|
|
+ okText: '知道了',
|
|
|
+ okType: 'danger',
|
|
|
+ centered: true,
|
|
|
+ zIndex: 100000
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ if(printTaskID){
|
|
|
+ getStatusValue('PRINT_STATUS_BUSY',printTaskID,function(isExist){
|
|
|
+ console.log(isExist)
|
|
|
+ if(isExist.length){
|
|
|
+ if(isExist != '0'){
|
|
|
+ confirm({
|
|
|
+ title: '提示',
|
|
|
+ content: h => <div style='font-size:14px;'><div>打印机正在打印中...</div><div>或者有未完成的打印任务</div><div>是否继续添加打印任务?</div></div>,
|
|
|
+ okText: '继续打印',
|
|
|
+ okType: 'danger',
|
|
|
+ cancelText: '取消',
|
|
|
+ centered: true,
|
|
|
+ zIndex: 100000,
|
|
|
+ onOk () {
|
|
|
+ noCallback()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ noCallback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ noCallback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// 打印控件
|
|
|
export const jGPrint = function (data, type, printerType, taskName) {
|
|
|
if (!data) {
|
|
@@ -203,13 +262,12 @@ export const jGPrint = function (data, type, printerType, taskName) {
|
|
|
store.commit('SET_showPdfPrint', data.data)
|
|
|
store.commit('SET_printTaskName', taskName)
|
|
|
} else if (type == 'print') { // pdf 打印
|
|
|
- // console.log(store.state.app.printTaskID)
|
|
|
- // PRINT_STATUS_BUSY
|
|
|
- // LODOP.GET_VALUE("PRINT_STATUS_OK",store.state.app.printTaskID);
|
|
|
- // 先选择打印机
|
|
|
- store.commit('SET_pdfPrintList', data.data)
|
|
|
- store.commit('SET_showSelectPrint', true)
|
|
|
- store.commit('SET_printTaskName', taskName)
|
|
|
+ hasExitTaskByName(function(){
|
|
|
+ // 选择打印机
|
|
|
+ store.commit('SET_pdfPrintList', data.data)
|
|
|
+ store.commit('SET_showSelectPrint', true)
|
|
|
+ store.commit('SET_printTaskName', taskName)
|
|
|
+ })
|
|
|
}
|
|
|
} else {
|
|
|
// 喷墨打印
|