我试图过滤数据,其中有多个过滤器。 我尝试了map()的多种技术,但是我得到的所有对象都不是。
filtersSelected是放置所有过滤器的对象。
状态是数据[i]。状态,金额是数据[i] .payment_detail.amount_charges.lc_amount
我试图根据用户选择来过滤数据,filtersSelected是用户在前端选择的键。用户可以按任意顺序选择数据(选择过滤器)。
var filtersSelected = {
status: ['acknowledged', 'save_as_draft'],
amount: [100000009],
expiry: [],
};
var data = [{
"user_id": "admin",
"uuid": "3cade470-c0ba-11e9-9adc-795e8c9df56c",
"common_info": {
"lc_name": "",
"lc_id": "as3d24sfi",
"initiation_date": "",
"lc_type": "conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "FGBCONV",
"issuer_reference": "GHQ ARMED Forces Direct of Fin Aff",
"name": "G H Q"
},
"beneficiary_detail": {
"name": "Tafale Aero Systems"
},
"lc_detail": {
"expiry_date": "2019-08-31T00:00:00.000Z"
},
"valid": true,
"visited": true
},
"payment_detail": {
"amount_charges": {
"lc_amount": 100000009,
"currency": "Dirhams"
},
"valid": true,
"visited": true
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": ""
},
"valid": true,
"visited": true
},
"shipment_detail": {
"general_info": {
"shipment_from": "qwert",
"shipment_to": "qwerty"
},
"valid": true,
"visited": true
},
"narrative_detail": {
"valid": true,
"visited": true
},
"attached_documents": [],
"status": "acknowledged",
"status_updated_at": 1566231731134,
"updatedAt": "1566025738195",
"createdAt": "1566024172600",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "040887d0-bcf8-11e9-9ead-37268ca96a91",
"common_info": {
"lc_name": "Gunther Systems_32",
"lc_id": "1023LC2313",
"initiation_date": "16-05-2019",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch_88",
"issuer_reference": "Emirate of Abu Dhabi Finance Dept",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Gunther Systems S.A."
},
"lc_detail": {
"expiry_date": "2019-05-09T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 800000,
"currency": "EUR"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "UBDS Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [{
"file_name": null,
"file_path": null
}],
"status": "returned_to_ghq_for_correction",
"status_updated_at": 1566231731134,
"updatedAt": "1565970913070",
"createdAt": "1565610901767",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "fefc48b0-bce5-11e9-a1f1-93c532b8cd7a",
"common_info": {
"lc_name": "South West Corp 007",
"lc_id": "1023LC2312",
"initiation_date": "21/12/2018",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch",
"issuer_reference": "G H Q Directorate of FIN Affairs",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Tafale Aero Systems"
},
"lc_detail": {
"expiry_date": "2019-05-09T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 9000000,
"currency": "USD"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [],
"status": "submitted_to_bank_for_authorization",
"status_updated_at": 1566231731134,
"updatedAt": "1565603162342",
"createdAt": "1565603162342",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "8686fe30-bce4-11e9-a1f1-93c532b8cd7a",
"common_info": {
"lc_name": "South Corp_89",
"lc_id": "1023LC2329",
"initiation_date": "11/05/2016",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch_18",
"issuer_reference": "G H Q Directorate of FIN Affairs",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Marthsell Adv Tech Solutions"
},
"lc_detail": {
"expiry_date": "2019-05-09T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 4500000,
"currency": "USD"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [],
"status": "approaching_expiry",
"status_updated_at": 1566231731134,
"updatedAt": "1565602530750",
"createdAt": "1565602530750",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "1d154790-bce4-11e9-a1f1-93c532b8cd7a",
"common_info": {
"lc_name": "North and South Corp_89",
"lc_id": "1023LC2310",
"initiation_date": "11/05/2016",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch_18",
"issuer_reference": "G H Q Directorate of FIN Affairs",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Hewlett Harbin First Mach"
},
"lc_detail": {
"expiry_date": "2019-05-09T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 4500000,
"currency": "USD"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [],
"status": "not_processed",
"status_updated_at": 1566231731134,
"updatedAt": "1565602353885",
"createdAt": "1565602353885",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "f5a59830-bcdf-11e9-9264-812f5d20a14a",
"common_info": {
"lc_name": "North and South Corp_89",
"lc_id": "1023LC2316",
"initiation_date": "11/05/2016",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch_18",
"issuer_reference": "G H Q Directorate of FIN Affairs",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Hewlett Harbin First Mach"
},
"lc_detail": {
"expiry_date": "2019-08-20T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 4500000,
"currency": "USD"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [],
"status": "not_processed",
"status_updated_at": 1566153000000,
"updatedAt": "1565600569724",
"createdAt": "1565600569724",
"valid": false,
"visited": false
}];
function updateData(data) {
// 'save_as_draft'
const updatedDataArr = data.filter(item => {
for (key in filtersSelected) {
if (item.status === filtersSelected[key]) {
return false;
}
// arr = filtersSelected[key].map( selectedFilter => {
// if(item.status === selectedFilter){
// return false;
// }
// })
// filtersSelected = {
// status : ['save_as_draft'],
// amount: [],
// expiry:[],
// };
// }
}
return true;
});
console.log(updatedDataArr);
}
updateData(data)
答案 0 :(得分:3)
filtersSelected[key]
是一个数组,而不是字符串。您需要检查相应属性的值是否是其中任何一个,而不是对整个对象进行比较。您可以为此使用Array.prototype.some()
方法。
您正在针对所有过滤器测试item.status
。您应该测试item[key]
来测试与特定过滤器相对应的属性。但是,键amount
和expiry
在您的数据中不存在,因此我不确定您打算它们做什么。
function updateData(data) {
// 'save_as_draft'
const updatedDataArr = data.filter(item => {
for (key in filtersSelected) {
if (filtersSelected[key].some(f => item[key] == f)) {
return false;
}
}
return true;
});
console.log(updatedDataArr);
}
var filtersSelected = {
status: ['acknowledged', 'save_as_draft'],
amount: [100000009],
expiry: [],
};
var data = [{
"user_id": "admin",
"uuid": "3cade470-c0ba-11e9-9adc-795e8c9df56c",
"common_info": {
"lc_name": "",
"lc_id": "as3d24sfi",
"initiation_date": "",
"lc_type": "conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "FGBCONV",
"issuer_reference": "GHQ ARMED Forces Direct of Fin Aff",
"name": "G H Q"
},
"beneficiary_detail": {
"name": "Tafale Aero Systems"
},
"lc_detail": {
"expiry_date": "2019-08-31T00:00:00.000Z"
},
"valid": true,
"visited": true
},
"payment_detail": {
"amount_charges": {
"lc_amount": 100000009,
"currency": "Dirhams"
},
"valid": true,
"visited": true
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": ""
},
"valid": true,
"visited": true
},
"shipment_detail": {
"general_info": {
"shipment_from": "qwert",
"shipment_to": "qwerty"
},
"valid": true,
"visited": true
},
"narrative_detail": {
"valid": true,
"visited": true
},
"attached_documents": [],
"status": "acknowledged",
"status_updated_at": 1566231731134,
"updatedAt": "1566025738195",
"createdAt": "1566024172600",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "040887d0-bcf8-11e9-9ead-37268ca96a91",
"common_info": {
"lc_name": "Gunther Systems_32",
"lc_id": "1023LC2313",
"initiation_date": "16-05-2019",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch_88",
"issuer_reference": "Emirate of Abu Dhabi Finance Dept",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Gunther Systems S.A."
},
"lc_detail": {
"expiry_date": "2019-05-09T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 800000,
"currency": "EUR"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "UBDS Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [{
"file_name": null,
"file_path": null
}],
"status": "returned_to_ghq_for_correction",
"status_updated_at": 1566231731134,
"updatedAt": "1565970913070",
"createdAt": "1565610901767",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "fefc48b0-bce5-11e9-a1f1-93c532b8cd7a",
"common_info": {
"lc_name": "South West Corp 007",
"lc_id": "1023LC2312",
"initiation_date": "21/12/2018",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch",
"issuer_reference": "G H Q Directorate of FIN Affairs",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Tafale Aero Systems"
},
"lc_detail": {
"expiry_date": "2019-05-09T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 9000000,
"currency": "USD"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [],
"status": "submitted_to_bank_for_authorization",
"status_updated_at": 1566231731134,
"updatedAt": "1565603162342",
"createdAt": "1565603162342",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "8686fe30-bce4-11e9-a1f1-93c532b8cd7a",
"common_info": {
"lc_name": "South Corp_89",
"lc_id": "1023LC2329",
"initiation_date": "11/05/2016",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch_18",
"issuer_reference": "G H Q Directorate of FIN Affairs",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Marthsell Adv Tech Solutions"
},
"lc_detail": {
"expiry_date": "2019-05-09T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 4500000,
"currency": "USD"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [],
"status": "approaching_expiry",
"status_updated_at": 1566231731134,
"updatedAt": "1565602530750",
"createdAt": "1565602530750",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "1d154790-bce4-11e9-a1f1-93c532b8cd7a",
"common_info": {
"lc_name": "North and South Corp_89",
"lc_id": "1023LC2310",
"initiation_date": "11/05/2016",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch_18",
"issuer_reference": "G H Q Directorate of FIN Affairs",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Hewlett Harbin First Mach"
},
"lc_detail": {
"expiry_date": "2019-05-09T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 4500000,
"currency": "USD"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [],
"status": "not_processed",
"status_updated_at": 1566231731134,
"updatedAt": "1565602353885",
"createdAt": "1565602353885",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "f5a59830-bcdf-11e9-9264-812f5d20a14a",
"common_info": {
"lc_name": "North and South Corp_89",
"lc_id": "1023LC2316",
"initiation_date": "11/05/2016",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch_18",
"issuer_reference": "G H Q Directorate of FIN Affairs",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Hewlett Harbin First Mach"
},
"lc_detail": {
"expiry_date": "2019-08-20T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 4500000,
"currency": "USD"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [],
"status": "not_processed",
"status_updated_at": 1566153000000,
"updatedAt": "1565600569724",
"createdAt": "1565600569724",
"valid": false,
"visited": false
}];
updateData(data)
答案 1 :(得分:0)
使用filter()和indexOf()方法,您可以过滤数据,并可以根据过滤器将数据存储在单独的数组中。您正在使用filtersSelected [key]这是一个数组,因此必须从数组中获取数据。您可以执行以下操作:
var filtersSelected = {
status: ['acknowledged', 'save_as_draft'],
amount: [100000009],
expiry: [],
};
var data = [{
"user_id": "admin",
"uuid": "3cade470-c0ba-11e9-9adc-795e8c9df56c",
"common_info": {
"lc_name": "",
"lc_id": "as3d24sfi",
"initiation_date": "",
"lc_type": "conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "FGBCONV",
"issuer_reference": "GHQ ARMED Forces Direct of Fin Aff",
"name": "G H Q"
},
"beneficiary_detail": {
"name": "Tafale Aero Systems"
},
"lc_detail": {
"expiry_date": "2019-08-31T00:00:00.000Z"
},
"valid": true,
"visited": true
},
"payment_detail": {
"amount_charges": {
"lc_amount": 100000009,
"currency": "Dirhams"
},
"valid": true,
"visited": true
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": ""
},
"valid": true,
"visited": true
},
"shipment_detail": {
"general_info": {
"shipment_from": "qwert",
"shipment_to": "qwerty"
},
"valid": true,
"visited": true
},
"narrative_detail": {
"valid": true,
"visited": true
},
"attached_documents": [],
"status": "acknowledged",
"status_updated_at": 1566231731134,
"updatedAt": "1566025738195",
"createdAt": "1566024172600",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "040887d0-bcf8-11e9-9ead-37268ca96a91",
"common_info": {
"lc_name": "Gunther Systems_32",
"lc_id": "1023LC2313",
"initiation_date": "16-05-2019",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch_88",
"issuer_reference": "Emirate of Abu Dhabi Finance Dept",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Gunther Systems S.A."
},
"lc_detail": {
"expiry_date": "2019-05-09T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 800000,
"currency": "EUR"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "UBDS Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [{
"file_name": null,
"file_path": null
}],
"status": "returned_to_ghq_for_correction",
"status_updated_at": 1566231731134,
"updatedAt": "1565970913070",
"createdAt": "1565610901767",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "fefc48b0-bce5-11e9-a1f1-93c532b8cd7a",
"common_info": {
"lc_name": "South West Corp 007",
"lc_id": "1023LC2312",
"initiation_date": "21/12/2018",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch",
"issuer_reference": "G H Q Directorate of FIN Affairs",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Tafale Aero Systems"
},
"lc_detail": {
"expiry_date": "2019-05-09T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 9000000,
"currency": "USD"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [],
"status": "submitted_to_bank_for_authorization",
"status_updated_at": 1566231731134,
"updatedAt": "1565603162342",
"createdAt": "1565603162342",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "8686fe30-bce4-11e9-a1f1-93c532b8cd7a",
"common_info": {
"lc_name": "South Corp_89",
"lc_id": "1023LC2329",
"initiation_date": "11/05/2016",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch_18",
"issuer_reference": "G H Q Directorate of FIN Affairs",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Marthsell Adv Tech Solutions"
},
"lc_detail": {
"expiry_date": "2019-05-09T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 4500000,
"currency": "USD"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [],
"status": "approaching_expiry",
"status_updated_at": 1566231731134,
"updatedAt": "1565602530750",
"createdAt": "1565602530750",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "1d154790-bce4-11e9-a1f1-93c532b8cd7a",
"common_info": {
"lc_name": "North and South Corp_89",
"lc_id": "1023LC2310",
"initiation_date": "11/05/2016",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch_18",
"issuer_reference": "G H Q Directorate of FIN Affairs",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Hewlett Harbin First Mach"
},
"lc_detail": {
"expiry_date": "2019-05-09T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 4500000,
"currency": "USD"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [],
"status": "not_processed",
"status_updated_at": 1566231731134,
"updatedAt": "1565602353885",
"createdAt": "1565602353885",
"valid": false,
"visited": false
}, {
"user_id": "admin",
"uuid": "f5a59830-bcdf-11e9-9264-812f5d20a14a",
"common_info": {
"lc_name": "North and South Corp_89",
"lc_id": "1023LC2316",
"initiation_date": "11/05/2016",
"lc_type": "Conventional"
},
"general_info": {
"applicant_detail": {
"bank_name": "TC Gorsch_18",
"issuer_reference": "G H Q Directorate of FIN Affairs",
"name": "GHQ"
},
"beneficiary_detail": {
"name": "Hewlett Harbin First Mach"
},
"lc_detail": {
"expiry_date": "2019-08-20T00:00:00.000Z"
},
"valid": false,
"visited": false
},
"payment_detail": {
"amount_charges": {
"lc_amount": 4500000,
"currency": "USD"
},
"valid": false,
"visited": false
},
"bank_other_party_detail": {
"credit_available": {
"type": "Any Bank",
"credit_available_by": "By Def Payment"
},
"valid": false,
"visited": false
},
"shipment_detail": {
"general_info": {
"shipment_from": "Atlanta, USA",
"shipment_to": "Abu Dhabi, UAE"
},
"valid": false,
"visited": false
},
"narrative_detail": {
"valid": false,
"visited": false
},
"attached_documents": [],
"status": "not_processed",
"status_updated_at": 1566153000000,
"updatedAt": "1565600569724",
"createdAt": "1565600569724",
"valid": false,
"visited": false
}];
let savedraft = [], ack = [], amt = [];
const updatedDataArr = data.filter(item => {
let key = Object.keys(filtersSelected)
for (key in filtersSelected) {
if (key === 'status') {
if (filtersSelected[key].indexOf(item.status) > -1) {
if (item.status === 'save_as_draft') {
savedraft.push(item.uuid)
} else if (item.status === 'acknowledged') {
ack.push(item.uuid)
}
}
}else if (key === 'amount') {
if (item.payment_detail.amount_charges.lc_amount===filtersSelected[key][0]) {
amt.push(item.uuid);
}
}
}
return true;
});
console.log(savedraft);
console.log(ack);
console.log(amt);
“状态” 和“金额” 在“键==='状态” 和“键=== “数量”” 是您保存在数据中的过滤器。希望对您有所帮助。