Files
OMS/app/brush/view/admin/delivery.html
2026-01-04 19:08:31 +08:00

190 lines
6.1 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!--
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.
-->
<style>
.notice a {
color: blue;
font-size: 12px;
font-weight: 700;
margin-left: 4px;
margin-right: 4px;
}
.notify {
border-color: #FFD324;
font-size: 12px;
}
.processBarBg {
border: 1px solid #999999;
width: 98%;
margin: 5px;
height: 25px;
line-height: 25px;
padding: 1px;
background: #EEEEEE;
}
.processBar {
background: #3366cc;
width: 0px;
padding-bottom: 1px;
overflow: hidden;
}
</style>
<div class="division">
<h4>当前共<{$deliveryCount}>个发货单</h4>
<div class="division" style="display:none;" id="information">
本次获取大约 <span id="iTotal" style="color:#083E96"></span> 个发货单,
<span id="iSucc" style="color:green"></span> 个发货成功,
<span id="iFail" style="color:red"></span> 个发货失败,请稍候……
<br/>
其中<span id="noPrint" style="color:red;"></span>个未打印
</div>
<div id="processBarBg" class="processBarBg">
<div id="processBar" class="processBar">
&nbsp;
</div>
</div>
<div class="table-action">
<{button label="开始" type="botton" name="Start" id="btn-run"}>
<{button label="关闭" type="botton" isCloseDialogBtn="true" }>
</div>
</div>
<script>
(function(){
$('btn-run').addEvent('click', function(){
doRun();
});
var MaxProcessOrderNum = 100;
var OrderGroups = <{$deliveryGroup}>;
var total = <{$deliveryCount}>;
var OrderQueue = new Array();
var doTotal = 0;
var doSucc = 0;
var doFail = 0;
var noPrint = 0;
function doRun(){
initOptQueue();
if (OrderQueue.length == 0) {
return ;
}
//禁用开始按钮
doTotal = 0;
doSucc = 0;
doFail = 0;
displayProcessInfo();
$('information').style.display ='';
$('btn-run').disabled = true;
$('btn-run').set('html', '<span><span>数据处理中,请稍候!</span></span>');
doAjaxProcess(1);
}
function initOptQueue() {
var OrderHash = '';
var OrderNum = 0;
var OrderKey = '';
if (OrderGroups == '') {
return;
}
var LeaveProcessOrderNum = total;
if (MaxProcessOrderNum > LeaveProcessOrderNum) {
MaxProcessOrderNum = LeaveProcessOrderNum;
}
var groupNum = OrderGroups.length;
for (var i=0;i<groupNum;i++) {
if (OrderHash == '')
OrderHash = OrderGroups[i];
else
OrderHash = OrderHash + ';' + OrderGroups[i];
OrderNum ++;
if (OrderNum >= MaxProcessOrderNum) {
OrderQueue.push(OrderHash);
OrderNum =0;
OrderHash = '';
LeaveProcessOrderNum = LeaveProcessOrderNum - MaxProcessOrderNum;
if (MaxProcessOrderNum > LeaveProcessOrderNum) {
MaxProcessOrderNum = LeaveProcessOrderNum;
}
}
}
if (OrderHash != '') {
OrderQueue.push(OrderHash);
}
}
/**
* 执行一次AJAX调用
*/
function doAjaxProcess(idx) {
if (idx > OrderQueue.length || doTotal >= getTotal()) {
$('processBar').setStyle('width', '100%');
$('btn-run').set('html', '<span><span>处理已完成本窗口将在5秒后自动关闭</span></span>');
setTimeout("$('btn-run').getParent('.dialog').retrieve('instance').close();finderGroup['<{$env.get.finder_id}>'].refresh();", 5000);
} else {
var params = OrderQueue[idx-1];
new Request({url:'index.php?app=brush&ctl=admin_delivery&act=ajaxDealDelivery',method:'post',data:'ajaxParams='+params,
onComplete:function(result){
if(!result) return;
ret = JSON.decode(result);
doTotal = doTotal + ret['total'];
doSucc = doSucc + ret['succ'];
doFail = doFail + ret['fail'];
noPrint = noPrint + ret['noPrint'];
displayProcessInfo();
$('processBar').setStyle('width', (doTotal*100/(getTotal())) + '%');
//error_msg
if(doFail > 0 && ret['error_msg']){
alert(ret['error_msg']);
}
doAjaxProcess(idx+1);
}
}).send();
}
}
/**
* 显示信息进度
*/
function displayProcessInfo() {
$('iTotal').set('html', getTotal());
$('iSucc').set('html', doSucc);
$('iFail').set('html', doFail);
$('noPrint').set('html', noPrint);
}
function getTotal() {
displayTotal= <{$deliveryCount}>;
return displayTotal;
}
doRun();
}());
</script>