高章伟
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<apex:page standardController="Maintenance_Contract_Estimate__c" extensions="MaintenanceContractVMPDFController" showHeader="false" sidebar="false" renderAs="pdf" action="{!init}"  applyHtmlTag="false" >
<!-- renderAs="pdf" -->
 
<html>
    <head>
        <style>
        @page {
            size: A4 landscape;
            margin: 12mm 12mm 5mm 12mm;
            
            @bottom-center {
                content: counter(page) " / " counter(pages);
            }
        }
        
        table { border-collapse: collapse; }
        
        td.border-thick-title { border-width: 1pt 0pt 1pt 0pt; border-style: solid; border-color: black; text-align: center; font-size: 10pt;}
        td.border-thick-bottom { border-width: 0pt 0pt 1pt 0pt; border-style: solid; border-color: black; text-align: center;}
        td.detail { text-align: center;  font-size: 10pt;}
        
        </style>
    </head>
<!--    TODO ラベル対応-->
    <body style="font-family: Arial Unicode MS; page-break-inside: auto">
        <apex:variable value="{!1}" var="pageCnt" />
        <apex:variable value="{!0}" var="lineNo" />
        <!-- 改ページループ -->
        <apex:repeat value="{!targetObjList}" var="targetObj">
            <table width="100%" cellspacing="0" cellpadding="0" >
                <tr>
                    <td colspan="2" style="text-align: center;font-size: 20pt">服务合同报价单</td>
                </tr>
                <tr>
                    <td style="text-align: right;">报价编码:</td>
                    <td width="15%" style="text-align: right;">{!targetObj.estimate.Name}</td>
                </tr>
                <tr>
                    <td style="text-align: right;">报价提出日:</td>
                    <td width="15%" style="text-align: right;">{!SUBSTITUTE(TEXT(TODAY()), '-', '/')}</td>
                </tr>
                <tr>
                    <td style="text-align: right;">报价有效截止日:</td>
                    <td width="15%" style="text-align: right;">{!SUBSTITUTE(TEXT(estimateendDate), '-', '/')}</td>
                </tr>
               <!--  <tr>
                    <td colspan="2" style="text-align: right;">此报价单自报价作成日起三个月内有效</td>
                </tr> -->
            </table>
            <table width="100%" cellspacing="0" cellpadding="0" >
                <tr>
                    <td width="15%">&nbsp;</td>
                    <td width="3%">&nbsp;</td>
                    <td width="7%">&nbsp;</td>
                    <td width="15%">&nbsp;</td>
                    <td width="5%">&nbsp;</td>
                    <td width="3%">&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>医院名</td>
                    <td>:</td>
                    <td colspan="2">{!targetObj.estimate.Maintenance_Contract__r.Hospital__r.Name}</td>
                    <td>科室</td>
                    <td>:</td>
                    <td>{!targetObj.estimate.Department__c}</td>
                </tr>
                <tr>
                    <td>合同类型</td>
                    <td>:</td>
                    <td colspan="2">{!targetObj.estimate.Maintenance_Contract__r.RecordType.Name}</td>
                    <td>是否续签</td>
                    <td>:</td>
                    <apex:outputPanel rendered="{!(targetObj.estimate.New_Contract_Type_TxT__c == '新品合同' || targetObj.estimate.New_Contract_Type_TxT__c == '首签合同')}" layout="none">
                        <td colspan="2">新签合同</td>
                    </apex:outputPanel>
                    <apex:outputPanel rendered="{!(targetObj.estimate.New_Contract_Type_TxT__c == '续签合同' || targetObj.estimate.New_Contract_Type_TxT__c == '非续签合同')}" layout="none">
                       <td colspan="2">续签合同</td>
                    </apex:outputPanel>
                </tr>
                <tr>
                    <td>合同预定开始日期</td>
                    <td>:</td>
                    <td colspan="2">{!SUBSTITUTE(TEXT(targetObj.estimate.Contract_Esti_Start_Date__c), '-', '/')}</td>
                    <td>合同月数</td>
                    <td>:</td>
                    <td><apex:outputText value="{0,number,#,###}">
                        <apex:param value="{!targetObj.estimate.Contract_Range__c}" />
                    </apex:outputText>个月</td>
                </tr>
                <tr>
                    <td>提交对象</td>
                    <td>:</td>
                    <td colspan="2">{!targetObj.estimate.Estimate_Target__c}</td>
                   <!--  <apex:outputPanel rendered="{!targetObj.estimate.Estimate_Target__c == '经销商'}" layout="none">
                        <td colspan="2">{!targetObj.estimate.Dealer__r.Name}</td>
                    </apex:outputPanel>
                    <apex:outputPanel rendered="{!targetObj.estimate.Estimate_Target__c == '医院'}" layout="none">
                       <td colspan="2">{!targetObj.estimate.Maintenance_Contract__r.Hospital__r.Name}</td>
                    </apex:outputPanel> -->
                    <td>主担当者</td>
                    <td>:</td>
                    <td colspan="2">{!targetObj.estimate.Maintenance_Contract__r.Service_Contract_Staff__r.Name}</td>
                </tr>
                <tr>
                    <td colspan="7" style="text-align: right">单位:RMB</td>
                </tr>
            </table>
            <table width="100%"  cellspacing="0" cellpadding="0" >
                <tr>
 
                    <td class="border-thick-title" >No.</td>
                    <td  class="border-thick-title" >型号</td>
                    <td  class="border-thick-title" >产品描述</td>
                    <td  class="border-thick-title" >机身编码</td>
                    <td  class="border-thick-title" >安装日期</td>
                    <td  class="border-thick-title" >点检结果</td>
 
                    <apex:outputPanel rendered="{!(targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_Simplify__c) }" layout="none">
                    <td  class="border-thick-title" >最近一期<br/>合同编码</td>
                    </apex:outputPanel>
 
                    <apex:outputPanel rendered="{!(targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_Simplify__c) }" layout="none">
                    <td class="border-thick-title" >最近一期<br/>合同金额</td>
                    </apex:outputPanel>
 
                    <!-- 消费率 打印服务合同报价单PDF    -->
                    <apex:outputPanel rendered="{!(targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_Simplify__c) }" layout="none">
                        <td  class="border-thick-title" >消费率</td>
                    </apex:outputPanel>
 
                    <!-- 调整比例 打印服务合同报价单PDF    -->
                    <apex:outputPanel rendered="{!(targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_Simplify__c) }" layout="none">
                        <td  class="border-thick-title" >调整比例</td>
                    </apex:outputPanel>
 
                    <!-- 基准价格 打印服务合同报价单PDF    -->
                    <apex:outputPanel rendered="{!((targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_RepairPrice__c) || targetObj.estimate.Asset_Repair_Sum_Price__c > 0)}" layout="none">
                        <td  class="border-thick-title" >基准价格</td>
                    </apex:outputPanel>
 
                    <!-- 参保价格 打印服务合同报价单PDF    -->
                    <apex:outputPanel rendered="{!!((targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_RepairPrice__c) || targetObj.estimate.Asset_Repair_Sum_Price__c > 0)}" layout="none">
                        <td  class="border-thick-title" >{!IF(!(targetObj.estimate.Asset_Repair_Sum_Price__c > 0), '参保价格', '')}</td>
                    </apex:outputPanel>
 
                    <!-- 修理金额 打印服务合同报价单PDF    -->
                    <apex:outputPanel rendered="{!(targetObj.estimate.Asset_Repair_Sum_Price__c > 0) }" layout="none">
                    <td  class="border-thick-title" >{!IF(targetObj.estimate.Asset_Repair_Sum_Price__c > 0, '修理金额', '')}</td>
                    </apex:outputPanel>
                    <td class="border-thick-title" >备注</td>
                    <!-- add 点检改善:约定点检设备对象 2021.6.10 fxk start-->
                    <!-- <td class="border-thick-title" >约定点检设备对象</td> -->
                    <!-- add 点检改善:约定点检设备对象 2021.6.10 fxk end-->
                </tr>
                <!-- 明細行ループ -->
                <apex:repeat value="{!targetObj.assetInfoList}" var="asset" id="asset">
                    <tr>
                        <!-- No -->
                        <td class="detail"><c:PDFWbr targetStr="{!asset.lineNo}"/></td>
                        <!-- 型号 -->
                        <td class="detail"><c:PDFWbr targetStr="{!asset.assetModelNo}"/></td>
                        <!-- 机器名称 -->
                        <td class="detail"><c:PDFWbr targetStr="{!asset.assetName}"/></td>
                        <!-- 机身编码 -->
                        <td class="detail"><c:PDFWbr targetStr="{!asset.assetSerialNumber}"/></td>
                        <!-- 安装日期 -->
                        <td class="detail"><c:PDFWbr targetStr="{!asset.installDate}"/></td>
                        <!-- 点检结果 -->
                        <td class="detail"><c:PDFWbr targetStr="{!IF(ISNULL(asset.mcae), '-', asset.mcae.Check_Result_Formula__c)}"/></td>
                        <!-- 最近一期合同编码 -->
                        <apex:outputPanel rendered="{!(targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_Simplify__c) }" layout="none">
                        <td class="detail"><c:PDFWbr targetStr="{!IF(ISNULL(asset.mcae), '-', asset.mcae.Asset__r.CurrentContract_F__r.Maintenance_Contract_No_F__c)}"/></td>
                        </apex:outputPanel>
 
                        <!-- 最近一期合同金额 -->
                        <apex:outputPanel rendered="{!(targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_Simplify__c) }" layout="none">
                        <td class="detail">
                            <apex:outputText value="{0,number,#,##0}" rendered="{!IF(asset.assetSerialNumber == '新购入','false','true')}">
                                <apex:param value="{!IF(ISNULL(asset.mcae), '', asset.mcae.Asset__r.CurrentContract_F_asset__r.Estimate_Cost_formula__c)}" />
                            </apex:outputText>
                        <!--<c:PDFWbr targetStr="{!IF(ISNULL(asset.mcae), '-', asset.mcae.Asset__r.CurrentContract_F_asset__r.Estimate_Cost_formula__c)}"  rendered="{!IF(asset.assetSerialNumber == '新购入','false','true')}"/>--></td>
                        </apex:outputPanel>
 
                        <!-- 消费率 -->
                        <apex:outputPanel rendered="{!(targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_Simplify__c) }" layout="none">
                            <td class="detail">
                               <apex:outputText value="{0,number,#,##0.00%}">
                                    <apex:param value="{!IF(ISNULL(asset.mcae), '', asset.mcae.Asset_Consumption_rate__c)}" />
                                </apex:outputText>
                                <!--<c:PDFWbr targetStr="{!IF(ISNULL(asset.mcae), '', asset.mcae.Asset_Consumption_rate__c)}"/>-->
                            </td>
                        </apex:outputPanel>
                        <!-- 调整比例 -->
                        <apex:outputPanel rendered="{!(targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_Simplify__c) }" layout="none">
                            
                            <td class="detail">
                              <!--  <apex:outputText value="{0,number,#,##0.00%}">
                                    <apex:param value="{!IF(ISNULL(asset.mcae), '', asset.mcae.Maintenance_Contract_Estimate__r.Discount_Percentage__c)}" />
                                </apex:outputText> -->
                                <apex:outputText value="{0,number,#,##0.00%}" rendered="{!IF(asset.assetSerialNumber == '新购入','false','true')}">
                                    <apex:param value="{!IF(targetObj.estimate.Estimate_Target__c == '医院',asset.mcae.Adjustment_ratio_Upper__c , asset.mcae.Adjustment_ratio_Lower__c)}" />
                                </apex:outputText>
                            </td>
                        </apex:outputPanel>
                        <!-- 基准价格 实绩连动规则计算出的标准金额。经销商/医院所有表不同,标准价格也不同。-->
                        <!-- 折扣前显示 或者折扣后 修理大于0 -->
                        <apex:outputPanel rendered="{!((targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_RepairPrice__c) || targetObj.estimate.Asset_Repair_Sum_Price__c > 0)}" layout="none">
                            <td class="detail">
                            <apex:outputText value="{0,number,#,##0}" rendered="{!targetObj.estimate.Estimate_Target__c == '经销商'}">
                                <apex:param value="{!IF(ISNULL(asset.mcae), '', asset.mcae.Adjustment_Lower_price__c)}" />
                            </apex:outputText>
                            <apex:outputText value="{0,number,#,##0}" rendered="{!targetObj.estimate.Estimate_Target__c == '医院'}">
                                <apex:param value="{!IF(ISNULL(asset.mcae), '', asset.mcae.Adjustment_Upper_price__c)}" />
                            </apex:outputText>
                            </td>
                        </apex:outputPanel>
                        <!-- 参保价格 -->
                        <apex:outputPanel rendered="{!!((targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_RepairPrice__c) || targetObj.estimate.Asset_Repair_Sum_Price__c > 0)}" layout="none">
                            <td class="detail">
                                <apex:outputText value="{0,number,#,##0}">
                                    <apex:param value="{!IF(ISNULL(asset.mcae), '', asset.mcae.Benchmark_price__c)}" />
                                </apex:outputText>
                            </td>
                        </apex:outputPanel>
                        <!-- 修理价格 -->
                        <apex:outputPanel rendered="{!(targetObj.estimate.Asset_Repair_Sum_Price__c > 0)}" layout="none">
                            <td class="detail">
                               <apex:outputText value="{0,number,#,##0}">
                                    <apex:param value="{!IF(ISNULL(asset.mcae), '', asset.mcae.Repair_Price__c)}" />
                                </apex:outputText>
                            </td>
                        </apex:outputPanel>
                         <!-- 备注 -->
                        <td class="detail" style="text-align: center;"><c:PDFWbr targetStr="{!asset.mcae.Comment__c}"/></td>
                        <!-- add 点检改善:约定点检设备对象 2021.6.10 fxk start-->
                        <!-- <td class="detail" style="text-align: center;"><c:PDFWbr targetStr="{!If((asset.mcae.Check_Object__c = true),'√','×')}"/></td> -->
                        <!-- add 点检改善:约定点检设备对象 2021.6.10 fxk end-->
                    </tr>
                    <apex:variable value="{!lineNo + 1}" var="lineNo" />
                </apex:repeat>
 
                <!-- 最後ページに合計金額だけが存在する場合のみ、描画しない -->
                <apex:outputPanel rendered="{!NOT(pageCnt == targetObjSize && lineNo < pageCnt)}" layout="none">
                  
                         <tr><td colspan="{!IF(targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_Simplify__c, if(targetObj.estimate.Asset_Repair_Sum_Price__c > 0,'13','13'), if(targetObj.estimate.Asset_Repair_Sum_Price__c > 0,'9','8'))}" class="border-thick-bottom"></td></tr>
                    
                </apex:outputPanel>
                
                
                <apex:outputPanel rendered="{!((targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_RepairPrice__c) || targetObj.estimate.Asset_Repair_Sum_Price__c > 0) && pageCnt == targetObjSize}" layout="none">
                    <tr>
                        <td colspan="{!IF(targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_Simplify__c, if( targetObj.estimate.Asset_Repair_Sum_Price__c > 0,'11','11'), if(targetObj.estimate.Asset_Repair_Sum_Price__c > 0,'7','7'))}" style="text-align: right;">报价总额</td>
                        <td colspan="2" style="text-align: right;">
                            <apex:outputText value="{0,number,#,##0 }" rendered="{!(((targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_RepairPrice__c) || targetObj.estimate.Asset_Repair_Sum_Price__c > 0) &&targetObj.estimate.Estimate_Target__c == '医院')}">
                                <apex:param value="{!targetObj.estimate.GuidePrice_Up__c}" />
                            </apex:outputText>
                            <apex:outputText value="{0,number,#,##0 }" rendered="{!(((targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_RepairPrice__c) || targetObj.estimate.Asset_Repair_Sum_Price__c > 0)  && targetObj.estimate.Estimate_Target__c == '经销商')}">
                                <apex:param value="{!targetObj.estimate.GuidePrice_Down__c}" />
                            </apex:outputText>
                            <apex:outputText value="{0,number,#,##0 }" rendered="{!!((targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_RepairPrice__c) || targetObj.estimate.Asset_Repair_Sum_Price__c > 0)}">
                                <apex:param value="{!benchmark_priceSum}" />
                            </apex:outputText>
                        </td>
                    </tr>
                </apex:outputPanel>
                <apex:outputPanel rendered="{!((targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_RepairPrice__c) || targetObj.estimate.Asset_Repair_Sum_Price__c > 0) &&pageCnt == targetObjSize }" layout="none">
                    <tr>
                        <td colspan="{!IF(targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_Simplify__c, if( targetObj.estimate.Asset_Repair_Sum_Price__c > 0,'11','11'), if(targetObj.estimate.Asset_Repair_Sum_Price__c > 0,'7','7'))}" style="text-align: right;">优惠百分比</td>
                        <td colspan="2" style="text-align: right;">
                            <apex:outputField value="{!targetObj.estimate.Service_DiscountPercentage__c}"/>
                        </td>
                    </tr>
                </apex:outputPanel>
                <apex:outputPanel rendered="{!((targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_RepairPrice__c) && pageCnt == targetObjSize) }" layout="none">
                    <tr>
                        <td colspan="{!IF(targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_Simplify__c, if( targetObj.estimate.Asset_Repair_Sum_Price__c > 0,'11','11'), if(targetObj.estimate.Asset_Repair_Sum_Price__c > 0,'7','7'))}" style="text-align: right;">优惠金额</td>
                        <td colspan="2" style="text-align: right;">
                            <apex:outputText value="{0,number,#,##0 }">
                                <apex:param value="{!targetObj.estimate.Service_Discount_Price__c}" />
                            </apex:outputText>
                        </td>
                    </tr>
                </apex:outputPanel>
                <apex:outputPanel rendered="{!(targetObj.estimate.Asset_Repair_Sum_Price__c > 0) && pageCnt == targetObjSize }" layout="none">
                    <tr>
                        <td colspan="{!IF(targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_Simplify__c, if( targetObj.estimate.Asset_Repair_Sum_Price__c > 0,'11','11'), if(targetObj.estimate.Asset_Repair_Sum_Price__c > 0,'7','7'))}" style="text-align: right;">维修金额总额</td>
                        <td colspan="2" style="text-align: right;">
                            <apex:outputText value="{0,number,#,##0 }">
                                <apex:param value="{!targetObj.estimate.Asset_Repair_Sum_Price__c}" />
                            </apex:outputText>
                        </td>
                    </tr>
                </apex:outputPanel>
                <apex:outputPanel rendered="{!(pageCnt == targetObjSize)}" layout="none">
                    <tr>
                        <td colspan="{!IF(targetObj.estimate.Print_ListPrice__c || targetObj.estimate.Print_Simplify__c, if( targetObj.estimate.Asset_Repair_Sum_Price__c > 0,'11','11'), if(targetObj.estimate.Asset_Repair_Sum_Price__c > 0,'7','7'))}" style="text-align: right;">合同总价格</td>
                        <td colspan="2" style="text-align: right;">
                            <apex:outputText value="{0,number,#,##0 }">
                                <apex:param value="{!targetObj.estimate.Maintenance_Price__c}"/>
                            </apex:outputText>
                        </td>
                    </tr>
                </apex:outputPanel>
            </table>
            
            <apex:outputPanel rendered="{!pageCnt < targetObjSize}" layout="none">
                <div style="page-break-after: always;"/>
            </apex:outputPanel>
            
            <apex:variable value="{!pageCnt + 1}" var="pageCnt" />
        </apex:repeat>
    </body>
</html>
</apex:page>