maindiv.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <div class="panel panel-warning">
  2. <div class="panel-heading">
  3. <h4 class="panel-title">
  4. <span class="glyphicon glyphicon-filter btn-xs"></span>
  5. 查找/筛选/过滤
  6. <small>(带*项目可模糊查询)</small>
  7. </h4>
  8. </div>
  9. <div class="panel-body">
  10. <form class="form-inline" action="" method="GET" onsubmit="return procFilterData();">
  11. {% for i in textitems %}
  12. <div class="form-group">
  13. <label class="sr-only" for="{{i.ctid}}">{{i.title}}</label>
  14. <input type="text" class="form-control" id="{{i.ctid}}" name="{{i.ctname}}" placeholder="{{i.title}}" value="{{i.value}}" />
  15. </div>
  16. {% endfor %}
  17. {% for i in valitems %}
  18. <div class="form-group">
  19. <label class="sr-only" for="{{i.ctid}}">{{i.title}}</label>
  20. <input type="text" class="form-control" id="{{i.ctid}}" name="{{i.ctname}}" placeholder="{{i.title}}" value="{{i.value}}" />
  21. </div>
  22. {% endfor %}
  23. {% for i in dateeqi %}
  24. <div class="form-group">
  25. <label class="sr-only" for="{{i.ctid}}">{{i.title}}</label>
  26. <input type="text" class="form-control" id="{{i.ctid}}" name="{{i.ctname}}" placeholder="{{i.title}}" value="{{i.value}}" />
  27. </div>
  28. {% endfor %}
  29. {% for i in datergi %}
  30. <div class="form-group">
  31. <label class="sr-only" for="{{i.ctid}}">{{i.title}}</label>
  32. <input type="hidden" id="{{i.ctid}}" class="datergi-res" name="{{i.ctname}}"/>
  33. <input type="text" class="form-control datergi-st" id="rgl_{{i.ctid}}" name="{{i.ctname}}" placeholder="{{i.title}}(起始日期)" value="{{i.valuest}}" />~
  34. <input type="text" class="form-control datergi-ed" id="rgr_{{i.ctid}}" name="{{i.ctname}}" placeholder="{{i.title}}(结束日期)" value="{{i.valueed}}" />
  35. </div>
  36. {% endfor %}
  37. {% for i in scitems %}
  38. <div class="form-group">
  39. <label for="{{i.ctid}}">{{i.title}}</label>
  40. <select class="form-control" id="{{i.ctid}}" name="{{i.ctname}}">
  41. <option value="all">全部</option>
  42. {% for j in i.oplst %}
  43. <option value="{{forloop.counter0}}">{{j}}</option>
  44. {% endfor %}
  45. </select>
  46. </div>
  47. {% endfor %}
  48. {% for i in mcitems %}
  49. <div class="form-group">
  50. <label for="{{i.ctid}}">{{i.title}}</label>
  51. <input type="hidden" id="smf_{{i.ctid}}" class="cmcres" name="{{i.ctname}}"/>
  52. <select multiple class="form-control cmcbox" id="{{i.ctid}}">
  53. {% for j in i.oplst %}
  54. <option value="{{forloop.counter0}}">{{j}}</option>
  55. {% endfor %}
  56. </select>
  57. </div>
  58. {% endfor %}
  59. <button type="submit" class="btn btn-primary">
  60. <span class="glyphicon glyphicon-ok btn-xs"></span>
  61. 提交
  62. </button>
  63. </form>
  64. <script type="text/javascript">
  65. function InitSC(){
  66. {% for i in scitems %}
  67. $("#{{i.ctid}}").val("{{i.value}}");
  68. {% endfor %}
  69. }
  70. function MCSet(ctid,sllt){
  71. var ar=Array();
  72. ar=sllt.split(',');
  73. for (var i = ar.length - 1; i >= 0; i--) {
  74. var ia=ar[i];
  75. console.log("#"+ctid+" option[value="+ia+"]");
  76. $("#"+ctid+" option[value="+ia+"]").attr('selected',true);
  77. };
  78. $("#"+ctid).val("{{i.value}}");
  79. }
  80. function InitMC(){
  81. {% for i in mcitems %}
  82. MCSet("{{i.ctid}}","{{i.value}}");
  83. {% endfor %}
  84. }
  85. function procFilterData(){
  86. $(".datergi-res").each(
  87. function(){
  88. var oid=$(this).attr('id');
  89. if($('#rgl_'+oid).val() && $('#rgr_'+oid).val()){
  90. $(this).val($('#rgl_'+oid).val()+"~"+$('#rgr_'+oid).val());
  91. }else{
  92. $(this).remove();
  93. }
  94. $('#rgl_'+oid).remove();
  95. $('#rgr_'+oid).remove();
  96. }
  97. );
  98. $(".cmcbox").each(
  99. function(){
  100. var sla=Array();
  101. var oid=$(this).attr('id');
  102. var sol=$("#"+oid+' option:selected');
  103. for (var i = sol.length - 1; i >= 0; i--) {
  104. var iv=$(sol[i]);
  105. sla.push(iv.val());
  106. };
  107. $("#smf_"+oid).val(sla.join(','));
  108. //$(this).remove();
  109. }
  110. );
  111. $("select").each(
  112. function(){
  113. if(!$(this).val()){
  114. $(this).remove();
  115. }
  116. if($(this).val()=="all"){
  117. $(this).remove();
  118. }
  119. }
  120. );
  121. $("input").each(
  122. function(){
  123. if(!$(this).val()){
  124. $(this).remove();
  125. }
  126. }
  127. );
  128. //return confirm('确认***吗??');
  129. }
  130. InitSC();
  131. InitMC();
  132. </script>
  133. </div>
  134. </div>