|
//获取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 tabIndex;
|
$(document).on("click", "input[name='plc_payment_plan.incomeUnitName']", function () {
|
tabIndex = $(this).closest('tr').index();
|
getcompanyinfo();
|
});
|
var dtN = '';
|
var firstTime = '';
|
var secondTime = '';
|
var thredTime = '';
|
initData = function () {
|
var projectid = parseInt(getUrlParam('projectid'));
|
if(projectid>0)
|
{
|
$('#plc_payment_plan_dtl_projectid').val(projectid);
|
$('#plc_payment_plan_dtl_projectid').attr('disabled', 'disabled');
|
$('#plc_payment_plan_dtl_projectid').trigger("chosen:updated");
|
}
|
inputs = '<input type="hidden" id="plc_company_filed_project_id" name="plc_company_filed_project_id" field="project_id" value="' + (sysid == '' ? 0 : initItems.project_id) + '">';
|
$('#plc_payment_plan_dtl_projectid').after(inputs);
|
if (window.sysid === '') {
|
$.ajax({
|
url: "/PLC_payment_plan/GetDefault?projectid=" + projectid,
|
async: false,
|
cache: false,
|
dataType: "json",
|
success: function(resp) {
|
dtN = resp.dtN;
|
firstTime = resp.first;
|
secondTime = resp.second;
|
thredTime = resp.three;
|
$("#plc_payment_plan_dtl_code").val(resp.Num);
|
$("#plc_payment_plan_dtl_reportmonth").val(resp.dtN);
|
$("#plc_payment_plan_dtl_projectname").val(resp.projectname);
|
$("#plc_payment_plan_dtl_projectid").val(resp.projectid);
|
$('input[name="plc_payment_plan.firstdate"]').eq(0).val(firstTime);
|
$('input[name="plc_payment_plan.seconddate"]').eq(0).val(secondTime);
|
$('input[name="plc_payment_plan.thirddate"]').eq(0).val(thredTime);
|
}
|
});
|
} else {
|
$('input[name="plc_payment_plan.firstdate"]').each(function (i, r) {
|
var value = $(r).val();
|
if (value!='') {
|
var newvalue = Change(value);
|
$(r).val(newvalue);
|
}
|
});
|
$('input[name="plc_payment_plan.seconddate"]').each(function (i, r) {
|
var value = $(r).val();
|
if (value != '') {
|
var newvalue = Change(value);
|
$(r).val(newvalue);
|
}
|
});
|
$('input[name="plc_payment_plan.thirddate"]').each(function (i, r) {
|
var value = $(r).val();
|
if (value != '') {
|
var newvalue = Change(value);
|
$(r).val(newvalue);
|
}
|
});
|
|
var datastarttime = $("#plc_payment_plan_dtl_reportmonth").val();
|
if (datastarttime != '') {
|
var date = new Date(parseInt(datastarttime.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;
|
$("#plc_payment_plan_dtl_reportmonth").val(dataStr);
|
}
|
|
}
|
}
|
|
compute = function (value, date, endDate) {
|
dtN = value;
|
var dt = new Date(value + '-01');
|
firstTime = new Date(dt.getFullYear(), dt.getMonth() + 1).Format('yyyy-MM');
|
secondTime = new Date(dt.getFullYear(), dt.getMonth() + 2).Format('yyyy-MM');
|
thredTime = new Date(dt.getFullYear(), dt.getMonth() + 3).Format('yyyy-MM');
|
$('input[name="plc_payment_plan.firstdate"]').val(firstTime);
|
$('input[name="plc_payment_plan.seconddate"]').val(secondTime);
|
$('input[name="plc_payment_plan.thirddate"]').val(thredTime);
|
}
|
|
createMethod = function () {
|
var ntr = $('input[name="plc_payment_plan.firstdate"]').length;
|
if(ntr>0)
|
{
|
$('input[name="plc_payment_plan.firstdate"]').eq(ntr-1).val(firstTime);
|
$('input[name="plc_payment_plan.seconddate"]').eq(ntr-1).val(secondTime);
|
$('input[name="plc_payment_plan.thirddate"]').eq(ntr-1).val(thredTime);
|
}
|
}
|
|
var getcompanyinfo = function () {
|
layer.open({
|
type: 2,
|
title: '收款单位',
|
shadeClose: true,
|
shade: 0.4,
|
area: ['90%', '90%'],
|
content: "/oa/General/company"
|
});
|
}
|
|
//选择供应商后绑定数据
|
var setCompanyInfo = function (id, name, UserName, Phone, BankName, BankDeposit, BankAccount) {
|
var $row = $("table tr:eq(" + tabIndex + ")");
|
$row.find("input[field='incomeUnitID']").val(id);
|
$row.find("input[field='incomeUnitName']").val(name);
|
layer.closeAll();
|
}
|
|
|
function Change(e) {
|
|
var date = new Date(parseInt(e.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;
|
return dataStr;
|
}
|