binxie
2024-01-16 4d3febe8045eb0fa0283af3c53b0c48344b8664d
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
<!--仿EquipmentSetSRList2.page-->
<apex:page Controller="ReceivingNoteListController" showHeader="false" sidebar="false" id="allPage" action="{!init}" title="收货清单配套一览" lightningStylesheets="true">
<head>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="viewport" content="width=device-width,initial-scale=1"/>
</head>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:stylesheet value="{!URLFOR($Resource.sldsMy)}"/><!-- 20230925 ljh lightning -->
<apex:stylesheet value="{!URLFOR($Resource.StyleUtilColorCss)}"/><!-- 20230619 ljh lightning  -->
<script>
var standalone = window.navigator.standalone,
    userAgent = window.navigator.userAgent.toLowerCase(),
    safari = /safari/.test( userAgent ),
    ios = /iphone|ipod|ipad/.test( userAgent );
 
function checkAll(ele) {
    
    var ckd = j$(ele).attr("checked") ? true : false;
    j$('input[type="checkbox"]:not(:disabled)').prop("checked", ckd);
    
    
}
function checkOK() {
    j$('input[name$="summarycheck"]:checked').each(function() {
        j$(this).parent().parent().find('select[name$="packageStatus"]').val("OK");
    });
}
function go() {
    var type = j$(escapeVfId('allPage:allForm:allBlock:type')).value();
    var typeStr = j$(escapeVfId('allPage:allForm:allBlock:type')).children(':selected').text();
    var raesIds = j$('input[type="checkbox"]:checked').next().map(function() { return j$(this).val(); } ).get();
 
    var hasgrey = j$('input[type="checkbox"]:checked').parent().parent().toArray().some(function(x) {return j$(x).css('background-color') == 'rgb(169, 169, 169)'});
 
    var raesIdsStr = raesIds.join(',');
    if (raesIdsStr == '') {
        alert('请选择至少一条收货清单配套一览');
        return;
    }
    if (type == '无') {
        alert('请选择一种方式');
    } else if(hasgrey && (type == '清点' || type == '验收' || type == '入库')) {
        alert('收货确认NG的一览不能操作');
    } else {
        setType();
    }
}
var photoType, photoId;
function goPhoto(type, pid) {
    photoType = type;
    photoId = pid;
    setType();
}
 
function openLink(linkStr) {
    if (!standalone && !safari && ios) {
        window.location.href = linkStr;
    } else {
        window.open(linkStr,'id');
    }
}
function changePage() {
    if (photoType != null) {
        window.location.href = '/'+photoType+'?id='+photoId+'&no='+j$('input[name$="receiving_note_no"]').val();
        photoType = null;
        photoId = null;
        return;
    }
    var type = j$(escapeVfId('allPage:allForm:allBlock:type')).value();
    var typeStr = j$(escapeVfId('allPage:allForm:allBlock:type')).children(':selected').text();
    var rndIdList = j$('input[type="checkbox"]:checked').next().map(function() { return j$(this).val(); } ).get();
    var rndIdsStr = rndIdList.join(',');
    var url = '';
    if (typeStr == '清点') {
        page = 'ReceivingNoteAcceptance';
        openLink("/apex/"+page+"?id=" + rndIdsStr);
    }
    else if(typeStr == '验收'){
        page = 'ReceivingNoteExamination';
        openLink("/apex/"+page+"?id=" + rndIdsStr);
    }
    else if(typeStr == '入库'){
        page = 'ReceivingNoteStockIn';
        openLink("/apex/"+page+"?id=" + rndIdsStr);
    }
    else if (typeStr == '收货确认'){
        receivedConfirm();
    }
    else if (typeStr == '取消收货确认'){
        receivedConfirm();
    }
}
 
</script>
<style type="text/css">
    .mainTitle {
        font-size: 23px !important;
    }
    th,td{
        text-align: left;
    }
    .pbButton {
        display: none;
    }
 
