Ingen beskrivning
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

score_level.htm 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. {include file="public/layout" /}
  2. <body class="bodystyle" style="overflow-y: scroll; cursor: default; -moz-user-select: inherit;">
  3. <div id="append_parent"></div>
  4. <div id="ajaxwaitid"></div>
  5. <div class="page" style="min-width: auto;">
  6. {include file="ask/bar" /}
  7. <div class="flexigrid">
  8. <div class="hDiv">
  9. <div class="hDivBox">
  10. <table cellspacing="0" cellpadding="0" style="width: 100%">
  11. <thead>
  12. <tr>
  13. <th abbr="ac_id" axis="col4">
  14. <div style="text-align: left; padding-left: 10px;" class="">头衔名称</div>
  15. </th>
  16. <th abbr="article_time" class="w190">
  17. <div class="tc">积分大于</div>
  18. </th>
  19. <th abbr="article_time" class="w60">
  20. <div class="tc">操作</div>
  21. </th>
  22. </tr>
  23. </thead>
  24. </table>
  25. </div>
  26. </div>
  27. <div class="bDiv" style="height: auto;">
  28. <form id="PostForm">
  29. <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
  30. <table style="width: 100%">
  31. <tbody id='TbodyTemplate'>
  32. {empty name="list"}
  33. <tr>
  34. <td class="no-data" align="center" axis="col0" colspan="50">
  35. <div class="no_row">
  36. <div class="no_pic"><img src="__SKIN__/images/null-data.png"></div>
  37. </div>
  38. </td>
  39. </tr>
  40. {else/}
  41. {volist name="list" id="vo"}
  42. <tr class="tr">
  43. <td style="width: 100%">
  44. <div class="tl" style="padding-left: 10px;">
  45. <input type="hidden" name="id[]" value="{$vo.id}">
  46. <input type="text" name="name[]" value="{$vo.name}">
  47. </div>
  48. </td>
  49. <td class="">
  50. <div class="w190 tc">
  51. <input type="text" name="min[]" value="{$vo.min}" style="width: 50px;">
  52. </div>
  53. </td>
  54. <td class="operation">
  55. <div class="w60 tc">
  56. {eq name="$Think.const.CONTROLLER_NAME.'@score_level_del'|is_check_access" value="1"}
  57. <a class="btn red" href="javascript:void(0);" data-url="{:url('Ask/score_level_del')}" onclick="FindDelData(this, '{$vo.id}');">删除</a>
  58. {/eq}
  59. </div>
  60. </td>
  61. </tr>
  62. {/volist}
  63. {/empty}
  64. </tbody>
  65. </table>
  66. <div id='Template'></div>
  67. </div>
  68. </form>
  69. <div class="iDiv" style="display: none;"></div>
  70. </div>
  71. <div class="footer-oper">
  72. <div class="fbutton">
  73. <a href="javascript:void(0);" data-url="{:url('Ask/score_level')}" onclick="AddAskData(this);" class="layui-btn layui-btn-primary">
  74. <span class="">保存</span>
  75. </a>
  76. </div>
  77. <div class="fbutton">
  78. <a onclick="AskType(this);" class="layui-btn layui-btn-primary">
  79. <span class="red">新增头衔</span>
  80. </a>
  81. </div>
  82. </div>
  83. <div style="clear:both"></div>
  84. </div>
  85. </div>
  86. <input type="hidden" id="IsEmpty" value="{$IsEmpty}">
  87. <script type="text/javascript">
  88. // tr数,取唯一标识
  89. var SerialNum = $('#TbodyTemplate .tr').length;
  90. function AskType(){
  91. var AddHtml = [];
  92. AddHtml +=
  93. [
  94. '<tr class="tr" id="tr_'+SerialNum+'">'+
  95. '<td style="width: 100%">'+
  96. '<div class="tl" style="padding-left: 10px;">'+
  97. '<input type="hidden" name="id[]" >'+
  98. '<input type="text" name="name[]" >'+
  99. '</div>'+
  100. '</td>'+
  101. '<td class="">'+
  102. '<div class="w190 tc">'+
  103. '<input type="text" name="min[]" style="width: 50px;">\n'+
  104. '</div>'+
  105. '</td>'+
  106. '<td class="operation">'+
  107. '<div class="w60 tc">'+
  108. '<a class="btn red" href="javascript:void(0);" data-id="tr_'+SerialNum+'" onclick="DelHtml(this)">删除</a>'+
  109. '</div>'+
  110. '</td>'+
  111. '</tr>'
  112. ];
  113. /*加载方式*/
  114. if (1 == $('#IsEmpty').val()) {
  115. // 已有栏目数据则执行追加
  116. $('#Template').append(AddHtml);
  117. }else{
  118. if (0 == SerialNum) {
  119. // 没有栏目则执行覆盖
  120. $('#TbodyTemplate').html(AddHtml);
  121. }else{
  122. // 已新增过一次则执行追加
  123. $('#TbodyTemplate').append(AddHtml);
  124. }
  125. }
  126. /* END */
  127. SerialNum++;
  128. }
  129. // 删除未保存的级别
  130. function DelHtml(obj){
  131. $('#'+$(obj).attr('data-id')).remove();
  132. }
  133. // 保存数据
  134. function AddAskData(obj){
  135. if ($('input[name*=name]').length == 0) {
  136. showErrorAlert('至少新增一个级别!');
  137. return false;
  138. } else {
  139. var is_empty = true;
  140. $('input[name*=name]').each(function(index, item){
  141. if ($.trim($(item).val()) != '') {
  142. is_empty = false;
  143. return false;
  144. }
  145. });
  146. if (true == is_empty) {
  147. showErrorAlert('级别名称不能为空!');
  148. return false;
  149. }
  150. }
  151. layer_loading('正在处理');
  152. $.ajax({
  153. type : 'post',
  154. url : $(obj).attr('data-url'),
  155. data : $('#PostForm').serialize(),
  156. dataType : 'json',
  157. success : function(res){
  158. layer.closeAll();
  159. if(res.code == 1){
  160. layer.msg(res.msg, {icon: 1, time:1000},function(){
  161. window.location.reload();
  162. });
  163. }else{
  164. showErrorAlert(res.msg);
  165. }
  166. },
  167. error : function(e) {
  168. layer.closeAll();
  169. showErrorAlert(e.responseText);
  170. }
  171. })
  172. }
  173. /**
  174. * 单个删除
  175. */
  176. function FindDelData(obj, del_id) {
  177. layer.confirm('此操作不可恢复,确认删除?', {
  178. area: ['480px', '190px'],
  179. move: false,
  180. title: '提示',
  181. shade: layer_shade,
  182. btnAlign:'r',
  183. closeBtn: 3,
  184. btn: ['确定','取消'] ,//按钮
  185. success: function () {
  186. $(".layui-layer-content").css('text-align', 'left');
  187. }
  188. }, function () {
  189. layer_loading('正在处理');
  190. $.ajax({
  191. url: $(obj).data('url'),
  192. type: 'post',
  193. dataType: 'json',
  194. data:{del_id:del_id,_ajax:1},
  195. success: function(res){
  196. layer.closeAll();
  197. if (1 == res.code) {
  198. layer.msg(res.msg, {time: 1000},function(){
  199. window.location.reload();
  200. });
  201. } else {
  202. showErrorAlert(res.msg);
  203. }
  204. },
  205. error : function(e) {
  206. layer.closeAll();
  207. showErrorAlert(e.responseText);
  208. }
  209. });
  210. }, function (index) {
  211. layer.closeAll(index);
  212. });
  213. }
  214. </script>
  215. {include file="public/footer" /}