mirror of
https://gitee.com/ShopeX/OMS
synced 2026-03-31 13:25:32 +08:00
305 lines
11 KiB
HTML
305 lines
11 KiB
HTML
<!--
|
||
Copyright 2012-2026 ShopeX (https://www.shopex.cn)
|
||
|
||
Licensed under the Apache License, Version 2.0 (the "License");
|
||
you may not use this file except in compliance with the License.
|
||
You may obtain a copy of the License at
|
||
|
||
http://www.apache.org/licenses/LICENSE-2.0
|
||
|
||
Unless required by applicable law or agreed to in writing, software
|
||
distributed under the License is distributed on an "AS IS" BASIS,
|
||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
See the License for the specific language governing permissions and
|
||
limitations under the License.
|
||
-->
|
||
|
||
<textarea id="template_data" name="template_data" style="display:none">
|
||
<{if $printTmpl.template_data}>
|
||
<{$printTmpl.template_data}>
|
||
<{else}>
|
||
paper:<{$printTmpl.template_width}>,<{$printTmpl.template_height}>,NONE;
|
||
<{/if}>
|
||
</textarea>
|
||
<textarea id="jsondata_newdata" style="display:none">
|
||
<{$jsondata}>
|
||
</textarea>
|
||
<script>
|
||
(function() {
|
||
var embedId = 'embed1<{$uniqid}>';
|
||
var embed1 = $(embedId);
|
||
var browerType = parseInt("<{$userAgent.type}>");
|
||
var totalPage = '<{$totalPage}>';
|
||
var curPage = 0;
|
||
//控件没有安装, IE, Chrome没有安装控件为object,Firfox没有安装控件为function
|
||
if ( ("object" == typeof(embed1) || "function" == typeof(embed1)) && ('adjustpos' in embed1 == false)) {
|
||
$(embedId).setStyle('display', 'none');
|
||
if('normal' == '<{$printTmpl.template_type}>'){
|
||
$('express_tools').setStyle('display', 'none');
|
||
$('formContent').setStyle('display', 'none');
|
||
}
|
||
else {
|
||
$('formContent').setStyle('display', 'none');
|
||
}
|
||
downloadprintsite();
|
||
}
|
||
|
||
window.addEvent('domready', function() {
|
||
var printerlist = embed1.loadprinterlist();
|
||
var result = JSON.decode(printerlist);
|
||
if(result.printerlist){
|
||
var defaultIndex = expressIndex = -1;
|
||
//组织打印机选择列表
|
||
var temp = '<select id="printerlist" name="printerlist" class="x-input-select inputstyle" style="width:130px;">';
|
||
Object.each(result.printerlist,function(i,index){
|
||
temp+='<option value="'+i.printername+'">'+i.printername+'</option>';
|
||
//记录默认打印机的键值
|
||
if(result.default == i.printername) {
|
||
defaultIndex = index;
|
||
}
|
||
//记录上次选择的打印机键值
|
||
if(result.lastSelected.express == i.printername && result.lastSelected.express !='') {
|
||
expressIndex = index;
|
||
}
|
||
});
|
||
temp+='</select>';
|
||
$('printerSpan').set('html', temp);
|
||
|
||
//设置本次应该选择的打印机
|
||
var printerIndex = 0;
|
||
if(expressIndex>=0) {
|
||
printerIndex = expressIndex;
|
||
} else if(defaultIndex>=0) {
|
||
printerIndex = defaultIndex;
|
||
}
|
||
$('printerlist').options[printerIndex].selected = true;
|
||
|
||
//设置本次选择打印机的属性
|
||
var selectPrinter = result.printerlist[printerIndex];
|
||
if(selectPrinter) {
|
||
//设置偏移量
|
||
$('offsetx').set('value', selectPrinter.x);
|
||
$('offsety').set('value', selectPrinter.y);
|
||
//设置热敏
|
||
if (selectPrinter.isThermal) {
|
||
$('thermal').set('checked', true);
|
||
} else {
|
||
$('thermal').set('checked', false);
|
||
}
|
||
}
|
||
|
||
//增加打印机变更事件
|
||
$('printerlist').addEvent('change',function(){
|
||
var printer = $("printerlist").value;
|
||
Object.each(result.printerlist,function(i,index){
|
||
if(printer == i.printername) {
|
||
//设置偏移量
|
||
$('offsetx').set('value', i.x);
|
||
$('offsety').set('value', i.y);
|
||
//设置热敏
|
||
if (i.isThermal) {
|
||
$('thermal').set('checked', true);
|
||
} else {
|
||
$('thermal').set('checked', false);
|
||
}
|
||
}
|
||
});
|
||
});
|
||
}
|
||
else {
|
||
$('printPreview_1').setStyle('display', 'none');
|
||
$('printPreview_2').setStyle('display', 'none');
|
||
$('printPreview_3').setStyle('display', '');
|
||
}
|
||
});
|
||
|
||
$('printPreview_close').addEvent('click', function(){
|
||
window.close();
|
||
});
|
||
|
||
$('printerSetting').addEvent('click', function(){
|
||
var printer = $('printerlist').value;
|
||
var thermal = ($('thermal').checked==true) ? 1 : 0;
|
||
embed1.printreport(printer,'express',1,thermal);
|
||
});
|
||
|
||
if($('onlyprint_btn')) {
|
||
$('onlyprint_btn').addEvent('click', function(){
|
||
var printer = $('printerlist').value;
|
||
var thermal = ($('thermal').checked==true) ? 1 : 0;
|
||
var offsetx = $('offsetx').value;
|
||
var offsety = $('offsety').value;
|
||
offsetx = offsetx.toInt();
|
||
offsety = offsety.toInt();
|
||
|
||
/* 设置偏移量 */
|
||
if(offsetx>0 || offsety>0) {
|
||
embed1.adjustpos(offsetx,offsety,printer);
|
||
}
|
||
/* 执行打印 */
|
||
embed1.printreport(printer,'express',0,thermal);
|
||
});
|
||
}
|
||
|
||
if($('doprint_btn')) {
|
||
$('doprint_btn').addEvent('click', function(){
|
||
new Dialog(new Element("div.tableform",{html:'<div id="pause" class="division">正在提交...<{img app="desktop" src="loading.gif"}></div><div class="table-action"><{button label="关闭" onclick="re_finder();"}></div>'}),{
|
||
title:'提示',
|
||
width:230,
|
||
height:130,
|
||
modal:true,
|
||
resizeable:false}
|
||
);
|
||
if ($('printname')) {
|
||
var printname= $('printname').value;
|
||
} else {
|
||
var printname= '';
|
||
<{if $vid}>
|
||
printname= '<{$vid}>';
|
||
<{/if}>
|
||
}
|
||
new Request({url:'index.php?app=ome&ctl=admin_receipts_print&act=setPrintStatus',method:'post',data:'type=express&str='+printname,
|
||
onSuccess:function(json){
|
||
if (json == 'true'){
|
||
$('pause').getParent('.dialog').retrieve('instance').close();
|
||
var printer = $('printerlist').value;
|
||
var thermal = ($('thermal').checked==true) ? 1 : 0;
|
||
var offsetx = $('offsetx').value;
|
||
var offsety = $('offsety').value;
|
||
offsetx = offsetx.toInt();
|
||
offsety = offsety.toInt();
|
||
|
||
/* 设置偏移量 */
|
||
//if(offsetx>0 || offsety>0) {
|
||
// embed1.adjustpos(10,20,printer);
|
||
//}
|
||
embed1.adjustpos(offsetx,offsety,printer);
|
||
/* 执行打印 */
|
||
embed1.printreport(printer,'express',0,thermal);
|
||
|
||
if('normal' == '<{$printTmpl.template_type}>'){
|
||
/*显示运单号绑定*/
|
||
setTimeout(showBindLogi,1000);
|
||
}
|
||
}else {
|
||
$('pause').set('text',json);
|
||
}
|
||
}
|
||
}).send();
|
||
});
|
||
}
|
||
|
||
/* 加载打印控件编辑器 */
|
||
function loadReport() {
|
||
var s = $("template_data").value;
|
||
try {
|
||
//var vAbout = embed1.LoadReport(s,jsondata);
|
||
da = $('jsondata_newdata').value
|
||
//var vAbout = embed1.LoadReport(s,da,0);
|
||
if (browerType == 2) {
|
||
var vAbout = embed1.LoadReport(s,da,0);
|
||
}
|
||
else {
|
||
setTimeout(function(){var vAbout = embed1.LoadReport(s,da,0);}, 20);
|
||
}
|
||
} catch(e) {
|
||
alert(e.number);
|
||
}
|
||
return false;
|
||
}
|
||
loadReport();
|
||
|
||
<{if $totalPage>1}>
|
||
/* 跳转到某条 */
|
||
var jump=$('jumpinput');
|
||
var keyCodeFix=[13,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105,8,9,46,37,39];
|
||
|
||
jump.addEvent('keydown',function(e){
|
||
if(!keyCodeFix.contains(e.code)){e.stop();}
|
||
if (e.key=="enter") {
|
||
var page = jump.value.toInt()-1;
|
||
if (page>=0 && page<totalPage) {
|
||
curPage = page;
|
||
embed1.moveto(page);
|
||
}
|
||
}
|
||
});
|
||
|
||
/* 上一条 */
|
||
$('uppage').addEvent('click', function(){
|
||
var page = curPage-1;
|
||
if (page>0 && page<totalPage) {
|
||
curPage = page;
|
||
embed1.moveto(page);
|
||
} else {
|
||
curPage = 0;
|
||
embed1.moveto(0);
|
||
}
|
||
});
|
||
|
||
/* 下一条 */
|
||
$('nextpage').addEvent('click', function(){
|
||
var page = curPage+1;
|
||
if (page<totalPage && page>0) {
|
||
curPage = page;
|
||
embed1.moveto(page);
|
||
} else {
|
||
curPage = totalPage;
|
||
embed1.moveto(totalPage);
|
||
}
|
||
});
|
||
<{/if}>
|
||
|
||
<{ if $errIds }>
|
||
var alertMsg = '';
|
||
<{ foreach from=$errIds item=cid }>
|
||
alertMsg = alertMsg + "<{$errBns[$cid]}>:" + "<{$errInfo[$cid]}> <br/>" ;
|
||
alertMsg = alertMsg + '';
|
||
<{/foreach}>
|
||
|
||
alertMsg = alertMsg + '<br/>以上发货单在本次打印列表中已被剔除,请在处理后重新打印。';
|
||
|
||
$('information').style.display='';
|
||
if ($('information').innerHTML != '') {
|
||
$('information').innerHTML = $('information').innerHTML + alertMsg;
|
||
} else {
|
||
$('information').innerHTML = alertMsg;
|
||
}
|
||
<{ /if }>
|
||
})();
|
||
function downloadprintsite_back() {
|
||
new Request({url:'index.php?app=ome&ctl=admin_order&act=downloadPrintSite',
|
||
onComplete:function(result){
|
||
if(!result) return;
|
||
ret = JSON.decode(result);
|
||
$("downprintsite").show();
|
||
$("downprintsiteurl").set('html', '<a target="_blank" href="'+ret.url+'">控件下载</a>');
|
||
}
|
||
}).send();
|
||
}
|
||
|
||
function downloadprintsite() {
|
||
setTimeout('diagLoadPrintSite()',1000);
|
||
}
|
||
|
||
function diagLoadPrintSite() {
|
||
new Dialog('index.php?app=ome&ctl=admin_order&act=diagLoadPrintSite',{width:500,height:220,title:'ShopEx Print Controller',
|
||
onClose:function(){
|
||
self.close();
|
||
}
|
||
});
|
||
}
|
||
|
||
function errorreportprintsite(errmsg) {
|
||
var data={'errmsg':errmsg};
|
||
new Request({
|
||
url : 'index.php?app=ome&ctl=admin_order&act=errorReportPrintSite',
|
||
method : 'post',
|
||
data:data,
|
||
onSuccess:function(responseText){
|
||
;
|
||
}
|
||
}).send();
|
||
}
|
||
</script>
|