黄千龙
2022-04-08 01f207d979d6be17c8cdec293feab48828c0ec3e
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<apex:page Controller="TransferShippmentReceived2Controller" showHeader="false" sidebar="false" id="allPage" action="{!init}" title="调拨出库入库">
<head>
    <meta name="format-detection" content="telephone=no"/>
</head>
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="{!URLFOR($Resource.instascan)}"/>
<apex:stylesheet value="{!URLFOR($Resource.TransferShippmentReceivedcss)}"/>
<apex:stylesheet value="{!URLFOR($Resource.jquery_confirm, 'jquery-confirm.min.css')}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery_confirm, 'jquery-confirm.min.js')}"/>
 
<script type="text/javascript">
function showConfirm(message, okhandler, errorhandler) {
    j$.confirm({
        title: '确认',
        content: message,
        boxWidth: '50%',
        useBootstrap: false,
        buttons: {
            OK: function () {
                okhandler();
            },
            cancel: {
                text: '取消', // With spaces and symbols
                action: function () {
                    errorhandler();
                }
            }
        }
    });
}
function savejs() {
    j$("select[name$='inspectionResult']").parent().parent().prev().css('color','');
    var emptyObj = j$("select[name$='inspectionResult']").filter(function() {
                        return !this.value;
                    });
    var string = '';
    emptyObj.parent().parent().prev().each(function() {
        string += '「' + j$(this).find("span").text().trim() + '」\n';
    })
    if (emptyObj.size() == 0) {
        blockme();
        save();
    } else {
        showConfirm(string + "以上明细「发货前-检测结果」为空,是否进行下一步操作?", function() {
            blockme();
            save();
        }, function() {
            emptyObj.parent().parent().prev().css('color', 'red');
        })
    }
}
function checkMessage() {
    if (j$(escapeVfId('allPage:allForm:done_flg')).val() == 'true') {
        alert("保存完了");
        window.location.reload(false);
    }
}
function filljs1() {
   j$("select[name$='inspectionResult']").val('OK');
   var selectNg = j$("select[name$='inspectionResultNg']");
   selectNg.children().remove();
   selectNg.append(j$("<option></option>").attr("value",'').text('--なし--'));
   selectNg.prop('disabled', true);
}
function filljsQR(qrcode) {
    blockme();
    var select1 = j$("[data-qr='"+qrcode+"']").children("select");
    if (select1.size() > 1) {
        alert("数量管理附属品请手动打勾!");
    } else {
        select1.val('OK');
        var select2 = j$("[data-qr='"+qrcode+"']").next().find("select");
        select2.children().remove();
        select2.append(j$("<option></option>").attr("value",'').text('--なし--'));
    }
    unblockUI();
    j$("#scanedqr").append("<li>"+qrcode+"</li>");
    j$("#scanedqr").animate({ scrollTop: j$("#scanedqr").prop("scrollHeight")}, 1000);
}
 
function resetDetailDivMargintop() {
    var handerHeight = document.getElementById('hander').clientHeight;
    document.getElementById('detailDiv').style.marginTop = handerHeight + 'px';
}
 
window.onload = function hiddenName(){
    if( document.getElementById('allPage:allForm:CDS_staff_mlktp')){
        document.getElementById('allPage:allForm:CDS_staff_mlktp').style.visibility="hidden" ;
        document.getElementById('allPage:allForm:CDS_staff_mlktp').style.width="200px" ;
    }
    resetDetailDivMargintop();
}
</script>
<style type="text/css">
    .menu div.m_title{
        width: 308px;
        text-align: left;
        margin: 0;
        background:#DCDCDC;
        border-radius:8px 8px 0 0;
        /*height: 42px;*/
    }
    .menu {
        border-radius:8px;
        border:1px solid #D1D1D1;
    }
    .dateFormat {
        display: none;
    }
    #Step_tab {
        list-style-type: none;
        padding: 0;
        height: 25px;
        border-bottom: 5px solid #3b5998;
    }
    #Step_tab li {
        position: relative;
        width: 24%;
        float: left;
        margin: 0;
        padding: 0;
        text-align: center;
        cursor: pointer;
    }
    #Step_tab li span {
        margin: 0;
        padding: 15px 0 11px;
        color: #2daae1;
        font-size: 12px;
        font-weight: bold;
        line-height: 1;
    }
    #Step_tab li.selected {
        background: #3b5998;
    }
    #Step_tab li.selected span {
        color: #fff;
    }
 
    div#main {
        width: 320px;
    }
 
    hr {
        border-top: 2px dotted #f00;
        color: #fff;
        background-color: #fff;
        height: 1px;
        width: 90%;
    }
    .close {
        color: #aaaaaa;
        float: right;
        font-size: 28px;
        font-weight: bold;
    }
    .close:hover,
    .close:focus {
        color: #000;
        text-decoration: none;
        cursor: pointer;
    }
    .menu blockquote{
        margin: 0;
        padding: 1px;
        list-style: none;
        border-top: 1px solid #ddd;
    }
