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.

89 lines
2.6 KiB

3 years ago
  1. $(".choose_type").change(function(){
  2. if ($("#item_type2").is(":checked") ) {
  3. $(".level_2_directory").removeAttr("disabled");
  4. $(".level_3_directory").removeAttr("disabled");
  5. $(".page").removeAttr("disabled");
  6. }else{
  7. $(".level_2_directory").attr("disabled","disabled");
  8. $(".level_3_directory").attr("disabled","disabled");
  9. $(".page").attr("disabled","disabled");
  10. }
  11. }).trigger("change");
  12. /*加载二级目录*/
  13. secondCatList();
  14. //监听是否选择了二级目录。如果选择了,则跟后台判断是否还子目录
  15. $(".level_2_directory").change(function() {
  16. getChildCatList();
  17. });
  18. function secondCatList() {
  19. var item_id = $("#item_id").val();
  20. $.post(
  21. DocConfig.server+"/api/catalog/secondCatList", {
  22. "item_id": item_id,
  23. },
  24. function(data) {
  25. $(".level_2_directory").html('<OPTION value="0">请选择</OPTION>');
  26. if (data.error_code == 0) {
  27. json = data.data;
  28. for (var i = 0; i < json.length; i++) {
  29. cat_html = '<OPTION value="' + json[i].cat_id + '" ';
  30. cat_html += ' ">' + json[i].cat_name + '</OPTION>';
  31. $(".level_2_directory").append(cat_html);
  32. };
  33. };
  34. },
  35. "json"
  36. );
  37. }
  38. /*加载三级目录*/
  39. function getChildCatList() {
  40. var cat_id = $(".level_2_directory").val();
  41. $.post(
  42. DocConfig.server+"/api/catalog/childCatList", {
  43. "cat_id": cat_id
  44. },
  45. function(data) {
  46. $(".level_3_directory").html('<OPTION value="0">全部</OPTION>');
  47. if (data.error_code == 0) {
  48. json = data.data;
  49. for (var i = 0; i < json.length; i++) {
  50. cat_html = '<OPTION value="' + json[i].cat_id + '" ';
  51. cat_html += ' ">' + json[i].cat_name + '</OPTION>';
  52. $(".level_3_directory").append(cat_html);
  53. };
  54. } else {}
  55. },
  56. "json"
  57. );
  58. }
  59. //提交
  60. $(".export-submit").click(function(){
  61. var item_id = $("#item_id").val();
  62. var val=$('input:radio[name="item_type"]:checked').val();
  63. if (val == 1 ) {
  64. var url = DocConfig.server+'/api/export/word&item_id='+item_id ;
  65. window.location.href = url;
  66. }
  67. else if (val == 2) {
  68. var cat_id2 = $(".level_2_directory").val();
  69. var cat_id3 = $(".level_3_directory").val();
  70. if (cat_id2 > 0 ) {
  71. var cat_id = cat_id3 > 0 ? cat_id3 : cat_id2 ;
  72. var url = DocConfig.server+'/api/export/word_cat&item_id='+item_id+'&cat_id='+cat_id ;
  73. window.location.href = url;
  74. }else{
  75. $.alert("请选择要导出的目录");
  76. }
  77. }
  78. return false;
  79. });