前端vue传值给后台,数组里面是对象形式解决方案

原格式

这个是数组需要循环

[
    {
    
    
        "_id": "635cc5942872c6453e58e4bc",
        "deleted_at": null,
        "id": "635cc5942872c6453e58e4bb",
        "supplier_id": "635a50b8c025aa02245eef53",
        "supplier_sku": "sku0000003",
        "mhw_reference_sku": "sku0002",
        "ean_13": "EAN13_0000003",
        "supplier_barcode_by_hmw": "hmw_barcode_0000003",
        "product_name": "供货商产品0000003",
        "category": "bedroom",
        "long": "0.8",
        "width": "0.2",
        "high": "0.6",
        "sales_unit": "suit",
        "unit_price": 0,
        "package_weight": 1.7,
        "packaging_qty": 20000,
        "minimum_purchase_qty": 1,
        "bulk_unit_price": 17000,
        "bulk_qty": 5,
        "gst_free": "No",
        "warranty": "Yes",
        "description": "超薄液晶屏电视",
        "time": 1667024276,
        "updated_at": {
    
    
            "timestamps": 1667024277,
            "datetime": "2022-10-29 14:17:57"
        },
        "created_at": {
    
    
            "timestamps": 1667024277,
            "datetime": "2022-10-29 14:17:57"
        },
        "supplier": {
    
    
            "_id": "635a50b8c025aa02245eef54",
            "deleted_at": null,
            "id": "635a50b8c025aa02245eef53",
            "under_aca_group": "abc",
            "supplier_category": "Bathroom",
            "company_name": "Company Icn 123",
            "company_initial": "002",
            "ABN": "ABN000012",
            "company_phone_number": "400-600-8820",
            "company_website": "www.test.com",
            "stock_check_link": "string",
            "address_billing_address": "地址地址",
            "credit_limit": 50,
            "position": "string",
            "name": "名称名称",
            "email": "[email protected]",
            "phone": "12345678910",
            "purchase_teams_type": "bathroom",
            "purchase_teams_value": 1,
            "rebate_notes": "xxxxx",
            "payment_method": "card",
            "shipping_method": [],
            "time": 1666863288,
            "updated_at": {
    
    
                "timestamps": 1666863288,
                "datetime": "2022-10-27 17:34:48"
            },
            "created_at": {
    
    
                "timestamps": 1666863288,
                "datetime": "2022-10-27 17:34:48"
            },
            "address_pickup_address": [],
            "supplier_contact": [],
            "supplier_product": [],
            "get_address_pickup_address": [],
            "get_supplier_contact": [],
            "get_supplier_product": []
        },
        "order_qty": "11111",
        "tag": "22222",
        "total": 0
    }
]

打印如图

在这里插入图片描述

解决

num就是上面数据data

const product = num.map((item) => ({
purchase_order_id: item.id,
qty: item.order_qty,
tag: item.tag,
tax_type: item.tag,
}));

console.log(product, ‘productproduct’);

网络传值后

就可以得到想要的数据格式了

在这里插入图片描述

最后

感觉文章好的话记得点个心心和关注和收藏,有错的地方麻烦指正一下,如果需要转载,请标明出处,多谢!!!

猜你喜欢

转载自blog.csdn.net/m0_49714202/article/details/127793754