• foreach枚举div控制单个显示


    @{
        ViewBag.Title = "Index";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    
    @model PagedList<Department>
    
    <div class="row-fluid">
        <div class="span4">
            <div>            
            </div>
        </div>
        <div class="span8">
            @using (Html.BeginForm(null, null, null, FormMethod.Get, new { id = "search" }))
            { 
            <div class="dataTables_filter">
                <label>
                    <button type="submit" class="btn">搜索 <i class="icon-search"></i></button>
                 </label>
                <label>
                    <span>手机:</span>
                    @Html.TextBox("Mobile", null, new { @class = "m-wrap small" })
                </label>
                <label>
                    <span>姓名:</span>
                    @Html.TextBox("LoginName", null, new { @class = "m-wrap small" })
                </label>
            </div>
            }
        </div>
    </div>
    
    <div class="row-fluid">
      <div class="span12">
         @using (Html.BeginForm("ExportExcel", "User", null, FormMethod.Post, new { id = "ExportForm" }))
            { 
            <div class="dataTables_filter">
                <label>
                    <button class="btn" id="Export" data-target="userDiv" data-file="用户列表">导出Excel <i class="icon-signout"></i></button>
                 </label>
    
                <input type="hidden" name="ExportContent" />
                <input type="hidden" name="ExportFileName" />
               
            </div>
            }
          </div>
        </div>
    
    @{
       foreach (Department s in Model)
       {
        <div id="a-@s.ID"  onclick="showdiv(this)">
            <table class="table table-striped table-hover table-bordered" id="userDiv">
            <thead>
                <tr>
                    <th class="hidden-480" style="text-align: left">
                        @s.Name
                    </th>
                </tr>           
            </thead>       
        </table>
        </div>
        <div @*id="@s.ID"*@ id="b-a-@s.ID" class="trhidd" style="display:none">
            <table class="table table-striped table-hover table-bordered">
                <thead>
                    <tr>
                        <th class="hidden-480">序号</th>
                        <th class="hidden-480">姓名</th>
                        <th class="hidden-480">月任务</th>
                        <th class="hidden-480">目前完成度</th>
                        <th class="hidden-480">其他</th>
                        <th class="hidden-480">操作</th>
                    </tr>
                </thead>
                @{
           var db = new BaseDbContext();
           List<User> us = db.Users.Where(p => p.DepartmentID == s.ID).ToList();
           if (us.Count>0)
           {
               foreach (var uss in us)
               {
                   decimal prop = 0;
                   var dbContent = new CrmDbContext();
                   crm_MonthPlanDetails monpd = dbContent.MonthPlanDetailss.Where(p => p.UserID == uss.ID).FirstOrDefault();              
                   if (monpd!=null)
                   {
                       decimal pro = monpd.FirstWeekDegree + monpd.SecondWeekDegree + monpd.ThirdWeekDegree + monpd.FourthWeekDegree;
                       prop = (pro / monpd.MonthPlan)*100;
                   }             
                    <tbody>
                        
                        <tr>
                            <td style="text-align: center" class="hidden-480">@(us.IndexOf(uss) + 1)</td>
                            <td style="text-align: center" class="hidden-480">@uss.RemarkName</td>
                            @if (monpd != null)
                            {
                                <td style="text-align: center" class="hidden-480">@monpd.MonthPlan</td>
                            }
                            else
                            {
                                <td style="text-align: center" class="hidden-480">0</td>   
                            }
    
                            <td style="text-align: center" class="hidden-480">
                               @if (monpd!=null)
                               {
                                   @Html.TextBox("wanchengdu", prop.ToString("f2"), "", new {@readonly=true })
                                   <span>%</span>
                               }
                               else
                               {
                                   @Html.TextBox("wanchengdu", 0, "", new {@readonly=true })
                                   <span>%</span>
                               }
                            </td>
    
                            <td style="text-align: center" class="hidden-480">其他</td>
                            <td style="text-align: center" class="hidden-480">
                                <a class="btn mini purple thickbox" title='查看详细信息' href="@Url.Action("Select", new { id = uss.ID })?TB_iframe=true&height=700&width=600">
                                    <i class="icon-edit"></i>
                                    查看
                                </a>
                            </td>
                        </tr>                  
                    </tbody>
                   
               }
           }
                    }
                
            </table>
        </div>
       }                    
        }
     <div class="dataTables_paginate paging_bootstrap pagination" style="margin-bottom:10px">
        @Html.Pager(Model, new PagerOptions() { ShowTotalItemCount = true })
    </div>
    @section PageSpecificStyleSheetIncludes{
        
        
    }
    @section PageSpecificJavascriptIncludes{   
        <script src="~/Assets/js/jquery-1.8.3.min.js"></script>
        <script type="text/javascript">
            //$(document).ready(function ()
            //{
            //    $(this).click(function ()
            //    {
            //        //var a = new Array();
            //        //$(".trhidd").each(function (key,id)
            //        //{
            //        //    var id = $(this).attr("id");
            //        //    id = $(this).data("id");
            //        //    a[key] = id;
            //        //    alert(a[key]);
            //        //});
            //        //for (var i = 0; i < a.length; i++) {
            //        //    alert(a[i]);
            //        //    $(a[i]).slideToggle("slow");
            //        //}
    
            //        var id = $(this).data("id");
            //        alert(id);
            //        $(".trhidd").slideToggle("slow");
            //    })
            //})
          
    
            function showdiv(div)
            {
               
                var a = div.id;          
                var c = ("b-" + a);           
                $("#"+c+"").slideToggle("fast")
            }
        </script>  
        }
  • 相关阅读:
    NDCG
    卷积核
    高斯核函数映射到无限维
    《Towards Knowledge-Based Recommender Dialog System》阅读笔记
    Pytorch官方教程:含注意力的seq2seq2机器翻译
    cad 已知拱高弦长求弧长
    MySQL直接将数据库的文件夹从服务器复制到本地,打开表提示需要修复 “is marked as crashed and should be repaired ”
    CSS小技巧:利用border实现三角形箭头
    完美解决ERROR 1064 (42000): You have an error in your SQL syntax; check the manual…
    Java 理论与实践:正确使用 Volatile 变量
  • 原文地址:https://www.cnblogs.com/happinesshappy/p/4799887.html
Copyright © 2020-2023  润新知