batch_replace_modal.ejs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <div class="modal fade" id="batch-replace" data-backdrop="static">
  2. <div class="modal-dialog" role="document">
  3. <div class="modal-content">
  4. <div class="modal-header">
  5. <h5 class="modal-title">批量替换清单</h5>
  6. </div>
  7. <div class="modal-body">
  8. 原清单:
  9. <table class="table table-bordered">
  10. <tr class="text-center"><th width="25%">编号</th><th width="40%">名称</th><th width="15%">单位</th><th width="20%">单价</th></tr>
  11. <tr><td id="br-org-code"></td><td id="br-org-name"></td><td class="text-center" id="br-org-unit"></td><td class="text-right" id="br-org-up">单价</td></tr>
  12. </table>
  13. 替换为:
  14. <table class="table table-bordered">
  15. <tr class="text-center"><th width="25%">编号</th><th width="40%">名称</th><th width="15%">单位</th><th width="20%">单价</th></tr>
  16. <tr>
  17. <td><input id="br-new-code" type="text" class="form-control form-control-sm"></td>
  18. <td><input id="br-new-name" type="text" class="form-control form-control-sm"></td>
  19. <td><input id="br-new-unit" type="text" class="form-control form-control-sm text-center"></td>
  20. <td><input id="br-new-up" type="text" class="form-control form-control-sm text-right"></td></tr>
  21. </table>
  22. </div>
  23. <div class="modal-footer">
  24. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>
  25. <a href="javascript: void(0);" class="btn btn-sm btn-primary" id="batch-replace-ok">确定</a>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <script>
  31. const BatchReplace = (function() {
  32. const orgValue = { code: '', name: '', unit: '', unit_price: 0 };
  33. let doReplace;
  34. const load = function(code, name, unit, unit_price, callback) {
  35. orgValue.code = code || '';
  36. orgValue.name = name || '';
  37. orgValue.unit = unit || '';
  38. orgValue.unit_price = unit_price || 0;
  39. $('#br-org-code').html(orgValue.code);
  40. $('#br-org-name').html(orgValue.name);
  41. $('#br-org-unit').html(orgValue.unit);
  42. $('#br-org-up').html(orgValue.unit_price || '');
  43. $('#br-new-code').val(orgValue.code);
  44. $('#br-new-name').val(orgValue.name);
  45. $('#br-new-unit').val(orgValue.unit);
  46. $('#br-new-up').val(orgValue.unit_price || '');
  47. doReplace = callback;
  48. $('#batch-replace').modal('show');
  49. }
  50. $('#batch-replace-ok').click(function() {
  51. if (doReplace) {
  52. const newValue = { code: $('#br-new-code').val(), name: $('#br-new-name').val(), unit: $('#br-new-unit').val(), unit_price: parseFloat($('#br-new-up').val()), };
  53. doReplace(orgValue, newValue);
  54. }
  55. $('#batch-replace').modal('hide');
  56. });
  57. return { load };
  58. })();
  59. </script>