2个日期的角度过滤器数组数据

时间:2019-07-25 06:52:14

标签: angular

我有一个看起来像这样的数组列表

{
    "count": 1000,
    "records": [
      {
            "company_id": "1120103661",
            "company_name": "WELLSERVE OILFIELD SERVICES (PVT) LTD",
            "claim_id": "2017\/01\/ISBHHDP00002-2018-00199",
            "user_id": "2017\/01\/ISBHHDP00002-000041",
            "type": "maternity-normal-delivery",
            "claim_category": "Non-Panel",
            "hospital_name": "-",
            "hospital_city": "-",
            "claim_year": "2018",
            "claim_period_start": "2018-02-08 12:02:00",
            "claim_period_end": "2018-02-08 05:02:12",
            "patient_id": "2017\/01\/ISBHHDP00002-157",
            "claim_description": null,
            "status": "settled",
            "created_at": "08-FEB-18",
            "updated_at": "08-FEB-18",
            "submitted_at": "08-FEB-18",
            "claimed_value": "9428",
            "approved_value": "9428",
            "responded_at": "08-FEB-18",
            "settled_at": "08-FEB-18",
            "healthcard_no": "9211-1111-1700-0095",
            "relationship": "Spouse",
            "policy_id": "2017\/01\/ISBHHDP00002",
            "member_name": "Amir Raza Abbasi",
            "patient_name": "Sadia Irshad Kayani",
            "total_limit": "75000",
            "limit_utilized": "9428",
            "remaining_limit": "65572"
        },
        {
            "company_id": "1120103661",
            "company_name": "WELLSERVE OILFIELD SERVICES (PVT) LTD",
            "claim_id": "2017\/01\/ISBHHDP00002-2018-00608",
            "user_id": "2017\/01\/ISBHHDP00002-000065",
            "type": "maternity-caesarean-section-lscs-multiple-births",
            "claim_category": "Non-Panel",
            "hospital_name": "-",
            "hospital_city": "-",
            "claim_year": "2018",
            "claim_period_start": "2018-04-26 12:04:00",
            "claim_period_end": "2018-05-03 05:05:30",
            "patient_id": "2017\/01\/ISBHHDP00002-258",
            "claim_description": "Expired Policy claim as per dr fawad email",
            "status": "settled",
            "created_at": "03-MAY-18",
            "updated_at": "03-MAY-18",
            "submitted_at": "26-APR-18",
            "claimed_value": "15956",
            "approved_value": "15956",
            "responded_at": "26-APR-18",
            "settled_at": "30-APR-18",
            "healthcard_no": "9211-1111-1700-0119",
            "relationship": "Spouse",
            "policy_id": "2017\/01\/ISBHHDP00002",
            "member_name": "Faisal Khan  ",
            "patient_name": "Mahjabeen Zaib",
            "total_limit": "105000",
            "limit_utilized": "15956",
            "remaining_limit": "89044"
        },
        {
            "company_id": "1120103661",
            "company_name": "WELLSERVE OILFIELD SERVICES (PVT) LTD",
            "claim_id": "2017\/01\/ISBHHDP00002-2018-00606",
            "user_id": "2017\/01\/ISBHHDP00002-000072",
            "type": "maternity-caesarean-section-lscs-multiple-births",
            "claim_category": "Non-Panel",
            "hospital_name": "-",
            "hospital_city": "-",
            "claim_year": "2018",
            "claim_period_start": "2018-04-26 12:04:00",
            "claim_period_end": "2018-05-03 05:05:23",
            "patient_id": "2017\/01\/ISBHHDP00002-276",
            "claim_description": null,
            "status": "settled",
            "created_at": "03-MAY-18",
            "updated_at": "03-MAY-18",
            "submitted_at": "26-APR-18",
            "claimed_value": "2817",
            "approved_value": "2817",
            "responded_at": "26-APR-18",
            "settled_at": "30-APR-18",
            "healthcard_no": "9211-1111-1700-0126",
            "relationship": "Spouse",
            "policy_id": "2017\/01\/ISBHHDP00002",
            "member_name": "Yasir Latif",
            "patient_name": "Asma Bibi",
            "total_limit": "105000",
            "limit_utilized": "2817",
            "remaining_limit": "102183"
        }
  ]
}

