Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.21 KB | None | 0 0
  1. <input type="text" id="search" placeholder="Поиск КОД МКТ">
  2.  
  3. <table>
  4. <thead>
  5. <th>№ п/п</th><th>Наименование медицинской услуги</th><th>КОД МКТ</th><th>Стоимость,руб</th><th>Количество</th><th>Добавить</th>
  6. </thead>
  7. <tbody id='manage1'>
  8. <script type="text/javascript">
  9.  
  10. $("#search").on("keyup", function () {
  11. var value = $(this).val().toLowerCase();
  12. if (value.length >= 3) {
  13. $.getJSON("/hospitalPrice/ajaxGetPrice/?codeMkt=" + value, function (codeMkt) {
  14. var html = "";
  15. for (var i = 0; i < codeMkt.length; i++) {
  16. html = html +
  17. "<tr><td><input type='text' name='hospitalPrice[" + i + "].id' value='" + codeMkt[i].id + "' id='hospitalPrice[" + i + "].count' size='5' readonly></td>" +
  18. "<td><input type='text' name='hospitalPrice[" + i + "].name' value='" + codeMkt[i].name + "' id='hospitalPrice[" + i + "].name' size='50' readonly></td>" +
  19. "<td><input type='text' name='hospitalPrice[" + i + "].codeMkt' value='" + codeMkt[i].codeMkt + "' id='hospitalPrice[" + i + "].codeMkt' size='8' readonly></td>" +
  20. "<td><input type='text' name='hospitalPrice[" + i + "].price' value='" + codeMkt[i].price + "' id='hospitalPrice[" + i + "].price' size='6' readonly></td>" +
  21. "<td><input type='number' name='hospitalPrice[" + i + "].count' value='1' id='hospitalPrice[" + i + "].count' size='2' ></td>" +
  22. "<td><button type='button' class='move'>+</button></td></tr>";
  23. }
  24. $("#manage1").empty().append(html);
  25. });
  26. }
  27. });
  28. </script>
  29. %{--<tr><td>999</td><td>test</td><td>2007</td><td>900</td></tr>--}%
  30. </tbody>
  31. </table>
  32.  
  33.  
  34. <h3>Выбранные Мед услуги</h3>
  35. <table>
  36. <thead>
  37. <th>№ п/п</th><th>Наименование медицинской услуги</th><th>КОД МКТ</th><th>Стоимость,руб</th><th>Количество</th><th>Удалить</th>
  38. </thead>
  39. <tbody id='manage2'>
  40.  
  41. </tbody>
  42. </table>
  43.  
  44. <script type="text/javascript">
  45. var productInfo = ${selectedProduct.productParametersJSON};
  46.  
  47. $('#manage1').on('click', 'button', function () {
  48. var $row = $(this).closest("tr");
  49. var surgeryAmount = parseInt(($("#surgeryAmount").val()) + parseInt(($row.find("input[id][name$='price']").val()) * parseInt(($row.find("input[id][name$='count']").val());
  50. var premiumAmount = "";
  51. var sumInsured = "";
  52. if (surgeryAmount) {
  53. var insurancePeriod = $("#insurancePeriod").val();
  54. premiumAmount = (surgeryAmount / (1 - productInfo.premiumAmountRate / 100)).toFixed(1);
  55. sumInsured = (premiumAmount / (productInfo.sumInsuredRate / 100)).toFixed(2);
  56. }
  57. $("#surgeryAmount").val(surgeryAmount);
  58. $("#calculatedSumInsured").val(sumInsured);
  59. $("#calculatedPremiumAmount").val(premiumAmount);
  60. $row.find("input[id][name$='count']").prop('readonly', true);
  61. $('#manage2').append($row);
  62. });
  63.  
  64. $('#manage2').on('click', 'button', function () {
  65. var $row = $(this).closest("tr");
  66. var surgeryAmount = parseInt(($("#surgeryAmount").val()) - parseInt(($row.find("input[id][name$='price']").val()) * parseInt(($row.find("input[id][name$='count']").val());
  67. var premiumAmount = "";
  68. var sumInsured = "";
  69. if (surgeryAmount) {
  70. var insurancePeriod = $("#insurancePeriod").val();
  71. premiumAmount = (surgeryAmount / (1 - productInfo.premiumAmountRate / 100)).toFixed(1);
  72. sumInsured = (premiumAmount / (productInfo.sumInsuredRate / 100)).toFixed(2);
  73. }
  74. $("#surgeryAmount").val(surgeryAmount);
  75. $("#calculatedSumInsured").val(sumInsured);
  76. $("#calculatedPremiumAmount").val(premiumAmount);
  77. $row.find("input[id][name$='count']").prop('readonly', false);
  78. $('#manage1').append($row);
  79. });
  80.  
  81. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement