高章伟
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
<apex:page id="Page" standardcontroller="Account" showHeader="false" sidebar="false" extensions="OFSHospitalLayoutController" action="{!init}" standardStylesheets="true" applyBodyTag="false" applyHtmlTag="false">
<html>
<head>
<meta name="viewport" content="width=1150,user-scalable=no" />     <!-- TODO 1150はコンテンツの幅 -->
<apex:stylesheet value="{!URLFOR($Resource.OFSHospitalLayoutCss)}"/>
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<!--FIXME yu: <title>{!accLabelMap[acc.Id]}</title> -->
<script src="https://hammerjs.github.io/dist/hammer.js"></script>
<script type="text/javascript">
function toggleMenuHover(pDiv) {
    jQuery(pDiv).parent().toggleClass("hoverClass");
    jQuery(pDiv).toggleClass("hoverClass");
}
 
function showAssetLayer() {
    j$("#glayLayer").show();
    j$("#divRelationList").show();
}
 
function checkAll(checker) {
    var cnt = document.getElementById('ProductCnt').value;
    for (var i = 0; i < cnt; i++) {
        document.getElementById('Page:Form:assetBlock:Dataline0:' + i + ':CheckAsset').checked = checker.checked;
    }
}
 
// レイアを用意 と heightをあわせる
j$(function(){
    //reportを読み込む前と後は高さに差がある
    var DIFHT = 21;
    var ht = j$(window).innerHeight() - j$(escapeVfId('InfoHeader')).height() - j$(escapeVfId('InfoFoot')).height() - DIFHT;
    j$(escapeVfId('InfoBody')).css('height', ht + 'px');
    
//alert(j$(escapeVfId('InfoHeader')).height() + j$(escapeVfId('InfoFoot')).height() + ht -j$(window).innerHeight());
//alert(scrollbarWidth());
// レイアを用意
    j$("#glayLayer").click(function(){
        j$(this).hide();
        j$("#divRelationList").hide();
    })
})
</script>
</head>
<body>
    <apex:form id="Form" style="margin:0 5px;">
        <apex:actionFunction name="showList" action="{!showList}" rerender="PanelRelation">
            <apex:param name="p1" assignTo="{!index}" value=""/>
        </apex:actionFunction>
        
        
        
        <apex:outputPanel id="MessageP">
            <apex:pageMessages />
        </apex:outputPanel>
        <div><apex:pageBlock mode="maindetail" Id="Block" rendered="{!initFlag}"> 
            <div style="position: relative;top:0;width:100%;" Id="InfoHeader">
                <ul class="menu-">
                    <li class="menu-case">
                        <div class="menu-name" onclick="toggleMenuHover(this)">☰&nbsp;{!accLabelMap[labelMapKeyMap[acc.Id]]}</div>
                        <ul class="menu-list">
                            <!-- TODO: 販売店はまだ-->
<apex:repeat value="{!accIds}" var="accId" id="AccIds">
                            <li class="menu-one">
                                <a style="text-decoration: none;" href="/apex/OFSHospitalLayout?id={!
URLENCODE(accId)}&wv=1">{!accLabelMap[accId]}</a>
                            </li>
</apex:repeat>
                        </ul>
                    </li>
                </ul>
                <table>
                    <tr>
                        <td><apex:outputLabel value="{!$ObjectType.Account.Label}:" style="font-size:18px;font-weight: bold;padding-right: 5px;"/></td>
                        <td><apex:outputLabel value="{!acc.Name}" style="font-size:18px;font-weight: bold;padding-right: 20px;"/></td>
                        <td style="text-align: center;padding-right: 100px;"><apex:commandButton style="width:80px;" value="保存" action="{!save}"/></td>
                        <td style="text-align: center;"><apex:commandButton style="width:80px;" value="关闭窗口" onclick="location.href='/apex/OFSWindowClose';return false;"/></td>
                    </tr>
                </table>
                <apex:pageBlockSection title="{!sectionList[0].title}" columns="{!sectionList[0].column}" showHeader="{!sectionList[0].showHeader}" rendered="{!sectionList.size>0}">
