Files
OMS/app/omeauto/view/order/label/addrole.html
2026-01-04 19:08:31 +08:00

180 lines
7.7 KiB
HTML

<!--
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.
-->
<{capture name="header"}>
<{css app='omeauto' src="style.css"}>
<{/capture}>
<div class="tableform">
<div class="division">
<form action="index.php?app=omeauto&ctl=order_type&act=createRole" method="post" id="m_con_form">
<input type="hidden" id='org_id' name="org_id" value="<{$org_id}>">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<th width="60"><label for="dom_el_bc">筛选条件:</label> </th>
<td >
<select name="type_id" id="type_id">
<option value="platform" <{if $init.role=='platform'}>selected<{/if}>>来源平台</option>
<option value="address" <{if $init.role=='address'}>selected<{/if}>>收货地址(省+市+区)</option>
<option value="shop" <{if $init.role=='shop'}>selected<{/if}>>前端店铺</option>
<option value="cod" <{if $init.role=='cod'}>selected<{/if}>>付款方式</option>
<option value="money" <{if $init.role=='money'}>selected<{/if}>>订单金额</option>
<option value="sku" <{if $init.role=='sku'}>selected<{/if}>>活动订单</option>
<option value="skunum" <{if $init.role=='skunum'}>selected<{/if}>>基础物料种类数</option>
<option value="itemnum" <{if $init.role=='itemnum'}>selected<{/if}>>基础物料总数量</option>
<option value="weight" <{if $init.role=='weight'}>selected<{/if}>>基础物料总重量</option>
<option value="memo" <{if $init.role=='memo'}>selected<{/if}>>备注关键字</option>
<option value="ordertype" <{if $init.role=='ordertype'}>selected<{/if}>>订单类型</option>
<option value="materialtype" <{if $init.role=='materialtype'}>selected<{/if}>>按基础物料类型</option>
<option value="materialcat" <{if $init.role=='materialcat'}>selected<{/if}>>按基础物料分类</option>
</select>
</td>
</tr>
<tr>
<th width="60"><label for="dom_el_bc">条件设定:</label> </th>
<td>
<div id="type_content">
</div>
</td>
</tr>
<tr>
<td colspan="2" align="center" height="3">
<hr/>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<{button class="btn-primary" label="确定" type="button" id="saveBtn"}>
<{button class="btn-primary" label="取消" type="button" id="cancelBtn"}>
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
<script>
(function() {
var uid = '<{$uid}>';
function displayDetail(role)
{
var type = $('type_id').value;
var org_id = $('org_id').value;
new Request.HTML({
url : 'index.php?app=omeauto&ctl=order_type&act=ajax',
method : 'post',
evalScripts : true,
update : $('type_content'),
onSuccess: function(){
}
}).post('p[0]='+type+'&p[1]=getUI&p[2]='+role+'&p[3]='+org_id);
}
//增加事件
$('type_id').addEvent('change',function(){
displayDetail('');
});
//关闭按钮
$('cancelBtn').addEvent('click', function(){
$('cancelBtn').getParent('.dialog').retrieve('instance').close();
});
//保存按钮
$('saveBtn').addEvent('click', function(){
$('m_con_form').fireEvent('submit', {
stop: function() {
}
});
});
$('m_con_form').removeEvents('submit').addEvent('submit', function(e)
{
e.stop();
new Request.JSON ({
url:this.action,
onRequest: function () {
$('saveBtn').set('disabled', 'true');
$('cancelBtn').set('disabled', 'true');
},
onSuccess: function(result) {
if (result.code =='SUCC') {
//成功
if (uid=='') {
addRole(result.msg);
} else {
editRole(result.msg, uid);
}
$('saveBtn').getParent('.dialog').retrieve('instance').close();
} else {
$('saveBtn').set('disabled', '');
$('cancelBtn').set('disabled', '');
//提示信息
alert(result.msg);
}
}
})[this.method](this);
});
function addRole(role)
{
var info = Json.evaluate(role);
var addItem = new Element('li .roleItem',{html:'<div title="'+info.caption+'">' + info.caption + '</div><span><a href="javascript:void(0);" class="edit" ref=\''+role+'\'>编辑</a>&nbsp;<a href="javascript:void(0);" class="del">删除</a></span>'}).inject('roleList');
addItem.id = 'm_item_'+ uniqueID();
addItem.getElement('.del').addEvent("click",function(){
if (confirm("你确定要删除当前指定规则吗?")) {
this.getParent().getParent().destroy();
}
});
addItem.getElement('.edit').addEvent("click",function(){
var role = this.get('ref');
var uid = this.getParent().getParent().id;
var org_id = $('chose_org').value;
new Dialog('index.php?ctl=order_type&act=addrole&app=omeauto&role=' + role + '&uid=' + uid+ '&org_id=' + org_id,{width:760,height:560,title:'规则设定'});
});
}
function editRole(role, uid)
{
var info = Json.evaluate(role);
var editItem = $(uid);
editItem.set('html','<div title="'+info.caption+'">' + info.caption + '</div><span><a href="javascript:void(0);" class="edit" ref=\''+role+'\'>编辑</a>&nbsp;<a href="javascript:void(0);" class="del">删除</a></span>');
editItem.getElement('.del').addEvent("click",function(){
if (confirm("你确定要删除当前指定规则吗?")) {
this.getParent().getParent().destroy();
}
});
editItem.getElement('.edit').addEvent("click",function(){
var role = this.get('ref');
var uid = this.getParent().getParent().id;
var org_id = $('chose_org').value;
new Dialog('index.php?ctl=order_type&act=addrole&app=omeauto&role=' + role + '&uid=' + uid+ '&org_id=' + org_id,{width:760,height:560,title:'规则设定'});
});
};
displayDetail('<{$role}>');
})();
</script>