</style>
<div id="myModal" class="modal">
 
  <!-- Modal content -->
  <div class="modal-content">
    <span class="close" onclick="stopScan()">&times;</span>
    <p>扫描中</p>
        <p>Code:<input type="text" id="qrcode"/></p>
    <video playsinline="true" id="preview" style="width: 100%;z-index: 11;transform: scaleX(-1);margin-top: 10px;"></video>
    扫码履历:
    <ul id="scanedqr" style="list-style-type: none; text-align: center;padding: 0;width: 100%; height: 100px; overflow: auto">
    </ul>
 
  </div>
 
</div>
<apex:form id="allForm">
    <!-- OCM_OLY-435 追加 window.location.reload(false) 保存后刷新画面 しないと、triggerにて更新した値がVFに反映されない -->
    <apex:actionFunction name="save" action="{!save}" rerender="detail,message,done_flg" onComplete="checkMessage();unblockUI();resetDetailDivMargintop();" />
    <apex:actionFunction name="Shippment1" action="{!Shippment1}" />
    <apex:actionFunction name="Shippment2" action="{!Shippment2}" />
    <apex:inputHidden value="{!done_flg}" id="done_flg"/>
    <div id="main">
        <div id="hander" class="freezehander">
            <apex:outputPanel id="message">
                <apex:pageMessages />
            </apex:outputPanel>
            <div style="text-align: right;margin-top: 10px;">
              <apex:commandButton styleClass="commandbutton" onclick="savejs();" value="保存" rerender="dummy" disabled="{!saveBtnDisabled}"/>
            </div>
            <apex:outputText id="saveBtnDisabled" value="{!saveBtnDisabled}" style="display: none;"/>
            <table style="border-collapse: collapse; font-size:13px;">
                <colgroup>
                    <col width="150" />
                    <col width="170" />
                </colgroup>
                <tr>
                    <!-- 状态切换btn -->
                    <th colspan="2" style="font-size:20px;text-align: center;width:380px;">
                        <ul id="Step_tab">
                        <apex:outputPanel layout="none" rendered="{!IF(SR_status='Shippment', true, false)}">
                            <apex:outputPanel layout="none" rendered="{!IF(Step_status='发货前', true, false)}">
                                <li onclick="javascript:Shippment1();" class="selected"><span class="tabsize">发货前检查</span></li>
                                <li onclick="javascript:Shippment2();"><span class="tabsize">发货</span></li>
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!IF(Step_status='发货', true, false)}">
                                <li onclick="javascript:Shippment1();"><span class="tabsize">发货前检测</span></li>
                                <li onclick="javascript:Shippment2();" class="selected"><span class="tabsize">发货</span></li>
                            </apex:outputPanel>
                        </apex:outputPanel>
                        </ul>
                    </th>
                </tr>
            </table>
            <div style="text-align: right">
                <apex:commandButton styleClass="commandbutton" onclick="qrsacn()" value="扫一扫" rerender="dummy" rendered="{!IF(Step_status='发货前', true, false)}"/>
                <apex:commandButton styleClass="commandbutton" onclick="filljs1();" value="全部OK" rerender="dummy" rendered="{!IF(Step_status='发货前', true, false)}"/>
            </div>
        </div>
        <apex:outputPanel id="detail">
 
        <div id="detailDiv" class="detail">
            <apex:variable var="indexloop" value="{!0}" />
            <apex:variable var="SetName" value="" />
            <apex:repeat value="{!esdList}" var="esdInfo" id="esdList" rendered="{!IF(SR_status='Shippment', true, false)}">
                <apex:variable var="indexloop" value="{!indexloop+1}"/>
                <apex:variable var="SetName" value="{!IF(SetName='', esdInfo.rec.TransferApplySummary__c, SetName)}" />
                <apex:outputPanel layout="none" rendered="{!IF(SetName=esdInfo.rec.TransferApplySummary__c && indexloop != 1, true, false)}">
                    <br/>
                </apex:outputPanel>
                <apex:outputPanel layout="none" rendered="{!IF(SetName=esdInfo.rec.TransferApplySummary__c, false, true)}">
                    <hr/>
                    <h3 style="padding: 5px;" class="detailtab">{!esdInfo.fsName}</h3>
                    <apex:variable var="SetName" value="{!esdInfo.rec.TransferApplySummary__c}" />
                </apex:outputPanel>
 
                <apex:outputPanel layout="none" rendered="{!IF(indexloop == 1, true, false)}">
                        <h3 style="padding: 5px;" class="detailtab">{!esdInfo.fsName}</h3>
                    </apex:outputPanel>
                <div class="menu">
                <h2><div class="m_title">&nbsp;<apex:outputField value="{!esdInfo.rec.Fixture_Name_F__c}" />&nbsp;&nbsp;
                </div></h2>
                <!-- TODO 回库はSet単位で、明細一つ一つのquickCheck要らないが、SetのquickCheck要る? -->
                <ul style="{!IF(esdInfo.quickCheck, 'background:#BBFF66;', '')}">
                    <apex:outputPanel layout="none" rendered="{!IF(Step_status='发货前', true, false)}">
                        <!-- <div style="position: relative; padding-left: 50px; background:{!IF(esdInfo.quickCheck, '#BBFF66', '')}"> -->
                        <li data-qr="{!esdInfo.rec.Fixture_QRCode_F__c}" style="{!IF(esdInfo.quickCheck, 'background:#BBFF66;', '')}">
                            <span>{!$ObjectType.TransferApplyDetail__c.fields.Inspection_result__c.label}: </span>
                            <apex:outputPanel layout="none" rendered="{!esdInfo.editable}">
                            <apex:inputField id="inspectionResult" value="{!esdInfo.rec.Inspection_result__c}" style="margin:3px;width:75px;" />
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!NOT(esdInfo.editable)}">
                            <span><apex:outputField id="inspectionResult2" value="{!esdInfo.rec.Inspection_result__c}" style="margin:3px;width:75px;" /></span>
                            </apex:outputPanel>
                        </li>
                        <li style="{!IF(esdInfo.quickCheck, 'background:#BBFF66;', '')}">
                            <span>{!$ObjectType.TransferApplyDetail__c.fields.Inspection_result_ng__c.label}: </span>
                            <apex:outputPanel layout="none" rendered="{!(esdInfo.editable)}">
                            <span><apex:inputField id="inspectionResultNg" value="{!esdInfo.rec.Inspection_result_ng__c}" style="margin:3px;width:75px;"/></span>
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!NOT(esdInfo.editable)}">
                            <span><apex:outputField id="inspectionResultNg1" value="{!esdInfo.rec.Inspection_result_ng__c}" style="margin:3px;width:75px;"/></span>
                            </apex:outputPanel>
                        </li>
                        <li style="{!IF(esdInfo.quickCheck, 'background:#BBFF66;', '')}">
                            <span>{!$ObjectType.TransferApplyDetail__c.fields.Pre_NG_abord_reason__c.label}: </span>
                            <apex:outputPanel layout="none" rendered="{!(esdInfo.editable)}">
                            <span>
                                <apex:inputField id="inspectionResultNg2" value="{!esdInfo.rec.Pre_NG_abord_reason__c}" style="margin:3px;width:75px;"/>
                                <script>
                                    disabledShowNG();
                                    function disabledShowNG() {
                                        var inspection_result_NG = '{!esdInfo.rec.Inspection_result_ng__c}';
                                        console.log("====",inspection_result_NG)
                                        if(inspection_result_NG  != '废弃'){
                                            j$(escapeVfId('allPage:allForm:esdList:' + ('{!indexloop}' - 1) + ':inspectionResultNG2')).prop("disabled", true);
                                        }
                                    }
                                </script>
                            </span>
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!NOT(esdInfo.editable)}">
                            <span><apex:outputField id="inspectionResultNg3" value="{!esdInfo.rec.Pre_NG_abord_reason__c}" style="margin:3px;width:75px;"/></span>
                            </apex:outputPanel>
                        </li>
                        <li style="{!IF(esdInfo.quickCheck, 'background:#BBFF66;', '')}">
                            <span>{!$ObjectType.TransferApplyDetail__c.fields.Pre_Inspection_Comment__c.label}: </span>
                            <apex:outputPanel layout="none" rendered="{!(esdInfo.editable)}">
                                <span>
                                    <apex:inputField value="{!esdInfo.rec.Pre_Inspection_Comment__c}" style="margin:3px;width:90%;float:left;"/>
                                </span>
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!NOT(esdInfo.editable)}">
                                <span>
                                    <apex:outputField value="{!esdInfo.rec.Pre_Inspection_Comment__c}" style="margin:3px;width:90%;float:left;"/>
                                </span>
                            </apex:outputPanel>
                        </li>
                        <li style="{!IF(esdInfo.quickCheck, 'background:#BBFF66;', '')}">
                            <span>上次回收后检测时间: </span>
                            <span><apex:outputField rendered="{!IF(esdInfo.rec.Asset__r.Pre_Reserve_TAES_Detail__c==null, false, true)}" value="{!esdInfo.rec.Asset__r.Pre_Reserve_TAES_Detail__r.After_Inspection_time__c}" style="margin:3px;width:75px;"/></span>
                        </li>
                        <li>
                            <span>{!$ObjectType.TransferApplyDetail__c.fields.Pre_After_Inspection_elapsed_days__c.label}: </span>
                            <span><apex:outputField value="{!esdInfo.rec.Pre_After_Inspection_elapsed_days__c}" style="margin:3px;width:75px;"/></span>
                        </li>
                        <li>
                            <span>{!$ObjectType.TransferApplyDetail__c.fields.SerialNumber_F__c.label}: </span>
                            <span><apex:outputField value="{!esdInfo.rec.SerialNumber_F__c}" style="margin:3px;width:75px;"/></span>
                        </li>
                        <!-- </div> -->
                    </apex:outputPanel>
                </ul>
                </div>
            </apex:repeat>
        </div>
        </apex:outputPanel>
    </div>
    <script type="text/javascript">
        var standalone = window.navigator.standalone,
            userAgent = window.navigator.userAgent.toLowerCase(),
            safari = /safari/.test( userAgent ),
            ios = /iphone|ipod|ipad/.test( userAgent );
            ver = '';
            if(ios) {
                ver = (navigator.userAgent).match(/OS (\d)?\d_\d(_\d)?/i)[0].split('_')[0].replace("OS ","");
            }
        let scanner = new Instascan.Scanner({ video: document.getElementById('preview'), scanPeriod: 5 ,mirror: false});
        scanner.addListener('scan', function (content) {
          filljsQR(content);
        });
 
        function qrsacn() {
            if (!standalone && !safari && ios) {
                window.location.href="sfqr://scan";
            } else {
                j$(".modal").show();
                Instascan.Camera.getCameras().then(function (cameras) {
                  if (cameras.length > 0) {
                    if (ver >= 13) {
                        scanner.start(cameras[1]);
                    } else {
                        scanner.start(cameras[0]);
                    }
                  } else {
                    console.error('No cameras found.');
                  }
                }).catch(function (e) {
                  console.error(e);
                });
            }
        }
 
        function stopScan() {
            scanner.stop().then(function () {
                j$(".modal").hide();
            });
            j$("#scanedqr").children().remove();
        }
 
        j$(document).ready(function(){
            j$( '#qrcode' ).unbind();
            j$( '#qrcode' ).keypress( function ( e ) {
                if ( e.which == 13 ) {
                    filljsQR(j$( '#qrcode' ).val());
                    return false;
                }
            });
        });
    </script>
</apex:form>
</apex:page>