<apex:repeat value="{!sectionList[0].sectionItemList}" var="sectionItem" id="SectionItemList">
                    <apex:outputField value="{!acc[sectionItem.api]}" rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&&NOT(sectionItem.isInput)}"/>
                    <apex:inputField style="width:{!sectionItem.width};height:{!sectionItem.height};" value="{!acc[sectionItem.api]}" rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&&sectionItem.isInput}" required="{!sectionItem.isRequired}" html-tabindex="{!sectionItem.index}"/>
                    <apex:pageblockSectionItem rendered="{!NOT(sectionItem.isDummy)&&(sectionItem.isCustomize)&&Not(isNull(sectionItem.customizeLable))}">
                        <apex:outputLabel value="{!sectionItem.customizeLable}"/>
                        <apex:outputPanel layout="none">
    <apex:repeat value="{!sectionItem.apiList}" var="api">
                            <apex:outputLabel style="font-weight: bold; padding-right: 5px;" value="{!sectionItem.apiLabelMap[api]}"/>
                            <apex:inputField value="{!acc[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/>
                            <apex:outputPanel style="display:inline-block;{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}">
                                <apex:outputField value="{!acc[api]}"/>
                            </apex:outputPanel>
    </apex:repeat>
                        </apex:outputPanel>
                    </apex:pageblockSectionItem>
                    <apex:pageblockSectionItem rendered="{!NOT(sectionItem.isDummy)&&(sectionItem.isCustomize)&&(isNull(sectionItem.customizeLable))}">
                        <apex:outputPanel layout="none">
    <apex:repeat value="{!sectionItem.apiList}" var="api">
                            <apex:outputLabel style="font-weight: bold; padding-right: 5px;" value="{!sectionItem.apiLabelMap[api]}"/>
                            <apex:inputField value="{!acc[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/>
                            <apex:outputPanel style="display:inline-block;{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}">
                                <apex:outputField value="{!acc[api]}"/>
                            </apex:outputPanel>
    </apex:repeat>
                        </apex:outputPanel>
                    </apex:pageblockSectionItem>
                    <apex:pageBlockSectionItem rendered="{!sectionItem.isDummy}"/>
</apex:repeat>
                </apex:pageBlockSection>
            </div>
            <div style="position: relative;top:0;height:700px;overflow:hidden;overflow-y:auto;-webkit-overflow-scrolling: touch;">
<apex:repeat value="{!sectionList}" var="section" id="SectionList">
                <apex:pageBlockSection title="{!section.title}" columns="{!section.column}" showHeader="{!section.showHeader}" rendered="{!!section.isTop}">
    <apex:repeat value="{!section.sectionItemList}" var="sectionItem" id="SectionItemList">
                    <apex:outputField value="{!acc[sectionItem.api]}" rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&&NOT(sectionItem.isInput)}"/>
                    <apex:inputField style="width:{!sectionItem.width};height:{!sectionItem.height};" value="{!acc[sectionItem.api]}" rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&&sectionItem.isInput}" required="{!sectionItem.isRequired}" html-tabindex="{!sectionItem.index}"/>
                    <apex:pageblockSectionItem rendered="{!NOT(sectionItem.isDummy)&&(sectionItem.isCustomize)&&Not(isNull(sectionItem.customizeLable))}">
                        <apex:outputLabel value="{!sectionItem.customizeLable}"/>
                        <apex:outputPanel layout="none">
        <apex:repeat value="{!sectionItem.apiList}" var="api">
                            <apex:outputLabel style="font-weight: bold; padding-right: 5px;" value="{!sectionItem.apiLabelMap[api]}"/>
                            <apex:inputField value="{!acc[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/>
                            <apex:outputPanel style="display:inline-block;{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}">
                                <apex:outputField value="{!acc[api]}"/>
                            </apex:outputPanel>
        </apex:repeat>
                        </apex:outputPanel>
                    </apex:pageblockSectionItem>
                    <apex:pageblockSectionItem rendered="{!NOT(sectionItem.isDummy)&&(sectionItem.isCustomize)&&(isNull(sectionItem.customizeLable))}">
                        <apex:outputPanel layout="none">
        <apex:repeat value="{!sectionItem.apiList}" var="api">
                            <apex:outputLabel style="font-weight: bold; padding-right: 5px;" value="{!sectionItem.apiLabelMap[api]}"/>
                            <apex:inputField value="{!acc[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/>
                            <apex:outputPanel style="display:inline-block;{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}">
                                <apex:outputField value="{!acc[api]}"/>
                            </apex:outputPanel>
        </apex:repeat>
                        </apex:outputPanel>
                    </apex:pageblockSectionItem>
                    <apex:pageBlockSectionItem rendered="{!sectionItem.isDummy}"/>
    </apex:repeat>
                </apex:pageBlockSection>
