123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <!--
- 费用明细
- -->
- <div class="el-main">
- <div class="el-tit">
- <div class="el-t-l">费用总计</div>
- <div class="el-t-m" ms-text="data['总费用']"></div>
- </div>
-
- <ul class="el-list" ms-if="data['费用'] && data['费用'].length > 0">
- <li class="el-item" ms-repeat="data['费用']">
- <p ms-if="el['分类']">
- <div ms-repeat-el="el['分类']">
- <div class="el-title" ms-if="el['分类']['分类名称'] && el['分类']['分类名称'].trim()">
- <span ms-text="el['分类']['分类名称']"></span>
- <span ms-text="el['分类']['费用']"></span>
- </div>
- <div ms-if="el['分类']['详情']">
- <p ms-repeat-elem="el['分类']['详情']">
- <span class="el-list" ms-if="elem['项目名称'] && elem['项目名称'].length > 0">
- <b ms-text="elem['项目名称']"></b>
- <b ms-text="elem['总价']"></b>
- </span>
- </p>
- </div>
- </div>
- </p>
- <p ms-if="!el['分类']">
- <div class="el-title noline" ms-if="el['项目名称'].trim()"><span ms-text="el['项目名称']"></span><span ms-text="el['总价']"></span></div>
- </p>
- </li>
- </ul>
- </div>
- <script>
-
- function dsXmlToJson0202_2(xmlStr) {
- var $xmlDom = $(xmlStr),
- $nodes = {
- "费用" :$xmlDom.find('component section entry')
- },
- countMon = 0;
- return {
- data:{
- "费用": (function() {
- var arr = [];
- _.each($nodes["费用"].find('group'),function(el,index) {
- var $ele = $(el);
-
- arr[index] = {
- '分类': {
- '分类名称': $ele.find('type').text(),
- '费用': $ele.find('fee').text() ? parseFloat($ele.find('fee').text()).toFixed(2) : '',
- '详情': []
- }
- };
- _.each($ele.find('item'),function(it,ind) {
- var $it = $(it);
- arr[index]['分类']['详情'][ind] = {
- "扣费时间": $it.find('date').text(), // 该字段实际与提供的文档不符
- "项目名称": $it.find('value').text(),
- "规格": $it.find('spec').text(), // 提供的文档没有提到该字段
- "数量": $it.find('quantity').text() ? parseFloat($it.find('quantity').text()).toFixed(0) + $it.find('unit').text() : '',
- "单价": $it.find('price').text() ? parseFloat($it.find('price').text()).toFixed(2) : '',
- "总价": $it.find('total').text(),
- "备注": $it.find('notes').text()
- };
- });
- });
- if(arr.length==0) {
- // arr = [{
- // "扣费时间": " ",
- // "项目名称": " ",
- // "数量": " ",
- // "单价": " ",
- // "总价": " ",
- // "备注": " "
- // }]
- arr = []
- } else {
- countMon = (function () {
- var c = 0;
- console.log(arr);
- _.each(arr,function (item,index) {
- var n = item['分类']['费用'];
- c += parseFloat(n);
- });
- return c.toFixed(2);
- })();
- }
- return arr;
- })(),
- '总费用':countMon
- }
- }
- }
- function dsXmlToJson0202_1(xmlStr) {
- var $xmlDom = $(xmlStr),
- $nodes = {
- "费用" :$xmlDom
- } ;
- return {
- data:{
- "费用": (function() {
- var arr = [];
- _.each($nodes["费用"].find('item'),function(it) {
- var $it = $(it);
- arr.push({
- "项目名称": $it.text(),
- "扣费时间": $it.attr('date'),
- "规格": $it.attr('spec'),
- "数量": $it.attr('quantity') ? parseFloat($it.attr('quantity')).toFixed(2) + $it.attr('unit') : '',
- "单价": $it.attr('price') ? parseFloat($it.attr('price')).toFixed(2) : '',
- "总价": $it.attr('total'),
- "备注": $it.text('notes')
- });
- })
-
- if(arr.length==0) {
- // arr = [{
- // "项目名称":" ",
- // "扣费时间":" ",
- // "规格": " ",
- // "数量": " ",
- // "单价": " ",
- // "总价": " ",
- // "备注": " "
- // }]
- arr = []
- } else {
- countMon = (_.reduce( _.pluck(arr, '总价'), function(a, b){ return a*1 + b*1; }, 0)).toFixed(2);
- }
- return arr;
- })(),
- '总费用':countMon
- }
- }
- }
- </script>
|