美文网首页
把两个数组内容拼装到新对象里

把两个数组内容拼装到新对象里

作者: 唐人不自醉 | 来源:发表于2018-11-27 00:52 被阅读3次

前言,原先数据格式,主要是嵌套循环,for in 循环 对象、然后 后面 内容 循环两个数组。特此记录下

{state:200,
data:[
{getReconProductTradeInfos:[a:aa,b:bb,c:cc,name:xx]},
{getReconDistributions:[d:dd,e:ee,f:ff,name:xx]}
] }
循环 处理后
detail:{
xx:[getReconProductTradeInfo:[a:aa,b:bb,c:cc ]  ],
xx:[getReconDistribution:[d:dd,e:ee,f:ff ] ]
}
 function recorderDetail() {
                var url =  'dizhineirongxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
                // var url = WebApi.addressUrl + 'api/v1/recorderDetail';
                var params={
                    'bill_type':scope.bill_type,
                    'bill_period':scope.bill_period,
                    'cust_id':scope.cust_id,
                }
                WebApi.post(params, url).then(function (res) {
                    if(res.msg == 'SUCCESS'){
                        console.log(res);
                        // 交易信息 getReconProductTradeInfos
                        var getReconProductTradeInfo = res.data[1].getReconProductTradeInfos;
                        console.log(getReconProductTradeInfo);
                       
                        // 分配信息   getReconDistributions
                        var getReconDistribution = res.data[0].getReconDistributions;
                        console.log(getReconDistribution);
                        if( res.data[1].getReconProductTradeInfos.length == '0' && res.data[0].getReconDistributions.length =='0'){
                            scope.part2Count = false;
                            return false;
                        }
                        var companymess = [];
                        var detail = {};
                        getReconProductTradeInfo.forEach(function (item,index) {
                            if (!detail[item.product_NAME]) {
                                detail[item.product_NAME] = {
                                    getReconProductTradeInfo: [],
                                    getReconDistribution: []
                                }
                            }
detail[item.product_NAME].getReconProductTradeInfo.push(item)
                        })
                        getReconDistribution.forEach(function (item,index) {
                            if (!detail[item.product_NAME]) {
                                detail[item.product_NAME] = {
                                    getReconProductTradeInfo: [],
                                    getReconDistribution: []
                                }
                            }
                            detail[item.product_NAME].getReconDistribution.push(item)
                        })
                        console.log(getReconProductTradeInfo) // 合同信息
                        console.log(getReconDistribution) // 交易信息
                        console.log(detail);
                        scope.detail = detail;
                    ued.$apply();
                    }else{
                        weui.alert(res.data);
                    }
                });  
            }

html部分


                <div ng-repeat="(key, val) in detail track by $index" ng-if="detail">
                    <h5 class="title">{{$index+1}}.{{key}}</h5>
                    

                    <h5><i class="dot"></i>期间信托合同交易信息</h5>
                    <table>
                        <thead>
                            <tr>
                                <th>交易类型</th>
                                <th>成交日期</th>
                                <th>成交单位净值</th>
                                <th>金额</th>
                                <th>份额</th>
                                <th>收益</th>
                                <th>扣减费用</th>
                            </tr>
                        </thead>
                        <tbody>
                        
                            <tr ng-repeat="item1 in val.getReconProductTradeInfo">
                                <td>{{item1.bill_BIZ_TYPE }}</td>
                                <td>{{item1.trade_DATE }}</td>
                                <td>{{item1.net_VALUE}}</td>
                                <td>{{rmb(item1.amount)}}</td>
                                <td>{{rmb(item1.shares )}}</td>
                                <td>{{rmb(item1.fp_AMOUNT)}}</td>
                                <td>{{rmb(item1.fee_AMOUNT)}}</td>
                            </tr>

                            <tr  ng-show="val.getReconProductTradeInfo.length == 0">                                
                                    <td>--</td>
                                    <td>--</td>
                                    <td>--</td>
                                    <td>--</td>
                                    <td>--</td>
                                    <td>--</td>
                                    <td>--</td>
                            </tr>
                       </tbody>
                    </table>

                    <h5><i class="dot"></i>期间信托合同分配信息</h5>
                    <table>
                        <thead>
                        <tr>
                            <th>分配类型</th>
                            <th>分配方式</th>
                            <th>分配日</th>
                            <th>分配金额</th>
                            <th>分配份额</th>
                            <th>收款银行</th>
                            <th>收款账号</th>
                        </tr>
                        </thead>
                        <tbody>
                            <tr ng-repeat="item2 in val.getReconDistribution" >                                
                                <td>{{item2.bill_FP_TYPE}}</td>
                                <td>{{item2.bill_FP_WAY}}</td>
                                <td>{{item2.fp_DATE}}</td>
                                <td>{{rmb(item2.amount)}}</td>
                                <td>{{rmb(item2.shares) }}</td>
                                <td>{{item2.fp_BANKE}}</td>
                                <td>{{item2.fp_ACCOUNT_NUM }}</td>
                            </tr>

                            <tr  ng-show="val.getReconDistribution.length == 0">                                
                                    <td>--</td>
                                    <td>--</td>
                                    <td>--</td>
                                    <td>--</td>
                                    <td>--</td>
                                    <td>--</td>
                                    <td>--</td>
                            </tr>
                              
                        </tbody>
                    </table>
                </div>

相关文章

  • 把两个数组内容拼装到新对象里

    前言,原先数据格式,主要是嵌套循环,for in 循环 对象、然后 后面 内容 循环两个数组。特此记录下 html部分

  • 处理数组对象,相同日期的数据加和

    思路:1遍历这个数组 然后把每个对象里面的年月日拼起来 拼成一个新的key 然后返回一个新的数组 就类似与['on...

  • 深浅拷贝

    浅拷贝将原对象/原数组的引用直接赋值给新对象/新数组,新对象/新数组只是原对象/原数组的一个引用。 深拷贝将原对象...

  • 把水装到月光里去把水装到太阳里去把水装到土地里去把水装到日子里去把水装到车子里去车子开到远方城市里去 水,生命最初...

  • 面向对象01

    面向对象思想的引入 我们学过数组,当有多个数组都需要遍历时,我们可以将遍历的代码封装到方法里,需要遍历的时候,就调...

  • 面向对象的三大特性:

    面向对象的三大特性,主要表现子哪方面 封装、继承 和 多态。 封装:把属性封装到对象当中 把相同方法封装到对象当中

  • JavaScript比较两个数组的内容是否相同

    比较两个数组内容是否相同 比较两个Object对象元素是否相同

  • Es6之判断b数组对象有没有跟a数组对象相同的id,有的话就过滤

    如下两个[数组]对象a和b filter() 方法创建一个新的数组,新数组中的元素是通过检查指定数组中符合条件的所...

  • NSArray和NSMutableArray

    NSArray不可变数组 初始化 字面量创建 数组元素个数 判断对象是否在数组中 某对象的位置 某位置的对象 �拼...

  • ES6+好用的小技巧,让你的代码更干净,短巧,易读

    模板字符串 扩展操作符 … 操作符,有两个主要用处:复制一个新的数组或对象把多个参数赋值给一个数组变量把一个数组变...

网友评论

      本文标题:把两个数组内容拼装到新对象里

      本文链接:https://www.haomeiwen.com/subject/cqlwqqtx.html