</style>
<apex:form id="allForm">
    <apex:pageBlock title="收货清单配套一览" id="allBlock" rendered="true">
        <apex:actionFunction name="setType" action="{!setType}" oncomplete="changePage();"/>
        <apex:actionFunction action="{!receivedConfirm}" name="receivedConfirm" reRender="allForm" oncomplete="if({!doneFlg}) {alert('{!selectedType}' == '收货确认' ?'收货确认成功':'取消收货确认成功');location.reload();}"/>
        <apex:outputPanel id="message">
            <apex:pageMessages />
        </apex:outputPanel>
        <!-- 20210331 you WLIG-BV8CHF start-->
        <div style="font-size: 16px;">
            <label style="font-size: 16px;">收货清单No.  {!receiving_note_no}</label>
            <apex:inputHidden value="{!receiving_note_no}" id="receiving_note_no"/>
            <label style="font-size: 16px;">操作 </label>
            <apex:selectList id="type" value="{!selectedType}" size="1" style="height: 35px; font-size: 16px;">
                <apex:actionSupport event="onchange" action="{!checkckb}" rerender="allForm"/>
                <apex:selectOptions value="{!typeList}"/>
            </apex:selectList>
            <apex:outputPanel layout="none" rendered="{!IF(selectedType = '收货确认' || selectedType = '取消收货确认' , TRUE, FALSE)}" >
                <apex:commandButton style="font-size: 16px;" value="全部OK" onclick="checkOK(); return false;"/>
                <apex:commandButton style="font-size: 16px; " value="保存" onclick="go(); return false;"/>
            </apex:outputPanel>
            <apex:outputPanel layout="none" rendered="{!IF(selectedType = '收货确认' || selectedType = '取消收货确认', FALSE, TRUE)}" >
                <apex:commandButton style="font-size: 16px; " value="确定" onclick="go(); return false;"/>
                <apex:commandButton style="font-size: 16px; padding:" value="拍照随货同行单" onclick="goPhoto('ReceivingPhoto','{!rnId}'); return false;"/>
            </apex:outputPanel>
 
        </div>
        <!-- 20210331 you WLIG-BV8CHF end-->
        <table border="1" style="border-collapse: collapse; font-size:18px;">
            <tr>
                <th style="text-align:center;"><input type="checkbox" onchange="checkAll(this)" />全选</th>
                <!--一览编号 -->
                <th style="text-align:center;white-space: normal;">收货清单配套一览No.</th>
                <!--备品配套明细型号-->
                <th style="text-align:center;white-space: normal;">备品配套明细型号</th>
                <!--机身编码-->
                <th style="text-align:center;">机身编码</th>
                <!--QRCODE-->
                <!-- <th style="text-align:center;white-space: normal;">备品QRCode/二维码</th> -->
                <!--备品类别-->
                <th style="text-align:center;">备品类别</th>
                <apex:outputPanel layout="none" rendered="{!IF(selectedType = '收货确认', TRUE, FALSE)}" >
                    <!--外包装是否完好-->
                    <th style="text-align:center;white-space: normal;">外包装是否完好</th>
                    <!--外包装情况备注-->
                    <th style="text-align:center;white-space: normal;">外包装情况备注</th>
                    <th style="text-align:center;">照片</th>
                </apex:outputPanel>
                <apex:outputPanel layout="none" rendered="{!IF(selectedType = '收货确认', FALSE, TRUE)}" >
                    <!--一览状态-->
                    <th style="text-align:center;white-space: normal;">收货清单配套一览状态</th>
                </apex:outputPanel>
            </tr>
            <apex:repeat value="{!summaryInfoList}" var="summaryInfo">
                <tr style="word-break: break-all;{!IF(summaryInfo.rns.Package_Status__c == 'NG', 'background-color: rgb(169, 169, 169);', '')}" >
                    <td><apex:inputCheckbox disabled="{!summaryInfo.disableFalg==false && (contains(selectedType,'收货确认')  || selectedType == '清点' || selectedType == '验收')}" value="{!summaryInfo.isChecked}" id="summarycheck"/><input type="hidden" value="{!summaryInfo.rns.Id}"/></td>
                    <!--一览.一览编号-->
                    <td><a href="openSafri?id={!summaryInfo.rns.Id}">{!summaryInfo.rns.ReceivingNoteSummaryNo__c}</a></td>
                    <!--一览.备品配套明细型号-->
                    <td>{!summaryInfo.rns.Fixture_Model_No_F__c}</td>
                    <!--一览.首条明细.机身编码-->
                    <td>{!summaryInfo.rns.First_RND__r.SerialNumber_F__c}</td>
                    <!--一览.清单.备品类别-->
                    <td>{!summaryInfo.rns.ReceivingNote__r.Asset_loaner_category__c}</td>
                    <apex:outputPanel layout="none" rendered="{!IF(selectedType = '收货确认', TRUE, FALSE)}" >
                        <apex:outputPanel layout="none" rendered="{!summaryInfo.canChange==true}">
                            <!--一览.外包装是否完好-->
                            <td><apex:inputField id="packageStatus" value="{!summaryInfo.rns.Package_Status__c}"/></td>
                            <!--一览.外包装情况备注-->
                            <td><apex:inputField value="{!summaryInfo.rns.Package_Status_Memo__c}"/></td>
                            <td>{!summaryInfo.fileCnt}张已上传<br/><a onclick="goPhoto('ReceivingSummaryPhoto','{!summaryInfo.rns.Id}'); return false;" href="#">追加</a></td>
                        </apex:outputPanel>
                        <apex:outputPanel layout="none" rendered="{!summaryInfo.canChange==false}">
                            <!--一览.外包装是否完好-->
                            <td><apex:outputField value="{!summaryInfo.rns.Package_Status__c}"/></td>
                            <!--一览.外包装情况备注-->
                            <td><apex:outputField value="{!summaryInfo.rns.Package_Status_Memo__c}"/></td>
                            <td>{!summaryInfo.fileCnt}张已上传</td>
                        </apex:outputPanel>
                    </apex:outputPanel>
                    <!--一览.首条明细.二维码-->
                    <!-- <td>{!summaryInfo.rns.First_RND__r.Fixture_QRCode_F__c}</td> -->
                    <!--一览.状态-->
                    <apex:outputPanel layout="none" rendered="{!IF(selectedType = '收货确认', FALSE, TRUE)}" >
                        <td>{!summaryInfo.rns.RNS_Status__c}</td>
                    </apex:outputPanel>
                </tr>
            </apex:repeat>
        </table>
    </apex:pageBlock>
