var acceptClick;
var selectBomInfo;
var calQty;
var BillBomInfo = [];
var BillBomSetInfos = [];
var BillBomSetInfos2 = [];
var BillBomSetInfos3 = [];
var BillBomSetInfos4 = [];
var BillBomSetInfos5 = [];
var BillBomSetInfos6 = [];
var BomsetCode = '';
var keyValue = request('keyValue');
var bootstrap = function ($, learun) {
"use strict";
var classnames = ['yellowCircle', 'purpleCircle', 'lightgreenCircle'];
var reg = /^(\-|\+)?\d+(\.\d+)?$/;
var regex = /^[1-9]\d*$/;
const IsEmptys = ["有"];//["", "有", "无"]; //是否放置物料
const SpoolTypes = ["WS18"]; //工字轮型号
const SideNums = ["", "正面朝上", "反面朝上"]; //工字轮朝向
const IsCores = ["", "是", "否"]; //是否芯股
const SilkTypes = ["", "单丝", "双丝", "三丝"]; //单双丝
const mattypes = ["第一种", "第二种", "第三种"];
const StampChildTypes = ["DOF4-01", "DOF4-02", "DOF4-03", "DOF4-04", "DOF4-05", "DOF4-06"];
var selectedRow = learun.frameTab.currentIframe().selectedRow;
var page = {
init: function () {
page.bind();
page.initData();
},
bind: function () {
// 设置小圆圈的点击事件
//$('.circle').click(function () {
// $(this).toggleClass('selectedactive');
//});
for (let j = 0; j < IsCores.length; j++) {
if (IsCores[j] == '') {
$("#IsTruss").append($(""));
} else if (IsCores[j] == '否') {
$("#IsTruss").append($(""));
}
else {
$("#IsTruss").append($(""));
}
}
for (let i = 0; i < StampChildTypes.length; i++) {
let id = i + 1;
$("#StampChildType").append($(""));
}
$("#StampChildType").on('change', function () {
for (let i = 0; i < StampChildTypes.length; i++) {
let id = i + 1;
if ($(this).val() == id) {
$("#StampChildType" + id).show();
}
else {
$("#StampChildType" + id).hide();
}
}
});
$("#StampChildType").val(1).change();
for (let i = 0; i < 3; i++) {
for (let j = 0; j < IsEmptys.length; j++) {
if (IsEmptys[j] == '') {
$("#IsEmpty" + i).append($(""));
}
else {
var value = j ;
$("#IsEmpty" + i).append($(""));
}
}
for (let j = 0; j < SpoolTypes.length; j++) {
if (SpoolTypes[j] == '') {
$("#SpoolType" + i).append($(""));
}
else {
$("#SpoolType" + i).append($(""));
}
}
for (let j = 0; j < SideNums.length; j++) {
if (SideNums[j] == '') {
$("#SideNum" + i).append($(""));
}
else {
$("#SideNum" + i).append($(""));
}
}
for (let j = 0; j < IsCores.length; j++) {
if (IsCores[j] == '') {
$("#IsCore" + i).append($(""));
}
else {
$("#IsCore" + i).append($(""));
}
}
for (let j = 0; j < SilkTypes.length; j++) {
if (SilkTypes[j] == '') {
$("#SilkType" + i).append($(""));
}
else {
$("#SilkType" + i).append($(""));
}
}
}
//$('#ProMaterCode').lrselect({
// url: top.$.rootUrl + "/FJManager/BaseMatinfo/GetList",
// allowSearch: true,
// width: 280,
//});
//$("#HWCountQty").on('change', function () {
// calQty();
//});
$('#SelectBomCode').on('click', function () {
learun.layerForm({
id: 'SelectBomCodeform',
title: '查询',
url: top.$.rootUrl + '/FJManager/BillBomInfo/SelectForm?SpoolType=' + SpoolTypes,
width: 1150,
height: 690,
callBack: function (id) {
return top[id].acceptClick(selectBomInfo);
},
});
});
// 设置小圆圈的点击事件
$('.clickcircle').click(function () {
for (var i = 0; i < classnames.length; i++) {
if ($(this).attr('class').indexOf(classnames[i]) >= 0) {
$(this).removeClass(classnames[i]);
$(this).removeClass('bordercircle18');
$(this).addClass('circle18');
$(this).addClass('selectedactive');
page.DelBillBomsetinfo($(this).text());
}
}
$(this).removeProp("data-geo");
$(this).toggleClass('selectedactive');
});
$("#SaveOne").on('click', function () {
if ($('#MatCode0').val() == '') {
learun.alert.info("请输入第一种湿拉物料!");
return;
}
if ($("#IsEmpty0").val() == '') {
learun.alert.info("请选择是否有货物!");
return;
}
if (page.CheckData(0)) {
$("#allcontainer > div").children().each(function () {
var classname = $(this).attr('class');
if (classname.indexOf('selectedactive') >= 0) {
$(this).removeClass('selectedactive');
$(this).addClass(classnames[0]);
if ($("#SideNum0").val() == "2") {
$(this).removeClass('circle18');
$(this).addClass('bordercircle18');
}
page.AddBillBomsetinfo(0, $(this).text());
$(this).prop("data-geo", "工字轮型号: " + $("#SpoolType0").val() + ",工字轮朝向:" + SideNums[$("#SideNum0").val()] + ",是否芯股:" + IsCores[$("#IsCore0").val()] + ",单双丝:" + SilkTypes[$("#SilkType0").val()]);
}
});
}
});
$("#SaveTwo").on('click', function () {
if ($('#MatCode1').val() == '') {
learun.alert.info("请输入第二种湿拉物料!");
return;
}
if ($("#IsEmpty1").val() == '') {
learun.alert.info("请选择是否有货物!");
return;
}
if (page.CheckData(1)) {
$("#allcontainer > div").children().each(function () {
var classname = $(this).attr('class');
if (classname.indexOf('selectedactive') >= 0) {
$(this).removeClass('selectedactive');
$(this).addClass(classnames[1]);
if ($("#SideNum1").val() == "2") {
$(this).removeClass('circle18');
$(this).addClass('bordercircle18');
}
page.AddBillBomsetinfo(1, $(this).text());
$(this).prop("data-geo", "工字轮型号: " + $("#SpoolType1").val() + ",工字轮朝向:" + SideNums[$("#SideNum1").val()] + ",是否芯股:" + IsCores[$("#IsCore1").val()] + ",单双丝:" + SilkTypes[$("#SilkType1").val()]);
}
});
}
});
$("#SaveThree").on('click', function () {
if ($('#MatCode2').val() == '') {
learun.alert.info("请输入第三种湿拉物料!");
return;
}
if ($("#IsEmpty2").val() == '') {
learun.alert.info("请选择是否有货物!");
return;
}
if (page.CheckData(2)) {
$("#allcontainer > div").children().each(function () {
var classname = $(this).attr('class');
if (classname.indexOf('selectedactive') >= 0) {
$(this).removeClass('selectedactive');
$(this).addClass(classnames[2]);
if ($("#SideNum2").val() == "2") {
$(this).removeClass('circle18');
$(this).addClass('bordercircle18');
}
page.AddBillBomsetinfo(2, $(this).text());
$(this).prop("data-geo", "工字轮型号: " + $("#SpoolType2").val() + ",工字轮朝向:" + SideNums[$("#SideNum2").val()] + ",是否芯股:" + IsCores[$("#IsCore2").val()] + ",单双丝:" + SilkTypes[$("#SilkType2").val()]);
}
});
}
});
//$(".left [dfm]").on('click', function () {
// $("#dialog").show();
// let circleid = $(this).attr('dfm');
// layer.open({
// type: 1,
// area: ['600px', '360px'],
// shadeClose: true,
// //modal: true,
// content: $("#dialog"),
// btns: 2,
// btn: ['确定', '取消'],
// modal: true,
// success: function () {
// },
// end: function () {
// $("#dialog").hide();
// },
// //close: function (index) {
// // $("#dialog").hide();
// //},
// yes: function (index) {
// //layer.msg('您选择了重要。', 2, 1);
// //$(this).dialog("close");
// /* $(this).closeAll("dialog");*/
// if (circleid==1)
// $("#" + circleid).addClass("havegoods");
// if (circleid == 5)
// $("#" + circleid).addClass("Sideout");
// $("#5").removeClass("Sideout");
// layer.closeAll();
// },
// //no: function (index) {
// //}
// });
//});
},
AddBillBomsetinfo: function (i, xyno) {
var setinfo = {};
setinfo["XYNo"] = xyno;
setinfo["CategoryId"] = i;
setinfo["MatCode"] = $("#MatCode" + i).val();
setinfo["SilkDiam"] = $("#SilkDiam" + i).val();
setinfo["QtyMaxCount"] = $("#QtyMaxCount" + i).val();
setinfo["IsEmpty"] = $("#IsEmpty" + i).val();
setinfo["SpoolType"] = $("#SpoolType" + i).val();
setinfo["SideNum"] = $("#SideNum" + i).val();
setinfo["IsCore"] = $("#IsCore" + i).val();
setinfo["SilkType"] = $("#SilkType" + i).val();
if ($("#StampChildType").val() == '1') {
BillBomSetInfos.push(setinfo);
}
else if ($("#StampChildType").val() == '2') {
BillBomSetInfos2.push(setinfo);
} else if ($("#StampChildType").val() == '3') {
BillBomSetInfos3.push(setinfo);
} else if ($("#StampChildType").val() == '4') {
BillBomSetInfos4.push(setinfo);
} else if ($("#StampChildType").val() == '5') {
BillBomSetInfos5.push(setinfo);
} else if ($("#StampChildType").val() == '6') {
BillBomSetInfos6.push(setinfo);
}
},
DelBillBomsetinfo: function (xyno) {
if ($("#StampChildType").val() == '1') {
for (let j = 0; j < BillBomSetInfos.length; j++) {
if (xyno == BillBomSetInfos[j].XYNo) {
BillBomSetInfos.splice(j, 1);
}
}
}
else if ($("#StampChildType").val() == '2') {
for (let j = 0; j < BillBomSetInfos2.length; j++) {
if (xyno == BillBomSetInfos2[j].XYNo) {
BillBomSetInfos2.splice(j, 1);
}
}
} else if ($("#StampChildType").val() == '3') {
for (let j = 0; j < BillBomSetInfos3.length; j++) {
if (xyno == BillBomSetInfos3[j].XYNo) {
BillBomSetInfos3.splice(j, 1);
}
}
}
else if ($("#StampChildType").val() == '4') {
for (let j = 0; j < BillBomSetInfos4.length; j++) {
if (xyno == BillBomSetInfos4[j].XYNo) {
BillBomSetInfos4.splice(j, 1);
}
}
}
else if ($("#StampChildType").val() == '5') {
for (let j = 0; j < BillBomSetInfos5.length; j++) {
if (xyno == BillBomSetInfos5[j].XYNo) {
BillBomSetInfos5.splice(j, 1);
}
}
} else if ($("#StampChildType").val() == '6') {
for (let j = 0; j < BillBomSetInfos6.length; j++) {
if (xyno == BillBomSetInfos6[j].XYNo) {
BillBomSetInfos6.splice(j, 1);
}
}
}
},
CheckData: function (i) {
if ($('#MatCode' + i).val() != '') {
//let qty2 = $('#SilkDiam' + i).val();
//if (!reg.test(qty2) || parseFloat(qty2) == 0) {
// learun.alert.error('请输入' + mattypes[i] +'湿拉物料的钢丝直径上限');
// return false;
//}
//let count = $('#QtyMaxCount' + i).val();
//if (!reg.test(count) || parseInt(count) == 0) {
// learun.alert.error('请输入' + mattypes[i] +'湿拉物料的数量');
// return false;
//}
let empty = $('#IsEmpty' + i).val();
if (empty == '') {
learun.alert.error('请选择' + mattypes[i] + '湿拉物料是否放置物料');
return false;
}
let SpoolType = $('#SpoolType' + i).val();
if (SpoolType == '') {
learun.alert.error('请选择' + mattypes[i] + '湿拉物料工字轮型号');
return false;
}
let SideNum = $('#SideNum' + i).val();
if (SideNum == '') {
learun.alert.error('请选择' + mattypes[i] + '湿拉物料工字轮朝向');
return false;
}
let IsCore = $('#IsCore' + i).val();
if (IsCore == '') {
learun.alert.error('请选择' + mattypes[i] + '湿拉物料是否芯股');
return false;
}
let SilkType = $('#SilkType' + i).val();
if (SilkType == '') {
learun.alert.error('请选择' + mattypes[i] + '湿拉物料单双丝');
return false;
}
}
return true;
},
change: function (classname) {
$("#allcontainer > div").children().each(function () {
var classname = $(this).attr('class');
if (classname.indexOf('selectedactive') >= 0) {
$(this).removeClass('selectedactive');
$(this).addClass(classname);
}
});
},
initData: function () {
if (!!keyValue) {
learun.httpAsync('GET', top.$.rootUrl + '/FJManager/BillBomSet/GetBillBomsetinfo', { id: keyValue }, function (res) {
if (res.code > 0) {
let BomsetInfo = res.data;
if (BomsetInfo.StampChildType == 1) {
BillBomSetInfos = BomsetInfo.Bomsetinfos;
} else if (BomsetInfo.StampChildType == 2) {
BillBomSetInfos2 = BomsetInfo.Bomsetinfos;
} else if (BomsetInfo.StampChildType == 3) {
BillBomSetInfos3 = BomsetInfo.Bomsetinfos;
} else if (BomsetInfo.StampChildType == 4) {
BillBomSetInfos4 = BomsetInfo.Bomsetinfos;
} else if (BomsetInfo.StampChildType == 5) {
BillBomSetInfos5 = BomsetInfo.Bomsetinfos;
} else if (BomsetInfo.StampChildType == 6) {
BillBomSetInfos6 = BomsetInfo.Bomsetinfos;
}
//$('#ProMaterCode').lrselectRefresh({
// url: top.$.rootUrl + "/FJManager/BaseMatinfo/GetListByBomCode",
// param: { queryJson: JSON.stringify({ Code: BomsetInfo.BomCode }) },
// allowSearch: true,
// width: 280,
//});
$("#StampChildType").val(BomsetInfo.StampChildType).change();
$("#StampChildType" + BomsetInfo.StampChildType).show();
for (var i = 0; i < BomsetInfo.Bomsetinfos.length; i++) {
var item = BomsetInfo.Bomsetinfos[i];
$("#MatCode" + item.CategoryId).val(item.MatCode);
$("#SilkDiam" + item.CategoryId).val(item.SilkDiam);
$("#QtyMaxCount" + item.CategoryId).val(item.QtyMaxCount);
$("#IsEmpty" + item.CategoryId).val(item.IsEmpty);
$("#SpoolType" + item.CategoryId).val(item.SpoolType);
$("#SideNum" + item.CategoryId).val(item.SideNum);
$("#IsCore" + item.CategoryId).val(item.IsCore);
$("#SilkType" + item.CategoryId).val(item.SilkType);
$("#StampChildType" + BomsetInfo.StampChildType).children().each(function () {
var id = $(this).text();
if (item.XYNo == id) {
if ($("#SideNum" + item.CategoryId).val() == "2") {
$(this).removeClass('circle18');
$(this).addClass('bordercircle18');
}
$(this).removeClass('selectedactive');
$(this).addClass(classnames[item.CategoryId]);
$(this).prop("data-geo", "工字轮型号: " + item.SpoolType + ",工字轮朝向:" + SideNums[item.SideNum] + ",是否芯股:" + IsCores[item.IsCore] + ",单双丝:" + SilkTypes[item.SilkType]);
}
});
//$("#allcontainer > div").children().each(function () {
// var id = $(this).text();
// if (item.XYNo == id) {
// $(this).removeClass('selectedactive');
// $(this).addClass(classnames[item.CategoryId]);
// }
//});
}
BomsetCode = BomsetInfo.BomCode;
$("#BomName").val(BomsetInfo.BomName);
setTimeout($('#form').lrSetFormData(res.data), 300);
//learun.httpAsync('GET', top.$.rootUrl + '/FJManager/BillBomInfo/GetList', { queryJson: JSON.stringify({ Code: BomsetInfo.BomCode, SpoolType: SpoolTypes }) }, function (res) {
// if (res.code > 0) {
// $("#BomName").val(res.data[0].Name);
// }
//});
}
});
}
}
};
calQty = function () {
//var totalQty = 0;
//for (var i = 0; i < BillBomInfo.length; i++) {
// totalQty += parseInt(BillBomInfo[i].HWCountQty);
//}
//var HWCountQty = $("#HWCountQty").val();
for (var i = 0; i < BillBomInfo.length; i++) {
$("#MatCode" + i).val(BillBomInfo[i].MatCode);
//if (HWCountQty != "" && reg.test(HWCountQty)) {
// var qty = Math.round(parseInt(HWCountQty) / totalQty);
// $("#QtyMaxCount" + i).val(qty * parseInt(BillBomInfo[i].HWCountQty));
//}
}
}
selectBomInfo = function (rowData) {
if (!!rowData) {
$("#BomName").val('');
//$("#BomName").val(code);
learun.httpAsync('GET', top.$.rootUrl + '/FJManager/BillBomInfo/GetList', { queryJson: JSON.stringify({ ProCode: rowData.ProCode, SpoolType: SpoolTypes, Code: rowData.Code }) }, function (res) {
if (res.code > 0) {
$(".lr-select-placeholder").empty();
//$("#learun_select_option_contentProMaterCode").children().empty();
//$('#ProMaterCode').lrselectRefresh({
// url: top.$.rootUrl + "/FJManager/BaseMatinfo/GetListByBomCode",
// param: { queryJson: JSON.stringify({ Code: code }) },
// allowSearch: true,
// width: 280,
//});
for (var i = 0; i < 3; i++) {
$("#MatCode" + i).val('');
}
$("#BomName").val(res.data[0].Name);
$("#ProMaterCode").val(res.data[0].ProMatCode);
BomsetCode = res.data[0].ProCode;
BillBomInfo = res.data;
calQty();
}
});
}
};
// 保存数据
acceptClick = function (callBack) {
if (!$('#form').lrValidform()) {
return false;
}
if ($("#BomName").val() == '') {
learun.alert.error('请输入投料信息');
return false;
}
let checkdata = false;
for (var i = 0; i < mattypes.length; i++) {
checkdata = page.CheckData(i);
}
if (!checkdata) {
return;
}
var postData = $('#form').lrGetFormData();
postData.StampChildType = $("#StampChildType").val();
//var setInfos = [];
//$("#allcontainer > div").children().each(function () {
//$("#StampChildType" + postData.StampChildType).children().each(function () {
// for (var i = 0; i < classnames.length; i++) {
// var setinfo = {};
// if ($(this).attr('class').indexOf(classnames[i]) >= 0) {
// setinfo["XYNo"] = $(this).text();
// setinfo["CategoryId"] = i;
// setinfo["MatCode"] = $("#MatCode" + i).val();
// setinfo["SilkDiam"] = $("#SilkDiam" + i).val();
// setinfo["QtyMaxCount"] = $("#QtyMaxCount" + i).val();
// setinfo["IsEmpty"] = $("#IsEmpty" + i).val();
// setinfo["SpoolType"] = $("#SpoolType" + i).val();
// setinfo["SideNum"] = $("#SideNum" + i).val();
// setinfo["IsCore"] = $("#IsCore" + i).val();
// setinfo["SilkType"] = $("#SilkType" + i).val();
// setInfos.push(setinfo);
// }
// }
//});
if (!$('#form').lrValidform()) {
return false;
}
if ($("#StampChildType").val() == '1' && BillBomSetInfos.length == 0) {
learun.alert.error('请选择跺型编号。');
return false;
}
else if ($("#StampChildType").val() == '2' && BillBomSetInfos2.length == 0) {
learun.alert.error('请选择跺型编号。');
return false;
} else if ($("#StampChildType").val() == '3' && BillBomSetInfos3.length == 0) {
learun.alert.error('请选择跺型编号。');
return false;
} else if ($("#StampChildType").val() == '4' && BillBomSetInfos4.length == 0) {
learun.alert.error('请选择跺型编号。');
return false;
} else if ($("#StampChildType").val() == '5' && BillBomSetInfos5.length == 0) {
learun.alert.error('请选择跺型编号。');
return false;
} else if ($("#StampChildType").val() == '6' && BillBomSetInfos6.length == 0) {
learun.alert.error('请选择跺型编号。');
return false;
}
postData.BomName = $("#BomName").val();
postData.ProCode = BomsetCode;
postData.Category = 1;
postData.StampType = 3;
postData.TotalQty = $(".clickcircle").length;
if ($("#StampChildType").val() == '1') {
postData.Bomsetinfos = BillBomSetInfos;
postData.TotalQty = $("#StampChildType1 .clickcircle").length;
}
else if ($("#StampChildType").val() == '2') {
postData.Bomsetinfos = BillBomSetInfos2;
postData.TotalQty = $("#StampChildType2 .clickcircle").length;
} else if ($("#StampChildType").val() == '3') {
postData.Bomsetinfos = BillBomSetInfos3;
postData.TotalQty = $("#StampChildType3 .clickcircle").length;
} else if ($("#StampChildType").val() == '4') {
postData.Bomsetinfos = BillBomSetInfos4;
postData.TotalQty = $("#StampChildType4 .clickcircle").length;
} else if ($("#StampChildType").val() == '5') {
postData.Bomsetinfos = BillBomSetInfos5;
postData.TotalQty = $("#StampChildType5 .clickcircle").length;
}
else if ($("#StampChildType").val() == '6') {
postData.Bomsetinfos = BillBomSetInfos6;
postData.TotalQty = $("#StampChildType6 .clickcircle").length;
}
$.lrSaveForm(top.$.rootUrl + '/FJManager/BillBomSet/SaveForm?keyValue=' + keyValue, postData, function (res) {
// 保存成功后才回调
if (!!callBack) {
callBack();
}
});
};
page.init();
}
$(document).tooltip({
items: "img, [data-geo], [title]",
content: function () {
var element = $(this);
if (element.is("[data-geo]")) {
return element.prop("data-geo");
}
if (element.is("[title]")) {
return element.prop("title");
}
if (element.is("img")) {
return element.prop("alt");
}
}
});