Files
OMS/app/ome/view/admin/order/confirm.html
2025-12-28 23:13:25 +08:00

1740 lines
78 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 © ShopeX http://www.shopex.cn. All rights reserved.
See LICENSE file for license details.
-->
<{capture name='headbar'}>
<{css app="ome" src="ome.css"}>
<table cellspacing="0" cellpadding="0" style="border-width:0 0 1px;" class="table-action">
<tbody>
<tr valign="middle">
<td>
<{button label='上一条' class="btn btn-primary" id="btn_prev" }>
<{button label='下一条' class="btn btn-primary" id="btn_next" }>
</td>
</tr>
</tbody>
</table>
<{/capture}>
<style>
.finder-detail{
background:#eee;
padding:5px;
margin:5px 0;
border:1px solid #bbb;
}
.finder-detail td{
background:#fff;
}
.gridlist tr.waring, .gridlist td.waring {
background:none repeat scroll 0 0 #9999ff;
color:#333333;
}
.gridlist tr.masterorder, .gridlist tr.masterorder td, .gridlist td.masterorder {
color: #000000;
font-weight: 700;
font-size : 12px;
background:#f0f6fe
}
.gridlist tr.memberorder, .gridlist tr.memberorder td, .gridlist td.memberorder tr.addressorder, .gridlist tr.addressorder td, .gridlist td.addressorder {
background: none repeat scroll 0 0 #e2effe;
color: #000000;
font-weight: 400;
font-size : 12px;
}
.order-reminder {
border-radius: 4px;
padding: 12px 15px;
margin: 10px 0;
font-size: 14px;
line-height: 1.4;
display: none; /* 默认隐藏 */
}
.order-reminder .reminder-content {
margin: 0;
}
/* 默认提醒样式 */
.order-reminder.reminder-info {
background: #fff3cd;
border: 1px solid #ffeaa7;
color: #856404;
}
/* 成功状态样式 */
.order-reminder.reminder-success {
background: #d4edda;
border: 1px solid #c3e6cb;
color: #155724;
}
/* 错误状态样式 */
.order-reminder.reminder-error {
background: #f8d7da;
border: 1px solid #f5c6cb;
color: #721c24;
}
/* 警告状态样式 */
.order-reminder.reminder-warning {
background: #fff3cd;
border: 1px solid #ffeaa7;
color: #856404;
}
/* 门店下拉保持与其它表头同高,不撑高行 */
#storeBranchHeader select { height: 24px; line-height: 24px; font-size: 12px; }
#storeBranchHeader .tail-select { height: 24px; line-height: 24px; display: inline-block; vertical-align: middle; border: 1px solid #C8D6DC; border-radius: 2px; background: #fff; width: 100% !important; box-sizing: border-box; }
#storeBranchHeader .tail-select .select-label { height: 24px; line-height: 24px; padding: 0 22px 0 8px; font-size: 12px; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#storeBranchHeader .tail-select .select-handle { height: 24px; }
#storeBranchHeader .tail-select .select-label:focus { outline: none; }
/* 门店列选中时,让下拉背景透明,突出表头选中底色 */
#storeBranchHeader.selected .tail-select .select-label,
#storeBranchHeader.selected .tail-select .select-handle { background: transparent !important; }
#storeBranchHeader.selected .tail-select { background: transparent !important; }
/* 缩窄下拉宽度,留出更多底色可见区域 */
#storeBranchHeader .tail-select { width: 100% !important; }
</style>
<form class="tableform" style="background:#fff; border:0 none;" method="post" action="index.php?app=ome&ctl=admin_order&act=finish_combine" id="order_split">
<input type="hidden" name="order_id" id="order_id" value="<{$order_id}>"/>
<input type="hidden" name="logi_no" value="<{$order.logi_no}>">
<input type="hidden" name="waybill_number" id="waybill_number" value=""/>
<input type="hidden" name="do_action" id="do_action" value=""/>
<input type="text" style="display:none" />
<!-- 订单确认提醒区域 -->
<div class="order-reminder reminder-info" id="order-reminder">
<div class="reminder-content">
</div>
</div>
<div id="nosplitarea">
<div>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<span style="margin-right: 40px">当前订单</span>
<span style="font-weight:700;">来源店铺:</span><{$shopInfo.name}>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<{foreach from=$orderStatus item=os}>
<a style="width:18px;padding:2px;height:16px;background-color:transparent;color:#ffffff;" rel="<{$os.msg}>" onmouseover="bindFinderColTip(event);" title="<{$os.msg}>" class="">
&nbsp;<{$os.flag}>&nbsp;
</a>
<{/foreach}>
</td>
</tr>
</table>
</div>
<div>
<{include file="admin/order/confirm/combine_confirm.html"}>
</div>
<{if $use_o2o}>
<div id="o2o_delivery" style="display:none;">
<{include file="admin/order/confirm/o2o_confirm.html"}>
</div>
<{/if}>
<h3 style="border-bottom:none;">购物清单信息<{if $repeat_product}><span style="color:#ff0000;">(订单中包含重复的商品[货号:<{$repeat_product}> ] 系统将不支持拆单,请编辑去除重复商品后再进行拆单!<input type="hidden" name="is_repeat_product" value="true"/></span><{elseif $order_is_cod=='true' || $use_o2o}><input type="hidden" name="is_repeat_product" value="true"/><{/if}></h3>
<div class="finder-detail" id="buy_order_item_list">
<{include file="admin/order/confirm/product_confirm.html"}>
</div>
<{if $check_items}>
<h3 style="border-bottom:none;">重点检查明细</h3>
<div class="finder-detail" id="buy_order_item_list">
<{include file="admin/order/confirm/check_items.html"}>
</div>
<{/if}>
<!-- 订单售后情况 BEGIN-->
<{if $reship_list || $refund_apply}>
<div class="finder-detail" id="refund_confirm_box" style="border:2px solid #FC0; background:#ffffcc;">
<{include file="admin/order/confirm/refund_apply_record.html"}>
</div>
<{/if}>
<!-- 订单售后情况 END-->
<div id="issplit" class="issplit" style="display:none;">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="fontcolorRed fontbold font14px" >已拆分-</td>
<td width="230" style="text-align: center; font-weight: normal;" >
快递公司选择:
<div class="corp_list"></div>
</td>
</tr>
</table>
<table cellspacing="0" class="gridlist" cellpadding="2" border="0" >
<thead>
<tr>
<th>销售物料编码</th>
<th>销售物料名称</th>
<th>数量</th>
<th>仓库</th>
<th style="width:100px;">操作</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<div id="issplitarea"></div>
<span id="has_gifts" style="display:none;">
<h3><font color="red">注意事项</font></h3>
<div class="finder-detail" style="margin-top:10px;">
<input type="checkbox" name="has_pro_gifts" id="has_pro_gifts" value=1 onclick="setButtonStatus();">&nbsp;<span style="color:red;font-size:14px;font-weight:bold;">选中订单有优惠赠品,请确认已经处理</span>
</div>
</span>
<div style="margin-top:10px;">
<{include file="admin/order/confirm/express.html"}>
</div>
<div style="margin-top:10px;">
<{include file="admin/order/confirm/receiver_info.html"}>
</div>
</form>
<{capture name='footbar'}>
<table cellspacing="0" cellpadding="0" class="table-action">
<tbody>
<tr valign="middle">
<td>
<{if isset($reship_list) || isset($refund_apply)}>
<input name="go_continue" type="checkbox" id="go_continue" value="1" /> <b>订单部分退款,已查阅并继续操作!</b> <span id="continue_but_1"><input type="submit" name="button" id="but_continue" disabled="disabled" value="确认并生成发货单" /></span><span id="continue_but_2" style="display:none;"><{button label="确认并生成发货单" type="button" class="btn-primary" id="btn_con" onclick="doDetailAction(3,0);"}></span>
<{else}>
<{button label="确认并生成发货单" type="button" class="btn-primary" id="btn_con" onclick="doDetailAction(3,0);"}>
<{/if}>
</td>
</tr>
</tbody>
</table>
<{/capture}>
<script>
var memberOrders = 0;
var curr_id = '<{$order_id}>';
var filter = [];
var prev_id = '';
var next_id = '';
var finderList = opener.window.document.getElementById('finder-list-<{$finder_id}>');
if(!finderList){
alert('待处理订单列表已被关闭!');
setTimeout('window.close()',120);
}
var dataNode = finderList.getElements('tr').get('item-id');
var data = dataNode.filter(function(d){return filter.indexOf(d) == -1;});
var index = data.indexOf(curr_id);
if(index >= 0){
if(index > 0) prev_id = data[index - 1];
if(index + 1 <= data.length) next_id = data[index + 1];
}
$('btn_prev').addEvent('click',function(e){
if(prev_id) {
window.location='index.php?app=ome&ctl=admin_order&act=do_confirm&p[0]='+prev_id+'&filter=<{$filter}>&find_id=<{$finder_id}>';
} else {
alert('没有上一条了');
}
});
$('btn_next').addEvent('click',function(e){
if(next_id) {
window.location='index.php?app=ome&ctl=admin_order&act=do_confirm&p[0]='+next_id+'&filter=<{$filter}>&find_id=<{$finder_id}>';
} else {
alert('没有下一条或已经到了页尾');
}
});
if ($defined($E('.order-sensitive-btn')))
$E('.order-sensitive-btn').addEvent('click',function(e){
Ex_Loader('security',function(){
new Security({url:'index.php?app=ome&ctl=admin_order&act=showSensitiveData&p[0]=<{$order.order_id}>',clickElement:$(e.target)}).desHtml($E('#delivery_info'));
});
});
if ($defined($E('.member-sensitive-btn')))
$E('.member-sensitive-btn').addEvent('click',function(e){
Ex_Loader('security',function(){
new Security({url:'index.php?app=ome&ctl=admin_member&act=showSensitiveData&p[0]=<{$order.order_id}>',clickElement:$(e.target)}).desHtml($ES('#buyer_area'));
});
});
//敏感数据处理 拼多多
if ($defined($E('.order-sensitive-btn-detail')))
$ES('.order-sensitive-btn-detail').addEvent('click',function(e){
var type = this.get('data-type');
console.log('type',type)
var tr = this.getParent('tr');
Ex_Loader('security',function(){
new Security({url:'index.php?app=ome&ctl=admin_order&act=showSensitiveData&p[0]=<{$order.order_id}>&p[1]='+type,clickElement:$(e.target)}).desHtml(tr);
});
});
//敏感数据处理 拼多多
if ($defined($E('.member-sensitive-btn-detail')))
$ES('.member-sensitive-btn-detail').addEvent('click',function(e){
var type = this.get('data-type');
var tr = this.getParent('tr');
Ex_Loader('security',function(){
new Security({url:'index.php?app=ome&ctl=admin_member&act=showSensitiveData&p[0]=<{$order.order_id}>&p[1]='+type,clickElement:$(e.target)}).desHtml(tr);
});
});
</script>
<script>
function getCorps(branch_id, area,weight,select_corp_id) {
var waybill_number = $('waybill_number').get('value');
if(waybill_number){
$('waybill_number').set('value','');//只要重新选物流,提前把电子面单号清除
}
//获取已选中订单(推送到快递鸟)
var hq_orders = getCombineOrders();
var hq_orderIds = new Array();
for (i=0; i < hq_orders.length; i++) {
hq_orderIds[i] = hq_orders[i].value;
}
var jsonorderIds = JSON.encode(hq_orderIds);
var defDly = '<{$defaultExpress.yes}>';
var shop_type = '<{$order.shop_type}>';
var shop_id = '<{$order.shop_id}>';
var cod = '<{$order.shipping.is_cod}>';
if(!branch_id) {
$('logi_id').set('html','<option>----</option>');
return;
}
var default_corp_id = '';
var default_shopcorp_id = '';
var default_corp_type = '';
new Request({
url:'index.php?app=ome&ctl=admin_order&act=getCorps',
method:'post',
data:'branch_id='+branch_id + '&area=' + area+'&weight='+weight+'&shop_type='+shop_type+'&shop_id='+shop_id+'&order_id=<{$order_id}>'+'&order_info='+jsonorderIds+'&order_bn=<{$order.order_bn}>', async:false,
onComplete: function(json) {
if(!json)
return;
var corp_info = JSON.decode(json);
//淘宝的智选物流有物流单号
if(corp_info.waybill_number){
var waybill_number = corp_info.waybill_number;
$('waybill_number').set('value',waybill_number);
json = corp_info.corpList;
}else{
json = corp_info;
}
var s = '';
var flag_dly = true;
json.each( function(j,i) {
if(j.flag_select=='1'){
default_corp_id = j.corp_id;
}
//判断是否货到付款
if (shop_type=='360buy' && cod=='true' && j.type=='JDCOD')
{
default_shopcorp_id = j.corp_id;
}
s += '<option id="' + j.type + '" value="'+j.corp_id+'">'+j.name+'</option>';
//选择的物流公司类型
if(select_corp_id && j.corp_id == select_corp_id)
{
default_corp_type = j.type;
}
});
$('logi_id').set('html',s);
if (default_shopcorp_id)
{
default_corp_id = default_shopcorp_id;
}
if(default_corp_id){
$('logi_id').getElement('option[value='+default_corp_id+']').selected=true;
}
else
{
json.each( function(j,i) {
if(j.type != "o2o_pickup" && j.type != "o2o_ship")
{
$('logi_id').getElement('option[value='+j.corp_id+']').selected=true;
}
});
}
if(defDly){
selectedExpress();
}
if(select_corp_id){
$('logi_id').getElement('option[value='+select_corp_id+']').selected=true;
//加载交付门店信息
if((default_corp_type == "o2o_pickup" || default_corp_type == "o2o_ship") && $("default_o2o_dly").value != "true")
{
default_load_o2o('<{$o2o_order.store_bn}>');
}
}
}
}).send();
}
function selectedExpress() {
var opts = $('logi_id').options;
var len = opts.length;
var defDly = '<{$defaultExpress.yes}>';
var noArr = new Array();
// 这里应该从PHP变量获取数据暂时使用空数组
// noArr = [];
for(var i=0; i<len; i++){
if(defDly == ''){
if(isDefault(noArr)){
if(inArray(opts[i].id, noArr) == false){
opts[i].selected = true;
return;
}
}
return;
}
if(opts[i].id == defDly){
opts[i].selected = true;
}
}
}
function isDefault(noArr){
return inArray(defValue = $('logi_id').options[0].id, noArr);
}
function inArray(value, arr){
for(var i=0; i<arr.length; i++){
if(value == arr[i]){
return true;
}
}
return false;
}
// 门店仓选择弹层函数
function showStoreBranchSelector() {
// 从全局变量获取门店仓数据
var storeBranches = window.storeBranchesData || [];
if (!storeBranches || storeBranches.length === 0) {
alert('没有可用的门店仓');
return;
}
// 获取当前选中的门店ID
var currentSelectedStoreId = '';
var header = $('storeBranchHeader');
if(header && header.hasClass('selected')){
currentSelectedStoreId = header.get('data-storeid');
}
// 构建弹层内容
var content = '<div class="division" style="max-height: 70vh; overflow-y: auto;">';
// 添加搜索功能
content += '<div style="margin-bottom: 15px; padding: 10px; background: #f8f9fa; border-radius: 4px; border: 1px solid #e9ecef;">';
content += '<div style="display: flex; align-items: center; gap: 10px;">';
content += '<label style="font-weight: bold; color: #495057; font-size: 12px; white-space: nowrap;">门店搜索:</label>';
content += '<input type="text" id="store_search_input" placeholder="输入门店名称进行搜索..." style="flex: 1; padding: 6px 10px; border: 1px solid #ced4da; border-radius: 3px; font-size: 12px; outline: none;" onkeyup="filterStores(this.value)">';
content += '<button onclick="clearStoreSearch()" style="padding: 6px 12px; background: #6c757d; color: white; border: none; border-radius: 3px; font-size: 12px; cursor: pointer;">清空</button>';
content += '</div>';
content += '<div id="search_result_info" style="margin-top: 8px; font-size: 11px; color: #6c757d;"></div>';
content += '</div>';
// 构建库存表格 - 使用更紧凑的样式
content += '<table class="gridlist" width="100%" cellspacing="0" cellpadding="1" border="0" style="font-size: 11px;">';
content += '<thead><tr style="background: #f5f5f5;">';
content += '<th style="padding: 2px 1px; width: 12%; height: 20px; line-height: 16px;">物料编码</th>';
content += '<th style="padding: 2px 1px; width: 15%; height: 20px; line-height: 16px;">物料名称</th>';
content += '<th style="padding: 2px 1px; width: 12%; height: 20px; line-height: 16px;">销售物料编码</th>';
content += '<th style="padding: 2px 1px; width: 15%; height: 20px; line-height: 16px;">销售物料名称</th>';
content += '<th style="padding: 2px 1px; width: 8%; height: 20px; line-height: 16px;">规格</th>';
content += '<th style="padding: 2px 1px; width: 8%; height: 20px; line-height: 16px;">价格</th>';
content += '<th style="padding: 2px 1px; width: 8%; height: 20px; line-height: 16px;">购买数量</th>';
content += '<th style="padding: 2px 1px; width: 8%; height: 20px; line-height: 16px;">门店库存</th>';
content += '<th style="padding: 2px 1px; width: 14%; height: 20px; line-height: 16px;">门店仓名称</th>';
content += '</tr></thead><tbody>';
// 遍历门店仓和商品生成表格行
for (var i = 0; i < storeBranches.length; i++) {
var store = storeBranches[i];
var firstRow = true;
var rowspan = 0;
// 先计算这个门店仓有多少个商品
for (var bn in orderItems) {
if (orderItems[bn]['delete'] == 'false') {
rowspan++;
}
}
// 如果不是第一个门店仓,添加分隔线
if (i > 0) {
content += '<tr><td colspan="9" style="padding: 0; height: 2px; background: #dee2e6; border: none;"></td></tr>';
}
for (var bn in orderItems) {
if (orderItems[bn]['delete'] == 'false') {
var item = orderItems[bn];
var storeInventory = item['branch_store'] && item['branch_store'][store.branch_id] ? item['branch_store'][store.branch_id] : 0;
var inventoryText = storeInventory;
if (typeof storeInventory === 'object' && storeInventory.store !== null) {
inventoryText = storeInventory.store;
}
var statusClass = '';
if (inventoryText >= item.quantity) {
statusClass = 'color: #28a745; font-weight: bold;';
} else if (inventoryText > 0) {
statusClass = 'color: #ffc107; font-weight: bold;';
} else {
statusClass = 'color: #dc3545; font-weight: bold;';
}
content += '<tr style="border-bottom: 1px solid #eee;">';
content += '<td style="padding: 2px; font-family: monospace; height: 20px; line-height: 16px;">' + (item.bn || '-') + '</td>';
content += '<td style="padding: 2px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; height: 20px; line-height: 16px;" title="' + (item.name || '-') + '">' + (item.name || '-') + '</td>';
content += '<td style="padding: 2px; font-family: monospace; height: 20px; line-height: 16px;">' + (item.goods_bn || '-') + '</td>';
content += '<td style="padding: 2px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; height: 20px; line-height: 16px;" title="' + (item.goods_name || '-') + '">' + (item.goods_name || '-') + '</td>';
content += '<td style="padding: 2px; height: 20px; line-height: 16px;">' + (item.addon || '-') + '</td>';
content += '<td style="padding: 2px; text-align: right; height: 20px; line-height: 16px;">' + (item.price ? item.price.toFixed(2) : '-') + '</td>';
content += '<td style="padding: 2px; text-align: center; height: 20px; line-height: 16px;">' + (item.quantity || 0) + '</td>';
content += '<td style="padding: 2px; text-align: center; height: 20px; line-height: 16px; ' + statusClass + '">' + inventoryText + '</td>';
// 只在第一行显示门店仓名称并设置rowspan
if (firstRow) {
// 判断是否为当前选中的门店,如果是则设置背景色
var storeNameCellStyle = 'padding: 2px; text-align: center; vertical-align: middle; height: 20px; line-height: 16px;';
if(String(store.branch_id) === String(currentSelectedStoreId)){
storeNameCellStyle += ' background: #dee2e6;';
}
content += '<td style="' + storeNameCellStyle + '" rowspan="' + rowspan + '"><a href="javascript:void(0);" onclick="selectStoreBranch(' + store.branch_id + ', \'' + store.name + '\')" style="color: #3367AC; text-decoration: none; cursor: pointer; font-weight: bold;" onmouseover="this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'" title="点击选择此门店仓">' + store.name + '</a></td>';
firstRow = false;
}
content += '</tr>';
}
}
}
content += '</tbody></table>';
content += '</div>';
// 计算弹层尺寸 - 自适应屏幕大小,允许用户手动调整
var screenHeight = window.innerHeight || document.documentElement.clientHeight;
var screenWidth = window.innerWidth || document.documentElement.clientWidth;
// 设置初始尺寸,但允许用户手动调整
var dialogWidth = Math.min(1400, screenWidth * 0.95);
var dialogHeight = Math.min(700, screenHeight * 0.85);
// 创建弹层 - 允许调整大小
new Dialog(new Element("div.tableform", {html: content}), {
width: dialogWidth,
height: dialogHeight,
title: '门店仓选择与库存查看',
resizable: true, // 允许调整大小
onClose: function() {
// 弹层关闭时的处理
}
});
}
// 门店搜索筛选函数
function filterStores(searchText) {
var searchText = searchText.toLowerCase().trim();
var table = document.querySelector('.dialog table tbody');
if (!table) return;
var rows = table.getElementsByTagName('tr');
var visibleStoreCount = 0;
var totalStoreCount = 0;
// 重新构建表格内容,只显示匹配的门店
var newContent = '';
var storeBranches = window.storeBranchesData || [];
for (var i = 0; i < storeBranches.length; i++) {
var store = storeBranches[i];
var shouldShow = searchText === '' || store.name.toLowerCase().indexOf(searchText) !== -1;
if (shouldShow) {
visibleStoreCount++;
totalStoreCount++;
// 如果不是第一个门店仓,添加分隔线
if (newContent !== '') {
newContent += '<tr><td colspan="9" style="padding: 0; height: 2px; background: #dee2e6; border: none;"></td></tr>';
}
var firstRow = true;
var rowspan = 0;
// 先计算这个门店仓有多少个商品
for (var bn in orderItems) {
if (orderItems[bn]['delete'] == 'false') {
rowspan++;
}
}
for (var bn in orderItems) {
if (orderItems[bn]['delete'] == 'false') {
var item = orderItems[bn];
var storeInventory = item['branch_store'] && item['branch_store'][store.branch_id] ? item['branch_store'][store.branch_id] : 0;
var inventoryText = storeInventory;
if (typeof storeInventory === 'object' && storeInventory.store !== null) {
inventoryText = storeInventory.store;
}
var statusClass = '';
if (inventoryText >= item.quantity) {
statusClass = 'color: #28a745; font-weight: bold;';
} else if (inventoryText > 0) {
statusClass = 'color: #ffc107; font-weight: bold;';
} else {
statusClass = 'color: #dc3545; font-weight: bold;';
}
newContent += '<tr style="border-bottom: 1px solid #eee;">';
newContent += '<td style="padding: 2px; font-family: monospace; height: 20px; line-height: 16px;">' + (item.bn || '-') + '</td>';
newContent += '<td style="padding: 2px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; height: 20px; line-height: 16px;" title="' + (item.name || '-') + '">' + (item.name || '-') + '</td>';
newContent += '<td style="padding: 2px; font-family: monospace; height: 20px; line-height: 16px;">' + (item.goods_bn || '-') + '</td>';
newContent += '<td style="padding: 2px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; height: 20px; line-height: 16px;" title="' + (item.goods_name || '-') + '">' + (item.goods_name || '-') + '</td>';
newContent += '<td style="padding: 2px; height: 20px; line-height: 16px;">' + (item.addon || '-') + '</td>';
newContent += '<td style="padding: 2px; text-align: right; height: 20px; line-height: 16px;">' + (item.price ? item.price.toFixed(2) : '-') + '</td>';
newContent += '<td style="padding: 2px; text-align: center; height: 20px; line-height: 16px;">' + (item.quantity || 0) + '</td>';
newContent += '<td style="padding: 2px; text-align: center; height: 20px; line-height: 16px; ' + statusClass + '">' + inventoryText + '</td>';
// 只在第一行显示门店仓名称并设置rowspan
if (firstRow) {
newContent += '<td style="padding: 2px; text-align: center; vertical-align: middle; height: 20px; line-height: 16px;" rowspan="' + rowspan + '"><a href="javascript:void(0);" onclick="selectStoreBranch(' + store.branch_id + ', \'' + store.name + '\')" style="color: #3367AC; text-decoration: none; cursor: pointer; font-weight: bold;" onmouseover="this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'" title="点击选择此门店仓">' + store.name + '</a></td>';
firstRow = false;
}
newContent += '</tr>';
}
}
} else {
totalStoreCount++;
}
}
// 更新表格内容
table.innerHTML = newContent;
// 更新搜索结果显示
var resultInfo = document.getElementById('search_result_info');
if (resultInfo) {
if (searchText === '') {
resultInfo.innerHTML = '显示所有门店 (' + totalStoreCount + ' 个)';
} else {
resultInfo.innerHTML = '找到 ' + visibleStoreCount + ' 个匹配门店 (共 ' + totalStoreCount + ' 个)';
}
}
}
// 清空搜索函数
function clearStoreSearch() {
var searchInput = document.getElementById('store_search_input');
if (searchInput) {
searchInput.value = '';
filterStores('');
searchInput.focus();
}
}
// 选择门店仓
function selectStoreBranch(branch_id, store_name) {
// 更新选中的门店仓
$('selected_store_name').set('text', store_name);
// 更新门店列的 data-storeid 与高亮
var header = $('storeBranchHeader');
if(header){
var ths = header.getParent('tr').getElements('th');
ths.removeClass('selected');
header.addClass('selected');
header.set('data-storeid', branch_id);
// 门店仓选择器不需要额外设置背景,使用系统默认的选中效果
// 当门店列被选中时,系统会自动应用 th.selected 的样式
// 但需要设置文字颜色为白色,与"我的仓库"选中效果一致
var selector = $('store_branch_selector');
if(selector){
selector.style.color = '#fff';
}
}
// 更新门店库存列
__updateStoreColumnFor(branch_id);
// 获取物流公司
var area = $E('[name="consignee[area]"]',$('delivery_info')).value;
getCorps(branch_id, area, '<{$weight}>', '');
// 关闭弹层
var dialogs = document.getElementsByClassName('dialog');
if (dialogs.length > 0) {
var lastDialog = dialogs[dialogs.length - 1];
if (lastDialog.retrieve && lastDialog.retrieve('instance')) {
lastDialog.retrieve('instance').close();
}
}
}
(function() {
var splited = <{$is_splited}>?<{$is_splited}>:'';
var branch_id = 0;
var arrive_conf = <{$arrive_conf}>;
var logi_id = $('logi_id'),
issplitarea = $('issplitarea'),
select_branch = $$('.select_branch'),
order_split = $('order_split'),
order_id = $E('[name=order_id]',$('order_split')).value;
$$('.show_consign').addEvent('click', function() {
this.getParent('.division').getElement('.consign_area').setStyle('display','block');
this.set('html','');
});
$$('.fold_consign').addEvent('click', function() {
this.getParent('.consign_area').setStyle('display','none');
this.getParent('.division').getElement('.show_consign').set('html','更多>>');
});
// getCorps('<{$selected_branch_id}>', '<{$order.consignee.area}>','<{$weight}>','<{$o2o_order.select_corp_id}>');
select_branch.each( function(item,i) {
var p = item.getParent('th');
var index = item.getParent('tr').getElements('th').indexOf(item.getParent('th'));
item.addEvents({
'click': function(e) {
this.getParent('tr').getElements('th.selected').removeClass('selected');
p.addClass('selected');
$E('.row-tips') && $E('.row-tips').destroy();
// 门店仓选择器使用系统默认的选中效果,不需要手动重置样式
// 但需要重置文字颜色为与"我的仓库"相同的颜色,表示可点击状态
var storeSelector = $('store_branch_selector');
if(storeSelector){
storeSelector.style.color = '#3367AC';
}
// 切换到大仓时,重置门店仓选择器为默认状态
try{
var storeSelector = $('store_branch_selector');
if(storeSelector){
// 重置门店仓选择器显示的名称
$('selected_store_name').set('text', '可选择O2O门店');
// 重置门店仓选择器的样式(蓝色文字)
storeSelector.style.color = '#3367AC';
}
// 重置门店列的选中状态
var header = $('storeBranchHeader');
if(header){
header.removeClass('selected');
header.set('data-storeid', '');
}
// 重置门店库存列为0
__resetStoreColumnToZero();
}catch(e){}
var branch_id = $('dataNode').getParent().getElement('th.selected') ? $('dataNode').getParent().getElement('th.selected').get('data-storeid') : '';
// 切换到大仓后,重置门店库存列为 0
__resetStoreColumnToZero();
var area = $E('[name="consignee[area]"]',$('delivery_info')).value;
getCorps(branch_id,area,'<{$weight}>','');
},
'mouseenter': function(e) {
if(p.hasClass('selected'))
return;
var tips = new Element('div.row-tips', {
html:'<div class="tips">选择它来发货</div>'
}).inject(document.body).fade(1);
tips.setStyles({
'width':p.getSize().x+1,
'top':p.getPosition().y-24,
'left':p.getPosition().x
});
p.getPrevious().setStyle('border-right-color','#84a2ad');
p.setStyle('border-color','#84a2ad');
},
'mouseleave': function() {
$E('.row-tips') && $E('.row-tips').destroy();
p.getPrevious().setStyle('border-right-color','#C8D6DC');
p.setStyle('border-color', '#C8D6DC');
}
});
});
if ($('logi_id'))
{
$('logi_id').addEvent('change',function(e){
var waybill_number = $('waybill_number').get('value');
$('waybill_number').set('value','');//只要切换物流,就一定要把电子面单号清除,否则可能造成生成发货时,有面单号
});
}
if ($('other_delivery')) {
$('other_delivery').addEvent('click', function(e) {
new Request.HTML({
url:'index.php?app=ome&ctl=admin_order&act=do_confirm_delivery_info_edit&p[0]='+order_id,
method:'get',
update:$('delivery_info'),
onComplete: function() {
this.set('html','');
}.bind(this)
}).send();
});
}
order_split.removeEvents('submit').addEvent('submit', function(e) {
var act = $('do_action').value;
e.stop();
new Request.JSON({
url:this.action,
onRequest: function () {
if ($('btn_consign')) {
$('btn_consign').set('disabled', 'true');
$('btn_consign').getElements('span')[1].set('text','拆分中');
} else if ($('btn_con')) {
$('btn_con').set('disabled', 'true');
$('btn_con').getElements('span')[1].set('text','正在处理请求中');
}
},
onSuccess: function(jsontext) {
var json = jsontext;
if (typeof(json.error) == 'undefined') {
if (json.success=='成功:订单暂停成功' || json.success=='成功:订单恢复成功' || json.success=='成功:订单确认成功' || json.success=='成功:订单拆分成功') {
window.location = window.location.href;
try {
opener.finderGroup['<{$finder_id}>'].refresh.delay(100,opener.finderGroup['<{$finder_id}>']);
} catch(e) {
}
} else {
if(json.success=='成功:订单处理成功') {
var curr_id = '<{$order_id}>';
var orders = getCombineOrders();
var filter = new Array();
for (i=0; i<orders.length; i++) {
if (orders[i].value != curr_id) {
filter.push(orders[i].value);
}
}
var next_id = '';
var finderList = opener.window.document.getElementById('finder-list-<{$finder_id}>');
if(!finderList){
alert('没有下一条或已经到了页尾!');
setTimeout('window.close()',120);
}
var dataNode = finderList.getElements('tr').get('item-id');
var data = dataNode.filter(function(d){return $defined(d) && filter.indexOf(d) == -1;});
var index = data.indexOf(curr_id);
if(index >= 0){
if(index + 1 <= data.length-1) {
next_id = data[index + 1];
} else {
if (index >0 ) {
next_id = data[index - 1];
}
}
}
try {
opener.finderGroup['<{$finder_id}>'].refresh.delay(100,opener.finderGroup['<{$finder_id}>']);
} catch(e) {
}
if(next_id) {
window.location='index.php?app=ome&ctl=admin_order&act=do_confirm&p[0]='+next_id+'&filter=<{$filter}>&find_id=<{$finder_id}>';
} else {
alert('没有下一条或已经到了页尾');
setTimeout('window.close()',120);
}
} else {
try {
opener.finderGroup['<{$finder_id}>'].refresh.delay(100,opener.finderGroup['<{$finder_id}>']);
} catch(e) {
}
setTimeout('window.close()',120);
}
}
} else {
MessageBox.error(json.error);
$('btn_con').set('disabled', '');
$('btn_con').getElements('span')[1].set('text','确认并生成发货单');
try {
opener.finderGroup['<{$finder_id}>'].refresh.delay(100,opener.finderGroup['<{$finder_id}>']);
} catch(e) {
}
}
}
})[this.method](this);
});
})();
</script>
<script>
var assign_express_name = "<{$assign_express_name}>";
var assign_express_code = "<{$assign_express_code}>";
var gOrders = <{$jsOrders}>;
var orderItems = new Array();
// 初始化门店仓数据
window.storeBranchesData = <{$jsStoreBranches}>;
for (id in gOrders) {
if (gOrders[id]['pause'] == 'true' || gOrders[id]['derviveryId']>0) {
new Element('div.error', {
html:'部分订单已生成发货单,进入配货流程或已被置为暂停状态,请仔细检查后操作。',
style:'margin-top:10px;font-size:14px;font-weight:bold; line-height:28px; text-align:center;'
}).inject($E('.content-main'),'top');
break;
}
}
function getCombineOrders() {
var orderRow = $$('#orderNode input, #present .seemingly-orders input, #orderCombineTbody input').filter( function(item, i) {
return item.checked;
});
return orderRow;
}
/**
* 获取选中订单的CPUP服务信息
* @param {Array} orders 选中的订单元素数组
* @returns {Array} CPUP服务信息数组
*/
function getCpupServices(orders) {
var cpupServices = [];
orders.each(function(orderInput) {
var orderId = orderInput.value;
var orderRow = orderInput.getParent('tr[data-order-id="' + orderId + '"]');
var cpupContainer = orderRow ? orderRow.getElement('.cpup-service') : null;
if (cpupContainer) {
var services = cpupContainer.getElements('span').map(function(span) {
return span.get('text').split(',');
}).flatten().filter(function(text) {
return text.trim();
});
if (services.length > 0) {
cpupServices.push({
orderId: orderId,
services: services
});
}
}
});
return cpupServices;
}
function checkItemHtmlData() {
var html = '';
for (var product in orderCheckItems) {
if (orderCheckItems[product]['delete'] == 'false') {
html = html + '<tr data-g_pid="'+orderCheckItems[product]['product_id']+'" data-g_shop_pid="'+orderItems[product]['shop_product_id']+'" data-item_id="'+orderItems[product]['item_id']+'">';
html = html + '<td class="number">' + orderCheckItems[product]['bn'] + '</td>';
html = html + '<td class="number">' + orderCheckItems[product]['order_sn'] + '</td>';
html = html + '<td class="number">' + orderCheckItems[product]['delivery_warehouse'] + '</td>';
html = html + '<td class="number">' + orderCheckItems[product]['channel'] + '</td>';
html = html + '<td class="number">' + orderCheckItems[product]['problem_desc'] + '</td>';
html = html + '<td class="number">' + orderCheckItems[product]['order_label'] + '</td>';
html = html + '<td class="number">' + orderCheckItems[product]['image_list'] + '</td>';
html = html + '<td class="number">' + orderCheckItems[product]['video_list'] + '</td>';
html = html + '<td class="number">' + orderCheckItems[product]['first_classification'] + '</td>';
html = html + '<td class="number">' + orderCheckItems[product]['second_classification'] + '</td>';
html = html + '<td class="number">' + orderCheckItems[product]['third_classification'] + '</td>';
html = html + '</tr>';
}
}
return html;
}
function itemHtmlData(){
var html = '';
//全渠道订单
var branch_style = '';
var is_select_o2o = $("is_select_o2o") ? $("is_select_o2o").value : "";
var o2o_store_id = $("o2o_store_id") ? $("o2o_store_id").value : "";
if(is_select_o2o == "true" && o2o_store_id)
{
var o2o_branch_id = $("o2o_branch_id").value;
o2o_branch_id = o2o_branch_id ? o2o_branch_id : "<{$o2o_order.branch_id}>";
//门店仓库是否管控供货关系
branch_is_ctrl_supply_relation = $('branch_is_ctrl_supply_relation').value;
//门店仓库是否管控库存
branch_is_ctrl_store = $("branch_is_ctrl_store").value;
//初始化无效的基础物料编号为空
$("invalid_material_bn").value = "";
//隐藏电商仓库
branch_style = 'style="display: none;"';
}
for (var product in orderItems) {
if (orderItems[product]['delete'] == 'false') {
html = html + '<tr data-g_pid="'+orderItems[product]['product_id']+'" data-g_shop_pid="'+orderItems[product]['shop_product_id']+'" data-item_id="'+orderItems[product]['item_id']+'"><td>基础物料</td>';
html = html + '<td class="number">' + orderItems[product]['bn'] + '</td>';
html = html + '<td class="goodsname">' + orderItems[product]['name'] + '</td>';
//销售物料编码和销售物料名称
html = html + '<td class="goods_bn">' + orderItems[product]['goods_bn'] + '</td>';
html = html + '<td class="goods_name">' + orderItems[product]['goods_name'] + '</td>';
html = html + '<td class="addon">' + orderItems[product]['addon'] + '</td>';
html = html + '<td class="price">' + orderItems[product]['price'].toFixed(2) + '</td>';
<{if $cnService}>
html = html + '<td style="color: red">' + orderItems[product]['cnService'] + '</td>';
<{/if}>
html = html + '<td class="buycounts">' + orderItems[product]['quantity'] + '</td>';
<{foreach from=$branch_list item=branch}>
var branch_store = orderItems[product]['branch_store'][<{$branch.branch_id}>]?orderItems[product]['branch_store'][<{$branch.branch_id}>]:0;
html = html + '<td class="branch ColColorGreen" '+ branch_style +'>' + branch_store + '</td>';
<{/foreach}>
<{if $has_store_branch == 'true'}>
// 门店仓库存列(使用当前选中的门店 branch_id
var selectedStoreBid = $('storeBranchHeader') ? $('storeBranchHeader').get('data-storeid') : '<{$default_store_branch_id}>';
var store_branch_store = 0;
if(orderItems[product]['branch_store'][selectedStoreBid]){
if(typeOf(orderItems[product]['branch_store'][selectedStoreBid]) == 'object' && orderItems[product]['branch_store'][selectedStoreBid]['store']!=null){
store_branch_store = orderItems[product]['branch_store'][selectedStoreBid]['store'];
}else{
store_branch_store = orderItems[product]['branch_store'][selectedStoreBid];
}
}
html = html + '<td class="branch ColColorGreen" is_o2o_branch="true">' + (store_branch_store||0) + '</td>';
<{/if}>
//全渠道订单处理
if(is_select_o2o == "true" && o2o_store_id)
{
//门店仓不管控供货关系
if(branch_is_ctrl_supply_relation == 'false'){
html = html + '<td class="branch ColColorGreen" is_o2o_branch="true"> - </td>';
}else{
var is_relation = false;
var is_ctrl_store = false;
var branch_store = 0;
if(orderItems[product]['branch_store'][o2o_branch_id])
{
is_relation = orderItems[product]['branch_store'][o2o_branch_id]['is_relation'];//供货关系
is_ctrl_store = orderItems[product]['branch_store'][o2o_branch_id]['is_ctrl_store'];//基础物料是否管控库存
}
if(!is_relation){
html = html + '<td class="branch ColColorGreen" is_o2o_branch="true"><span style="color:red;">x</span></td>';
//[打标]无供货关系的基础物料编号
$("invalid_material_bn").value = orderItems[product]['bn'];
}else{
//门店仓管控供货关系
if(branch_is_ctrl_store == 'true')
{
if(is_ctrl_store)
{
branch_store = orderItems[product]['branch_store'][o2o_branch_id]['store'] ? orderItems[product]['branch_store'][o2o_branch_id]['store'] : 0;
html = html + '<td class="branch ColColorGreen" is_o2o_branch="true"> '+ branch_store +' </td>';
}else{
html = html + '<td class="branch ColColorGreen" is_o2o_branch="true"> - </td>';
}
}else{
html = html + '<td class="branch ColColorGreen" is_o2o_branch="true"> - </td>';
}
}
}
}
html = html + '</tr>';
}
}
return html;
}
// 根据门店 branch_id 渲染门店库存列(首屏或切换时调用)
function __updateStoreColumnFor(branch_id){
try{
if(!branch_id){ return; }
var rows = $('dataNode').getElements('tr');
rows.each(function(row){
var bnCell = row.getElements('td.number')[0];
if(!bnCell) return;
var bn = (bnCell.get('text')||'').trim();
var storeVal = 0;
if(orderItems[bn] && orderItems[bn]['branch_store'] && orderItems[bn]['branch_store'][branch_id]){
var v = orderItems[bn]['branch_store'][branch_id];
if(typeOf(v)=='object' && v['store']!=null){ storeVal = v['store']; } else { storeVal = v; }
}
var storeTd = row.getElement('td[is_o2o_branch]');
if(storeTd){ storeTd.set('text', storeVal || 0); }
});
}catch(e){}
}
// 将门店库存列统一重置为 0当未选择门店或切回大仓时
function __resetStoreColumnToZero(){
try{
var rows = $('dataNode').getElements('tr');
rows.each(function(row){
var storeTd = row.getElement('td[is_o2o_branch]');
if(storeTd){ storeTd.set('text', 0); }
});
}catch(e){}
}
function createGoodsItemHtml(product, obj) {
if (product['delete'] == 'false') {
if(!orderItems[product['bn']]){
orderItems[product['bn']] = new Array();
orderItems[product['bn']]['delete'] = 'false';
orderItems[product['bn']]['bn'] = product['bn'];
orderItems[product['bn']]['name'] = product['name'];
orderItems[product['bn']]['addon'] = product['addon'];
orderItems[product['bn']]['price'] = parseFloat(product['price']);
orderItems[product['bn']]['amount'] = parseFloat(product['amount']);
orderItems[product['bn']]['quantity'] = parseFloat(product['quantity']);
orderItems[product['bn']]['left_nums'] = parseFloat(product['left_nums']);
orderItems[product['bn']]['branch_store'] = product['branch_store'];
orderItems[product['bn']]['cnService'] = obj['cnServiceBranch'];
//销售物料编码和销售物料名称
pbnGbn[product['bn']] = [];
pbnGbn[product['bn']].push(obj['bn']);
orderItems[product['bn']]['goods_bn'] = obj['bn'];
orderItems[product['bn']]['goods_name'] = obj['name'];
}else{
orderItems[product['bn']]['amount'] = parseFloat(orderItems[product['bn']]['amount']) + parseFloat(product['amount']);
orderItems[product['bn']]['quantity'] = parseFloat(orderItems[product['bn']]['quantity']) + parseFloat(product['quantity']);
orderItems[product['bn']]['left_nums'] = parseFloat(orderItems[product['bn']]['left_nums']) + parseFloat(product['left_nums']);
//销售物料编码和销售物料名称
if(pbnGbn[product['bn']].indexOf(obj['bn']) == -1) {
pbnGbn[product['bn']].push(obj['bn']);
orderItems[product['bn']]['goods_bn'] += ','+obj['bn'];
orderItems[product['bn']]['goods_name'] += ','+obj['name'];
}
}
}
}
function createGoodsHtml(goods) {
for (objId in goods) {
for (itemId in goods[objId]['order_items']) {
createGoodsItemHtml(goods[objId]['order_items'][itemId], goods[objId]);
}
}
}
function createCheckItemsHtml(cItems) {
for (cId in cItems) {
if (cItems[cId]['delete'] == 'false') {
if(!orderCheckItems[cItems[cId]['bn']]){
orderCheckItems[cItems[cId]['bn']] = cItems[cId]
}
}
}
}
function getProducts(orderId) {
for (id in gOrders) {
if (orderId == id) {
var products = gOrders[id]['items'];
for (ptype in products) {
createGoodsHtml(gOrders[id]['items'][ptype]);
if (ptype == 'goods') {
} else if (ptype == 'gift') {
} else if (ptype == 'pkg') {
}
}
}
}
}
function getCheckItems(orderId) {
for (id in gOrders) {
if (orderId == id) {
var check_items = gOrders[id]['check_items'];
createCheckItemsHtml(check_items);
}
}
}
function reWriteProductWeight() {
var orders = getCombineOrders();
var orderWeight = <{$orderWeight}>;
var weight = 0;
for (i=0; i<orders.length; i++) {
order_id = orders[i].value;
if(orderWeight[order_id]==0){
weight=0;
break;
}else{
weight+=orderWeight[order_id];
}
}
if(weight==0){
weight_html='<font color=red>商品未设置重量<br>默认使用首重</font>';
}else{
weight_html=(weight/1000).toFixed(3)+'KG';
}
$('order_weight').set('html',weight_html);
return weight;
}
function reWriteProductNode () {
// 先要隐藏和清空order-reminder
hideReminder();
//计算所有产品信息
var orders = getCombineOrders();
// 判断是否存在cpup,如果存在做提示order-reminder。getCombineOrders需要大于1
if(orders.length > 1) {
// 获取所有订单cpup-service元素的class为cpup-service
var cpupServices = getCpupServices(orders);
if (cpupServices.length > 0) {
// 需要将services去重后拼接成字符串并赋给order-reminder
var allServices = [];
cpupServices.each(function(item) {
allServices = allServices.concat(item.services);
});
// 去重
var uniqueServices = allServices.filter(function(service, index) {
return allServices.indexOf(service) === index;
});
// 拼接成字符串并显示
var servicesText = '订单存在物流服务标签:<span style="color: #ff6600; font-weight: bold;">' + uniqueServices.join('、') + '</span> 等服务订单。如果合并会导致其中部分服务订单未履约被判责,有赔付风险,请确认是否操作。';
showInfoMessage(servicesText);
}
}
var html = '';
var orderIds = new Array();
var select_corp_id='';
if($('logi_id')){
select_corp_id = $('logi_id').value;
}
orderItems = new Array();
orderCheckItems = new Array();
pbnGbn = [];
for (i=0; i<orders.length; i++) {
getProducts(orders[i].value);
orderIds[i] = orders[i].value;
getCheckItems(orders[i].value)
}
weight = reWriteProductWeight();
// console.log(orderCheckItems);
html = itemHtmlData();
checkHtml = checkItemHtmlData();
new Request({
url:'index.php?app=ome&ctl=admin_order&act=getDefaultBranchForNormal',
method:'post',
async: false,
data:'orders='+JSON.encode(orderIds),
onComplete: function(json) {
if(!json){
return;
}else{
json = JSON.decode(json);
if(json.branch_id==0){
var branch = '没有推荐发货仓库,请手动确认';
}else{
var branch = '推荐用仓库:"' + json.name + '"发货';
}
$('recommend_branch').set('html', branch);
if(json.corp_id) {
select_corp_id = json.corp_id;
}
setTimeout(function () {
Object.each($$('[data-storeid]'), function(si) {
if(typeof si != 'object') {
return;
}
var allBId = json.all_branch_id || {};
var isHad = 0;
Object.each(allBId, function(bi) {
if(bi == si.getAttribute('data-storeid')) {
isHad = 1;
si.style.display = '';
}
})
if(!isHad) {
var tr = si.getParent('TR');
var theNum = 0;
for(var i=0, len=tr.cells.length; i<len; i++){
if(tr.cells[i] == si) {
theNum = i;
break;
}
}
var table = si.getParent('table');
var trs = table.rows;
for(var i = 0, len = trs.length; i < len; i++){
var cell = trs[i].cells[theNum];
if ($defined(cell)) {
cell.style.display = 'none';
}
}
return;
}
if(si.getAttribute('data-storeid') == json.branch_id && json.branch_id!=0) {
si.getElement('.select_branch').fireEvent('click',);
}
});
}, 100);
// Handle getCorps call for recommended warehouse
if(json.branch_id && json.branch_id!=0) {
var area0 = $E('[name="consignee[area]"]',$('delivery_info')).value;
getCorps(json.branch_id, area0, weight, '');
}
// If recommended warehouse is store branch, select store column and update inventory
try{
if('<{$has_store_branch}>'=='true' && $('store_branch_selector')){
// 检查返回的branch_id是否在门店仓列表中
var isStoreBranch = false;
var storeName = '可选择O2O门店';
if(window.storeBranchesData){
for(var i = 0; i < window.storeBranchesData.length; i++){
if(String(window.storeBranchesData[i].branch_id) == String(json.branch_id)){
isStoreBranch = true;
storeName = window.storeBranchesData[i].name;
break;
}
}
}
if(isStoreBranch){
// 更新门店仓选择器显示的名称
var storeSelector = $('store_branch_selector');
if(storeSelector){
$('selected_store_name').set('text', storeName);
// 设置门店仓选择器的选中状态样式(白色文字)
storeSelector.style.color = '#fff';
}
// 更新门店列的选中状态
var header = $('storeBranchHeader');
if(header){
var ths = header.getParent('tr').getElements('th');
ths.removeClass('selected');
header.addClass('selected');
header.set('data-storeid', json.branch_id);
}
// Mark for store inventory column update after table rendering
window.__init_store_branch_to_update = json.branch_id;
// Note: getCorps already called above, no need to call again here
}
}
}catch(e){}
}
}
}).send();
$('dataNode').set('html', html);
// 若初始化标记了门店,需要在表体渲染完成后同步一次门店库存列
try{
if(window.__init_store_branch_to_update){
__updateStoreColumnFor(window.__init_store_branch_to_update);
window.__init_store_branch_to_update = null;
}
}catch(e){}
// 门店仓相关逻辑已移除,因为现在使用弹层选择器
<{if $check_items}>
$('checkDataNode').set('html', checkHtml);
<{/if}>
// 门店仓快递公司加载逻辑已移除,因为现在使用弹层选择器
if ($('btn_delivery_submit') && memberOrders > 0 ) {
resetAddress();
}
}
function displayDetail(e) {
var orderId = e.id.replace('extendBtn', '');
var displayObj = $('detail'+orderId);
if (displayObj.style.display == 'none') {
e.set('html', '-');
displayObj.style.display = '';
} else {
e.set('html', '+');
displayObj.style.display = 'none';
}
}
function displayGiftNote() {
$('has_gifts').setStyle('display','none');
$('btn_con').set('disabled', '');
$ES("input[name^='orderIds[]']").each(function(item){
if(item.checked && item.get('has_gift') == '1' ){
$('has_gifts').setStyle('display','');
$('btn_con').set('disabled', 'true');
}
});
}
function setButtonStatus(){
if($('has_pro_gifts').checked){
$('btn_con').set('disabled', '');
}else{
$('btn_con').set('disabled', 'true');
}
}
function checkProcess(is_select_o2o) {
var el = $$('#orderNode input');
var result = false;
var hasrefund = false;
for(i=0;i<el.length; i++) {
if (el[i].name =='orderIds[]') {
if (el[i].checked) {
result=true;
}
}
}
var branch_id = $('dataNode').getParent().getElement('th.selected') ? $('dataNode').getParent().getElement('th.selected').get('data-storeid') : '';
if (!branch_id) return MessageBox.error('请先选择仓库!');
if ('<{$order_sort_type}>' == 'cnauto' && branch_id!='<{$auto_branch_id}>'){
return MessageBox.error('菜鸟流转订单必须选择绑定仓库!');
}
if ($defined($E('#issplitarea input[type=hidden][name=branch_id]')))
{
$E('#issplitarea input[type=hidden][name=branch_id]').set('value',branch_id);
} else {
new Element('input[type=hidden][name=branch_id]', {
value: branch_id
}).inject($('issplitarea'), 'top');
}
for (var item in orderItems) {
if (orderItems[item]['delete'] == 'false') {
//门店履约订单
if(is_select_o2o == 'true'){
branch_is_ctrl_supply_relation = $('branch_is_ctrl_supply_relation').value;
if(branch_is_ctrl_supply_relation == 'true'){
var is_ctrl_store = false;
var branch_store = 0;
var branch_is_ctrl_store = $("branch_is_ctrl_store") ? $("branch_is_ctrl_store").value : "";
if(orderItems[item]['branch_store'][branch_id])
{
is_ctrl_store = orderItems[item]['branch_store'][branch_id]['is_ctrl_store'];
}
//门店管控库存,货品管控库存的才进行库存检查
if(is_ctrl_store && branch_is_ctrl_store == 'true')
{
branch_store = orderItems[item]['branch_store'][branch_id]['store'] ? orderItems[item]['branch_store'][branch_id]['store'] : 0;
if(branch_store < orderItems[item]['quantity']){
return MessageBox.error(orderItems[item]['bn']+'库存不足,不能发货!');
break;
}
}
}
}else{
orderItems[item]['branch_store'][branch_id] = parseInt(orderItems[item]['branch_store'][branch_id]);
orderItems[item]['branch_store'][branch_id] = isNaN(orderItems[item]['branch_store'][branch_id]) ? 0 : orderItems[item]['branch_store'][branch_id];
if(orderItems[item]['branch_store'][branch_id] < orderItems[item]['quantity']){
return MessageBox.error(orderItems[item]['bn']+'库存不足,不能发货!');
break;
}
}
}
}
if (!result) {
return MessageBox.error('你没有勾选任何可操作的订单');
}
if (hasrefund) {
return confirm("在要确认的订单中有退款标记的订单,建议您仔细检查后再执行此操作,以避免出现发错货或多发货的现像\n你还确定要确认并生发货单吗?");
}
return result;
}
function doDetailAction(act, orderId) {
var opts = $('logi_id').options;
var logi_id = $('logi_id').value;
var logi_code = "";
for(var i=0; i<opts.length; i++){
if(opts[i].value == logi_id){
logi_code = $('logi_id').options[i].id;
}
}
//指定快递
if(assign_express_code && logi_code && (logi_code != assign_express_code)){
if(!confirm("买家要求指定快递: "+ assign_express_name +" 发货,确定不使用么?")){
return false;
}
}
//全渠道订单提交时数据检查
is_select_o2o = $("is_select_o2o") ? $("is_select_o2o").value : "";
if(is_select_o2o == "true")
{
o2o_store_id = $("o2o_store_id").value;
if(!o2o_store_id)
{
alert('请先选择门店');
return false;
}
//存在无供货关系的基础物料
invalid_material_bn = $("invalid_material_bn") ? $("invalid_material_bn").value : "";
if(invalid_material_bn)
{
alert("基础物料:"+ invalid_material_bn +" 不存在供货关系,请检查!");
return false;
}
}
//检查
if (act==1 || act==3) {
if($('btn_delivery_submit')) {
return MessageBox.error('您的配送信息正处于编辑状态!');
}
if ($('logi_id').value == '') {
return MessageBox.error('没有选择快递公司,如你还没有进行过快递公司的设置,请设置后再试!');
}
}
var select_logi_id = $('logi_id').value;
var select_branch_id = $('dataNode').getParent().getElement('th.selected') ? $('dataNode').getParent().getElement('th.selected').get('data-storeid') : '';
var select_order_ids = '';
$ES("input[name^='orderIds[]']").each(function(item){
if(item.checked){
if(select_order_ids){
select_order_ids += ',' + item.value;
}else{
select_order_ids = item.value;
}
}
});
//check
if(act == 3){
if(select_logi_id == '' || select_branch_id == ''){
return MessageBox.error('请选择发货仓库和配送物流!');
}
}
//查看是否有可合并发货单
var combine_delivery='';
var check_type = '';
var check_error_msg = '';
if (act == 1 || act == 2 || act == 3) {
if (!checkProcess(is_select_o2o)) {
return false;
}
//检查是否有单据可以合并
if(is_select_o2o != "true")
{
new Request({
url:'index.php?app=ome&ctl=admin_order&act=fetchCombineDelivery',async:false,
method:'post',
data:{order_id:'<{$order_id}>', logi_id: select_logi_id, branch_id: select_branch_id, order_ids: select_order_ids},
onComplete: function(json) {
if(json){
jsonResult = JSON.decode(json);
//check_type
check_type = jsonResult['check_type'];
if(check_type == 'aox'){
check_error_msg = jsonResult['error_msg'];
}else if(check_type == 'combine_delivery'){
check_error_msg = jsonResult['error_msg'];
//combine_delivery
for(var i=0;i<json.length;i++){
combine_delivery+=+json[i]+',';
}
}
}
}
}).send();
}
}
$('do_action').value = act;
$('order_id').value = orderId;
if(check_type && check_error_msg){
if(check_type == 'aox'){
var url = 'index.php?app=ome&ctl=admin_order&act=reconfirmOrder&order_id=<{$order_id}>&logi_id='+ select_logi_id + '&branch_id='+ select_branch_id + '&order_ids='+select_order_ids;
new Dialog(url, {title:'翱象审核订单提醒',width:520,height:260});
}else if(check_type == 'combine_delivery' && combine_delivery.length>0){
var url = 'index.php?app=ome&ctl=admin_order&act=combineOrderNotify&order_id=<{$order_id}>';
new Dialog(url,{title:'确认',width:500,height:200});
}else{
alert('无效的操作:'+ check_type +''+ check_error_msg);
}
}else{
$('order_split').fireEvent('submit', {
stop: function() {
}
});
}
}
// 提醒区域控制函数
function updateReminder(type, content) {
var reminder = $('order-reminder');
if (!reminder) return;
// 移除所有状态类
reminder.removeClass('reminder-info reminder-success reminder-error reminder-warning');
// 添加新的状态类
reminder.addClass('reminder-' + type);
// 更新内容
var contentEl = reminder.getElement('.reminder-content');
if (contentEl) contentEl.set('html', content);
// 显示提醒区域
reminder.setStyle('display', 'block');
}
// 显示成功信息
function showSuccessMessage(content) {
updateReminder('success', content || '订单确认成功,可以继续后续操作。');
}
// 显示错误信息
function showErrorMessage(content) {
updateReminder('error', content || '订单确认失败,请检查相关信息后重试。');
}
// 显示警告信息
function showWarningMessage(content) {
updateReminder('warning', content || '请仔细检查订单信息,确认无误后再进行操作。');
}
// 显示普通提醒信息
function showInfoMessage(content) {
updateReminder('info', content || '请仔细核对订单信息、收货地址、商品明细和库存情况,确认无误后再进行发货操作。');
}
// 隐藏提醒区域
function hideReminder() {
var reminder = $('order-reminder');
if (reminder) {
reminder.setStyle('display', 'none');
reminder.getElement('.reminder-content').set('html', '');
}
}
reWriteProductNode();
window.addEvent('domready', function(){
$ES("input[name^='orderIds[]']").each(function(item){
if(item.checked && item.get('has_gift') == '1' ){
$('has_gifts').setStyle('display','');
$('btn_con').set('disabled', 'true');
}
});
// 绑定门店仓选择按钮点击事件
if ($('store_branch_selector')) {
$('store_branch_selector').addEvent('click', function() {
showStoreBranchSelector();
});
// 绑定鼠标悬停事件 - 显示下划线
$('store_branch_selector').addEvent('mouseenter', function() {
this.style.textDecoration = 'underline';
});
// 绑定鼠标离开事件 - 隐藏下划线
$('store_branch_selector').addEvent('mouseleave', function() {
this.style.textDecoration = 'none';
});
}
});
//有退款或售后记录,确认操作按钮
if(document.getElementById("go_continue"))
{
$('go_continue').addEvent('click',function(e){
window.location.hash = "#go_return";
if($('go_continue').checked){
$('continue_but_1').setStyle('display','none');
$('continue_but_2').setStyle('display','');
}else{
$('continue_but_1').setStyle('display','');
$('continue_but_2').setStyle('display','none');
}
});
}
</script>