bills_template.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. $('#copyTemplate').click(function () {
  53. const libID = $('#libID').val();
  54. const name = $('#copyName').val();
  55. if (!name) {
  56. $('#copyNameError').show();
  57. return;
  58. }
  59. $.bootstrapLoading.start();
  60. CommonAjax.post('/billsTemplate/copyLib', {libID, name}, function () {
  61. $.bootstrapLoading.end();
  62. window.location.reload();
  63. }, function () {
  64. $.bootstrapLoading.end();
  65. });
  66. });
  67. });
  68. function getTemplateLib (ID) {
  69. CommonAjax.post("/billsTemplate/getLibByID",{libID:ID},function (data) {
  70. $("#renameText").val(data.name);
  71. $("#libID").val(ID);
  72. $("#edit").modal({show:true});
  73. });
  74. }
  75. function showDeleteModal(ID){
  76. $("#libID_del").val(ID);
  77. $("#delCount").val(0);
  78. $("#del").modal({show:true});
  79. }
  80. function showCopyModal(ID) {
  81. $('#libID').val(ID);
  82. $('#copy').modal('show');
  83. }