YYC
2023-06-13 c7ba1ce89a2a552eee9b5edadc9a302d8aafb05b
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
var url = null;
var dateTime; //日期:yyyy-MM-dd
var outRecordData = null;
var data = {
    "interfaceId": "5204",
    "sign": "10204",
    "outId": "10204",
    "reqDateTime": new Date(),
    "tokenAuth": "",
    "data": {
        "deptId": "",
        "dateTime": ''
    }
};
 
//初始化数据
function init() {
    var user = JSON.parse(localStorage.getItem('user'));
    var selectDeptId = JSON.parse(localStorage.getItem('selectDeptId'));
    url = user.url + "/api-phone/v35/gateway";
    data.tokenAuth = user.tokenAuth;
    data.data.deptId = selectDeptId;
    
    //获取当前天时间
    dateTime = getDate(new Date());
    $("#dateTime").val(dateTime);
 
    //获取出库记录
    getOutRecordList();
}
 
//查询出库记录
function getOutRecordList() {
    outRecordData = null;
    
    //赋值参数的日期
    data.data.dateTime = dateTime;
    console.log(JSON.stringify(data.data), "inout-out-record")
    //请求
    mui.ajax(url, {
        type: "POST",
        dataType: "json",
        crossDomain: true,
        contentType: "application/json;charset=utf-8",
        data: JSON.stringify(data),
        success: function(result) {
            if (result.code == "0000") {
                console.log(JSON.stringify(result))
                outRecordData = result.data;
                renderData();
            } else {
                mui.toast(result.mag);
                renderData();
                
            }
        },
        error: function() {
            mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div")
        }
    })
    // outRecordData = {
    //     "sum": "55",
    //     "listInout": [{
    //             "id": "98",
    //             "plateNum": "39",
    //             "depotId": "83",
    //             "depotName": "能始际法高等",
    //             "foodVariety": "quis Ut",
    //             "foodVarietyName": "被龙济来",
    //             "recordWeight": "25",
    //             "completeTime": "1971-10-20 14:45:38"
    //         },
    //         {
    //             "id": "37",
    //             "plateNum": "50",
    //             "depotId": "16",
    //             "depotName": "准民青共工",
    //             "foodVariety": "aliquip eiusmod laborum nulla",
    //             "foodVarietyName": "号走根形",
    //             "recordWeight": "30",
    //             "completeTime": "1971-04-09 06:42:06"
    //         }
    //     ],
    // }
}
 
//渲染页面
function renderData() {
    var html = '';
    var sumHtml = '0';
    if(outRecordData){
        sumHtml = outRecordData.sum;
        console.log()
        var outRecordList = outRecordData.listInout;
        if (outRecordList && outRecordList.length > 0) {
            $.each(outRecordList, function(index, item) {
                html += '<div class="item">';
                html += '<div class="id">单据号: ' + item.id + '</div>';
                html += '<ul class="g-listb2">';
                html += '<li><div class="con" style="background-image: url(images/icons/g-i24.png);">';
                html += '车牌号:<b>' + (item.plateNum == null ? "" : item.plateNum) + '</b></div></li>';
                html += '<li><div class="con" style="background-image: url(images/icons/g-i25.png);">';
                html += '仓库名称:<b>' + (item.depotName == null ? "" : item.depotName) + '</b></div></li>';
                html += '<li><div class="con" style="background-image: url(images/icons/g-i32.png);">';
                html += '粮食品种:<b>' + (item.foodVarietyName == null ? "" : item.foodVarietyName) + '</b></div></li>';
                html += '<li><div class="con" style="background-image: url(images/icons/g-i24.png);">';
                html += '结算重量:<span><em>' + (item.recordWeight == null ? "0" : item.recordWeight) + '</em>KG</span></div></li>';
                html += '</ul><div class="time">完成时间:' + getStrDate(item.completeTime) + '</div></div>';
            })
        } else {
            html += '<div class="id" style="text-align: center;font-size: 20px;color:#dd524d">所选日期暂无出库记录信息</div>';
        }
    }else{
        html += '<div class="id" style="text-align: center;font-size: 20px;color:#dd524d">所选日期暂无出库记录信息</div>';
    }
    $("#sum").html(sumHtml);
    $("#recordList").html(html);
}
 
//加减天
function addAndReduceMonth(tag) {
    var date = new Date(dateTime);
 
    date = date.setDate(date.getDate() + tag);
    date = new Date(date);
    dateTime = getDate(date);
    $("#dateTime").val(dateTime);
    
    getOutRecordList();
}
 
//选择日期
function chooseDate() {
    var dtpicker = new mui.DtPicker({
        type: "date" ,//设置日历初始视图模式 
        value: dateTime
    })
    var time = dateTime
    dtpicker.show(function(e) {
        dateTime = e.value;
        $("#dateTime").val(dateTime);
        if(time != dateTime){
            getOutRecordList();
        }
    })
}
 
//默认获取当前日期(yyyy-MM-dd)
function getDate(date) {
    var year = date.getFullYear();
    var month, day;
    month = date.getMonth() + 1;
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    day = date.getDate();
    if (day >= 1 && day <= 9) {
        day = "0" + day;
    }
    return year + "-" + month + "-" + day;
}
 
//获取日期格式(yyyy-MM-dd HH:mm)
function getStrDate(tag) {
    var date = new Date(tag);
    var year = date.getFullYear();
    var month, day, hour, min;
    month = date.getMonth() + 1;
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    day = date.getDate();
    if (day >= 1 && day <= 9) {
        day = "0" + day;
    }
    hour = date.getHours();
    if (hour >= 1 && hour <= 9) {
        hour = "0" + hour;
    }
    min = date.getMinutes();
    if (min >= 1 && min <= 9) {
        min = "0" + min;
    }
    return year + "-" + month + "-" + day + " " + hour + ":" + min;
}
 
//滑动
mui('.mui-scroll-wrapper').scroll({
    indicators: false, //是否显示滚动条
    deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏
    bounce: false, //是否启用回弹
    deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006
});