123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 |
- var acceptClick;
- var selectBomInfo;
- var calQty;
- var BillBomInfo = [];
- var BomsetCode = '';
- var keyValue = request('keyValue');
- var bootstrap = function ($, learun) {
- "use strict";
- const SpoolTypes = ["WS09"]; //工字轮型号
- var classnames = ['yellowCircle', 'purpleCircle', 'lightgreenCircle'];
- var reg = /^(\-|\+)?\d+(\.\d+)?$/;
- var regex = /^[1-9]\d*$/;
-
- var page = {
- init: function () {
- page.bind();
- page.initData();
- },
- bind: function () {
- $('#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: 1050,
- 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).addClass('selectedactive');
- }
- }
- $(this).toggleClass('selectedactive');
- });
- $("#SaveOne").on('click', function () {
- var matcode0 = $("#MatCode0").val();
- if (matcode0 == "") {
- learun.alert.error('请输入第一种湿拉物料');
- return false;
- }
- var qty = $("#QtyMaxCount0").val();
- if (qty == "" && !reg.test(qty)) {
- learun.alert.error('请输入第一种湿拉物料的数量');
- return false;
- }
- var selectqty = $("#allcontainer > div").find("." + classnames[0]).length + $("#allcontainer > div").find(".selectedactive").length;
- if (parseInt(qty) != selectqty) {
- learun.alert.error('选择的数量与第一种湿拉物料的数量不相符!');
- return false;
- }
- $("#allcontainer > div").children().each(function () {
- var classname = $(this).attr('class');
- if (classname.indexOf('selectedactive') >= 0) {
- $(this).removeClass('selectedactive');
- $(this).addClass(classnames[0]);
- }
- });
- });
- $("#SaveTwo").on('click', function () {
- var matcode1 = $("#MatCode1").val();
- if (matcode1 == "") {
- learun.alert.error('请输入第二种湿拉物料');
- return false;
- }
- var qty = $("#QtyMaxCount1").val();
- if (qty == "" && !reg.test(qty)) {
- learun.alert.error('请输入第二种湿拉物料的数量');
- return false;
- }
- var selectqty = $("#allcontainer > div").find("." + classnames[1]).length + $("#allcontainer > div").find(".selectedactive").length;
- if (parseInt(qty) != selectqty) {
- learun.alert.error('选择的数量与第二种湿拉物料的数量不相符!');
- return false;
- }
- $("#allcontainer > div").children().each(function () {
- var classname = $(this).attr('class');
- if (classname.indexOf('selectedactive') >= 0) {
- $(this).removeClass('selectedactive');
- $(this).addClass(classnames[1]);
- }
- });
- });
- $("#SaveThree").on('click', function () {
- var matcode2 = $("#MatCode2").val();
- if (matcode2 == "") {
- learun.alert.error('请输入第三种湿拉物料');
- return false;
- }
- var qty = $("#QtyMaxCount2").val();
- if (qty == "" && !reg.test(qty)) {
- learun.alert.error('请输入第三种湿拉物料的数量');
- return false;
- }
- var selectqty = $("#allcontainer > div").find("." + classnames[2]).length + $("#allcontainer > div").find(".selectedactive").length;
- if (parseInt(qty) != selectqty) {
- learun.alert.error('选择的数量与第三种湿拉物料的数量不相符!');
- return false;
- }
- $("#allcontainer > div").children().each(function () {
- var classname = $(this).attr('class');
- if (classname.indexOf('selectedactive') >= 0) {
- $(this).removeClass('selectedactive');
- $(this).addClass(classnames[2]);
- }
- });
- });
- },
- 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;
- $('#ProMaterCode').lrselectRefresh({
- url: top.$.rootUrl + "/FJManager/BaseMatinfo/GetListByProCode",
- param: { queryJson: JSON.stringify({ Code: BomsetInfo.BomCode }) },
- allowSearch: true,
- width: 280,
- });
- 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);
- $("#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);
- learun.httpAsync('GET', top.$.rootUrl + '/FJManager/BillBomInfo/GetList', { queryJson: JSON.stringify({ ProCode: BomsetInfo.BomCode, SpoolType: SpoolTypes }) }, function (res) {
- if (res.code > 0) {
- BillBomInfo = res.data;
- calQty();
- }
- });
- 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);
- // }
- //});
- }
- });
- }
- }
- };
- 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) {
- //$('#ProMaterCode').lrselect({
- // url: top.$.rootUrl + "/FJManager/BaseMatinfo/GetListByBomCode",
- // param: { queryJson: JSON.stringify({ Code: code }) },
- // allowSearch: true,
- // width: 280,
- //});
- $(".lr-select-placeholder").empty();
- $("#learun_select_option_contentProMaterCode").children().empty();
- $('#ProMaterCode').lrselectRefresh({
- url: top.$.rootUrl + "/FJManager/BaseMatinfo/GetListByBomCode",
- param: { queryJson: JSON.stringify({ Code: rowData.Code }) },
- allowSearch: true,
- width: 280,
- });
- for (var i = 0; i < 3; i++) {
- $("#MatCode" + i).val('');
- }
- $("#BomName").val(res.data[0].Name);
- BomsetCode = res.data[0].ProCode;
- BillBomInfo = res.data;
- calQty();
- }
- });
- }
- };
- calQty = function () {
- var totalQty = 0;
- for (var i = 0; i < BillBomInfo.length; i++) {
- totalQty += parseInt(BillBomInfo[i].HWCountQty);
- }
- if (totalQty == 0) {
- totalQty = 1;
- }
- 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);
- if (BillBomInfo[i].HWCountQty == 0) {
- $("#QtyMaxCount" + i).val(qty);
- }
- else {
- $("#QtyMaxCount" + i).val(qty * parseInt(BillBomInfo[i].HWCountQty));
- }
- }
- }
- };
- // 保存数据
- acceptClick = function (callBack) {
- if (!$('#form').lrValidform()) {
- return false;
- }
- if ($("#BomName").val() == '') {
- learun.alert.error('请输入投料信息');
- return false;
- }
- var HWCountQty = $("#HWCountQty").val();
- if (HWCountQty == "" || parseInt(HWCountQty) == 0 || !reg.test(HWCountQty)) {
- learun.alert.error('请输入工字轮个数');
- return false;
- }
- var LayerCountQty = $("#LayerCountQty").val();
- if (LayerCountQty == "" || parseInt(LayerCountQty) == 0 || !regex.test(LayerCountQty)) {
- learun.alert.error('请输入层数');
- return false;
- }
- var ShortCode = $("#ShortCode").val();
- if (ShortCode == "" || parseInt(ShortCode) == 0 || !regex.test(ShortCode)) {
- learun.alert.error('请输入短编号');
- return false;
- }
- var matcode0 = $("#MatCode0").val();
- if (matcode0 != "") {
- var selectqty0 = $("#allcontainer > div").find("." + classnames[0]).length;
- if (selectqty0 == 0) {
- learun.alert.error('请选择第一种湿拉物料的跺型编号!');
- return false;
- }
- }
- var matcode1 = $("#MatCode1").val();
- if (matcode1 != "") {
- var selectqty1 = $("#allcontainer > div").find("." + classnames[1]).length;
- if (selectqty1 == 0) {
- learun.alert.error('请选择第二种湿拉物料的跺型编号!');
- return false;
- }
- }
- var matcode2 = $("#MatCode2").val();
- if (matcode2 != "") {
- var selectqty2 = $("#allcontainer > div").find("." + classnames[2]).length;
- if (selectqty2 == 0) {
- learun.alert.error('请选择第三种湿拉物料的跺型编号!');
- return false;
- }
- }
- var qty0 = $("#QtyMaxCount0").val();
- if (qty0 != "") {
- if (!reg.test(qty0) || parseInt(qty0) == 0) {
- learun.alert.error('请输入第一种湿拉物料的数量');
- return false;
- }
- else {
- var selectqty0 = $("#allcontainer > div").find("." + classnames[0]).length;
- if (parseInt(qty0) != selectqty0) {
- learun.alert.error('选择的数量与第一种湿拉物料的数量不相符!');
- return false;
- }
- }
- }
- var qty1 = $("#QtyMaxCount1").val();
- if (qty1 != "") {
- if (!reg.test(qty1) || parseInt(qty1) == 0) {
- learun.alert.error('请输入第二种湿拉物料的数量');
- return false;
- }
- else {
- var selectqty1 = $("#allcontainer > div").find("." + classnames[1]).length;
- if (parseInt(qty1) != selectqty1) {
- learun.alert.error('选择的数量与第二种湿拉物料的数量不相符!');
- return false;
- }
- }
- }
- var qty2 = $("#QtyMaxCount2").val();
- if (qty2 != "") {
- if (!reg.test(qty2) || parseInt(qty2) == 0) {
- learun.alert.error('请输入第三种湿拉物料的数量');
- return false;
- }
- else {
- var selectqty2 = $("#allcontainer > div").find("." + classnames[2]).length;
- if (parseInt(qty2) != selectqty2) {
- learun.alert.error('选择的数量与第三种湿拉物料的数量不相符!');
- return false;
- }
- }
- }
- 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"] = 0;
- setInfos.push(setinfo);
- }
- }
- });
- if (!$('#form').lrValidform()) {
- return false;
- }
- if (setInfos.length == 0) {
- learun.alert.error('请选择跺型编号。');
- return false;
- }
- //if (setInfos.length != HWCountQty) {
- // learun.alert.error('勾选的跺型编号与输入的工字轮个数不符。');
- // return false;
- //}
- postData.BomName = $("#BomName").val();
- postData.ProCode = BomsetCode;
- postData.Category = 1;
- postData.StampType = 1;
- postData.Bomsetinfos = setInfos;
- postData.TotalQty = $(".clickcircle").length;
-
- $.lrSaveForm(top.$.rootUrl + '/FJManager/BillBomSet/Save09Form?keyValue=' + keyValue, postData, function (res) {
- // 保存成功后才回调
- if (!!callBack) {
- callBack();
- }
- });
- };
- page.init();
- }
|