Files
OMS/app/ome/view/admin/batch/cancel.html
2026-01-04 17:22:44 +08:00

176 lines
5.5 KiB
HTML
Raw 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 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>当前共<{$ordertotal}>个订单,可取消<font color='red'><{$ordercount}></font><br>
</h4>
<div class="gridlist" >
<table class="nosplit" width="100%" cellspacing="0" cellpadding="0" border="0" >
<tr>
<th>取消理由:</th>
<td>
<textarea id='memo' name="memo" cols="80" rows="5" width="100%" vtype="required"></textarea>
</td>
</tr>
</table>
</div>
<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> 个失败,请稍候……
</div>
<{if $ordercount>0}>
<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>
<{/if}>
</div>
<script>
var MaxProcessOrderNum = 20;
var OrderGroups = <{$orderGroup}>;
var total = <{$ordercount}>;
var OrderQueue = new Array();
var doTotal = 0;
var doFailInfo='';
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;
}
for (var i=0;i<OrderGroups.length;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);
}
}
$('btn-run').addEvent('click', function(){
var memo = $('memo').value;
if(memo == ''){
alert('备注必填!');
return ;
}
doRun();
});
/**
* 显示信息进度
*/
function displayProcessInfo() {
$('iTotal').set('html', getTotal());
$('iSucc').set('html', doSucc);
$('iFail').set('html', doFail);
}
function getTotal() {
displayTotal= <{$ordercount}>;
return displayTotal;
}
/**
* 执行一次AJAX调用
*/
function doAjaxProcess(idx) {
if (idx > OrderQueue.length || doTotal >= getTotal()) {
$('processBar').setStyle('width', '100%');
$('btn-run').set('html', '<span><span>处理已完成本窗口将在3秒后自动关闭</span></span>');
setTimeout("$('btn-run').getParent('.dialog').retrieve('instance').close();finderGroup['<{$finder_id}>'].refresh();",2000);
} else {
var params = OrderQueue[idx-1];
new Request({url:'index.php?app=ome&ctl=admin_batch_order&act=doBatchCancel',method:'post',data:'ajaxParams='+params+'&memo='+$('memo').value,
onComplete:function(result){
if(!result) return;
ret = JSON.decode(result);
doTotal = doTotal + ret['total'];
doSucc = doSucc + ret['succ'];
doFail = doFail + ret['fail'];
displayProcessInfo();
$('processBar').setStyle('width', (doTotal*100/(getTotal())) + '%');
doAjaxProcess(idx+1);
}
}).send();
}
}
</script>