高章伟
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
362
363
364
365
366
367
<apex:page controller="SampleInventoryController" showHeader="false" sidebar="false" id="Page" action="{!init}" title="样本盘点">
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
    <apex:stylesheet value="{!URLFOR($Resource.jquerysuggestcss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquerysuggestjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
    <apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
    <style type="text/css">
        .pure-table {
            /* border-collapse: collapse; */
            /* border-spacing: 0; */
            empty-cells: show;
            border: 1px solid #cbcbcb;
            width: 100%;
        }
 
        .pure-table caption {
            color: #000;
            font: italic 85%/1 arial,sans-serif;
        /* padding: 1em 0;*/
            text-align: center;
        }
        
        .pure-table td,.pure-table th {
            border-left: 1px solid #cbcbcb;
            border-width: 0 0 0 1px;
            font-size: inherit;
            margin: 0;
            overflow: visible;
            padding: .5em 1em;
        }
        
        .pure-table thead {
            background-color: #c3bfbf;
            color: #000;
            text-align: center;
            vertical-align: bottom;
        }
        
        .pure-table td {
            background-color: transparent; 
        }
 
        .pure-table-horizontal th,.pure-table-horizontal td {
            border-width: 0 0 1px 0;
            border-bottom: 1px solid #cbcbcb;
        }
 
        .pure-table-horizontal tbody>tr:last-child>td {
            border-bottom-width: 0;
        }
        
        .waves{
            position:relative;
            cursor:pointer;
            display:inline-block;
            overflow:hidden;
            text-align: center;
            -webkit-tap-highlight-color:transparent;
            z-index:1;
        }
        .waves .waves-animation{
            position:absolute;
            border-radius:50%;
            width:25px;
            height:25px;
            opacity:0;
            background:rgba(255,255,255,0.3);
            transition:all 0.7s ease-out;
            transition-property:transform, opacity, -webkit-transform;
            -webkit-transform:scale(0);
            transform:scale(0);
            pointer-events:none
        }
        .ts-btn{
            width: 150px;
            padding: 8px;
            height: 20px;
            line-height: 20px;
            background: #909b8a;
            color: #fff;
            border-radius: 5px;
            float: right;
            margin-right: 10px;
            margin-top: 5px;
        }
    </style>
    <script type="text/javascript">
        //文本框输入值,复选框自动打勾
        function ComputePrice(j) {
            var size = {!SISize};
            for(var i = 0; i < size; i++){
                var InventoryCheck = document.getElementById("Page:allForm:records:"+ i +":Inventory_Check").value;
                var checklist = j$("input[name='Page:allForm:records:"+ i +":checklist']");
                if(InventoryCheck != null && InventoryCheck != 0 && InventoryCheck != ''){
                    checklist[0].checked = true;
                }else{
                    checklist[0].checked = false;
                }
            }
        }
        //全选功能
        function selectAll() {
            var size = {!SISize};
            var all = j$(escapeVfId("Page:allForm:checkAll"));
            if (all[0].checked) {
                for(var i = 0; i < size; i++){
                    var checklist = j$("input[name='Page:allForm:records:"+ i +":checklist']");
                    checklist[0].checked = true;
                }
            } else {
                for(var i = 0; i < size; i++){
                    var checklist = j$("input[name='Page:allForm:records:"+ i +":checklist']");
                    checklist[0].checked = false;
                }
            }
        }
        //报错之后盘点数量为0的置为空
        function InventoryToNull() {
            var size = {!SISize};
            for(var i = 0; i < size; i++){
                if(document.getElementById("Page:allForm:records:"+ i +":Inventory_Check").value / 1 == 0){
                    j$(escapeVfId('Page:allForm:records:' + i + ':Inventory_Check')).attr('value',"");
                }
            }
        }
        //盘点确认
        function InventoryConfirmJS() {
            var size = {!SISize};
            var Inventoryflag = false;
            var Inflag = false;
            var lastflag = true;
            for(var i = 0; i < size; i++){
                //盘点库存大于发货数量的时候进行拦截
                var EffectiveInventory = (document.getElementById("Page:allForm:records:"+ i +":EffectiveInventory").innerText / 1);
                var Inventory = document.getElementById("Page:allForm:records:"+ i +":Inventory_Check").value / 1 ;
                if(Inventory > EffectiveInventory){
                    alert('输入的数量只可以小于等于有效库存!');
                    document.getElementById("Page:allForm:records:"+ i +":Inventory_Check").focus();
                    Inventoryflag = false;
                    lastflag = false;
                    break;
                }
                //文本框输入非数字进行拦截
                if(isNaN(Inventory)){
                    alert('请输入数字!');
                    document.getElementById("Page:allForm:records:"+ i +":Inventory_Check").focus();
                    Inventoryflag = false;
                    lastflag = false;
                    break;
                }
            }  
            if(lastflag){
                for(var i = 0; i < size; i++){
                    //如果没有勾选盘点,并且盘点库存没有值
                    if(document.getElementById("Page:allForm:records:"+ i +":Inventory_Check").value == ''
                        && document.getElementById("Page:allForm:records:"+ i +":checklist").checked == false){
                        Inventoryflag = false;
                        Inflag = true;
                    } else{
                        Inflag = false;
                        for(var i = 0; i < size; i++){
                            if(document.getElementById("Page:allForm:records:"+ i +":checklist").checked == true
                                && document.getElementById("Page:allForm:records:"+ i +":Inventory_Check").value == ''){    
                                alert('盘点库存不能为空!');
                                document.getElementById("Page:allForm:records:"+ i +":Inventory_Check").focus();
                                Inventoryflag = false;
                                break;
                            } else if (document.getElementById("Page:allForm:records:"+ i +":Inventory_Check").value != ''
                                && document.getElementById("Page:allForm:records:"+ i +":checklist").checked == false){
                                alert('请选择要盘点的样本!');
                                document.getElementById("Page:allForm:records:"+ i +":Inventory_Check").focus();
                                Inventoryflag = false;
                                break;
                            } else if(document.getElementById("Page:allForm:records:"+ i +":checklist").checked == true
                                && document.getElementById("Page:allForm:records:"+ i +":Inventory_Check").value - 0 < 0){
                                alert('盘点库存不能为负数!');
                                document.getElementById("Page:allForm:records:"+ i +":Inventory_Check").focus();
                                Inventoryflag = false;
                                break;
                            } else{
                                Inventoryflag = true;
                            }
                        }
                        if(!Inventoryflag){
                            break;
                        }
                    } 
                }
            }
            //蒙层+后台保存方法
            if(Inventoryflag){
                blockme();
                InventoryConfirm();
            }
            if(Inflag){
                alert('至少选择一个样本才能进行盘点确认!');
            }
        }
        //按钮水波纹效果
        document.addEventListener('DOMContentLoaded',function(){
            var duration = 750;
            // 样式string拼凑
            var forStyle = function(position){
            var cssStr = '';
            for( var key in position){
                if(position.hasOwnProperty(key)) cssStr += key+':'+position[key]+';';
            };
            return cssStr;
            }
            // 获取鼠标点击位置
            var forRect = function(target){
            var position = {
                top:0,
                left:0
            }, ele = document.documentElement;
            'undefined' != typeof target.getBoundingClientRect && (position = target.getBoundingClientRect());
            return {
                top: position.top + window.pageYOffset - ele.clientTop,
                left: position.left + window.pageXOffset - ele.clientLeft
            }
            }
            var show = function(event){
            var pDiv = event.target,
                cDiv = document.createElement('div');
            pDiv.appendChild(cDiv);
            var rectObj = forRect(pDiv),
                _height = event.pageY - rectObj.top,
                _left = event.pageX - rectObj.left,
                _scale = 'scale(' + pDiv.clientWidth / 100 * 10 + ')';
            var position = {
                top: _height+'px',
                left: _left+'px'
            };
            cDiv.className = cDiv.className + " waves-animation",
            cDiv.setAttribute("style", forStyle(position)),
            position["-webkit-transform"] = _scale,
            position["-moz-transform"] = _scale,
            position["-ms-transform"] = _scale,
            position["-o-transform"] = _scale,
            position.transform = _scale,
            position.opacity = "1",
            position["-webkit-transition-duration"] = duration + "ms",
            position["-moz-transition-duration"] = duration + "ms",
            position["-o-transition-duration"] = duration + "ms",
            position["transition-duration"] = duration + "ms",
            position["-webkit-transition-timing-function"] = "cubic-bezier(0.250, 0.460, 0.450, 0.940)",
            position["-moz-transition-timing-function"] = "cubic-bezier(0.250, 0.460, 0.450, 0.940)",
            position["-o-transition-timing-function"] = "cubic-bezier(0.250, 0.460, 0.450, 0.940)",
            position["transition-timing-function"] = "cubic-bezier(0.250, 0.460, 0.450, 0.940)",
            cDiv.setAttribute("style", forStyle(position));
            var finishStyle = {
                opacity: 0,
                "-webkit-transition-duration": duration + "ms",
                "-moz-transition-duration": duration + "ms",
                "-o-transition-duration": duration + "ms",
                "transition-duration": duration + "ms",
                "-webkit-transform" : _scale,
                "-moz-transform" : _scale,
                "-ms-transform" : _scale,
                "-o-transform" : _scale,
                top: _height + "px",
                left: _left + "px",
            };
            setTimeout(function(){
                cDiv.setAttribute("style", forStyle(finishStyle));
                setTimeout(function(){
                pDiv.removeChild(cDiv);
                },duration);
            },100)
            }
            document.querySelector('.waves').addEventListener('click',function(e){
            show(e);
            },!1);
            },!1);
    </script>
    
    <apex:form id="allForm">
        <!-- 后台报错信息显示 -->
        <apex:outputPanel id="message">
            <apex:pageMessages ></apex:pageMessages>
        </apex:outputPanel>
        <h1 style ="font-size: 30px; margin-left: 45%;">样本盘点</h1>
        <!-- 后台盘点确认方法之后执行 -->
        <apex:actionFunction name="InventoryConfirm" action="{!InventoryConfirm}" rerender="allForm,allPanel,records" oncomplete="InventoryToNull();unblockUI();">
        </apex:actionFunction>
        <apex:outputPanel id="allPanel">
            <div style="width:1000px; height:100%; margin:auto; overflow:auto;">
            <input type="hidden" id="hasError" value="{!hasError}"/>
            <table class="pure-table pure-table-horizontal" id="theTable_header" styleclass="list">
                <!-- 统一设置列宽度 -->
                <colgroup>
                    <col width="100px"/>
                    <col width="150px"/>
                    <col width="300px"/>
                    <col width="50px"/>
                    <col width="100px"/>
                    <col width="100px"/>
                    <col width="200px"/>
                </colgroup>
                <tr style="background-color:#f2f3f3;">
                    <th style="align:left">
                        <apex:inputCheckbox id="checkAll" onclick="selectAll()" style="text-align:left;"/>是否盘点
                    </th>
                    <th style="text-align:left">
                        资料编码
                    </th>
                    <th style="text-align:left">
                        资料名称
                    </th>
                    <th style="text-align:left">
                        规格
                    </th>
                    <th style="text-align:left">
                        有效期内库存
                    </th>
                    <th style="text-align:left">
                        过期库存
                    </th>
                    <th style="text-align:left">
                        有效盘点库存(最小单位)
                    </th>
                </tr>
            </table>
            
            <table class="pure-table pure-table-horizontal" id="theTable_header" styleclass="list" style="width: 100%">
                <colgroup>
                    <col width="100px"/>
                    <col width="150px"/>
                    <col width="300px"/>
                    <col width="50px"/>
                    <col width="100px"/>
                    <col width="100px"/>
                    <col width="200px"/>
                </colgroup>
                <apex:repeat value="{!SIInfo}" var="SIfo" id="records">
                <tr>
                    <td align="left">
                        <apex:inputCheckbox style="text-align:left;" id="checklist" value="{!SIfo.IFCount}" />
                    </td>
                    <td align="left">
                        <apex:outputText id="OTCode" value="{!SIfo.OTCode}"/>
                    </td>
                    <td align="left">
                        <apex:outputText id="Samplename" value="{!SIfo.ProductName}"/>
                    </td>
                    <td align="left">
                        <apex:outputText id="Specs" value="{!SIfo.ProductSpecs}"/>    
                    </td>
                    <td align="center">
                        <apex:outputText id="EffectiveInventory" value="{!SIfo.EffectiveInventory}"/>
                    </td>
                    <td align="center">
                        <apex:outputText id="ExpiredInventory" value="{!SIfo.ExpiredInventory}"/> 
                    </td>
                    <td align="center">
                        <apex:inputText onblur="ComputePrice(this)" style="text-align:left;" id="Inventory_Check" value="{!SIfo.Check}" />
                    </td>  
                </tr>
                </apex:repeat>
            </table>
            <a class="waves ts-btn" onclick="InventoryConfirmJS()">盘点确认</a>
            </div>
        </apex:outputPanel>
    </apex:form>
</apex:page>