jquery.flea_class.js 7.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 + '/Fleaclass/goods_class/?ajax=1&fleaclass_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='" + ADMINSITEROOT + "/images/treetable/vertline.gif'/>";
  18. src += "<tr id='ds_row_" +data[i].fleaclass_id+ "' class='" + pr.attr('class') + " row" + id + "'>";
  19. src += "<td class='w36'><input type='checkbox' name='check_fleaclass_id[]' value='" + data[i].fleaclass_id + "' class='checkitem'>";
  20. //图片
  21. if (data[i].have_child == 1) {
  22. src += " <img fieldid='" + data[i].fleaclass_id + "' status='open' ds_type='flex' src='" + ADMINSITEROOT + "/images/treetable/tv-expandable.gif' />";
  23. } else {
  24. src += " <img fieldid='" + data[i].fleaclass_id + "' status='none' ds_type='flex' src='" + ADMINSITEROOT + "/images/treetable/tv-item.gif' />";
  25. }
  26. src += "</td><td class='w48 sort'>";
  27. //排序
  28. src += " <span title='可编辑下级分类排序' ajax_branch='goods_class_sort' datatype='number' fieldid='" + data[i].fleaclass_id + "' fieldname='fleaclass_sort' ds_type='inline_edit' class='editable tooltip'>" + data[i].fleaclass_sort + "</span></td>";
  29. //名称
  30. src += "<td class='w50pre 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].fleaclass_id + "' status='open' ds_type='flex' src='" + ADMINSITEROOT + "/images/treetable/tv-item1.gif' />";
  36. } else {
  37. src += " <img fieldid='" + data[i].fleaclass_id + "' status='none' ds_type='flex' src='" + ADMINSITEROOT + "/images/treetable/tv-expandable1.gif' />";
  38. }
  39. src += " <span title='可编辑下级分类名称' required='1' fieldid='" + data[i].fleaclass_id + "' ajax_branch='goods_class_name' fieldname='fleaclass_name' ds_type='inline_edit' class='editable tooltip'>" + data[i].fleaclass_name + "</span>";
  40. //新增下级
  41. if (data[i].deep < 3) {
  42. src += "<a class='btn-add-nofloat marginleft' href=\"javascript:dsLayerOpen('" + ADMINSITEURL + "/Fleaclass/goods_class_add/fleaclass_parent_id/" + data[i].fleaclass_id + "','新增下级')\"><span>新增下级</span></a>";
  43. }
  44. src += "</td>";
  45. //显示状态
  46. src += "<td class='align-center yes-onoff'>";
  47. if (data[i].fleaclass_index_show == 0) {
  48. src += "<a href='JavaScript:void(0);' class='tooltip disabled' fieldvalue='0' fieldid='" + data[i].fleaclass_id + "' ajax_branch='goods_class_show' fieldname='fleaclass_show' ds_type='inline_edit' title='可编辑该分类是否显示'><img src='" + ADMINSITEROOT + "/images/treetable/transparent.gif'></a>"
  49. } else {
  50. src += "<a href='JavaScript:void(0);' class='tooltip enabled' fieldvalue='1' fieldid='" + data[i].fleaclass_id + "' ajax_branch='goods_class_show' fieldname='fleaclass_show' ds_type='inline_edit' title='可编辑该分类是否显示'><img src='" + ADMINSITEROOT + "/images/treetable/transparent.gif'></a>"
  51. }
  52. src += "</td>";
  53. //首页显示状态
  54. src += "<td class='align-center yes-onoff'>";
  55. if (data[i].fleaclass_show == 0) {
  56. src += "<a href='JavaScript:void(0);' class='tooltip disabled' fieldvalue='0' fieldid='" + data[i].fleaclass_id + "' ajax_branch='goods_class_index_show' fieldname='fleaclass_index_show' ds_type='inline_edit' title='可编辑该分类是否在首页显示'><img src='" + ADMINSITEROOT + "/images/treetable/transparent.gif'></a>"
  57. } else {
  58. src += "<a href='JavaScript:void(0);' class='tooltip enabled' fieldvalue='1' fieldid='" + data[i].fleaclass_id + "' ajax_branch='goods_class_index_show' fieldname='fleaclass_index_show' ds_type='inline_edit' title='可编辑该分类是否在首页显示'><img src='" + ADMINSITEROOT + "/images/treetable/transparent.gif'></a>"
  59. }
  60. src += "</td>";
  61. //操作
  62. src += "<td class='w84'>";
  63. src += "<a href=\"javascript:dsLayerOpen('" + ADMINSITEURL + "/Fleaclass/goods_class_edit/fleaclass_id/" + data[i].fleaclass_id + "','编辑-"+data[i].fleaclass_name+"')\" class='dsui-btn-edit'><i class='iconfont'></i>编辑</a>";
  64. src += " <a href=\"javascript:dsLayerConfirm('" + ADMINSITEURL + "/Fleaclass/goods_class_del/?fleaclass_id=" + data[i].fleaclass_id + "','删除该分类将会同时删除该分类的所有下级分类,您确定要删除吗'," + data[i].fleaclass_id + ");\" class='dsui-btn-del'><i class='iconfont'></i>删除</a>";
  65. src += "</td>";
  66. src += "</tr>";
  67. }
  68. //插入
  69. pr.after(src);
  70. obj.attr('status', 'close');
  71. obj.attr('src', obj.attr('src').replace("tv-expandable", "tv-collapsable"));
  72. $('img[ds_type="flex"]').unbind('click');
  73. $('span[ds_type="inline_edit"]').unbind('click');
  74. //重现初始化页面
  75. $.getScript(ADMINSITEROOT + "/js/jquery.edit.js");
  76. $.getScript(ADMINSITEROOT + "/js/flea/jquery.flea_class.js");
  77. $.getScript(ADMINSITEROOT + "/js/admin.js");
  78. },
  79. error: function () {
  80. alert('获取信息失败');
  81. }
  82. });
  83. }
  84. if (status == 'close') {
  85. $(".row" + $(this).attr('fieldid')).remove();
  86. $(this).attr('src', $(this).attr('src').replace("tv-collapsable", "tv-expandable"));
  87. $(this).attr('status', 'open');
  88. }
  89. })
  90. });