bills_template.js 2.6 KB

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