高章伟
2023-04-04 ecf60bb0cd5a04ce38120302be4cf55fd3c3a27b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<aura:component implements="force:hasRecordId,flexipage:availableForAllPageTypes" access="global">
    
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="property" type="Property__c" default="{Days_On_Market__c: 0}"/> 
    <aura:attribute name="propertyRecord" type="Property__c"/> 
    <aura:attribute name="formattedDateListed" type="String" /> 
    <aura:attribute name="status" type="String" /> 
    
    <force:recordData aura:id="service" 
                      recordId="{!v.recordId}" 
                      targetFields="{!v.property}" 
                      fields="['Id', 'Date_Listed__c', 'Days_On_Market__c']" 
                      recordUpdated="{!c.recordUpdated}"/>
    
    <aura:handler event="ltng:selectSObject" action="{!c.recordChangeHandler}"/>
 
    <div>
        <lightning:layout >
            <lightning:layoutitem class="{! 'days-block ' + v.status}">
                <div class="days">{!v.property.Days_On_Market__c}</div>days
            </lightning:layoutitem>
            <lightning:layoutitem flexibility="grow" class="chart">
                <div class="{! 'bar ' + v.status }" style="{! 'width:' + v.property.Days_On_Market__c / 90 * 100 + '%' }"/>
                <div class="axis">
                    <div><div class="legend">{!v.formattedDateListed}</div></div>
                    <div><div class="legend">30 days</div></div>
                    <div><div class="legend">60 days</div></div>
                </div>
            </lightning:layoutitem>
        </lightning:layout>
    </div>
    
</aura:component>