ecshop后台【商品管理】
1.商品列表增加“运费”,并且ajax修改
a.增添html代码
<span onclick="listTable.edit(this, 'edit_express_price', {$goods.goods_id})">{$goods.express_price}</span>
b.goods.php对edit_express_price进行处理
admin/goods.php代码
elseif ($_REQUEST['act'] == 'edit_express_price') { check_authz_json('goods_manage'); $goods_id = intval($_POST['id']); $express_price = intval($_POST['val']); if($express_price < 0 || $express_price == 0 && $_POST['val'] != "$goods_num") { make_json_error($_LANG['goods_number_error']); } if(check_goods_product_exist($goods_id) == 1) { make_json_error($_LANG['sys']['wrong'] . $_LANG['cannot_goods_number']); } if ($exc->edit("express_price = '$express_price', last_update=" .gmtime(), $goods_id)) { clear_cache_files(); make_json_result($express_price); } }
c.商品列表,增加express_price
admin/include/lib_goods.php, function goods_list(){} 第911行,修改代码
/* 分页大小 */ $filter = page_and_size($filter); $sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral,goods_thumb,express_price, "
2.商品批量设置商品品牌
a.增加html代码,增加“设置品牌”
<select name="type" id="selAction" onchange="changeAction()"> <option value="move_to">{$lang.move_to}</option> {if $suppliers_list > 0} <option value="suppliers_move_to">{$lang.suppliers_move_to}</option> {/if} <option value="country_to">转移国家产地</option> <option value="brand_to">设置品牌</option> </select>
选择设置品牌后,再显示下级小分类
<!--设置品牌--> <select name="brand_id" style="display:none"> <option value="0">{$lang.select_please}</option> {foreach from=$brand_list item=vo key=key} <option value="{$key}">{$vo}</option> {/foreach} </select>
b.增加js功能
changeAction() 功能:选择设置品牌,会显示下级小分类
function changeAction() { var frm = document.forms['listForm']; // 切换分类列表的显示 frm.elements['target_cat'].style.display = frm.elements['type'].value == 'move_to' ? '' : 'none'; frm.elements['country_id'].style.display = frm.elements['type'].value == 'country_to' ? '' : 'none'; frm.elements['brand_id'].style.display = frm.elements['type'].value == 'brand_to' ? '' : 'none'; if (!document.getElementById('btnSubmit').disabled && confirmSubmit(frm, false)) { frm.submit(); } }
confirmSubmit() 功能:转移分类
function confirmSubmit(frm, ext) { if (frm.elements['type'].value == 'trash') { return confirm(batch_trash_confirm); } else if (frm.elements['type'].value == 'brand_to') { ext = (ext == undefined) ? true : ext; return ext && frm.elements['brand_id'].value != 0; } else if (frm.elements['type'].value == '') { return false; } else { return true; } }
c.php代码,批量操作 elseif ($_REQUEST['act'] == 'batch') 第1189行
/* 转移到供货商 */ elseif ($_POST['type'] == 'suppliers_move_to') { /* 检查权限 */ admin_priv('goods_manage'); update_goods($goods_id, 'suppliers_id', $_POST['suppliers_id']); } /* 转移国家产地 */ elseif ($_POST['type'] == 'brand_to') { /* 检查权限 */ admin_priv('goods_manage'); update_goods($goods_id, 'brand_id', $_POST['brand_id']); }