</apex:repeat>
            </div>
            <div style="position: fixed; bottom: 0; width:100%;z-index:1" Id="InfoFoot">
                <apex:pageBlockSection title="报告" columns="3" Id="Report"  showHeader="false" >
                    <apex:outputPanel styleClass="reportElement"  layout="block" rendered="{!selectedRptMapList.size > pageNo*3+0}" style="float:left;width:100%">
                        <apex:outputPanel layout="none" rendered="{!(selectedRptMapList[pageNo*3+0]['Column'] != 'false')}">
                            <analytics:reportChart reportId="{!selectedRptMapList[pageNo*3+0]['Report']}" cacheResults="true" size="tiny"  filter="[{column:'{!selectedRptMapList[pageNo*3+0]['Column']}',operator:'startsWith',value:'{!Left(acc.Id,15)}'}]" />
                        </apex:outputPanel> 
                        <apex:outputPanel layout="none" rendered="{!(selectedRptMapList[pageNo*3+0]['Column'] == 'false')}">
                            <analytics:reportChart reportId="{!selectedRptMapList[pageNo*3+0]['Report']}" cacheResults="true" size="tiny"/>
                        </apex:outputPanel>
                    </apex:outputPanel>
                    <apex:outputPanel styleClass="reportElement"  layout="block" rendered="{!selectedRptMapList.size > pageNo*3+1}" style="float:left;">
                        <apex:outputPanel layout="none" rendered="{!(selectedRptMapList[pageNo*3+1]['Column'] != 'false')}">
                            <analytics:reportChart reportId="{!selectedRptMapList[pageNo*3+1]['Report']}" cacheResults="true" size="tiny"  filter="[{column:'{!selectedRptMapList[pageNo*3+1]['Column']}',operator:'startsWith',value:'{!Left(acc.Id,15)}'}]" />
                        </apex:outputPanel> 
                        <apex:outputPanel layout="none" rendered="{!(selectedRptMapList[pageNo*3+1]['Column'] == 'false')}">
                            <analytics:reportChart reportId="{!selectedRptMapList[pageNo*3+1]['Report']}" cacheResults="true" size="tiny"/>
                        </apex:outputPanel>
                    </apex:outputPanel>
                    <apex:outputPanel styleClass="reportElement"  layout="block" rendered="{!selectedRptMapList.size > pageNo*3+2}" style="float:left;">
                        <apex:outputPanel layout="none" rendered="{!(selectedRptMapList[pageNo*3+2]['Column'] != 'false')}">
                            <analytics:reportChart reportId="{!selectedRptMapList[pageNo*3+2]['Report']}" cacheResults="true" size="tiny"  filter="[{column:'{!selectedRptMapList[pageNo*3+2]['Column']}',operator:'startsWith',value:'{!Left(acc.Id,15)}'}]" />
                        </apex:outputPanel> 
                        <apex:outputPanel layout="none" rendered="{!(selectedRptMapList[pageNo*3+2]['Column'] == 'false')}">
                            <analytics:reportChart reportId="{!selectedRptMapList[pageNo*3+2]['Report']}" cacheResults="true" size="tiny"/>
                        </apex:outputPanel>
                    </apex:outputPanel>
                </apex:pageBlockSection>
                <apex:outputPanel rendered="{!selectedRptMapList.size > 0}">
                    <br/>
                    <table style="width:100%; font-size:12px; font-weight:bold;">
                        <tr><td style="text-align:center;">
                            <apex:commandButton id="swipeLeft" action="{!prePage}" value="←" disabled="{!pageNo <= 0}" onclick="windowResize();"/>
                            &nbsp;{!pageNo+1}/{!CEILING(selectedRptMapList.size/3)}&nbsp;
                            <apex:commandButton id="swipeRight" action="{!nextPage}" value="→" disabled="{!pageNo+1 >= CEILING(selectedRptMapList.size/3)}" onclick="windowResize();"/>
                            </td></tr>
                    </table>
                </apex:outputPanel>
                <apex:outputPanel >
                    <table class="relationList">
                        <tr>
<apex:repeat value="{!relationKeyList}" var="rkey">
                            <apex:commandButton value="{!relationMap[rkey].fieldSetLabel}" onclick="showList('{!rkey}');" rerender="dummy"/>&nbsp;&nbsp;
