提交 868233ce 编写于 作者: 蔡祥熠

Merge branch 'feature/Process.datagrid_addable_deleteable' into 'develop'

Merge of feature/Process.datagrid_addable_deleteable to develop

See merge request o2oa/o2oa!1388
...@@ -28,11 +28,11 @@ ...@@ -28,11 +28,11 @@
<td class="editTableValue"><input type="color" name="zebraColor" value="text{$.zebraColor}" class="editTableInput"/></td> <td class="editTableValue"><input type="color" name="zebraColor" value="text{$.zebraColor}" class="editTableInput"/></td>
</tr> </tr>
<!--<tr>--> <!--<tr>-->
<!--<td class="editTableTitle">序号:</td>--> <!--<td class="editTableTitle">序号:</td>-->
<!--<td class="editTableValue">--> <!--<td class="editTableValue">-->
<!--<input type="radio" name="sequence" value="yes" text{($.sequence=='yes')?'checked':''}/>显示--> <!--<input type="radio" name="sequence" value="yes" text{($.sequence=='yes')?'checked':''}/>显示-->
<!--<input type="radio" name="sequence" value="no" text{($.sequence=='no')?'checked':''}/>不显示--> <!--<input type="radio" name="sequence" value="no" text{($.sequence=='no')?'checked':''}/>不显示-->
<!--</td>--> <!--</td>-->
<!--</tr>--> <!--</tr>-->
</table> </table>
...@@ -41,6 +41,23 @@ ...@@ -41,6 +41,23 @@
<div class="MWFMaplist" name="properties" collapse="true" title="属性"></div> <div class="MWFMaplist" name="properties" collapse="true" title="属性"></div>
<div class="MWFScriptArea" name="defaultData" title="默认数据(S)"></div> <div class="MWFScriptArea" name="defaultData" title="默认数据(S)"></div>
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
<tr>
<td class="editTableTitle">允许删除:</td>
<td class="editTableValue">
<input type="radio" name="deleteable" value="yes" text{($.deleteable!=='no')?'checked':''}/>
<input type="radio" name="deleteable" value="no" text{($.deleteable==='no')?'checked':''}/>
</td>
</tr>
<tr>
<td class="editTableTitle">允许添加:</td>
<td class="editTableValue">
<input type="radio" name="addable" value="yes" text{($.addable!=='no')?'checked':''}/>
<input type="radio" name="addable" value="no" text{($.addable==='no')?'checked':''}/>
</td>
</tr>
</table>
<div class="MWFScriptArea" name="editableScript" title="是否可编辑(S)"></div> <div class="MWFScriptArea" name="editableScript" title="是否可编辑(S)"></div>
<div class="MWFValidation" name="validationConfig"></div> <div class="MWFValidation" name="validationConfig"></div>
......
MWF.xDesktop.requireApp("process.Xform", "$Module", null, false); MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
MWF.xApplication.process.Xform.DatagridMobile = new Class({ MWF.xApplication.process.Xform.DatagridMobile = new Class({
Implements: [Events], Implements: [Events],
Extends: MWF.APP$Module, Extends: MWF.APP$Module,
isEdit: false, isEdit: false,
options: { options: {
"moduleEvents": ["queryLoad","postLoad","load","completeLineEdit", "addLine", "deleteLine", "afterDeleteLine","editLine"] "moduleEvents": ["queryLoad","postLoad","load","completeLineEdit", "addLine", "deleteLine", "afterDeleteLine","editLine"]
}, },
...@@ -15,13 +15,13 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -15,13 +15,13 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
this.field = true; this.field = true;
}, },
_loadUserInterface: function(){ _loadUserInterface: function(){
this.fireEvent("queryLoad"); this.fireEvent("queryLoad");
this.editModules = []; this.editModules = [];
this.node.setStyle("overflow-x", "hidden"); this.node.setStyle("overflow-x", "hidden");
this.node.setStyle("overflow-y", "hidden"); this.node.setStyle("overflow-y", "hidden");
this.table = this.node.getElement("table"); this.table = this.node.getElement("table");
this.createMobileTable(); this.createMobileTable();
...@@ -29,25 +29,28 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -29,25 +29,28 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
if (this.editable) this.editable = this.form.Macro.exec(((this.json.editableScript) ? this.json.editableScript.code : ""), this); if (this.editable) this.editable = this.form.Macro.exec(((this.json.editableScript) ? this.json.editableScript.code : ""), this);
//this.editable = false; //this.editable = false;
this.deleteable = this.json.deleteable !== "no";
this.addable = this.json.addable !== "no";
this.gridData = this._getValue(); this.gridData = this._getValue();
this.totalModules = []; this.totalModules = [];
this._loadDatagridTitleModules(); this._loadDatagridTitleModules();
if (this.editable!=false){ if (this.editable!=false){
this._loadDatagridDataModules(); this._loadDatagridDataModules();
//this._addTitleActionColumn(); //this._addTitleActionColumn();
this._loadEditDatagrid(); this._loadEditDatagrid();
//this._loadReadDatagrid(); //this._loadReadDatagrid();
this.fireEvent("postLoad"); this.fireEvent("postLoad");
this.fireEvent("load"); this.fireEvent("load");
}else{ }else{
this._loadDatagridDataModules(); this._loadDatagridDataModules();
this._loadReadDatagrid(); this._loadReadDatagrid();
this.fireEvent("postLoad"); this.fireEvent("postLoad");
this.fireEvent("load"); this.fireEvent("load");
} }
}, },
createMobileTable: function(){ createMobileTable: function(){
var mobileTable = new Element("table").inject(this.node); var mobileTable = new Element("table").inject(this.node);
mobileTable.set(this.json.properties); mobileTable.set(this.json.properties);
...@@ -77,87 +80,87 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -77,87 +80,87 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
this.table = mobileTable; this.table = mobileTable;
}, },
_loadStyles: function(){ _loadStyles: function(){
//this.table.setStyles(this.json.tableStyles); //this.table.setStyles(this.json.tableStyles);
this.node.setStyles(this.json.styles); this.node.setStyles(this.json.styles);
var tables = this.node.getElements("table"); var tables = this.node.getElements("table");
tables.each(function(table){ tables.each(function(table){
table.setStyles(this.json.tableStyles); table.setStyles(this.json.tableStyles);
}.bind(this)); }.bind(this));
}, },
_getValue: function(){ _getValue: function(){
var value = []; var value = [];
value = this._getBusinessData(); value = this._getBusinessData();
if (!value){ if (!value){
if (this.json.defaultData && this.json.defaultData.code) value = this.form.Macro.exec(this.json.defaultData.code, this); if (this.json.defaultData && this.json.defaultData.code) value = this.form.Macro.exec(this.json.defaultData.code, this);
value = {"data": value || []}; value = {"data": value || []};
} }
return value || []; return value || [];
}, },
_getValueText: function(idx, value){ _getValueText: function(idx, value){
var module = this.editModules[idx]; var module = this.editModules[idx];
if (module){ if (module){
switch (module.json.type){ switch (module.json.type){
case "Select": case "Select":
for (var i=0; i<module.json.itemValues.length; i++){ for (var i=0; i<module.json.itemValues.length; i++){
var itemv = module.json.itemValues[i]; var itemv = module.json.itemValues[i];
var arr = itemv.split(/\|/); var arr = itemv.split(/\|/);
var text = arr[0]; var text = arr[0];
var v = (arr.length>1) ? arr[1] : arr[0]; var v = (arr.length>1) ? arr[1] : arr[0];
if (value===v) return text; if (value===v) return text;
} }
// var ops = module.node.getElements("option"); // var ops = module.node.getElements("option");
// for (var i=0; i<ops.length; i++){ // for (var i=0; i<ops.length; i++){
// if (ops[i].value == value){ // if (ops[i].value == value){
// return ops[i].get("text"); // return ops[i].get("text");
// } // }
// } // }
break; break;
case "Radio": case "Radio":
var ops = module.node.getElements("input"); var ops = module.node.getElements("input");
for (var i=0; i<ops.length; i++){ for (var i=0; i<ops.length; i++){
if (ops[i].value == value){ if (ops[i].value == value){
return ops[i].get("showText"); return ops[i].get("showText");
}
}
break;
case "Checkbox":
var ops = module.node.getElements("input");
var texts = [];
for (var i=0; i<ops.length; i++){
if (value.indexOf(ops[i].value) != -1) texts.push(ops[i].get("showText"));
}
if (texts.length) return texts.join(", ");
break;
case "Orgfield":
case "Personfield":
case "Org":
//var v = module.getTextData();
//return v.text[0];
if (typeOf(value)==="array"){
var textArray = [];
value.each( function( item ){
if (typeOf(item)==="object"){
textArray.push( item.name+((item.unitName) ? "("+item.unitName+")" : "") );
}else{
textArray.push(item);
} }
}.bind(this)); }
return textArray.join(", "); break;
}else if (typeOf(value)==="object"){ case "Checkbox":
return value.name+((value.unitName) ? "("+value.unitName+")" : ""); var ops = module.node.getElements("input");
}else{ var texts = [];
return value; for (var i=0; i<ops.length; i++){
} if (value.indexOf(ops[i].value) != -1) texts.push(ops[i].get("showText"));
break; }
} if (texts.length) return texts.join(", ");
} break;
return value; case "Orgfield":
}, case "Personfield":
case "Org":
//var v = module.getTextData();
//return v.text[0];
if (typeOf(value)==="array"){
var textArray = [];
value.each( function( item ){
if (typeOf(item)==="object"){
textArray.push( item.name+((item.unitName) ? "("+item.unitName+")" : "") );
}else{
textArray.push(item);
}
}.bind(this));
return textArray.join(", ");
}else if (typeOf(value)==="object"){
return value.name+((value.unitName) ? "("+value.unitName+")" : "");
}else{
return value;
}
break;
}
}
return value;
},
editValidation: function(){ editValidation: function(){
var flag = true; var flag = true;
...@@ -170,8 +173,8 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -170,8 +173,8 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
return flag; return flag;
}, },
_loadReadDatagrid: function(){ _loadReadDatagrid: function(){
this.gridData = this._getValue(); this.gridData = this._getValue();
var titleHeaders = this.table.getElements("th"); var titleHeaders = this.table.getElements("th");
var tds = this.table.getElements("td"); var tds = this.table.getElements("td");
...@@ -246,7 +249,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -246,7 +249,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
} }
//this._loadTotal(); //this._loadTotal();
}, },
_loadEditDatagrid: function(){ _loadEditDatagrid: function(){
//this._createHelpNode(); //this._createHelpNode();
...@@ -329,9 +332,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -329,9 +332,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
}.bind(this)); }.bind(this));
}else{ }else{
if (this.addAction){ if (this.addAction){
this.addAction.setStyle("display", "block"); if( this.addable )this.addAction.setStyle("display", "block");
}else{ }else{
this._loadAddAction(); if( this.addable )this._loadAddAction();
} }
// this._loadAddAction(); // this._loadAddAction();
} }
...@@ -341,18 +344,24 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -341,18 +344,24 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
var actionNode = new Element("div", { var actionNode = new Element("div", {
"styles": this.form.css.mobileDatagridActionNode "styles": this.form.css.mobileDatagridActionNode
}).inject(titleDiv); }).inject(titleDiv);
var delAction = new Element("div", { var delAction = new Element("div", {
"styles": this.form.css.mobileDatagridDelActionNode, "styles": this.form.css.mobileDatagridDelActionNode,
"text": MWF.xApplication.process.Xform.LP["delete"] "text": MWF.xApplication.process.Xform.LP["delete"]
}).inject(actionNode); }).inject(actionNode);
if( !this.deleteable )delAction.hide();
var editAction = new Element("div", { var editAction = new Element("div", {
"styles": this.form.css.mobileDatagridEditActionNode, "styles": this.form.css.mobileDatagridEditActionNode,
"text": MWF.xApplication.process.Xform.LP.edit "text": MWF.xApplication.process.Xform.LP.edit
}).inject(actionNode); }).inject(actionNode);
var addAction = new Element("div", { var addAction = new Element("div", {
"styles": this.form.css.mobileDatagridAddActionNode, "styles": this.form.css.mobileDatagridAddActionNode,
"text": MWF.xApplication.process.Xform.LP.add "text": MWF.xApplication.process.Xform.LP.add
}).inject(actionNode); }).inject(actionNode);
if( !this.addable )addAction.hide();
var cancelAction = new Element("div", { var cancelAction = new Element("div", {
"styles": this.form.css.mobileDatagridCancelActionNode, "styles": this.form.css.mobileDatagridCancelActionNode,
"text": MWF.xApplication.process.Xform.LP.cancelEdit "text": MWF.xApplication.process.Xform.LP.cancelEdit
...@@ -364,7 +373,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -364,7 +373,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
var _self = this; var _self = this;
delAction.addEvent("click", function(e){ if( this.deleteable )delAction.addEvent("click", function(e){
_self._deleteLine(this.getParent().getParent().getParent(), e); _self._deleteLine(this.getParent().getParent().getParent(), e);
}); });
editAction.addEvent("click", function(e){ editAction.addEvent("click", function(e){
...@@ -376,7 +385,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -376,7 +385,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
cancelAction.addEvent("click", function(e){ cancelAction.addEvent("click", function(e){
_self._cancelLineEdit(e); _self._cancelLineEdit(e);
}); });
addAction.addEvent("click", function(e){ if( this.addable )addAction.addEvent("click", function(e){
_self._addLine(); _self._addLine();
}); });
}, },
...@@ -481,7 +490,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -481,7 +490,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
this.validationMode(); this.validationMode();
}, },
_loadAddAction: function(){ _loadAddAction: function(){
if( !this.addAction ){ if( !this.addAction ){
this.addAction = new Element("div", {"styles": this.form.css.gridMobileActionNode}).inject(this.node, "top"); this.addAction = new Element("div", {"styles": this.form.css.gridMobileActionNode}).inject(this.node, "top");
this.addAction.set("text", MWF.xApplication.process.Xform.LP.addLine); this.addAction.set("text", MWF.xApplication.process.Xform.LP.addLine);
this.addAction.addEvent("click", function(){ this.addAction.addEvent("click", function(){
...@@ -550,9 +559,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -550,9 +559,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
currentEditTable.setStyle("display", "table"); currentEditTable.setStyle("display", "table");
var actions = datagrid.currentEditLine.getFirst("div").getLast("div").getElements("div"); var actions = datagrid.currentEditLine.getFirst("div").getLast("div").getElements("div");
if (actions[0]) actions[0].setStyle("display", "block"); if (actions[0] && this.deleteable ) actions[0].setStyle("display", "block");
if (actions[1]) actions[1].setStyle("display", "block"); if (actions[1] ) actions[1].setStyle("display", "block");
if (actions[2]) actions[2].setStyle("display", "block"); if (actions[2] && this.addable ) actions[2].setStyle("display", "block");
if (actions[3]) actions[3].setStyle("display", "none"); if (actions[3]) actions[3].setStyle("display", "none");
if (actions[4]) actions[4].setStyle("display", "none"); if (actions[4]) actions[4].setStyle("display", "none");
...@@ -567,9 +576,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -567,9 +576,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
if (!_self.gridData.data.length){ if (!_self.gridData.data.length){
if (_self.addAction){ if (_self.addAction){
_self.addAction.setStyle("display", "block"); if( _self.addable )_self.addAction.setStyle("display", "block");
}else{ }else{
_self._loadAddAction(); if( _self.addable )_self._loadAddAction();
} }
} }
...@@ -601,9 +610,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -601,9 +610,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
table = dataNode.getElement("table"); table = dataNode.getElement("table");
var actions = this.currentEditLine.getFirst("div").getLast("div").getElements("div"); var actions = this.currentEditLine.getFirst("div").getLast("div").getElements("div");
if (actions[0]) actions[0].setStyle("display", "block"); if (actions[0] && this.deleteable ) actions[0].setStyle("display", "block");
if (actions[1]) actions[1].setStyle("display", "block"); if (actions[1]) actions[1].setStyle("display", "block");
if (actions[2]) actions[2].setStyle("display", "block"); if (actions[2] && this.addable ) actions[2].setStyle("display", "block");
if (actions[3]) actions[3].setStyle("display", "none"); if (actions[3]) actions[3].setStyle("display", "none");
if (actions[4]) actions[4].setStyle("display", "none"); if (actions[4]) actions[4].setStyle("display", "none");
}else{ }else{
...@@ -616,9 +625,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -616,9 +625,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
} }
var actions = this.table.getParent().getPrevious("div").getLast("div").getElements("div"); var actions = this.table.getParent().getPrevious("div").getLast("div").getElements("div");
if (actions[0]) actions[0].setStyle("display", "block"); if (actions[0] && this.deleteable ) actions[0].setStyle("display", "block");
if (actions[1]) actions[1].setStyle("display", "block"); if (actions[1]) actions[1].setStyle("display", "block");
if (actions[2]) actions[2].setStyle("display", "block"); if (actions[2] && this.addable ) actions[2].setStyle("display", "block");
if (actions[3]) actions[3].setStyle("display", "none"); if (actions[3]) actions[3].setStyle("display", "none");
if (actions[4]) actions[4].setStyle("display", "none"); if (actions[4]) actions[4].setStyle("display", "none");
...@@ -851,9 +860,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -851,9 +860,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
if (!_self.gridData.data.length){ if (!_self.gridData.data.length){
if (_self.addAction){ if (_self.addAction){
_self.addAction.setStyle("display", "block"); if( _self.addable )_self.addAction.setStyle("display", "block");
}else{ }else{
_self._loadAddAction(); if( _self.addable )_self._loadAddAction();
} }
} }
this.close(); this.close();
...@@ -908,9 +917,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -908,9 +917,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
tableNode.setStyle("margin-right", ""+width+"px"); tableNode.setStyle("margin-right", ""+width+"px");
}, },
_loadDatagridStyle: function(){ _loadDatagridStyle: function(){
//var ths = this.node.getElements("th"); //var ths = this.node.getElements("th");
//ths.setStyles(this.form.css.datagridTitle); //ths.setStyles(this.form.css.datagridTitle);
this.loadGridTitleStyle(); this.loadGridTitleStyle();
this.loadGridContentStyle(); this.loadGridContentStyle();
...@@ -918,10 +927,10 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -918,10 +927,10 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
this.loadGridEditStyle(); this.loadGridEditStyle();
this._loadTotal(); this._loadTotal();
this._loadBorderStyle(); this._loadBorderStyle();
this._loadZebraStyle(); this._loadZebraStyle();
this._loadSequence(); this._loadSequence();
}, },
loadGridEditStyle: function(){ loadGridEditStyle: function(){
if (this.table){ if (this.table){
...@@ -953,15 +962,15 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -953,15 +962,15 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
tds.setStyles(this.json.contentStyles); tds.setStyles(this.json.contentStyles);
} }
}, },
_loadZebraStyle: function(){ _loadZebraStyle: function(){
if (this.json.zebraColor || this.json.backgroundColor){ if (this.json.zebraColor || this.json.backgroundColor){
var tables = this.node.getElements("table"); var tables = this.node.getElements("table");
tables.each(function(table){ tables.each(function(table){
this._loadTableZebraStyle(table); this._loadTableZebraStyle(table);
}.bind(this)); }.bind(this));
} }
}, },
_loadTableZebraStyle: function(table){ _loadTableZebraStyle: function(table){
var trs = table.getElements("tr"); var trs = table.getElements("tr");
for (var i=0; i<trs.length; i++){ for (var i=0; i<trs.length; i++){
...@@ -1024,7 +1033,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -1024,7 +1033,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
tr = this.totalTable.insertRow(i); tr = this.totalTable.insertRow(i);
var datath = new Element("th").inject(tr); var datath = new Element("th").inject(tr);
datath.set("text", m.module.node.get("text")); datath.set("text", m.module.node.get("text"));
// datath.setStyle("width", "30%"); // datath.setStyle("width", "30%");
datath.setStyles(this.json.titleStyles); datath.setStyles(this.json.titleStyles);
tr.insertCell(1).setStyles(this.json.amountStyles).set("text", totalResaults[i] || ""); tr.insertCell(1).setStyles(this.json.amountStyles).set("text", totalResaults[i] || "");
}else{ }else{
...@@ -1055,15 +1064,15 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -1055,15 +1064,15 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
}.bind(this)); }.bind(this));
}.bind(this)); }.bind(this));
}, },
_loadBorderStyle: function(){ _loadBorderStyle: function(){
if (this.json.border){ if (this.json.border){
var tables = this.node.getElements("table"); var tables = this.node.getElements("table");
tables.each(function(table){ tables.each(function(table){
this._loadTableBorderStyle(table) this._loadTableBorderStyle(table)
}.bind(this)); }.bind(this));
} }
}, },
_loadTableBorderStyle: function(table){ _loadTableBorderStyle: function(table){
table.setStyles({ table.setStyles({
"border-top": this.json.border, "border-top": this.json.border,
...@@ -1081,9 +1090,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -1081,9 +1090,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
"background": "transparent" "background": "transparent"
}); });
}, },
_loadDatagridTitleModules: function(){ _loadDatagridTitleModules: function(){
var ths = this.node.getElements("th"); var ths = this.node.getElements("th");
ths.each(function(th){ ths.each(function(th){
var json = this.form._getDomjson(th); var json = this.form._getDomjson(th);
th.store("dataGrid", this); th.store("dataGrid", this);
if (json){ if (json){
...@@ -1091,25 +1100,25 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -1091,25 +1100,25 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
this.form.modules.push(module); this.form.modules.push(module);
} }
}.bind(this)); }.bind(this));
}, },
_loadDatagridDataModules: function(){ _loadDatagridDataModules: function(){
var tds = this.node.getElements("td"); var tds = this.node.getElements("td");
tds.each(function(td){ tds.each(function(td){
var json = this.form._getDomjson(td); var json = this.form._getDomjson(td);
td.store("dataGrid", this); td.store("dataGrid", this);
if (json){ if (json){
var module = this.form._loadModule(json, td, function(){ var module = this.form._loadModule(json, td, function(){
this.field = false; this.field = false;
}); });
td.store("module", module); td.store("module", module);
this.form.modules.push(module); this.form.modules.push(module);
} }
}.bind(this)); }.bind(this));
}, },
_afterLoaded: function(){ _afterLoaded: function(){
this._loadDatagridStyle(); this._loadDatagridStyle();
if (this.table) this.table.setStyle("display", "none"); if (this.table) this.table.setStyle("display", "none");
}, },
resetData: function(){ resetData: function(){
this.setData(this._getValue()); this.setData(this._getValue());
}, },
...@@ -1207,15 +1216,15 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -1207,15 +1216,15 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
return this.totalResaults; return this.totalResaults;
}, },
isEmpty: function(){ isEmpty: function(){
var data = this.getData(); var data = this.getData();
if( !data )return true; if( !data )return true;
if( typeOf( data ) === "object" ){ if( typeOf( data ) === "object" ){
if( typeOf( data.data ) !== "array" )return true; if( typeOf( data.data ) !== "array" )return true;
if( data.data.length === 0 )return true; if( data.data.length === 0 )return true;
} }
return false; return false;
}, },
getData: function(){ getData: function(){
if (this.editable!=false){ if (this.editable!=false){
if (this.isEdit) this._completeLineEdit(); if (this.isEdit) this._completeLineEdit();
var data = []; var data = [];
...@@ -1238,7 +1247,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -1238,7 +1247,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
}else{ }else{
return this._getBusinessData(); return this._getBusinessData();
} }
}, },
getAmount: function(){ getAmount: function(){
return this._loadTotal(); return this._loadTotal();
}, },
...@@ -1391,12 +1400,12 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ ...@@ -1391,12 +1400,12 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
} }
return true; return true;
} }
}); });
MWF.xApplication.process.Xform.DatagridMobile$Title = new Class({ MWF.xApplication.process.Xform.DatagridMobile$Title = new Class({
Extends: MWF.APP$Module, Extends: MWF.APP$Module,
_afterLoaded: function(){ _afterLoaded: function(){
this.dataGrid = this.node.retrieve("dataGrid"); this.dataGrid = this.node.retrieve("dataGrid");
if ((this.json.total == "number") || (this.json.total == "count")){ if ((this.json.total == "number") || (this.json.total == "count")){
this.dataGrid.totalModules.push({ this.dataGrid.totalModules.push({
...@@ -1405,14 +1414,14 @@ MWF.xApplication.process.Xform.DatagridMobile$Title = new Class({ ...@@ -1405,14 +1414,14 @@ MWF.xApplication.process.Xform.DatagridMobile$Title = new Class({
"type": this.json.total "type": this.json.total
}) })
} }
// this.form._loadModules(this.node); // this.form._loadModules(this.node);
} }
}); });
MWF.xApplication.process.Xform.DatagridMobile$Data = new Class({ MWF.xApplication.process.Xform.DatagridMobile$Data = new Class({
Extends: MWF.APP$Module, Extends: MWF.APP$Module,
_afterLoaded: function(){ _afterLoaded: function(){
//this.form._loadModules(this.node); //this.form._loadModules(this.node);
this.dataGrid = this.node.retrieve("dataGrid"); this.dataGrid = this.node.retrieve("dataGrid");
var td = this.node; var td = this.node;
if (this.json.cellType == "sequence"){ if (this.json.cellType == "sequence"){
...@@ -1442,5 +1451,5 @@ MWF.xApplication.process.Xform.DatagridMobile$Data = new Class({ ...@@ -1442,5 +1451,5 @@ MWF.xApplication.process.Xform.DatagridMobile$Data = new Class({
this.dataGrid.editModules.push(module); this.dataGrid.editModules.push(module);
}.bind(this)); }.bind(this));
} }
} }
}); });
\ No newline at end of file
...@@ -3,37 +3,40 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -3,37 +3,40 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
Implements: [Events], Implements: [Events],
Extends: MWF.APP$Module, Extends: MWF.APP$Module,
isEdit: false, isEdit: false,
options: { options: {
"moduleEvents": ["queryLoad","postLoad","load","completeLineEdit", "addLine", "deleteLine", "afterDeleteLine","editLine"] "moduleEvents": ["queryLoad","postLoad","load","completeLineEdit", "addLine", "deleteLine", "afterDeleteLine","editLine"]
}, },
initialize: function(node, json, form, options){ initialize: function(node, json, form, options){
this.node = $(node); this.node = $(node);
this.node.store("module", this); this.node.store("module", this);
this.json = json; this.json = json;
this.form = form; this.form = form;
this.field = true; this.field = true;
}, },
_loadUserInterface: function(){ _loadUserInterface: function(){
this.fireEvent("queryLoad"); this.fireEvent("queryLoad");
this.editModules = []; this.editModules = [];
this.node.setStyle("overflow-x", "auto"); this.node.setStyle("overflow-x", "auto");
this.node.setStyle("overflow-y", "hidden"); this.node.setStyle("overflow-y", "hidden");
this.table = this.node.getElement("table"); this.table = this.node.getElement("table");
this.editable = (this.readonly) ? false : true; this.editable = (this.readonly) ? false : true;
if (this.editable) this.editable = this.form.Macro.exec(((this.json.editableScript) ? this.json.editableScript.code : ""), this); if (this.editable) this.editable = this.form.Macro.exec(((this.json.editableScript) ? this.json.editableScript.code : ""), this);
this.deleteable = this.json.deleteable !== "no";
this.addable = this.json.addable !== "no";
this.gridData = this._getValue(); this.gridData = this._getValue();
this.totalModules = []; this.totalModules = [];
this._loadDatagridTitleModules(); this._loadDatagridTitleModules();
if (this.editable!=false){ if (this.editable!=false){
this._loadDatagridDataModules(); this._loadDatagridDataModules();
this._addTitleActionColumn(); this._addTitleActionColumn();
this._loadEditDatagrid(); this._loadEditDatagrid();
...@@ -41,8 +44,8 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -41,8 +44,8 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
this.fireEvent("load"); this.fireEvent("load");
//this._loadReadDatagrid(); //this._loadReadDatagrid();
}else{ }else{
this._loadDatagridDataModules(); this._loadDatagridDataModules();
this._getDatagridEditorTr(); this._getDatagridEditorTr();
this._loadReadDatagrid(); this._loadReadDatagrid();
if(this.editorTr)this.editorTr.setStyle("display", "none"); if(this.editorTr)this.editorTr.setStyle("display", "none");
...@@ -52,14 +55,14 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -52,14 +55,14 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
}, },
_loadStyles: function(){ _loadStyles: function(){
this.table.setStyles(this.json.tableStyles); this.table.setStyles(this.json.tableStyles);
this.node.setStyles(this.json.styles); this.node.setStyles(this.json.styles);
}, },
_getValue: function(){ _getValue: function(){
var value = []; var value = [];
value = this._getBusinessData(); value = this._getBusinessData();
if (!value){ if (!value){
if (this.json.defaultData && this.json.defaultData.code) value = this.form.Macro.exec(this.json.defaultData.code, this); if (this.json.defaultData && this.json.defaultData.code) value = this.form.Macro.exec(this.json.defaultData.code, this);
value = {"data": value || []}; value = {"data": value || []};
} }
return value || {}; return value || {};
}, },
...@@ -74,136 +77,140 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -74,136 +77,140 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
_getDatagridEditorTr: function(){ _getDatagridEditorTr: function(){
var trs = this.table.getElements("tr"); var trs = this.table.getElements("tr");
this.editorTr = trs[trs.length-1]; this.editorTr = trs[trs.length-1];
this.editorTr.addClass("datagridEditorTr"); this.editorTr.addClass("datagridEditorTr");
return this.editorTr; return this.editorTr;
}, },
_addTitleActionColumn: function(){ _addTitleActionColumn: function(){
if (!this.titleTr) this._getDatagridTitleTr(); if (!this.titleTr) this._getDatagridTitleTr();
if (!this.editorTr) this._getDatagridEditorTr(); if (!this.editorTr) this._getDatagridEditorTr();
var actionTh = new Element("th", {"styles": {"width": "46px"}}).inject(this.titleTr, "top"); var actionTh = new Element("th", {"styles": {"width": "46px"}}).inject(this.titleTr, "top");
new Element("th").inject(this.titleTr, "bottom"); new Element("th").inject(this.titleTr, "bottom");
this._createAddLineAction(actionTh); if( this.addable ){
this._createAddLineAction(actionTh);
}
//this._createDelLineAction(actionTh); //this._createDelLineAction(actionTh);
var actionEditTd = new Element("td").inject(this.editorTr, "top"); var actionEditTd = new Element("td").inject(this.editorTr, "top");
this._createCompleteAction(actionEditTd); this._createCompleteAction(actionEditTd);
this._createCancelAction(actionEditTd); if( this.deleteable ){
this._createCancelAction(actionEditTd);
}
new Element("td").inject(this.editorTr, "bottom"); new Element("td").inject(this.editorTr, "bottom");
//if (this.totalTr){ //if (this.totalTr){
// new Element("td").inject(this.totalTr, "top"); // new Element("td").inject(this.totalTr, "top");
// new Element("td").inject(this.totalTr, "bottom"); // new Element("td").inject(this.totalTr, "bottom");
// this.totalModules.each(function(m){ // this.totalModules.each(function(m){
// m.index = m.index+1; // m.index = m.index+1;
// }); // });
//} //}
}, },
_loadEditDatagrid: function(){ _loadEditDatagrid: function(){
var titleThs = this.titleTr.getElements("th"); var titleThs = this.titleTr.getElements("th");
var editorTds = this.editorTr.getElements("td"); var editorTds = this.editorTr.getElements("td");
if (this.gridData.data){ if (this.gridData.data){
this.gridData.data.each(function(data, idx){ this.gridData.data.each(function(data, idx){
var tr = $(this.table.insertRow(idx+1)); var tr = $(this.table.insertRow(idx+1));
tr.store("data", data); tr.store("data", data);
titleThs.each(function(th, index){ titleThs.each(function(th, index){
var cellData = data[th.get("id")]; var cellData = data[th.get("id")];
var text = ""; var text = "";
for (key in cellData){ for (key in cellData){
var value = cellData[key]; var value = cellData[key];
text = this._getValueText(index-1, value); text = this._getValueText(index-1, value);
break; break;
} }
this._createNewEditTd(tr, index, editorTds[index].get("id"), text, titleThs.length-1); this._createNewEditTd(tr, index, editorTds[index].get("id"), text, titleThs.length-1);
}.bind(this)); }.bind(this));
}.bind(this)); }.bind(this));
} }
this.editorTr.setStyle("display", "none"); this.editorTr.setStyle("display", "none");
}, },
_getValueText: function(idx, value){ _getValueText: function(idx, value){
debugger; debugger;
var module = this.editModules[idx]; var module = this.editModules[idx];
if (module){ if (module){
switch (module.json.type){ switch (module.json.type){
case "Select": case "Select":
for (var i=0; i<module.json.itemValues.length; i++){ for (var i=0; i<module.json.itemValues.length; i++){
var itemv = module.json.itemValues[i]; var itemv = module.json.itemValues[i];
var arr = itemv.split(/\|/); var arr = itemv.split(/\|/);
var text = arr[0]; var text = arr[0];
var v = (arr.length>1) ? arr[1] : arr[0]; var v = (arr.length>1) ? arr[1] : arr[0];
if (value===v) return text; if (value===v) return text;
} }
// var ops = module.node.getElements("option"); // var ops = module.node.getElements("option");
// for (var i=0; i<ops.length; i++){ // for (var i=0; i<ops.length; i++){
// if (ops[i].value == value){ // if (ops[i].value == value){
// return ops[i].get("text"); // return ops[i].get("text");
// break; // break;
// } // }
// } // }
break; break;
case "Radio": case "Radio":
var ops = module.node.getElements("input"); var ops = module.node.getElements("input");
for (var i=0; i<ops.length; i++){ for (var i=0; i<ops.length; i++){
if (ops[i].value == value){ if (ops[i].value == value){
return ops[i].get("showText"); return ops[i].get("showText");
break; break;
}
}
break;
case "Checkbox":
var ops = module.node.getElements("input");
var texts = [];
for (var i=0; i<ops.length; i++){
if (value.indexOf(ops[i].value) != -1) texts.push(ops[i].get("showText"));
}
if (texts.length) return texts.join(", ");
break;
case "Orgfield":
case "Personfield":
case "Org":
//var v = module.getTextData();
//return v.text[0];
if (typeOf(value)==="array"){
var textArray = [];
value.each( function( item ){
if (typeOf(item)==="object"){
textArray.push( item.name+((item.unitName) ? "("+item.unitName+")" : "") );
}else{
textArray.push(item);
} }
}.bind(this)); }
return textArray.join(", "); break;
}else if (typeOf(value)==="object"){ case "Checkbox":
return value.name+((value.unitName) ? "("+value.unitName+")" : ""); var ops = module.node.getElements("input");
}else{ var texts = [];
return value; for (var i=0; i<ops.length; i++){
} if (value.indexOf(ops[i].value) != -1) texts.push(ops[i].get("showText"));
}
if (texts.length) return texts.join(", ");
break;
case "Orgfield":
case "Personfield":
case "Org":
//var v = module.getTextData();
//return v.text[0];
if (typeOf(value)==="array"){
var textArray = [];
value.each( function( item ){
if (typeOf(item)==="object"){
textArray.push( item.name+((item.unitName) ? "("+item.unitName+")" : "") );
}else{
textArray.push(item);
}
}.bind(this));
return textArray.join(", ");
}else if (typeOf(value)==="object"){
return value.name+((value.unitName) ? "("+value.unitName+")" : "");
}else{
return value;
}
break; break;
// case "address": // case "address":
// if (typeOf(value)==="array"){ // if (typeOf(value)==="array"){
// //
// } // }
// break; // break;
} }
} }
return value; return value;
}, },
_createNewEditTd: function(tr, idx, id, text, lastIdx){ _createNewEditTd: function(tr, idx, id, text, lastIdx){
var cell = $(tr.insertCell(idx)); var cell = $(tr.insertCell(idx));
if (idx==0){ if (idx==0){
cell.setStyles(this.form.css.gridLineActionCell); cell.setStyles(this.form.css.gridLineActionCell);
this._createAddLineAction(cell); if( this.addable )this._createAddLineAction(cell);
this._createDelLineAction(cell); if( this.deleteable )this._createDelLineAction(cell);
}else if (idx == lastIdx){ }else if (idx == lastIdx){
cell.setStyles(this.form.css.gridMoveActionCell); cell.setStyles(this.form.css.gridMoveActionCell);
this._createMoveLineAction(cell); this._createMoveLineAction(cell);
...@@ -223,17 +230,17 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -223,17 +230,17 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
var json = this.form._getDomjson(cell); var json = this.form._getDomjson(cell);
if (json){ if (json){
cell.store("dataGrid", this); cell.store("dataGrid", this);
var module = this.form._loadModule(json, cell); var module = this.form._loadModule(json, cell);
cell.store("module", module); cell.store("module", module);
this.form.modules.push(module); this.form.modules.push(module);
} }
}, },
_createAddLineAction: function(td){ _createAddLineAction: function(td){
var addLineAction = new Element("div", { var addLineAction = new Element("div", {
"styles": this.form.css.addLineAction, "styles": this.form.css.addLineAction,
"events": { "events": {
"click": function(e){ "click": function(e){
this._addLine(e.target); this._addLine(e.target);
...@@ -244,7 +251,7 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -244,7 +251,7 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
}, },
_createDelLineAction: function(td){ _createDelLineAction: function(td){
var delLineAction = new Element("div", { var delLineAction = new Element("div", {
"styles": this.form.css.delLineAction, "styles": this.form.css.delLineAction,
"events": { "events": {
"click": function(e){ "click": function(e){
this._deleteLine(e); this._deleteLine(e);
...@@ -255,7 +262,7 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -255,7 +262,7 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
}, },
_createCompleteAction: function(td){ _createCompleteAction: function(td){
var completeAction = new Element("div", { var completeAction = new Element("div", {
"styles": this.form.css.completeLineAction, "styles": this.form.css.completeLineAction,
"events": { "events": {
"click": function(e){ "click": function(e){
this._completeLineEdit(e); this._completeLineEdit(e);
...@@ -275,12 +282,12 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -275,12 +282,12 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
}); });
cancelAction.inject(td); cancelAction.inject(td);
}, },
_editLine:function(td){ _editLine:function(td){
if (this.isEdit){ if (this.isEdit){
if (!this._completeLineEdit()) return false; if (!this._completeLineEdit()) return false;
} }
this.currentEditLine = td.getParent("tr"); this.currentEditLine = td.getParent("tr");
if (this.currentEditLine){ if (this.currentEditLine){
this.editorTr.setStyles({ this.editorTr.setStyles({
...@@ -289,52 +296,52 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -289,52 +296,52 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
}); });
this.editorTr.inject(this.currentEditLine, "before"); this.editorTr.inject(this.currentEditLine, "before");
this.currentEditLine.setStyle("display", "none"); this.currentEditLine.setStyle("display", "none");
var data = this.currentEditLine.retrieve("data"); var data = this.currentEditLine.retrieve("data");
var titleThs = this.titleTr.getElements("th"); var titleThs = this.titleTr.getElements("th");
titleThs.each(function(th, idx){ titleThs.each(function(th, idx){
var id = th.get("id"); var id = th.get("id");
var module = this.editModules[idx-1]; var module = this.editModules[idx-1];
if (module){ if (module){
if (module.json.type=="sequence"){ if (module.json.type=="sequence"){
module.node.set("text", module.node.getParent("tr").rowIndex); module.node.set("text", module.node.getParent("tr").rowIndex);
//var i = newTr.rowIndex; //var i = newTr.rowIndex;
//var data = {"value": [i], "text": [i]}; //var data = {"value": [i], "text": [i]};
}else { }else {
debugger; debugger;
if (data[id]) { if (data[id]) {
module.setData(data[id][module.json.id]); module.setData(data[id][module.json.id]);
} else { } else {
module.setData(null); module.setData(null);
} }
} }
} }
}.bind(this)); }.bind(this));
var cellIdx = this.currentEditLine.getElements("td").indexOf(td); var cellIdx = this.currentEditLine.getElements("td").indexOf(td);
var module = this.editModules[cellIdx-1]; var module = this.editModules[cellIdx-1];
if (module) module.focus(); if (module) module.focus();
this.fireEvent("editLine"); this.fireEvent("editLine");
this.isEdit =true; this.isEdit =true;
} }
this.validationMode(); this.validationMode();
},
editValidation: function(){
var flag = true;
this.editModules.each(function(field, key){
if (field.json.type!="sequence"){
field.validationMode();
if (!field.validation()) flag = false;
}
}.bind(this));
return flag;
}, },
editValidation: function(){
var flag = true;
this.editModules.each(function(field, key){
if (field.json.type!="sequence"){
field.validationMode();
if (!field.validation()) flag = false;
}
}.bind(this));
return flag;
},
// _cancelLineEdit: function(e){ // _cancelLineEdit: function(e){
// this.isEdit = false; // this.isEdit = false;
...@@ -412,9 +419,9 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -412,9 +419,9 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
} }
this.isEdit = false; this.isEdit = false;
var flag = true; var flag = true;
var griddata = {}; var griddata = {};
var newTr = null; var newTr = null;
...@@ -434,20 +441,20 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -434,20 +441,20 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
var id = th.get("id"); var id = th.get("id");
var module = this.editModules[idx-1]; var module = this.editModules[idx-1];
if (module){ if (module){
if (module.json.type=="sequence"){ if (module.json.type=="sequence"){
var i = newTr.rowIndex; var i = newTr.rowIndex;
var data = {"value": [i], "text": [i]}; var data = {"value": [i], "text": [i]};
}else{ }else{
var data = module.getTextData(); var data = module.getTextData();
if (data.value[0]) flag = false; if (data.value[0]) flag = false;
if (data.value.length<2){ if (data.value.length<2){
if (!griddata[id]) griddata[id] = {}; if (!griddata[id]) griddata[id] = {};
griddata[id][module.json.id] = data.value[0]; griddata[id][module.json.id] = data.value[0];
}else{ }else{
if (!griddata[id]) griddata[id] = {}; if (!griddata[id]) griddata[id] = {};
griddata[id][module.json.id] = data.value; griddata[id][module.json.id] = data.value;
} }
} }
if (cell){ if (cell){
if( module.json.type == "ImageClipper" ){ if( module.json.type == "ImageClipper" ){
...@@ -461,40 +468,40 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -461,40 +468,40 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
}else{ }else{
if (!cell) this._createNewEditTd(newTr, idx, id, "", titleThs.length-1); if (!cell) this._createNewEditTd(newTr, idx, id, "", titleThs.length-1);
} }
module = null; module = null;
}.bind(this)); }.bind(this));
newTr.store("data", griddata); newTr.store("data", griddata);
newTr.setStyle("display", "table-row"); newTr.setStyle("display", "table-row");
if (flag){ if (flag){
newTr.destroy(); newTr.destroy();
} }
this.currentEditLine = null; this.currentEditLine = null;
this._editorTrGoBack(); this._editorTrGoBack();
if (this.json.contentStyles){ if (this.json.contentStyles){
var tds = newTr.getElements("td"); var tds = newTr.getElements("td");
tds.setStyles(this.json.contentStyles); tds.setStyles(this.json.contentStyles);
} }
if (this.json.actionStyles){ if (this.json.actionStyles){
newTr.getFirst().setStyles(this.json.actionStyles); newTr.getFirst().setStyles(this.json.actionStyles);
} }
//this._loadTotal(); //this._loadTotal();
this._loadBorderStyle(); this._loadBorderStyle();
this._loadZebraStyle(); this._loadZebraStyle();
this._loadSequence(); this._loadSequence();
this.getData(); this.getData();
this.validationMode(); this.validationMode();
this.fireEvent("completeLineEdit", [newTr]); this.fireEvent("completeLineEdit", [newTr]);
return true; return true;
}, },
_createImage : function( cell, module, data ){ _createImage : function( cell, module, data ){
cell.empty(); cell.empty();
...@@ -516,30 +523,30 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -516,30 +523,30 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
_editorTrGoBack: function(){ _editorTrGoBack: function(){
this.editorTr.setStyle("display", "none"); this.editorTr.setStyle("display", "none");
// this.editTr.removeEvents("blur"); // this.editTr.removeEvents("blur");
if (this.totalTr){ if (this.totalTr){
this.editorTr.inject(this.totalTr, "before"); this.editorTr.inject(this.totalTr, "before");
}else{ }else{
var lastTrs = this.table.getElements("tr"); var lastTrs = this.table.getElements("tr");
var lastTr = lastTrs[lastTrs.length-1]; var lastTr = lastTrs[lastTrs.length-1];
this.editorTr.inject(lastTr, "after"); this.editorTr.inject(lastTr, "after");
} }
}, },
_addLine: function(node){ _addLine: function(node){
if (this.isEdit){ if (this.isEdit){
if (!this._completeLineEdit()) return false; if (!this._completeLineEdit()) return false;
} }
this.editorTr.setStyles({ this.editorTr.setStyles({
//"background-color": "#fffeb5", //"background-color": "#fffeb5",
"display": "table-row" "display": "table-row"
}); });
this.currentEditLine = null; this.currentEditLine = null;
var currentTr = node.getParent("tr"); var currentTr = node.getParent("tr");
if (currentTr){ if (currentTr){
this.editorTr.inject(currentTr, "after"); this.editorTr.inject(currentTr, "after");
} }
this.isEdit =true; this.isEdit =true;
this.validationMode(); this.validationMode();
this.fireEvent("addLine",[this.editorTr]); this.fireEvent("addLine",[this.editorTr]);
// newTr.addEvent("blur", function(e){ // newTr.addEvent("blur", function(e){
// this._completeLineEdit(); // this._completeLineEdit();
// }.bind(this)); // }.bind(this));
...@@ -553,23 +560,23 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -553,23 +560,23 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
var datagrid = this; var datagrid = this;
var _self = this; var _self = this;
this.form.confirm("warn", e, MWF.xApplication.process.Xform.LP.deleteDatagridLineTitle, MWF.xApplication.process.Xform.LP.deleteDatagridLine, 300, 120, function(){ this.form.confirm("warn", e, MWF.xApplication.process.Xform.LP.deleteDatagridLineTitle, MWF.xApplication.process.Xform.LP.deleteDatagridLine, 300, 120, function(){
_self.fireEvent("deleteLine", [currentTr]); _self.fireEvent("deleteLine", [currentTr]);
currentTr.destroy(); currentTr.destroy();
datagrid._loadZebraStyle(); datagrid._loadZebraStyle();
datagrid._loadSequence(); datagrid._loadSequence();
datagrid._loadTotal(); datagrid._loadTotal();
datagrid.getData(); datagrid.getData();
this.close(); this.close();
_self.fireEvent("afterDeleteLine"); _self.fireEvent("afterDeleteLine");
}, function(){ }, function(){
var color = currentTr.retrieve("bgcolor"); var color = currentTr.retrieve("bgcolor");
currentTr.tween("background", color); currentTr.tween("background", color);
this.close(); this.close();
}, null, null, this.form.json.confirmStyle); }, null, null, this.form.json.confirmStyle);
} }
this.validationMode(); this.validationMode();
}, },
_createMoveLineAction: function(td){ _createMoveLineAction: function(td){
var moveLineAction = new Element("div", { var moveLineAction = new Element("div", {
...@@ -589,7 +596,7 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -589,7 +596,7 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
var dragNode = div.clone().setStyle("width", size.x).inject(document.body); var dragNode = div.clone().setStyle("width", size.x).inject(document.body);
var dragtable = dragNode.getElement("table"); var dragtable = dragNode.getElement("table");
dragtable.empty(); dragtable.empty();
var clone = tr.clone().setStyles(this.form.css.gridMoveLineDragNodeTr).inject(dragtable); var clone = tr.clone().setStyles(this.form.css.gridMoveLineDragNodeTr).inject(dragtable);
var tds = tr.getElements("td"); var tds = tr.getElements("td");
var clonetds = clone.getElements("td"); var clonetds = clone.getElements("td");
...@@ -597,27 +604,27 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -597,27 +604,27 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
var size = td.getComputedSize(); var size = td.getComputedSize();
clonetds[idx].setStyle("width", size.width+1); clonetds[idx].setStyle("width", size.width+1);
}); });
var coordinates = tr.getCoordinates(); var coordinates = tr.getCoordinates();
dragNode.setStyles(this.form.css.gridMoveLineDragNode); dragNode.setStyles(this.form.css.gridMoveLineDragNode);
dragNode.setStyles(coordinates); dragNode.setStyles(coordinates);
return dragNode; return dragNode;
}, },
_moveLine: function(e){ _moveLine: function(e){
var trs = this.table.getElements("tr"); var trs = this.table.getElements("tr");
var div = e.target; var div = e.target;
var tr = div.getParent("tr"); var tr = div.getParent("tr");
var dragNode = this._getMoveDragNode(tr); var dragNode = this._getMoveDragNode(tr);
coordinates = dragNode.getCoordinates(); coordinates = dragNode.getCoordinates();
var dragTr = dragNode.getElement("tr"); var dragTr = dragNode.getElement("tr");
var dragTable = dragNode.getElement("table"); var dragTable = dragNode.getElement("table");
var color = tr.getStyle("background"); var color = tr.getStyle("background");
tr.store("bgcolor", color); tr.store("bgcolor", color);
//tr.tween('background-color', '#f3f1ad'); //tr.tween('background-color', '#f3f1ad');
tr.tween('background-color', '#e4f6e9'); tr.tween('background-color', '#e4f6e9');
var drag = new Drag.Move(dragNode, { var drag = new Drag.Move(dragNode, {
...@@ -625,32 +632,32 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -625,32 +632,32 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
"limit": {"x": [coordinates.left, coordinates.left]}, "limit": {"x": [coordinates.left, coordinates.left]},
onDrop: function(dragging, droppable){ onDrop: function(dragging, droppable){
dragging.destroy(); dragging.destroy();
//debugger; //debugger;
var color = tr.retrieve("bgcolor"); var color = tr.retrieve("bgcolor");
if (color){ if (color){
tr.tween("background", color); tr.tween("background", color);
}else{ }else{
tr.tween("background", "transparent"); tr.tween("background", "transparent");
} }
//if (droppable){ //if (droppable){
// color = droppable.retrieve("bgcolor"); // color = droppable.retrieve("bgcolor");
// if (color){ // if (color){
// droppable.tween("background", color); // droppable.tween("background", color);
// }else{ // }else{
// droppable.tween("background", "transparent"); // droppable.tween("background", "transparent");
// } // }
//} //}
tr.setStyle("display", "table-row"); tr.setStyle("display", "table-row");
if (droppable != null){ if (droppable != null){
tr.inject(dragTr, "after"); tr.inject(dragTr, "after");
dragTr.destroy(); dragTr.destroy();
//this._loadZebraStyle(); //this._loadZebraStyle();
//this._loadSequence(); //this._loadSequence();
//this._loadTotal(); //this._loadTotal();
this._loadDatagridStyle(); this._loadDatagridStyle();
this.getData(); this.getData();
} }
}.bind(this), }.bind(this),
"onEnter": function(dragging, drop){ "onEnter": function(dragging, drop){
...@@ -676,14 +683,14 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -676,14 +683,14 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
dragNode.setStyle("cursor", "move"); dragNode.setStyle("cursor", "move");
}, },
"onCancel": function(dragging){ "onCancel": function(dragging){
dragging.destroy(); dragging.destroy();
var color = tr.retrieve("bgcolor"); var color = tr.retrieve("bgcolor");
if (color){ if (color){
tr.tween("background", color); tr.tween("background", color);
}else{ }else{
tr.tween("background", "transparent"); tr.tween("background", "transparent");
} }
tr.setStyle("display", "table-row"); tr.setStyle("display", "table-row");
} }
}); });
drag.start(e); drag.start(e);
...@@ -691,28 +698,28 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -691,28 +698,28 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
}, },
_loadReadDatagrid: function(){ _loadReadDatagrid: function(){
this.gridData = this._getValue(); this.gridData = this._getValue();
if (!this.titleTr) this._getDatagridTitleTr(); if (!this.titleTr) this._getDatagridTitleTr();
//var titleTr = this.table.getElement("tr"); //var titleTr = this.table.getElement("tr");
var titleHeaders = this.titleTr.getElements("th"); var titleHeaders = this.titleTr.getElements("th");
var lastTrs = this.table.getElements("tr"); var lastTrs = this.table.getElements("tr");
var lastTr = lastTrs[lastTrs.length-1]; var lastTr = lastTrs[lastTrs.length-1];
//var tds = lastTr.getElements("td"); //var tds = lastTr.getElements("td");
if (this.gridData.data){ if (this.gridData.data){
this.gridData.data.each(function(data, idx){ this.gridData.data.each(function(data, idx){
var tr = this.table.insertRow(idx+1); var tr = this.table.insertRow(idx+1);
tr.store("data", data); tr.store("data", data);
titleHeaders.each(function(th, index){ titleHeaders.each(function(th, index){
var cell = tr.insertCell(index); var cell = tr.insertCell(index);
// cell.set("MWFId", tds[index].get("id")); // cell.set("MWFId", tds[index].get("id"));
var cellData = data[th.get("id")]; var cellData = data[th.get("id")];
if (cellData){ if (cellData){
for (key in cellData){ for (key in cellData){
var v = cellData[key]; var v = cellData[key];
var module = this.editModules[index]; var module = this.editModules[index];
if( module && module.json.type == "ImageClipper" ){ if( module && module.json.type == "ImageClipper" ){
...@@ -734,159 +741,159 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -734,159 +741,159 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
// }.bind(this)); // }.bind(this));
// cell.set("text", textArray.join(", ")); // cell.set("text", textArray.join(", "));
// }else if (typeOf(v)==="object"){ // }else if (typeOf(v)==="object"){
// cell.set("text", v.name+((v.unitName) ? "("+v.unitName+")" : "")); // cell.set("text", v.name+((v.unitName) ? "("+v.unitName+")" : ""));
// }else{ // }else{
// cell.set("text", v); // cell.set("text", v);
// } // }
break; break;
} }
}else{ //Sequence }else{ //Sequence
cell.setStyle("text-align", "center"); cell.setStyle("text-align", "center");
cell.set("text", tr.rowIndex); cell.set("text", tr.rowIndex);
} }
}.bind(this));
}.bind(this));
}
}.bind(this));
}.bind(this));
}
//lastTr.destroy();
//lastTr.destroy(); this._loadTotal();
// this._loadSequenceRead();
this._loadTotal();
// this._loadSequenceRead();
}, },
_loadDatagridStyle: function(){ _loadDatagridStyle: function(){
//var ths = this.titleTr.getElements("th"); //var ths = this.titleTr.getElements("th");
//ths.setStyles(this.form.css.datagridTitle); //ths.setStyles(this.form.css.datagridTitle);
this.loadGridTitleStyle(); this.loadGridTitleStyle();
this.loadGridContentStyle(); this.loadGridContentStyle();
this.loadGridActionStyle(); this.loadGridActionStyle();
this.loadGridEditStyle(); this.loadGridEditStyle();
this._loadTotal(); this._loadTotal();
this._loadBorderStyle(); this._loadBorderStyle();
this._loadZebraStyle(); this._loadZebraStyle();
this._loadSequence(); this._loadSequence();
}, },
loadGridEditStyle: function(){ loadGridEditStyle: function(){
if (this.editorTr){ if (this.editorTr){
if (this.json.editStyles){ if (this.json.editStyles){
var tds = this.editorTr.getElements("td"); var tds = this.editorTr.getElements("td");
tds.setStyles(this.json.editStyles); tds.setStyles(this.json.editStyles);
} }
} }
}, },
loadGridActionStyle: function(){ loadGridActionStyle: function(){
if (this.editable!=false){ if (this.editable!=false){
if (this.json.actionStyles){ if (this.json.actionStyles){
var trs = this.table.getElements("tr"); var trs = this.table.getElements("tr");
trs.each(function(tr, idx){ trs.each(function(tr, idx){
if (idx != 0) tr.getFirst().setStyles(this.json.actionStyles); if (idx != 0) tr.getFirst().setStyles(this.json.actionStyles);
}.bind(this)); }.bind(this));
} }
} }
}, },
loadGridTitleStyle: function(){ loadGridTitleStyle: function(){
if (this.json.titleStyles){ if (this.json.titleStyles){
var ths = this.titleTr.getElements("th"); var ths = this.titleTr.getElements("th");
ths.setStyles(this.json.titleStyles); ths.setStyles(this.json.titleStyles);
} }
}, },
loadGridContentStyle: function(){ loadGridContentStyle: function(){
if (this.json.contentStyles){ if (this.json.contentStyles){
var tds = this.table.getElements("td"); var tds = this.table.getElements("td");
tds.setStyles(this.json.contentStyles); tds.setStyles(this.json.contentStyles);
} }
}, },
_loadZebraStyle: function(){ _loadZebraStyle: function(){
var trs = this.table.getElements("tr"); var trs = this.table.getElements("tr");
for (var i=1; i<trs.length; i++){ for (var i=1; i<trs.length; i++){
if (!trs[i].hasClass("datagridTotalTr")){ if (!trs[i].hasClass("datagridTotalTr")){
if (this.json.backgroundColor) trs[i].setStyle("background-color", this.json.backgroundColor); if (this.json.backgroundColor) trs[i].setStyle("background-color", this.json.backgroundColor);
if ((i%2)==0){ if ((i%2)==0){
if (this.json.zebraColor) trs[i].setStyle("background-color", this.json.zebraColor); if (this.json.zebraColor) trs[i].setStyle("background-color", this.json.zebraColor);
} }
} }
}
},
createTotalTr: function(){
var trs = this.node.getElements("tr");
var lastTr = trs[trs.length-1];
this.totalTr = new Element("tr.datagridTotalTr", {"styles": this.form.css.datagridTotalTr}).inject(lastTr, "after");
var ths = this.node.getElements("th");
ths.each(function(th, idx){
var td = new Element("td", {"text": "", "styles": this.form.css.datagridTotalTd}).inject(this.totalTr);
if (this.json.amountStyles) td.setStyles(this.json.amountStyles);
}.bind(this));
},
_loadTotal: function(){
var data = {};
this.totalResaults = {};
if (this.totalModules.length){
if (!this.totalTr){
this.createTotalTr();
}
var totalResaults = [];
//this.totalModules.each(function(m. i){
// totalResaults.push(0);
//}.bind(this));
var trs = this.table.getElements("tr");
var totalTds = this.totalTr.getElements("td");
for (var i=1; i<trs.length; i++){
if (!trs[i].hasClass("datagridTotalTr") && (!trs[i].hasClass("datagridEditorTr"))){
var cells = trs[i].getElements("td");
this.totalModules.each(function(m, i){
if (!totalResaults[i]) totalResaults.push(0);
var tmpV = new Decimal(totalResaults[i]);
if (m.type=="number"){
var cell = cells[m.index];
var addv = cell.get("text").toFloat();
tmpV = tmpV.plus(addv||0);
//tmpV = tmpV + addv;
}
if (m.type=="count"){
tmpV = tmpV.plus(1);
//tmpV = tmpV+1;
}
totalResaults[i] = tmpV.toString();
data[m.module.json.id] = totalResaults[i];
}.bind(this));
}
}
this.totalModules.each(function(m, i){
this.totalResaults[m.module.json.id] = totalResaults[i];
var td = totalTds[m.index];
td.set("text", isNaN( totalResaults[i] ) ? "" : totalResaults[i] );
}.bind(this));
}
return data;
},
_loadSequence: function(){
var trs = this.table.getElements("tr");
for (var i=1; i<trs.length; i++){
var cells = trs[i].getElements("td");
cells.each(function(cell){
var module = cell.retrieve("module");
if (module){
if (module.json.cellType=="sequence"){
cell.set("text", i)
}
}
}.bind(this));
} }
}, },
createTotalTr: function(){
var trs = this.node.getElements("tr");
var lastTr = trs[trs.length-1];
this.totalTr = new Element("tr.datagridTotalTr", {"styles": this.form.css.datagridTotalTr}).inject(lastTr, "after");
var ths = this.node.getElements("th");
ths.each(function(th, idx){
var td = new Element("td", {"text": "", "styles": this.form.css.datagridTotalTd}).inject(this.totalTr);
if (this.json.amountStyles) td.setStyles(this.json.amountStyles);
}.bind(this));
},
_loadTotal: function(){
var data = {};
this.totalResaults = {};
if (this.totalModules.length){
if (!this.totalTr){
this.createTotalTr();
}
var totalResaults = [];
//this.totalModules.each(function(m. i){
// totalResaults.push(0);
//}.bind(this));
var trs = this.table.getElements("tr");
var totalTds = this.totalTr.getElements("td");
for (var i=1; i<trs.length; i++){
if (!trs[i].hasClass("datagridTotalTr") && (!trs[i].hasClass("datagridEditorTr"))){
var cells = trs[i].getElements("td");
this.totalModules.each(function(m, i){
if (!totalResaults[i]) totalResaults.push(0);
var tmpV = new Decimal(totalResaults[i]);
if (m.type=="number"){
var cell = cells[m.index];
var addv = cell.get("text").toFloat();
tmpV = tmpV.plus(addv||0);
//tmpV = tmpV + addv;
}
if (m.type=="count"){
tmpV = tmpV.plus(1);
//tmpV = tmpV+1;
}
totalResaults[i] = tmpV.toString();
data[m.module.json.id] = totalResaults[i];
}.bind(this));
}
}
this.totalModules.each(function(m, i){
this.totalResaults[m.module.json.id] = totalResaults[i];
var td = totalTds[m.index];
td.set("text", isNaN( totalResaults[i] ) ? "" : totalResaults[i] );
}.bind(this));
}
return data;
},
_loadSequence: function(){
var trs = this.table.getElements("tr");
for (var i=1; i<trs.length; i++){
var cells = trs[i].getElements("td");
cells.each(function(cell){
var module = cell.retrieve("module");
if (module){
if (module.json.cellType=="sequence"){
cell.set("text", i)
}
}
}.bind(this));
}
},
_loadBorderStyle: function(){ _loadBorderStyle: function(){
if (this.json.border){ if (this.json.border){
this.table.setStyles({ this.table.setStyles({
...@@ -909,13 +916,13 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -909,13 +916,13 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
_loadDatagridTitleModules: function(){ _loadDatagridTitleModules: function(){
var ths = this.node.getElements("th"); var ths = this.node.getElements("th");
ths.each(function(th){ ths.each(function(th){
var json = this.form._getDomjson(th); var json = this.form._getDomjson(th);
th.store("dataGrid", this); th.store("dataGrid", this);
if (json){ if (json){
var module = this.form._loadModule(json, th); var module = this.form._loadModule(json, th);
this.form.modules.push(module); this.form.modules.push(module);
} }
}.bind(this)); }.bind(this));
}, },
_loadDatagridDataModules: function(){ _loadDatagridDataModules: function(){
var tds = this.node.getElements("td"); var tds = this.node.getElements("td");
...@@ -924,8 +931,8 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -924,8 +931,8 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
td.store("dataGrid", this); td.store("dataGrid", this);
if (json){ if (json){
var module = this.form._loadModule(json, td, function(){ var module = this.form._loadModule(json, td, function(){
this.field = false; this.field = false;
}); });
td.store("module", module); td.store("module", module);
this.form.modules.push(module); this.form.modules.push(module);
} }
...@@ -934,19 +941,19 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -934,19 +941,19 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
_afterLoaded: function(){ _afterLoaded: function(){
this._loadDatagridStyle(); this._loadDatagridStyle();
}, },
resetData: function(){ resetData: function(){
this.setData(this._getValue()); this.setData(this._getValue());
}, },
setData: function(data){ setData: function(data){
// if( typeOf( data ) === "object" && typeOf(data.data) === "array" ){ // if( typeOf( data ) === "object" && typeOf(data.data) === "array" ){
if (data){ if (data){
this._setBusinessData(data); this._setBusinessData(data);
this.gridData = data; this.gridData = data;
}else{ }else{
this.gridData = this._getValue(); this.gridData = this._getValue();
} }
// if (this.isEdit) this._completeLineEdit(); // if (this.isEdit) this._completeLineEdit();
if( this.isEdit ){ //如果有在编辑的,取消编辑行 if( this.isEdit ){ //如果有在编辑的,取消编辑行
if (this.currentEditLine) { if (this.currentEditLine) {
this.currentEditLine.setStyle("display", "table-row"); this.currentEditLine.setStyle("display", "table-row");
...@@ -956,44 +963,44 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -956,44 +963,44 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
this._editorTrGoBack(); this._editorTrGoBack();
} }
if (this.gridData){ if (this.gridData){
var trs = this.table.getElements("tr"); var trs = this.table.getElements("tr");
for (var i=1; i<trs.length-1; i++){ for (var i=1; i<trs.length-1; i++){
var tr = trs[i]; var tr = trs[i];
if( tr.hasClass("datagridEditorTr") )continue; if( tr.hasClass("datagridEditorTr") )continue;
var tds = tr.getElements("td"); var tds = tr.getElements("td");
for (var j=0; j<tds.length; j++){ for (var j=0; j<tds.length; j++){
var td = tds[j]; var td = tds[j];
var module = td.retrieve("module"); var module = td.retrieve("module");
if (module){ if (module){
this.form.modules.erase(module); this.form.modules.erase(module);
delete module; delete module;
} }
} }
} }
for (var i=1; i<trs.length-1; i++){ for (var i=1; i<trs.length-1; i++){
if( trs[i].hasClass("datagridTotalTr") )continue; if( trs[i].hasClass("datagridTotalTr") )continue;
if( trs[i].hasClass("datagridEditorTr") )continue; if( trs[i].hasClass("datagridEditorTr") )continue;
trs[i].destroy(); trs[i].destroy();
} }
//while (this.table.rows.length>2){ //while (this.table.rows.length>2){
//this.table.rows[1].destroy(); //this.table.rows[1].destroy();
//} //}
if (this.editable!=false){ if (this.editable!=false){
this._loadEditDatagrid(); this._loadEditDatagrid();
//this._loadReadDatagrid(); //this._loadReadDatagrid();
}else{ }else{
this._loadReadDatagrid(); this._loadReadDatagrid();
} }
this._loadDatagridStyle(); this._loadDatagridStyle();
} }
}, },
getTotal: function(){ getTotal: function(){
this._loadTotal(); this._loadTotal();
return this.totalResaults; return this.totalResaults;
}, },
isEmpty: function(){ isEmpty: function(){
var data = this.getData(); var data = this.getData();
if( !data )return true; if( !data )return true;
...@@ -1004,195 +1011,195 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ ...@@ -1004,195 +1011,195 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
return false; return false;
}, },
getData: function(){ getData: function(){
if (this.editable!=false){ if (this.editable!=false){
if (this.isEdit) this._completeLineEdit(); if (this.isEdit) this._completeLineEdit();
var data = []; var data = [];
var trs = this.table.getElements("tr"); var trs = this.table.getElements("tr");
for (var i=1; i<trs.length-1; i++){ for (var i=1; i<trs.length-1; i++){
var tr = trs[i]; var tr = trs[i];
var d = tr.retrieve("data"); var d = tr.retrieve("data");
if (d) data.push(d); if (d) data.push(d);
} }
this.gridData = {}; this.gridData = {};
this.gridData.data = data; this.gridData.data = data;
this._loadTotal(); this._loadTotal();
this.gridData.total = this.totalResaults; this.gridData.total = this.totalResaults;
this._setBusinessData(this.gridData); this._setBusinessData(this.gridData);
return (this.gridData.data.length) ? this.gridData : {data:[]}; return (this.gridData.data.length) ? this.gridData : {data:[]};
}else{ }else{
return this._getBusinessData(); return this._getBusinessData();
} }
},
getAmount: function(){
return this._loadTotal();
},
createErrorNode: function(text){
var node = new Element("div");
var iconNode = new Element("div", {
"styles": {
"width": "20px",
"height": "20px",
"float": "left",
"background": "url("+"../x_component_process_Xform/$Form/default/icon/error.png) center center no-repeat"
}
}).inject(node);
var textNode = new Element("div", {
"styles": {
"line-height": "20px",
"margin-left": "20px",
"color": "red",
"word-break": "keep-all"
},
"text": text
}).inject(node);
return node;
},
notValidationMode: function(text){
if (!this.isNotValidationMode){
this.isNotValidationMode = true;
this.node.store("borderStyle", this.node.getStyles("border-left", "border-right", "border-top", "border-bottom"));
this.node.setStyle("border", "1px solid red");
this.errNode = this.createErrorNode(text).inject(this.node, "after");
this.showNotValidationMode(this.node);
}
},
showNotValidationMode: function(node){
var p = node.getParent("div");
if (p){
if (p.get("MWFtype") == "tab$Content"){
if (p.getParent("div").getStyle("display")=="none"){
var contentAreaNode = p.getParent("div").getParent("div");
var tabAreaNode = contentAreaNode.getPrevious("div");
var idx = contentAreaNode.getChildren().indexOf(p.getParent("div"));
var tabNode = tabAreaNode.getLast().getFirst().getChildren()[idx];
tabNode.click();
p = tabAreaNode.getParent("div");
}
}
this.showNotValidationMode(p);
}
}, },
getAmount: function(){ validationMode: function(){
return this._loadTotal(); if (this.isNotValidationMode){
}, this.isNotValidationMode = false;
createErrorNode: function(text){ this.node.setStyles(this.node.retrieve("borderStyle"));
var node = new Element("div"); if (this.errNode){
var iconNode = new Element("div", { this.errNode.destroy();
"styles": { this.errNode = null;
"width": "20px", }
"height": "20px", }
"float": "left", },
"background": "url("+"../x_component_process_Xform/$Form/default/icon/error.png) center center no-repeat"
} validationConfigItem: function(routeName, data){
}).inject(node); var flag = (data.status=="all") ? true: (routeName == data.decision);
var textNode = new Element("div", { if (flag){
"styles": { var n = this.getData();
"line-height": "20px",
"margin-left": "20px",
"color": "red",
"word-break": "keep-all"
},
"text": text
}).inject(node);
return node;
},
notValidationMode: function(text){
if (!this.isNotValidationMode){
this.isNotValidationMode = true;
this.node.store("borderStyle", this.node.getStyles("border-left", "border-right", "border-top", "border-bottom"));
this.node.setStyle("border", "1px solid red");
this.errNode = this.createErrorNode(text).inject(this.node, "after");
this.showNotValidationMode(this.node);
}
},
showNotValidationMode: function(node){
var p = node.getParent("div");
if (p){
if (p.get("MWFtype") == "tab$Content"){
if (p.getParent("div").getStyle("display")=="none"){
var contentAreaNode = p.getParent("div").getParent("div");
var tabAreaNode = contentAreaNode.getPrevious("div");
var idx = contentAreaNode.getChildren().indexOf(p.getParent("div"));
var tabNode = tabAreaNode.getLast().getFirst().getChildren()[idx];
tabNode.click();
p = tabAreaNode.getParent("div");
}
}
this.showNotValidationMode(p);
}
},
validationMode: function(){
if (this.isNotValidationMode){
this.isNotValidationMode = false;
this.node.setStyles(this.node.retrieve("borderStyle"));
if (this.errNode){
this.errNode.destroy();
this.errNode = null;
}
}
},
validationConfigItem: function(routeName, data){
var flag = (data.status=="all") ? true: (routeName == data.decision);
if (flag){
var n = this.getData();
if( typeOf(n)==="object" && JSON.stringify(n) === JSON.stringify({data:[]}) )n = ""; if( typeOf(n)==="object" && JSON.stringify(n) === JSON.stringify({data:[]}) )n = "";
var v = (data.valueType=="value") ? n : n.length; var v = (data.valueType=="value") ? n : n.length;
switch (data.operateor){ switch (data.operateor){
case "isnull": case "isnull":
if (!v){ if (!v){
this.notValidationMode(data.prompt); this.notValidationMode(data.prompt);
return false; return false;
} }
break; break;
case "notnull": case "notnull":
if (v){ if (v){
this.notValidationMode(data.prompt); this.notValidationMode(data.prompt);
return false; return false;
} }
break; break;
case "gt": case "gt":
if (v>data.value){ if (v>data.value){
this.notValidationMode(data.prompt); this.notValidationMode(data.prompt);
return false; return false;
} }
break; break;
case "lt": case "lt":
if (v<data.value){ if (v<data.value){
this.notValidationMode(data.prompt); this.notValidationMode(data.prompt);
return false; return false;
} }
break; break;
case "equal": case "equal":
if (v==data.value){ if (v==data.value){
this.notValidationMode(data.prompt); this.notValidationMode(data.prompt);
return false; return false;
} }
break; break;
case "neq": case "neq":
if (v!=data.value){ if (v!=data.value){
this.notValidationMode(data.prompt); this.notValidationMode(data.prompt);
return false; return false;
} }
break; break;
case "contain": case "contain":
if (v.indexOf(data.value)!=-1){ if (v.indexOf(data.value)!=-1){
this.notValidationMode(data.prompt); this.notValidationMode(data.prompt);
return false; return false;
} }
break; break;
case "notcontain": case "notcontain":
if (v.indexOf(data.value)==-1){ if (v.indexOf(data.value)==-1){
this.notValidationMode(data.prompt); this.notValidationMode(data.prompt);
return false; return false;
} }
break; break;
} }
} }
return true; return true;
}, },
validationConfig: function(routeName, opinion){ validationConfig: function(routeName, opinion){
if (this.json.validationConfig){ if (this.json.validationConfig){
if (this.json.validationConfig.length){ if (this.json.validationConfig.length){
for (var i=0; i<this.json.validationConfig.length; i++) { for (var i=0; i<this.json.validationConfig.length; i++) {
var data = this.json.validationConfig[i]; var data = this.json.validationConfig[i];
if (!this.validationConfigItem(routeName, data)) return false; if (!this.validationConfigItem(routeName, data)) return false;
} }
} }
return true; return true;
} }
return true; return true;
}, },
validation: function(routeName, opinion){ validation: function(routeName, opinion){
if (this.isEdit){ if (this.isEdit){
if (!this.editValidation()){ if (!this.editValidation()){
return false; return false;
} }
} }
if (!this.validationConfig(routeName, opinion)) return false; if (!this.validationConfig(routeName, opinion)) return false;
if (!this.json.validation) return true; if (!this.json.validation) return true;
if (!this.json.validation.code) return true; if (!this.json.validation.code) return true;
var flag = this.form.Macro.exec(this.json.validation.code, this); var flag = this.form.Macro.exec(this.json.validation.code, this);
if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation; if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
if (flag.toString()!="true"){ if (flag.toString()!="true"){
this.notValidationMode(flag); this.notValidationMode(flag);
return false; return false;
} }
return true; return true;
} }
}); });
MWF.xApplication.process.Xform.DatagridPC$Title = new Class({ MWF.xApplication.process.Xform.DatagridPC$Title = new Class({
Extends: MWF.APP$Module, Extends: MWF.APP$Module,
_afterLoaded: function(){ _afterLoaded: function(){
this.dataGrid = this.node.retrieve("dataGrid"); this.dataGrid = this.node.retrieve("dataGrid");
if ((this.json.total == "number") || (this.json.total == "count")){ if ((this.json.total == "number") || (this.json.total == "count")){
this.dataGrid.totalModules.push({ this.dataGrid.totalModules.push({
"module": this, "module": this,
"index": (this.dataGrid.editable!=false) ? this.node.cellIndex+1 : this.node.cellIndex, "index": (this.dataGrid.editable!=false) ? this.node.cellIndex+1 : this.node.cellIndex,
"type": this.json.total "type": this.json.total
}) })
} }
// this.form._loadModules(this.node); // this.form._loadModules(this.node);
} }
}); });
MWF.xApplication.process.Xform.DatagridPC$Data = new Class({ MWF.xApplication.process.Xform.DatagridPC$Data = new Class({
...@@ -1201,33 +1208,33 @@ MWF.xApplication.process.Xform.DatagridPC$Data = new Class({ ...@@ -1201,33 +1208,33 @@ MWF.xApplication.process.Xform.DatagridPC$Data = new Class({
//this.form._loadModules(this.node); //this.form._loadModules(this.node);
this.dataGrid = this.node.retrieve("dataGrid"); this.dataGrid = this.node.retrieve("dataGrid");
var td = this.node; var td = this.node;
if (this.json.cellType == "sequence"){ if (this.json.cellType == "sequence"){
var flag = true; var flag = true;
for (var i=0; i<this.dataGrid.editModules.length; i++){ for (var i=0; i<this.dataGrid.editModules.length; i++){
if (this.dataGrid.editModules[i].json.id == this.json.id){ if (this.dataGrid.editModules[i].json.id == this.json.id){
flag = false; flag = false;
break; break;
} }
} }
if (flag){ if (flag){
this.dataGrid.editModules.push({ this.dataGrid.editModules.push({
"json": {"type": "sequence", "id": this.json.id}, "json": {"type": "sequence", "id": this.json.id},
"node": td , "node": td ,
"focus": function(){} "focus": function(){}
}); });
} }
}else{ }else{
var moduleNodes = this.form._getModuleNodes(this.node); var moduleNodes = this.form._getModuleNodes(this.node);
moduleNodes.each(function(node){ moduleNodes.each(function(node){
var json = this.form._getDomjson(node); var json = this.form._getDomjson(node);
var module = this.form._loadModule(json, node, function(){ var module = this.form._loadModule(json, node, function(){
this.field = false; this.field = false;
}); });
module.dataModule = this; module.dataModule = this;
this.dataGrid.editModules.push(module); this.dataGrid.editModules.push(module);
}.bind(this)); }.bind(this));
} }
} }
}); });
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册