高章伟
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
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
<apex:page controller="RentalAgencyReceivedController" showHeader="false" sidebar="false" id="allPage" action="{!init}" title="办事处欠品确认">
    <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:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
<style type="text/css">
    .hideDropdown select{
        display: none
    }
    .modal {
       display:none;
       position: fixed; /* Stay in place */
       z-index: 10; /* Sit on top */
       left: 0;
       top: 0;
       width: 100%; /* Full width */
       height: 100%; /* Full height */
       overflow: auto; /* Enable scroll if needed */
       background-color: rgb(0,0,0); /* Fallback color */
       background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    }
 
    /* Modal Content/Box */
    .modal-content {
       background-color: #fefefe;
       margin-left: 6px;
       margin-top: 100px;
       padding: 20px;
       border: 1px solid #888;
       right: 5%;
       position: absolute;
       width: 200px;
    }
    table.list td{
        width:100px;
        border-width: 1px;
    }
    table.list td.col_chk {
        width:30px;
    }
    body .pbBody table.list tr.headerRow td, body .pbBody table.list tr.headerRow th {
        border-width: 1px;
    }
    .col_stockin {
      position: relative;
      display: inline-block;
      border-bottom: 1px dotted black; /* If you want dots under the hoverable text */
    }
 
    /* Tooltip text */
    .col_stockin .tooltiptext {
      visibility: hidden;
      width: 200px;
      /*background-color: #fefdba;*/
      /*color: #fff;*/
      text-align: center;
      padding: 5px 0;
      border-radius: 6px;
 
      /* Position the tooltip text - see examples below! */
      position: absolute;
      z-index: 1;
    }
 
    /* Show the tooltip text when you mouse over the tooltip container */
    .col_stockin:hover .tooltiptext {
      visibility: visible;
    }
</style>
<script type="text/javascript">
function checkMessage() {
    if (j$(escapeVfId('allPage:allForm:done_flg')).val() == 'true') {
        alert("保存成功");
    }
}
function filljsQR(qrcode) {
    if(!qrcode) return;
    // blockme();
    if(scanType == 1){
        j$("input[name$='SlipNo']").val(qrcode);
    }
    else{
        scanAndCheck(qrcode);
    }
    j$("#scanedqr").append("<li>"+qrcode+"</li>");
    j$("#scanedqr").animate({ scrollTop: j$("#scanedqr").prop("scrollHeight")}, 1000);
    // unblockUI();
}
 
function checkAll() {
    var checked = j$("input#checker").prop('checked')
    j$("table#tableData_L td.col_chk input[type=checkbox]:enabled:visible").each(function(){
        this.checked = checked;
    })
    if(checked) {
        // blockme();
        checkAllOK();
    }
}
var globalChecked = false;
function checkGlobal() {
    globalChecked = !globalChecked;
    j$("table#tableData_L td.col_chk input[type=checkbox]:enabled:visible").each(function(){
        this.checked = globalChecked;
    })
    j$("input#checker").prop('checked', globalChecked);
    if(globalChecked) {
        // blockme();
        checkAllOK();
    }
}
function checkAllOK() {
    j$("#tableData_L td.col_chk input[name=qrcode]").each(function() {
        scanAndCheck(this.value);
    })
}
// 欠品确认和cds连动
function changeCDS(lostResult, follow) {
    var cds = j$(lostResult).parent().parent().find('td.col_cds select');
    if(lostResult.value == 'OK'){
        if(!lostResult.disabled) {
            cds.prop('disabled', false);
        }
        if(lostResult.value == 'OK' && follow) {
            cds.val('OK');
        }
    }
    else {
        cds.val('');
        cds.prop('disabled', true);
    }
}
// 修改选择项时行首自动打勾
function checkLine(raesId) {
    j$("td[name=" + raesId + "]").children("input:enabled:visible")[0].checked=true;
}
// 扫码后整个一览下全部OK
function scanAndCheck(qrcode) {
    var raesId = j$("input[name='qrcode'][value='" + qrcode + "']").parent().attr('name');
    if(raesId == undefined) {
        alert("设备不存在!");
        return;
    }
    // 可操作的下拉框选OK
    j$("#tableData_L tr").each(function() {
       if(j$(this).find('td.col_chk').attr('name') == raesId) {
            j$(this).find('td select:enabled:visible').val('OK');
       }
    })
    // cds连动OK
    j$('td.col_lost select').each(function(){
        changeCDS(this, true);
    })
    // 行首打勾
    checkLine(raesId);
}
 
