纸张单位换算工具,自己练手的,有错误请指正,谢谢,也欢迎与我联系,QQ:11605490;打包下载 在线使用
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>纸张单位换算工具</title> <style type="text/css"> <!-- .NoNull {color: #FF0000} .qty { border-top-width: thin; border-right-width: thin; border-bottom-width: thin; border-left-width: thin; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; } .curqty { border-top-width: thin; border-right-width: thin; border-bottom-width: thin; border-left-width: thin; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-bottom-color: #FF0000; } .fixed { background-color: #999999; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-top-width: thin; border-right-width: thin; border-bottom-width: thin; border-left-width: thin; } .curmqty { border-top-width: thin; border-right-width: thin; border-bottom-width: thin; border-left-width: thin; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-bottom-color: #FF0000; } .mqty { border-top-width: thin; border-right-width: thin; border-bottom-width: thin; border-left-width: thin; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; } #error { padding-left:15px; color:Red; } --> </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> </head> <!-- 制作:fm 日期:2012-12-01 QQ:11605490 --> <body> <p> <strong>纸张单位换算工具</strong></p> <span id="error"></span> <table border="0" cellspacing="5"> <tr> <td><span class="NoNull">克重:</span></td> <td><label> <input name="textfield" type="text" class="fixed" value="157" size="10" />(g/㎡) </label></td> <td class="NoNull">宽度:</td> <td><input name="textfield2" type="text" class="fixed" value="889" size="10" />(mm)</td> <td class="NoNull">长度:</td> <td><input name="textfield3" type="text" class="fixed" value="1194" size="10" />(mm)</td> <td> </td> <td> </td> </tr> <tr> <td>吨数:</td> <td><input name="textfield4" id="txtTonQty" type="text" class="qty" size="10" /></td> <td>令数:</td> <td><input name="textfield5" type="text" class="qty" size="10" /></td> <td>张数:</td> <td><input name="textfield6" type="text" class="qty" size="10" /></td> <td>平方数:</td> <td><input name="textfield62" type="text" class="qty" size="10" /></td> </tr> <tr> <td>吨价:</td> <td><input name="textfield4" type="text" class="mqty" size="10" /></td> <td>令价:</td> <td><input name="textfield5" type="text" class="mqty" size="10" /></td> <td>张价:</td> <td><input name="textfield6" type="text" class="mqty" size="10" /></td> <td>平方价:</td> <td><input name="textfield62" type="text" class="mqty" size="10" /></td> </tr> </table> <script type="text/javascript" language="javascript"> // $(document).ready(function () { function doRound(t, n) { return Math.round(t * Math.pow(10, n)) / Math.pow(10, n); } $("#error").hide(); $(".qty,.mqty,.fixed").each(function () { $(this).keydown(function (event) { var keyCode = event.which; if (keyCode == 46 || keyCode == 8 || keyCode == 190 || (keyCode >= 48 && keyCode <= 57) || (keyCode >= 96 && keyCode <= 105) || keyCode == 110 || keyCode == 37 || keyCode == 39 || keyCode == 13 || keyCode == 9) { $("#error").hide(); return true; } else { $("#error").html("请输入数字!").show(); return false } }).focus(function () { this.style.imeMode = 'disabled'; }); }); var g,w,l;//克重,宽,长 //判断克重、纸张尺寸是否为空,isMes-true,显示提示,false,不提示 function ISFill(isMes) { var res = true; $(".fixed").each(function (index) { if ($(this).val() == "" && res) { $(this).focus().select(); var parentObj = this.parentNode; var tmpStr = $(parentObj.parentNode).children().eq($(parentObj).index() - 1).html(); $("#error").html("[" + tmpStr.replace(":", "") + "]不能为空!").show(); res = false; } else { if (index == 0) g = $(this).val(); if (index == 1) w = $(this).val(); if (index == 2) l = $(this).val(); } }); if (res || !isMes) $("#error").hide(); return res; } $(".qty").each(function (index) { $(this).focus(function () { $(this).removeClass("qty"); $(".curqty").each(function () { $(this).removeClass("curqty"); $(this).addClass("qty"); }); $(this).addClass("curqty"); }); $(this).change(function () { doCalQty(this); }); }); //计算数量 function doCalQty(obj) { if (ISFill(true))//判断克重、纸张尺寸是否为空 { var tmpQ = $(obj).val(); if (tmpQ == "" || tmpQ == 0) return; var tmpObjs = $(obj.parentNode.parentNode).children(); var tonObj = tmpObjs[1].children(0); var lingObj = tmpObjs[3].children(0); var zhangObj = tmpObjs[5].children(0); var pinObj = tmpObjs[7].children(0); var index = ($(obj.parentNode).index() - 1) / 2; var tQty = tonObj.value, lQty = lingObj.value, zQty = zhangObj.value, pQty = pinObj.value; switch (index) { case 0: // tQty = "ass"; lQty = doRound(tmpQ / (g * l * w) * 1000000 * 1000000 / 500,3); zQty = tmpQ / (g * l * w) * 1000000 * 1000000; pQty = doRound(tmpQ / g * 1000000,6); break; case 1: tQty = tmpQ * (g * l * w) / 1000000 / 1000000 * 500; // lQty = tmpQ / (g * l * w) * 1000000 * 1000000 / 500; zQty = tmpQ * 500; pQty = tmpQ * 500 * l * w / 1000000; break; case 2: tQty = tmpQ * (g * l * w) / 1000000 / 1000000; lQty = tmpQ / 500; // zQty = tmpQ * 500; pQty = tmpQ * l * w / 1000000; break; case 3: tQty = tmpQ * g / 1000000; lQty = tmpQ / (l * w) * 1000000 / 500; zQty = tmpQ / (l * w) * 1000000; // pQty = tmpQ * 500 * l * w / 1000000; break; } tonObj.value = doRound(tQty, 6); lingObj.value = doRound(lQty, 3); zhangObj.value = Math.round(zQty); pinObj.value = doRound(pQty, 6); } else { } } $(".mqty").each(function (index) { $(this).focus(function () { $(this).removeClass("mqty"); $(".curmqty").each(function () { $(this).removeClass("curmqty"); $(this).addClass("mqty"); }); $(this).addClass("curmqty"); }); $(this).change(function () { doCalMqty(this); }); }); //计算单价 function doCalMqty(obj) { if (ISFill(true))//判断克重、纸张尺寸是否为空 { var tmpQ = $(obj).val(); if (tmpQ == "" || tmpQ == 0) return; var tmpObjs = $(obj.parentNode.parentNode).children(); var tonObj = tmpObjs[1].children(0); var lingObj = tmpObjs[3].children(0); var zhangObj = tmpObjs[5].children(0); var pinObj = tmpObjs[7].children(0); var index = ($(obj.parentNode).index() - 1) / 2; var tQty = tonObj.value, lQty = lingObj.value, zQty = zhangObj.value, pQty = pinObj.value; switch (index) { case 0: // tQty = "ass"; lQty = tmpQ *(g * l * w) / 1000000 / 1000000 * 500; zQty = tmpQ * (g * l * w) / 1000000 / 1000000; pQty = tmpQ * g / 1000000; break; case 1: tQty = tmpQ / (g * l * w) * 1000000 * 1000000/500; // lQty = tmpQ / (g * l * w) * 1000000 * 1000000 / 500; zQty = tmpQ /500; pQty = tmpQ / 500 * l * w / 1000000; break; case 2: tQty = tmpQ / (g * l * w) * 1000000 * 1000000; lQty = tmpQ * 500; // zQty = tmpQ * 500; pQty = tmpQ / (l * w) * 1000000; break; case 3: tQty = tmpQ / g * 1000000; lQty = tmpQ * (l * w) / 1000000 * 500; zQty = tmpQ * (l * w) / 1000000; // pQty = tmpQ * 500 * l * w / 1000000; break; } tonObj.value = doRound(tQty, 2); lingObj.value = doRound(lQty, 6); zhangObj.value = doRound(zQty, 10); pinObj.value = doRound(pQty,10); } else { } } $(".fixed").each(function (index) { $(this).change(function () { if (ISFill(false)) { var curQty = $(".qty")[0]; var curQtys = $(".curqty"); if (curQtys.length > 0) { curQty = curQtys[0]; } doCalQty(curQty); var curMqty = $(".mqty")[0]; var curMqtys = $(".curmqty"); if (curMqtys.length > 0) { curMqty = curMqtys[0]; } doCalMqty(curMqty); } }); }); // }); </script> <p> 使用说明:</p> <p style="margin-left: 40px"> 1、克重、长度、宽度须全部录入方可换算。</p> <p style="margin-left: 40px"> 2、输入吨数、令数、张数、平方数等任意一个数据后回车,其余三个就会自动计算出来。</p> <p style="margin-left: 40px"> 3、输入吨价、令价、张价、平方价等任意一个数据后回车,其余三个就会自动计算出来。</p> <p style="margin-left: 40px">网上在线地址:<a href="http://www.PrintERP.com/Others/ConversionTool" target="_blank">http://www.PrintERP.com/Others/ConversionTool</a></p> </body> </html>