高章伟
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
<apex:page controller="Lost_Return_DeliverySlipController" showHeader="false" sidebar="false" id="allPage" action="{!init}">
    <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;
           width: 265px; /* Could be more or less, depending on screen size */
        }
        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;
        }
    </style>
    <script type="text/javascript">
        function filljsQR(qrcode) {
            if(!qrcode) return;
            blockme();
            if(scanType == 1){
                j$("input[name$='SlipNo']").val(qrcode);
            }
            else{
                var qrtag = j$("input[name=qrcode][value='"+qrcode+"']");
                if(qrtag == undefined) {
                    return;
                }
                if(qrtag.size() > 1) {
                    alert("数量管理附属品请手动打勾!");
                }
                else if(qrtag.size() == 1) {
                    box = qrtag.siblings("input[type=checkbox]")[0];
                    box.disabled = false;
                    box.checked = true;
                }
            }
            j$("#scanedqr").append("<li>"+qrcode+"</li>");
            j$("#scanedqr").animate({ scrollTop: j$("#scanedqr").prop("scrollHeight")}, 1000);
            unblockUI();
        }
    </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="searchSlip" action="{!searchSlip}" reRender="allForm" onComplete="unblockUI();" />
    <apex:pageBlock id="searchBlock" tabStyle="Report" title="欠品发货">
        <apex:pageBlockButtons location="top">
            <apex:commandButton value="全选/取消全选" onclick="checkGlobal(); return false;" disabled="{!readOnly}"/>
            <apex:commandButton value="扫一扫" onclick="qrscan(0);return false;" disabled="{!readOnly}"/>
            <apex:commandButton value="发货" onclick="blockme();" action="{!returnDelivery}" reRender="allForm" oncomplete="unblockUI();"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection >
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="发货-{!$ObjectType.FixtureDeliverySlip__c.fields.Name.Label}"/>
                <apex:outputPanel >
                    <apex:inputField value="{!slip.Name}" id="SlipNo"/>
                    <apex:commandButton value="扫运输单" onclick="qrscan(1);return false;" disabled="{!readOnly}"/>
                    <apex:commandButton value="检索" onclick="blockme();searchSlip(); return false;" disabled="{!readOnly}" oncomplete="checEventFrame();"/>
                </apex:outputPanel>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem />
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="发货-{!$ObjectType.FixtureDeliverySlip__c.fields.DeliveryType__c.Label}"/>
                <apex:inputField value="{!slip.DeliveryType__c}" id="deliveryType"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="发货-{!$ObjectType.FixtureDeliverySlip__c.fields.Distributor_method__c.Label}"/>
                <apex:inputField value="{!slip.Distributor_method__c}" id="distributorMethod"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="发货-{!$ObjectType.FixtureDeliverySlip__c.fields.DeliveryCompany__c.Label}"/>
                <apex:inputField value="{!slip.DeliveryCompany__c}" id="deliveryCompany"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="发货-{!$ObjectType.FixtureDeliverySlip__c.fields.Wh_Staff__c.Label}"/>
                <apex:outputPanel layout="none">
                    <apex:outputPanel layout="none" rendered="{!readOnly}">
                        <apex:outputField value="{!slip.Wh_Staff__c}" styleClass="hideDropdown"/>
                    </apex:outputPanel>
                    <apex:outputPanel layout="none" rendered="{!readOnly == false}">
                        <apex:inputField value="{!slip.Wh_Staff__c}" styleClass="hideDropdown"/>
                    </apex:outputPanel>
                </apex:outputPanel>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </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 style="width: 110px;">
                   {!SUBSTITUTE($ObjectType.TransferApplyDetail__c.fields.Fixture_Model_No__c.Label, '(Sys)', '')}
                </td>
                <td style="width: 110px;">
                   {!SUBSTITUTE($ObjectType.TransferApplyDetail__c.fields.SerialNumber__c.Label, '(Sys)', '')}
                </td>
                <td style="width: 110px;">
                   {!SUBSTITUTE($ObjectType.TransferApplyDetail__c.fields.TAESD_Status__c.Label, '(Sys)', '')}
                </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="{!pbList}" var="esdInfo">
                        <tr class="" id="tableData_L_{!Cnt}">
                            <td class="dataCellBorder1 col_chk" align="center">
                                <apex:inputCheckbox styleClass="rowchkcls" value="{!esdInfo.checked}" id="rowCheck"/>
                                <input type="hidden" name="qrcode" value="{!esdInfo.tad.Fixture_QRCode_F__c}"/>
                            </td>
                            <td style="width: 110px;">
                                <apex:outputField value="{!esdInfo.tad.Fixture_Model_No__c}"/>
                            </td>
                            <td style="width: 110px;">
                                <apex:outputField value="{!esdInfo.tad.SerialNumber__c}"/>
                            </td>
                            <td style="width: 110px;">
                                <apex:outputField value="{!esdInfo.tad.TAESD_Status__c}"/>
                            </td>
                        </tr>
                    <apex:variable value="{!Cnt+1}" var="Cnt" />
                </apex:repeat>
            </table>
        </div>
    </apex:outputPanel>
    <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;
            }
        });
    });
    function checEventFrame() {
        // j$('select[name$="deliveryType"]').val('回寄');
        j$('select[name$="deliveryType"]').prop('disabled', true);
        // j$("input[name=onetoone]").siblings("input[type=checkbox]").each(function(){
        //     this.disabled = true;
        // })
        if (j$(escapeVfId('allPage:allForm:readOnly')).val() == 'true') {
            j$("input#checker").attr('disabled', 'disabled');
        }
        else {
            j$("input#checker").removeAttr('disabled');
        }
        setTimeout(function() {
            // j$('select[name$="distributorMethod"]').children('option[value="空运"]').remove();
            // j$('select[name$="deliveryCompany"]').children('option[value="莱比特"],option[value="嘉里大通"]').remove();
            if (j$(escapeVfId('allPage:allForm:readOnly')).val() == 'true') {
                j$("input[type=text],select").each(function(){
                    this.disabled = true;
                })
            }
        }, 500);
 
    }
    function checkAll() {
        j$("table#tableData_L td.col_chk input").each(function(){
            if(!this.disabled) {
                this.checked = j$("input#checker").prop('checked');
            }
        })
    }
    var globalChecked = false;
    function checkGlobal() {
        globalChecked = !globalChecked;
        j$("table td.col_chk input[type=checkbox]").each(function(){
            this.checked = globalChecked;
        })
    }
    checEventFrame();
</script>
</apex:form>
</apex:page>