高章伟
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
<apex:page standardController="DiscountProductApplication__c" extensions="DiscountProductApplicationController"  action="{!init}"  showHeader="false"   sidebar="true" id="dpaPage"  title="特价产品申请信息">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
<apex:includeScript value="/soap/ajax/29.0/connection.js"/>
<apex:includeScript value="/soap/ajax/29.0/apex.js"/>
    <script>
function setFocusOnLoad() {}
function bodyOnLoad(){setFocusOnLoad();}
        function searchAimsAccount1(){
            // openPopup('/apex/searchAimsAccount?accId={!dpa.RawAccount__c }', 'setsearch', 800, 600, 'width=900,height=600,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=1', true);
            var flag = {!ispage};
            if (flag == true) {
                // var accid = j$(escapeVfId('dpaPage:dpaForm:dpaBlock:rawAccountId_lkid')).value();
                var accid = j$(escapeVfId('dpaPage:dpaForm:dpaBlock:rawAccountId')).value();
                openPopup('/apex/searchAimsAccount?accName='+accid, 'setsearch', 800, 600, 'width=900,height=600,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=1', true);
            }else{
                openPopup('/apex/searchAimsAccount?accId={!dpa.RawAccount__c }', 'setsearch', 800, 600, 'width=900,height=600,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=1', true);
            }
 
        }
 
        function checkAll() {
            blockme(); 
            selectedSize = 0;
            var productCount = j$(escapeVfId('dpaPage:dpaForm:ConsumableorderdetailsSection:unCheckedDpadCount')).value();
            if (j$(escapeVfId('checker')).attr('checked') == 'checked') {
                for (var i = 0; i < productCount; i++) {
                    j$(escapeVfId('dpaPage:dpaForm:ConsumableorderdetailsSection:Product2List:' + i + ':variableinfo' + ':Product2Check')).attr('checked',true);
                    selectedSize ++;
                    //alert(selectedSize);
                }
            } else {
                //var outer = 0;
                for (var i = 0; i < productCount; i++) {
                    //outer = Math.floor(i / 1000);
                    j$(escapeVfId('dpaPage:dpaForm:ConsumableorderdetailsSection:Product2List:' + i + ':variableinfo' + ':Product2Check')).attr('checked',false);
                    //selectedSize --;
                }
            }
        }
        
        // function pdValue(j){
        //     var z;
        //     var a = j.id;
        //     var i=a.substring(0,a.lastIndexOf(':'));
        //     z  =  parseFloat(j$(escapeVfId(i+':ProductDiscount')).value());
        //     if(isNaN(z)){z=0.00;}
        //     var y = parseFloat(j$(escapeVfId(i+':ProductDiscountmoney')).value());
 
        //     if(y == null || (y != z && z!=null&&z!=0&&z!='')){
        //     j$(escapeVfId(i+':variableinfo:Product2Check')).attr('checked',true);
        //     }else{
        //     j$(escapeVfId(i+':variableinfo:Product2Check')).attr('checked',false);
        //     }
        // }
        function pdValue(j){
            var a = j.id;
            var i=a.substring(0,a.lastIndexOf(':'));
            var strz = j$(escapeVfId(i+':ProductDiscount')).value();
            strz = strz.replace(',','');
            var z  =  parseFloat(strz+"");
            console.log('z:'+z);
            console.log('strz:'+strz);
 
            var strOldValue = j$(escapeVfId(i+':ProductDiscountmoney')).value();
 
            var oldValue = parseFloat(strOldValue);
            console.log('oldValue:'+oldValue);
            if (isNaN(z) && isNaN(oldValue)) {
                j$(escapeVfId(i+':variableinfo:Product2Check')).attr('checked',false);
 
            }else{
                if (z != oldValue) {
                    console.log('12');
                    j$(escapeVfId(i+':variableinfo:Product2Check')).attr('checked',true);
                }else if (z == oldValue) {
                    j$(escapeVfId(i+':variableinfo:Product2Check')).attr('checked',false);
                }
            }
            
            
            
 
        }
        function SearchJs(){
 
        }
 
        //add by rentx 2021-2-20
        function searchAccount() {
            // body...
            openPopup('/apex/searchAccount', 'setsearch', 800, 600, 'width=900,height=600,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=1', true);
        }
 
        function searchFn() {
            blockme();
            search();
            j$(escapeVfId("dpaPage:dpaForm:dpaBlock:tempid")).val('tempId');
            // j$(escapeVfId('dpaPage:dpaForm:dpaBlock:tempid')).value() = 'tempid';
 
        }
 
        //add by rentx 2021-2-20
    </script>
 
    <apex:form id="dpaForm" >
        <apex:actionFunction name="search" action="{!searchAllProduct2}" oncomplete="unblockUI();" reRender="ConsumableorderdetailsSection,message" />
        <apex:pageBlock title="特价产品申请信息" id="dpaBlock" >
            <apex:pageBlockButtons location="top"  >
                <apex:commandButton value="保存" disabled="{!IF(dpa.ApplicationStatus__c='申请中'||dpa.ApplicationStatus__c='批准'||dpa.ApplicationStatus__c='驳回',true,false)}" onclick="blockme();" style="margin-left:30px;width:100px" action="{!savesaveDiscountProduct}" onComplete="unblockUI();CheckStatusAfter();" reRender="ConsumableorderdetailsSection,message"/>
            </apex:pageBlockButtons>
            <table style="width: 900px;margin: auto;">
                <tr>
                    <td align="right" >经销商:</td>
                    <td align="left">
                        <!-- //update by rentx 2021-2-22 start -->
                        <apex:outputField rendered="{!!isPage}" value="{!dpa.RawAccount__c}" style="width:300px"/>
                        <apex:inputField id="rawAccountId" rendered="{!isPage}" required="true" value="{!dpa.RawAccount__c}" />
                        <!-- //update by rentx 2021-2-22 end -->
                    </td>
 
                    <td/>
                    <td align="right">医院:
                    </td>
                    <td width="100px"><apex:inputText id="AimsAccount" disabled="{!IF(dpa.ApplicationStatus__c='申请中'||dpa.ApplicationStatus__c='批准'||dpa.ApplicationStatus__c='驳回',true,false)}" style="width:150px" value="{!AimsAccount}" onclick="searchAimsAccount1()"  
                        onfocus="if (j$(escapeVfId('dpaPage:dpaForm:dpaBlock:tempid')).value() != 'tempId' && j$(escapeVfId('dpaPage:dpaForm:dpaBlock:tempid')).value() != '') {searchFn()}" />
                    </td>
                    <td style="display:none"><apex:inputText style="display:none" id="AimsAccountId" value="{!AimsAccountId}"/></td>
                    <td style="display:none"><apex:inputText style="display:none"  value="{!dpa.ApplicationStatus__c }"/></td>
                    <apex:inputHidden id="tempid" value="{!tempVal}"/>
 
                    <td>
                        <!-- <apex:commandButton value="保存" disabled="{!IF(dpa.ApplicationStatus__c='申请中'||dpa.ApplicationStatus__c='批准'||dpa.ApplicationStatus__c='驳回',true,false)}" onclick="blockme();" style="margin-left:30px;width:180px" action="{!savesaveDiscountProduct}" onComplete="unblockUI();CheckStatusAfter();" reRender="ConsumableorderdetailsSection,message"/> -->
                        <!-- <apex:commandButton value="保存" disabled="{!IF(dpa.ApplicationStatus__c='申请中'||dpa.ApplicationStatus__c='批准'||dpa.ApplicationStatus__c='驳回',true,false)}" onclick="blockme();saveAimsAccountId();" style="margin-left:30px;width:180px" action="{!savesaveDiscountProduct}" onComplete="unblockUI();CheckStatusAfter();" reRender="ConsumableorderdetailsSection,message"/> -->
                    </td>
                    <!-- <td/> -->
                </tr>
                <tr style="height: 10px" />
                <tr>
                    <td align="right" >产品名称:</td>
                    <td align="left"><apex:inputText disabled="{!IF(dpa.ApplicationStatus__c='申请中'||dpa.ApplicationStatus__c='批准'||dpa.ApplicationStatus__c='驳回',true,false)}" value="{!text1}" style="width:300"/>
                    </td>
                    <td/>
                    <td align="right" >产品编码:</td>
                    <td align="left"><apex:inputText disabled="{!IF(dpa.ApplicationStatus__c='申请中'||dpa.ApplicationStatus__c='批准'||dpa.ApplicationStatus__c='驳回',true,false)}" value="{!text2}" style="width:150px"/>
                    </td>
                    
                    <td><apex:commandButton value="检索" disabled="{!IF(dpa.ApplicationStatus__c='申请中'||dpa.ApplicationStatus__c='批准'||dpa.ApplicationStatus__c='驳回',true,false)}" onclick="blockme();" style="margin-left:30px;width:100px" action="{!searchAllProduct2}" oncomplete="unblockUI();" reRender="ConsumableorderdetailsSection,message"/>
                    </td>
                </tr>
            </table>
        </apex:pageBlock>
 
        <apex:outputPanel id="message" >
            <apex:pageMessages />
        </apex:outputPanel>
            <apex:pageBlock title="特价产品明细" id="ConsumableorderdetailsSection">
                <input type="hidden" id="dpaPage:dpaForm:ConsumableorderdetailsSection:unCheckedDpadCount" value="{!unCheckedDpadCount}" />
                
                <table class="list" border="0" cellpadding="0" cellspacing="0">
                    <colgroup>
                        <col width="4%" />
                        <col width="34%" />
                        <col width="9%" />
                        <col width="9%" />
                        <col width="9%" />
                        <col width="9%" />
                        <col width="9%" />
                        <col width="9%" />
                        <col width="8%" />
                    </colgroup>
                    <tr class="headerRow">
                        
                        <apex:variable var="" value="" >
                            <th  type='checkbox' onClick='checkAll()'>
                                <input disabled="{!IF(dpa.ApplicationStatus__c='申请中'||dpa.ApplicationStatus__c='批准'||dpa.ApplicationStatus__c='驳回',true,false)}" type='checkbox' onClick='checkAll()' id='checker'/>选择</th>
                        </apex:variable>
                        
                        <!-- update by rentx 2021-01-17 -->
                        <!-- <th>产品检索用</th> -->
                        <th>产品名称</th>
                        <!-- update by rentx 2021-01-17 -->
 
                        <th>产品编码</th>
                        <th>NMPA状态</th>
                        <!-- <th>内贸定价(RMB)</th>
                        <th>外贸定价(USD)</th> -->
                        <th>第2分类</th>
                        <th>第3分类</th>
                        <th>第4分类</th>
                        <th>第5分类</th>
                        <th>产品特价</th>
                    </tr>
                        <apex:repeat value="{!DiscountProductApplicationDetailList}" var="dpad" id="Product2List">
                        <tr class="dataRow">
                           <apex:variable var="v" value="" id="variableinfo">
                                <td>
                                <apex:inputCheckbox value="{!dpad.check}" disabled="{!IF(dpa.ApplicationStatus__c='申请中'||dpa.ApplicationStatus__c='批准'||dpa.ApplicationStatus__c='驳回',true,false)}" onclick="CheckSize(this);" id="Product2Check"/>
                                <apex:inputHidden value="{!dpad.dp.id}"/>
                                </td>
                            </apex:variable>
                            <td class="dataCell" style="display:none">{!dpad.pr2.id}</td>
                            <td class="dataCell">{!dpad.pr2.Name__c}</td>
                            <td class="dataCell">{!dpad.pr2.OT_CODE_Text__c}</td>
                            <td class="dataCell">{!dpad.pr2.SFDA_Status__c}</td>
                            <!-- <td class="dataCell">{!dpad.pr2.Intra_Trade_List_RMB__c}</td>
                            <td class="dataCell">{!dpad.pr2.Foreign_Trade_List_US__c}</td> -->
                            <td class="dataCell">{!dpad.pr2.Category2__c}</td>
                            <td class="dataCell">{!dpad.pr2.Category3__c}</td>
                            <td class="dataCell">{!dpad.pr2.Category4__c}</td>
                            <td class="dataCell">{!dpad.pr2.Category5__c}</td>
                            <td class="dataCell">
                                <apex:inputField rendered="{!IF(dpa.ApplicationStatus__c='草案中' || dpa.ApplicationStatus__c='',true,false)}" onblur="pdValue(this)" id="ProductDiscount" value="{!dpad.dp.ProductDiscount__c}" style="width: 100px;"/>
                                <apex:outputField rendered="{!IF(dpa.ApplicationStatus__c !='草案中' && dpa.ApplicationStatus__c !='',true,false)}" value="{!dpad.dp.ProductDiscount__c}" />
                                <apex:inputHidden id="ProductDiscountmoney" value="{!dpad.dismoney}"/>
                            </td>  
                        </tr>
                        </apex:repeat>
                </table>
             </apex:pageBlock>
    </apex:form>
</apex:page>