恩 不错不错 真的是一点一点写出来的,good ! //------------------------设置fields,及fields所属类型------------------------------ headField=[ {name:"recId",title:"主键",primaryKey:true}, {name:"refId",title:"单号",canEdit:true}, {name:"pickListNum",title:"领料预算表"}, {name:"createdBy",title:"创建人"}, {name:"createdDate",title:"创建日期"} ]; lineField=[ {name:"recId", title:"主键",primaryKey:true,width:150}, {name:"exFactoryNo", title:"出场单号",width:150}, {name:"itemId",title:"物料编号",width:150}, {name:"inputQty",title:"总数量",width:150}, {name:"inputUnit",title:"单位",width:150}, {name:"inputWeight",title:"总重量",width:150}, {name:"levelQty",title:"对淮数",width:150}, {name:"containerType",title:"箱类型",width:150}, {name:"containerQty",title:"箱数量",width:150}, {name:"mouldId",title:"洋行模号",width:150}, {name:"mouldRefNum",title:"模厂模号",width:150}, {name:"mouldVersion",title:"模版本",width:150}, {name:"frmWarehouse",title:"由仓库",width:150}, {name:"frmLocation",title:"由位置",width:150}, {name:"toWarehouse",title:"至仓库",width:150}, {name:"toLocation",title:"至位置",width:150}, {name:"frmProjId",title:"由项目",width:150}, {name:"frmSKU",title:"由SKU",width:150}, {name:"frmBatchId",title:"由批号",width:150}, {name:"toProjId",title:"至项目",width:150}, {name:"toSKU",title:"至SKU",width:150}, {name:"toBatchId",title:"至批号",width:150}, {name:"pickListNum",title:"领料预算表",width:150}, {name:"remarks",title:"备注",width:150} ]; //--------------------------------数据源------------------------------------------------------------ isc.DataSource.create({ ID:"HeadData", dataFormat:"json", recordXPath:"data", fields:headField, operationBindings:[ {operationType:"fetch", dataURL:"BarCode/findAllBarcodeHead.action" }, {operationType:"remove",dataURL:"BarCode/deleteBarcodeHead.action"}, {operationType:"update",dataURL:"BarCode/UpdateBarcodeHead.action"} ] }); isc.DataSource.create({ ID:"lineData", dataFormat:"json", recordXPath:"data", fields:lineField, operationBindings:[ // {operationType:"fetch", dataURL:"BarCode/findAllBarcodeLine.action" }, {operationType:"fetch",dataURL:"BarCode/findByFKRecId.action"}, // {operationType:"add", dataURL:"TreeAndList/saveInfo.action"}, {operationType:"update", dataURL:"BarCode/updateBarcodeLine.action" }, {operationType:"remove", dataURL:"BarCode/deleteByRecId.action" } ] }); isc.ListGrid.create({ ID:"BarcodeHead", width:950, showRowNumbers:true, recordClick:"this.findItems(this.getSelectedRecord().recId)", height:155, //autoFetchData:true, fields:headField, dataSource:"HeadData", //数据来源 alternateRecordStyles:true, findItems : function (recId) { var findValues; //var recId = BarcodeHead.getSelectedRecord().recId; //isc.say('recId--->'+recId); findValues = {PickListTableRecId:recId}; //設置PickListTableRecId值為recId的值 LineList.filterData(findValues); //like fechData function } }); isc.ListGrid.create({ ID: "LineList", height:320, showRowNumbers:true, dataSource:"lineData", //recordClick:"isc.say('您单击listgrid一次')", // autoFetchData: true,//自动获取数据 canEdit: true, //可编辑grid autoSaveEdits: true, //自动保存所编辑的内容 fields:lineField, //对应的字段 alternateRecordStyles:true, canEdit:true }); //*************************************条码输入框及事件处理********************************************************* isc.SearchForm.create({ ID:"findForm", left:20, autoFocus:true,//设置自动获取光标 width:"120", fields:[{name: "barcode", type:"text", title:"barcode",width:250,height:25}], itemKeyPress:function(item,keyName,characterName){ var itemName=this.getItems()[0].getFieldName(); var barcode = this.getItems()[0].getValue(); // 获取输入文本框中的值 var focusNode = this; var itemObj=this.getItem(itemName); if((barcode !== null) && (keyName == 'Enter')){ //如果条码不为空 and 单击回车键 RPCManager.sendRequest({ paramsOnly:true, //actionURL: "BarCode/insertBarcode.action", //增加条码 actionURL:"Barcode/IsHavePickListNum.action",//检查条码 params:{inputbarcode:barcode}, callback:function(data) {focusNode.myCallBack(data);} }); } }, myCallBack:function(data) { var focusNode = this; var msg=data.data.split(",")[0].split(":")[1]; var boo = data.data.split(",")[2].split(":")[1]; var barcode = data.data.split(",")[3].split(":")[1]; var pickListNum = data.data.split(",")[1].split(":")[1]; var line = "barcodeline"; var head = "barcodehead"; console.log(data.data); if(barcode.contains(head)){ if(boo){ console.log(pickListNum); isc.ask("温馨提示:" + msg+"领料预算表:"+pickListNum,focusNode.addBarcodeHead); }else{ isc.ask("记录不存在 可以添加"+msg,focusNode.addBarcodeHead); }//BarcodeHead.clearCriteria();//清除过滤器中的数据 }else if (barcode.contains(line)){ /*var recId = data.data.split(",")[2].split(":")[1].substring(0,2); console.log("recId is --->"+recId); var FKRecId = { PickListTableRecId:recId }; LineList.filterData(FKRecId); isc.say("温馨提示:" + msg ); */ if(boo){ var itemId = data.data.split(",")[4].split(":")[1]; isc.ask("溫馨提示:"+msg+"領料預算表:"+pickListNum+"物料編號:"+itemId,focusNode.addBarcodeHead); }else{ focusNode.addBarcodeHead(); } }else{ isc.say("温馨提示 :" + msg ); } //this.getFields()[0].setValue()=" "; //清空条码框 }, addBarcodeHead:function(value){ if(value){ var focusNode = this; var bar = findForm.getField("barcode").getValue(); //findForm.getField("barcode").setValue()=""; console.log(bar); RPCManager.sendRequest({ paramsOnly:true, actionURL:"BarCode/insertBarcode.action", params:{inputbarcode:bar}, callback:function(data){ var msg = data.data.split(",")[0].split(":")[1]; var barcode = data.data.split(",")[0].split(":")[1]; var line = "barcodeline"; var head = "barcodehead"; if(barcode.contains(head)){ BarcodeHead.filterData(); isc.say("温馨提示"+msg); }else if (barcode.contains(line)){ var recId = data.data.split(",")[2].split(":")[1].substring(0,2); console.log("recId is --->"+recId); var FKRecId = { PickListTableRecId:recId }; LineList.filterData(FKRecId); isc.say("温馨提示:" + msg ); }else{ isc.say("温馨提示:"+msg); } } }) }else{ isc.say("您取消添加单头"); } findForm.getFields()[0].setValue()=" "; //清空条码框 } }) //******************************************单头事件按钮*************************************************************** isc.HLayout.create({ ID:"buttonLayout", width:"100%", height:1, membersMargin: 30, members: [ isc.IButton.create({ ID: "upload", width:"120", height:25, title: "上 载", click:function(){ var focusNode=this; if((!BarcodeHead.getSelectedRecord())){ isc.say("请选择上载记录"); }else{ var refId = BarcodeHead.getSelectedRecords()[0].refId; isc.ask("确定上载领料单号:"+refId+"吗?",focusNode.myCallBack); } }, myCallBack:function(value) { var recId = BarcodeHead.getSelectedRecord().recId; // 获取当前选中的主键 if(value){ RPCManager.sendRequest({ paramsOnly:true, actionURL: "Barcode/uploadppcPickList.action", params:{a:recId}, callback:function(data) { var msg=data.data.split(",")[0].split(":")[1]; var recId = data.data.split(",")[2].split(":")[1].substring(0,2); BarcodeHead.filterData();//自动刷新领料单行数据 var FKRecId = { PickListTableRecId:recId }; LineList.filterData(FKRecId); //上载成功后自动刷新数据 alert("温馨提示:" + msg); } }); }else{}; } }), isc.IButton.create({ ID: "print", width:"120", height:25, title: "列 印", click: "BarcodeHead.addSummaryField();" }), isc.IButton.create({ ID:"delete", width:"120", height:25, title:"删 除", click:function(){ var focusNode = this; if((!BarcodeHead.getSelectedRecord())){ isc.say('请选择要删除的记录'); }else{ var table = BarcodeHead.getSelectedRecords()[0].pickListNum; isc.ask("确认删除领料预算表:"+table+"吗?",focusNode.Mycallback); //对是否做出相应的处理 } }, Mycallback: function(value){ console.log(value); if(value){ BarcodeHead.removeSelectedData(); isc.say('删除成功!'); }else if(value=="" || value == null){ }else{ isc.say('删除失败,请重新操作!'); } } }), isc.IButton.create({ ID: "updateClumn", width:"120", height:25, title: " 更 新 栏 位", click: function () { var focusNode = this; if((!BarcodeHead.getSelectedRecord())){ isc.say('请选择要更新的栏位'); }else{ isc.askForValue("请输入要修改的单号",focusNode.updateInfo); } }, updateInfo:function(value){ if(value){ var Id = BarcodeHead.getSelectedRecords()[0].recId; var focus = this; RPCManager.sendRequest({ paramsOnly:true, actionURL: "BarCode/UpdateBarcodeHead.action", params:{refId:value,recId:Id}, callback:function(data){ var msg=data.data.split(",")[0].split(":")[1]; BarcodeHead.filterData(); isc.say(msg);} }); }else if(value ==null || value ==""){} } }) ] }); //******************************************单行事件按钮*************************************************************** isc.HLayout.create({ ID:"buttonLayout2", width:"100%", height:10, membersMargin: 20, members: [ isc.IButton.create({ ID:"delete2", width:"120", height:25, title:"删除信息", click:function(){ if(!LineList.getSelectedRecord()){ isc.say('请选择要删除的记录'); }else{ var itemId = LineList.getSelectedRecords()[0].itemId; isc.ask('确认删除物料编号:'+itemId+'?',this.deleteLine); } }, deleteLine:function(value){ if(value){ LineList.removeSelectedData(); isc.say("删除成功!"); }else if(value == "" || value== null){ }else{ isc.say('删除失败,请重新操作!'); } } }), isc.IButton.create({ ID: "updateClumn2", width:"120", height:25, title: "更新栏位", click:function(){ if(!LineList.getSelectedRecord()){ isc.say('请选择要更新的栏位'); }else{ updatelinewin.show() } } }) ] }); //********************************************系统首界面布局************************************************************* isc.DataView.create({ ID:"barcodeLayout", autoDraw: true, overflow: "hidden", width: "100%", height: "100%", members: [ isc.HLayout.create({ membersMargin: 5, padding:5, vertical:"true", members: [ isc.VLayout.create({ ID:"barcode", padding:10, height:20, membersMargin:10, isGroup:true, members:[findForm], groupTitle:"请输入条码" }), isc.VLayout.create({ ID:"barcodeHead", padding:10, membersMargin: 5, members: [BarcodeHead,buttonLayout], isGroup:true, height:200, groupTitle:"领料单头" }), isc.VLayout.create({ ID: "barcodeLine", padding:10, membersMargin: 5, overflow: "auto", members: [LineList,buttonLayout2], isGroup:true, groupTitle:"领料单行" })] }) ] }); BarcodeHead.fetchData();