//4,房产管理
//5,机械设备管理
//6,固定资产/周转材料
// 8,行政办公设备/车辆管理
// 801, 行政办公设备
//802,行政车辆
//803, 电脑 / 打印机 / 会议系统
//9,设备维修/改装管理
//901,设备委外维修
//902,设备改造
//10桩机配件采购管理
// 13????
//获取href里面的参数
getQueryVariable = function (parameter) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] === parameter) { return pair[1]; }
}
return "";
}
//计算总金额
var countmoney = function () {
var count = $("#girdtable input[name='erp_procurementorder_dtl.count']").eq(dtlIndex).val();
if (count == null || count == undefined) {
count = 0;
};
var price = $("#girdtable input[name='erp_procurementorder_dtl.price']").eq(dtlIndex).val();
if (price == null || price == undefined) {
price = 0;
};
var amount = accMul(count, price).toFixed(2);
$("#girdtable input[name='erp_procurementorder_dtl.amount']").eq(dtlIndex).val(amount.toFixed(2));
var taxrate = accDiv(Number($('#girdtable .body').eq(dtlIndex).find('select[name="erp_procurementorder_dtl.taxrate"]').val()), 100);;
var no_taxrate_amount = accSub(amount, (accMul(accDiv(amount, accAdd(1, taxrate)), taxrate)));
$('#girdtable .body').eq(dtlIndex).find('input[name="erp_procurementorder_dtl.amount"]').val(amount.toFixed(2));
$('#girdtable .body').eq(dtlIndex).find('input[name="erp_procurementorder_dtl.no_taxrate_amount"]').val(no_taxrate_amount.toFixed(2));
getall();
}
var getall = function () {
var allmoney = 0;
$.each($('#girdtable .body'), function (i, r) {
$("#girdtable input[name='erp_procurementorder_dtl.amount']").eq(i).val();
var money = $("#girdtable input[name='erp_procurementorder_dtl.amount']").eq(i).val();
if (money == null || money == undefined) {
money = 0;
}
allmoney = accAdd(allmoney, money);
});
$("#erp_procurementorder_money").val(allmoney);
$("#erp_procurementorder_moneyfont").val(Arabia_to_Chinese(allmoney));
seltax();
}
var seltax = function () {
var money = $("#erp_procurementorder_money").val();
var taxrate = accDiv($('#erp_procurementorder_taxrate').val(), 100).toFixed(2);
var tax = accMul(money, taxrate).toFixed(2);
$("#erp_procurementorder_taxmoney").val(tax);
}
var yfchange = function () {
var yfmoney = $("#erp_procurementorder_freight").val();
var yftaxrate = accDiv($('#erp_procurementorder_freighttaxrate').val(), 100).toFixed(2);
var yftax = accMul(yfmoney, yftaxrate).toFixed(2);
$("#erp_procurementorder_freighttaxmoney").val(yftax.toFixed(2));
}
$(document).ready(function () {
$("[class='form-control datetime']").each(function () {
var dataValue = $(this).val();
if (dataValue != '') {
var date = new Date(parseInt(dataValue.replace("/Date(", "").replace(")/", ""), 10));
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
var dataStr = date.getFullYear() + "-" + month + "-" + currentDate;
$(this).val(dataStr);
}
});
var type = getQueryVariable('type');
if (type == "12") {
$("input[name='erp_procurementorder_dtl.materielinfo_code']").removeAttr("disabled");
$("#erp_procurementorder_supplier_id").removeAttr("disabled");
$("#erp_procurementorder_supplier_id").trigger("chosen:updated");
$("#erp_procurementorder_project_id").removeAttr("disabled");
$("#erp_procurementorder_project_id").trigger("chosen:updated");
$("#erp_procurementorder_contractNum").parent().parent().hide();
$("#erp_procurementorder_purchaseApplication_code").parent().parent().hide();
}
});
//删除事件回调操作
deleteMethod = function (self) {
countmoney();
CheckAllMaterielinfoCode();
}
//添加事件回调操作
createMethod = function () {
BindEvent();
ISShowtaxrate();
$("#girdtable .body").each(function (i, v) {
if ($(v).attr("autoLoade") != "true") {
$(v).find("input[name='erp_procurementorder_dtl.materielinfo_name'],input[name='erp_procurementorder_dtl.materielinfo_code']").removeAttr("disabled");
debugger;
$(v).find("[name='erp_procurementorder_dtl.taxrate']").val($("[name='erp_procurementorder_dtl.taxrate']").eq(0).val());
}
});
}
var dtlIndex = 0;
var materielTypes = '';
///数据加载
initData = function () {
NumberBind();
ISShowtaxrate();
if (window.taskid == '') {
debugger;
LoadData();
LoadPage();
BindEvent();
//CheckAllMaterielinfoCode();
}
ChangeFormTitle();
}
$(document).ready(function () {
var type = getQueryVariable('type');
if (type != "12") {
$('.subtradd_js').hide();
}
if (window.taskid != '') {
var dataValue = $("#erp_procurementorder_createtime").val();
if (dataValue != '') {
}
} else {
var date = new Date();
var curDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
$("#erp_procurementorder_createtime").val(curDate);
}
//});
});
var ProcurementOrder = {};
function LoadData() {
var relationCode = getQueryVariable('relationCode');
var typeSource = getQueryVariable('typeSource');
var type = getQueryVariable('type');
$.ajax({
url: "/ERP/Erp_procurementorder/GetPageData?flowid=" + flowid + "&taskid=" + taskid + "&relationCode=" + relationCode + "&type=" + type + "&typeSource=" + typeSource
, async: false
, cache: false
, dataType: "json",
success: function (data) {
ProcurementOrder = data;
}
});
$.ajax({
url: "/ERP/Erp_procurementorder/GetMaterielTypesByType?flowType=" + type
, async: false
, cache: false
, dataType: "json",
success: function (data) {
materielTypes = data;
}
});
}
function LoadPage() {
$("#erp_procurementorder_orderCode").val(ProcurementOrder.orderCode);
$("#erp_procurementorder_name").val(ProcurementOrder.name);
$("#erp_procurementorder_contractNum").val(ProcurementOrder.contractNum);
$("#erp_procurementorder_purchaseApplication_code").val(ProcurementOrder.purchaseApplication_code);
$("#erp_procurementorder_supplier_id").val(ProcurementOrder.supplier_id);
$("#erp_procurementorder_supplier_id").trigger("chosen:updated");
$("#erp_procurementorder_project_id").val(ProcurementOrder.project_id);
$("#erp_procurementorder_project_id").trigger("chosen:updated");
var date = new Date(parseInt(ProcurementOrder.createtime.replace("/Date(", "").replace(")/", ""), 10));
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
var dataStr = date.getFullYear() + "-" + month + "-" + currentDate;
$("#erp_procurementorder_createtime").val(dataStr);
changepurchase();
// 把type存一下
var sprintbtn = '';
$('#erp_procurementorder_orderCode').after(sprintbtn);// 先弄个隐藏框把数据存起来
$('#erp_procurementorder_type').val(ProcurementOrder.type);
// 处理隐藏框
var type = getQueryVariable('type');
if (type == "2") {// 辅材隐藏合同单号
$("#erp_procurementorder_contractNum").parent().parent().hide();
$("#erp_procurementorder_supplier_id").removeAttr("disabled");
$("#erp_procurementorder_supplier_id").trigger("chosen:updated");
} else if (type == "4") {// 房产隐藏供应商,运费相关
//$("#erp_procurementorder_supplier_id").parent().parent().hide();
$("#erp_procurementorder_freight").parent().parent().hide();
$("#erp_procurementorder_freighttaxrate").parent().parent().hide();
$("#erp_procurementorder_freighttaxmoney").parent().parent().hide();
} else if (type == "8" && type == "801" && type == "802" && type == "803") {// 行政办公车辆
$("#erp_procurementorder_supplier_id").trigger("chosen:updated");
}
var typeSource = getQueryVariable('typeSource');
if (typeSource == "purchaseApplication") {
$("#erp_procurementorder_supplier_id").removeAttr("disabled");
$("#erp_procurementorder_supplier_id").trigger("chosen:updated");
}
if (type == "12") {
SetAcceptWarehouse('');
} else {
SetAcceptWarehouse(ProcurementOrder.project_id);
}
}
function BindEvent() {
NumberBind();
// 物料页面
$("input[name='erp_procurementorder_dtl.materielinfo_name'],input[name='erp_procurementorder_dtl.materielinfo_code']").unbind();
$("input[name='erp_procurementorder_dtl.materielinfo_name'],input[name='erp_procurementorder_dtl.materielinfo_code']").bind('focus', function () {
//dtlIndex = $(this).attr("data-id");
dtlIndex = $(this).closest('tr').index() - 1;
layer.open({
type: 2,
title: '资源库',
shadeClose: true,
shade: 0.4,
area: ['90%', '90%'],
content: "/Article/index?type=" + materielTypes
});
});
// 采购申请
$("#erp_procurementorder_purchaseApplication_code").change(function () {
changepurchase();
});
// 供应商选择
$("#erp_procurementorder_supplier_id").parent().click(function () {
if ($("#erp_procurementorder_supplier_id").attr("disabled") == "disabled") {
return false;
}
getcompanyinfo();
return false;
});
//运费税
$('[name="erp_procurementorder.freight"],[name="erp_procurementorder.freighttaxrate"]').change(function () {
yfchange();
});
//税
$('[name="erp_procurementorder.taxrate"]').change(function () {
seltax();
});
//选择计算金额
$('input[name="erp_procurementorder_dtl.price"],input[name="erp_procurementorder_dtl.count"],select[name="erp_procurementorder_dtl.taxrate"]').change(function () {
dtlIndex = $(this).closest('tr').index() - 1;
countmoney();
});
}
var isshow = 0;
function ISShowtaxrate() {
debugger;
var typeSource = getQueryVariable('typeSource');
var type = getQueryVariable('type');
if (typeSource == "purchaseApplication") {
if (type == "4" || type == "5" || type == "6" || type == "8" || type == "801" || type == "802" || type == "803" || type == "9" || type == "901" || type == "902" || type == "10") {
isshow = 1;
}
}
if (typeSource == "contractpretrial") {
if (type == "1" || type == "10") {
isshow = 1;
}
}
var tdIndex2 = $('#girdtable .body').eq(0).find('[name="erp_procurementorder_dtl.taxrate"]').parent('td').index();
var tdIndex3 = $('#girdtable .body').eq(0).find('[name="erp_procurementorder_dtl.no_taxrate_amount"]').parent('td').index();
$('#girdtable tr').each(function () {
if (tdIndex2 > -1) {
if (isshow == 1) {
$(this).children("td").eq(tdIndex2).show();
} else {
$(this).children("td").eq(tdIndex2).hide();
}
}
if (tdIndex3 > -1) {
if (isshow == 1) {
$(this).children("td").eq(tdIndex3).show();
} else {
$(this).children("td").eq(tdIndex3).hide();
}
}
});
}
function changepurchase() {
var typeSource = getQueryVariable('typeSource');
if (typeSource == "purchaseApplication") {
var purchaseid = $("#erp_procurementorder_purchaseApplication_code").val();
$.ajax({
url: '/Erp_procurementorder/GetPurchaseapplication_dtl?purchaseid=' + purchaseid,
type: 'Get',
datatype: 'json',
success: function (resp) {
debugger;
if (resp.length > 0) {
$('#girdtable .body').remove();
for (var j = 0; j < resp.length; j++) {
//var html = '
| | | | | | | | | |
';
var html = ' | | | | | | | |
';
var setHtml = ' | | ';
$('#girdtable tbody').append(html);
debugger;
if (isshow == 1) {
$("#girdtable [name='erp_procurementorder_dtl.amount']").eq(j).parent('td').after(setHtml);
}
$("[name='erp_procurementorder_dtl.taxrate']").trigger("chosen:updated");
$("#girdtable [name='erp_procurementorder_dtl.materielinfo_name']").eq(j).val(resp[j].itemsname);
$("#girdtable [name='erp_procurementorder_dtl.materielinfo_code']").eq(j).val(resp[j].materielinfo_code);
$("#girdtable [name='erp_procurementorder_dtl.price']").eq(j).val(resp[j].Price);
$("#girdtable [name='erp_procurementorder_dtl.measurementUnit']").eq(j).val(resp[j].itemmeasuringunit);
$("#girdtable [name='erp_procurementorder_dtl.Specification']").eq(j).val(resp[j].Specification);
$("#girdtable .body").eq(j).attr("autoLoade", 'true');
BindEvent();
}
CheckAllMaterielinfoCode();
};
},
error: function () {
},
});
} else if (typeSource == "contractpretrial") {
var contractpretrialCode = $("#erp_procurementorder_contractNum").val();
$.ajax({
url: '/Erp_procurementorder/GetContractpretrialDtlByContractpretrialCode?contractpretrialCode=' + contractpretrialCode,
type: 'Get',
datatype: 'json',
success: function (resp) {
if (resp.length > 0) {
$('#girdtable .body').remove();
for (var j = 0; j < resp.length; j++) {
var html = ' | | | | | | | |
';
var setHtml = ' | | ';
$('#girdtable tbody').append(html);
debugger;
if (isshow == 1) {
$("#girdtable [name='erp_procurementorder_dtl.amount']").eq(j).parent('td').after(setHtml);
}
//$('#girdtable tbody').append(html);
$("[name='erp_procurementorder_dtl.taxrate']").trigger("chosen:updated");
$("#girdtable [name='erp_procurementorder_dtl.materielinfo_name']").eq(j).val(resp[j].MaterialName);
$("#girdtable [name='erp_procurementorder_dtl.materielinfo_code']").eq(j).val(resp[j].MaterialCode);
$("#girdtable [name='erp_procurementorder_dtl.price']").eq(j).val(resp[j].UnitPrice);
$("#girdtable [name='erp_procurementorder_dtl.measurementUnit']").eq(j).val(resp[j].Unit);
$("#girdtable [name='erp_procurementorder_dtl.Specification']").eq(j).val(resp[j].Model);
$("#girdtable [name='erp_procurementorder_dtl.taxrate']").eq(j).val(resp[j].TaxRate);
$("#girdtable [name='erp_procurementorder_dtl.taxrate']").eq(j).attr("disabled", "disabled");
$("#girdtable .body").eq(j).attr("autoLoade", 'true');
BindEvent();
}
CheckAllMaterielinfoCode();
};
},
error: function () {
},
});
}
}
//供应商选择
var getcompanyinfo = function () {
layer.open({
type: 2,
title: '供应商',
shadeClose: true,
shade: 0.4,
area: ['90%', '90%'],
content: "/oa/General/company"
});
}
var setBaseInfo = function (materialNumber, materialName, resourceClassificationId, resourceClassificationName, specificationModel, measurementUnit, index, measurementUnitName, resourceClassificationSupName) {
$("[name='erp_procurementorder_dtl.materielinfo_name']").eq(dtlIndex).val(materialName);
$("[name='erp_procurementorder_dtl.materielinfo_code']").eq(dtlIndex).val(materialNumber);
$("[name='erp_procurementorder_dtl.measurementUnit']").eq(dtlIndex).val(measurementUnitName);
$("[name='erp_procurementorder_dtl.Specification']").eq(dtlIndex).val(specificationModel);
layer.closeAll();
}
var setCompanyInfo = function (id, name, UserName, Phone, BankName, BankDeposit, BankAccount) {
$("#erp_procurementorder_supplier_id").val(id);
$("#erp_procurementorder_supplier_id").trigger("chosen:updated");
layer.closeAll();
}
// 改变页面表单标题
function ChangeFormTitle() {
var titleStr = $("#erp_procurementorder_name").val().replace(/\(\S*\)/, "");
$("#txtTitle").text(titleStr);
$('#girdtable').prev("h3").text(titleStr + "明细");
}
function CheckAllMaterielinfoCode() {
var isAllHNT = true;
$("input[name='erp_procurementorder_dtl.materielinfo_code']").each(function (i, v) {
if (IsHNT($(v).val()) == false) {
isAllHNT = false;
return false;
}
});
if (isAllHNT) {
$('.subtradd_js').show();
materielTypes = '010002';
}
var isAllGJ = true;
$("input[name='erp_procurementorder_dtl.materielinfo_code']").each(function (i, v) {
if (IsGJ($(v).val()) == false) {
isAllGJ = false;
return false;
}
});
if (isAllGJ) {
$('.subtradd_js').show();
materielTypes = '010005';
}
}
function IsGJ(materielinfoCode) {
var result = false;
$.ajax({
url: "/ERP/Erp_procurementorder/IsGJ?materielinfo_code=" + materielinfoCode
, async: false
, cache: false
, dataType: "json",
success: function (data) {
if (data.Result) {
result = data.Remark == "True";
} else {
layer.alert("判断物料类型是否是钢筋失败");
}
}
});
return result;
}
function IsHNT(materielinfoCode) {
var result = false;
$.ajax({
url: "/ERP/Erp_procurementorder/IsHNT?materielinfo_code=" + materielinfoCode
, async: false
, cache: false
, dataType: "json",
success: function (data) {
if (data.Result) {
result = data.Remark == "True";
} else {
layer.alert("判断物料类型是否是混凝土失败");
}
}
});
return result;
}
function SetAcceptWarehouse(projectId) {
$("#erp_procurementorder_accept_warehouse_id").empty();
$("#erp_procurementorder_accept_warehouse_id").trigger("chosen:updated");
$.ajax({
url: '/DropDown/WareHouseDropDown?projectId=' + projectId,
type: 'Get',
datatype: 'json',
success: function (dataList) {
if (dataList != null && dataList.length > 0) {
$("#erp_procurementorder_accept_warehouse_id").append('');
for (var i = 0; i < dataList.length; i++) {
var dataItem = dataList[i];
$("#erp_procurementorder_accept_warehouse_id").append("");
$("#erp_procurementorder_accept_warehouse_id").trigger("chosen:updated");
}
} else {
layer.msg("该项目下没有仓库同信息", { icon: 5 });
}
}
});
}
/**
* 乘法
* @param arg1
* @param arg2
* @returns {Number}
*/
function accMul(arg1, arg2) {
var num1 = Number(arg1.toString());
var num2 = Number(arg2.toString());
return Number((num1 * num2).toFixed(2));
//var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
//try { m += s1.split(".")[1].length } catch (e) { }
//try { m += s2.split(".")[1].length } catch (e) { }
//return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
}
/**
* 除法
* @param arg1
* @param arg2
* @returns {Number}
*/
function accDiv(arg1, arg2) {
var t1 = 0, t2 = 0, r1, r2;
try { t1 = arg1.toString().split(".")[1].length } catch (e) { }
try { t2 = arg2.toString().split(".")[1].length } catch (e) { }
with (Math) {
r1 = Number(arg1.toString().replace(".", ""))
r2 = Number(arg2.toString().replace(".", ""))
return (r1 / r2) * pow(10, t2 - t1);
}
}
/**
* 加法
* @param arg1
* @param arg2
* @returns {Number}
*/
function accAdd(arg1, arg2) {
var r1, r2, m, c;
try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
c = Math.abs(r1 - r2);
m = Math.pow(10, Math.max(r1, r2))
if (c > 0) {
var cm = Math.pow(10, c);
if (r1 > r2) {
arg1 = Number(arg1.toString().replace(".", ""));
arg2 = Number(arg2.toString().replace(".", "")) * cm;
}
else {
arg1 = Number(arg1.toString().replace(".", "")) * cm;
arg2 = Number(arg2.toString().replace(".", ""));
}
}
else {
arg1 = Number(arg1.toString().replace(".", ""));
arg2 = Number(arg2.toString().replace(".", ""));
}
return (arg1 + arg2) / m
}
/**
* 减法
* @param arg1
* @param arg2
* @returns
*/
function accSub(arg1, arg2) {
var r1, r2, m, n;
try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
m = Math.pow(10, Math.max(r1, r2));
//last modify by deeka
//动态控制精度长度
n = (r1 >= r2) ? r1 : r2;
return ((arg1 * m - arg2 * m) / m).toFixed(n);
}
/**
* 数字转换为大写
* @param NumStr
* @returns
*/
function Arabia_to_Chinese(NumStr) {
var Num = NumStr + "";
for (i = Num.length - 1; i >= 0; i--) {
Num = Num.replace(",", "")//替换tomoney()中的“,”
Num = Num.replace(" ", "")//替换tomoney()中的空格
}
Num = Num.replace("¥", "")//替换掉可能出现的¥字符
if (isNaN(Num)) { //验证输入的字符是否为数字
alert("请检查小写金额是否正确");
return;
}
//字符处理完毕后开始转换,采用前后两部分分别转换
part = String(Num).split(".");
newchar = "";
//小数点前进行转化
for (i = part[0].length - 1; i >= 0; i--) {
if (part[0].length > 10) {
alert("位数过大,无法计算");
return "";
}//若数量超过拾亿单位,提示
tmpnewchar = ""
perchar = part[0].charAt(i);
switch (perchar) {
case "0": tmpnewchar = "零" + tmpnewchar; break;
case "1": tmpnewchar = "壹" + tmpnewchar; break;
case "2": tmpnewchar = "贰" + tmpnewchar; break;
case "3": tmpnewchar = "叁" + tmpnewchar; break;
case "4": tmpnewchar = "肆" + tmpnewchar; break;
case "5": tmpnewchar = "伍" + tmpnewchar; break;
case "6": tmpnewchar = "陆" + tmpnewchar; break;
case "7": tmpnewchar = "柒" + tmpnewchar; break;
case "8": tmpnewchar = "捌" + tmpnewchar; break;
case "9": tmpnewchar = "玖" + tmpnewchar; break;
}
switch (part[0].length - i - 1) {
case 0: tmpnewchar = tmpnewchar + "元"; break;
case 1: if (perchar != 0) tmpnewchar = tmpnewchar + "拾"; break;
case 2: if (perchar != 0) tmpnewchar = tmpnewchar + "佰"; break;
case 3: if (perchar != 0) tmpnewchar = tmpnewchar + "仟"; break;
case 4: tmpnewchar = tmpnewchar + "万"; break;
case 5: if (perchar != 0) tmpnewchar = tmpnewchar + "拾"; break;
case 6: if (perchar != 0) tmpnewchar = tmpnewchar + "佰"; break;
case 7: if (perchar != 0) tmpnewchar = tmpnewchar + "仟"; break;
case 8: tmpnewchar = tmpnewchar + "亿"; break;
case 9: tmpnewchar = tmpnewchar + "拾"; break;
}
newchar = tmpnewchar + newchar;
}
//小数点之后进行转化
if (Num.indexOf(".") != -1) {
if (part[1].length > 2) {
alert("小数点之后只能保留两位,系统将自动截断");
part[1] = part[1].substr(0, 2)
}
for (i = 0; i < part[1].length; i++) {
tmpnewchar = ""
perchar = part[1].charAt(i)
switch (perchar) {
case "0": tmpnewchar = "零" + tmpnewchar; break;
case "1": tmpnewchar = "壹" + tmpnewchar; break;
case "2": tmpnewchar = "贰" + tmpnewchar; break;
case "3": tmpnewchar = "叁" + tmpnewchar; break;
case "4": tmpnewchar = "肆" + tmpnewchar; break;
case "5": tmpnewchar = "伍" + tmpnewchar; break;
case "6": tmpnewchar = "陆" + tmpnewchar; break;
case "7": tmpnewchar = "柒" + tmpnewchar; break;
case "8": tmpnewchar = "捌" + tmpnewchar; break;
case "9": tmpnewchar = "玖" + tmpnewchar; break;
}
if (i == 0) tmpnewchar = tmpnewchar + "角";
if (i == 1) tmpnewchar = tmpnewchar + "分";
newchar = newchar + tmpnewchar;
}
}
//替换所有无用汉字
while (newchar.search("零零") != -1)
newchar = newchar.replace("零零", "零");
newchar = newchar.replace("零亿", "亿");
newchar = newchar.replace("亿万", "亿");
newchar = newchar.replace("零万", "万");
newchar = newchar.replace("零元", "元");
newchar = newchar.replace("零角", "");
newchar = newchar.replace("零分", "");
if (newchar.charAt(newchar.length - 1) == "元" || newchar.charAt(newchar.length - 1) == "角")
newchar = newchar + "整"
return newchar;
}
/**
* 增加千分符以及保留几位小数(四舍五入)
* @param NumStr
* @returns
*/
function Mmoney(s, n) {
console.log(s);
console.log(n);
return s.toFixed(n);
//var t = '';
//var regPos = /^\d+(\.\d+)?$/; //非负浮点数
//var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
//if (s == 0 || regPos.test(s) || regNeg.test(s)) {
// n = n > 0 && n <= 20 ? n : 2;
// s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(n) + '';
// var l = '';
// if (parseFloat(s.split('.')[0]) >= 0) {
// l = s.split('.')[0].split('').reverse();
// } else {
// l = s.split('.')[0].split('-')[1].split('').reverse();
// }
// r = s.split('.')[1];
// for (var i = 0; i < l.length; i++) {
// t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? ',' : '');
// };
// t = t.split('').reverse().join('') + '.' + r;
// if (parseFloat(s.split('.')[0]) < 0) {
// t = "-" + t;
// };
//}
//return t;
}
NumberBind = function () {
$("[name='erp_procurementorder_dtl.count']").addClass("countTxtBox");
$("[name='erp_procurementorder_dtl.price']").addClass("priceTxtBox");
$("[name='erp_procurementorder_dtl.amount']").addClass("amountTxtBox");
NumberBoxBind();
}