index.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. {include file="public/header" /}
  2. <div class="page">
  3. <div class="fixed-bar">
  4. <div class="item-title">
  5. <div class="subject">
  6. <h3>{$Think.lang.ds_membergrade}</h3>
  7. <h5></h5>
  8. </div>
  9. {include file="public/admin_items" /}
  10. </div>
  11. </div>
  12. <div class="explanation" id="explanation">
  13. <div class="title" id="checkZoom">
  14. <h4 title="{$Think.lang.ds_explanation_tip}">{$Think.lang.ds_explanation}</h4>
  15. <span id="explanationZoom" title="{$Think.lang.ds_explanation_close}" class="arrow"></span>
  16. </div>
  17. <ul>
  18. <li class="tips">{$Think.lang.membergrade_index_help1}</li>
  19. <li class="tips">{$Think.lang.membergrade_index_help2}</li>
  20. </ul>
  21. </div>
  22. <form method="post" id="mg_form" name="mg_form" enctype="multipart/form-data">
  23. <table class="ds-default-table">
  24. <thead>
  25. <tr class="thead">
  26. <th class="align-center">{$Think.lang.membergrade_level_name}</th>
  27. <th class="align-left">{$Think.lang.membergrade_exppoints}</th>
  28. <th class="align-left">{$Think.lang.ds_handle}</th>
  29. </tr>
  30. </thead>
  31. <tbody id="mg_tbody">
  32. {notempty name="membergrade_list"}
  33. {foreach name="membergrade_list" item="membergrade" key="k" }
  34. <tr>
  35. <td><input type="text" ds_type="verify" name="mg[{$membergrade.level}][level_name]" value="{$membergrade.level_name}" class="w120" /></td>
  36. <td><input type="text" ds_type="verify" name="mg[{$membergrade.level}][exppoints]" value="{$membergrade.exppoints}" class="w60" {if $membergrade.level eq 1}readonly{/if}/></td>
  37. <td>{if $membergrade.level neq 1}<a onclick="remove_tr($(this));" href="JavaScript:void(0);">{$Think.lang.ds_del}</a>{/if}</td>
  38. </tr>
  39. {/foreach}
  40. {else /}
  41. {/notempty}
  42. </tbody>
  43. <tbody>
  44. <tr>
  45. <td colspan="3">
  46. <a id="add_membergrade" class="btn-add-nofloat marginleft" href="JavaScript:void(0);"> <span>{$Think.lang.membergrade_add}</span> </a>
  47. </td>
  48. </tr>
  49. </tbody>
  50. <tfoot>
  51. <tr>
  52. <td colspan="3"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span>{$Think.lang.ds_submit}</span></a></td>
  53. </tr>
  54. </tfoot>
  55. </table>
  56. </form>
  57. <script type="text/javascript">
  58. $(function () {
  59. var i = {$maxlevel};
  60. var mg_tbody = '<tr>' +
  61. '<td><input type="text" ds_type="verify" name="mg[key][level_name]" value="" class="w120" /></td>' +
  62. '<td><input type="text" ds_type="verify" name="mg[key][exppoints]" value="" class="w60" /></td>' +
  63. '<td><a onclick="remove_tr($(this));" href="JavaScript:void(0);">{$Think.lang.membergrade_remove}</a></td>' +
  64. '</tr>';
  65. $("#add_membergrade").click(function () {
  66. $('#mg_tbody > tr:last').after(mg_tbody.replace(/key/g, i));
  67. i++;
  68. });
  69. $('#submitBtn').click(function () {
  70. var result = true;
  71. var error = new Array();
  72. $("#mg_tbody").find("[ds_type='verify']").each(function () {
  73. if (result) {
  74. data = $(this).val();
  75. if (!data) {
  76. result = false;
  77. //error.push('请将信息填写完整');
  78. error = '{$Think.lang.please_complete_info}';
  79. }
  80. //验证类型
  81. if (result) {
  82. var data_str = $(this).attr('data-param');
  83. if (data_str) {
  84. eval("data_str = " + data_str);
  85. switch (data_str.type) {
  86. case 'int':
  87. result = (data = parseInt(data)) > 0 ? true : false;
  88. error = (result == false) ? (data_str.name + '{$Think.lang.should_be_integer}') : '';
  89. }
  90. }
  91. }
  92. }
  93. });
  94. if (result) {
  95. $('#mg_form').submit();
  96. } else {
  97. layer.alert(error);
  98. }
  99. });
  100. })
  101. function remove_tr(o) {
  102. o.parents('tr:first').remove();
  103. }
  104. </script>
  105. </div>