|
//获取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 "";
|
}
|
|
//删除事件回调操作
|
deleteMethod = function (self) {
|
CountAmount();
|
$("#girdtable .body").each(function (i, v) {
|
CountAmountDtl($(v).find('[name = "erp_settlement_dtl.count"]'));
|
});
|
|
BindEvent();
|
if (window.taskid != '') {
|
var id = $(self).find("input[name='id']").val();
|
if (id != '') {
|
deleteDtlData(id);
|
}
|
}
|
}
|
|
deleteDtlData = function (id) {
|
$.ajax({
|
url: "/ERP/Erp_Settlement/RemoveSettlementDtl?settlementDtlId=" + id
|
, async: false
|
, cache: false
|
, dataType: "json",
|
success: function (data) {
|
if (data.Result) {
|
layer.alert("删除成功");
|
} else {
|
layer.alert("删除失败");
|
}
|
}
|
});
|
}
|
|
//添加事件回调操作
|
createMethod = function () {
|
NumberBind();
|
LoadConstructionCostDtlDropDownPage();
|
CountAmount();
|
$("#girdtable .body").each(function (i, v) {
|
CountAmountDtl($(v).find('[name = "erp_settlement_dtl.count"]'));
|
});
|
BindEvent();
|
ChangeDtlShowType();
|
if (completeLoadPage == 1) {
|
$("#girdtable .body").each(function () {
|
if (($(this).attr("dtSource") != "contractpretrial") && ($(this).attr("dtSource") != "prove")) {
|
$(this).find("[name='erp_settlement_dtl.type']").find("option[value='1']").remove();
|
}
|
});
|
}
|
|
}
|
|
$(document).ready(function () {
|
if (window.taskid != '') {
|
$("#erp_settlement_settlement_date").val(JsonDateToDate($("#erp_settlement_settlement_date").val()).Format('yyyy-MM-dd'));
|
$("#erp_settlement_start_date").val(JsonDateToDate($("#erp_settlement_start_date").val()).Format('yyyy-MM-dd'));
|
$("#erp_settlement_end_date").val(JsonDateToDate($("#erp_settlement_end_date").val()).Format('yyyy-MM-dd'));
|
} else {
|
var date = new Date();
|
var curDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
|
$("#erp_settlement_settlement_date").val(curDate);
|
$("#erp_settlement_start_date").val(curDate);
|
$("#erp_settlement_end_date").val(curDate);
|
}
|
|
$('#girdtable .body').find(".subtrdel_js").hide();
|
});
|
|
///数据加载
|
initData = function () {
|
NumberBind();
|
//debugger;
|
if (window.taskid == '') {
|
if (LoadData() == false) {
|
return;
|
}
|
|
LoadConstructionCostDtlDropDownData();
|
LoadConstructionCostDtlDropDownPage();
|
LoadPage();
|
} else {
|
LoadPJ();
|
LoadDataUpdate();
|
LoadConstructionCostDtlDropDownData();
|
LoadConstructionCostDtlDropDownPage();
|
}
|
|
ChangeLabel();
|
|
|
if (SettlementAllData.id > 0 && window.flowid != null && SettlementAllData.instance_status == 1) {
|
var sprintbtn = '<div style="padding-top:20px;padding-right:10px;padding-left:70%;"> <a onclick="" href="/ERP/Erp_Settlement/costprint/?printType=4&id=' + SettlementAllData.id + '&flowid=' + window.flowid + '&orderType=' + orderType + '" target="_blank" style="font-size:12px;"><img src="../../img/ico/printer.png" />结算单打印</a> <a onclick="" href="/ERP/Erp_Settlement/costprint/?printType=3&id=' + SettlementAllData.id + '&flowid=' + window.flowid + '&orderType=' + orderType + '" target="_blank" style="font-size:12px;"><img src="../../img/ico/printer.png" />附件打印</a></div>';
|
$('#txtTitle').append(sprintbtn);
|
}
|
|
//LoadConstructionCostDtlDropDown();
|
ChangeDtlShowType();
|
CountAmount();
|
$("#girdtable .body").each(function (i, v) {
|
CountAmountDtl($(v).find('[name = "erp_settlement_dtl.count"]'));
|
});
|
BindEvent();
|
ChangeFormTitle();
|
if (SettlementAllData.instance_status == 1 && (orderType == 4 || orderType == 5) && type == 3) {
|
var sprintbtn = '<div style="padding-top:20px;padding-right:10px;padding-left:70%;"> <a onclick="" href="/ERP/Erp_Settlement/costprintlw/?id=' + SettlementAllData.id + '" target="_blank" style="font-size:12px;"><img src="../../img/ico/printer.png" />单据打印</a></div>';
|
$('#txtTitle').append(sprintbtn);
|
}
|
|
//统一给主表的金额设置可编辑
|
$('[name="erp_settlement.amount"]').addClass('edit');
|
$('[name="erp_settlement.amount_after_deduction"]').addClass('edit');
|
$('[name="erp_settlement.payable_balance"]').addClass('edit');
|
}
|
|
var SettlementAllData = {};
|
var ContractpretrialSettlementDtl = [];
|
var ProveSettlementDtl = [];
|
var ConstructionCostDtls = [];
|
var type = 0;
|
var orderType = 0;
|
var completeLoadPage = 0;
|
var addClick = 0
|
function LoadData() {
|
var contractpretrialCode = getQueryVariable('contractpretrialCode');
|
type = getQueryVariable('type');
|
orderType = getQueryVariable('orderType');
|
var subject = 2;
|
$.ajax({
|
url: "/ERP/Erp_Settlement/Get?ContractpretrialCode=" + contractpretrialCode + "&type=" + type + "&orderType=" + orderType + "&subject=" + subject
|
, async: false
|
, cache: false
|
, dataType: "json",
|
success: function (data) {
|
SettlementAllData = data;
|
SettlementAllData.cumulative_payment_t = SettlementAllData.cumulative_payment;
|
SettlementAllData.cumulative_payable_t = SettlementAllData.cumulative_payable;
|
var json = JSON.stringify(SettlementAllData);
|
var sprintbtn = '<input type="hidden" id="erp_settlement_SettlementAllData" name="erp_settlement.SettlementAllData" field="SettlementAllData" class="form-control edit" isvalid="yes" checkexpession="NotNull"">';
|
$('#erp_settlement_code').after(sprintbtn);// 先弄个隐藏框把数据存起来
|
$("#erp_settlement_SettlementAllData").val(json);
|
//$("#txtTitle").text(data.title);
|
}
|
});
|
$.ajax({
|
url: "/ERP/Erp_Settlement/LoadSettlementDtlFromContractpretrial?contractpretrialCode=" + contractpretrialCode + "&orderType=" + orderType + "&type=" + type
|
, async: false
|
, cache: false
|
, dataType: "json",
|
success: function (data) {
|
//debugger;
|
if (data.Result) {
|
ContractpretrialSettlementDtl = data.DataInfo;
|
} else {
|
layer.alert(data.Message);
|
$(".btn-success").hide();
|
return false;
|
}
|
}
|
});
|
|
if (orderType == "4") {
|
$.ajax({
|
url: "/ERP/Erp_Settlement/LoadSettlementDtlFromProve?contractpretrialCode=" + contractpretrialCode
|
, async: false
|
, cache: false
|
, dataType: "json",
|
success: function (data) {
|
ProveSettlementDtl = data;
|
}
|
});
|
}
|
|
|
return true;
|
}
|
|
function LoadDataUpdate() {
|
$.ajax({
|
url: "/ERP/Erp_Settlement/Get?sysid=" + window.sysid
|
, async: false
|
, cache: false
|
, dataType: "json",
|
success: function (data) {
|
SettlementAllData = data;
|
SettlementAllData.cumulative_payment_t = SettlementAllData.cumulative_payment;
|
SettlementAllData.cumulative_payable_t = SettlementAllData.cumulative_payable;
|
type = SettlementAllData.type;
|
orderType = SettlementAllData.order_type;
|
var json = JSON.stringify(SettlementAllData);
|
var sprintbtn = '<input type="hidden" id="erp_settlement_SettlementAllData" name="erp_settlement.SettlementAllData" field="SettlementAllData" class="form-control" isvalid="yes" checkexpession="NotNull"">';
|
$('#erp_settlement_code').after(sprintbtn);// 先弄个隐藏框把数据存起来
|
$("#erp_settlement_SettlementAllData").val(json);
|
$("#txtTitle").text(data.title);
|
}
|
});
|
}
|
|
function LoadPage() {
|
$("#erp_settlement_code").val(SettlementAllData.code);
|
$("#erp_settlement_relation_order_num").val(SettlementAllData.relation_order_num);
|
$("#erp_settlement_project_id").val(SettlementAllData.ProjectName);
|
$("#erp_settlement_supplier_id").val(SettlementAllData.supplier_id);
|
$("#erp_settlement_supplier_id").trigger("chosen:updated");
|
$("#erp_settlement_contractpretrial_nature").val(SettlementAllData.contractpretrial_nature);
|
$("#erp_settlement_supplier_name").val(SettlementAllData.supplier_name);
|
$("#erp_settlement_supplier_user_name").val(SettlementAllData.supplier_user_name);
|
$("#erp_settlement_cumulative_payment").val(SettlementAllData.cumulative_payment);
|
$("#erp_settlement_cumulative_payable").val(SettlementAllData.cumulative_payable);
|
var dtlIndex = 0;
|
if (ContractpretrialSettlementDtl != null && ContractpretrialSettlementDtl.length > 0) {
|
for (var i = 0; i < ContractpretrialSettlementDtl.length; i++) {
|
$('#girdtable .body').eq(dtlIndex).attr("dtSource", "contractpretrial");
|
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.content']").val(ContractpretrialSettlementDtl[i].content);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.unit']").val(ContractpretrialSettlementDtl[i].unit);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.type']").trigger("chosen:updated");
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.count']").val(ContractpretrialSettlementDtl[i].count);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.price']").val(ContractpretrialSettlementDtl[i].price);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.amount']").val(ContractpretrialSettlementDtl[i].amount);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.construction_start_date']").val('');
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.construction_end_date']").val('');
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.no_taxrate_price']").val(ContractpretrialSettlementDtl[i].no_taxrate_price);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.no_taxrate_amount']").val(ContractpretrialSettlementDtl[i].no_taxrate_amount);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.jd_count_total']").val(ContractpretrialSettlementDtl[i].jd_count_total);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.jd_no_taxrate_amount_total']").val(ContractpretrialSettlementDtl[i].jd_no_taxrate_amount_total);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.construction_cost_dtl_id']").val(ContractpretrialSettlementDtl[i].construction_cost_dtl_id);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.construction_cost_dtl_id']").trigger("chosen:updated");
|
|
dtlIndex++;
|
if (dtlIndex != (ContractpretrialSettlementDtl.length + ProveSettlementDtl.length)) {
|
$(".subtradd_js").click();
|
}
|
}
|
}
|
|
if (ProveSettlementDtl != null && ProveSettlementDtl.length > 0) {
|
for (var i = 0; i < ProveSettlementDtl.length; i++) {
|
$('#girdtable .body').eq(dtlIndex).attr("dtSource", "prove");
|
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.content']").val(ProveSettlementDtl[i].content);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.unit']").val(ProveSettlementDtl[i].unit);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.type']").trigger("chosen:updated");
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.count']").val(ProveSettlementDtl[i].count);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.price']").val(ProveSettlementDtl[i].price);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.amount']").val(ProveSettlementDtl[i].amount);
|
|
//$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.construction_start_date']").val(JsonDateToDate(ProveSettlementDtl[i].construction_start_date).Format('yyyy-MM-dd'));
|
//$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.construction_end_date']").val(JsonDateToDate(ProveSettlementDtl[i].construction_end_date).Format('yyyy-MM-dd'));
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.construction_start_date']").val('');
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.construction_end_date']").val('');
|
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.jd_count_total']").val(0);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.jd_no_taxrate_amount_total']").val(0);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.construction_cost_dtl_id']").val(ProveSettlementDtl[i].construction_cost_dtl_id);
|
$('#girdtable .body').eq(dtlIndex).find("[name='erp_settlement_dtl.construction_cost_dtl_id']").trigger("chosen:updated");
|
|
dtlIndex++;
|
if (dtlIndex != (ContractpretrialSettlementDtl.length + ProveSettlementDtl.length)) {
|
$(".subtradd_js").click();
|
}
|
}
|
}
|
|
completeLoadPage = 1;
|
}
|
|
function LoadPJ() {
|
var pjid = $("#erp_settlement_project_id").val();
|
$.ajax({
|
url: "/PM/PM_Project/Get?id=" + pjid
|
, async: false
|
, cache: false
|
, dataType: "json",
|
success: function (data) {
|
$("#erp_settlement_project_id").val(data.pjname);
|
}
|
});
|
}
|
|
function LoadConstructionCostDtlDropDownData() {
|
if (type == "3") {
|
// 施工措施费的进度款关联 施工图目标成本的子表
|
$.ajax({
|
url: "/ERP/Erp_Settlement/GetConstructionCostDtlForSettlement?projectId=" + SettlementAllData.project_id + "&needDeduction=1"
|
, async: false
|
, cache: false
|
, dataType: "json",
|
success: function (data) {
|
ConstructionCostDtls = data;
|
//ConstructionCostDtlsBind();
|
}
|
});
|
}
|
}
|
|
function LoadConstructionCostDtlDropDownPage() {
|
if (ConstructionCostDtls != null && ConstructionCostDtls.length > 0) {
|
var optionHtml = '<option value="">请选择</option>';
|
for (var i = 0; i < ConstructionCostDtls.length; i++) {
|
var parentName = '';
|
if (ConstructionCostDtls[i].type == 1) {
|
parentName = '材料费';
|
} else if (ConstructionCostDtls[i].type == 2) {
|
parentName = '施工费';
|
} else if (ConstructionCostDtls[i].type == 3) {
|
parentName = '措施费';
|
} else if (ConstructionCostDtls[i].type == -999) {
|
parentName = '扣款项';
|
}
|
|
var textStr = parentName + '/' + ConstructionCostDtls[i].relation_name + '/' + ConstructionCostDtls[i].specification + '/' + ConstructionCostDtls[i].unit + '/' + ConstructionCostDtls[i].purposename;
|
optionHtml += '<option value="' + ConstructionCostDtls[i].id + '">' + textStr + '</option>';
|
}
|
$("[name='erp_settlement_dtl.construction_cost_dtl_id']").append(optionHtml);
|
|
if (window.taskid != "") {
|
$(SettlementAllData.Children).each(function (i, v) {
|
$("#girdtable .body").each(function () {
|
if ($(this).find('input[name="id"]').val() == v.id + "") {
|
$(this).find("[name='erp_settlement_dtl.construction_cost_dtl_id']").val(v.construction_cost_dtl_id);
|
$(this).find("[name='erp_settlement_dtl.construction_cost_dtl_id']").trigger("chosen:updated");
|
}
|
});
|
});
|
}
|
}
|
}
|
|
// 改下文本名 因为表单是按照结算的时候建的名字
|
function ChangeLabel() {
|
//设置合同性质单选框的高度,不然要强行换行
|
$('.z-radio').height($('.z-radio').parent('div').siblings().eq(0).find('div').eq(0).height());
|
|
if (orderType == "4") {
|
$("#erp_settlement_batch").parent('div').parent('div').hide();
|
}
|
if (orderType == "5") {
|
var width_4_child_div = $('.col-sm-4').eq(0).find('div').width();
|
$("#erp_settlement_supplier_id").parent('div').width(width_4_child_div);
|
$("#erp_settlement_supplier_id").parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
$("#erp_settlement_supplier_id").parent('div').parent('div').after($("#erp_settlement_supplier_user_name").parent('div').parent('div'));
|
$("#erp_settlement_supplier_user_name").parent('div').width(width_4_child_div)
|
$("#erp_settlement_supplier_user_name").parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
//
|
$("#erp_settlement_supplier_user_name").parent('div').parent('div').after($("#erp_settlement_code").parent('div').parent('div'));
|
$("#erp_settlement_code").parent('div').width(width_4_child_div)
|
$("#erp_settlement_code").parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
$("#erp_settlement_code").parent('div').parent('div').after($("#erp_settlement_content").parent('div').parent('div'));
|
$("#erp_settlement_content").parent('div').width(width_4_child_div)
|
$("#erp_settlement_content").parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
$("#erp_settlement_content").parent('div').parent('div').after($("[name='erp_settlement.contractpretrial_nature']").parent('label').parent('div').parent('div'));
|
//$("[name='erp_settlement.contractpretrial_nature']").parent('label').parent('div').parent('div').width(width_4_child_div)
|
$("[name='erp_settlement.contractpretrial_nature']").parent('label').parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
$("[name='erp_settlement.contractpretrial_nature']").parent('label').parent('div').parent('div').after($("#erp_settlement_relation_order_num").parent('div').parent('div'));
|
$("#erp_settlement_relation_order_num").parent('div').width(width_4_child_div)
|
$("#erp_settlement_relation_order_num").parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
$("#erp_settlement_relation_order_num").parent('div').parent('div').after($("#erp_settlement_start_date").parent('div').parent('div'));
|
$("#erp_settlement_start_date").parent('div').width(width_4_child_div)
|
$("#erp_settlement_start_date").parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
$("#erp_settlement_start_date").parent('div').parent('div').after($("#erp_settlement_end_date").parent('div').parent('div'));
|
$("#erp_settlement_end_date").parent('div').width(width_4_child_div)
|
$("#erp_settlement_end_date").parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
$("#erp_settlement_end_date").parent('div').parent('div').after($("#erp_settlement_settlement_date").parent('div').parent('div'));
|
$("#erp_settlement_settlement_date").parent('div').width(width_4_child_div)
|
$("#erp_settlement_settlement_date").parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
$("#erp_settlement_settlement_date").parent('div').parent('div').after($("#erp_settlement_amount").parent('div').parent('div'));
|
$("#erp_settlement_amount").parent('div').width(width_4_child_div)
|
$("#erp_settlement_amount").parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
$("#erp_settlement_amount").parent('div').parent('div').after($("#erp_settlement_cumulative_payment").parent('div').parent('div'));
|
$("#erp_settlement_cumulative_payment").parent('div').width(width_4_child_div)
|
$("#erp_settlement_cumulative_payment").parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
$("#erp_settlement_cumulative_payment").parent('div').parent('div').after($("#erp_settlement_payment_ratio").parent('div').parent('div'));
|
$("#erp_settlement_payment_ratio").parent('div').width(width_4_child_div)
|
$("#erp_settlement_payment_ratio").parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
$("#erp_settlement_payment_ratio").parent('div').parent('div').after($("#erp_settlement_payable_balance").parent('div').parent('div'));
|
$("#erp_settlement_payable_balance").parent('div').width(width_4_child_div)
|
$("#erp_settlement_payable_balance").parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
$("#erp_settlement_payable_balance").parent('div').parent('div').after($("#erp_settlement_cumulative_payable").parent('div').parent('div'));
|
$("#erp_settlement_cumulative_payable").parent('div').width(width_4_child_div)
|
$("#erp_settlement_cumulative_payable").parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
$("#erp_settlement_cumulative_payable").parent('div').parent('div').after($("#erp_settlement_batch").parent('div').parent('div'));
|
$("#erp_settlement_batch").parent('div').width(width_4_child_div)
|
$("#erp_settlement_batch").parent('div').parent('div').attr("class", "col-xs-4 col-sm-4");
|
|
// 累计已付-》累计完成
|
$("#erp_settlement_cumulative_payment").parent('div').prev('label').text("累计完成");
|
|
// 结算总金额-》本期完成
|
$("#erp_settlement_amount").parent('div').prev('label').text("本期完成");
|
|
// 应付款余额-》本期应付
|
$("#erp_settlement_payable_balance").parent('div').prev('label').text("本期应付");
|
|
// 合同单号-》关联单号
|
$("#erp_settlement_relation_order_num").parent('div').prev('label').text("关联单号");
|
|
// 合同单号-》关联单号
|
$("#erp_settlement_condition").parent('div').prev('label').text("合同支付条款说明");
|
|
// 施工起始日期-》计量起始日期
|
$("#erp_settlement_start_date").parent('div').prev('label').text("计量起始日期");
|
|
// 施工截止日期-》计量截止日期
|
$("#erp_settlement_end_date").parent('div').prev('label').text("计量截止日期");
|
|
// 结算日期-》计量日期
|
$("#erp_settlement_settlement_date").parent('div').prev('label').text("计量日期");
|
|
|
//// 承包内容隐藏
|
//$("#erp_settlement_content").parent('div').parent('div').hide();
|
if (orderType == "5" && type == "3") {
|
$(".subtradd_js").show();
|
} else {
|
$(".subtradd_js").hide();
|
}
|
}
|
}
|
|
// 处理子表启用禁用状态
|
function ChangeDtlShowType() {
|
$("#girdtable .body").each(function () {
|
if ($(this).find("input[name='id']").val() == '') {// 新增的时候
|
if ($(this).attr("dtSource") == "contractpretrial") {
|
$(this).find("[name='erp_settlement_dtl.type']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.type']").trigger("chosen:updated");
|
$(this).find("[name='erp_settlement_dtl.content']").attr("disabled", "disabled");
|
//$(this).find("[name='erp_settlement_dtl.unit']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.unit']").trigger("chosen:updated");
|
$(this).find("[name='erp_settlement_dtl.type']").trigger("chosen:updated");
|
//$(this).find("[name='erp_settlement_dtl.price']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.amount']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.no_taxrate_price']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.no_taxrate_amount']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.jd_count_total']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.jd_no_taxrate_amount_total']").attr("disabled", "disabled");
|
if (orderType == "4") {
|
$(this).find("[name='erp_settlement_dtl.construction_cost_dtl_id']").attr("disabled", "disabled");
|
} else {
|
$(this).find("[name='erp_settlement_dtl.construction_cost_dtl_id']").removeAttr("disabled");
|
}
|
$(this).find("[name='erp_settlement_dtl.construction_cost_dtl_id']").trigger("chosen:updated");
|
|
} else if ($(this).attr("dtSource") == "prove") {
|
$(this).find("[name='erp_settlement_dtl.type']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.type']").trigger("chosen:updated");
|
$(this).find("[name='erp_settlement_dtl.content']").attr("disabled", "disabled");
|
//$(this).find("[name='erp_settlement_dtl.unit']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.unit']").trigger("chosen:updated");
|
$(this).find("[name='erp_settlement_dtl.type']").trigger("chosen:updated");
|
//$(this).find("[name='erp_settlement_dtl.price']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.amount']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.construction_start_date']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.construction_end_date']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.no_taxrate_price']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.no_taxrate_amount']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.jd_count_total']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.jd_no_taxrate_amount_total']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.construction_cost_dtl_id']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.construction_cost_dtl_id']").trigger("chosen:updated");
|
} else {
|
// 扣款项
|
$(this).find("[name='erp_settlement_dtl.no_taxrate_price']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.no_taxrate_amount']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.jd_count_total']").val("0");
|
$(this).find("[name='erp_settlement_dtl.jd_count_total']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.jd_no_taxrate_amount_total']").val("0");
|
$(this).find("[name='erp_settlement_dtl.jd_no_taxrate_amount_total']").attr("disabled", "disabled");
|
//$(this).find("[name='erp_settlement_dtl.type']").find("option[value='1']").remove();
|
}
|
} else {// 保存后更新的时候
|
$(this).find("[name='erp_settlement_dtl.type']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.type']").trigger("chosen:updated");
|
$(this).find("[name='erp_settlement_dtl.content']").attr("disabled", "disabled");
|
//$(this).find("[name='erp_settlement_dtl.unit']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.unit']").trigger("chosen:updated");
|
$(this).find("[name='erp_settlement_dtl.type']").trigger("chosen:updated");
|
//$(this).find("[name='erp_settlement_dtl.price']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.amount']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.construction_start_date']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.construction_end_date']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.no_taxrate_price']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.no_taxrate_amount']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.jd_count_total']").attr("disabled", "disabled");
|
$(this).find("[name='erp_settlement_dtl.jd_no_taxrate_amount_total']").attr("disabled", "disabled");
|
}
|
});
|
|
if (orderType == "4") {
|
$('#erp_settlement_deductions').attr("checkexpession", "NotNull");
|
} else if (orderType == "5") {
|
$('#erp_settlement_payment_ratio').attr("checkexpession", "NotNull");
|
}
|
|
// 施工措施费的进度款关联 施工图目标成本的子表
|
var tdIndex = $('#girdtable .body').eq(0).find('[name="erp_settlement_dtl.construction_cost_dtl_id"]').parent('td').index();
|
if (tdIndex > -1) {
|
if (type == "3") {
|
$('#girdtable tr').each(function () {
|
$(this).children("td").eq(tdIndex).show();
|
});
|
$('[name="erp_settlement_dtl.construction_cost_dtl_id"]').attr("checkexpession", "NotNull");
|
} else {
|
$('#girdtable tr').each(function () {
|
$(this).children("td").eq(tdIndex).hide();
|
});
|
}
|
}
|
var tdIndex2 = $('#girdtable .body').eq(0).find('[name="erp_settlement_dtl.jd_count_total"]').parent('td').index();
|
var tdIndex3 = $('#girdtable .body').eq(0).find('[name="erp_settlement_dtl.jd_no_taxrate_amount_total"]').parent('td').index();
|
if (orderType == "5") {
|
$('#girdtable tr').each(function () {
|
if (window.taskid == "") {
|
$("[name='erp_settlement_dtl.price']").removeAttr("disabled");
|
}
|
if (tdIndex2 > -1) {
|
$(this).children("td").eq(tdIndex2).hide();
|
}
|
if (tdIndex3 > -1) {
|
$(this).children("td").eq(tdIndex3).hide();
|
}
|
});
|
}
|
}
|
|
// 改变页面表单标题
|
function ChangeFormTitle() {
|
//debugger;
|
var titleStr = SettlementAllData.title.replace('进度计量', '<span style="color: #4ee61d;">进度计量</span >').replace('结算计量', '<span style="color: #e75464;">结算计量</span >');
|
|
$("#txtTitle").html(titleStr);
|
$('#girdtable').prev("h3").html(titleStr + "明细");
|
}
|
|
function RemoveDtlType() {
|
|
}
|
|
function BindEvent() {
|
// 所以的输入框改变的时候都同步SettlementAllData对象
|
$('input,textarea,select').change(function () {
|
var fildName = $(this).attr("name").replace("erp_settlement.", "");
|
SettlementAllData[fildName] = $(this).val();
|
$("#erp_settlement_SettlementAllData").val(JSON.stringify(SettlementAllData));
|
});
|
|
// 结算项改变时重新算总价
|
$('[name="erp_settlement_dtl.type"]').change(function () {
|
CountAmount();
|
});
|
|
$('[name="erp_settlement_dtl.count"],[name="erp_settlement_dtl.price"],[name="erp_settlement_dtl.tax_rate"]').change(function () {
|
if (/^[0-9]+(([.]{1}([0-9]+))|)$/.test($(this).val()) == false) {
|
$(this).val('');
|
return false;
|
}
|
CountAmountDtl($(this));
|
});
|
|
// 供应商负责人同步
|
$('#erp_settlement_supplier_id').change(function () {
|
var supplier_id = $(this).val();
|
var supplier_name = $(this).next("div").find("a").find("span").text();
|
$.ajax({
|
url: "/SC/Sc_supplier/GetSupplierInfoByID?id=" + supplier_id
|
, async: false
|
, cache: false
|
, dataType: "json",
|
success: function (data) {
|
$("#erp_settlement_supplier_user_name").val(data.UserName);
|
SetJsonData("supplier_user_id", data.user_id);
|
SetJsonData("supplier_user_name", data.UserName);
|
SetJsonData("supplier_id", data.supplier_id);
|
SetJsonData("supplier_name", data.supplier_name);
|
}
|
});
|
});
|
|
// 合同详情跳转
|
$('#erp_settlement_relation_order_num').css({ "color": "cornflowerblue", "cursor": "pointer" });
|
$('#erp_settlement_relation_order_num').parent('div').click(function () {
|
var code = $(this).find("#erp_settlement_relation_order_num").val();
|
if (code == "无关联单号") {
|
return false;
|
}
|
|
$.ajax({
|
url: '/ERP/Erp_Settlement/GetContractpretrialByCode',
|
data: { code: code },
|
type: 'Post',
|
success: function (resp) {
|
if (resp.Data != null && resp.Data != undefined) {
|
var data = resp.Data;
|
var tableName = 'oa_contractpretrial';
|
$.ajax({
|
url: '/OA/OA_SysErpMGMT/GetFlowTaskByIdAndTable',
|
data: { id: data.PKID, table: tableName },
|
type: 'Post',
|
success: function (resp) {
|
var url = "/WorkFlowRun/Index?flowid=" + resp.FlowId + '&taskid=' + resp.TaskId;
|
appendTabByUrl(url, "查看单据详情");
|
}
|
});
|
} else {
|
layer.alert("合同未找到");
|
}
|
}
|
});
|
});
|
|
if (orderType == "4") {// 结算
|
$('#erp_settlement_deductions').bind('change', function () {
|
if (/^[-]{0,1}[0-9]+(([.]{1}([0-9]+))|)$/.test($(this).val()) == false) {
|
$(this).val('');
|
return false;
|
}
|
MoneyChangeEvent();
|
});
|
} else if (orderType == "5") {// 进度款
|
$('#erp_settlement_payment_ratio').bind('change', function () {
|
if (/^[0-9]+(([.]{1}([0-9]+))|)$/.test($(this).val()) == false) {
|
$(this).val('');
|
return false;
|
}
|
MoneyChangeEvent();
|
});
|
}
|
|
|
$('[name="erp_settlement_dtl.construction_cost_dtl_id"]').parent("td").unbind();
|
$('[name="erp_settlement_dtl.construction_cost_dtl_id"]').parent("td").click(function () {
|
ShowCostPage($(this).find('[name="erp_settlement_dtl.construction_cost_dtl_id"]'));
|
});
|
|
$('.subtradd_js').parent("span").unbind();
|
$('.subtradd_js').parent("span").click(function () {
|
if (completeLoadPage == 1 && orderType == "5") {
|
ShowContractpretrialList();
|
}
|
});
|
}
|
|
function CountAmount() {
|
// 算总金额
|
var amount = 0;
|
var deductions = 0;
|
$('[name="erp_settlement_dtl.amount"]').each(function (i, v) {
|
var type = $(this).parents('tr').find('[name="erp_settlement_dtl.type"]').val();
|
if (type == "1") {
|
var curAmountStr = $(v).val();
|
var curAmount = curAmountStr == "" ? 0 : Number(curAmountStr);
|
amount += curAmount;
|
} else if (type == "2") {
|
var curDeductionsStr = $(v).val();
|
var curDeductions = curDeductionsStr == "" ? 0 : Number(curDeductionsStr);
|
deductions += curDeductions;
|
}
|
});
|
|
$('#erp_settlement_amount').val(amount);
|
$('#erp_settlement_deductions').val(deductions);
|
SetJsonData("amount", amount);
|
SetJsonData("deductions", deductions);
|
MoneyChangeEvent();
|
}
|
|
function CountAmountDtl(self) {
|
//debugger;
|
//子表算总金额
|
var countStr = $(self).parents('tr').find('[name="erp_settlement_dtl.count"]').val();
|
var count = countStr == "" ? 0 : Number(countStr);
|
if (count == 0) {// 数量是0的时候 合计这些就不用算了
|
$(self).parents('tr').find('[name="erp_settlement_dtl.amount"]').val(0);
|
$(self).parents('tr').find('[name="erp_settlement_dtl.no_taxrate_amount"]').val(0);
|
$(self).parents('tr').find('[name="erp_settlement_dtl.no_taxrate_price"]').val(0);
|
} else {
|
var priceStr = $(self).parents('tr').find('[name="erp_settlement_dtl.price"]').val();
|
var price = priceStr == "" ? 0 : Number(priceStr);
|
var amount = accMul(count, price);
|
var taxrate = accDiv(Number($(self).parents('tr').find('select[name="erp_settlement_dtl.tax_rate"]').val()), 100);
|
//不含税合计 =含税合计- (含税合计 / (1 + 税率) * 税率)
|
var no_taxrate_amount = accSub(amount, (accMul(accDiv(amount, accAdd(1, taxrate)), taxrate)));
|
var no_taxrate_price = accDiv(no_taxrate_amount.toFixed(2), count);
|
$(self).parents('tr').find('[name="erp_settlement_dtl.amount"]').val(amount.toFixed(2));
|
$(self).parents('tr').find('[name="erp_settlement_dtl.no_taxrate_amount"]').val(no_taxrate_amount.toFixed(2));
|
$(self).parents('tr').find('[name="erp_settlement_dtl.no_taxrate_price"]').val(no_taxrate_price.toFixed(8));
|
}
|
|
// 全部总金额
|
CountAmount();
|
}
|
|
function MoneyChangeEvent() {
|
if (orderType == "4") {// 结算
|
// 扣款后结算金额=结算金额-各项 扣款
|
var erp_settlement_amount = $("#erp_settlement_amount").val() == "" ? 0 : Number($("#erp_settlement_amount").val());
|
var erp_settlement_deductions = $("#erp_settlement_deductions").val() == "" ? 0 : Number($("#erp_settlement_deductions").val());
|
var erp_settlement_amount_after_deduction = accSub(erp_settlement_amount, erp_settlement_deductions);
|
$("#erp_settlement_amount_after_deduction").val(erp_settlement_amount_after_deduction);
|
SetJsonData("amount_after_deduction", erp_settlement_amount_after_deduction);
|
// 应付款余额=扣款后结算金额-累计已付款
|
var erp_settlement_cumulative_payment = $("#erp_settlement_cumulative_payment").val() == "" ? 0 : Number($("#erp_settlement_cumulative_payment").val());
|
$("#erp_settlement_payable_balance").val(accSub(erp_settlement_amount_after_deduction, erp_settlement_cumulative_payment));
|
SetJsonData("payable_balance", erp_settlement_amount_after_deduction - erp_settlement_cumulative_payment);
|
} else if (orderType == "5") {// 进度款
|
// 本期应付=本期完成*支付比例
|
var erp_settlement_amount = $("#erp_settlement_amount").val() == "" ? 0 : Number($("#erp_settlement_amount").val());
|
var erp_settlement_payment_ratio = $("#erp_settlement_payment_ratio").val() == "" ? 0 : Number($("#erp_settlement_payment_ratio").val());
|
$("#erp_settlement_payable_balance").val(accMul(erp_settlement_amount, (accDiv(erp_settlement_payment_ratio, 100))).toFixed(2));
|
SetJsonData("payable_balance", accMul(erp_settlement_amount, (accDiv(erp_settlement_payment_ratio, 100))).toFixed(2));
|
//// 累计已付和累计应付要加本期本期应付和本期完成
|
$("#erp_settlement_cumulative_payment").val(SettlementAllData.cumulative_payment_t);
|
$("#erp_settlement_cumulative_payment").val(accAdd($("#erp_settlement_amount").val(), $("#erp_settlement_cumulative_payment").val()));
|
$("#erp_settlement_cumulative_payable").val(SettlementAllData.cumulative_payable_t);
|
//$("#erp_settlement_cumulative_payable").val(accAdd($("#erp_settlement_payable_balance").val(), $("#erp_settlement_cumulative_payable").val()));
|
$("#erp_settlement_cumulative_payable").val(accMul($("#erp_settlement_cumulative_payment").val(), accDiv($("#erp_settlement_payment_ratio").val(), 100)).toFixed(2));
|
}
|
}
|
|
function SetJsonData(key, value) {
|
SettlementAllData[key] = value;
|
var json = JSON.stringify(SettlementAllData);
|
$("#erp_settlement_SettlementAllData").val(json);
|
}
|
|
var _costInput;
|
//施工图明细选择选择
|
function ShowCostPage(costInput) {
|
//debugger;
|
var deduction = $(costInput).parents('tr').find("[name='erp_settlement_dtl.type']").val() == "2" ? 1 : 0;
|
if (orderType == "4" && deduction == 0 || $(costInput).attr("disabled") == "disabled") {
|
return false;
|
}
|
|
_costInput = costInput;
|
var id = $(_costInput).val();
|
//if ($(costInput).attr("disabled") == "disabled") {
|
// id = $(_costInput).val();
|
//}
|
layer.open({
|
type: 2,
|
title: '资源库',
|
shadeClose: true,
|
shade: 0.4,
|
area: ['90%', '90%'],
|
content: "/Article/Cost_Index?projectid=" + SettlementAllData.project_id + "&id=" + id + "&iskoukuan=" + deduction
|
});
|
}
|
|
function setCostInfo(id, relation_key, relation_name, specification, unit, count, price, amount, type, ratio, ratio_count, purposename, cost_subject_id) {
|
$(_costInput).val(id);
|
$(_costInput).trigger("chosen:updated");
|
//$(_costInput).parents('tr').find('[name="erp_settlement_dtl.unit"]').val(unit);
|
//$(_costInput).parents('tr').find('[name="erp_settlement_dtl.unit"]').trigger("chosen:updated");
|
|
$("#erp_settlement_remark").click();
|
|
layer.closeAll();
|
}
|
|
function setCostInfoOfKouKuan(id, parentid, name, typeName, specifications, unitid, unitName, range, debit_subject, credit_subject, before_subject, after_subject) {
|
$(_costInput).val(id);
|
$(_costInput).trigger("chosen:updated");
|
$("#erp_settlement_remark").click();
|
|
layer.closeAll();
|
}
|
|
function ShowContractpretrialList() {
|
//debugger;
|
var contractpretrialCode = $("#erp_settlement_relation_order_num").val();
|
layer.open({
|
type: 2,
|
title: '合同明细列表',
|
shadeClose: true,
|
shade: 0.4,
|
closeBtn: 0,
|
area: ['90%', '90%'],
|
content: "/Erp_Settlement/ContractpretrialList?contractpretrialCode=" + contractpretrialCode
|
});
|
}
|
|
function SelectContractpretrialDtl(name, unit, count, price, amount) {
|
$('#girdtable .body').last().find("[name='erp_settlement_dtl.content']").val(name);
|
$('#girdtable .body').last().find("[name='erp_settlement_dtl.unit']").val(unit);
|
$('#girdtable .body').last().find("[name='erp_settlement_dtl.unit']").trigger("chosen:updated");
|
$('#girdtable .body').last().find("[name='erp_settlement_dtl.count']").val(count);
|
$('#girdtable .body').last().find("[name='erp_settlement_dtl.price']").val(price);
|
$('#girdtable .body').last().find("[name='erp_settlement_dtl.amount']").val(amount);
|
//debugger;
|
$('#girdtable .body').last().find("[name='erp_settlement_dtl.type']").append("<option value='1'>结算项</option>");
|
$('#girdtable .body').last().find("[name='erp_settlement_dtl.type']").val("1");
|
$('#girdtable .body').last().find("[name='erp_settlement_dtl.type']").trigger("chosen:updated");
|
|
$('#girdtable .body').last().attr("dtSource", "contractpretrial");
|
//debugger;
|
createMethod();
|
layer.closeAll();
|
}
|
|
var NoContractpretrialDtlSelect = function () {
|
$('#girdtable .body').last().find(".subtrdel_js").click();
|
$('#girdtable .body').last().remove();
|
}
|
|
NumberBind = function () {
|
$("[name='erp_settlement_dtl.count']").addClass("countTxtBox");
|
$("[name='erp_settlement_dtl.price']").addClass("priceTxtBox");
|
$("[name='erp_settlement_dtl.amount']").addClass("amountTxtBox");
|
NumberBoxBind();
|
}
|
|
/**
|
* 乘法
|
*/
|
function accMul(arg1, arg2) {
|
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)
|
}
|
/**
|
* 除法
|
*/
|
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);
|
}
|
}
|
/**
|
* 加法
|
*/
|
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
|
}
|
/**
|
* 减法
|
*/
|
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);
|
}
|