From 0481353111afb43a2322e18530dde26f1d841ead Mon Sep 17 00:00:00 2001 From: yanghb <yanghb> Date: 星期五, 21 四月 2023 11:15:34 +0800 Subject: [PATCH] 代码调整 --- ManagementTravel/guns-admin/src/main/webapp/static/modular/system/tSystemPrice/tSystemPrice_info.js | 836 +++++++++++++++++++++++++--------------------------------- 1 files changed, 362 insertions(+), 474 deletions(-) diff --git a/ManagementTravel/guns-admin/src/main/webapp/static/modular/system/tSystemPrice/tSystemPrice_info.js b/ManagementTravel/guns-admin/src/main/webapp/static/modular/system/tSystemPrice/tSystemPrice_info.js index 252894c..e328209 100644 --- a/ManagementTravel/guns-admin/src/main/webapp/static/modular/system/tSystemPrice/tSystemPrice_info.js +++ b/ManagementTravel/guns-admin/src/main/webapp/static/modular/system/tSystemPrice/tSystemPrice_info.js @@ -1,82 +1,343 @@ /** - * 初始化快车价格设置详情对话框 + * 初始化专车价格设置详情对话框 */ var TSystemPriceInfoDlg = { tSystemPriceInfoData : {}, + validateFields: { + serverCarModelId: { + validators: { + notEmpty: { + message: '请选择车型' + } + } + }, + fareTypeNote: { + validators: { + notEmpty: { + message: '运价类型说明不能为空' + } + } + }, + num1: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num2: { + validators: { + notEmpty: { + message: '【公里】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【公里】输入框不能超过3位数,保留两位小数' + } + } + }, + num3: { + validators: { + notEmpty: { + message: '【分钟】输入框不能为空' + }, + regexp: { + regexp: /^[0-9]{0,3}$/, + message: '【分钟】输入框不能超过3位数' + } + } + }, + num4: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num5: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num6: { + validators: { + notEmpty: { + message: '【分钟】输入框不能为空' + }, + regexp: { + regexp: /^[0-9]{0,3}$/, + message: '【分钟】输入框不能超过3位数' + } + } + }, + num7: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num8: { + validators: { + notEmpty: { + message: '【公里】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【公里】输入框不能超过3位数,保留两位小数' + } + } + }, + num9: { + validators: { + notEmpty: { + message: '【公里】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【公里】输入框不能超过3位数,保留两位小数' + } + } + }, + num10: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num11: { + validators: { + notEmpty: { + message: '【公里】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【公里】输入框不能超过3位数,保留两位小数' + } + } + }, + num12: { + validators: { + notEmpty: { + message: '【公里】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【公里】输入框不能超过3位数,保留两位小数' + } + } + }, + num13: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num14: { + validators: { + notEmpty: { + message: '【公里】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【公里】输入框不能超过3位数,保留两位小数' + } + } + }, + num15: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num16: { + validators: { + notEmpty: { + message: '【时间】输入框不能为空' + } + } + }, + num17: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num18: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num19: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num20: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num21: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num22: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num23: { + validators: { + notEmpty: { + message: '【时间】输入框不能为空' + } + } + }, + num24: { + validators: { + notEmpty: { + message: '【时间】输入框不能为空' + } + } + }, + num25: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num26: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num27: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num28: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num29: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + }, + num30: { + validators: { + notEmpty: { + message: '【元】输入框不能为空' + }, + regexp: { + regexp: /^(0|[1-9]\d{0,2})(\.\d{1,2})?$/, + message: '【元】输入框不能超过3位数,保留两位小数' + } + } + } + } }; - - - -function checkedLable(e) { - $(e).attr('class', 'lab checked'); - let tag = $(e).attr('tag'); - $('.' + tag).show(); - $(e).siblings().each(function (i, el) { - $(el).attr('class', 'lab'); - let tag1 = $(el).attr('tag'); - $('.' + tag1).hide(); - }) -} - -function chooseCarpool(e, t){ - if(t == 1){ - $(e).attr('class', 'people'); - $(e).siblings().each(function (i, el) { - $(el).removeAttr('class'); - }) - } - if(t == 2){ - $(e).attr('class', 'carpool'); - $(e).siblings().each(function (i, el) { - $(el).removeAttr('class'); - }) - } - let people = $('.shareSeatPriceSetting .people').attr('tag'); - let carpool = $('.shareSeatPriceSetting .carpool').attr('tag'); - if(people == 1){ - if(carpool == 'spell'){ - $('.p1').show(); - $('.p1').siblings().each(function (i, el) { - $(el).hide(); - }) - } - if(carpool == 'notSpelled'){ - $('.wp1').show(); - $('.wp1').siblings().each(function (i, el) { - $(el).hide(); - }) - } - } - if(people == 2){ - if(carpool == 'spell'){ - $('.p2').show(); - $('.p2').siblings().each(function (i, el) { - $(el).hide(); - }) - } - if(carpool == 'notSpelled'){ - $('.wp2').show(); - $('.wp2').siblings().each(function (i, el) { - $(el).hide(); - }) - } - } - if(people == 3){ - if(carpool == 'spell'){ - $('.p3').show(); - $('.p3').siblings().each(function (i, el) { - $(el).hide(); - }) - } - if(carpool == 'notSpelled'){ - $('.wp3').show(); - $('.wp3').siblings().each(function (i, el) { - $(el).hide(); - }) - } - } -} - /** * 验证数据是否为空 @@ -139,189 +400,21 @@ * 提交添加 */ TSystemPriceInfoDlg.addSubmit = function() { - let serverCarModelId = $('#serverCarModelId').val(); - if(null == serverCarModelId){ - Feng.error("请选择车型"); - return + + this.clearData(); + this.collectData(); + if(!this.validate()){ + return ; } - - var b = false; - var waitFee = '{'; - $('.waitFee input[type="text"]').each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - waitFee = waitFee + '"'+$(this)[0].name+'":"'+value+'",'; - }); - waitFee = waitFee.substring(0,waitFee.length-1); - waitFee += '}'; - console.log(waitFee); - - var p1 = '{'; - $('.p1 input[type="text"]').each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - p1 = p1 + '"'+$(this)[0].name+'":"'+value+'",'; - }); - p1 = p1.substring(0,p1.length-1); - p1 += '}'; - console.log(p1); - if(b){ - return - } - - var p2 = '{'; - $('.p2 input[type="text"]').each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - p2 = p2 + '"'+$(this)[0].name+'":"'+value+'",'; - }); - p2 = p2.substring(0,p2.length-1); - p2 += '}'; - console.log(p2); - if(b){ - return - } - - var p3 = '{'; - $('.p3 input[type="text"]').each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - p3 = p3 + '"'+$(this)[0].name+'":"'+value+'",'; - }); - p3 = p3.substring(0,p3.length-1); - p3 += '}'; - console.log(p3); - if(b){ - return - } - - var wp1 = '{'; - $('.wp1 input[type="text"]').each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - wp1 = wp1 + '"'+$(this)[0].name+'":"'+value+'",'; - }); - wp1 = wp1.substring(0,wp1.length-1); - wp1 += '}'; - console.log(wp1); - if(b){ - return - } - - var wp2 = '{'; - $('.wp2 input[type="text"]').each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - wp2 = wp2 + '"'+$(this)[0].name+'":"'+value+'",'; - }); - wp2 = wp2.substring(0,wp2.length-1); - wp2 += '}'; - console.log(wp2); - if(b){ - return - } - - var wp3 = '{'; - $('.wp3 input[type="text"]').each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - wp3 = wp3 + '"'+$(this)[0].name+'":"'+value+'",'; - }); - wp3 = wp3.substring(0,wp3.length-1); - wp3 += '}'; - console.log(wp3); - if(b){ - return - } - - var contentExclusive = '{'; + var content = '{'; //拼接数据 - $(".exclusivePriceSettings input[type='text']").each(function(){ + $("input").each(function(){ var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - contentExclusive = contentExclusive + '"'+$(this)[0].name+'":"'+value+'",'; + content = content + '"'+$(this)[0].name+'":"'+value+'",'; }); - contentExclusive = contentExclusive.substring(0,contentExclusive.length-1); - contentExclusive += '}'; - console.log(contentExclusive); - if(b){ - return - } - - var contentPrice = '{'; - //拼接数据 - $(".onePriceSetting input[type='text']").each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - contentPrice = contentPrice + '"'+$(this)[0].name+'":"'+value+'",'; - }); - contentPrice = contentPrice.substring(0,contentPrice.length-1); - contentPrice += '}'; - console.log(contentPrice); - if(b){ - return - } - - let fareTypeNote1 = $('#fareTypeNote1').val(); - let isOpen = $('#isOpen').is(":checked"); - if (isOpen){ - isOpen = 1; - } else { - isOpen = 2; - } - - let fareTypeNote2 = $('#fareTypeNote2').val(); - let isOpenExclusive = $('#isOpenExclusive').is(":checked"); - if (isOpenExclusive){ - isOpenExclusive = 1; - } else { - isOpenExclusive = 2; - } - - let fareTypeNote3 = $('#fareTypeNote3').val(); - let isOpenPrice = $('#isOpenPrice').is(":checked"); - if (isOpenPrice){ - isOpenPrice = 1; - } else { - isOpenPrice = 2; - } - + content = content.substring(0,content.length-1); + content += '}'; + console.log(content); //提交信息 var ajax = new $ax(Feng.ctxPath + "/tSystemPrice/add", function(data){ @@ -336,24 +429,8 @@ },function(data){ Feng.error("添加失败!" + data.responseJSON.message + "!"); }); - ajax.setData({ - serverCarModelId: serverCarModelId, - content: waitFee, - fareTypeNote1: fareTypeNote1, - fareTypeNote2: fareTypeNote2, - fareTypeNote3: fareTypeNote3, - contentPutOne: p1, - contentNotOne: wp1, - contentPutTwo: p2, - contentNotTwo: wp2, - contentPutThree: p3, - contentNotThree: wp3, - contentExclusive: contentExclusive, - contentPrice: contentPrice, - isOpen: isOpen, - isOpenExclusive: isOpenExclusive, - isOpenPrice: isOpenPrice - }) + ajax.set(this.tSystemPriceInfoData); + ajax.set("content",content); ajax.start(); } @@ -361,188 +438,21 @@ * 提交修改 */ TSystemPriceInfoDlg.editSubmit = function() { - let serverCarModelId = $('#serverCarModelId').val(); - if(null == serverCarModelId){ - Feng.error("请选择车型"); - return + + this.clearData(); + this.collectData(); + if(!this.validate()){ + return ; } - - var b = false; - var waitFee = '{'; - $('.waitFee input[type="text"]').each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - waitFee = waitFee + '"'+$(this)[0].name+'":"'+value+'",'; - }); - waitFee = waitFee.substring(0,waitFee.length-1); - waitFee += '}'; - console.log(waitFee); - - var p1 = '{'; - $('.p1 input[type="text"]').each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - p1 = p1 + '"'+$(this)[0].name+'":"'+value+'",'; - }); - p1 = p1.substring(0,p1.length-1); - p1 += '}'; - console.log(p1); - if(b){ - return - } - - var p2 = '{'; - $('.p2 input[type="text"]').each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - p2 = p2 + '"'+$(this)[0].name+'":"'+value+'",'; - }); - p2 = p2.substring(0,p2.length-1); - p2 += '}'; - console.log(p2); - if(b){ - return - } - - var p3 = '{'; - $('.p3 input[type="text"]').each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - p3 = p3 + '"'+$(this)[0].name+'":"'+value+'",'; - }); - p3 = p3.substring(0,p3.length-1); - p3 += '}'; - console.log(p3); - if(b){ - return - } - - var wp1 = '{'; - $('.wp1 input[type="text"]').each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - wp1 = wp1 + '"'+$(this)[0].name+'":"'+value+'",'; - }); - wp1 = wp1.substring(0,wp1.length-1); - wp1 += '}'; - console.log(wp1); - if(b){ - return - } - - var wp2 = '{'; - $('.wp2 input[type="text"]').each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - wp2 = wp2 + '"'+$(this)[0].name+'":"'+value+'",'; - }); - wp2 = wp2.substring(0,wp2.length-1); - wp2 += '}'; - console.log(wp2); - if(b){ - return - } - - var wp3 = '{'; - $('.wp3 input[type="text"]').each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - wp3 = wp3 + '"'+$(this)[0].name+'":"'+value+'",'; - }); - wp3 = wp3.substring(0,wp3.length-1); - wp3 += '}'; - console.log(wp3); - if(b){ - return - } - - var contentExclusive = '{'; + var content = '{'; //拼接数据 - $(".exclusivePriceSettings input[type='text']").each(function(){ + $("input").each(function(){ var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - contentExclusive = contentExclusive + '"'+$(this)[0].name+'":"'+value+'",'; + content = content + '"'+$(this)[0].name+'":"'+value+'",'; }); - contentExclusive = contentExclusive.substring(0,contentExclusive.length-1); - contentExclusive += '}'; - console.log(contentExclusive); - if(b){ - return - } - - var contentPrice = '{'; - //拼接数据 - $(".onePriceSetting input[type='text']").each(function(){ - var value = $(this).val(); - if('' == value){ - b = true; - Feng.info("请填写完整配置"); - return - } - contentPrice = contentPrice + '"'+$(this)[0].name+'":"'+value+'",'; - }); - contentPrice = contentPrice.substring(0,contentPrice.length-1); - contentPrice += '}'; - console.log(contentPrice); - if(b){ - return - } - - let fareTypeNote1 = $('#fareTypeNote1').val(); - let isOpen = $('#isOpen').is(":checked"); - if (isOpen){ - isOpen = 1; - } else { - isOpen = 2; - } - - let fareTypeNote2 = $('#fareTypeNote2').val(); - let isOpenExclusive = $('#isOpenExclusive').is(":checked"); - if (isOpenExclusive){ - isOpenExclusive = 1; - } else { - isOpenExclusive = 2; - } - - let fareTypeNote3 = $('#fareTypeNote3').val(); - let isOpenPrice = $('#isOpenPrice').is(":checked"); - if (isOpenPrice){ - isOpenPrice = 1; - } else { - isOpenPrice = 2; - }; + content = content.substring(0,content.length-1); + content += '}'; + console.log(content); //提交信息 var ajax = new $ax(Feng.ctxPath + "/tSystemPrice/update", function(data){ if (500 == data.code){ @@ -556,34 +466,12 @@ },function(data){ Feng.error("修改失败!" + data.responseJSON.message + "!"); }); - ajax.setData({ - id: $('#id').val(), - serverCarModelId: serverCarModelId, - content: waitFee, - fareTypeNote1: fareTypeNote1, - fareTypeNote2: fareTypeNote2, - fareTypeNote3: fareTypeNote3, - contentPutOne: p1, - contentNotOne: wp1, - contentPutTwo: p2, - contentNotTwo: wp2, - contentPutThree: p3, - contentNotThree: wp3, - contentExclusive: contentExclusive, - contentPrice: contentPrice, - isOpen: isOpen, - isOpenExclusive: isOpenExclusive, - isOpenPrice: isOpenPrice - }) + ajax.set(this.tSystemPriceInfoData); + ajax.set("id",$("#id").html()); + ajax.set("content",content); ajax.start(); } $(function() { - var elem1 = document.querySelector(".js-switch1"); - var init = new Switchery(elem1); - var elem2 = document.querySelector(".js-switch2"); - var init1 = new Switchery(elem2); - var elem3 = document.querySelector(".js-switch3"); - var init1 = new Switchery(elem3); Feng.initValidator("specialPriceInfoForm", TSystemPriceInfoDlg.validateFields); }); -- Gitblit v1.7.1