</apex:repeat>
                        </tr>
                    </table>
                </apex:outputPanel>
            </div>
        </apex:pageBlock></div>
        
        <div id="glayLayer" style="z-index:2"></div>
        <!-- 関連リストのLayer-->
        <apex:outputPanel id="PanelRelation" layout="inline" >
        <apex:variable value="{!relationMap[index]}" var="relationList" />
            <div id="divRelationList" style="display:none;z-index:3;top:{!relationList.top};max-height:{!relationList.height}">
                <apex:outputPanel id="PanelAsset" layout="none" rendered="{!(relationList.obj=='Asset')}">
                    <apex:pageBlock id="assetBlock" rendered="{!(relationList.mode=='relation')}">
                        <apex:commandButton value="新建点检报告书" action="{!irCreate}"/>
                        <input type="hidden" id="ProductCnt" value="{!productCount}" />
                        <table class="list" border="1" style="border-collapse:collapse;table-layout:fixed;border-bottom-width:0px;border-spacing:0;width:100%">
                            <tr style="background-color:#DCDCDC;" class="headerRow">
                                <td style="width:25px">
                                    <input type='checkbox' onClick='checkAll(this)'/>
                                </td>
<apex:repeat value="{!relationList.title}" var="t">
                                <td><apex:outputText value="{!t}"/></td>
</apex:repeat>
                            </tr>
<apex:repeat id="Dataline0" value="{!sobjectMap[index]}" var="sobject">
                           <tr>
                                <td style="padding: 2px 5px; width:25px">
                                    <apex:inputCheckbox value="{!checkMap[sobject.Id]}" id="CheckAsset"/>
                                </td>
    <apex:repeat value="{!relationList.columns}" var="cs">
                                <td>
                                    <apex:outputPanel rendered="{!(cs.column1=='')}" layout="none">
                                        <apex:outputField value="{!sobject[cs.column0]}"/>
                                    </apex:outputPanel>
                                    <apex:outputPanel rendered="{!(cs.column1!='')}" layout="none">
                                        <apex:outputField value="{!sobject[cs.column0][cs.column1]}"/>
                                    </apex:outputPanel>
                                </td>
    </apex:repeat>
                            </tr>
</apex:repeat>
                        </table>
                        <apex:commandButton value="新建点检报告书" action="{!irCreate}"/>
<script type="text/javascript">
                        showAssetLayer();
</script>
                    </apex:pageBlock>
                </apex:outputPanel>
                <apex:outputPanel id="PanelOthers" layout="none" rendered="{!(relationList.obj!='Asset')}">
                    <apex:pageBlock rendered="{!(relationList.mode=='relation')}">
                        <table class="list" border="1" style="border-collapse:collapse;table-layout:fixed;border-bottom-width:0px;border-spacing:0;width:100%">
                            <tr style="background-color:#DCDCDC;" class="headerRow">
<apex:repeat value="{!relationList.title}" var="t">
                                <td><apex:outputText value="{!t}"/></td>
</apex:repeat>
                            </tr>
<apex:repeat id="Dataline" value="{!sobjectMap[index]}" var="sobject">
                            <tr>
    <apex:repeat value="{!relationList.columns}" var="cs">
                                <td>
                                    <apex:outputPanel rendered="{!(cs.column1=='')}" layout="none">
                                        <apex:outputField value="{!sobject[cs.column0]}"/>
                                    </apex:outputPanel>
                                    <apex:outputPanel rendered="{!(cs.column1!='')}" layout="none">
                                        <apex:outputField value="{!sobject[cs.column0][cs.column1]}"/>
                                    </apex:outputPanel>
                                </td>
    </apex:repeat>
                            </tr>
</apex:repeat>
                        </table>
<script type="text/javascript">
                        showAssetLayer();
</script>
                    </apex:pageBlock>
                    <apex:outputPanel layout="none" rendered="{!(relationList.mode=='page')}">
                        <apex:iframe height="{!relationList.height}" width="99%" src="{!relationList.fieldSet}" scrolling="true" />
                    </apex:outputPanel>
                </apex:outputPanel>
            </div>
        </apex:outputPanel>
    </apex:form>
    <script type="text/javascript">
        var myElement = document.getElementById('Page:Form:Block:Report');
        var mc = new Hammer(myElement);
        mc.get('pan').set({ direction: Hammer.DIRECTION_ALL });
        mc.on("swipeleft swiperight", function(ev) {
            if (ev.type == "swipeleft") {
                document.getElementById('Page:Form:Block:swipeLeft').click();
            } else {
                document.getElementById('Page:Form:Block:swipeRight').click();
            }
        });
    </script>
</body>
</html>
</apex:page>