陈战涛
2023-03-14 c29ed2aa867b00eccfdc7c3a68f431008b13ea7d
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
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>实时出库</title>
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <link href="./css/mui.min.css" rel="stylesheet" />
        <style>
            .inout_title{
                display: block;
                font-size: 16px;
                background: #fff; 
                padding: 0 15px; 
                box-sizing: border-box;
                color: #245ca7; 
                height: 40px; 
                line-height: 40px; 
                border-bottom: 1px #efefef solid;
            }
            .inout_table {
                margin-bottom: 6px;
            }
            .inout_table table {
                width: 100%;
                background-color: #fff !important
            }
            .inout_table tr {
                font-size: 13px;
                text-align: center;
                line-height: 30px;
            }
            .inout_table th {
                font-weight: 400;
                min-width: 42px;
                text-align: center;
            }
            .inout_table td {
                min-width: 42px;
                text-align: center;
                padding: 0 2px;
            }
            .right{
                border-right: 2px #efefef solid !important;
            }
            .back{
                background: #bfdbf9;
            }
        </style>
    </head>
    <body>
        <!--下拉刷新容器-->
        <div id="pullrefresh" class="mui-content mui-scroll-wrapper">
            <div class="mui-scroll">
                <!--入库实时信息-->
                <div class="inout_title"><strong id="title2">实时信息</strong><span style="color: #333333;">&nbsp;&nbsp;(下拉刷新)</span></div>
                <div style="width: 100%;background: #FFFFFF;height: 35px;border-bottom: 1px #efefef solid;padding: 5px 0 5px 15px;">
                    <h3 style="font-size: 16px;font-weight: 400;">
                        <span>更新时间:</span>
                        <span id="updateTime"></span>
                    </h3>
                </div>
                <div class="inout_table">
                    <table>
                        <thead>
                            <tr>
                                <th class="right">单据号</th>
                                <th class="right">车牌号</th>
                                <th class="right">类型</th>
                                <th class="right">当前流程</th>
                                <th>目标仓库</th>
                            </tr>
                        </thead>
                        <tbody id="inoutList">
                            <!-- <tr class="back">
                            <td class="right">03180001</td>
                            <td class="right">豫A12BC5</td>
                            <td class="right">入库</td>
                            <td class="right">值仓</td>
                            <td>43号仓</td>
                        </tr>-->
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
 
        <script src="./js/mui.min.js"></script>
        <script src="./js/jquery.min.js"></script>
        <script type="text/javascript" charset="utf-8">
            mui.init({
                pullRefresh: {
                    container: '#pullrefresh',
                    down: {
                        callback: pullRefresh
                    }
                    // ,up: {
                    //     contentrefresh: '正在加载...',
                    //     callback: pullRefresh
                    // }
                }
            });
 
            var url;
            var time;
            var inoutRealList;
            var data = {
                "interfaceId": "5203",
                "sign": "10203",
                "outId": "10203",
                "reqDateTime": new Date(),
                "tokenAuth": "",
                "data": {}
            };
 
            mui.plusReady(function() {
                var user = JSON.parse(localStorage.getItem('user'));
                url = user.url + "/api-phone/gateway";
                var curr = plus.webview.currentWebview();
                inoutType = curr.type;
                data.tokenAuth = user.tokenAuth;
                pullRefresh()
            })
 
            /**
             * 下拉或者刷新具体业务实现
             */
            function pullRefresh() {
                setTimeout(function() {
                    getInoutList();
                }, 1000);
            }
 
            function getInoutList() {
                inoutRealList = null;
                time = null;
                mui.ajax(url, {
                    type: "POST",
                    dataType: "json",
                    crossDomain: true,
                    contentType: "application/json;charset=utf-8",
                    data: JSON.stringify(data),
                    success: function(result) {
                        time = result.respDateTime;
                        if (result.code == "0000") {
                            inoutRealList = result.data;
                            renderInout();
                        } else {
                            renderInout();
                        }
                    },
                    error: function() {
                        mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div")
                    }
                })
            }
 
            //渲染页面
            function renderInout() {
                if (time) {
                    $("#updateTime").html(time);
                }
                //更新实时流水信息
                var list = inoutRealList.listInout;
                var html = '';
                var count = 0;
                if (list != null && list.length > 0) {
                    $.each(list, function(index, item) {
                        if (item.type == "OUT") {
                            if (count % 2 == 0) {
                                html += '<tr class="back">';
                            } else {
                                html += '<tr>';
                            }
                            html += '<td class="right">' + item.id.substring(6) + '</td>';
                            html += '<td class="right">' + item.plateNum + '</td>';
                            html += '<td class="right">' + item.typeName + '</td>';
                            html += '<td class="right">' + item.progressName + '</td>';
                            html += '<td>' + item.depotName + '</td></tr>';
                            count++;
                        }
                    })
                    
                    mui.toast("数据已刷新!");
                }else{
                    html += '<tr><td class="back" colspan="5">暂无信息</td></tr>';
                    mui.toast("已刷新,暂无信息!");
                }
                $("#inoutList").html(html);
                mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
                // mui('#pullrefresh').pullRefresh().endPullupToRefresh();
            }
        </script>
    </body>
</html>