mirror of
https://gitee.com/ShopeX/OMS
synced 2026-04-09 07:55:34 +08:00
676 lines
30 KiB
HTML
676 lines
30 KiB
HTML
<!--
|
||
Copyright © ShopeX (http://www.shopex.cn). All rights reserved.
|
||
See LICENSE file for license details.
|
||
-->
|
||
|
||
<{capture name="header"}>
|
||
<{css app="ome" src="ome.css"}>
|
||
<{css app="ome" src="style.css"}>
|
||
<{script src="coms/modedialog.js" app="desktop"}>
|
||
<{script src="coms/autocompleter.js" app="desktop"}>
|
||
<{script src="coms/pager.js" app="desktop"}>
|
||
<{/capture}>
|
||
<style>
|
||
.notice-inline.error {background-image:none;margin-left:25px}
|
||
.luckybag_hr {height:12px;margin-top:10px}
|
||
.luckybag_title {height:30px;line-height:30px}
|
||
.luckybag_title_name {float:left}
|
||
.luckybag_title_del {float:left;cursor:pointer;color:blue;margin-left:6px}
|
||
.luckybag_title_material {float:right}
|
||
.luckybag_table {margin:4px 0;}
|
||
.luckybag_table_operation_th {width:50px;}
|
||
.luckybag_rule {height:30px}
|
||
#hand-selected-product {
|
||
padding-left: 20px;
|
||
}
|
||
.object-select {
|
||
width: auto!important;
|
||
}
|
||
#body .workground {
|
||
width: 100%!important;
|
||
}
|
||
.content-main {
|
||
width: 100%!important;
|
||
}
|
||
</style>
|
||
<link href="../../../../app/desktop/statics/perfect/main.css" rel="stylesheet" type="text/css">
|
||
<div class="form-layout">
|
||
<form method="post" id="sales_material_form" action="index.php?app=dealer&ctl=admin_material_sales&act=toEdit">
|
||
<input type="hidden" name="sm_id" value="<{$material_info.sm_id}>">
|
||
<div class="form-layout-block">
|
||
<h3>编辑销售商品基本信息</h3>
|
||
<div class="form-layout-fields form-layout-fields-column">
|
||
<div class="form-field">
|
||
<span class="form-field-label">销售商品名称:</span>
|
||
<input class="form-input" placeholder="请输入商品名称" type="text" name="sales_material_name" vtype="required" value="<{$material_info.sales_material_name}>" /><span style="color:red;">*</span>
|
||
</div>
|
||
<div class="form-field">
|
||
<span class="form-field-label">销售商品编码:</span>
|
||
<{$material_info.sales_material_bn}>
|
||
<input class="form-input" placeholder="请输入商品编码" type="hidden" name="sales_material_bn" vtype="required" value="<{$material_info.sales_material_bn}>" onkeyup="value=value.replace(/[^A-Za-z0-9_-]/ig,'')" /><span style="color:red;">*</span>
|
||
</div>
|
||
<div class="form-field">
|
||
<span class="form-field-label">商品类型:</span>
|
||
<{if $readonly.type == true}>
|
||
<{if $material_info.sales_material_type == 1}>普通
|
||
<{elseif $material_info.sales_material_type ==2}>组合
|
||
<{elseif $material_info.sales_material_type ==3}>赠品
|
||
<{/if}>
|
||
<input type="hidden" name="sales_material_type" value="<{$material_info.sales_material_type}>"> <span style="color:red;">(已有关联订单或店铺冻结不能修改)</span>
|
||
<{else}>
|
||
<div class="form-radios">
|
||
<input id="type1" type="radio" name="sales_material_type" value="1" <{if $material_info.sales_material_type == 1}>checked="checked"<{/if}> />
|
||
<label for="type1">普通</label>
|
||
<input id="type2" type="radio" name="sales_material_type" value="2" <{if $material_info.sales_material_type == 2}>checked="checked"<{/if}> />
|
||
<label for="type2">组合</label>
|
||
<input id="type3" type="radio" name="sales_material_type" value="3" <{if $material_info.sales_material_type == 3}>checked="checked"<{/if}> />
|
||
<label for="type3">赠品</label>
|
||
</div>
|
||
<{/if}>
|
||
</div>
|
||
<div class="form-field">
|
||
<span class="form-field-label">所属店铺:</span>
|
||
<{if $readonly.shop == true}>
|
||
<{foreach from=$shops item=shop}><{if $material_info.shop_id == $shop.shop_id }><{$shop.name}><{/if}><{/foreach}>
|
||
<input type="hidden" name="shop_id" value="<{$material_info.shop_id}>"> <span style="color:red;">(已有关联订单不能修改)</span>
|
||
<{else}>
|
||
<select class="form-input" id="shop_id" name="shop_id">
|
||
<{foreach from=$shops item=shop}>
|
||
<option value="<{$shop.shop_id}>" <{if $material_info.shop_id == $shop.shop_id }>selected="selected"<{/if}> ><{$shop.name}></option>
|
||
<{/foreach}>
|
||
</select>
|
||
<span id="shop_text" style="display:none;">全部店铺</span>
|
||
<{/if}>
|
||
</div>
|
||
|
||
<div class="form-field" id="bind_basic_material" <{if $readonly.bind_item == true && $material_info.sales_material_type == 2}>style="display:none"<{/if}>>
|
||
<span class="form-field-label">关联基础商品:</span>
|
||
<{if $hasBm}>
|
||
<{input class='form-input' type='material_object' object='basic_material@material' breakpoint='0' name='bm_id' textcol='material_name' value=$bind_bm_id callback='material_object_callback' replacehtml=$replacehtml emptytext='选取基础商品' style='float:left;width:200px;' filter=$bm_filter }>
|
||
<{else}>
|
||
<span style="color:red;">没有基础物料权限</span>
|
||
<{/if}>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="form-layout-block" id="promotion_items" <{if $readonly.bind_item == true && $material_info.sales_material_type == 2}>style="margin-top:10px;"<{else}>style="margin-top:10px;display:none"<{/if}> >
|
||
<h3>组合关联基础商品</h3>
|
||
<div class="form-layout-fields form-layout-fields-column">
|
||
<div class="form-field">
|
||
<{if $readonly.bind_item == true && $material_info.sales_material_type == 2}>
|
||
<span id="cantdel" style="color:red;">(绑定商品已有关联订单不能修改)</span>
|
||
<{else}>
|
||
<{button label="商品库频道" id="material-find-btn" }>
|
||
<{/if}>
|
||
</div>
|
||
<table class="gridlist" id="material_table" style="margin:4px 0;">
|
||
<thead>
|
||
<tr>
|
||
<th>编码</th>
|
||
<th style="width:240px;">名称</th>
|
||
<th>成本价</th>
|
||
<th>数量</th>
|
||
<th>组合价格贡献占比(1-100数值)</th>
|
||
<th style="width:30px;">删除</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="dataNode">
|
||
<tr>
|
||
<td colspan="6" style="padding:0;"><div class="note" style="margin:0;"> 暂无商品信息 </div></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div align="right">
|
||
<{button type="button" id="material-compute-rate" label="按成本价计算贡献比" }>
|
||
<{if $readonly.bind_item == true && $material_info.sales_material_type == 2}>
|
||
|
||
<{else}>
|
||
<{button type="button" id="material-delall-btn" label="全部删除" }>
|
||
<{/if}>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="form-layout-block" id="gift_items"
|
||
<{if $readonly.bind_item == true && $material_info.sales_material_type == 3}>style="margin-top:10px;"
|
||
<{else}>style="margin-top:10px;display:none"<{/if}> >
|
||
<h3>赠品关联基础商品</h3>
|
||
<div class="form-layout-fields form-layout-fields-column">
|
||
<div class="form-field">
|
||
<{if $readonly.bind_item == true && $material_info.sales_material_type == 3}>
|
||
|
||
<span id="cantdel" style="color:red;">(绑定商品已有关联订单不能修改)</span>
|
||
<{else}>
|
||
<{button label="基础商品列表" id="gift-material-find-btn" }>
|
||
<{/if}>
|
||
</div>
|
||
<table class="gridlist" style="margin:4px 0;">
|
||
<thead>
|
||
<tr>
|
||
<th>编码</th>
|
||
<th style="width:240px;">名称</th>
|
||
<th>成本价</th>
|
||
<th>数量</th>
|
||
<th style="width:30px;">删除</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="gift_dataNode">
|
||
<tr>
|
||
<td colspan="5" style="padding:0;">
|
||
<div class="note" style="margin:0;"> 暂无商品信息</div>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div align="right">
|
||
<{if $readonly.bind_item == true && $material_info.sales_material_type == 3}>
|
||
|
||
<{else}>
|
||
<{button type="button" id="gift-material-delall-btn" label="全部删除" }>
|
||
<{/if}>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-layout-block">
|
||
<div id="cc" class="noprint table-action">
|
||
<{button type="button" id="sales_material_btn" label="保 存"}>
|
||
<{button type="button" class="btn-secondary" id="return-btn" label="关 闭" onclick="javascript:void(window.close());"}>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<script>
|
||
(function() {
|
||
window.addEvent('domready', function() {
|
||
if($ES("input[name='sales_material_type']:checked").length) {
|
||
var chose_type = $ES("input[name='sales_material_type']:checked").get('value');
|
||
} else {
|
||
var chose_type = $ES("input[name='sales_material_type']").get('value');
|
||
}
|
||
// 普通
|
||
if(chose_type == 1){
|
||
$('promotion_items').setStyle('display','none');
|
||
|
||
if($('bind_basic_material')){
|
||
$('bind_basic_material').setStyle('display','flex');
|
||
}
|
||
|
||
if ($('shop_id')) {
|
||
$('shop_id').setStyle('display', 'block');
|
||
$('shop_text').setStyle('display', 'none');
|
||
}
|
||
|
||
}else if(chose_type == 2){
|
||
$('promotion_items').setStyle('display','block');
|
||
|
||
if($('bind_basic_material')){
|
||
$('bind_basic_material').setStyle('display','none');
|
||
}
|
||
if($('shop_id')){
|
||
$('shop_id').setStyle('display','block');
|
||
$('shop_text').setStyle('display','none');
|
||
}
|
||
}else if(chose_type == 3){
|
||
// 组合明细屏蔽
|
||
$('promotion_items').setStyle('display', 'none');
|
||
// 绑定基础商品屏蔽
|
||
$('bind_basic_material').setStyle('display', 'none');
|
||
// 赠品明细显示
|
||
$('gift_items').setStyle('display', 'block');
|
||
}
|
||
|
||
$ES('input[name="sales_material_type"]').each(function(item){
|
||
item.addEvent('click',function(e){
|
||
$('promotion_items').setStyle('display','none');
|
||
$('gift_items').setStyle('display','none');
|
||
|
||
if (this.value == '1') { //普通
|
||
$('bind_basic_material').setStyle('display', 'table-row');
|
||
$('shop_id').setStyle('display','block');
|
||
$('shop_text').setStyle('display','none');
|
||
}else{
|
||
if (this.value == '3') { //赠品
|
||
// 赠品关联基础商品div打开
|
||
$('gift_items').setStyle('display', 'block');
|
||
}else{
|
||
$('promotion_items').setStyle('display','block');
|
||
}
|
||
|
||
if($('bind_basic_material')){
|
||
$('bind_basic_material').setStyle('display','none');
|
||
}
|
||
|
||
$('shop_id').setStyle('display','block');
|
||
$('shop_text').setStyle('display','none');
|
||
}
|
||
});
|
||
|
||
});
|
||
|
||
//页面加载商品
|
||
new Request({url:'index.php?app=dealer&ctl=admin_material_sales&act=getEditMaterial&p[0]='+<{$material_info.sm_id}>,
|
||
onComplete:function(rs){
|
||
rs=JSON.decode(rs);
|
||
var original = rs.original; //普通、赠品、组合
|
||
if(original){
|
||
store.combine(original);
|
||
|
||
// 不同的销售商品类型保存store数据至类型变量
|
||
<{if $material_info.sales_material_type == 3}>
|
||
giftStore = store;
|
||
<{else}>
|
||
bmStore = store;
|
||
<{/if}>
|
||
|
||
<{if $material_info.sales_material_type == 3}>
|
||
createGiftProduct(store);
|
||
<{else}>
|
||
createProduct(store);
|
||
<{/if}>
|
||
}
|
||
}}).send();
|
||
|
||
if($('cantdel')){
|
||
var tpl='<tr key="{bm_id}" id="bm_{bm_id}" title="点击选取/反选此条记录">'
|
||
+' <td>{material_bn}</td><td class="material-name">{material_name}</td><td>{cost}</td>'
|
||
+' <td><input type="text" value="{number}" key="number" vtype="number&&required" tname="at[_PRIMARY_]" size="6" readonly></td>'
|
||
+' <td><input type="text" vtype="number&&required" tname="pr[_PRIMARY_]" key="rate" value="{rate}" id="rate_{bm_id}" size="5"></td>'
|
||
+' <td style="text-align:center;">-<{img src="bundle/delecate.gif" style="display:none;" app="desktop" key="state" class="pointer btn-delete-item"}></td>'
|
||
+'</tr>';
|
||
var gift_tpl = '<tr key="{bm_id}" id="bm_{bm_id}" title="点击选取/反选此条记录">' +
|
||
'<td>{material_bn}</td>' +
|
||
'<td class="material-name">{material_name}</td>' +
|
||
'<td>{cost}</td>' +
|
||
'<td><input type="text" value="{number}" key="number" vtype="number&&required" tname="at[_PRIMARY_]" size="6" readonly></td>' +
|
||
'<td style="text-align:center;">-<{img src="bundle/delecate.gif" style="display:none;" app="desktop" key="state" class="pointer btn-delete-item"}></td>'
|
||
+ '</tr>';
|
||
}else{
|
||
var tpl='<tr key="{bm_id}" id="bm_{bm_id}" title="点击选取/反选此条记录">'
|
||
+' <td>{material_bn}</td><td class="material-name">{material_name}</td><td>{cost}</td>'
|
||
+' <td><input type="text" value="{number}" key="number" vtype="number&&required" tname="at[_PRIMARY_]" size="6"></td>'
|
||
+' <td><input type="text" vtype="number&&required" tname="pr[_PRIMARY_]" key="rate" value="{rate}" id="rate_{bm_id}" size="5"></td>'
|
||
+' <td><{img src="bundle/delecate.gif" app="desktop" key="state" class="pointer btn-delete-item"}></td>'
|
||
+'</tr>';
|
||
var gift_tpl = '<tr key="{bm_id}" id="bm_{bm_id}" title="点击选取/反选此条记录">' +
|
||
'<td>{material_bn}</td>' +
|
||
'<td class="material-name">{material_name}</td>' +
|
||
'<td>{cost}</td>' +
|
||
'<td><input type="text" value="{number}" key="number" vtype="number&&required" tname="at[_PRIMARY_]" size="6"></td>' +
|
||
'<td><{img src="bundle/delecate.gif" app="desktop" key="state" class="pointer btn-delete-item"}></td>'
|
||
+ '</tr>';
|
||
}
|
||
|
||
var callurl='index.php?app=material&ctl=admin_material_basic&act=getMaterial',store=[], bmStore = [], giftStore = [];
|
||
var url='index.php?app=desktop&act=alertpages&goto='+encodeURIComponent('index.php?app=material&ctl=admin_material_basic&act=findMaterial&filter=<{$bm_filter}>');
|
||
if($('material-find-btn')){
|
||
$('material-find-btn').addEvent('click',function(e){
|
||
new finderDialog(url,{params:{url:callurl,name:'bm_id[]'},width:1000,height:660,
|
||
onCallback:function(rs){
|
||
if(!rs)return;
|
||
rs=JSON.decode(rs);
|
||
init(rs);
|
||
}
|
||
});
|
||
});
|
||
}
|
||
|
||
// 赠品
|
||
if ($('gift-material-find-btn')) {
|
||
$('gift-material-find-btn').addEvent('click', function (e) {
|
||
new finderDialog(url, {
|
||
params: {url: callurl, name: 'bm_id[]'}, width: 1000, height: 660,
|
||
onCallback: function (rs) {
|
||
if (!rs) return;
|
||
rs = JSON.decode(rs);
|
||
init(rs, 'gift');
|
||
}
|
||
});
|
||
});
|
||
}
|
||
|
||
var pag,rows,giftPag;
|
||
function emptyData(){
|
||
var noData='<tr>'
|
||
+'<td colspan="7" style="padding:0;"><div class="note" style="margin:0;"> 暂无商品信息 </div></td>'
|
||
+'</tr>';
|
||
$('dataNode').set('html',noData);
|
||
}
|
||
|
||
// 赠品关联商品清空时显示
|
||
function emptyGiftData() {
|
||
var noData = '<tr>'
|
||
+ '<td colspan="7" style="padding:0;"><div class="note" style="margin:0;"> 暂无商品信息 </div></td>'
|
||
+ '</tr>';
|
||
$('gift_dataNode').set('html', noData);
|
||
}
|
||
|
||
function createProduct(data){
|
||
pag=new PageData(tpl,data,{'updateMain':$('dataNode'),'pageNum':10,PRIMARY_ID:'bm_id',
|
||
'onShow':function(){
|
||
var _this=this;
|
||
$$('#dataNode input[type]').addEvent('change',function(e){
|
||
var pid=this.getParent('tr').get('key'),value=this.value;
|
||
|
||
_this.editData(pid,[this.get('key'),value]);
|
||
});
|
||
|
||
rows=$ES('#dataNode tr');
|
||
rows.each(function(item,i){
|
||
item.addEvent('click',function(e){
|
||
this.toggleClass('selected');
|
||
});
|
||
item.getElement('.btn-delete-item').addEvent('click',function(e){
|
||
if(_this.selectData(item.get('key')) && confirm('确定要删除 '+ _this.selectData(item.get('key'))['material_name'] +' 吗?')) _this.delData(item.get('key'));
|
||
if(!$E('#dataNode tr')) emptyData();
|
||
});
|
||
item.getElement('input[key^=number]').addEvent('keypress',function(e){
|
||
if(e.code==13) $E('#pfba input').focus();
|
||
});
|
||
});
|
||
|
||
if(this.data.length) rows[0].getElement('input[key^=number]').focus();
|
||
|
||
$ES('.material-name').removeEvent('mouseover').addEvent('mouseover',function(e){
|
||
if (this.get('visibility')=='false')
|
||
{
|
||
var e = new Event(e), el = e.target;
|
||
visiTips.attach(el);
|
||
el.addEvent('mouseleave',function(){
|
||
this.removeClass('active');
|
||
});
|
||
el.fireEvent('mouseenter',e);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
}
|
||
|
||
function createGiftProduct(data) {
|
||
giftPag = new PageData(gift_tpl, data, {
|
||
'updateMain': $('gift_dataNode'), 'pageNum': 10, PRIMARY_ID: 'bm_id',
|
||
'onShow': function () {
|
||
var _this = this;
|
||
|
||
$$('#gift_dataNode input[type]').addEvent('change', function (e) {
|
||
var pid = this.getParent('tr').get('key'), value = this.value;
|
||
|
||
_this.editData(pid, [this.get('key'), value]);
|
||
});
|
||
|
||
rows = $ES('#gift_dataNode tr');
|
||
rows.each(function (item, i) {
|
||
item.addEvent('click', function (e) {
|
||
this.toggleClass('selected');
|
||
});
|
||
item.getElement('.btn-delete-item').addEvent('click', function (e) {
|
||
if (_this.selectData(item.get('key')) && confirm('确定要删除 ' + _this.selectData(item.get('key'))['material_name'] + ' 吗?')) _this.delData(item.get('key'));
|
||
if (!$E('#dataNode tr')) emptyData();
|
||
compute(item);
|
||
});
|
||
|
||
item.getElement('input[key^=number]').addEvent('keypress', function (e) {
|
||
if (e.code == 13) $E('#pfba input').focus();
|
||
});
|
||
});
|
||
|
||
if (this.data.length) rows[0].getElement('input[key^=number]').focus();
|
||
|
||
$ES('.material-name').removeEvent('mouseover').addEvent('mouseover', function (e) {
|
||
if (this.get('visibility') == 'false') {
|
||
var e = new Event(e), el = e.target;
|
||
visiTips.attach(el);
|
||
el.addEvent('mouseleave', function () {
|
||
this.removeClass('active');
|
||
});
|
||
el.fireEvent('mouseenter', e);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
}
|
||
|
||
function init(rs, sm_type = 'pkg'){
|
||
// 根据销售商品类型,对全局变量store的内容做调整
|
||
if (sm_type == 'gift') {
|
||
store = giftStore;
|
||
} else {
|
||
store = bmStore;
|
||
}
|
||
// 同已有bm对比,进行去重
|
||
var tmparr=findProduct(rs,'bm_id');
|
||
// 新明细列表颠倒顺序,合并至旧数组
|
||
store.unshift.apply(store,tmparr.reverse());
|
||
|
||
// 不同的销售商品类型调用不同的函数,并保存store数据至类型变量
|
||
if (sm_type == 'gift') {
|
||
createGiftProduct(store);
|
||
giftStore = store;
|
||
}else{
|
||
createProduct(store);
|
||
bmStore = store;
|
||
}
|
||
}
|
||
|
||
function findProduct(arr,PRIMARY){
|
||
if(!store.length)return arr;
|
||
store.each(function(a){
|
||
arr.each(function(b){
|
||
if(a[PRIMARY]==b[PRIMARY])arr.erase(b);
|
||
});
|
||
});
|
||
return arr;
|
||
}
|
||
|
||
if($('material-delall-btn')){
|
||
$('material-delall-btn').addEvent('click',function(e){
|
||
if(!pag||!pag.data)return;
|
||
var delarr=[];
|
||
pag.data.each(function(d){
|
||
delarr.push(d['bm_id']);
|
||
});
|
||
if(confirm('确认删除全部商品吗?')){
|
||
delProduct(pag,delarr);
|
||
emptyData();
|
||
}
|
||
});
|
||
}
|
||
|
||
if ($('gift-material-delall-btn')) {
|
||
$('gift-material-delall-btn').addEvent('click', function (e) {
|
||
if (!giftPag || !giftPag.data) return;
|
||
var delarr = [];
|
||
giftPag.data.each(function (d) {
|
||
delarr.push(d['bm_id']);
|
||
});
|
||
if (confirm('确认删除全部商品吗?')) {
|
||
delProduct(giftPag, delarr);
|
||
emptyGiftData();
|
||
}
|
||
});
|
||
}
|
||
|
||
function delProduct(obj,arr){
|
||
arr.each(function(d){obj.delData(d);});
|
||
}
|
||
|
||
if($('material-compute-rate')){
|
||
$('material-compute-rate').addEvent('click',function(e){
|
||
if(!pag||!pag.data)return;
|
||
|
||
var item_count = 0;
|
||
var num = 0;
|
||
var is_error = false;
|
||
var cost_total = 0;
|
||
|
||
pag.data.each(function(d){
|
||
num = parseInt(d['number']);
|
||
if(num <= 0 || isNaN(num)){
|
||
is_error = true;
|
||
}else{
|
||
cost_total += Number(d['cost']) * num;
|
||
}
|
||
|
||
if(d['cost'] > 0) {
|
||
item_count++;
|
||
}
|
||
});
|
||
|
||
if(is_error){
|
||
alert("请正确填写数量!");
|
||
return false;
|
||
}
|
||
|
||
if(cost_total <= 0){
|
||
alert("都是0元货品,请手工输入贡献占比!");
|
||
return false;
|
||
}
|
||
|
||
var sum_rate = 0;
|
||
var item_rate = 0;
|
||
var item_price = 0;
|
||
var line_i = 0;
|
||
pag.data.each(function(d){
|
||
if(d['cost'] <= 0) {
|
||
return;
|
||
}
|
||
bm_id = d['bm_id'];
|
||
num = parseInt(d['number']);
|
||
item_price = Number(d['cost']) * num;
|
||
|
||
line_i++;
|
||
|
||
if(line_i == item_count){
|
||
item_rate = 100 - sum_rate;
|
||
}else{
|
||
item_rate = Math.floor(item_price / cost_total * 100 * 100) / 100;
|
||
|
||
sum_rate += item_rate;
|
||
|
||
//兼容
|
||
if(sum_rate > 100){
|
||
sum_rate -= item_rate;
|
||
|
||
item_rate = 100 - sum_rate;
|
||
sum_rate += item_rate;
|
||
}
|
||
}
|
||
|
||
//兼容
|
||
if(item_rate < 0){
|
||
item_rate = 0;
|
||
}
|
||
|
||
if($("rate_" + bm_id)){
|
||
$("rate_" + bm_id).set('value', item_rate.toFixed(2));
|
||
}
|
||
|
||
rows=$ES('#dataNode tr');
|
||
rows.each(function(item,i)
|
||
{
|
||
if(bm_id == item.get('key')){
|
||
var pid = item.get('key');
|
||
pag.editData(pid, ['rate', item_rate]);
|
||
}
|
||
});
|
||
|
||
});
|
||
});
|
||
}
|
||
|
||
$('sales_material_btn').addEvent('click',function(e){
|
||
var _this=this;
|
||
var form=this.getParent('form');
|
||
|
||
// 明细绑定页面dom的ID
|
||
let dataNodeDomName = 'dataNode';
|
||
// 关联基础商品列表数组
|
||
let dataItemList;
|
||
|
||
let readonlyType = "<{$readonly.type}>";
|
||
let salesMaterialType;
|
||
if (readonlyType == true ){
|
||
salesMaterialType = $E("input[name=sales_material_type]").value;
|
||
}else{
|
||
salesMaterialType = $E("input[name=sales_material_type]:checked").value;
|
||
}
|
||
|
||
if (salesMaterialType == '3') {
|
||
// 赠品切换明细dom节点
|
||
dataNodeDomName = 'gift_dataNode';
|
||
// 关联基础商品列表数组确定
|
||
dataItemList = giftPag;
|
||
} else {
|
||
dataItemList = pag;
|
||
}
|
||
|
||
// 存在关联多商品明细的情况
|
||
if (dataItemList) {
|
||
var data= dataItemList.toHideInput($(dataNodeDomName).getElement('tr'));
|
||
form.store('target',{extraData:data,
|
||
onRequest:function(){
|
||
_this.disabled=true;
|
||
},
|
||
onComplete:function(jsontext){
|
||
try{
|
||
var json = JSON.decode(jsontext);
|
||
if (typeof(json.error)!='undefined'){
|
||
_this.disabled=false;
|
||
}else{
|
||
_this.disabled=true;
|
||
if(opener.finderGroup['<{$env.get.finder_id}>']) opener.finderGroup['<{$env.get.finder_id}>'].refresh.delay(100,opener.finderGroup['<{$env.get.finder_id}>']);
|
||
setTimeout('window.close()',200);
|
||
}
|
||
}catch(e){}
|
||
}
|
||
});
|
||
}else{
|
||
form.store('target',{
|
||
onRequest:function(){
|
||
_this.disabled=true;
|
||
},
|
||
onComplete:function(jsontext){
|
||
try{
|
||
var json = JSON.decode(jsontext);
|
||
if (typeof(json.error)!='undefined'){
|
||
_this.disabled=false;
|
||
}else{
|
||
_this.disabled=true;
|
||
if(opener.finderGroup['<{$env.get.finder_id}>']) opener.finderGroup['<{$env.get.finder_id}>'].refresh.delay(100,opener.finderGroup['<{$env.get.finder_id}>']);
|
||
setTimeout('window.close()',200);
|
||
}
|
||
}catch(e){}
|
||
}
|
||
});
|
||
}
|
||
form.fireEvent('submit',e);
|
||
});
|
||
|
||
if($('cantdel')){
|
||
$ES(".btn-delete-item").each(function(item){
|
||
this.setStyle('display','none');
|
||
})
|
||
}
|
||
});
|
||
|
||
})();
|
||
|
||
function material_object_callback(rs,handle){
|
||
var p_node = handle.getParent('div');
|
||
var html = '已选择了1个商品,'+"<a href='javascript:void(0);' onclick='material_selected_show();'>查看关联的商品</a>";
|
||
if ($defined($('hand-selected-product')))
|
||
{
|
||
$('hand-selected-product').setHTML(html);
|
||
} else {
|
||
var div = new Element('div',{'html':html,'id':'hand-selected-product'});
|
||
div.injectAfter(p_node);
|
||
}
|
||
}
|
||
|
||
function material_selected_show(){
|
||
new Dialog('index.php?app=dealer&ctl=admin_material_sales&act=showMaterials',{
|
||
ajaxoptions:{data:$('hand-selected-product').getPrevious('div'),method:'post'}
|
||
});
|
||
}
|
||
</script>
|