0102.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!--
  2. 费用清单
  3. -->
  4. <div class="el-main">
  5. <div class="el-tit">
  6. <div class="el-t-l">费用总计</div>
  7. <div class="el-t-m" ms-text="data['费用总计']"></div>
  8. </div>
  9. <ul class="el-list">
  10. <li class="el-item" ms-repeat="data['门诊分类']">
  11. <div class="title"><span ms-text="el['分类名称']"></span><span ms-text="el['费用金额']"></span></div>
  12. <div class="list" ms-if="el['费用详情']" ms-repeat-item="el['费用详情']"><span ms-text="item['项目名称']"></span><span ms-text="item['总价']"></span></div>
  13. </li>
  14. </ul>
  15. </div>
  16. <script>
  17. function dsXmlToJson0102_2(xmlStr) {
  18. var $xmlDom = $(xmlStr),
  19. fee_sum = '';//费用总计
  20. $nodes = {
  21. "费用" :$xmlDom.find('component section entry')
  22. } ;
  23. return {
  24. data:{
  25. "门诊分类":(function(){
  26. var arr = [];
  27. _.each($nodes["费用"].find('group'),function(el) {
  28. var $ele = $(el);
  29. arr.push({
  30. "分类名称": $ele.find('type').text(),
  31. "费用金额":$ele.find('fee').text() ?parseFloat($ele.find('fee').text()).toFixed(2):'',
  32. "费用详情": (function() {
  33. var arr1 = [];
  34. _.each($ele.find('item'),function(it) {
  35. var $it = $(it);
  36. arr1.push({
  37. "项目名称": $it.find('value').text(),
  38. "总价": $it.find('total').text() ? parseFloat($it.find('total').text()).toFixed(2) : ''
  39. })
  40. })
  41. return arr1;
  42. })()
  43. })
  44. })
  45. fee_sum = _.reduce( _.pluck(arr, '费用金额'), function(a, b){ return a*1 + b*1; }, 0).toFixed(2);
  46. return arr;
  47. })(),
  48. "费用总计":fee_sum,
  49. }
  50. }
  51. }
  52. function dsXmlToJson0102_1(xmlStr) {
  53. var $xmlDom = $(xmlStr),
  54. fee_sum = '',//费用总计
  55. $nodes = {
  56. "费用" :$xmlDom
  57. } ;
  58. return {
  59. data:{
  60. "门诊分类": (function() {
  61. var arr = [];
  62. _.each($nodes["费用"].find('item'),function(it) {
  63. var $it = $(it);
  64. arr.push({
  65. "分类名称": $it.text(),
  66. "费用金额":$it.attr('total') ? parseFloat($it.attr('total')).toFixed(2):'',
  67. })
  68. })
  69. fee_sum = _.reduce( _.pluck(arr, '费用金额'), function(a, b){ return a*1 + b*1; }, 0).toFixed(2);
  70. return arr;
  71. })(),
  72. "费用总计":fee_sum,
  73. }
  74. }
  75. }
  76. </script>