bills_template.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * Created by zhang on 2018/7/12.
  3. */
  4. $(document).ready(function() {
  5. $('#add').on('show.bs.modal', function () {
  6. $('#compilationSels').empty();
  7. mainAjax.getCompilationList();
  8. });
  9. // 保存按钮
  10. $("#addTemplate").click(function() {
  11. let name = $('#name').val();
  12. if(name==''){
  13. $("#nameError").show();
  14. return;
  15. }else {
  16. $("#addTemplate").addClass("disabled");//防止重复提交
  17. $("#addTemplateForm").submit();
  18. }
  19. });
  20. $("#rename").click(function() {
  21. let libID = $("#libID").val();
  22. let name = $('#renameText').val();
  23. if(libID!=''){
  24. if(name ==''){
  25. $("#renameError").show();
  26. return;
  27. }else {
  28. CommonAjax.post("/billsTemplate/saveLib",{query:{ID:libID},data:{name:name}},function (data) {
  29. $("#"+libID).children("a").text(data.name);
  30. $("#edit").modal('hide');
  31. });
  32. }
  33. }
  34. });
  35. $("#delete").click(function() {
  36. let libID = $("#libID_del").val();
  37. let delCount = parseInt($("#delCount").val());
  38. delCount = delCount+1;
  39. $("#delCount").val(delCount)
  40. if(delCount == 3){
  41. if(libID!=""){
  42. CommonAjax.post("/billsTemplate/deleteLibByID",{ID:libID},function (data) {
  43. if(data.ok){
  44. $("#"+libID).parent(".libTr").remove();
  45. }
  46. $("#del").modal('hide');
  47. });
  48. }
  49. }
  50. });
  51. });
  52. function getTemplateLib (ID) {
  53. CommonAjax.post("/billsTemplate/getLibByID",{libID:ID},function (data) {
  54. $("#renameText").val(data.name);
  55. $("#libID").val(ID);
  56. $("#edit").modal({show:true});
  57. });
  58. }
  59. function showDeleteModal(ID){
  60. $("#libID_del").val(ID);
  61. $("#delCount").val(0);
  62. $("#del").modal({show:true});
  63. }