高章伟
2022-03-18 4bfe21c4b5ddc089ae5a95f4b10f6cff148b690d
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
<apex:page standardController="Product_Set__c" id="ProductSetRollup" readOnly="true" showHeader="false" sidebar="false">
<div class="bPageBlock brandSecondaryBrd bDetailBlock secondaryPalette">
    <table class="detailList" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td class="labelCol" style ="border-bottom:0px;">
                {!$ObjectType.Product_Set_Detail__c.fields.Stop_Quantity__c.Label}&nbsp;
            </td>
            <td class="dataCol col02 inlineEditLock" style="padding-left:5px; border-bottom:0px;">
                <apex:outputField value="{!Product_Set__c.Quantity__c}" id="Sum_Stop"/>
            </td>
        </tr>
    </table>
</div>
<script src="/soap/ajax/30.0/connection.js" type="text/javascript"></script>
<script type="text/javascript">
    var psId = '{!Product_Set__c.Id}';
//    sforce.connection.sessionId = '{!$Api.Session_ID}';
    var resultSet = sforce.connection.query(
        "SELECT Count(Id) Cnt_Id, Sum(Contain_stop_product__c) Cnt_Stop, Sum(Stop_Quantity__c) Sum_Stop" + 
        "  FROM Product_Set_Detail__c" +
        " WHERE Product_Set__c = '" + psId + "'" +
        " GROUP By Product_Set__c"
    );
    var records = resultSet.getArray("records");
    if (records != null && records.length > 0) {
        var aggregateResult = records[0];
        document.getElementById("ProductSetRollup:Sum_Stop").innerText = parseInt(aggregateResult.Sum_Stop);
    } else {
        document.getElementById("ProductSetRollup:Sum_Stop").innerText = "";
    }
</script>
</apex:page>