</script>
<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" styleclass="pbBody">
    <apex:actionFunction name="changeStep" rerender="allForm" oncomplete="unblockUI();"/>
    <apex:actionFunction name="redirectPag" action="{!redirectPag}"/>
    <apex:inputHidden value="{!done_flg}" id="done_flg"/>
 
     <apex:pageBlock id="searchBlock" tabStyle="Report" title="办事处欠品确认">
        <apex:pageBlockButtons location="top">
            回库
            <apex:selectList size="1" value="{!stepName}" onchange="blockme();changeStep();">
                <apex:selectOption itemValue="" itemLabel="--无--"/>
                <apex:selectOption itemValue="欠品确认&CDS" itemLabel="欠品确认&CDS"/>
                <apex:selectOption itemValue="回库确认" itemLabel="回库确认"/>
            </apex:selectList>
            <apex:commandButton value="扫一扫" onclick="qrscan(0);return false;" disabled="{!readOnly || stepName == '' }"/>
            <apex:commandButton value="全选/取消全选" onclick="checkGlobal(); return false;" disabled="{!readOnly}"/>
            <apex:commandButton value="欠品确认&CDS" action="{!lostAndCDS}" onclick="blockme()" disabled="{!readOnly || stepName != '欠品确认&CDS' }" reRender="allForm" oncomplete="unblockUI();checkMessage();"/>
            <apex:commandButton value="回库" action="{!stockup}" onclick="blockme();" rerender="allForm" disabled="{! !stockupActive || stepName != '回库确认'}" oncomplete="unblockUI();checkMessage();"/>
        </apex:pageBlockButtons>
        欠品确认
        <apex:selectList size="1" value="{!lostResult}">
            <apex:selectOption itemValue="" itemLabel="--无--"/>
            <apex:selectOption itemValue="OK" itemLabel="OK"/>
            <apex:selectOption itemValue="欠品" itemLabel="欠品"/>
        </apex:selectList>
        &nbsp;&nbsp;CDS结果
        <apex:selectList size="1" value="{!cdsResult}">
            <apex:selectOption itemValue="" itemLabel="--无--"/>
            <apex:selectOption itemValue="OK" itemLabel="OK"/>
        </apex:selectList>
        &nbsp;&nbsp;
        <apex:commandButton value="检索" onclick="blockme();" action="{!filter}" reRender="allForm" oncomplete="unblockUI();"/>
        <apex:commandButton value="清除" onclick="blockme();" action="{!clearFilter}" reRender="allForm" oncomplete="unblockUI();"/>
    </apex:pageBlock>
    <apex:outputPanel id="message">
        <apex:pageMessages />
    </apex:outputPanel>
    <div id="out_Div_L">
        <table class="list" style="border-bottom-width: 0px; font-size:11px; border-spacing:0;" border="" id="tableHeader_L">
            <tr class="headerRow" height="30px">
                <td class="col_chk" align="center">
                    全选<input type='checkbox' onClick='checkAll();' id="checker"/>
                </td>
                <td>型号</td>
                <td>固定资产编号(Key)</td>
                <td>机身编号</td>
                <td style="{!IF(stepName='欠品确认&CDS','background-color: #cfeef9','')}">欠品确认</td>
                <td style="{!IF(stepName='欠品确认&CDS','background-color: #cfeef9','')}">CDS</td>
                <!-- <td style="width: 110px;" class="onetoone"> 一对一主体 </td> -->
                <td style="{!IF(stepName='回库确认','background-color: #cfeef9','')}">回库确认</td>
            </tr>
        </table>
    </div>
    <apex:outputPanel id="detail">
        <div id="in_Div_L">
            <table class="list" style="border-bottom-width: 0px; font-size:11px; border-spacing:0;" border="" id="tableData_L">
                <apex:variable value="{!0}" var="Cnt" />
                    <apex:repeat id="dataline_L" value="{!esdList}" var="esdInfo">
                        <tr class="" id="tableData_L_{!Cnt}" style="{!IF(esdInfo.hidden,'display: none','')}">
                            <td class="dataCellBorder1 col_chk" align="center" name="{!esdInfo.rec.Rental_Apply_Equipment_Set__c}">
                                <apex:inputCheckbox styleClass="rowchkcls" value="{!esdInfo.checked}" rendered="{!esdInfo.rec.Is_Body__c}"
                                id="rowCheck"
                                onchange="if(this.checked) {scanAndCheck('{!esdInfo.rec.Fixture_QRCode_F__c}');}"/>
                                <input type="hidden" name="qrcode" value="{!esdInfo.rec.Fixture_QRCode_F__c}"/>
                            </td>
                            <td>{!esdInfo.rec.Fixture_Model_No__c}</td>
                            <td>{!esdInfo.rec.Internal_Asset_number_c__c}</td>
                            <td>{!esdInfo.rec.SerialNumber_F__c}</td>
                            <td class="col_lost" style="{!IF(stepName='欠品确认&CDS','background-color: #cfeef9','')}">
                                <apex:selectList size="1" value="{!esdInfo.lostFinished}" disabled="{!!esdInfo.editable || stepName!='欠品确认&CDS' || esdInfo.rec.Arrival_in_wh__c}"
                                                onchange="changeCDS(this, true);checkLine('{!esdInfo.rec.Rental_Apply_Equipment_Set__c}');">
                                    <apex:selectOption itemValue="" itemLabel="--无--"/>
                                    <apex:selectOption itemValue="OK" itemLabel="OK"/>
                                    <apex:selectOption itemValue="欠品" itemLabel="欠品"/>
                                </apex:selectList>
                            </td>
                            <td class="col_cds" style="{!IF(stepName='欠品确认&CDS','background-color: #cfeef9','')}">
                                <apex:selectList size="1" value="{!esdInfo.cdsFinished}" disabled="{!!esdInfo.editable || stepName!='欠品确认&CDS' || esdInfo.rec.Arrival_in_wh__c}"
                                                onchange="checkLine('{!esdInfo.rec.Rental_Apply_Equipment_Set__c}');">
                                    <apex:selectOption itemValue="" itemLabel="--无--"/>
                                    <apex:selectOption itemValue="OK" itemLabel="OK"/>
                                </apex:selectList>
                            </td>
                            <td class="col_stockin" style="{!IF(stepName='回库确认','background-color: #cfeef9','')}">
                                <apex:selectList size="1" value="{!esdInfo.rec.Arrival_wh_Result_Agency__c}"
                                disabled="{!NOT(esdInfo.editable && stepName=='回库确认' && esdInfo.cdsFinished=='OK' && esdInfo.canChangeResult)}"
                                onchange="checkLine('{!esdInfo.rec.Rental_Apply_Equipment_Set__c}');">
                                    <apex:selectOption itemValue="" itemLabel="--无--"/>
                                    <apex:selectOption itemValue="OK" itemLabel="OK"/>
                                    <apex:selectOption itemValue="移至报废区" itemLabel="移至报废区"/>
                                    <apex:selectOption itemValue="待修理" itemLabel="待修理"/>
                                </apex:selectList>
                                <span class="tooltiptext">{!esdInfo.errorInfo}</span>
                            </td>
                        </tr>
                    <apex:variable value="{!Cnt+1}" var="Cnt" />
                </apex:repeat>
            </table>
        </div>
    </apex:outputPanel>
    <apex:outputPanel id="checEventFrame">
        <script>
            j$('td.col_lost select').each(function(){
                changeCDS(this, false);
            })
        </script>
    </apex:outputPanel>
</apex:form>
<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 qrscan(stype) {
        scanType = stype;
        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;
            }
        });
    });
 
    //wangweipeng     2021/09/01   SFDC-C4H4BM    start
    window.onload = function popupWarn(){
        hintNoReceiptForm();
    }
 
    //如果是从单,并且从单没有上传签收单,那么弹出一个提示框
    function hintNoReceiptForm(){
        var isImportReceiptForm = {!isImportReceiptForm};
        if(isImportReceiptForm){
            var hintContent = '';
            var isAdvocateFollow  = {!isAdvocateFollow};
            if(isAdvocateFollow){
                hintContent = '申请单尚未上传签收单,是否继续';
            }else{
                hintContent = '主单尚未上传签收单,是否继续';
            }
            if(!confirm(hintContent)){
                //判断是否是pad端
                if (!standalone && !safari && ios) {
                    //上一步
                    window.history.back(-1);
                }else{
                    redirectPag();
                }
            }
        }
    }
    //wangweipeng     2021/09/01   SFDC-C4H4BM    end
</script>
</apex:page>