jquery.goods_class.js 5.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 + '/Goodsclass/goods_class.html?ajax=1&gc_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].gc_id +"' class='" + pr.attr('class') + " row" + id + "'>";
  19. src += "<td class='w36'><input type='checkbox' name='check_gc_id[]' value='" + data[i].gc_id + "' class='checkitem'>";
  20. //图片
  21. if (data[i].have_child == 1) {
  22. src += " <img fieldid='" + data[i].gc_id + "' status='open' ds_type='flex' src='" + ADMINSITEROOT + "/images/treetable/tv-expandable.gif' />";
  23. } else {
  24. src += " <img fieldid='" + data[i].gc_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].gc_id + "' fieldname='gc_sort' ds_type='inline_edit' class='editable tooltip'>" + data[i].gc_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].gc_id + "' status='open' ds_type='flex' src='" + ADMINSITEROOT + "/images/treetable/tv-item1.gif' />";
  36. } else {
  37. src += " <img fieldid='" + data[i].gc_id + "' status='none' ds_type='flex' src='" + ADMINSITEROOT + "/images/treetable/tv-expandable1.gif' />";
  38. }
  39. src += " <span title='可编辑下级分类名称' required='1' fieldid='" + data[i].gc_id + "' ajax_branch='goods_class_name' fieldname='gc_name' ds_type='inline_edit' class='editable tooltip'>" + data[i].gc_name + "</span>";
  40. //新增下级
  41. if (data[i].deep < 3) {
  42. src += "<a class='btn-add-nofloat marginleft' href='"+ADMINSITEURL+"/Goodsclass/goods_class_add.html?gc_parent_id=" + data[i].gc_id + "'><span>新增下级</span></a>";
  43. }
  44. src += "</td>";
  45. //是否显示
  46. /*src += "<td class='power-onoff'>";
  47. if(data[i].gc_show == 0){
  48. src += "<a href='JavaScript:void(0);' class='tooltip disabled' fieldvalue='0' fieldid='"+data[i].gc_id+"' ajax_branch='goods_class_show' fieldname='gc_show' ds_type='inline_edit'><img src='"+ADMIN_TEMPLATES_URL+"/images/transparent.gif'></a>";
  49. }else{
  50. src += "<a href='JavaScript:void(0);' class='tooltip enabled' fieldvalue='1' fieldid='"+data[i].gc_id+"' ajax_branch='goods_class_show' fieldname='gc_show' ds_type='inline_edit'><img src='"+ADMIN_TEMPLATES_URL+"/images/transparent.gif'></a>";
  51. }
  52. src += "</td>";
  53. */
  54. //类型
  55. src += "<td>" + data[i].type_name + "</td>";
  56. //分佣
  57. src += "<td>" + data[i].commis_rate + " %</td>";
  58. //虚拟
  59. if (data[i].gc_virtual == 1) {
  60. src += "<td>虚拟</td>";
  61. } else {
  62. src += "<td></td>";
  63. }
  64. //操作
  65. src += "<td class='w84'>";
  66. src += "<a href='"+ADMINSITEURL+"/Goodsclass/goods_class_edit.html?gc_id=" + data[i].gc_id + "'>编辑</a>";
  67. src += " | <a href=\"javascript:dsLayerConfirm('" + ADMINSITEURL + "/Goodsclass/goods_class_del/gc_id/" + data[i].gc_id + "','您确定要删除吗'," + data[i].gc_id + ");\">删除</a>";
  68. src += "</td>";
  69. src += "</tr>";
  70. }
  71. //插入
  72. pr.after(src);
  73. obj.attr('status', 'close');
  74. obj.attr('src', obj.attr('src').replace("tv-expandable", "tv-collapsable"));
  75. $('img[ds_type="flex"]').unbind('click');
  76. $('span[ds_type="inline_edit"]').unbind('click');
  77. //重现初始化页面
  78. $.getScript(ADMINSITEROOT + "/js/jquery.edit.js");
  79. $.getScript(ADMINSITEROOT + "/js/jquery.goods_class.js");
  80. },
  81. error: function() {
  82. alert('获取信息失败');
  83. }
  84. });
  85. }
  86. if (status == 'close') {
  87. $(".row" + $(this).attr('fieldid')).remove();
  88. $(this).attr('src', $(this).attr('src').replace("tv-collapsable", "tv-expandable"));
  89. $(this).attr('status', 'open');
  90. }
  91. })
  92. });