JS中的JSON过滤方法filter

// 打印所有
        function onAllButtonClick() {
            $("#print div div:contains('项目号:')").html('项目号:' + F.ui.lbItem_no.getText());
            $("#print div div:contains('内部合同号:')").html('内部合同号:' + F.ui.lbContract_i_no.getText());
            $("#print div div:contains('收货单位')").html('收货单位:' + F.ui.customerName.getText());
            $("#print div div:contains('工程:')").html('工程:' + F.ui.Project_name.getText());

            var oldstr = $("#print > div").prop("outerHTML");
            var temp = $("#print").find("div").prop("outerHTML");
            $("#print").empty();
            var list = F.ui.ddlNumber.data;
             //打印所有 每个柜号 的条形码不一样
                F.doPostBack({
                url: '@Url.Action("InvoicesBarCodeMore")',
                    fields: 'ddlNumber,hfPlanOrdersID,ddlContract_i_no',
                params: {
                    list: F.toJSON(list)
                },
                    complete: function (data) {
                        data = JSON.parse(data);
                        if (data.length>0) {
                            for (var i = 0; i < list.length; i++) {

                                $("#print").append(temp);

                                $("#print>div:eq(" + i + ") div:contains('本批货物共')").html(F.ui.Plat_number2.getText() + '' + list[i].text + '件   柜号' + list[i].text);
                                var urlimageData = data.filter((p) => {
                                    return p.containerNumber == list[i].text;
                                });
                                //字符串进行拆分
                                var urlimageDataArr = new Array(); //定义一数组
                                urlimageDataArr = urlimageData[0].productNameAndClientItem.split(","); //字符分割
                                $("#print>div:eq(" + i + ")").find('div[class="productName"]').html('柜型:' + urlimageDataArr[0]);
                                $("#print>div:eq(" + i + ")").find('div[class="clientItem"]').html('客户料号:' + urlimageDataArr[1]);
                            }
                            $('#print').print();
                            $("#print").html(oldstr);
                       }
                }
            });


           
       
        }

 

posted @ 2020-06-20 17:22  咖啡无眠  阅读(9457)  评论(0编辑  收藏  举报