article_class.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. $(document).ready(function () {
  2. //列表下拉
  3. $('img[ds_type="flex"]').click(function () {
  4. var status = $(this).attr('status');
  5. if (status == 'open') {
  6. var pr = $(this).parent('td').parent('tr');
  7. var id = $(this).attr('fieldid');
  8. var obj = $(this);
  9. $(this).attr('status', 'none');
  10. //ajax
  11. $.ajax({
  12. url: ADMINSITEURL + '/Articleclass/index?ajax=1&ac_parent_id=' + id,
  13. dataType: 'json',
  14. success: function (data) {
  15. var src = '';
  16. for (var i = 0; i < data.length; i++) {
  17. var tmp_vertline = "<img class='preimg' src='templates/images/vertline.gif'/>";
  18. src += "<tr id='ds_row_"+ data[i].ac_id +"' class='" + pr.attr('class') + " row" + id + "'>";
  19. src += "<td class='w36'><input type='checkbox' name='check_ac_id[]' value='" + data[i].ac_id + "' class='checkitem'>";
  20. if (data[i].have_child == 1) {
  21. src += "<img fieldid='" + data[i].ac_id + "' status='open' ds_type='flex' src='" + ADMINSITEROOT + "/images/treetable/tv-expandable.gif' />";
  22. } else {
  23. src += "<img fieldid='" + data[i].ac_id + "' status='none' ds_type='flex' src='" + ADMINSITEROOT + "/images/treetable/tv-item.gif' />";
  24. }
  25. //图片
  26. src += "</td><td class='w48 sort'>";
  27. //排序
  28. src += "<span title='可编辑' ajax_branch='article_class_sort' datatype='number' fieldid='" + data[i].ac_id + "' fieldname='ac_sort' ds_type='inline_edit' class='editable'>" + data[i].ac_sort + "</span></td>";
  29. //名称
  30. src += "<td class='name'>";
  31. for (var tmp_i = 1; tmp_i < (data[i].deep - 1); tmp_i++) {
  32. src += tmp_vertline;
  33. }
  34. if (data[i].have_child == 1) {
  35. src += " <img fieldid='" + data[i].ac_id + "' status='open' ds_type='flex' src='" + ADMINSITEROOT + "/images/treetable/tv-item1.gif' />";
  36. } else {
  37. src += " <img fieldid='" + data[i].ac_id + "' status='none' ds_type='flex' src='" + ADMINSITEROOT + "/images/treetable/tv-expandable1.gif' />";
  38. }
  39. src += " <span title='可编辑' required='1' fieldid='" + data[i].ac_id + "' ajax_branch='article_class_name' fieldname='ac_name' ds_type='inline_edit' class='editable'>" + data[i].ac_name + "</span>";
  40. //新增下级
  41. if (data[i].deep < 2) {
  42. src += "<a class='btn-add-nofloat marginleft' href=\"javascript:dsLayerOpen('" + ADMINSITEURL + "/Articleclass/article_class_add/ac_parent_id/" + data[i].ac_id + "','新增下级')\"><span>新增下级</span></a></span>";
  43. }
  44. src += "</td>";
  45. //操作
  46. src += "<td class='w84'>";
  47. src += "<span><a href=\"javascript:dsLayerOpen('" + ADMINSITEURL + "/Articleclass/article_class_edit/ac_id/" + data[i].ac_id + "','编辑-"+data[i].ac_name+"')\" class='dsui-btn-edit'><i class='iconfont'></i>编辑</a>";
  48. src += "<a href=\"javascript:dsLayerConfirm('" + ADMINSITEURL + "/Articleclass/article_class_del/ac_id/" + data[i].ac_id + "','删除该分类将会同时删除该分类的所有下级分类,您确定要删除吗'," + data[i].ac_id + ");\" class='dsui-btn-del'><i class='iconfont'></i>删除</a>";
  49. src += "</td>";
  50. src += "</tr>";
  51. }
  52. //插入
  53. pr.after(src);
  54. obj.attr('status', 'close');
  55. obj.attr('src', obj.attr('src').replace("tv-expandable", "tv-collapsable"));
  56. $('img[ds_type="flex"]').unbind('click');
  57. $('span[ds_type="inline_edit"]').unbind('click');
  58. //重现初始化页面
  59. $.getScript(ADMINSITEROOT + "/js/jquery.edit.js");
  60. $.getScript(ADMINSITEROOT + "/js/article_class.js");
  61. },
  62. error: function () {
  63. alert('获取信息失败');
  64. }
  65. });
  66. }
  67. if (status == 'close') {
  68. $(".row" + $(this).attr('fieldid')).remove();
  69. $(this).attr('src', $(this).attr('src').replace("tv-collapsable", "tv-expandable"));
  70. $(this).attr('status', 'open');
  71. }
  72. })
  73. });