wangzhibo
4 天以前 ae6f40460dcd56af6c5f60ba52c883854c3bac55
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"/>
  <title>压缩站计量</title>
  <link rel="stylesheet" href="css.css"/>
</head>
<body>
<div class="wrap">
  <div class="page-head">
    <h1>压缩站计量</h1>
    <a class="back-link" href="home.html">返回工作台</a>
  </div>
  <div class="card">
    <label class="req">压缩站</label>
    <select id="businessId"></select>
    <label>垃圾类型</label>
    <input value="干垃圾 SW64" disabled/>
    <label class="req">重量(吨/或额定载荷)</label>
    <input id="weight" type="number" step="0.01"/>
    <label>备注</label>
    <textarea id="remark" rows="3"></textarea>
    <button class="btn" onclick="save()">上报</button>
  </div>
  <div class="card" id="list"></div>
</div>
<script src="app.js"></script>
<script>
api("/app/basicdata/options/sites", { siteType: "压缩站" }).then(function (rows) {
  if (!(rows || []).length) {
    $("businessId").innerHTML = "<option value=''>暂无本部门压缩站</option>";
    toast("未找到本部门压缩站");
    return;
  }
  $("businessId").innerHTML = (rows || []).map(function (r) {
    return "<option value='" + r.businessId + "'>" + r.businessName + "</option>";
  }).join("");
}).catch(function (e) { toast(e.message); });
 
function save() {
  if (!$("businessId").value) { toast("请选择压缩站"); return; }
  api("/app/push/sorter/siteweightAdd", {
    businessId: $("businessId").value,
    deviceNo: "人工填报",
    garbageType: "SW64",
    weight: Number($("weight").value),
    remark: $("remark").value
  }).then(function () {
    toast("已上报"); $("weight").value = ""; load();
  }).catch(function (e) { toast(e.message); });
}
function load() {
  api("/app/push/sorter/siteweightPage", { page: 1, size: 30 }).then(function (res) {
    var list = (res && res.list) || [];
    $("list").innerHTML = list.length ? list.map(function (r) {
      return "<div class='item'>" + (r.businessName || r.businessId) + " " + r.weight +
        "<div class='muted'>" + (r.uploadTime || "") + " · " + (r.deviceNo || "") + "</div></div>";
    }).join("") : "<div class='muted'>暂无记录</div>";
  }).catch(function (e) { toast(e.message); });
}
load();
</script>
</body>
</html>