";
$("#baseTable tbody").append(html);
$("#pageing ul").empty();// 清空分页
}
JY.Model.loadingClose();
});
}
var i=1;
var idd='';
var results = new Array();
function addNewTable(id,dd){
JY.Ajax.doRequest(null, bonuspath + '/disassembly/getListDataById', {
id:id,
}, function(data) {
var da=data.obj;
var id=da.id+",";
idd=idd+","+id+",";
results.push(da);
var len=results.length-1;
results[len].ids=i;
results[len].typeName=null;
results[len].typeNameId=null;
results[len].typeId=null;
results[len].type=null;
results[len].type=null;
results[len].originNum=null;
i=i+1;
//第二次添加
console.log(results);
getNewDataTable(results);
});
}
//添加表数据信息
function getNewDataTable(results){
$("#newBaseTable tbody").empty();
var html = "";
if (results != null && results.length > 0) {
for (var i = 0; i < results.length; i++) {
var l = results[i];
html += "
";
html += "
"
+ (i + 1) + "
";
//
html += "
"+ JY.Object.notEmpty(l.companyName) + "
";
var typeName= l.typeName;
var typeNameId=l.typeNameId;
if(typeName==null){
typeName='';
}
if(typeNameId==null){
typeNameId='';
}
html += "
" +
""
+""
+"
";
var type= l.type;
if(type==null){
type='';
}
var typeId= l.typeId;
if(typeId==null){
typeId='';
}
html += "
" +
"" +
"" +
"
";
html += "
"+ JY.Object.notEmpty(l.deviceCode) + "
";
var originNum= l.originNum;
if(originNum==null){
originNum='';
}
html += "
";
html += "
在库
";
html+= "
";
html += "
";
html += "";
html += "
";
html += "
";
html += "
";
}
$("#newBaseTable tbody").append(html);
} else {
html += "
没有相关数据
";
$("#newBaseTable tbody").append(html);
}
}
function deleteData(ids){
for (var i = 0; i < results.length; i++) {
var l = results[i];
var idd=l.ids;
if(ids==idd){
results.splice(i,1);
break;
}
}
getNewDataTable(results);
}
//shuju
function inputOnBlur(ids){
var typeName1=$("#typeName"+ids).val();
var type1=$("#type"+ids).val();
if(typeName1==null || typeName1=='' ||type1==null || type1=='' ){
$("#inNums"+ids).val('');
JY.Model.info("请先选择机具设备及规格");
return false;
}
var deviceCode=$("#inNums"+ids).val();
var b=false;
for (var i = 0; i < results.length; i++) {
var l = results[i];
var typeName=l.typeName;
var type=l.type;
var idd=l.ids;
var originNum=l.originNum;
if(ids==idd){
//设备编码校验 唯一性
$.ajax({
url: bonuspath + '/disassembly/getListDataByDeviceCode',
data:{
type : type,
deviceCode:deviceCode,
typeName:typeName
},
type:'post',
dataType:'json',
async:false,
success:function(data){
if(data.obj==1){
$("#inNums"+ids).val('');
b=true;
}else{
l.originNum=deviceCode;//新数据赋值
}
}
})
}else{
if(typeName1==typeName && type==type1 && ids!=idd && originNum==deviceCode){
$("#inNums"+ids).val('');
b=true;
}
}
if(b){
break;
}
}
if(b){
JY.Model.info(deviceCode+"设备编码重复!");
return;
}
}
//数据校验
function saveNewData(){
var isreturn=false;
if(results.length<1){
return;
}
for (var i = 0; i < results.length; i++) {
var l = results[i];
var originNum=l.originNum;
if(originNum=='' || originNum==null){
isreturn=true;
break;
}
}
if(isreturn){
JY.Model.info("请填写设备编码或删除无用数据");
return;
}
//数据校验重复性
var isall=false;
var originNum;
var newDeviceCode;
var isFalse=false;
for (var i = 0; i < results.length; i++) {
var l = results[i];
var typeName=l.typeName;
var type=l.type;
var idd=l.ids;
originNum=l.originNum;
$.ajax({
url: bonuspath + '/disassembly/getListDataByDeviceCode',
data:{
type : type,
deviceCode:originNum,
typeName:typeName
},
type:'post',
dataType:'json',
async:false,
success:function(data){
if(data.obj==1){
newDeviceCode=originNum;
isall=true;
}
}
})
if(isall){
break;
}
for (var j = 0; j < results.length; j++) {
var ll = results[j];
var typeName1=ll.typeName;
var deviceCode=ll.originNum;
newDeviceCode=originNum;
var type1=ll.type;
var ids=ll.ids;
if(typeName1==typeName && type==type1 && ids!=idd && originNum==deviceCode){
newDeviceCode=deviceCode;
isFalse=true;
break;
}
}
}
if(isFalse){
JY.Model.info(newDeviceCode+"设备编码重复!");
return ;
}
if(isall){
JY.Model.info(newDeviceCode+"设备编码重复!");
return ;
}
var array=new Array();
for (var i = 0; i < results.length; i++) {
var l = results[i];
var id=l.id;
var originNum=l.originNum;
var typeId=l.typeId;
var ids=id+"_"+originNum+"_"+typeId;
array.push(ids);
}
var da=array.join("@");
JY.Model.loading();
//数据后台处理
JY.Ajax.doRequest(null, bonuspath + '/disassembly/insertDatasplit', {
id : da,
}, function(data) {
JY.Model.info(data.obj);
getbaseList();
getNewDataTable(null);
results = new Array();
JY.Model.loadingClose();
});
}
//树
var isOpen=false;
var isOpen2=false;
var isOpen3=false;
//规格
function typeChange(ids){
if(isOpen){
return false;
}
localStorage.setItem("disIds",ids);
var maTypeId = $("#typeNameId"+ids).val();
if(maTypeId=='' || maTypeId==null ){
JY.Model.info("请选择机具类型!");
}else{
localStorage.setItem("maModelId","");
localStorage.setItem("maModelName","");
localStorage.setItem("maModelTreeName",$("#maModelName").val());
localStorage.setItem("maTypeTreeId",maTypeId);
isOpen=true;
layer.open({
type: 2,
title:['规格型号','background-color: #438EB9;color:#fff'],
shadeClose:true,
shade:false,
maxmin: true,
area: ['400px', '400px'],
content: bonuspath+'/backstage/machineType/maModelTree2',
cancel: function(){
// 右上角关闭事件的逻辑
isOpen=false;
}
});
}
}
//记录查询
function history(){
if(isOpen3){
return false;
}
localStorage.setItem("flowType","1");
layer.open({
type: 2,
title:['拆分记录','background-color: #438EB9;color:#fff'],
shadeClose:true,
shade:false,
maxmin: true,
area: ['1200px', '750px'],
content: bonuspath+'/disassembly/historyFlow',
cancel: function(){
// 右上角关闭事件的逻辑
isOpen3=false;
}
});
}
//名称
function typeNameChange(ids){
if(isOpen2){
return false;
}
localStorage.setItem("disIds",ids);
localStorage.setItem("maTypeId","");
localStorage.setItem("maTypeName","");
isOpen2=true;
layer.open({
type: 2,
title:['机具类型','background-color: #438EB9;color:#fff'],
shadeClose:true,
shade:false,
maxmin: true,
area: ['400px', '400px'],
content: bonuspath+'/backstage/machineType/maTypeTree2',
cancel: function(){
// 右上角关闭事件的逻辑
isOpen2=false;
}
});
}
//机具名称
function setMaTypeForm(id,name){
var ids=localStorage.getItem("disIds");
$("#typeName"+ids).val(name);
$("#typeNameId"+ids).val(id);
$("#type"+ids).val('');
$("#typeId"+ids).val('');
isOpen2=false;
for (var i = 0; i < results.length; i++) {
var l = results[i];
var idd=l.ids;
if(ids==idd){
l.typeName=name;//新数据赋值
l.typeNameId=id;
l.type=null;//新数据赋值
l.typeId=null;
}
}
}
//规格
function setMaModelForm(id,name){
var ids=localStorage.getItem("disIds");
$("#type"+ids).val(name);
$("#typeId"+ids).val(id);
isOpen=false;
for (var i = 0; i < results.length; i++) {
var l = results[i];
var idd=l.ids;
if(ids==idd){
l.type=name;//新数据赋值
l.typeId=id;
}
}
}