</apex:form>
<apex:relatedList subject="{!relatedNote}" list="AttachedContentDocuments"/>
 
<script>
    // 20231015 ljh add start
    function unblockUI(){
        init();// 20231011 ljh add
    }
    // 重写 url
    init();
    function init(){
        var obgMap = new Map();
        var obgStr = "{!cdlStr}";
        var obgMapTemp = obgStr.split(';');
        for(let i = 0;i<obgMapTemp.length;i++){
            if(obgMapTemp[i] != ''){
                obgMap.set(obgMapTemp[i].split('_')[0],obgMapTemp[i].split('_')[1]);
            }
        }
        console.log(obgMap);
        var _event_list = {};
        // var links = [];
        // 找到页面上所有的a 符合标签
        var linksAll = document.getElementsByClassName("actionLink");
        for(let i = 0; i < linksAll.length;i++  ){
            if(linksAll[i].innerText == '预览'){
                var tempA = linksAll[i].parentNode.nextSibling.children[0]
                if(tempA.innerText == 'QRCode-'+'{!receiving_note_no}'){
                    console.log(tempA.innerText);
                    console.log(linksAll[i].parentNode.parentNode);
                    var tr=linksAll[i].parentNode.parentNode;
                    tr.parentNode.removeChild(tr);
                    // linksAll[i].parentNode.parentNode.hide();
                }
            }
        }
        // console.log('zheli:'+linksAll.length);    
        for(let i = 0; i < linksAll.length;i++  ){
            // console.log('zheli:',linksAll[i].innerText);
            if(linksAll[i].innerText == '预览'){
                // console.log('zheli:',linksAll[i].innerText);
                // links.push(linksAll[i]);
                // console.log();
                // 保存click属性的值
                // var _click = linksAll[i].getAttribute("onclick");
                // 保存href属性的值
                var _href = linksAll[i].getAttribute("href");
                // console.log('zheli00:',_href);
                var tempA = linksAll[i].parentNode.nextSibling.children[0]
                var  _hreff= tempA.getAttribute("href");
                if (_href != null) {
                    // 拿到href属性的值
                    // console.log('zhel99:',_href);
                    // console.log('zheli88:',UrlDecode(_href));
                    var idTemp = UrlDecode(_href).split(',');
                    var idS = idTemp[3].replaceAll('\'','').substring(0,15);
                    // console.log(idS);
                    var lid = obgMap.get(idS);
                    // console.log(lid);
                    // console.log('zheli8899:',idTemp[3].replaceAll('\'',''));
                    // // 给href属性重新设值
                    linksAll[i].setAttribute("href", "/lightning/r/ContentDocument/"+lid+"/view");
                    linksAll[i].setAttribute("target", "_blank");
                }
                if(_hreff != null){
                    var lfidtemp = _hreff.split('/').slice(-1)[0];
                    var lfid = obgMap.get(lfidtemp);
                    console.log(lfidtemp);
                    tempA.setAttribute("href", "/lightning/r/ContentDocument/"+lfid+"/view");
                    tempA.setAttribute("target", "_blank");
                }
 
            }
        }
    }
 
    function UrlDecode(zipStr){ 
      var uzipStr = ''; 
      for (var i = 0; i < zipStr.length; i += 1) {
        var chr = zipStr.charAt(i); 
        if (chr === '+') { 
          uzipStr += ' ';
        } else if (chr === '%') { 
          var asc = zipStr.substring(i + 1, i + 3); 
          if (parseInt('0x' + asc) > 0x7f) {
            uzipStr += decodeURI('%' + asc.toString() + zipStr.substring(i+3, i+9).toString()); 
            i += 8;
          }else{ 
            uzipStr += AsciiToString(parseInt('0x' + asc)); 
            i += 2;
          } 
        }else{ 
          uzipStr += chr; 
        } 
      } 
 
      return uzipStr; 
    } 
     
    function AsciiToString(asccode){ 
      return String.fromCharCode(asccode); 
    }
    // 20231015 ljh add end
</script>
</apex:page>