New file |
| | |
| | | <%@ Page Language="C#" masterpagefile="~/Main.master" AutoEventWireup="true" CodeFile="GwOpGroup.aspx.cs" Inherits="GwOpGroupPage" %> |
| | | |
| | | |
| | | <asp:Content ID="Content1" ContentPlaceHolderID="title" Runat="Server"> |
| | | 通道组管理 |
| | | </asp:Content> |
| | | <asp:Content ID="Content2" ContentPlaceHolderID="head" Runat="Server"> |
| | | </asp:Content> |
| | | <asp:Content ID="Content3" ContentPlaceHolderID="content" Runat="Server"> |
| | | <div class="listCanvas"> |
| | | <table class="table table-striped table-bordered table-hover"> |
| | | <tr class="header"> |
| | | <th> |
| | | 通道组名称 |
| | | </th> |
| | | <th> |
| | | 通道组数据 |
| | | </th> |
| | | <th class="col-sm-1"> |
| | | 操作 |
| | | </th> |
| | | </tr> |
| | | <%=RenderGroupList() %> |
| | | </table> |
| | | |
| | | <button class="action-modal-create btn btn-primary">创建通道组</button> |
| | | </div> |
| | | <div class="modal inmodal fade" id="groupDialog" tabindex="-1" role="dialog" aria-hidden="true"> |
| | | <form method="post" class=" form-horizontal"> |
| | | <div class="modal-dialog modal-xs"> |
| | | <div class="modal-content "> |
| | | <div class="modal-header"> |
| | | <button type="button" class="close" data-dismiss="modal"> |
| | | <span aria-hidden="true">×</span><span class="sr-only">Close</span></button> |
| | | <h4 class="modal-title"> |
| | | 创建/修改通道组 <input type="hidden" name="apid" id="apid" value="0"/></h4> |
| | | </div> |
| | | <div class="modal-body"> |
| | | <div class="form-group"> |
| | | <label class="control-label" > |
| | | 通道组名称</label> |
| | | <div> |
| | | <input type="text" name="groupName" id="groupName" value="" class="form-control" /> |
| | | </div> |
| | | </div> |
| | | <div class="form-group"> |
| | | <table class="table table-striped table-bordered table-hover" id="opList"> |
| | | <thead> |
| | | <tr><th class="col-md-6">通道</th><th class="col-md-4">权重</th><th class="col-md-2">操作</th></tr> |
| | | </thead> |
| | | <tbody> |
| | | |
| | | </tbody> |
| | | <tfoot> |
| | | <tr><td colspan="3"><a href="javascript:;" class="btn btn-xs btn-warning action-add-op">添加通道</a> <span>通道权重必须在0-10之间,通道权重为0时,为备份通道</span></td></tr> |
| | | </tfoot> |
| | | </table> |
| | | </div> |
| | | </div> |
| | | <div class="modal-footer"> |
| | | <button class="btn btn-warning" data-dismiss="modal" aria-hidden="true"> |
| | | 取消</button> |
| | | <button class="btn btn-primary action-save-group"> |
| | | 保存</button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </form> |
| | | </div> |
| | | |
| | | <script type="text/javascript" language="javascript"> |
| | | $(document).ready(function () { |
| | | var opList = <%=RenderOpListJson()%> |
| | | |
| | | $(".action-modal-create").on("click", function () { |
| | | $("#groupDialog").data("id", 0); |
| | | $("#groupDialog .modal-title").text("创建通道组"); |
| | | $("#groupDialog #opList tbody").html(""); |
| | | $("#groupDialog").modal("show"); |
| | | }); |
| | | $("#groupDialog").on("click", ".action-remove-op", function () { |
| | | var tr = $(this).parents("tr"); |
| | | tr && (tr.remove()); |
| | | }); |
| | | |
| | | $(".action-add-op").on("click", function () { |
| | | appendOpRow(0,10); |
| | | }); |
| | | |
| | | function appendOpRow(opid,weight) { |
| | | var html = []; |
| | | html.push("<tr>"); |
| | | html.push("<td><select class='form-control' name='opid'>"); |
| | | $.each(opList, function (i) { |
| | | html.push("<option value='" + this.OpID + "' "+((this.OpID == opid) ? "selected" : "")+">" +this.OpID+"-"+ this.OpName + "</option>"); |
| | | }); |
| | | html.push("</select></td>"); |
| | | html.push("<td><input type='text' class='form-control' name='weight' value='"+weight+"'></td>"); |
| | | html.push("<td><a href='javascript:;' class='btn btn-xs btn-danger action-remove-op'><i class='fa fa-trash'></i></a> </td>"); |
| | | html.push("</tr>"); |
| | | |
| | | $("#opList tbody").append(html.join("")); |
| | | } |
| | | |
| | | $(".action-save-group").on("click", function (e) { |
| | | e.preventDefault(); |
| | | var groupName = $("#groupName").val(); |
| | | var groupID = $("#groupDialog").data("id"); |
| | | var groupData = []; |
| | | $("#opList tbody tr").each(function (i) { |
| | | var opid = $(this).find("select[name='opid']").val(); |
| | | var weight = $(this).find("input[name='weight']").val(); |
| | | groupData.push({ opid: opid, weight: weight }); |
| | | }); |
| | | |
| | | $.post("gwopgroup.ashx", { action: "save", groupID: groupID, groupName: groupName, groupData: $.toJSON(groupData) }, function (r) { |
| | | mytek.alert(r.Message, r.OK, function () { |
| | | r.OK && (window.location.reload()); |
| | | }); |
| | | }, "json"); |
| | | }); |
| | | $(".action-delete").on("click",function(e){ |
| | | var id = $(this).data("id"); |
| | | |
| | | mytek.confirm("是否需要删除该通道组?", "删除通道组后将无法恢复,并影响相应账号发送,请谨慎操作!", function (b) { |
| | | if (b) { |
| | | $.post("gwopgroup.ashx", { action: "delete", groupID: id }, function (r) { |
| | | mytek.alert(r.Message, r.OK, function () { |
| | | window.location.reload(); |
| | | }); |
| | | }); |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | $(".action-modal-edit").on("click", function (e) { |
| | | var id = $(this).data("id"); |
| | | |
| | | |
| | | $.get("gwopgroup.ashx", { action: "getGroup", groupid: id }, function (r) { |
| | | if (r.OK) { |
| | | $("#groupDialog").data("id", id); |
| | | $("#groupDialog .modal-title").text("编辑通道组"); |
| | | $("#groupDialog #groupName").val(r.Message.GroupName); |
| | | $("#groupDialog #opList tbody").html(""); |
| | | |
| | | var data = $.evalJSON(r.Message.GroupData); |
| | | $.each(data, function (i) { |
| | | appendOpRow(this.opid,this.weight); |
| | | }); |
| | | |
| | | $("#groupDialog").modal("show"); |
| | | } else { |
| | | mytek.alert(r.Message); |
| | | } |
| | | }); |
| | | }); |
| | | }); |
| | | </script> |
| | | </asp:Content> |
| | | |