123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598 |
- var acceptClick;
- var selectBomInfo;
- var calQty;
- var BillBomInfo = [];
- var BillBomSetInfos = [];
- var BillBomSetInfos2 = [];
- var BillBomSetInfos3 = [];
- var BillBomSetInfos4 = [];
- 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 = ["WS50"]; //工字轮型号
- const SideNums = ["", "正面朝上", "反面朝上"]; //工字轮朝向
- const IsCores = ["", "是", "否"]; //是否芯股
- const SilkTypes = ["", "单丝", "双丝", "三丝"]; //单双丝
- const mattypes = ["第一种", "第二种", "第三种"];
- const StampChildTypes = ["DOF2-01", "DOF2-02", "DOF2-03", "DOF2-04"];
- var selectedRow = learun.frameTab.currentIframe().selectedRow;
- var page = {
- init: function () {
- page.bind();
- page.initData();
- },
- bind: function () {
- // 设置小圆圈的点击事件
- //$('.circle').click(function () {
- // $(this).toggleClass('selectedactive');
- //});
- for (var i = 0; i < StampChildTypes.length; i++) {
- let id = i + 1;
- $("#StampChildType").append($("<option value='" + id + "'>" + StampChildTypes[i] + "</option>"));
- }
- $("#StampChildType").on('change', function () {
- for (var 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 (var i = 0; i < 3; i++) {
- for (var j = 0; j < IsEmptys.length; j++) {
- if (IsEmptys[j] == '') {
- $("#IsEmpty" + i).append($("<option value=''>请选择</option>"));
- }
- else {
- var value = j;
- $("#IsEmpty" + i).append($("<option value='" + value + "'>" + IsEmptys[j] + "</option>"));
- }
- }
- for (var j = 0; j < SpoolTypes.length; j++) {
- if (SpoolTypes[j] == '') {
- $("#SpoolType" + i).append($("<option value=''>请选择</option>"));
- }
- else {
- $("#SpoolType" + i).append($("<option value='" + SpoolTypes[j] + "'>" + SpoolTypes[j] + "</option>"));
- }
- }
- for (var j = 0; j < SideNums.length; j++) {
- if (SideNums[j] == '') {
- $("#SideNum" + i).append($("<option value=''>请选择</option>"));
- }
- else {
- $("#SideNum" + i).append($("<option value='" + j + "'>" + SideNums[j] + "</option>"));
- }
- }
- for (var j = 0; j < IsCores.length; j++) {
- if (IsCores[j] == '') {
- $("#IsCore" + i).append($("<option value=''>请选择</option>"));
- }
- else {
- $("#IsCore" + i).append($("<option value='" + j + "'>" + IsCores[j] + "</option>"));
- }
- }
- for (var j = 0; j < SilkTypes.length; j++) {
- if (SilkTypes[j] == '') {
- $("#SilkType" + i).append($("<option value=''>请选择</option>"));
- }
- else {
- $("#SilkType" + i).append($("<option value='" + j + "'>" + SilkTypes[j] + "</option>"));
- }
- }
- }
- //$('#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 (let i = 0; i < classnames.length; i++) {
- if ($(this).attr('class').indexOf(classnames[i]) >= 0) {
- $(this).removeClass(classnames[i]);
- $(this).removeClass('bordercircle');
- $(this).addClass('circle');
- $(this).addClass('selectedactive');
- page.DelBillBomsetinfo($(this).text());
- }
- }
- $(this).removeProp("data-geo");
- //$(this).prop("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('circle');
- $(this).addClass('bordercircle');
- }
- 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('circle');
- $(this).addClass('bordercircle');
- }
- 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('circle');
- $(this).addClass('bordercircle');
- }
- 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) {
- //page.DelBillBomsetinfo(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);
- }
- },
- 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);
- }
- }
- }
- },
- AddBoardCircleClass(jqobject, i) {
- var classname = $(jqobject).attr('class');
- if (classname.indexOf('34') >= 0 && $("#SideNum" + i).val() == "2") {
- $(jqobject).removeClass('circle34');
- $(jqobject).addClass('bordercircle34');
- }
- else if (classname.indexOf('18') >= 0 && $("#SideNum" + i).val() == "2") {
- $(jqobject).removeClass('circle18');
- $(jqobject).addClass('bordercircle18');
- }
- else if ($("#SideNum" + i).val() == "2") {
- $(jqobject).removeClass('circle');
- $(jqobject).addClass('bordercircle');
- }
- },
- DelBoardCircleClass(jqobject) {
- var classname = $(jqobject).attr('class');
- if (classname.indexOf('34') >= 0) {
- $(jqobject).removeClass('bordercircle34');
- $(jqobject).addClass('circle34');
- }
- else if (classname.indexOf('18') >= 0) {
- $(jqobject).removeClass('bordercircle18');
- $(jqobject).addClass('circle18');
- }
- else {
- $(jqobject).removeClass('bordercircle');
- $(jqobject).addClass('circle');
- }
- },
- 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;
- }
- //$('#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('circle');
- $(this).addClass('bordercircle');
- }
- $(this).removeClass('selectedactive');
- $(this).addClass(classnames[item.CategoryId]);
- $(this).prop("data-geo", "工字轮型号: " + item.SpoolType + ",工字轮朝向:" + SideNums[item.SideNum] + ",是否芯股:" + IsCores[item.IsCore] + ",单双丝:" + SilkTypes[item.SilkType]);
- }
- });
- }
- 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();
- var setInfos = [];
- //$("#allcontainer > div").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;
- }
- postData.StampChildType = $("#StampChildType").val();
- postData.BomName = $("#BomName").val();
- postData.ProCode = BomsetCode;
- postData.Category = 1;
- postData.StampType = 2;
- 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;
- }
- $.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");
- }
- }
- });
|