mirror of
https://gitee.com/ShopeX/OMS
synced 2026-03-31 05:25:32 +08:00
133 lines
4.9 KiB
HTML
133 lines
4.9 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.
|
||
-->
|
||
|
||
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
|
||
<tr>
|
||
<td colspan=2 nowrap>
|
||
<fieldset><legend align="top"><{t}>公式验算<{/t}></legend>
|
||
<div class='notice'>
|
||
<span>您可以在这里测试配送公式是否计算正确、有效</span>
|
||
<div>公式设置:</div>
|
||
<div>{{w}-0.1}*{{2000-w}-0.1}*1.52</div>
|
||
<div>+{{w-2000}-0.6}*{{5000-w}-0.1}*2.26</div>
|
||
<div>+{{w-5000}-0.6}*{{10000-w}-0.1}*2.54</div>
|
||
<div>+{{w-10000}-0.6}*4.10</div>
|
||
<div>+{{n-1}-0.6}*[(n-1)]*0.19</div>
|
||
<div>+{{h-1}-0.6}*[(h-1)]*0.23</div>
|
||
<div>设置技巧:</div>
|
||
<div>w-1000代表w>1000,2000-w代表w<2000,</div>
|
||
<div>-0.1代表包含等号,-0.6代表不包含等号,</div>
|
||
<div>[(w-2000)/1000]代表2公斤以上超了多少公斤</div>
|
||
</div>
|
||
<table width="98%" border="0" cellspacing="0" cellpadding="2">
|
||
<tr>
|
||
<td width="70%" nowrap>公式:
|
||
<input type="text" id="dlg_expressions" value="<{$expressions}>" size="50" /></td>
|
||
</tr>
|
||
<tr>
|
||
<td width="70%" nowrap>商品重量:
|
||
<input type="text" id="weight" name="weight" class="inputstyle" maxlength="20" size="8" value="0">
|
||
克 </td>
|
||
<td width="30%" nowrap rowspan="3">
|
||
<p><button id="btn-calculate" class='sysiconBtnNoIcon'><{t}>计算<{/t}></button>
|
||
</p></td>
|
||
</tr>
|
||
<tr>
|
||
<td width="70%" nowrap>商品件数:
|
||
<{input type="money" id="num" name="num" class="inputstyle" maxlength="20" size="8" value="0"}> </td>
|
||
</tr>
|
||
<tr>
|
||
<td width="70%" nowrap>商品行数:
|
||
<{input type="money" id="hang" name="hang" class="inputstyle" maxlength="20" size="8" value="0"}> </td>
|
||
</tr>
|
||
<tr>
|
||
<td width="70%" nowrap>
|
||
<span id="result"></span>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</fieldset></td>
|
||
</tr>
|
||
</table>
|
||
<div class='mainFoot' style='height:40px;width:80px;margin:0 auto;'>
|
||
<div class="table-action"> <{button type="button" id="btn-confirm" label="确定"}> </div>
|
||
</div>
|
||
<script language="javascript">
|
||
(function() {
|
||
$('btn-calculate').addEvent('click',function(){countexp();});
|
||
$('btn-confirm').addEvent('click',function(){countexp(this)});
|
||
function getval(expval) {
|
||
if (eval(expval) > 0.000001) {
|
||
return 1;
|
||
} else if (eval(expval) > - 0.000001 && eval(expval) < 0.000001) {
|
||
return 1 / 2;
|
||
} else {
|
||
return 0;
|
||
}
|
||
}
|
||
function getceil(expval) {
|
||
if (eval(expval) > 0) {
|
||
return Math.ceil(eval(expval) - 0.000001);
|
||
} else {
|
||
return 0;
|
||
}
|
||
}
|
||
function countexp(qd) {
|
||
var bds = $('dlg_expressions').value;
|
||
if (!qd) {
|
||
if (bds == '') {
|
||
$('dlg_expressions').focus();
|
||
alert("请输入配送公式");
|
||
return;
|
||
}
|
||
}
|
||
var re = new RegExp("/^[^\]\[\}\{\)\(0-9WwPp\+\-\/\*]+$/");
|
||
if (re.test(bds)) {
|
||
alert("公式中含有非法字符");
|
||
$('dlg_expressions').focus();
|
||
return;
|
||
}
|
||
var weight = $('weight').value;
|
||
var num = $('num').value;
|
||
var hang = $('hang').value;
|
||
var str;
|
||
str = bds.replace(/(\[)/g, "getceil(");
|
||
str = str.replace(/(\])/g, ")");
|
||
str = str.replace(/(\{)/g, "getval(");
|
||
str = str.replace(/(\})/g, ")");
|
||
str = str.replace(/(W)/g, weight);
|
||
str = str.replace(/(w)/g, weight);
|
||
str = str.replace(/(N)/g, num);
|
||
str = str.replace(/(n)/g, num);
|
||
str = str.replace(/(H)/g, hang);
|
||
str = str.replace(/(h)/g, hang);
|
||
try {
|
||
eval(str);
|
||
}
|
||
catch(e) {
|
||
alert("公式格式不正确");
|
||
return;
|
||
}
|
||
$('result').set('html', '<b><{t}>计算结果:' + Math.floor(eval(str) * 100 + 0.01) / 100 + '<{/t}></b>');
|
||
if (!qd) return;
|
||
qd = $(qd);
|
||
var dialog = qd.getParent(".dialog");
|
||
$E('[name=deal_cost]').set("value", $("dlg_expressions").getValue());
|
||
dialog.retrieve("instance").close();
|
||
}
|
||
})()
|
||
</script>
|