<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page language="java" import="com.tepper.common.ToolConstants"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>工具报废移除</title>
<%@ include file="/busi/qui_head.jsp"%>
<script type="text/javascript" src="<%=path%>/libs/js/popup/drag.js"></script>
<script type="text/javascript" src="<%=path%>/libs/js/popup/dialog.js"></script>
<script src="<%=path%>/libs/js/form/form.js" type="text/javascript"></script>
<script src="<%=path%>/libs/js/form/validationRule.js" type="text/javascript"></script>
<script src="<%=path%>/libs/js/form/validation.js" type="text/javascript"></script>
<script type="text/javascript" src="<%=path%>/libs/js/form/stepper.js"></script>
<script type="text/javascript" src="/busi/tool/common/common.js"></script>
<link href="<%=path%>/busi/css/reset.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/busi/css/newMain.css" rel="stylesheet" type="text/css" />
<eRedG4:ext.codeRender fields="ISFLAG,TOOLSTATUS,ISVALID"/>
</head>
<body onbeforeunload="closeCardReader()">
<object id="cardReader" classid="clsid:0077C28B-EEFF-403A-B74D-FD33AC4F6AFE" width="10" height="0"></object>
<form method="post" id="allocateForm" action="<%=path%>/busi/stockAction.ered?reqCode=scrapRem">
<div class="conentMain" id="conentMain">
<div class="hd">
<h3 class="fl">${deptname}</h3>
<span class="fr">${name} ${account}</span></div>
<div class="bd">
<div class="used">
<table class="ct">
<tr>
<td><input type="radio" name="scrap" id="scrap" checked="checked" value="3" />报废
<input type="radio" name="scrap" id="remove" value="0"/>移除 </td>
<td>操作监区:</td>
<td>
<select id="sys_suborgid" name="sys_suborgid" selWidth="95" data=‘${prisonJson}‘ prompt="请选择" childId="tool" childDataPath="<%=path%>/busi/stockAction.ered?reqCode=toolScrapSelect&sys_suborgid=" onchange="removelist()"/>
</td>
<td> <input type="radio" name="scan" id="scan" checked="checked" value="1" />扫描
<input type="radio" name="scan" id="manualAdd" value="2"/>手动添加 </td>
<td><select id="tool" name="tool" style="width:60px" prompt="请选择" selWidth="95" onchange="toList()"/> </td>
<td> <input type="checkbox" name="free" id="free" value="1" checked="checked" />在库
<input type="checkbox" name="free" id="diabled" value="3" disabled />报废
<input type="checkbox" name="free" id="loss" value="4" checked="checked" />报损上缴</td>
</tr>
</table>
</div>
<div class="path"><em>当前扫描工具信息:</em><span id="tipDiv"> </span></div>
<div class="tableMain stableMain">
<div class="tableLeft fl">
<table class="tableST" width="100%" border="0" cellpadding="0" cellspacing="0" border="0" id="labelList" name="labelList">
<tr>
<th width="40">序号</th><th>物理标签</th><th>临/固</th><th>状态</th><th>操作</th>
</tr>
</table>
</div>
<div class="tableRight fr">
<div class="rowspan10">
<table class="tableST" width="100%" border="0" cellpadding="0" cellspacing="0" border="0" id="collectList" name="collectList" >
<tr>
<th width="40">序号</th><th>类型</th><th>标签工具</th><th width="50">数量</th><th>操作</th>
</tr>
</table>
</div>
<div class="toolAll">
<span>报废移除总数:<i id="totalNum" >0</i></span>
<span>标签工具:<i id="isLabTolNum" style="color:blue;">0</i></span>
<span>非标签工具:<i id="notLabTolNum" style="color:blue;">0</i></span>
</div>
<div class="funBtn">
<ul>
<li>
<button type="button" onclick="javascript:scanstart();" id="btn_start" style="display:none;padding-left: 5px;" ><span class="icon_find" style="cursor: default;">开始扫描</span></button>
</li>
<li>
<button type="button" id="btn_stop" class="button" style="padding-left: 5px;" onclick="javascript:stop();"><span class="icon_pause" style="cursor: default;">暂停扫描</span></button>
</li>
<li>
<button type="button" class="button" style="padding-left: 5px;" onclick="javascript:onSure();" ><span class="icon_ok" style="cursor: default;">确认调配</span></button>
</li>
<li>
<button type="button" class="button" style="padding-left: 5px;" onclick="javascript:doEmptyData();" ><span class="icon_circle" style="cursor: default;">清空数据</span></button>
</li>
<li>
<button type="button" class="button" style="padding-left: 5px;" onclick="javascript:doClose();" ><span class="icon_delete" style="cursor: default;">关闭</span></button>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<input type="hidden" name="hy_stockoperation" id="hy_stockoperation" value="${hy_stockoperation}"/><!-- 5=报废移除 -->
<input type="hidden" name="dirtydata" id="dirtydata"/>
</form>
<script type="text/javascript">
parent.optWindow = window;
var $currentTr;
var interval;
var totalNum = 0;
var isLabelTotalNum = 0;
var notLabelTotalNum = 0;
var iMilliSeconds = 2 * 1000;
//报废、移除单选点击事件
$(function(){
$("input[name=scrap]").click(function(){
$("#totalNum,#isLabTolNum,#notLabTolNum").html(0);
$("#labelList tr:gt(0)").remove();
$("#labelList").render();
$("#collectList tr:gt(0)").remove();
$("#collectList").render();
showCont();
});
$("input[name=scan]").click(function(){
$("#labelList tr:gt(0)").remove();
$("#labelList").render();
});
openCardReader();
});
function removelist(){
$("#labelList tr:gt(0)").remove();
$("#labelList").render();
}
function showCont(){
switch($("input[name=scrap]:checked").attr("id")){
case "scrap":
$("#diabled").attr("checked",false);
$("#diabled").attr("disabled",true);
break;
case "remove":
$("#diabled").attr("disabled",false);
break;
}
}
//手动添加列表
function toList(){
stop();
$("#labelList tr:gt(0)").remove();
$("#labelList").render();
$("#manualAdd").attr("checked",true);//下拉框选择后自动切换成手动添加
var sys_suborgid=$("#sys_suborgid").attr("relValue");
var tool=$("#tool").attr("relValue");
var scan=$("input:radio[name=scan]").filter("[checked]").val();
var scrap=$("input:radio[name=scrap]").filter("[checked]").val();
if(scrap==‘3‘){
scrap=‘报废‘;
}
if(scrap==‘0‘){
scrap=‘移除‘;
}
//scrap=(scrap==‘3‘?‘报废‘:‘移除‘);
var free = "";
$("input:checkbox[name=free]").each(function(){
if($(this).attr("checked")){
free += "," + $(this).val();
}
})
free=free.substring(1);
var param = {
scan: scan,
tool: tool,
free: free,
sys_suborgid:sys_suborgid
};
$.post(‘<%=path%>/busi/stockAction.ered?reqCode=searchList‘,param,function(result){
var resultData=eval("("+result+")");
var html=[];
for(var i=0; i<resultData.length; i++) {
html.push(‘<tr>‘);
html.push(‘<td>‘+(i+1)+‘</td>‘);
if(resultData[i].htt_islabel==‘1‘){
html.push(‘<input type="hidden" name="hte_id" value="‘+resultData[i].hte_id+‘" />‘);//工具类型
html.push(‘<td>‘+resultData[i].hte_pcode+‘</td>‘);//物理标签hte_ecode
}else{
html.push(‘<td>‘+resultData[i].htt_name+‘(‘+resultData[i].number+‘)‘+‘</td>‘);//物理标签hte_ecode
}
if(resultData[i].htt_isfixed==‘1‘){
html.push(‘<td>固定</td>‘); //是否固定工具
}else{
html.push(‘<td>临时</td>‘); //是否固定工具
}
html.push(‘<td>‘+TOOLSTATUSRender(resultData[i].hte_statu)+‘</td>‘); //状态
var j=0;
if(resultData[i].htt_islabel==‘1‘){
$("#collectList tr:gt(0)").each(function(){ //判断右侧是否已选择(重新选择了标签工具)
var RFIDNos = $(this).find("input[name=RFIDNo]").val();
if(RFIDNos&&RFIDNos.indexOf(resultData[i].hte_id)!=-1){
html.push(‘<td><span class="img_ok" title="‘+"取消"+scrap+‘" onclick="addrow(\‘‘+resultData[i].hte_id+‘\‘,\‘‘+resultData[i].htt_name+‘\‘,\‘‘+resultData[i].htt_islabel+‘\‘,\‘‘+resultData[i].htt_id+‘\‘,\‘‘+(i+1)+‘\‘,\‘‘+resultData[i].hte_statu+‘\‘)"></span></td>‘);
j++;
}
});
}
if(j==0){
html.push(‘<td><span class="img_no" title="‘+scrap+‘" onclick="addrow(\‘‘+resultData[i].hte_id+‘\‘,\‘‘+resultData[i].htt_name+‘\‘,\‘‘+resultData[i].htt_islabel+‘\‘,\‘‘+resultData[i].htt_id+‘\‘,\‘‘+(i+1)+‘\‘,\‘‘+resultData[i].hte_statu+‘\‘)"></span></td>‘);
}
html.push(‘</tr>‘);
}
$("#labelList").append(html.join(""));
$("#labelList").render();
});
}
function addrow(hte_id,htt_name,htt_islabel,htt_id,rownumber,hte_statu){
var colIdMap = new Map();
var existRowNum = 0;
var clIndex = $("#collectList tr").length;//汇总列表行数
var htt_name = htt_name;//工具类型名
if(htt_islabel==‘0‘){//非标签
var url="<%=path%>/busi/stockAction.ered?reqCode=searchnotLab&htt_id="+htt_id+"&hte_statu="+hte_statu;
var sys_orgid=$("#sys_suborgid").attr("relValue");
if(sys_orgid!=""&&sys_orgid!=null){
url+="&sys_orgid="+sys_orgid;
}
var dialog = Dialog.open({
URL: url,
Title: ‘非标签工具报废移除‘,
Width: 450,
Height: 180
});
}else{//标签
var scrap=$("input:radio[name=scrap]").filter("[checked]").val();
if(scrap==‘3‘){
scrap=‘取消报废‘;
}
if(scrap==‘0‘){
scrap=‘取消移除‘;
}
$("#labelList tr:eq("+rownumber+")").find("td:eq(4)").html(‘<span class="img_ok" title="‘+scrap+‘" style="color:red" onclick="cancel(\‘‘+hte_id+‘\‘,\‘‘+htt_name+‘\‘,\‘‘+htt_islabel+‘\‘,\‘‘+htt_id+‘\‘,\‘‘+rownumber+‘\‘)"/></span>‘);
$("#labelList").render();
var colIdMap = new Map();
var existRowNum = 0;
//查找已添加至汇总列表中的工具类型Id,存放在idMap中
$("#collectList tr:gt(0)").each(function(){
var htt_idbak = $(this).find("input[name=htt_id]").val();
colIdMap.put(htt_idbak, htt_idbak);
if(htt_idbak == htt_id){//如果扫描来的类型ID与之前的类型ID相等,那么就应该将记录行号
existRowNum = colIdMap.size();
}
});
var clIndex = $("#collectList tr").length;//汇总列表行数
var htt_name = htt_name;//工具类型名
//var htt_islabelChina = ISFLAGRender(htt_islabel); //是否标签工具
if(!colIdMap.get(htt_id)){//如果类型不在汇总列表中,重新添加一行汇总记录
var colTr = [];
colTr.push(‘<tr>‘);
colTr.push(‘<input type="hidden" id="htt_id" name="htt_id" value="‘+htt_id+‘" />‘);//工具类型
colTr.push(‘<input type="hidden" name="htt_islabel" value="‘+htt_islabel+‘" />‘); //是否电子标签
colTr.push(‘<input type="hidden" name="RFIDNo" value="‘+hte_id+‘" />‘);//电子标签号字符串
colTr.push(‘<td>‘+clIndex+‘</td><td>‘+htt_name+‘</td><td>是</td><td>‘+1+‘</td>‘);
colTr.push(‘<td><span class="img_delete hand" title="删除"></span></td>‘);
colTr.push(‘</tr>‘);
$tr = $(colTr.join(""));
addNewRowHandler($tr, clIndex);
}else{//如果类型已在汇总列表中,那么在原来行记录中改变发放数量和电子标签号字符串内容
var RFIDNos = $("#collectList tr:eq("+existRowNum+")").find("input[name=RFIDNo]").val();
var num = $("#collectList tr:eq("+existRowNum+")").find("td:eq(3)").html();
RFIDNos=RFIDNos+","+hte_id;
var hsl_toolnumber = Number(num) + 1;
$("#collectList tr:eq("+existRowNum+")").find("input[name=RFIDNo]").val(RFIDNos);
$("#collectList tr:eq("+existRowNum+")").find("td:eq(3)").html(hsl_toolnumber);
$("#collectList").render(); //重新渲染表格
}
var isLabelTotalNum = $("#isLabTolNum").html();
isLabelTotalNum=Number(isLabelTotalNum)+1
$("#isLabTolNum").html(isLabelTotalNum);
var tempNotLabTN = $("#notLabTolNum").html();
totalNum = Number(isLabelTotalNum) + Number(tempNotLabTN);
$("#totalNum").html(totalNum);
}
}
//标签工具取消报废移除状态
function cancel(hte_id,htt_name,htt_islabel,htt_id,rownumber){
var scrap=$("input:radio[name=scrap]").filter("[checked]").val();
if(scrap==‘3‘){
scrap=‘报废‘;
}
if(scrap==‘0‘){
scrap=‘移除‘;
}
//左侧按钮改变
$("#labelList tr:eq("+rownumber+")").find("td:eq(4)").html(‘<span class="img_no" title="‘+scrap+‘" onclick="addrow(\‘‘+hte_id+‘\‘,\‘‘+htt_name+‘\‘,\‘‘+htt_islabel+‘\‘,\‘‘+htt_id+‘\‘,\‘‘+rownumber+‘\‘)"/></span>‘);
//右侧数量改变
$("#collectList tr:gt(0)").each(function(){
var labelToolNum = $(this).find("td:eq(3)").html();
var htt_idbak = $(this).find("input[name=htt_id]").val();
if(htt_id==htt_idbak){
labelToolNum=Number(labelToolNum)-1;
if(labelToolNum==0){
//当前tr的同辈元素重置序号
$(this).nextAll().each(function() {
var index = Number($.trim($(this).find("td:eq(0)").html()));
$(this).find("td:eq(0)").html(index-1);
});
$(this).remove();
}else{
$(this).find("td:eq(3)").html(labelToolNum);
}
var totalNum = $("#totalNum").html();//标签和非标签目前添加总数
var isLabTolNum = $("#isLabTolNum").html();//标签目前添加总数
$("#isLabTolNum").html(Number(isLabTolNum)-1);
$("#totalNum").html(Number(totalNum)-1);
}
});
}
//添加非标签工具(子页面操作)
function doAddNotLabel(number,notlabelNum,htt_id,htt_name,statu){
var isExist = 0;
var num=0;
$("#collectList tr:gt(0)").each(function (){
var existHttId = $(this).find("input[name=htt_id]").val();
var statubak = $(this).find("input[name=statu]").val();
if(existHttId == htt_id&&statu==statubak){//添加的非标签类型,如果之前汇总列表已存在
var existNotLabNum = $(this).find("td:eq(3)").html();//找出之前添加的非标签数量值
var addNotLabTotalNum = Number(existNotLabNum) + Number(notlabelNum);
if(Number(addNotLabTotalNum) > Number(number)){
parent.Dialog.alert("添加的非标签工具总数量超过了库存数量!");
num++;
return;
}else{//如果未超过,那么改变原来添加数量
$(this).find("td:eq(3)").html(addNotLabTotalNum);
}
isExist++;
}
});
if(isExist == 0&&num==0){//如果汇总记录不存在,添加一行记录
var nlclIndex = $("#collectList tr").length;
var nlislabelChina = "否"; //是否标签工具
var notLabColTr = [];
notLabColTr.push(‘<tr>‘);
notLabColTr.push(‘<input type="hidden" name="htt_id" value="‘+htt_id+‘" />‘);//工具类型
notLabColTr.push(‘<input type="hidden" name="statu" value="‘+statu+‘" />‘);//库存状态
notLabColTr.push(‘<input type="hidden" name="htt_islabel" value="‘+nlislabelChina+‘" />‘); //是否电子标签
notLabColTr.push(‘<td>‘+nlclIndex+‘</td><td>‘+htt_name+"("+statu+")"+‘</td><td>‘+nlislabelChina+‘</td><td>‘+notlabelNum+‘</td>‘);
notLabColTr.push(‘<td><span class="img_delete hand" title="删除"></span></td>‘);
notLabColTr.push(‘</tr>‘);
$tr = $(notLabColTr.join(""));
addNewRowHandler($tr, nlclIndex);
}
if(num==0){
$("#collectList").render();
var totalNum = $("#totalNum").html();//标签和非标签目前添加总数
var isLabTolNum = $("#isLabTolNum").html();//标签目前添加总数
var notLabTolNum = $("#notLabTolNum").html();//非标签目前添加总数
totalNum=Number(totalNum)+Number(notlabelNum);
$("#totalNum").html(totalNum);
$("#notLabTolNum").html(Number(notLabTolNum)+Number(notlabelNum));
}
}
//删除汇总行标签记录时触发
function delHandler($obj){
$currentTr=$obj.parents("tr");
parent.Dialog.confirm("确定要删除吗?",function(){
//获取删除的非标签或标签记录中数量
var recordLabelNum = $currentTr.find("td:eq(3)").html();
var RFIDNos = $currentTr.find("input[name=RFIDNo]").val();
var isLabel = $currentTr.find("input[name=htt_islabel]").val();
var htt_id = $currentTr.find("input[name=htt_id]").val();
var htt_name = $currentTr.find("td:eq(1)").html();
if(isLabel == ‘1‘){//标签工具
$("#labelList tr:gt(0)").each(function(){//同时也要将左侧的同一工具类型改状态
var pcode=$(this).find("input[name=hte_id]").val();
var rownumber = $(this).find("td:eq(0)").html();
var scrap=$("input:radio[name=scrap]").filter("[checked]").val();
if(scrap==‘3‘){
scrap=‘报废‘;
}
if(scrap==‘0‘){
scrap=‘移除‘;
}
if(RFIDNos.indexOf(pcode) != -1){
$(this).find("td:eq(4)").html(‘<span class="img_no" title="‘+scrap+‘" onclick="addrow(\‘‘+pcode+‘\‘,\‘‘+htt_name+‘\‘,\‘‘+isLabel+‘\‘,\‘‘+htt_id+‘\‘,\‘‘+rownumber+‘\‘)"/></span>‘);
}
});
}
//当前tr的同辈元素重置序号
$currentTr.nextAll().each(function() {
var index = Number($.trim($(this).find("td:eq(0)").html()));
$(this).find("td:eq(0)").html(index-1);
});
$currentTr.remove();
var totalNum = $("#totalNum").html();//标签和非标签目前添加总数
var isLabTolNum = $("#isLabTolNum").html();//标签目前添加总数
var notLabTolNum = $("#notLabTolNum").html();//非标签目前添加总数
if(isLabel == ‘1‘){//标签工具
isLabTolNum = Number(isLabTolNum) - Number(recordLabelNum);
$("#isLabTolNum").html(isLabTolNum);
}else{//非标签工具
notLabTolNum = Number(notLabTolNum) - Number(recordLabelNum);
$("#notLabTolNum").html(notLabTolNum);
}
totalNum = Number(isLabTolNum) + Number(notLabTolNum);
$("#totalNum").html(totalNum);
});
}
//删除左侧记录时触发
function delHandlerleft($obj){
$currentTr=$obj.parents("tr");
parent.Dialog.confirm("确定要删除吗?",function(){
//当前tr的同辈元素重置序号
$currentTr.nextAll().each(function() {
var index = Number($.trim($(this).find("td:eq(0)").html()));
$(this).find("td:eq(0)").html(index-1);
});
$currentTr.remove();
});
}
var isCheck = true;
//读取卡
function startRead() {
var sys_suborgid=$("#sys_suborgid").attr("relValue");
if(sys_suborgid==‘‘||sys_suborgid==null){
parent.Dialog.alert("请先选择操作监区!");
return;
}
var cardReader = window.document.getElementById("cardReader");
var cardNo = cardReader.openReaderCard();
if(cardNo.match(/\d+/g)) { //校验是否为合法
if(cardNo.length != 24) {
$("#tipDiv").html("请勿同时扫描多个电子标签工具!");
return;
}
var isExists = false;
if($("#"+cardNo).length > 0) { //去掉重复
isExists = true;
}
if(!isExists && isCheck) {
isCheck = false;
$("#tipDiv").html(‘‘);
//var param = {hy_stockoperation: hy_stockoperation, hte_ecode: cardNo, sys_suborgid: parent.$(‘#sys_orgid‘).attr("relValue"), htt_id: $("#htt_id").attr(‘relValue‘)};
$.post(‘<%=path%>/busi/toolEntityAction.ered?reqCode=queryOne‘, {hte_ecode: cardNo}, function(data) {
var result = $.parseJSON(data);
analyzeResult(result, cardNo); //分析结果
isCheck = true;
});
}
if(isExists) {
$("#tipDiv").html(‘电子标签为‘+cardNo+"已扫描!");
}
}
}
//分析结果
function analyzeResult(result, cardNo) {
var isValid = false;
var hy_stockoperation = $("#hy_stockoperation").val();
result.sys_suborgid = result.sys_suborgid || ‘‘;
var sys_orgid = result.sys_orgid;
var sys_suborgid=$("#sys_suborgid").attr("relValue");
if(sys_suborgid==‘‘||sys_suborgid==null){//没选监区默认登录监区
sys_suborgid=‘<%=userInfo.getDeptid()%>‘;
}
if(result.hte_statu ==‘0‘){
parent.Dialog.alert("当前扫描的工具未入库!");
return;
}
if(!result.success){
parent.Dialog.alert("当前扫描的标签并未入库,请核对处理!");
return;
}
if(result.sys_suborgid ==‘‘||result.sys_suborgid ==null){
if(sys_orgid != sys_suborgid){
parent.Dialog.alert("当前扫描的工具不是所选监区所有,请及时处理!");
return;
}
}else{
if(result.sys_suborgid != sys_suborgid){
parent.Dialog.alert("当前扫描的工具不是所选分监区所有,请及时处理!");
return;
}
}
if(result.hte_statu ==‘2‘ ){
parent.Dialog.alert("当前扫描的工具还没回收,请回收后再做此操作!");
return;
}
var codenum=0;//用来判断之前有没有选择
$("#collectList tr:gt(0)").each(function(){//查找出之前已扫描添加至标签列表中的电子标签号
var codes = $(this).find("input[name=RFIDNo]").val();
var code=result.hte_id;
if(codes&&codes.indexOf(code)!=-1){//工具类型名一样时才可以放入同一个标签号字符串中
parent.Dialog.alert("当前扫描的工具已在移除列表中!");
codenum++;
return false;
}
});
if(codenum!=0){
return;
}
var checkdisabled = document.getElementById(‘diabled‘);
var checkfree = document.getElementById(‘free‘);
var checkloss = document.getElementById(‘loss‘);
if(!checkdisabled.checked&&result.hte_statu ==‘3‘){
parent.Dialog.alert("当前扫描的工具为报废状态!");
return;
}
if(!checkfree.checked&&result.hte_statu ==‘1‘){
parent.Dialog.alert("当前扫描的工具为在库状态!");
return;
}
if(!checkloss.checked&&result.hte_statu ==‘4‘){
parent.Dialog.alert("当前扫描的工具为报废上缴状态!");
return;
}
if(result.success){
isValid = true;
}
if(hy_stockoperation != ‘2‘ ) {
if(!result.success) {
$("#tipDiv").html("未查询到电子标签为"+cardNo+"的工具!");
}else if(isValid) {
var llIndex = $("#labelList tr").length;//标签列表行数
var labelMsg = ‘‘;
if(result.sys_suborgid != null && result.sys_suborgid != ‘‘){
labelMsg = result.sys_suborgname;
}else{
labelMsg = result.sys_orgname;
}
labelMsg += " "+result.htt_name+" "+result.hte_pcode+" "+TOOLSTATUSRender(result.hte_statu)+" "+cardNo;
$("#tipDiv").html(labelMsg);
var htt_isfixed=‘‘;
if(result.htt_isfixed==‘1‘){
htt_isfixed="固定";
}else{
htt_isfixed="临时";
}
var $tr = $(‘<tr id="‘+cardNo+‘"><input type="hidden" name="htt_name" value="‘+result.htt_name+‘"/><input type="hidden" name="hte_id" value="‘+result.hte_id+‘"/><td>‘+llIndex+‘</td><td>‘+result.hte_pcode+‘</td><td>‘+htt_isfixed+‘</td><td>‘+TOOLSTATUSRender(result.hte_statu)+‘</td><td><a href="javascript:;"><span class="img_delete"></span></a></td></tr>‘);
var $delBtn = $tr.find(".img_delete");
$delBtn.click(function(){
delHandlerleft($(this));
});
$("#labelList").append($tr);
$("#labelList tr:last").focus();
var hsl_toolnumber = 1;//数量
var code=result.hte_id;//code字符串
$("#collectList tr:gt(0)").each(function(){//查找出之前已扫描添加至标签列表中的电子标签号
var codes = $(this).find("input[name=RFIDNo]").val();
var id = $(this).find("input[name=htt_id]").val();
if(id == result.htt_id){//工具类型名一样时才可以放入同一个标签号字符串中
hsl_toolnumber += Number($(this).find("td:eq(3)").html());
code+=","+codes;
}
});
var colIdMap = new Map();
var existRowNum = 0;
//查找已添加至汇总列表中的工具类型Id,存放在idMap中
$("#collectList tr:gt(0)").each(function(){
var htt_id = $(this).find("input[name=htt_id]").val();
colIdMap.put(htt_id, htt_id);
if(htt_id == result.htt_id){//如果扫描来的类型ID与之前的类型ID相等,那么就应该将记录行号
existRowNum = colIdMap.size();
}
});
var clIndex = $("#collectList tr").length;//汇总列表行数
var htt_name = result.htt_name;//工具类型名
//var htt_islabelChina = ISFLAGRender(result.htt_islabel); //是否标签工具
if(!colIdMap.get(result.htt_id)){//如果类型不在汇总列表中,重新添加一行汇总记录
var colTr = [];
colTr.push(‘<tr>‘);
colTr.push(‘<input type="hidden" name="htt_id" value="‘+result.htt_id+‘" />‘);//工具类型
colTr.push(‘<input type="hidden" name="htt_islabel" value="‘+result.htt_islabel+‘" />‘); //是否电子标签
colTr.push(‘<input type="hidden" name="RFIDNo" value="‘+code+‘" />‘);//电子标签号字符串
colTr.push(‘<td>‘+clIndex+‘</td><td>‘+htt_name+‘</td><td>是</td><td>‘+hsl_toolnumber+‘</td>‘);
colTr.push(‘<td><span class="img_delete hand" title="删除"></span></td>‘);
colTr.push(‘</tr>‘);
$tr = $(colTr.join(""));
addNewRowHandler($tr, clIndex);
}else{//如果类型已在汇总列表中,那么在原来行记录中改变发 放数量和电子标签号字符串内容
$("#collectList tr:eq("+existRowNum+")").find("input[name=RFIDNo]").val(code);
$("#collectList tr:eq("+existRowNum+")").find("td:eq(3)").html(hsl_toolnumber);
$("#collectList").render(); //重新渲染表格
}
isLabelTotalNum = 0;
$("#collectList tr:gt(0)").each(function(){
var existLabel = $(this).find("input[name=htt_islabel]").val();//1=电子标签,0=否电子标签
if(existLabel == ‘1‘){
var labelToolNum = $(this).find("td:eq(3)").html();
isLabelTotalNum = Number(labelToolNum) + Number(isLabelTotalNum);
}
});
$("#isLabTolNum").html(isLabelTotalNum);
var tempNotLabTN = $("#notLabTolNum").html();
totalNum = Number(isLabelTotalNum) + Number(tempNotLabTN);
$("#totalNum").html(totalNum);
}else{
var errMsg = ‘‘;
if(result.sys_suborgid != null && result.sys_suborgid != ‘‘){
errMsg = result.sys_suborgname;
}else{
errMsg = result.sys_orgname;
}
errMsg += " "+result.htt_name+" "+result.hte_pcode+" "+TOOLSTATUSRender(result.hte_statu)+" "+cardNo;
$("#tipDiv").html(errMsg);
}
}
}
//添加行处理
function addNewRowHandler($tr, index){
var $delBtn=$tr.find(".img_delete");
$delBtn.click(function(){
delHandler($(this))
});
$("#collectList").append($tr);
$("#collectList").render(); //重新渲染表格
}
//确认报废移除
function doOkAllocate(){
var jsonArray = [];
$("#collectList tr:gt(0)").each(function() {
var htt_id = $(this).find("input[name=htt_id]").val();
var htt_islabel = $(this).find("input[name=htt_islabel]").val();
var RFIDNo = $(this).find("input[name=RFIDNo]").val();
var hsl_toolnumber = $.trim($(this).find("td:eq(3)").html());
if(htt_islabel=="0"){
jsonArray.push(‘{"htt_id":"‘+htt_id+‘","hsl_toolnumber":"‘+hsl_toolnumber+‘","htt_islabel":"‘+htt_islabel+‘","RFIDNo":"‘+RFIDNo+‘"}‘);
}else{
var statu = $(this).find("input[name=statu]").val();
jsonArray.push(‘{"htt_id":"‘+htt_id+‘","statu":"‘+statu+‘","hsl_toolnumber":"‘+hsl_toolnumber+‘","htt_islabel":"‘+htt_islabel+‘","RFIDNo":"‘+RFIDNo+‘"}‘);
}
});
if(jsonArray.length == 0) {
parent.Dialog.alert("无保存数据!",null,null,null,5);
return;
}
$("#dirtydata").val(‘[‘ + jsonArray.join(",") + ‘]‘);
$("#allocateForm").ajaxSubmit({
//表单提交成功后的回调
success: function(responseText, statusText, xhr, $form){
var result = $.parseJSON(responseText);
if(result.success) {
toEmptyData();
parent.Dialog.alert(result.msg,null,null,null,5);
start();
sureDialog.close();
}else {
parent.Dialog.alert(result.msg,null,null,null,6);
}
}
});
}
var sureDialog;
//确认
function onSure() {
stop();
var jsonArray = [];
$("#collectList tr:gt(0)").each(function() {
var htt_id = $(this).find("input[name=htt_id]").val();
var htt_islabel = $(this).find("input[name=htt_islabel]").val();
var RFIDNo = $(this).find("input[name=RFIDNo]").val();
var hsl_toolnumber = $.trim($(this).find("td:eq(3)").html());
if(htt_islabel=="0"){
jsonArray.push(‘{"htt_id":"‘+htt_id+‘","hsl_toolnumber":"‘+hsl_toolnumber+‘","htt_islabel":"‘+htt_islabel+‘","RFIDNo":"‘+RFIDNo+‘"}‘);
}else{
var statu = $(this).find("input[name=statu]").val();
jsonArray.push(‘{"htt_id":"‘+htt_id+‘","statu":"‘+statu+‘","hsl_toolnumber":"‘+hsl_toolnumber+‘","htt_islabel":"‘+htt_islabel+‘","RFIDNo":"‘+RFIDNo+‘"}‘);
}
});
if(jsonArray.length == 0) {
parent.Dialog.alert("无保存数据!",null,null,null,5);
return;
}
sureDialog = new parent.Dialog();
sureDialog.URL = ‘/busi/commonAction.ered?reqCode=onSure&hy_stockoperation=5‘;
sureDialog.Title = "确认";
sureDialog.Width = 550;
sureDialog.Height = 480;
sureDialog.OkButtonText = "保存";
sureDialog.OKEvent = doOkAllocate;
sureDialog.CancelEvent = function() {
start();
sureDialog.close();
};
sureDialog.show();
}
//清空数据
function doEmptyData(){
if($("#collectList tr").length > 1){
parent.Dialog.confirm("当前界面存在未确认报废移除的数据,是否确认清空?",function(){
toEmptyData();
});
}else{
parent.Dialog.alert("报废移除列表没有需要清空的数据!");
}
}
function toEmptyData(){
$("#totalNum,#isLabTolNum,#notLabTolNum").html(0);
$("#labelList tr:gt(0)").remove();
$("#labelList").render();
$("#collectList tr:gt(0)").remove();
$("#collectList").render();
}
function doClose(){
if($("#collectList tr").length > 1){
parent.Dialog.confirm("当前界面存在报废移除数据,是否确认关闭当前界面?", function(){
closeCardReader();
top.toolDialog.close();
});
}else{
closeCardReader();
top.toolDialog.close();
}
}
//开始
function scanstart() {
$("#scan").attr("checked",true);//下拉框选择后自动切换成手动添加
$("#labelList tr:gt(0)").remove();
$("#labelList").render();
$("#btn_start").hide();
$("#btn_stop").show();
intervalId = setInterval(startRead, iMilliSeconds);
}
</script>
<script language="javascript" for="cardReader" event="OnRecvMsg(msg)">
//document.getElementById("divLog").innerHTML += msg;
</script>
<script type="text/javascript" src="/busi/tool/common/common.js"></script>
</body>
</html>