|
|
//获取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 GetMoney = function () {
|
var nmaterialMoney = $.trim($('#plc_quality_accident_list_materialMoney').val());
|
nmaterialMoney = nmaterialMoney == '' ? 0 : parseFloat(nmaterialMoney);
|
var labourMoney = $.trim($('#plc_quality_accident_list_labourMoney').val());
|
labourMoney = labourMoney == '' ? 0 : parseFloat(labourMoney);
|
var otherMoney = $.trim($('#plc_quality_accident_list_otherMoney').val());
|
otherMoney = otherMoney == '' ? 0 : parseFloat(otherMoney);
|
var totalMoney = (parseFloat(nmaterialMoney) + parseFloat(labourMoney) + parseFloat(otherMoney)).toFixed(0);
|
$('#plc_quality_accident_list_totalMoney').val(totalMoney);
|
}
|
|
|
//选择计算金额
|
$(document).on('change', $('#plc_quality_accident_list_materialMoney,#plc_quality_accident_list_labourMoney,#plc_quality_accident_list_otherMoney'), function (i, r) {
|
GetMoney();
|
});
|
|
initData = function () {
|
var accidentid = getUrlParam('accidentid');
|
if (window.flowid == "74370845834942BC8481AA1100DB8237") {
|
if (window.sysid === '') {
|
$.ajax({
|
url: "/PLC_quality_accident_list/GetNum",
|
async: false,
|
cache: false,
|
dataType: "json",
|
success: function (resp) {
|
$("#plc_quality_accident_list_code").val(resp);
|
}
|
});
|
} else {
|
var dataaddTime = $("#plc_quality_accident_list_addTime").val();
|
if (dataaddTime != '') {
|
var date = new Date(parseInt(dataaddTime.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;
|
$("#plc_quality_accident_list_addTime").val(dataStr);
|
}
|
}
|
} else if (window.flowid == "3A2B9AC4D9294D36AC8FAA5400FDF2E6") {
|
inputs = '<input type="hidden" id="plc_quality_accident_list_id" name="plc_quality_accident_list.id" field="id" value="' + (sysid == '' ? 0 : initItems.id) + '">';
|
$('#plc_quality_accident_list_code').after(inputs);
|
if (window.sysid === '') {
|
|
$.ajax({
|
url: "/PLC_quality_accident_list/Get",
|
async: false,
|
cache: false,
|
dataType: "json",
|
data: { sysid: accidentid },
|
success: function (resp) {
|
if (resp) {
|
$("#plc_quality_accident_list_id").val(resp.id);
|
$("#plc_quality_accident_list_code").val(resp.code+"-2");
|
$("#plc_quality_accident_list_project_id").val(resp.project_id);
|
$("#plc_quality_accident_list_project_id").trigger("chosen:updated");
|
$("#plc_quality_accident_list_addTime").val(resp.addTime);
|
var Listlevel = $("input[name='plc_quality_accident_list.accident_level']");
|
for (var i = 0; i < Listlevel.length; i++) {
|
if (Listlevel[i].getAttribute("value") ==resp.accident_level) {
|
Listlevel[i].setAttribute("checked", "checked");
|
}
|
}
|
var piletype = $("input[name='plc_quality_accident_list.pileType']");
|
var pile = resp.pileType.split(',');
|
for (var i = 0; i < piletype.length;i++) {
|
for (var j = 0; j < pile.length; j++) {
|
if (piletype[i].getAttribute("value") == pile[j]) {
|
piletype[i].setAttribute("checked","ckecked");
|
}
|
|
}
|
}
|
var accident_types = $("input[name='plc_quality_accident_list.accident_types']");
|
var accident = resp.accident_types.split(',');
|
for (var i = 0; i < accident_types.length; i++) {
|
for (var j = 0; j < accident.length; j++) {
|
if (accident_types[i].getAttribute("value") == accident[j]) {
|
accident_types[i].setAttribute("checked", "ckecked");
|
}
|
|
}
|
}
|
$("#plc_quality_accident_list_occurs").html(resp.occurs);
|
$("#plc_quality_accident_list_quality_engineer").val(resp.quality_engineer);
|
$("#plc_quality_accident_list_projectmangmenter").val(resp.projectmangmenter);
|
}
|
}
|
});
|
} else {
|
var name = $("#plc_quality_accident_list_code").val();
|
$("#plc_quality_accident_list_code").val(name + "-2");
|
}
|
var dataaddTime = $("#plc_quality_accident_list_addTime").val();
|
if (dataaddTime != '') {
|
var date = new Date(parseInt(dataaddTime.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;
|
$("#plc_quality_accident_list_addTime").val(dataStr);
|
}
|
} else if (window.flowid =="11F293E61FE5444BB7BCAA540102DB9D") {
|
inputs = '<input type="hidden" id="plc_quality_accident_list_id" name="plc_quality_accident_list.id" field="id" value="' + (sysid == '' ? 0 : initItems.id) + '">';
|
$('#plc_quality_accident_list_code').after(inputs);
|
if (window.sysid === '') {
|
$.ajax({
|
url: "/PLC_quality_accident_list/Get",
|
async: false,
|
cache: false,
|
dataType: "json",
|
data: { sysid: accidentid },
|
success: function (resp) {
|
if (resp) {
|
$("#plc_quality_accident_list_id").val(resp.id);
|
$("#plc_quality_accident_list_code").val(resp.code + "-3");
|
$("#plc_quality_accident_list_project_id").val(resp.project_id);
|
$("#plc_quality_accident_list_project_id").trigger("chosen:updated");
|
$("#plc_quality_accident_list_addTime").val(resp.addTime);
|
var Listlevel = $("input[name='plc_quality_accident_list.accident_level']");
|
for (var i = 0; i < Listlevel.length; i++) {
|
if (Listlevel[i].getAttribute("value") == resp.accident_level) {
|
Listlevel[i].setAttribute("checked", "checked");
|
}
|
}
|
var piletype = $("input[name='plc_quality_accident_list.pileType']");
|
var pile = resp.pileType.split(',');
|
for (var i = 0; i < piletype.length; i++) {
|
for (var j = 0; j < pile.length; j++) {
|
if (piletype[i].getAttribute("value") == pile[j]) {
|
piletype[i].setAttribute("checked", "ckecked");
|
}
|
|
}
|
}
|
var accident_types = $("input[name='plc_quality_accident_list.accident_types']");
|
var accident = resp.accident_types.split(',');
|
for (var i = 0; i < accident_types.length; i++) {
|
for (var j = 0; j < accident.length; j++) {
|
if (accident_types[i].getAttribute("value") == accident[j]) {
|
accident_types[i].setAttribute("checked", "ckecked");
|
}
|
|
}
|
}
|
$("#plc_quality_accident_list_occurs").html(resp.occurs);
|
$("#plc_quality_accident_list_quality_engineer").val(resp.quality_engineer);
|
$("#plc_quality_accident_list_projectmangmenter").val(resp.projectmangmenter);
|
$("#plc_quality_accident_list_reason").html(resp.reason);
|
$("#plc_quality_accident_list_Responsibility").html(resp.Responsibility);
|
}
|
}
|
});
|
} else {
|
var name = $("#plc_quality_accident_list_code").val();
|
$("#plc_quality_accident_list_code").val(name + "-3");
|
}
|
var dataaddTime = $("#plc_quality_accident_list_addTime").val();
|
if (dataaddTime != '') {
|
var date = new Date(parseInt(dataaddTime.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;
|
$("#plc_quality_accident_list_addTime").val(dataStr);
|
}
|
}
|
$('#plc_quality_accident_list_totalMoney').attr('disabled', 'disabled');
|
}
|