与数组中一样,responded_at中有一些日期

我正在与用户约会2次。 this.from&this.to。

我需要按2个日期过滤此数组。仅意味着该数组将显示这两个日期之间的哪个。

任何人请告诉我我该怎么做?谢谢

1 个答案:

答案 0 :(得分:1)

您可以为此使用input image

Array.filter()的回调中,您可以将responded_at转换为JavaScript Array.filter对象,并将其与fromto日期进行比较。

const data = {"count":1000,"records":[{"company_id":"1120103661","company_name":"WELLSERVE OILFIELD SERVICES (PVT) LTD","claim_id":"2017/01/ISBHHDP00002-2018-00199","user_id":"2017/01/ISBHHDP00002-000041","type":"maternity-normal-delivery","claim_category":"Non-Panel","hospital_name":"-","hospital_city":"-","claim_year":"2018","claim_period_start":"2018-02-08 12:02:00","claim_period_end":"2018-02-08 05:02:12","patient_id":"2017/01/ISBHHDP00002-157","claim_description":null,"status":"settled","created_at":"08-FEB-18","updated_at":"08-FEB-18","submitted_at":"08-FEB-18","claimed_value":"9428","approved_value":"9428","responded_at":"08-FEB-18","settled_at":"08-FEB-18","healthcard_no":"9211-1111-1700-0095","relationship":"Spouse","policy_id":"2017/01/ISBHHDP00002","member_name":"Amir Raza Abbasi","patient_name":"Sadia Irshad Kayani","total_limit":"75000","limit_utilized":"9428","remaining_limit":"65572"},{"company_id":"1120103661","company_name":"WELLSERVE OILFIELD SERVICES (PVT) LTD","claim_id":"2017/01/ISBHHDP00002-2018-00608","user_id":"2017/01/ISBHHDP00002-000065","type":"maternity-caesarean-section-lscs-multiple-births","claim_category":"Non-Panel","hospital_name":"-","hospital_city":"-","claim_year":"2018","claim_period_start":"2018-04-26 12:04:00","claim_period_end":"2018-05-03 05:05:30","patient_id":"2017/01/ISBHHDP00002-258","claim_description":"Expired Policy claim as per dr fawad email","status":"settled","created_at":"03-MAY-18","updated_at":"03-MAY-18","submitted_at":"26-APR-18","claimed_value":"15956","approved_value":"15956","responded_at":"26-APR-18","settled_at":"30-APR-18","healthcard_no":"9211-1111-1700-0119","relationship":"Spouse","policy_id":"2017/01/ISBHHDP00002","member_name":"Faisal Khan  ","patient_name":"Mahjabeen Zaib","total_limit":"105000","limit_utilized":"15956","remaining_limit":"89044"},{"company_id":"1120103661","company_name":"WELLSERVE OILFIELD SERVICES (PVT) LTD","claim_id":"2017/01/ISBHHDP00002-2018-00606","user_id":"2017/01/ISBHHDP00002-000072","type":"maternity-caesarean-section-lscs-multiple-births","claim_category":"Non-Panel","hospital_name":"-","hospital_city":"-","claim_year":"2018","claim_period_start":"2018-04-26 12:04:00","claim_period_end":"2018-05-03 05:05:23","patient_id":"2017/01/ISBHHDP00002-276","claim_description":null,"status":"settled","created_at":"03-MAY-18","updated_at":"03-MAY-18","submitted_at":"26-APR-18","claimed_value":"2817","approved_value":"2817","responded_at":"26-APR-18","settled_at":"30-APR-18","healthcard_no":"9211-1111-1700-0126","relationship":"Spouse","policy_id":"2017/01/ISBHHDP00002","member_name":"Yasir Latif","patient_name":"Asma Bibi","total_limit":"105000","limit_utilized":"2817","remaining_limit":"102183"}]};
const from = new Date('10-APR-18');
const to = new Date('30-APR-18');

const res = data.records.filter(obj => new Date(obj.responded_at) > from && new Date(obj.responded_at) < to);
console.log(res);