<!DOCTYPE html>
|
<html>
|
<head>
|
<meta charset="utf-8">
|
<meta name="viewport"
|
content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
|
<title></title>
|
<script src="js/mui.min.js"></script>
|
<script src="js/common.js"></script>
|
<script src="js/template-web.js"></script>
|
<script src="js/api.js"></script>
|
<script src="js/commonScanCode.js"></script>
|
<script src="print/jf_print_template.js"></script>
|
<link rel="stylesheet" type="text/css" href="css/iconfont.css" />
|
<link href="css/mui.min.css" rel="stylesheet" />
|
<link href="css/mui.picker.min.css" rel="stylesheet" />
|
<link rel="stylesheet" type="text/css" href="css/input.css" />
|
<!-- <link rel="stylesheet" type="text/css" href="http://at.alicdn.com/t/font_783714_7tht2ujc04k.css" /> -->
|
<script src="js/main.js"></script>
|
<script src="js/mui.picker.min.js"></script>
|
<style type="text/css">
|
/*整体字体调小*/
|
.mui-input-group .mui-input-row {
|
height: 30px;
|
}
|
|
.mui-content {
|
font-size: 14px;
|
}
|
|
input,
|
select,
|
textarea {
|
font-size: 14px;
|
!important
|
}
|
|
.mui-input-row select {
|
font-size: 14px;
|
}
|
|
input[type=color],
|
input[type=date],
|
input[type=datetime-local],
|
input[type=datetime],
|
input[type=email],
|
input[type=month],
|
input[type=number],
|
input[type=password],
|
input[type=search],
|
input[type=tel],
|
input[type=text],
|
input[type=time],
|
input[type=url],
|
input[type=week],
|
select,
|
textarea {
|
line-height: 18px;
|
width: 100%;
|
height: 30px;
|
margin-bottom: 5px;
|
padding: 5px 10px;
|
-webkit-user-select: text;
|
border: 1px solid rgba(0, 0, 0, .2);
|
border-radius: 2px;
|
outline: 0;
|
background-color: #fff;
|
-webkit-appearance: none;
|
}
|
|
/* 可选择的下拉框样式 */
|
select {
|
background: url(../img/right-arrow.png) no-repeat right center;
|
/*background-color: #d5d5d5;*/
|
background-size: 1.5rem 1.5rem;
|
}
|
|
/* 表格样式 */
|
.table th {
|
background-repeat: repeat-x;
|
/* height: 30px; */
|
}
|
|
.table td,
|
.table th {
|
border: 1px solid #cad9ea;
|
padding: 0 1em 0;
|
text-align: center;
|
font-size: 14px;
|
!important
|
}
|
|
.table tr.alter {
|
background-color: #f5fafe;
|
}
|
|
.table tr {
|
border-top: 1px solid #0e94ea;
|
background: rgba(14, 148, 234, 0.1);
|
}
|
|
.table thead tr th {
|
background: rgba(169, 207, 255, 1.0);
|
position: sticky;
|
height: 25px;
|
top: 0;
|
z-index: 2;
|
}
|
|
.table tr.bg-color {
|
background: rgba(14, 148, 234, 0.2);
|
}
|
|
/*header 用户名居于右侧*/
|
.title-right {
|
float: right;
|
line-height: 44px !important;
|
font-size: 16px;
|
}
|
</style>
|
</head>
|
<body>
|
<header class="mui-bar mui-bar-nav" id="header">
|
<button type="button" class="mui-left mui-action-back mui-btn mui-btn-link mui-btn-nav mui-pull-left">
|
<span class="mui-icon mui-icon-left-nav"></span>
|
</button>
|
<h1 class="mui-title" id="title">MES移动终端</h1>
|
<a class="mui-pull-right"><span class="title-right" id="usr"></span></a>
|
</header>
|
<div class="mui-content">
|
<div id="divid"></div>
|
<div id="tableDiv" style="border-top:solid 2px #ffffff;height:20rem;overflow: auto; display: none;">
|
<table width="100%;" class="table">
|
<thead id="t_head">
|
</thead>
|
<tbody id="t_body">
|
</tbody>
|
</table>
|
</div>
|
</div>
|
<script id='form-template' type="text/template">
|
<div class="mui-input-group" id="form">
|
<% for(var i in record){ var item=record[i]; %>
|
{{if item[2] == 'VARCHAR2' || item[2] == 'VARCHAR'}}
|
{{if item[4] == '3'}}
|
<div class="mui-input-row">
|
<label><%=(item[1])%></label>
|
{{if item[3] == '1'}}
|
<input readonly type="text" id="<%=(item[0])%>" name="inputDefault" value="<%=(item[12])%>" style="background-color: #f1f1f5;">
|
{{else }}
|
<input type="text" id="<%=(item[0])%>" class="mui-input-clear" value="<%=(item[12])%>" οnfοcus="this.select()" οnmοuseοver="this.focus()" onkeyup="enterSearch(event,'<%=(item[7])%>','<%=(item[8])%>','<%=(item[0])%>','<%=(item[9])%>','<%=(item[10])%>')" placeholder="请输入<%=(item[1])%>">
|
{{/if}}
|
</div>
|
{{else if item[4] == '2'}}
|
<div class="mui-input-row">
|
<!-- <label onclick="clicked('commom/saomiao.html','saomiao',true);"> -->
|
<label ><%=(item[1])%></label>
|
<input type="search" style="text-align:left " readonly name="selectList" id="selectList-<%=(item[0])%>-<%=(item[1])%>" class="mui-input-clear" placeholder="请输入批次号" class="mui-navigate-right" ">
|
</div>
|
{{else if item[4] == '4'}}
|
<div class="mui-input-row">
|
<label><%=(item[1])%></label>
|
<input id="<%=(item[0])%>" value="<%=(item[12])%>" type="hidden">
|
|
<input type="text" class="mui-input" style="width: 50%;float: left;" id="scanSelect-<%=(item[0])%>" onkeyup="enterScanSelect(event,'<%=(item[8])%>','<%=(item[0])%>','<%=(item[10])%>','<%=(item[7])%>')" placeholder="请选择/扫描<%=(item[1])%>">
|
<a class="mui-navigate-right">
|
<select class="mui-select" id="select-<%=(item[0])%>" style="margin:auto;width: 14%;color:#56bd6a;background-color:#56bd6a;" onchange="getCheckItem('<%=(item[8])%>','<%=(item[0])%>','<%=(item[10])%>','<%=(item[7])%>');">
|
<%=(item[0])%>
|
</select>
|
</a>
|
</div>
|
{{else if item[4] == '9'}}
|
<div class="mui-input-row" style="height: 4rem;">
|
<ul class="mui-table-view ulcss" >
|
<li class="mui-table-view-cell acss" style="background-color: rgb(129, 255, 140);" onclick="photoButton(<%=(item)%>)">
|
<a><%=(item[1])%></a>
|
</li>
|
</ul>
|
</div>
|
{{else if item[4] == '11'}}
|
<div class="mui-input-row" style="height: 4rem;">
|
<ul class="mui-table-view ulcss" >
|
<li class="mui-table-view-cell acss" style="background-color: rgb(255, 215, 114);" onclick="listButton(<%=(item)%>)">
|
<a><%=(item[1])%></a>
|
</li>
|
</ul>
|
</div>
|
{{else if item[4] == '13'}}
|
<div class="mui-input-row" style="height: 4rem;">
|
<ul class="mui-table-view ulcss" >
|
<li class="mui-table-view-cell acss" style="background-color: rgb(153,204,153);" onclick="clickPrintBtn(<%=(item)%>)">
|
<a><%=(item[1])%></a>
|
</li>
|
</ul>
|
</div>
|
{{else}}
|
<div class="mui-input-row">
|
<label><%=(item[1])%></label>
|
<input id="<%=(item[0])%>" value="<%=(item[12])%>" type="hidden">
|
<div id="<%=(item[0])%>-switch" data-href="<%=(item[0])%>" class="mui-switch">
|
<div class="mui-switch-handle"></div>
|
</div>
|
</div>
|
{{/if}}
|
{{else if item[2] == 'MEMO'}}
|
<div class="mui-input-row" style="height:<%=(item[14])%>px;">
|
<label><%=(item[1])%></label>
|
<textarea class="form" rows="8" id="<%=(item[0])%>" style="height:<%=(item[14])%>px;"></textarea>
|
</div>
|
{{else if item[2] == 'BUTTON'}}
|
<div class="mui-input-row" style="height: 4rem;">
|
<ul class="mui-table-view ulcss" >
|
<li class="mui-table-view-cell acss" style="background-color: rgb(146, 148, 255);" onclick="clickButton(<%=(item)%>)">
|
<a><%=(item[1])%></a>
|
</li>
|
</ul>
|
</div>
|
{{else if item[2] == 'EDIT'}}
|
{{if item[4] == '11'}}
|
<div class="mui-input-row" style="height: 4rem;">
|
<ul class="mui-table-view ulcss" >
|
<li class="mui-table-view-cell acss" style="background-color: rgb(255, 215, 114);" onclick="listButton(<%=(item)%>)">
|
<a><%=(item[1])%></a>
|
</li>
|
</ul>
|
</div>
|
{{else if item[4] == '4'}}
|
<div class="mui-input-row">
|
<label><%=(item[1])%></label>
|
<input id="<%=(item[0])%>" value="<%=(item[12])%>" type="hidden">
|
|
<input type="text" class="mui-input" style="width: 50%;float: left;" id="scanSelect-mul<%=(item[0])%>" onkeyup="enterScanSelect(event,'<%=(item[8])%>','<%=(item[0])%>','<%=(item[10])%>','<%=(item[7])%>')" placeholder="请选择/扫描<%=(item[1])%>">
|
<a class="mui-navigate-right">
|
<select multiple="multiple" class="mui-select-mul" id="select-mul<%=(item[0])%>" style="margin:auto;width: 14%;color:#56bd6a;background-color:#56bd6a;" onchange="getCheckMultiItem('<%=(item[8])%>','<%=(item[0])%>','<%=(item[10])%>','<%=(item[7])%>');">
|
<%=(item[0])%>
|
</select>
|
|
</a>
|
</div>
|
{{/if}}
|
|
{{else if item[2] == 'DATE'}}
|
<div class="mui-input-row">
|
<label><%=(item[1])%></label>
|
<input id="<%=(item[0])%>" type="hidden">
|
<a class="mui-navigate-right">
|
<span class="mui-badge1" id='<%=(item[0] +1) %>' data-options='{"type":"datatime"}'>
|
<select class="mui-select" id="select-<%=(item[0])%>" style="margin:auto; color:#000;"
|
onchange="getCheckItems('<%=(item[8])%>','<%=(item[0] +1) %>');">
|
<%=(item[0])%>
|
</select>
|
</span>
|
</a>
|
</div>
|
{{else if item[2] == 'SM'}}
|
<div class="mui-input-row">
|
<label><%=(item[1])%></label>
|
<input type="text" class="mui-input" style="width: 50%;float: left;"
|
id="<%=(item[0])%>"
|
placeholder="请扫描<%=(item[1])%>"
|
onkeyup="setSeanCode(event,'<%=(item[7])%>','<%=(item[8])%>','<%=(item[0])%>','<%=(item[9])%>','<%=(item[10])%>')"
|
>
|
<img onclick="openBarcodeCustom('<%=(item[7])%>','<%=(item[8])%>','<%=(item[0])%>','<%=(item[9])%>','<%=(item[10])%>')" src="img/xj_camera.svg" />
|
</div>
|
{{/if}}
|
<% } %>
|
<!--23-12-13 PDA 新加date数据类型测试 <ul class="mui-table-view">
|
<li class="mui-table-view-cell">
|
<a class="mui-navigate-right">
|
会议时间 <span id='startime' data-options='{"type":"datatime"}' class="mui-pull-right"
|
style="margin-right: 20px;min-width:160px;text-align: right;">请选择(必填)</span>
|
</a>
|
<input type="hidden" name="rideStartTime" id='rideS2tartTime'/>
|
</li>
|
<li class="mui-table-view-cell">
|
<a class="mui-navigate-right">
|
至 <span id='endtime' data-options='{"type":"time"}' class="mui-pull-right"
|
style="margin-right: 20px;min-width:160px;text-align: right;">请选择(必填)</span>
|
</a>
|
<input type="hidden" name="rideEndTime" id='rideEn2dTime'/>
|
</li>
|
</ul> -->
|
</div>
|
|
</script>
|
|
<script type="text/javascript" charset="utf-8">
|
var dateTi = null;
|
|
var findId = null;
|
var file71 = null;
|
var str1= null;
|
var file91= null;
|
var file101= null;
|
|
var YES_VOICE;
|
var NO_VOICE;
|
var isCommitted = false; //请求是否已提交标识,true-已提交,false-未提交
|
mui.init({});
|
//获取返回的数据
|
window.addEventListener('changeFlot', function(e) {
|
//获取参数值
|
var flot = e.detail.flot;
|
|
if (flot) {
|
document.getElementById(e.detail.fileId).value = flot
|
}
|
});
|
|
|
mui.plusReady(function() {
|
document.getElementById("usr").innerHTML = setUsrCode();
|
document.getElementById("title").innerHTML = api_localStorageGet("functionName");
|
document.getElementById("divid").innerHTML = "";
|
getData();
|
//初始化打印机
|
if (API.Bluetooth == 'true') {
|
initBluetooth()
|
}
|
})
|
|
function openBarcodeCustom(file7, str, fileId, file9, file10) {
|
findId = fileId;
|
file71 = file7;
|
str1= str;
|
file91= file9;
|
file101= file10;
|
|
createWithoutTitle('getScanCode.html', {
|
titleNView: {
|
type: 'float',
|
backgroundColor: '#009DE2',
|
titleText: '扫一扫',
|
titleColor: '#FFFFFF',
|
autoBackButton: true
|
}
|
});
|
}
|
|
function scaned(t, r, f) {
|
console.log(r);
|
document.getElementById(findId).value = r;
|
setSeanCode({keyCode:123},file71, str1, findId, file91, file101);
|
}
|
|
//蓝牙打印机初始化
|
function initBluetooth() {
|
try {
|
var main = plus.android.runtimeMainActivity();
|
var BluetoothAdapter = plus.android.importClass("android.bluetooth.BluetoothAdapter");
|
var UUID = plus.android.importClass("java.util.UUID");
|
|
uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
|
var BAdapter = BluetoothAdapter.getDefaultAdapter();
|
BAdapter.cancelDiscovery(); //停止扫描
|
|
var address_mac = api_localStorageGet("printMac") ? api_localStorageGet("printMac") :
|
"DC:1D:30:3F:D2:50";
|
device = BAdapter.getRemoteDevice(address_mac);
|
plus.android.importClass(device);
|
|
bluetoothSocket = device.createInsecureRfcommSocketToServiceRecord(uuid);
|
plus.android.importClass(bluetoothSocket);
|
//plus.ui.toast("蓝牙连接成功");
|
} catch (err) {
|
// console.log(err);
|
//mui.alert(err)
|
plus.ui.toast("蓝牙连接异常!");
|
}
|
|
}
|
|
function getData() {
|
mui.ajax(storage["_basePath"] + '/getRfSetup?functionName=' + api_localStorageGet("functionName"), {
|
data: {},
|
dataType: 'json',
|
type: 'POST',
|
timeout: 60000,
|
headers: {
|
'Content-Type': 'application/json'
|
},
|
success: function(data) {
|
//console.log(JSON.stringify(data))
|
if (data.result) {
|
// console.log(JSON.stringify(data.data))
|
var fData = JSON.stringify(data.data)
|
while (fData.indexOf('\\r\\n') != -1) //判断是否含回车符号
|
{
|
fData = fData.replace("\\r\\n", " "); //用空格替换回车
|
}
|
fData = JSON.parse(fData)
|
|
document.getElementById('divid').innerHTML = template('form-template', {
|
"record": fData,
|
});
|
|
dateTi = fData;
|
|
//过滤出时间日期的控件
|
let dateArray = dateTi.filter(item => item[2] == 'DATE');
|
|
//获取所有扫码的控件 在获取组件时已经按照了顺序排序
|
let scanCodeList = dateTi.filter(item => item[2] == 'SM');
|
//取出第一个扫码控件
|
let topScanCode = scanCodeList[0];
|
if (topScanCode) {
|
//获取焦点
|
document.getElementById(topScanCode[0]).focus(); //获取焦点
|
document.getElementById(topScanCode[0]).value = "";
|
}
|
|
console.log(scanCodeList);
|
|
let functions = [];
|
//循环
|
for (let i = 0; i < dateArray.length; i++) {
|
let dateItem = dateArray[i];
|
let functionName = dateItem[0] + "1";
|
|
const dynamicFunction = function() {
|
document.getElementById(functionName).addEventListener('tap',
|
function() {
|
var dDate = new Date();
|
var optionsJson = this.getAttribute(
|
'data-options') || '{}';
|
var options = JSON.parse(optionsJson);
|
var picker = new mui.DtPicker(options);
|
picker.show(function(rs) {
|
//console.log(JSON.stringify(rs))
|
var timestr = rs.y.text + "-" + rs.m
|
.text + "-" + rs
|
.d.text + " " + rs.h.text + ":" + rs
|
.i.text;
|
document.getElementById(functionName)
|
.innerHTML =
|
timestr;
|
document.getElementById(dateItem[0])
|
.value = timestr;
|
picker.dispose();
|
});
|
})
|
};
|
|
functions.push(dynamicFunction);
|
}
|
|
for (const func of functions) {
|
func();
|
}
|
|
|
//滑块
|
addSwitchTog();
|
//comboBox
|
getSelectData();
|
//SQL语句的默认值
|
getExcuteSql();
|
//下拉Lookup
|
getSelectList();
|
} else { //登录失败
|
plus.ui.toast(data.msg);
|
}
|
},
|
error: function(xhr, type, errorThrown) {
|
plus.ui.toast("error:" + type);
|
}
|
})
|
}
|
|
function setSeanCode(event, file7, str, fileId, file9, file10) {
|
if (event.keyCode == 123) {
|
if (file7 != 'N') {
|
//拆分参数
|
doProByFile8(str, fileId);
|
}
|
if (file9 == '0' && file10 == '') {
|
//回车后就停留在本字段,本字段内容先清空
|
document.getElementById(fileId).value = '';
|
document.getElementById(fileId).focus(); //获取焦点
|
}
|
if (file10) {
|
document.getElementById(file10).focus(); //获取焦点
|
document.getElementById(file10).value = "";
|
}
|
}
|
}
|
|
|
function enterSearch(event, file7, str, fileId, file9, file10) {
|
if (event.keyCode == 13 || event.keyCode == 9) { //用户点击回车的事件号为13
|
//判断是否需要调用存储过程
|
if (file7 != 'N') {
|
//{FILED4,FILED3,FILED5,FILED1,FILED2}{FILED1,FILED6,FILED7,INFO}
|
//拆分参数
|
doProByFile8(str, fileId);
|
}
|
//判断跳转字段
|
//console.log(file9)
|
//console.log(file10)
|
if (file9 == '1') {
|
//回车自动跳至下一非只读字段
|
}
|
if (file9 == '0' && file10 == '') {
|
//回车后就停留在本字段,本字段内容先清空
|
document.getElementById(fileId).value = '';
|
document.getElementById(fileId).focus(); //获取焦点
|
}
|
if (file10 != '') {
|
//跳至指定字段,当要求跳到指定字段时,这个指定字段及后面顺序的字段框内容均需要清空;
|
document.getElementById(file10).focus(); //获取焦点
|
document.getElementById(file10).value = '';
|
}
|
}
|
return false;
|
}
|
/* 2022/5/30 新增 下拉项可输入框事件 */
|
function enterScanSelect(event, file8, fileId, file10, file7) {
|
if (event.keyCode == 13 || event.keyCode == 9) { //用户点击回车的事件号为13
|
var obj = document.getElementById('scanSelect-' + fileId); //定位id
|
var value = obj.value; // 选值
|
|
//console.log(document.getElementById(fileId).value = value)
|
if (value == '') {
|
plus.ui.toast('请扫描');
|
document.getElementById(fileId).value = value; //选空后仍然要设置值,否则会提交上一次数据
|
return false;
|
}
|
document.getElementById(fileId).value = value;
|
if (file7 != 'N') { //若此字段不为N,则执行数据请求
|
doProByFile8(file8, fileId);
|
}
|
if (file10 != '') {
|
//跳至指定字段,当要求跳到指定字段时,这个指定字段及后面顺序的字段框内容均需要清空;
|
//document.getElementById(file10).value = '';
|
document.getElementById(file10).focus(); //获取焦点
|
}
|
}
|
return false;
|
}
|
|
function getCursor(fileName, fileValue, outFiles, stype) {
|
var fileId = fileName;
|
fileName = fileName.replace(/\s+/g, "");
|
var url = storage["_basePath"] + '/getCursor?functionName=' + api_localStorageGet("functionName") +
|
'&fileName=' + fileName + '&pmachtype=&fileValue=' + encodeURIComponent(fileValue) +
|
'&outFiles=' + outFiles;
|
// console.log(url+"请求地址");
|
mui.ajax(url, {
|
data: {},
|
dataType: 'json',
|
type: 'POST',
|
timeout: 60000,
|
headers: {
|
'Content-Type': 'application/json'
|
},
|
success: function(data) {
|
console.log(JSON.stringify(data))
|
if (data.result) {
|
if (data.data[0]) {
|
mui.alert("功能发生异常,请联系IT人员")
|
} else {
|
var tdata = [];
|
tdata = data.data[2];
|
var col = [];
|
col = data.data[3];
|
var tbody = '';
|
// console.log(tdata[0].领料单号+"数据");
|
//处理表头
|
var thead = '<tr>';
|
|
for (var i = 0; i < col.length; i++) {
|
// thead += '<th>' + col[i] + '</th>';
|
if (col[i].indexOf('_') != -1) { //判断是否包含设置列宽
|
var tArr = col[i].split('_') //设置列宽,列名
|
thead += '<th width="' + tArr[1] + '%">' + tArr[0] + '</th>'
|
} else {
|
thead += '<th>' + col[i] + '</th>';
|
}
|
|
}
|
thead += '</tr>';
|
document.getElementById('t_head').innerHTML = thead;
|
|
var tbodyItem = '';
|
for (var j = 0; j < tdata.length; j++) {
|
|
tbodyItem += '<tr>'
|
//遍历对象属性值
|
Object.values(tdata[j]).forEach(val => {
|
// console.log(val)
|
tbodyItem += '<td>' + val + '</td>'
|
})
|
tbodyItem += '</tr>'
|
|
}
|
|
tbody += tbodyItem
|
|
document.getElementById('t_body').innerHTML = tbody
|
document.getElementById('tableDiv').style.display = 'block'
|
}
|
|
} else { //获取列表失败
|
plus.ui.toast(data.msg);
|
}
|
},
|
error: function(xhr, type, errorThrown) {
|
plus.ui.toast("error:" + type);
|
}
|
})
|
}
|
|
function getExcProc(fileName, fileValue, outFiles, stype) {
|
console.log(fileName+" "+fileValue+" "+outFiles+" "+stype);
|
var fileId = fileName;
|
fileName = fileName.replace(/\s+/g, "");
|
var url = storage["_basePath"] + '/getExcProc?functionName=' + api_localStorageGet("functionName") +
|
'&fileName=' + fileName + '&pmachtype=&fileValue=' + encodeURIComponent(fileValue) +
|
'&outFiles=' + outFiles;
|
//console.log(fileValue)
|
mui.ajax(url, {
|
data: {},
|
dataType: 'json',
|
type: 'POST',
|
timeout: 60000,
|
headers: {
|
'Content-Type': 'application/json'
|
},
|
success: function(data) {
|
//console.log(JSON.stringify(data))
|
if (data.result) {
|
playerYes()
|
if (stype.indexOf('proc') != -1) {
|
//console.log(data.data[0]);
|
|
|
for (var i = 0; i < data.data.length; i++) {
|
var t = data.data[i];
|
if (document.getElementById(t[0])) {
|
//document.getElementById(t[0]).value = t[1];
|
//20200420-fyx,如果返回值包括{则是下拉框类型
|
if (t[1].indexOf("{") == -1) {
|
let dateId = t[0] + "1";
|
document.getElementById(t[0]).value = t[1];
|
|
if(document.getElementById(dateId)){
|
//如果配置平台配置了清空则将原本已有的值重新赋上
|
let dateTime = document.getElementById(dateId).innerHTML;
|
document.getElementById(t[0]).value = dateTime;
|
}
|
|
} else {
|
var a = t[1].split('{')
|
setSelect(a, t[0])
|
}
|
}
|
}
|
|
} else if (stype.indexOf('select') != -1) {
|
var t = data.data.split(',');
|
var commHtml = "<option value=''>请点击选择</option>"
|
//console.log(t)
|
for (var i in t) {
|
if (t[i].length > 0) {
|
commHtml += "<option value='" + t[i] + "'>" + t[i] + "</option>";
|
}
|
}
|
if (document.getElementById('select-' + fileName) == null) {
|
document.getElementById('select-mul' + fileName).innerHTML =
|
commHtml;
|
} else {
|
document.getElementById('select-' + fileName).innerHTML = commHtml;
|
}
|
|
//document.getElementById('select-mui' + fileName).innerHTML = commHtml;
|
}
|
if (stype.indexOf('cursor') != -1) {
|
var valueData = data.data.toString()
|
var t1 = valueData.substring(valueData.indexOf(',') + 1, valueData
|
.length)
|
//console.log(t1)
|
var tData = t1.split(',')
|
//console.log(tData)
|
var table = tData[tData.length - 1].split('{')
|
var tbody = ''
|
for (var i = 0; i < table.length; i++) {
|
var item = table[i].split('@')
|
|
if (i == 0) {
|
var thead = '<tr>'
|
/* for (var j = 0; j < item.length; j++) { //处理数据
|
thead += '<th>' + item[j] + '</th>'
|
} */
|
for (var j = 0; j < item.length; j++) { //处理数据-2022/3/11
|
// console.log(item[j]);
|
if (item[j].indexOf('_') != -1) { //判断是否包含设置列宽
|
var tArr = item[j].split('_') //设置列宽,列名
|
thead += '<th width="' + tArr[1] + '%">' + tArr[0] +
|
'</th>'
|
} else {
|
thead += '<th>' + item[j] + '</th>'
|
}
|
}
|
thead += '</tr>'
|
document.getElementById('t_head').innerHTML = thead
|
} else {
|
var tbodyItem = '<tr>'
|
for (var j = 0; j < item.length; j++) { //处理数据
|
tbodyItem += '<td>' + item[j] + '</td>'
|
}
|
tbodyItem += '</tr>'
|
tbody += tbodyItem
|
}
|
}
|
document.getElementById('t_body').innerHTML = tbody
|
document.getElementById('tableDiv').style.display = 'block'
|
}
|
|
if (stype.indexOf('print') != -1) {
|
//打印 ,1取到ID,2查询打印内容,3调用打印
|
var da = data.data[0];
|
if (da != "") {
|
da.splice(0, 1);
|
printByIds(da.toString());
|
//printByIds("16459811");
|
}
|
// printByIds(da.toString());
|
}
|
//plus.nativeUI.toast("请求成功",{verticalAlign:'center'})
|
} else {
|
playerNo()
|
mui.alert(data.msg, '错误', function() {
|
document.getElementById(fileId).value = "";
|
document.getElementById(fileId).focus(); //获取焦点
|
//关闭回调函数
|
//clearUi()
|
});
|
}
|
isCommitted = false; //请求结束,标识设置为未提交状态
|
},
|
error: function(xhr, type, errorThrown) {
|
console.log(xhr)
|
console.log(type)
|
console.log(errorThrown)
|
isCommitted = false; //请求结束,标识设置为未提交状态
|
plus.ui.toast("error1:" + type);
|
}
|
})
|
}
|
|
function addSwitchTog() {
|
var switchs = document.getElementsByClassName('mui-switch');
|
if (switchs.length > 0) {
|
mui('.mui-switch')['switch']();
|
for (var i = 0; i < switchs.length; i++) { //2021-4-21 lst add 滑块按键增加默认值0
|
var fileId = switchs[i].getAttribute('data-href');
|
document.getElementById(fileId).value = "0";
|
}
|
for (var i = 0; i < switchs.length; i++) {
|
switchs[i].addEventListener("toggle", function(event) {
|
var fileId = this.getAttribute('data-href');
|
if (event.detail.isActive) {
|
//console.log("你启动了开关");
|
document.getElementById(fileId).value = "1";
|
} else {
|
//console.log("你关闭了开关");
|
document.getElementById(fileId).value = "0";
|
}
|
})
|
}
|
}
|
};
|
|
function getSelectData() {
|
var selects = document.getElementsByClassName('mui-select');
|
var selectsMul = document.getElementsByClassName('mui-select-mul');
|
if (selects.length > 0) {
|
for (var i = 0; i < selects.length; i++) {
|
// console.log(selects[i].innerHTML+';'+api_localStorageGet("code")+';')
|
getExcProc(selects[i].innerHTML, api_localStorageGet("code") + '[_N', '', 'select');
|
}
|
//console.log(selects[0].innerHTML+';'+api_localStorageGet("code")+';')
|
//getExcProc(selects[0].innerHTML, api_localStorageGet("code") + '[_N','','select');
|
}
|
if (selectsMul.length > 0) {
|
for (var i = 0; i < selectsMul.length; i++) {
|
// console.log(selects[i].innerHTML+';'+api_localStorageGet("code")+';')
|
// console.log("111111111111")
|
getExcProc(selectsMul[i].innerHTML, api_localStorageGet("code") + '[_N', '', 'select');
|
}
|
}
|
}
|
|
function getExcuteSql() { //设置含SQL语句的默认值
|
var input = document.getElementsByName('inputDefault');
|
if (input.length > 0) {
|
for (var i = 0; i < input.length; i++) {
|
var upperValue = input[i].value.toUpperCase();
|
|
var reg = new RegExp(/INSERT|DELETE|UPDATE|DROP|TRUNCATE/)
|
if (reg.test(upperValue)) {
|
continue; //正则过滤数据库关键词
|
}
|
|
upperValue = upperValue.replace('{USERCODE}', api_localStorageGet("code"))
|
if (upperValue.substring(0, 6) == "SELECT") { //首6位为SELECT才可执行查询语句,否则视为字符串
|
getExcuteSqlData(upperValue, input[i].id)
|
}
|
}
|
}
|
}
|
|
//执行SQL查询语句
|
function getExcuteSqlData(str, inputId) {
|
mui.ajax(storage["_basePath"] + '/getExcuteSql', {
|
data: {
|
"str": str,
|
},
|
type: 'POST',
|
timeout: 30000,
|
success: function(data) {
|
if (data.result) {
|
document.getElementById(inputId).value = data.data[0]; //指定第一个值输入框赋值
|
} else {
|
plus.ui.toast(data.msg); //查询失败原因
|
}
|
},
|
error: function(xhr, type, errorThrown) {
|
plus.ui.toast('失败!失败类型是:' + type);
|
}
|
})
|
}
|
|
function getSelectList() {
|
var select_list = document.getElementsByName("selectList");
|
if (select_list.length > 0) {
|
for (var i = 0; i < select_list.length; i++) {
|
var strs = select_list[i].id.split("-"); //字符分割
|
//console.log(JSON.stringify(select_list[0].id))
|
var fileId = '';
|
if (strs.length >= 1) {
|
fileId = strs[1]
|
}
|
var fileName = '';
|
if (strs.length >= 2) {
|
fileName = strs[2]
|
}
|
|
document.getElementById(select_list[i].id).addEventListener('tap', function(event) {
|
openList(fileId, fileName)
|
|
});
|
}
|
|
}
|
}
|
|
//20211214-fyx-打开新的列表页面
|
function openList(fileId, fileName) {
|
|
mui.openWindow({
|
id: 'select_search_list',
|
url: 'select_search_list.html',
|
extras: {
|
file_name: fileId,
|
title_name: fileName,
|
test: '中文'
|
},
|
waiting: { // 控制 弹出转圈框的信息
|
autoShow: true, //自动显示等待框,默认为true
|
title: '加载中' //等待对话框上显示的提示内容
|
}
|
});
|
}
|
|
function getCheckMultiItem(file8, fileId, file10, file7, file15) {
|
// console.log("方法调用")
|
|
var obj = document.getElementById('select-mul' + fileId); //定位id
|
|
var select = document.getElementById('select-mul' + fileId);
|
var value = [];
|
for (i = 0; i < select.length; i++) {
|
if (select.options[i].selected) {
|
value.push(select[i].value);
|
}
|
}
|
// console.log(value+"111111111")
|
// value.join('@')
|
|
var str = ' ';
|
var t = '@';
|
for (var i = 0; i < value.length; i++) {
|
if (i == value.length - 1) {
|
str += value[i];
|
} else {
|
str += value[i] + t;
|
}
|
}
|
|
// console.log(str+"转换后的")
|
if (value == '') {
|
plus.ui.toast('请选择');
|
document.getElementById('scanSelect-mul' + fileId).value = value; //扫描输入框展示
|
document.getElementById(fileId).value = value; //选空后仍然要设置值,否则会提交上一次数据
|
return false;
|
}
|
|
document.getElementById('scanSelect-mul' + fileId).value = str; //扫描输入框展示
|
document.getElementById(fileId).value = str;
|
|
if (file7 != 'N') { //若此字段不为N,则执行数据请求
|
doProByFile8(file8, fileId);
|
}
|
if (file10 != '') {
|
//跳至指定字段,当要求跳到指定字段时,这个指定字段及后面顺序的字段框内容均需要清空;
|
document.getElementById(file10).value = '';
|
document.getElementById(file10).focus(); //获取焦点
|
}
|
}
|
|
function getCheckItem(file8, fileId, file10, file7, file15) {
|
//console.log(file8)
|
//console.log(fileId)
|
var obj = document.getElementById('select-' + fileId); //定位id
|
var index = obj.selectedIndex; // 选中索引
|
var value = obj.options[index].value; // 选中值
|
if (value == '') {
|
plus.ui.toast('请选择');
|
document.getElementById('scanSelect-' + fileId).value = value; //扫描输入框展示
|
document.getElementById(fileId).value = value; //选空后仍然要设置值,否则会提交上一次数据
|
return false;
|
}
|
|
document.getElementById('scanSelect-' + fileId).value = value; //扫描输入框展示
|
document.getElementById(fileId).value = value;
|
if (file7 != 'N') { //若此字段不为N,则执行数据请求
|
doProByFile8(file8, fileId);
|
}
|
if (file10 != '') {
|
//跳至指定字段,当要求跳到指定字段时,这个指定字段及后面顺序的字段框内容均需要清空;
|
document.getElementById(file10).value = '';
|
document.getElementById(file10).focus(); //获取焦点
|
}
|
}
|
|
|
function getCheckItems(file8, fileId) {
|
console.log('------------' + fileId);
|
var obj = document.getElementById(fileId);
|
var index = obj.selectedIndex;
|
var value = obj.options[index].value;
|
if (value == '') {
|
plus.ui.toast('请选择');
|
document.getElementById(fileId).value = value;
|
return false;
|
}
|
document.getElementById(fileId).value = value;
|
doProByFile8(file8, fileId);
|
}
|
|
//检验返回结果,若尚未返回则不可再次提交
|
function doProByFile8(file8, fileId) {
|
// console.log("提交状态:" + isCommitted)
|
if (isCommitted == false) { //当请求未提交时-可提交
|
isCommitted = true; //标识设置为已提交状态
|
doProByFile8Prc(file8, fileId)
|
} else { //当请求已提交时-不可提交,驳回请求
|
// console.log("提交失败")
|
// mui.toast("数据已发送,请不要连续操作")
|
return false
|
}
|
}
|
//原文件名-doProByFile8
|
function doProByFile8Prc(file8, fileId) {
|
|
try {
|
//console.log(file8)
|
var date = file8.substring(1, file8.length - 1);
|
var a = date.split("}{");
|
var iput = a[0].split(',');
|
//sconsole.log(iput)
|
var fileValue = api_localStorageGet("code") + '[';
|
for (var i = 0; i < iput.length; i++) {
|
var fv = document.getElementById(iput[i]).value
|
//fv = fv.replace(/\s*/g,"");
|
fv = fv.trim();
|
//console.log(fv)
|
fileValue += fv + '[';
|
//console.log(fileValue)
|
}
|
fileValue = fileValue.substring(0, fileValue.length - 1);
|
console.log(fileValue);
|
//getExcProc(fileId, fileValue, a[1], 'proc');
|
if (a[1]) {
|
var input = a[1].split(',');
|
if (input[input.length - 1] == 'FVIEW') {
|
|
getExcProc(fileId, fileValue, a[1], 'cursor+proc');
|
} else {
|
getExcProc(fileId, fileValue, a[1], 'proc');
|
}
|
} else {
|
getExcProc(fileId, fileValue, a[1], 'proc');
|
}
|
} catch (e) {
|
//console.log(e)
|
mui.alert("功能发生异常,请联系IT人员")
|
isCommitted = false; //请求结束,标识设置为未提交状态
|
return false
|
}
|
}
|
|
//点击打印
|
function clickPrintBtn(item) {
|
try {
|
console.log(item)
|
var file8 = item[8]
|
var file9 = item[9]
|
var file10 = item[10]
|
var fileId = item[0]
|
var date = file8.substring(1, file8.length - 1);
|
var a = date.split("}{");
|
var iput = a[0].split(',');
|
console.log(a)
|
console.log(iput)
|
var fileValue = api_localStorageGet("code") + '[';
|
for (var i = 0; i < iput.length; i++) {
|
var fv = document.getElementById(iput[i]).value
|
//fv = fv.replace(/\s*/g, "");//兼容条码内可带空格的情况-2022/9/8
|
//console.log(fv)
|
fileValue += fv + '[';
|
}
|
fileValue = fileValue.substring(0, fileValue.length - 1);
|
|
//先清空字段
|
if (file10 != '') {
|
//跳至指定字段,当要求跳到指定字段时,这个指定字段及后面顺序的字段框内容均需要清空;
|
document.getElementById(file10).value = '';
|
document.getElementById(file10).focus(); //获取焦点
|
}
|
|
setTimeout(function() {
|
if (a[1]) {
|
var input = a[1].split(',');
|
if (input[input.length - 1] == 'FVIEW') { //执行过程后可刷新列表
|
getExcProc(fileId, fileValue, a[1], 'cursor+print');
|
} else {
|
getExcProc(fileId, fileValue, a[1], 'print');
|
}
|
} else {
|
getExcProc(fileId, fileValue, a[1], 'print');
|
}
|
}, 50) //延迟执行打印
|
|
} catch (e) {
|
console.log(e)
|
mui.alert("功能发生异常,请联系IT人员")
|
isCommitted = false; //请求结束,标识设置为未提交状态
|
return false
|
}
|
}
|
|
function printByIds(ids) {
|
//console.log(ids)
|
mui.ajax(storage["_basePath"] + '/getPrintInfoById', {
|
data: {
|
"ids": ids,
|
},
|
type: 'POST',
|
timeout: 30000,
|
success: function(data) {
|
if (data.result) {
|
console.log(JSON.stringify(data.data));
|
try {
|
var printCmd = ""
|
for (var i = 0; i < data.data.length; i++) {
|
var templateNo = data.data[i].FNO;
|
switch (templateNo) {
|
case 1:
|
printCmd += printTemplate(data.data[i]) + "\r\n";
|
break;
|
case 2:
|
printCmd = printCardBoardTemplate(data.data[i])
|
break;
|
default:
|
mui.alert("获取模板编号失败,请检查数据")
|
return false
|
}
|
}
|
setTimeout(function() {
|
doPrint(printCmd, 1)
|
}, 1000)
|
} catch (e) {
|
plus.ui.toast("打印执行异常: " + e)
|
//plus.ui.toast("printErr: " + err)
|
}
|
|
|
/* for (var i = 0; i < data.data.length; i++) {
|
var printCmd = printTemplate(data.data[i])
|
setTimeout(function(){
|
doPrint(printCmd, 1)
|
},1000)
|
} */ //旧版本,会有标签打印缺失的情况
|
} else {
|
//查询失败原因
|
plus.ui.toast(data.msg);
|
}
|
},
|
error: function(xhr, type, errorThrown) {
|
plus.ui.toast('打印失败!失败类型是:' + type);
|
}
|
})
|
}
|
|
function doPrint(printCmd, printNum) { //printNum:打印次数
|
if (printNum < 3) { //只递归3次
|
try {
|
//console.log("打印机连接状态:" + bluetoothSocket.isConnected())
|
var connectStatus = 0; //连接状态
|
for (var i = 0; i < 10; i++) {
|
if (!bluetoothSocket.isConnected()) {
|
plus.ui.toast("重新连接");
|
bluetoothSocket.connect();
|
}
|
//console.log("重连次数i"+i)
|
if (bluetoothSocket.isConnected()) {
|
connectStatus = 1;
|
break;
|
} else {
|
continue;
|
}
|
}
|
//console.log("status:"+connectStatus)
|
if (connectStatus == 1) {
|
var outputStream = bluetoothSocket.getOutputStream();
|
plus.android.importClass(outputStream);
|
var arrayBuffer = plus.android.invoke(printCmd, 'getBytes',
|
'gbk'); //stringToByte(printCmd);
|
outputStream.write(arrayBuffer);
|
outputStream.flush();
|
} else {
|
plus.ui.toast("连接打印机失败")
|
}
|
} catch (e) {
|
printNum++;
|
plus.ui.toast("正在重连打印机第" + printNum + "次:" + e)
|
//console.log(e)
|
setTimeout(initBluetooth(), 1000) //一连接异常就初始化打印机
|
setTimeout(function() {
|
doPrint(printCmd, printNum) //重新执行
|
}, 1000)
|
}
|
} else { //不再回调自身
|
try {
|
//console.log("打印机连接状态:" + bluetoothSocket.isConnected())
|
var connectStatus = 0; //连接状态
|
for (var i = 0; i < 10; i++) {
|
if (!bluetoothSocket.isConnected()) {
|
plus.ui.toast("重新连接");
|
bluetoothSocket.connect();
|
}
|
//console.log("重连次数i"+i)
|
if (bluetoothSocket.isConnected()) {
|
connectStatus = 1;
|
break;
|
} else {
|
continue;
|
}
|
}
|
if (connectStatus == 1) {
|
var outputStream = bluetoothSocket.getOutputStream();
|
plus.android.importClass(outputStream);
|
var arrayBuffer = plus.android.invoke(printCmd, 'getBytes',
|
'gbk'); //stringToByte(printCmd);
|
outputStream.write(arrayBuffer);
|
outputStream.flush();
|
} else {
|
plus.ui.toast("连接打印机失败")
|
}
|
} catch (e) {
|
printNum++;
|
plus.ui.toast("打印机异常第" + printNum + "次:" + e)
|
//console.log(e)
|
mui.alert("重连打印机失败,请重新打开页面,初始化打印机。")
|
}
|
}
|
//console.log(printNum)
|
//console.log(printCmd)
|
}
|
|
function doProByFile8Cursor(file8, fileId, fileType) {
|
//document.getElementById('tableDiv').style.display = 'block'
|
var date = file8.substring(1, file8.length - 1);
|
var a = date.split("}{");
|
// console.log(a,"file9");
|
var iput = a[0].split(',');
|
var fileValue = api_localStorageGet("code") + '[';
|
for (var i = 0; i < iput.length; i++) {
|
//console.log(iput[i])
|
var fv = document.getElementById(iput[i]).value
|
fv = fv.trim();
|
//console.log(fv)
|
fileValue += fv + '[';
|
}
|
fileValue = fileValue.substring(0, fileValue.length - 1);
|
if (fileType == 'EDIT') {
|
getCursor(fileId, fileValue, a[1], 'cursor');
|
} else {
|
getExcProc(fileId, fileValue, a[1], 'cursor');
|
}
|
}
|
|
//20200420-fyx
|
function setSelect(t, fileName) {
|
//console.log("t:" + t)
|
var commHtml = "<option value=''>请点击选择</option>"
|
for (var i in t) {
|
if (t[i].length > 0) {
|
commHtml += "<option value='" + t[i] + "'>" + t[i] + "</option>";
|
}
|
}
|
document.getElementById('select-' + fileName).innerHTML = commHtml;
|
document.getElementById(fileName).value = ''; //将对应数据栏的数据清空,防止数据重新载入还保留上一次数据
|
}
|
|
//点击按钮
|
function clickButton(item) {
|
|
var file10 = item[10]
|
var file8 = item[8]
|
doProByFile8(file8, item[0])
|
|
//执行后判断
|
if (file10 != '') {
|
//跳至指定字段,当要求跳到指定字段时,这个指定字段及后面顺序的字段框内容均需要清空;
|
document.getElementById(file10).value = '';
|
document.getElementById(file10).focus(); //获取焦点
|
}
|
|
}
|
|
|
|
|
//点击拍照按钮
|
function photoButton(item) {
|
//先执行,将返回id传递过去
|
mui.openWindow({
|
id: 'pictrue_add',
|
url: 'ftp/pictrue_add.html',
|
waiting: { // 控制 弹出转圈框的信息
|
autoShow: true, //自动显示等待框,默认为true
|
title: '加载中' //等待对话框上显示的提示内容
|
}
|
});
|
}
|
|
function listButton(item) {
|
var file8 = item[8]
|
doProByFile8Cursor(file8, item[0], item[2])
|
}
|
|
//播放声音-成功音效
|
function playerYes() { //播放音乐
|
YES_VOICE = plus.audio.createPlayer("wav/YES.WAV");
|
|
YES_VOICE.play(function() {
|
YES_VOICE.close()
|
}, function(e) {
|
//console.log("Audio play error: " + e.message);
|
})
|
}
|
|
//播放声音-失败音效
|
function playerNo() { //播放音乐
|
NO_VOICE = plus.audio.createPlayer("wav/NO.WAV");
|
|
NO_VOICE.play(function() {
|
NO_VOICE.close()
|
}, function(e) {
|
//console.log("Audio play error: " + e.message);
|
});
|
}
|
</script>
|
</body>
|
</html>
|