var tabIndex;
|
var currentUserName;
|
$(document).on("click", "input[name='erp_purchaseapplication_dtl.materielinfo_code']", function () {
|
var $type = getQueryVariable("type");
|
var $classfy = "";
|
if ($type == undefined || $type == '')
|
$type = initItems.Type + '';
|
switch ($type) {
|
case "1"://主材采购申请
|
$classfy = "01";
|
break;
|
case "2"://辅材采购申请
|
$classfy = "02";
|
break;
|
case "3"://施工方/措施费
|
$classfy = "99";
|
break;
|
case "4"://房产采购
|
$classfy = "05";//固定资产
|
break;
|
case "5"://机械设备采购
|
//$classfy = "050001,050003";
|
$classfy = "";
|
break;
|
case "6"://固定资产/周转材料
|
$classfy = "04,05,06";
|
break;
|
case "8"://行政办公设备/行政车辆
|
$classfy = "07,08,09,05,040007";
|
break;
|
case "801":///行政办公设备
|
$classfy = "07,08,09,050006";
|
break;
|
case "802":///行政车辆
|
$classfy = "050005,040007,060003,030002";
|
break;
|
case "803":///电脑、打印机、会议系统
|
$classfy = "050007";
|
break;
|
case "9"://设备维修/改装
|
$classfy = "99";
|
break;
|
case "901"://设备委外维修
|
$classfy = "99";
|
break;
|
case "902"://设备改造
|
$classfy = "99";
|
break;
|
case "10"://桩机配件
|
$classfy = "06,02";
|
break;
|
case "13"://运输费用
|
$classfy = "99";
|
break;
|
}
|
if ($classfy == "99") return;
|
tabIndex = $(this).closest('tr').index();
|
layer.open({
|
type: 2,
|
title: '物资物料',
|
shadeClose: true,
|
shade: 0.4,
|
area: ['80%', '80%'],
|
//content: "/Article/index?type=" + $classfy
|
content: "/Article/index"
|
});
|
});
|
|
setBaseInfo = function (materialCode, materialName, resourceClassificationId, resourceClassificationName, specificationModel, measurementUnit, index, measurementUnitName, resourceClassificationSupName) {
|
//console.log(materialCode, materialName, resourceClassificationId, resourceClassificationName, specificationModel, measurementUnit, index, measurementUnitName, resourceClassificationSupName)
|
if (hasRepeat(materialCode)) {
|
layer.alert("明细中已存在[" + materialName + "(" + materialCode + ")],不能重复添加!");
|
return;
|
}
|
materialTypeObj[materialCode] = { typeId: resourceClassificationId, typeName: resourceClassificationName };
|
var $row = $("table tr:eq(" + tabIndex + ")");
|
$row.find("input[field='materielinfo_code']").val(materialCode);
|
$row.find("input[field='materielinfoName']").val(materialName);
|
$row.find("input[field='Unit']").val(measurementUnitName);
|
$row.find("input[field='model']").val(specificationModel);
|
|
layer.closeAll();
|
}
|
|
initData = function () {
|
//debugger;
|
NumberBind();
|
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);
|
}
|
}
|
});
|
}
|
RefreshName();
|
|
$("#erp_purchaseapplication_TotalPrice").attr("disabled", "disabled");
|
$("#erp_purchaseapplication_orderCode").attr("disabled", "disabled");
|
$("#erp_purchaseapplication_createtime").attr("disabled", "disabled");
|
$("#erp_purchaseapplication_name").attr("disabled", "disabled");
|
// 设置type
|
var type = '';
|
if (window.taskid === '') {
|
type = getQueryVariable("type");
|
} else {
|
type = initItems.Type;
|
}
|
if (type == '801' || type == '802' || type == '803' || type == '901' || type == '902') {
|
var hiddenHtml = '<input type="hidden" id="erp_purchaseapplication_Type" name="erp_purchaseapplication.Type" field="Type" class="form-control" isvalid="yes" value="' + type + '">';
|
$("#erp_purchaseapplication_orderCode").after(hiddenHtml);
|
}
|
|
BindShowProjectEvent();
|
|
//电脑会议 申请
|
if (type=='803') {
|
//如果单据归属有值 动态设置项目是否显示
|
if ($('[name="erp_purchaseapplication.IsProject"][checked="checked"]').val() == 'false') {
|
$('.main>div').eq(4).show();
|
} else {
|
$('.main>div').eq(4).hide();
|
}
|
}
|
|
|
if ($.trim(sysid) != '' && initItems != null && type == '803') {
|
var sprintbtn = '<span style="position: absolute;right:200px;"><a onclick="" href="/erp/Erp_Purchaseapplication/PrintOrder?flowid=' + flowid + '&taskid=' + taskid + '" target="_blank" style="font-size:12px;"><img src="../../img/ico/printer.png" />单据打印</a></span>';
|
$('#txtTitle').append(sprintbtn);
|
}
|
}
|
|
RefreshName = function () {
|
if (window.taskid === '') {
|
var $type = getQueryVariable("type");
|
if ($type == undefined || $type == '') $type = initItems.Type;
|
var $title = "";
|
switch ($type) {
|
case "1":
|
$("#txtTitle").html("主材采购申请");
|
$title = "主材采购申请" + "(" + currentUserName + ")";
|
break;
|
case "2":
|
$("#txtTitle").html("辅材采购申请");
|
$title = "辅材采购申请" + "(" + currentUserName + ")";
|
break;
|
case "3":
|
$("#txtTitle").html("施工费/措施费采购申请");
|
$title = "施工费/措施费采购申请" + "(" + currentUserName + ")";
|
break;
|
case "4":
|
$("#txtTitle").html("房产采购申请");
|
$title = "房产采购申请" + "(" + currentUserName + ")";
|
break;
|
case "5":
|
$("#txtTitle").html("机械设备采购申请");
|
$title = "机械设备采购申请" + "(" + currentUserName + ")";
|
break;
|
case "6":
|
$("#txtTitle").html("固定资产/周转材料采购申请");
|
$title = "固定资产/周转材料采购申请" + "(" + currentUserName + ")";
|
break;
|
case "8":
|
$("#txtTitle").html("行政办公设备/行政车辆采购申请");
|
$title = "行政办公设备/行政车辆采购申请" + "(" + currentUserName + ")";
|
break;
|
case "801":
|
$("#txtTitle").html("行政办公设备采购申请");
|
$title = "行政办公设备采购申请" + "(" + currentUserName + ")";
|
break;
|
case "802":
|
$("#txtTitle").html("行政车辆采购申请");
|
$title = "行政车辆采购申请" + "(" + currentUserName + ")";
|
break;
|
case "803":
|
$("#txtTitle").html("电脑/打印机/会议系统采购申请");
|
$title = "电脑/打印机/会议系统采购申请" + "(" + currentUserName + ")";
|
break;
|
case "9":
|
$("#txtTitle").html("设备维修/改装采购申请");
|
$title = "设备维修/改装采购申请" + "(" + currentUserName + ")";
|
break;
|
case "901":
|
$("#txtTitle").html("设备委外维修");
|
$title = "设备委外维修采购申请" + "(" + currentUserName + ")";
|
break;
|
case "902":
|
$("#txtTitle").html("设备改造采购申请");
|
$title = "设备改造采购申请" + "(" + currentUserName + ")";
|
break;
|
case "10":
|
$("#txtTitle").html("桩机配件采购申请");
|
$title = "桩机配件采购申请" + "(" + currentUserName + ")";
|
break;
|
case "11":
|
$("#txtTitle").html("设备部劳务班组费用");
|
$title = "设备部劳务班组费用" + "(" + currentUserName + ")";
|
break;
|
case "13":
|
$("#txtTitle").html("运输费用");
|
$title = "运输费用" + "(" + currentUserName + ")";
|
break;
|
}
|
$("#erp_purchaseapplication_name").val($title);
|
} else {
|
var $type = initItems.Type + '';
|
switch ($type) {
|
case "1":
|
$("#txtTitle").html("主材采购申请");
|
break;
|
case "2":
|
$("#txtTitle").html("辅材采购申请");
|
break;
|
case "3":
|
$("#txtTitle").html("施工费/措施费采购申请");
|
break;
|
case "4":
|
$("#txtTitle").html("房产采购申请");
|
break;
|
case "5":
|
$("#txtTitle").html("机械设备采购申请");
|
break;
|
case "6":
|
$("#txtTitle").html("固定资产/周转材料采购申请");
|
break;
|
case "8":
|
$("#txtTitle").html("行政办公设备/行政车辆采购申请");
|
break;
|
case "801":
|
$("#txtTitle").html("行政办公设备采购申请");
|
break;
|
case "802":
|
$("#txtTitle").html("行政车辆采购申请");
|
break;
|
case "803":
|
$("#txtTitle").html("电脑、打印机、会议系统采购申请");
|
break;
|
case "9":
|
$("#txtTitle").html("设备维修/改装采购申请");
|
break;
|
case "901":
|
$("#txtTitle").html("设备委外维修采购申请");
|
break;
|
case "902":
|
$("#txtTitle").html("设备改造采购申请");
|
break;
|
case "10":
|
$("#txtTitle").html("桩机配件采购申请");
|
break;
|
case "11":
|
$("#txtTitle").html("设备部劳务班组费用");
|
break;
|
case "13":
|
$("#txtTitle").html("运输费用");
|
break;
|
}
|
}
|
}
|
|
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).toFixed(2);
|
} else {
|
price = $(this).find("#erp_purchaseapplication_dtl_TotalPrice").val();
|
if (price !== null && price > 0)
|
total += accMul(1.0, price).toFixed(2);
|
}
|
});
|
$("#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_Classfy", function () {
|
var $name = $("#erp_purchaseapplication_Classfy").find("option:selected").text();
|
var $txttitle = $name + "_采购申请(" + currentUserName + ")";
|
$("#erp_purchaseapplication_name").val($txttitle);
|
});
|
|
deleteMethod = function (tr) {
|
totalcompute();
|
}
|
|
//添加事件回调操作
|
createMethod = function () {
|
NumberBind();
|
}
|
//BeforeSave = function (data) {
|
// data.MainData.name = changeTitle();
|
// return data;
|
//}
|
var materialTypeObj = [];
|
function changeTitle() {
|
$inputCodeList = $("#girdtable td [name='erp_purchaseapplication_dtl.materielinfo_code']");
|
// 去重
|
var codeObj = {};
|
$inputCodeList.each((i, input) => {
|
var code = input.value;
|
if (code in materialTypeObj) {
|
type = materialTypeObj[code];
|
codeObj[type.typeId] = type.typeName;
|
}
|
})
|
var typeName = "";
|
for (let code in codeObj) {
|
if (!typeName)
|
typeName = codeObj[code];
|
else
|
typeName += "," + codeObj[code];
|
}
|
typeName = typeName ? `[${typeName}]` : "";
|
var user = currentUserName ? `(${currentUserName})` : "";
|
var projectName = $("#erp_purchaseapplication_project_id option:selected").text();
|
var title = projectName + typeName + user;
|
return title;
|
}
|
|
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 "";
|
}
|
|
hasRepeat = function (value) {
|
var $array = [];
|
$(".grid tbody tr").each(function () {
|
if ($(this).find('#erp_purchaseapplication_dtl_materielinfo_code').val() != undefined)
|
$array.push($(this).find('#erp_purchaseapplication_dtl_materielinfo_code').val());
|
});
|
if ($array.Contains(value))
|
return true;
|
else return false;
|
}
|
|
Array.prototype.Contains = function (val) {
|
for (var i = 0; i < this.length; i++) {
|
if (this[i] == val) {
|
return true;
|
}
|
}
|
return false;
|
};
|
|
NumberBind = function () {
|
$("[name='erp_purchaseapplication_dtl.count']").addClass("countTxtBox");
|
$("[name='erp_purchaseapplication_dtl.Price']").addClass("priceTxtBox");
|
NumberBoxBind();
|
}
|
|
//绑定是否显示项目下拉事件
|
BindShowProjectEvent = function () {
|
if ($('[name="erp_purchaseapplication.IsProject"]').length > 0) {
|
$('[name="erp_purchaseapplication.IsProject"]').click(function () {
|
if ($(this).val() == 'false') {
|
$('.main>div').eq(4).show();
|
} else {
|
$('.main>div').eq(4).hide();
|
}
|
});
|
}
|
}
|