首页 > 代码库 > MVC动态添加模块cshtml页面
MVC动态添加模块cshtml页面
@model Lixise.HealthCloud.ServiceOrder.Models.ServiceOrderEdit @using Lixise.HealthCloud.ServiceOrder.Utils @{ ViewBag.Title = "CreateOrder"; } <style type="text/css"> #close { /*background: url(img/close.png) no-repeat; width: 30px; height: 30px;*/ cursor: pointer; position: absolute; right: 10px; top: 5px; /*text-indent: -999em;*/ color: #fff; font-size: 16px; } #mask { background-color: #ccc; opacity: 0.7; filter: alpha(opacity=70); position: absolute; left: 200px; top: 0; z-index: 1000; } #dialog { position: fixed; z-index: 1001; } /*弹出层的样式*/ .dialogCon { padding: 1px; position: relative; width: 670px; height: 380px; background: lightblue; /*border: 3px solid #9BE0F2;*/ box-shadow: 0 0 15px 5px #888888; text-align: center; } .dialogCon .diaHead { width: 100%; height: 55px; } .dialogCon .diaBody { margin-top: 10px; width: 100%; height: 220px; } #diaBody label{ width:111.6px; padding-bottom:15px; } .dialogCon .diaFoot { width:100%; height:auto; } </style> @*此页面的所有中文字段后期一律改为多语言*@ <form method="post" id="formOrder"> <div class="bg-light lter b-b wrapper-md"> <h1 class="m-n font-thin h3"> <i class="icon icon-layers"></i> @T(Constanct.ServiceOrder_Add) <span class="panel-link">@Html.ActionLink(T(Constanct.Server_List_Title), "Services")</span> <span class="pull-right"> <select class="input-sm w-sm inline" id="SelectModule" onchange="select()"> <option value=http://www.mamicode.com/"selEmpty">请选择模块</option> <option value=http://www.mamicode.com/"selAboutInfo"> 相关部件信息 </option> <option value=http://www.mamicode.com/"selPaymentInfo">付款信息</option> <option value=http://www.mamicode.com/"selLogisticsInfo">物流信息</option> </select> <span style="display:none;" id="toggleSle"> <select class="input-sm w-sm inline" id="SecondModule"> <option value=http://www.mamicode.com/"selEmpty">请选择</option> <option value=http://www.mamicode.com/"selAlternator">发电机模块</option> <option value=http://www.mamicode.com/"selEngine">发动机模块</option> <option value=http://www.mamicode.com/"selControl">控制器模块</option> <option value=http://www.mamicode.com/"selHarvester">采集器模块</option> <option value=http://www.mamicode.com/"selOther">其他模块</option> </select> </span> <button type="button" id="btnAdd" class="btn btn-info">点击新增模块</button> </span> </h1> </div> <div class="wrapper-md"> <div class="col-sm-6"> <div class="panel panel-default"> <div class="panel-heading font-bold" name="moduleGrop">客户信息</div> <div class="panel-body"> <div class="form-group"> <label>公司名称</label> <input type="text" class="form-control" placeholder="公司名称"> </div> <div class="form-group"> <label>联系人</label> <input type="text" class="form-control" placeholder="联系人"> </div> <div class="form-group"> <label>联系电话</label> <input type="text" class="form-control" placeholder="联系电话"> </div> </div> </div> </div> <div class="col-sm-6"> <div class="panel panel-default"> <div class="panel-heading font-bold" name="moduleGrop">收货信息</div> <div class="panel-body"> <div class="form-group"> <label>收货人姓名</label> <input type="email" class="form-control" placeholder="收货人姓名"> </div> <div class="form-group"> <label>收货人地址</label> <input type="email" class="form-control" placeholder="收货人地址"> </div> <div class="form-group"> <label>收货人电话</label> <input type="email" class="form-control" placeholder="收货人电话"> </div> <div class="form-group"> <label>收货人邮箱</label> <input type="email" class="form-control" placeholder="收货人邮箱"> </div> <div class="form-group"> <label>收货人邮编</label> <input type="email" class="form-control" placeholder="收货人邮编"> </div> </div> </div> </div> @*<div class=‘col-sm-6‘> <div class=‘panel panel-default‘> <div class=‘panel-heading font-bold‘> <span name="moduleGrop">付款信息</span> <button class=‘btn btn-info pull-right‘ name="selField" type="button">选择字段</button> </div> <div class=‘panel-body‘> <div class=‘dialogCon‘> <div id="diaHead"> <h3>请选择字段</h3> <div id=‘close‘>?</div> </div> <div id="diaBody"> <div class="col-sm-12"> <label class="checkbox-inline i-checks"> <input type="checkbox" value=http://www.mamicode.com/"option1"><i></i> 发电机型号 </label> <label class="checkbox-inline i-checks"> <input type="checkbox" value=http://www.mamicode.com/"option2"><i></i> AVR型号 </label> </div> </div> <div id="diaFoot"> <button class=‘btn btn-primary pull-in‘ type="button">保存</button> </div> </div> </div> </div> </div>*@ </div> </form> @section FootScripts{ <script type="text/javascript"> var jsonvalue = http://www.mamicode.com/null; $(function () { var moduleName = null; var emptyModule = ""; var seleteVal = null; //动态添加模块 $("#btnAdd").click(function () { if ($("#SelectModule option:selected").val() == "selEmpty") { alert("请选择需要添加的模块"); return; } if ($("#SelectModule option:selected").val() == "selAboutInfo") { if ($("#toggleSle option:selected").val() == "selEmpty") { alert("请选择相关部件模块"); return; } else{ moduleName = $("#toggleSle option:selected").text(); seleteVal = $("#toggleSle option:selected").val(); } } else { moduleName = $("#SelectModule option:selected").text(); seleteVal = $("#SelectModule option:selected").val() } //动态添加模块 var emptyModule = "<div class=‘col-sm-6‘><div class=‘panel panel-default‘><div class=‘panel-heading font-bold‘><span name=‘moduleGrop‘>" + moduleName + "</span><button class=‘btn btn-info pull-right‘ name=‘" + seleteVal + "selField‘ type=‘button‘>添加字段</button></div><div class=‘panel-body‘></div></div></div>"; //对比是否存在当前模块名称,存在则return 不存在则添加 if (!IsExistModule(moduleName)) { alert("已有此模块,请添加其他模块!"); return; } $(".col-sm-6").last().after(emptyModule); //选择字段 var aa = $("[name=‘" + seleteVal + "selField‘]"); $("[name=‘" + seleteVal + "selField‘]").click(function () { var aa = $("[name=‘" + seleteVal + "selField‘]"); Dialog(function () { console.log(‘我是点击后的事件‘); console.log(aa); }); }) }) }); //二级下拉框的显示与隐藏 function select() { if ($("#SelectModule option:selected").val() == "selAboutInfo") { $("#toggleSle").css("display", "inline"); } else $("#toggleSle").css("display", "none"); }; //当前要添加的模块名与当前存在的模块名是否相同,返回bool function IsExistModule(moduleName) { var result = true; $("[name=‘moduleGrop‘]").each(function () { if (moduleName == this.innerText) { result = false; } }); return result; } //点击添加字段的弹出层效果 function Dialog(okcallback) { //获取当前页面的高度和宽度 //var sWidth = document.body.scrollWidth || document.documentElement.scrollWidth; var sWidth = document.getElementById("formOrder").scrollWidth || document.documentElement.scrollWidth; var sHeight = document.body.scrollHeight || document.documentElement.scrollHeight; //获取页面的可视区域高度和宽度 var wHeight = document.documentElement.clientHeight || document.body.clientHeight; //创建遮罩层 var oMask = document.createElement("div"); oMask.id = "mask"; oMask.style.height = sHeight + "px"; oMask.style.width = sWidth + "px"; document.body.appendChild(oMask); //添加到body末尾 //创建弹出层 var oDialog = document.createElement("div"); oDialog.id = "dialog"; oDialog.innerHTML = "<div class=‘dialogCon‘><div class=‘diaHead‘><h3>请选择字段</h3><div id=‘close‘>?</div></div><div class=‘diaBody‘><div class=‘col-sm-12‘><label class=‘checkbox-inline i-checks‘><input type=‘checkbox‘ value=http://www.mamicode.com/‘option1‘> 发电机型号
MVC动态添加模块cshtml页面
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。