$paytype = 0;
|
//获取href里面的参数
|
function getUrlParam(name) {
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
|
var r = window.location.search.substr(1).match(reg); //匹配目标参数
|
if (r != null) return unescape(r[2]); return null; //返回参数值
|
}
|
|
var listtypeoptions = [];
|
var type = 0;
|
|
|
var setpaytype = function (ntype) {
|
switch (ntype) {
|
case 41: $paytype = 1; $('#txtTitle').html('项目主材付款单'); break;
|
case 42: $paytype = 2; $('#txtTitle').html('项目辅材付款单'); break;
|
case 43: $paytype = 3; $('#txtTitle').html('项目施工费/措施费付款单'); break;
|
case 45: $paytype = 4; $('#txtTitle').html('房产付款单'); break;
|
case 46: $paytype = 5; $('#txtTitle').html('机械设备付款单'); break;
|
case 47: $paytype = 6; $('#txtTitle').html('固定资产/周转材料付款单'); break;
|
case 51: $paytype = 7; $('#txtTitle').html('周转材料付款单'); break;
|
case 48: $paytype = 8; $('#txtTitle').html('行政办公设备/车辆付款单'); break;
|
case 49: $paytype = 9; $('#txtTitle').html('设备维修/改装付款单'); break;
|
case 52: $paytype = 10; $('#txtTitle').html('桩机配件采购付款单'); break;
|
case 50: $paytype = 11; $('#txtTitle').html('设备部劳务班组费用付款单'); break;
|
case 54: $paytype = 13; $('#txtTitle').html('运输费用付款单'); break;
|
case 4801: $paytype = 801; $('#txtTitle').html('行政办公设备付款单'); break;
|
case 4802: $paytype = 802; $('#txtTitle').html('行政车辆付款单'); break;
|
case 4803: $paytype = 803; $('#txtTitle').html('电脑/打印机/会议系统付款单'); break;
|
case 4901: $paytype = 901; $('#txtTitle').html('设备委外维修付款单'); break;
|
case 4902: $paytype = 902; $('#txtTitle').html('设备改造付款单'); break;
|
}
|
}
|
|
// 金额转大写
|
var changeMoneyToChinese = function (money) {
|
//汉字的数字
|
var cnNums = new Array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖');
|
//基本单位
|
var cnIntRadice = new Array('', '拾', '佰', '仟');
|
//对应整数部分扩展单位
|
var cnIntUnits = new Array('', '万', '亿', '兆');
|
//对应小数部分单位
|
var cnDecUnits = new Array('角', '分', '毫', '厘');
|
//整数金额时后面跟的字符
|
var cnInteger = '整';
|
//整型完以后的单位
|
var cnIntLast = '元';
|
//最大处理的数字
|
var maxNum = 999999999999999.9999;
|
//金额整数部分
|
var integerNum;
|
//金额小数部分
|
var decimalNum;
|
//输出的中文金额字符串
|
var chineseStr = '';
|
//分离金额后用的数组,预定义
|
var parts;
|
if (money == '') { return ''; }
|
money = parseFloat(money);
|
if (money >= maxNum) {
|
//超出最大处理数字
|
toastr.warning("付款总额超出最大范围");
|
return '';
|
}
|
if (money == 0) {
|
chineseStr = cnNums[0] + cnIntLast + cnInteger;
|
return chineseStr;
|
}
|
//转换为字符串
|
money = money.toString();
|
if (money.indexOf('.') == -1) {
|
integerNum = money;
|
decimalNum = '';
|
} else {
|
parts = money.split('.');
|
integerNum = parts[0];
|
decimalNum = parts[1].substr(0, 4);
|
}
|
//获取整型部分转换
|
if (parseInt(integerNum, 10) > 0) {
|
var zeroCount = 0;
|
var IntLen = integerNum.length;
|
for (var i = 0; i < IntLen; i++) {
|
var n = integerNum.substr(i, 1);
|
var p = IntLen - i - 1;
|
var q = p / 4;
|
var m = p % 4;
|
if (n == '0') {
|
zeroCount++;
|
} else {
|
if (zeroCount > 0) {
|
chineseStr += cnNums[0];
|
}
|
//归零
|
zeroCount = 0;
|
chineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
|
}
|
if (m == 0 && zeroCount < 4) {
|
chineseStr += cnIntUnits[q];
|
}
|
}
|
chineseStr += cnIntLast;
|
}
|
//小数部分
|
if (decimalNum != '') {
|
var decLen = decimalNum.length;
|
for (var i = 0; i < decLen; i++) {
|
var n = decimalNum.substr(i, 1);
|
if (n != '0') {
|
chineseStr += cnNums[Number(n)] + cnDecUnits[i];
|
}
|
}
|
}
|
if (chineseStr == '') {
|
chineseStr += cnNums[0] + cnIntLast + cnInteger;
|
} else if (decimalNum == '') {
|
chineseStr += cnInteger;
|
}
|
return chineseStr;
|
}
|
|
|
//获取默认单据号与名称
|
var getusername = function (type) {
|
if ($.trim(sysid) == '') {
|
$.ajax({
|
url: "/oa/General/GetLoad", async: false, cache: false, dataType: "json",
|
success: function (data) {
|
$('input[name="fm_otherexpenditureinfo.Code"]').val(data.orderCode);
|
$('select[name="fm_otherexpenditureinfo.DepartmentID"]').val(data.deptid);
|
$('select[name="fm_otherexpenditureinfo.DepartmentID"]').trigger("chosen:updated");
|
switch (type) {
|
|
case 41:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('项目主材付款(' + data.username + ')');
|
break;
|
case 42:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('项目辅材付款(' + data.username + ')');
|
break;
|
case 43:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('项目施工费/措施费付款(' + data.username + ')');
|
break;
|
case 44:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('办公消耗品付款(' + data.username + ')');
|
break;
|
case 45:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('房产付款(' + data.username + ')');
|
break;
|
case 46:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('机械设备付款(' + data.username + ')');
|
break;
|
case 47:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('固定资产/周转材料付款(' + data.username + ')');
|
break;
|
case 48:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('行政办公设备/车辆付款(' + data.username + ')');
|
break;
|
case 49:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('设备维修/改装付款(' + data.username + ')');
|
break;
|
case 50:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('设备部劳务班组费用付款(' + data.username + ')');
|
break;
|
case 51:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('周转材料付款(' + data.username + ')');
|
break;
|
case 52:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('桩机配件采购付款(' + data.username + ')');
|
break;
|
case 54:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('运输费付款(' + data.username + ')');
|
break;
|
case 4801:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('行政办公设备付款(' + data.username + ')');
|
break;
|
case 4802:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('行政车辆付款(' + data.username + ')');
|
break;
|
case 4803:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('电脑/打印机/会议系统付款(' + data.username + ')');
|
break;
|
case 4901:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('设备委外维修付款(' + data.username + ')');
|
break;
|
case 4902:
|
$('input[name="fm_otherexpenditureinfo.Title"]').val('设备改造付款(' + data.username + ')');
|
break;
|
|
}
|
}
|
});
|
}
|
}
|
|
|
var orderCode = '';
|
|
|
//选择供应商后绑定数据
|
var setCompanyInfo = function (id, name, UserName, Phone, BankName, BankDeposit, BankAccount) {
|
$('#fm_otherexpenditureinfo_IncomeUnitID').val(id);
|
$('#fm_otherexpenditureinfo_IncomeUnitName').val(name);
|
$('#fm_otherexpenditureinfo_AccountOpenBankAccount').val(BankName);
|
$('#fm_otherexpenditureinfo_CashBankName').val(BankDeposit);
|
$('#fm_otherexpenditureinfo_ReceivablesAccount').val(BankAccount);
|
loadOrders();
|
layer.closeAll();
|
}
|
|
//收入单位选择
|
var getcompanyinfo = function () {
|
layer.open({
|
type: 2,
|
title: '收款单位',
|
shadeClose: true,
|
shade: 0.4,
|
area: ['90%', '90%'],
|
content: "/oa/General/company"
|
});
|
}
|
|
var showorder = function (orderCode)
|
{
|
if($.trim(orderCode)!='')
|
{
|
$.ajax({
|
url: '/oa/General/GetOrderUrl?ordercode=' + orderCode, async: false, cache: false, dataType: "json",
|
success: function (data) {
|
appendTabByUrl(data, "查看单据详情");
|
}
|
});
|
}
|
|
}
|
|
//加载项目和供应商之间的订单信息
|
var loadOrders = function () {
|
var projectid = $.trim($('#fm_otherexpenditureinfo_ProjectID').val());
|
var PartyBId = $.trim($('#fm_otherexpenditureinfo_IncomeUnitID').val());
|
$('.subtradd_js').hide();
|
$('#girdtable').find('.body').remove();
|
if (projectid != '' && PartyBId != '' && projectid != '0' && PartyBId != '0')
|
{
|
$.ajax({
|
url: '/oa/General/GetOrdersByProjectAndGYS?fktype=' + type + '&type=' + $paytype + '&&projectid=' + projectid + '&&PartyBId=' + PartyBId, async: false, cache: false, dataType: "json",
|
success: function (data) {
|
var html = '';
|
if (data.length > 0) {
|
$.each(data, function (i, r) {
|
$('.subtradd_js').click();
|
$('#girdtable').find('.body').eq(i).find('input[name="fm_otherexpenditureinfo_dtl.ExpenditureTypeName"]').val(r.orderCode);
|
$('#girdtable').find('.body').eq(i).find('input[name="fm_otherexpenditureinfo_dtl.ExpenditureTypeName"]').removeAttr('disabled');
|
$('#girdtable').find('.body').eq(i).find('input[name="fm_otherexpenditureinfo_dtl.ExpenditureTypeName"]').attr('readonly', 'readonly');
|
$('#girdtable').find('.body').eq(i).find('input[name="fm_otherexpenditureinfo_dtl.ExpenditureTypeName"]').attr('onclick', 'showorder(\'' + r.orderCode + '\')');
|
$('#girdtable').find('.body').eq(i).find('input[name="fm_otherexpenditureinfo_dtl.ExpenditureTypeName"]').css({ 'background': 'WhiteSmoke', 'cursor': 'pointer' });
|
|
$('#girdtable').find('.body').eq(i).find('input[name="fm_otherexpenditureinfo_dtl.Remarks"]').val(r.remark);
|
$('#girdtable').find('.body').eq(i).find('input[name="fm_otherexpenditureinfo_dtl.ExpenditureNotContainTaxAmount"]').val(r.balance);
|
});
|
}
|
countmoney();
|
}
|
});
|
}
|
|
}
|
|
function JsonDateToDate(jsondate) {
|
var date = new Date(parseInt(jsondate.replace("/Date(", "").replace(")/", ""), 10));
|
return date;
|
}
|
|
Date.prototype.Format = function (formatStr) {
|
var str = formatStr;
|
var Week = ['日', '一', '二', '三', '四', '五', '六'];
|
|
var mt = this.getMonth() + 1;
|
str = str.replace(/yyyy|YYYY/, this.getFullYear());
|
str = str.replace(/yy|YY/, (this.getYear() % 100) > 9 ? (this.getYear() % 100).toString() : '0' + (this.getYear() % 100));
|
str = str.replace(/MM/, mt > 9 ? mt : '0' + mt);
|
str = str.replace(/M/g, mt);
|
str = str.replace(/w|W/g, Week[this.getDay()]);
|
str = str.replace(/dd|DD/, this.getDate() > 9 ? this.getDate().toString() : '0' + this.getDate());
|
str = str.replace(/d|D/g, this.getDate());
|
str = str.replace(/hh|HH/, this.getHours() > 9 ? this.getHours().toString() : '0' + this.getHours());
|
str = str.replace(/h|H/g, this.getHours());
|
str = str.replace(/mm/, this.getMinutes() > 9 ? this.getMinutes().toString() : '0' + this.getMinutes());
|
str = str.replace(/m/g, this.getMinutes());
|
|
str = str.replace(/ss|SS/, this.getSeconds() > 9 ? this.getSeconds().toString() : '0' + this.getSeconds());
|
str = str.replace(/s|S/g, this.getSeconds());
|
return str;
|
}
|
|
//选择计算金额
|
$(document).on('change', $('input[name="fm_otherexpenditureinfo_dtl.ExpenditureNotContainTaxAmount"]'), function (i, r) {
|
countmoney();
|
});
|
|
//计算总金额
|
var countmoney = function () {
|
var count = 0;
|
$.each($('input[name="fm_otherexpenditureinfo_dtl.ExpenditureNotContainTaxAmount"]'), function () {
|
var val = $.trim($(this).val());
|
val = isNaN(val) ? 0 : val;
|
val = val == '' ? 0 : parseFloat(val);
|
count += val;
|
});
|
$('input[name="fm_otherexpenditureinfo.TotalExpenditure"]').val(count);
|
$('input[name="fm_otherexpenditureinfo.CapitalizationTotalExpenditure"]').val(changeMoneyToChinese(count));
|
|
}
|
|
///数据加载
|
var initData = function () {
|
$('.subtradd_js').hide();
|
var url = window.location.href;
|
type = parseInt(getUrlParam('type'));
|
if ($.trim(sysid) != '' && initItems != null) {
|
type = parseInt(initItems.ExpenditureBusinessTypeID);
|
}
|
if (type == 42) {
|
$('#fm_otherexpenditureinfo_SettlementNumber').parent().parent().remove();
|
}
|
setpaytype(type);
|
var ExpenditureBusinessTypeName = $('#txtTitle').html().replace('付款单', '');
|
if (sysid != '' && initItems != null) {
|
ExpenditureBusinessTypeName = initItems.ExpenditureBusinessTypeName;
|
}
|
var inputs = '<input type="hidden" id="fm_otherexpenditureinfo_ExpenditureBusinessTypeID" name="fm_otherexpenditureinfo.ExpenditureBusinessTypeID" field="ExpenditureBusinessTypeID" value="' + type + '">';
|
inputs += '<input type="hidden" id="fm_otherexpenditureinfo_ExpenditureBusinessTypeName" name="fm_otherexpenditureinfo.ExpenditureBusinessTypeName" field="ExpenditureBusinessTypeName" value="' + ExpenditureBusinessTypeName + '">';
|
$('input[name="fm_otherexpenditureinfo.Code"]').after(inputs);
|
|
inputs = '<input type="hidden" id="fm_otherexpenditureinfo_orderType" name="fm_otherexpenditureinfo.orderType" field="orderType" value="0">';
|
$('input[name="fm_otherexpenditureinfo.Code"]').after(inputs);
|
var SettlementMethodName = (initItems != null && $.trim(initItems.SettlementMethodName) != '') ? initItems.SettlementMethodName : $('select[name="fm_otherexpenditureinfo.SettlementMethodID"]').find('option:eq(0)').text();
|
inputs = '<input type="hidden" id="fm_otherexpenditureinfo_SettlementMethodName" name="fm_otherexpenditureinfo.SettlementMethodName" field="SettlementMethodName" value="' + SettlementMethodName + '">';
|
$('select[name="fm_otherexpenditureinfo.SettlementMethodID"]').after(inputs);
|
$('select[name="fm_otherexpenditureinfo.SettlementMethodID"]').bind('change', function () {
|
var text = $(this).find('option:selected').text();
|
$('input[name="fm_otherexpenditureinfo.SettlementMethodName"]').val(text);
|
});
|
|
inputs = '<input type="hidden" id="fm_otherexpenditureinfo_ProjectName" name="fm_otherexpenditureinfo.ProjectName" field="ProjectName" value="">';
|
$('#fm_otherexpenditureinfo_ProjectID').after(inputs);
|
if ($.trim(initItems.ProjectName) != '') {
|
$('input[name="fm_otherexpenditureinfo.ProjectName"]').val(initItems.ProjectName);
|
}
|
|
inputs = '<input type="hidden" id="fm_otherexpenditureinfo_IncomeUnitID" name="fm_otherexpenditureinfo.IncomeUnitID" field="IncomeUnitID" value="0">';
|
$('#fm_otherexpenditureinfo_IncomeUnitName').after(inputs);
|
if ($.trim(initItems.IncomeUnitID) != '') {
|
$('input[name="fm_otherexpenditureinfo.IncomeUnitID"]').val(initItems.IncomeUnitID);
|
}
|
$('input[name="fm_otherexpenditureinfo.IsInPlan"]:eq(0)').attr("value", '1');
|
$('input[name="fm_otherexpenditureinfo.IsInPlan"]:eq(1)').attr("value", '2');
|
|
if ($.trim(sysid) != '' && initItems != null) {
|
var sprintbtn = '<span style="position: absolute;right:20px;"><a onclick="" href="/oa/General/erpcostprint?id=' + sysid + '" target="_blank" style="font-size:12px;margin-right: 20px;"><img src="../../img/ico/printer.png" />表单打印</a>';
|
sprintbtn += '<a onclick="" href="/oa/General/printyj?flowid=' + flowid + '&taskid=' + taskid + '" target="_blank" style="font-size:12px;"><img src="../../img/ico/printer.png" />审核意见打印</a></span>';
|
$('#txtTitle').append(sprintbtn);
|
}
|
getusername(type);
|
//绑定收款单位改变触发事件
|
$('#fm_otherexpenditureinfo_IncomeUnitName').bind('focus', function () {
|
getcompanyinfo();
|
});
|
|
//绑定项目改变触发事件
|
$('#fm_otherexpenditureinfo_ProjectID').bind('change', function () {
|
var projectname = $('#fm_otherexpenditureinfo_ProjectID').find('option:selected').text();
|
$('#fm_otherexpenditureinfo_ProjectName').val(projectname);
|
loadOrders()
|
});
|
if ($.trim(sysid) == '') {
|
loadOrders();
|
}
|
|
///给查看时给订单明细中采购单号添加点击事件
|
$('input[name="fm_otherexpenditureinfo_dtl.ExpenditureTypeName"]').removeAttr('disabled');
|
$('input[name="fm_otherexpenditureinfo_dtl.ExpenditureTypeName"]').attr('readonly', 'readonly');
|
$('input[name="fm_otherexpenditureinfo_dtl.ExpenditureTypeName"]').css({ 'background': 'WhiteSmoke', 'cursor': 'pointer' });
|
$('input[name="fm_otherexpenditureinfo_dtl.ExpenditureTypeName"]').bind('click', function () {
|
var order = $(this).val();
|
showorder(order);
|
});
|
|
|
}
|