1. 程式人生 > >關於樹形彈出框選擇JS和sql的記錄

關於樹形彈出框選擇JS和sql的記錄

主頁面事件(資料接收事件)

Model.prototype.windowDialog2Receive = function(event){


//var TE_ProjectInfo = this.comp("TE_ProjectInfo");
//宣告data
var mainData = this.comp("mainData");
var detailData = this.comp("detailData");

var params = new biz.Request.ActionParam();
params.setString("sIDs", event.data);
params.setString("currID",mainData.getCurrentRowID());
// 呼叫動作
var me = this;
biz.Request.sendBizRequest({
"context" : this.getContext(),
"action" : "Insertselectmaterialinformation",
"parameters" : params,
"callback" : function(data) {
// data.ignoreError 是否忽略預設的異常處理,預設值true
data.ignoreError = false;
// data.state 請求返回狀態,標識請求是否執行成功
if (data.state) {
debugger;
mainData.saveData();
detailData.refreshData();
}
}
});
};

彈出框確定事件(選中的傳到主頁面)

Model.prototype.result = function(){
//實現返回的邏輯
var dialogData = this.comp("dialogData");
var grid1 = this.comp("grid1");
var sIDs = grid1.getCheckeds();

for(var i=0;i<sIDs.length;i++){
var parent = dialogData.getValueByID("fParent",sIDs[i]);
if(parent){
grid1.setRowChecked(parent,true);
}
}
var sIDs = grid1.getCheckeds();
debugger;
return sIDs;
};
Model.prototype.OKBtnClick = function(event){
this.comp('wReceiver').windowEnsure(this.result());
};

sql語句實現

public static void Insertselectmaterialinformation(String currID,String sIDs){


System.out.println(sIDs);
String uuid = CommonUtils.createGUID();
String strKsql = "select m,m.fParent as fParent,m.fMaterialType as fMaterialType,m.fNodeKind as fNodeKind,m.fTypeCode as fTypeCode from MaterCodeTable m where m in ('"+sIDs.replaceAll(",","','")+"')";


System.out.println(strKsql);
Table table = KSQL.select(strKsql, null, "/SceneTeam/ClassDoor/data", null);
Iterator<Row> rows = table.iterator();
while (rows.hasNext()) {
Row row = rows.next();
String m = row.getString("m");
String fParent = row.getString("fParent");
String fMaterialType = row.getString("fMaterialType");
String fNodeKind = row.getString("fNodeKind");
String fTypeCode = row.getString("fTypeCode");


String isExist = "select m from MasterList m where m.fZBID='"+currID+"' and m like '%"+m+"%'";
Table t = KSQL.select(isExist, null, "/SceneTeam/ClassDoor/data", null);
Iterator<Row> tRow = t.iterator();


if(tRow.hasNext()){
Row r = tRow.next();
String fid = r.getString("m");
uuid = fid.substring(0, 32);
}else{
String inKsql = "";
if("".equals(fNodeKind) || fNodeKind=="" ||fNodeKind==null|| fNodeKind=="null"){
if("".equals(fParent) || fParent=="" || fParent==null || fParent =="null"){
inKsql = "insert into MasterList t (t,t.version,t.fMaterialType,t.fParent,t.fNodeKind,t.fTypeCode,t.fZBID,t.fListType) values('"+uuid+m+"',0,'"+fMaterialType+"','','"+fNodeKind+"','"+fTypeCode+"','"+currID+"','物資發放')";
}else{
inKsql = "insert into MasterList t (t,t.version,t.fMaterialType,t.fParent,t.fNodeKind,t.fTypeCode,t.fZBID,t.fListType) values('"+uuid+m+"',0,'"+fMaterialType+"','"+uuid+fParent+"','"+fNodeKind+"','"+fTypeCode+"','"+currID+"','物資發放')";
}
}else{
if("".equals(fParent) || fParent=="" || fParent==null || fParent =="null"){
inKsql = "insert into MasterList t (t,t.version,tfMaterName,t.fParent,t.fNodeKind,t.fTypeCode,t.fZBID,t.fListType) values('"+uuid+m+"',0,'"+fMaterialType+"','','"+fNodeKind+"','"+fTypeCode+"','"+currID+"','物資發放')";
}else{
inKsql = "insert into MasterList t (t,t.version,t.fMaterName,t.fParent,t.fNodeKind,t.fTypeCode,t.fZBID,t.fListType) values('"+uuid+m+"',0,'"+fMaterialType+"','"+uuid+fParent+"','"+fNodeKind+"','"+fTypeCode+"','"+currID+"','物資發放')";
}
}
System.out.println(inKsql);
KSQL.executeUpdate(inKsql, null, "/SceneTeam/ClassDoor/data", null);


}
}
}
}