var tabIndex;
|
var currentUserName;
|
initData = function () {
|
if (window.taskid === '') {
|
$.ajax({
|
url: "/PurchaseApply/InitData",
|
async: false,
|
cache: false,
|
dataType: "json",
|
success: function (data) {
|
currentUserName = data.CurrentUserName;
|
var $data = data.children;
|
for (var name in data) {
|
if (name !== "children") {
|
var $value = data[name];
|
if ($value != null && $value !== '') {
|
var $control = $(".main [field='" + name + "']");
|
var $controltype = $control.prop("tagName");
|
if ($controltype != null && $controltype !== '') {
|
|
var $type = $control.attr("type");
|
if ($type !== "radio" && $type !== "checkbox") {
|
$(".main [field='" + name + "']").val($value);
|
}
|
if ($type === "radio") {
|
$(".main [field='" + name + "'][value='" + $value + "']").attr("checked", "checked");
|
}
|
if ($type === "checkbox") {
|
var $items = $(".main [field='" + name + "']");
|
var $arr = $value.split(",");
|
$.each($items, function (index, obj) {
|
var value = $(obj).attr("value");
|
if (contains($arr, value))
|
$(obj).attr("checked", "checked");
|
});
|
}
|
}
|
}
|
}
|
}
|
if ($data != null && $data.length > 0) {
|
renderGirdtableByData($children, $data.length);
|
}
|
}
|
});
|
var $txttitle = $("#txtTitle").text();
|
$txttitle = $txttitle + "(" + currentUserName + ")";
|
$("#erp_purchaseapplication_name").val($txttitle);
|
|
var $classfy = getQueryVariable("type");
|
if (document.getElementById("erp_purchaseapplication_Classfy") && $classfy !== '') { //js判断元素是否存在
|
$("#erp_purchaseapplication_Classfy").val($classfy);
|
$('#erp_purchaseapplication_Classfy').trigger("chosen:updated");
|
$("#erp_purchaseapplication_Classfy").attr("disabled", true);
|
var $name = $("#erp_purchaseapplication_Classfy").find("option:selected").text();
|
var $type = $("#erp_purchaseapplication_Classfy").find("option:selected").val();
|
if ($type == 12) {
|
$("#girdtable tr").find('td:eq(0)').hide();
|
}
|
$('#txtTitle').html($name + "申请单");
|
if (window.taskid === '') {
|
$txttitle = $name + "申请单(" + currentUserName + ")";
|
$("#erp_purchaseapplication_name").val($txttitle);
|
}
|
} else if ($classfy !== '') {
|
var $control = $('<input id="erp_purchaseapplication_Classfy" name="erp_purchaseapplication.Classfy" field="Classfy" type="hidden" value="' + $classfy + '" />');
|
$(".main").append($control);
|
if (window.taskid === '') {
|
$txttitle = $("#txtTitle").html() + "申请单(" + currentUserName + ")";;
|
$("#erp_purchaseapplication_name").val($txttitle);
|
}
|
}
|
if ($classfy == undefined || $classfy == '') {
|
var $name = $("#erp_purchaseapplication_Classfy").find("option:selected").text();
|
$('#txtTitle').html($name + "申请单");
|
$("#erp_purchaseapplication_name").val($name + "申请单(" + currentUserName + ")");
|
}
|
} else {
|
var name = $("#erp_purchaseapplication_Classfy").find("option:selected").text();
|
if (name != "") {
|
$('#txtTitle').html(name + "申请单");
|
}
|
var $type = $("#erp_purchaseapplication_Classfy").find("option:selected").val();
|
if ($type == 12) {
|
$("#girdtable tr").find('td:eq(0)').hide();
|
}
|
var formName = $("#erp_purchaseapplication_name").val();
|
currentUserName = formName.substring(formName.indexOf("(") + 1, formName.indexOf(")"));
|
$("#erp_purchaseapplication_Classfy").attr("disabled", true);
|
$('#erp_purchaseapplication_Classfy').trigger("chosen:updated");
|
}
|
$("#erp_purchaseapplication_TotalPrice").attr("readonly", "readonly");
|
$("#erp_purchaseapplication_orderCode").attr("readonly", "readonly");
|
$("#erp_purchaseapplication_createtime").attr("readonly", "readonly");
|
$("#erp_purchaseapplication_name").attr("readonly", "readonly");
|
}
|
|
|
//添加事件回调操作
|
createMethod = function () {
|
|
var $type = $("#erp_purchaseapplication_Classfy").find("option:selected").val();
|
if ($type == 12) {
|
$("#erp_purchaseapplication_dtl_Object").parent().parent().parent().find("tr").find('td:eq(0)').hide();
|
} else {
|
$("#erp_purchaseapplication_dtl_Object").parent().parent().parent().find("tr").find('td:eq(0)').show();
|
}
|
}
|
|
|
totalcompute = function () {
|
var total = 0;
|
$('.grid').find("table .body").each(function () {
|
var count = $(this).find("#erp_purchaseapplication_dtl_count").val();
|
var price = $(this).find("#erp_purchaseapplication_dtl_Price").val();
|
if (count !== null && price !== null && count > 0 && price > 0)
|
total += accMul(count,price);
|
else {
|
price = $(this).find("#erp_purchaseapplication_dtl_TotalPrice").val();
|
if (price !== null && price > 0)
|
total += accMul(1.0, price);
|
}
|
});
|
$("#erp_purchaseapplication_TotalPrice").val(total);
|
}
|
|
$(document).ready(function () {
|
$(".grid").on("blur", "#erp_purchaseapplication_dtl_count", function () {
|
totalcompute();
|
});
|
$(".grid").on("blur", "#erp_purchaseapplication_dtl_Price", function () {
|
totalcompute();
|
});
|
$(".grid").on("blur", "#erp_purchaseapplication_dtl_TotalPrice", function () {
|
totalcompute();
|
});
|
});
|
|
//$(document).on("change", "#erp_purchaseapplication_project_id", function () {
|
// var $name = $("#erp_purchaseapplication_project_id").find("option:selected").text();
|
// var $title = $("#txtTitle").html() + "(" + currentUserName + ")";
|
// $("#erp_purchaseapplication_name").val($name + '_' + $title);
|
//});
|
|
$(document).on("change", "#erp_purchaseapplication_Classfy", function () {
|
var $name = $("#erp_purchaseapplication_Classfy").find("option:selected").text();
|
var $txttitle = $name + "申请单(" + currentUserName + ")";
|
$("#erp_purchaseapplication_name").val($txttitle);
|
$('#txtTitle').html($name + "申请单");
|
});
|
|
deleteMethod = function () {
|
totalcompute();
|
}
|
|
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 "";
|
}
|