<!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" />
|
<link href="./css/mui.picker.min.css" rel="stylesheet" />
|
<style>
|
.mui-bar-nav {
|
background: #245ca7;
|
-webkit-box-shadow: none;
|
box-shadow: none;
|
}
|
|
.mui-title {
|
color: #FFFFFF;
|
}
|
|
.mui-icon-back:before,
|
.mui-icon-left-nav:before {
|
color: #FFFFFF;
|
}
|
|
.mui-content-padded {
|
margin:unset;
|
padding: 6px;
|
}
|
input[type=search] {
|
font-size: 16px;
|
-webkit-box-sizing: border-box;
|
box-sizing: border-box;
|
height: 35px;
|
text-align: left;
|
border: 0;
|
border-radius: 50px;
|
background-color: #efeff4;
|
margin-bottom: 1px;
|
width: 72%;
|
}
|
.duka{
|
background:#ff6355;
|
color: #fff;
|
border-radius: 5px;
|
line-height: 20px;
|
margin-right: 8px;
|
float: right;
|
width: 18%;
|
}
|
/*出入库记录、值仓列表*/
|
.inout_record {
|
width: 96%;
|
margin: auto;
|
margin-bottom: 10px;
|
border-top-left-radius: 5px;
|
border-top-right-radius: 5px;
|
}
|
.inout_record_title {
|
background: rgb(68, 189, 245);
|
height: 10px;
|
border-top-left-radius: 5px;
|
border-top-right-radius: 5px;
|
margin-top: 6px;
|
}
|
.inout_record_body {
|
padding-left: 15px;
|
background: #FFFFFF;
|
}
|
.inout_record_body table {
|
width: 100%;
|
}
|
.inout_record_body tr {
|
border-bottom: 1px #efefef solid;
|
height: 32px;
|
line-height: 32px;
|
}
|
.inout_record_button {
|
background: #668dc1;
|
color: #fff;
|
border: 0px;
|
border-radius: 5px;
|
margin: 2px 5px;
|
float: right
|
}
|
.inout_record_button_yc {
|
background: #8363ef;
|
color: #fff;
|
border: 0px;
|
border-radius: 5px;
|
margin: 2px 5px;
|
float: right
|
}
|
.inout_record_one {
|
color: rgb(102, 102, 102);
|
font-size: 15px;
|
width: 35%;
|
}
|
.inout_record_two {
|
color: black;
|
font-size: 16px;
|
}
|
.heji{
|
margin-top: 6px;
|
border-radius: 6px;
|
background: #9cc5f3;
|
}
|
.heji1{
|
color: #222;
|
font-weight: 700;
|
font-size: 16px;
|
}
|
</style>
|
</head>
|
<body>
|
<header class="mui-bar mui-bar-nav">
|
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
|
<h1 class="mui-title">入库值仓列表</h1>
|
</header>
|
<div class="mui-content">
|
<div class="mui-content-padded" style="background: #FFFFFF;">
|
<input id="plateNum" type="search" placeholder="请输入车牌信息检索...">
|
<button class="btn duka" onclick="readCard()">读卡</button>
|
</div>
|
<div class="inout_record" id="inoutHandle">
|
<!-- <div class="inout_record_title"></div>
|
<div class="inout_record_body">
|
<table>
|
<tr class="inout_record_tr">
|
<td class="inout_record_one">目标仓库:</td>
|
<td class="inout_record_two">1号仓</td>
|
<td>
|
<button class="inout_record_button" (click)="goPage(item.id)">现场值仓</button>
|
</td>
|
</tr>
|
<tr>
|
<td class="inout_record_one">车牌号:</td>
|
<td class="inout_record_two">豫A12345</td>
|
<td>
|
<button class="inout_record_button_yc" (click)="goPage(item.id)">远程值仓</button>
|
</td>
|
</tr>
|
<tr>
|
<td class="inout_record_one">粮食品种:</td>
|
<td class="inout_record_two">早籼稻</td>
|
<td></td>
|
</tr>
|
<tr>
|
<td class="inout_record_one">粮食等级:</td>
|
<td class="inout_record_two">1级</td>
|
<td></td>
|
</tr>
|
</table>
|
</div> -->
|
</div>
|
</div>
|
<script src="./js/mui.js"></script>
|
<script src="./js/mui.picker.min.js"></script>
|
<script src="./js/jquery.min.js"></script>
|
<script src="./js/echarts.min.js"></script>
|
<script type="text/javascript" charset="utf-8">
|
mui.init();
|
var url; //接口路径
|
var handleInList; //入库值仓列表集合
|
//获取入库待值仓列表请求参数
|
var data1 = {
|
"interfaceId": "5204",
|
"sign": "10204",
|
"outId": "10204",
|
"reqDateTime": new Date(),
|
"tokenAuth": "",
|
"data": {
|
"plateNum": ""
|
}
|
};
|
//查看值仓详情请求参数(NFC读卡时使用)
|
var data2 = {
|
"interfaceId": "5208",
|
"sign": "10208",
|
"outId": "10208",
|
"reqDateTime": new Date(),
|
"tokenAuth": "",
|
"data": {
|
"id": "",
|
"intelCard": ""
|
}
|
};
|
|
mui.plusReady(function() {
|
var user = JSON.parse(localStorage.getItem('user'));
|
data1.tokenAuth = user.tokenAuth;
|
data2.tokenAuth = user.tokenAuth;
|
url = user.url + "/api-phone/gateway";
|
gethandleInList();
|
})
|
|
//监听输入框
|
mui('.mui-content-padded').on('change', 'input[type="search"]', function() {
|
//将输入框的值赋值给参数
|
data1.data.plateNum = mui("#plateNum")[0].value;
|
//发送请求查询
|
gethandleInList();
|
});
|
|
//事件监听子页面的mui.back方法
|
window.addEventListener('refresh', function(e){//执行刷新
|
location.reload();
|
});
|
|
//获取入仓值仓列表
|
function gethandleInList() {
|
mui.ajax(url, {
|
type: "POST",
|
dataType: "json",
|
crossDomain: true,
|
contentType: "application/json;charset=utf-8",
|
data: JSON.stringify(data1),
|
success: function(result) {
|
if (result.code == "0000") {
|
handleInList = result.data;
|
if (handleInList != null && handleInList.length > 0) {
|
renderhandleInList();
|
} else {
|
mui.toast("暂无入库值仓信息!");
|
}
|
} else {
|
mui.toast(result.msg);
|
}
|
},
|
error: function() {
|
mui.alert('系统繁忙,请重试!', '提示', ["确定"], function() {}, "div");
|
}
|
})
|
}
|
|
//渲染
|
function renderhandleInList() {
|
var html = '';
|
$.each(handleInList, function(index, item) {
|
html += '<div class="inout_record_title"></div><div class="inout_record_body"><table>';
|
html += '<tr class="inout_record_tr"><td class="inout_record_one">目标仓库:</td>' +
|
'<td class="inout_record_two">' + item.depotName + '</td><td><button class="inout_record_button"' +
|
' onclick="toHandleView(\'' + item.id + '\',\'photo\')">现场值仓</button></td></tr>';
|
html += '<tr><td class="inout_record_one">车牌号:</td><td class="inout_record_two">' +
|
item.plateNum + '</td><td><button class="inout_record_button_yc"' +
|
' onclick="toHandleView(\'' + item.id + '\',\'snap\')">远程值仓</button></td></tr>';
|
html += '<tr><td class="inout_record_one">粮食品种:</td><td class="inout_record_two">' +
|
item.foodVarietyName + '</td><td></td></tr>';
|
html += '<tr><td class="inout_record_one">粮食等级:</td><td class="inout_record_two">' +
|
item.foodLevelName + '</td><td></td></tr>';
|
html += '</table></div>';
|
})
|
$("#inoutHandle").html(html);
|
}
|
|
//跳转值仓页面
|
function toHandleView(inoutId, tag) {
|
if(tag == "snap"){
|
//远程值仓
|
mui.openWindow({
|
url: "inout-handle-in-snap.html",
|
id: "inout-handle-in-snap",
|
extras: {
|
recordId: inoutId
|
}
|
})
|
}else{
|
//现场值仓
|
mui.openWindow({
|
url: "inout-handle-in.html",
|
id: "inout-handle-in",
|
extras: {
|
recordId: inoutId
|
}
|
})
|
}
|
}
|
|
/*---------------NFC读卡功能-------------------*/
|
var waiting;
|
var readyRead = false;
|
//读卡方法
|
function readCard() {
|
readyRead = true;
|
listenNFCStatus();
|
}
|
|
var NfcAdapter;
|
var NdefRecord;
|
var NdefMessage;
|
var count = 0;
|
//监听NFC状态
|
function listenNFCStatus() {
|
try {
|
var main = plus.android.runtimeMainActivity();
|
var Intent = plus.android.importClass('android.content.Intent');
|
var Activity = plus.android.importClass('android.app.Activity');
|
var PendingIntent = plus.android.importClass('android.app.PendingIntent');
|
var IntentFilter = plus.android.importClass('android.content.IntentFilter');
|
NfcAdapter = plus.android.importClass('android.nfc.NfcAdapter');
|
var nfcAdapter = NfcAdapter.getDefaultAdapter(main);
|
//判断设备是否支持NFC功能
|
if (nfcAdapter == null) {
|
mui.alert("设备不支持NFC功能!", '提示', ["确定"], function() {}, "div");
|
return;
|
}
|
//判断设备是否开启NFC功能
|
if (!nfcAdapter.isEnabled()) {
|
mui.alert("请在系统设置中启用NFC功能!", '提示', ["确定"], function() {}, "div");
|
return;
|
}
|
waiting = plus.nativeUI.showWaiting("请将NFC标签靠近!");
|
|
//倒计时10秒,读取不到后提示是否重新读卡
|
var interval = setInterval(function(){//定义定时器
|
count ++;
|
if(count == 10 && readyRead){
|
readyRead = false;
|
count = 0;
|
waiting.close();
|
clearInterval(interval);//清除定时器
|
var btnArray = ["重试", "取消"];
|
mui.confirm("已超时,是否重新读卡!", "提示", btnArray, function(e) {
|
if (e.index == 0) {
|
readCard();
|
}
|
}, "div")
|
}
|
},1000);
|
|
var intent = new Intent(main, main.getClass());
|
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
var pendingIntent = PendingIntent.getActivity(main, 0, intent, 0);
|
var ndef = new IntentFilter("android.nfc.action.TECH_DISCOVERED");
|
ndef.addDataType("*/*");
|
var intentFiltersArray = [ndef];
|
var techListsArray = [
|
["android.nfc.tech.IsoDep"],
|
["android.nfc.tech.NfcA"],
|
["android.nfc.tech.NfcB"],
|
["android.nfc.tech.NfcF"],
|
["android.nfc.tech.Ndef"],
|
["android.nfc.tech.NfcV"],
|
["android.nfc.tech.NdefFormatable"],
|
["android.nfc.tech.MifareClassic"],
|
["android.nfc.tech.MifareUltralight"]
|
];
|
document.addEventListener("newintent",
|
function() {
|
setTimeout(readData, 1000);
|
}, false);
|
document.addEventListener("pause", function(e) {
|
if (nfcAdapter) {
|
nfcAdapter.disableForegroundDispatch(main);
|
}
|
}, false);
|
document.addEventListener("resume", function(e) {
|
if (nfcAdapter) {
|
nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray);
|
}
|
}, false);
|
nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray);
|
} catch (e) {
|
mui.toast("读卡失败,请重试!");
|
waiting.close();
|
}
|
}
|
|
//读取数据
|
function readData() {
|
NdefRecord = plus.android.importClass("android.nfc.NdefRecord");
|
NdefMessage = plus.android.importClass("android.nfc.NdefMessage");
|
var main = plus.android.runtimeMainActivity();
|
var intent = main.getIntent();
|
// if ("android.nfc.action.TAG_DISCOVERED" == intent.getAction()) { //真机调试
|
if ("android.nfc.action.TECH_DISCOVERED" == intent.getAction()) { //打包时
|
if (readyRead) {
|
readyRead = false;
|
|
waiting.setTitle('请勿移开标签\n正在读取数据...');
|
var Parcelable = plus.android.importClass("android.os.Parcelable");
|
//读取id
|
var byteId = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
|
//将id转为16进制字符串
|
var id = ByteArrayToHexString(byteId);
|
//关闭等待圆圈
|
waiting.close();
|
|
//读取id成功,赋值并发送请求查询
|
data2.data.intelCard = id;
|
getInoutDetail();
|
}
|
} else {
|
waiting.close();
|
mui.alert('读取失败,请重试!', '提示', ["确定"], function() {}, "div");
|
}
|
}
|
|
//获取值仓单子详细信息
|
function getInoutDetail() {
|
mui.ajax(url, {
|
type: "POST",
|
dataType: "json",
|
crossDomain: true,
|
contentType: "application/json;charset=utf-8",
|
data: JSON.stringify(data2),
|
success: function(result) {
|
if (result.code == "0000") {
|
//弹窗信息:单子车牌跟仓库,去值仓则进入值仓页面,传递单子id;
|
var btnArray = ["去值仓", "取消"];
|
var text = '值仓仓库:' + result.data.depotName + '<br/>车牌号:' + result.data.plateNum;
|
mui.confirm(text, "检测到待值仓信息如下", btnArray, function(e) {
|
if (e.index == 0) {
|
//先判断单子是否在值仓状态
|
if(result.data.progress == "HANDLE"){
|
//去值仓时判断单子类型是否是入库,不是给出提醒;
|
if (result.data.type == "IN") {
|
mui.openWindow({
|
url: "inout-handle-in.html",
|
id: "inout-handle-in",
|
extras: {
|
recordId: result.data.id
|
}
|
})
|
} else {
|
mui.alert("该卡信息不是入库类型,请核对!", "提示", ["确定"], function() {}, "div")
|
}
|
}else {
|
mui.alert("当前卡不在值仓状态,请核查!", "提示", ["确定"], function() {}, "div")
|
}
|
}
|
}, "div")
|
} else {
|
mui.toast(result.msg);
|
}
|
},
|
error: function() {
|
mui.alert('系统繁忙,请重试!', '提示', ["确定"], function() {}, "div");
|
}
|
})
|
}
|
|
//将字节数组转为16进制字符串
|
function ByteArrayToHexString(inarray) {
|
var i, j, inn;
|
hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
|
out = "";
|
for (j = 0; j < inarray.length; ++j) {
|
inn = inarray[j] & 0xff;
|
i = (inn >>> 4) & 0x0f;
|
out += hex[i];
|
i = inn & 0x0f;
|
out += hex[i];
|
}
|
return out;
|
}
|
</script>
|
</body>
|
</html>
|