提交 8a94ee96 编写于 作者: NoSubject's avatar NoSubject

Merge branch 'cherry-pick-3e09e4b6' into 'master'

允许elementUI组件用于数据表格

See merge request o2oa/o2oa!339
......@@ -62,3 +62,11 @@ if (!Array.prototype.findIndex) {
}
});
}
if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, 'startsWith', {
value: function(search, pos) {
pos = !pos || pos < 0 ? 0 : +pos;
return this.substring(pos, pos + search.length) === search;
}
});
}
\ No newline at end of file
......@@ -22,7 +22,8 @@ MWF.xApplication.process.FormDesigner.Module.Datatable$Data = MWF.FCDatatable$Da
}
],
"allowModules": ["textfield", "number", "personfield", "orgfield", "org", "calendar", "textarea", "select", "radio", "checkbox", "combox", "image", "label",
"htmleditor", "tinymceeditor", "button","imageclipper", "address", "attachment", "elinput", "elcheckbox", "elselect"]
"htmleditor", "tinymceeditor", "button","imageclipper", "address", "attachment", "elinput", "elcheckbox", "elselect", "elautocomplete", "elnumber", "elradio", "elcascader",
"elswitch", "elslider", "eltime", "eldate", "eldatetime", "elrate"]
},
initialize: function(form, options){
......
......@@ -20,6 +20,13 @@
<input type="radio" name="isReadonly" value="false" text{(!$.isReadonly)?'checked':''}/>{{$.lp.no}}
</td>
</tr>
<tr>
<td class="editTableTitle">{{$.lp.el_disabled}}:</td>
<td class="editTableValue">
<input type="radio" name="disabled" value="true" text{($.disabled)?'checked':''}/>{{$.lp.yes}}
<input type="radio" name="disabled" value="false" text{(!$.disabled)?'checked':''}/>{{$.lp.no}}
</td>
</tr>
</table>
<div style="text-align: center; height:24px; padding-left: 5px; line-height: 24px; background-color: #EEE; border-bottom: 1px solid #ccc; border-top: 1px solid #999;font-weight:bold;">{{$.lp.options}}</div>
<div style="border-bottom: 1px solid #cccccc">
......
......@@ -20,6 +20,14 @@
<input type="radio" name="isReadonly" value="false" text{(!$.isReadonly)?'checked':''}/>{{$.lp.no}}
</td>
</tr>
<tr>
<td class="editTableTitle">{{$.lp.el_disabled}}:</td>
<td class="editTableValue">
<input type="radio" name="disabled" value="true" text{($.disabled)?'checked':''}/>{{$.lp.yes}}
<input type="radio" name="disabled" value="false" text{(!$.disabled)?'checked':''}/>{{$.lp.no}}
</td>
</tr>
</table>
<div style="text-align: center; height:24px; padding-left: 5px; line-height: 24px; background-color: #EEE; border-bottom: 1px solid #ccc; border-top: 1px solid #999;font-weight:bold;">{{$.lp.options}}</div>
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
......
......@@ -20,6 +20,13 @@
<input type="radio" name="isReadonly" value="false" text{(!$.isReadonly)?'checked':''}/>{{$.lp.no}}
</td>
</tr>
<tr>
<td class="editTableTitle">{{$.lp.el_disabled}}:</td>
<td class="editTableValue">
<input type="radio" name="disabled" value="true" text{($.disabled)?'checked':''}/>{{$.lp.yes}}
<input type="radio" name="disabled" value="false" text{(!$.disabled)?'checked':''}/>{{$.lp.no}}
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
......
......@@ -20,6 +20,13 @@
<input type="radio" name="isReadonly" value="false" text{(!$.isReadonly)?'checked':''}/>{{$.lp.no}}
</td>
</tr>
<tr>
<td class="editTableTitle">{{$.lp.el_disabled}}:</td>
<td class="editTableValue">
<input type="radio" name="disabled" value="true" text{($.disabled)?'checked':''}/>{{$.lp.yes}}
<input type="radio" name="disabled" value="false" text{(!$.disabled)?'checked':''}/>{{$.lp.no}}
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
......
......@@ -57,10 +57,10 @@ MWF.xApplication.process.Xform.Elcascader = MWF.APPElcascader = new Class(
*/
"elEvents": ["focus", "blur", "change", "visible-change", "remove-tag", "expand-change", "before-filter"]
},
_loadNode: function(){
if (this.isReadonly()) this.json.disabled = true;
this._loadNodeEdit();
},
// _loadNode: function(){
// if (this.isReadonly()) this.json.disabled = true;
// this._loadNodeEdit();
// },
_appendVueData: function(){
this.form.Macro.environment.data.check(this.json.id);
this.json[this.json.id] = this._getBusinessData();
......@@ -90,7 +90,8 @@ MWF.xApplication.process.Xform.Elcascader = MWF.APPElcascader = new Class(
this._loadOptions();
if (this.json.props.multiple===true) if (!this.json[this.json.id] || !this.json[this.json.id].length) this.json[this.json.id] = [];
//if (this.json.props.multiple===true) if (!this.json[this.json.id] || !this.json[this.json.id].length) this.json[this.json.id] = [];
if (this.json.props.multiple===true) if (!this.json[this.json.$id] || !this.json[this.json.$id].length) this.json[this.json.$id] = [];
},
appendVueMethods: function(methods){
if (this.json.filterMethod && this.json.filterMethod.code){
......@@ -144,7 +145,7 @@ MWF.xApplication.process.Xform.Elcascader = MWF.APPElcascader = new Class(
if (!this.json.props) this.json.props = {};
var html = "<el-cascader ";
html += " v-model=\""+this.json.id+"\"";
html += " v-model=\""+this.json.$id+"\"";
html += " :clearable=\"clearable\"";
html += " :size=\"size\"";
html += " :filterable=\"filterable\"";
......@@ -182,8 +183,51 @@ MWF.xApplication.process.Xform.Elcascader = MWF.APPElcascader = new Class(
html += "</el-cascader >";
return html;
},
__setReadonly: function(data){},
//__setReadonly: function(data){},
getCheckedNodes: function(leafOnly){
return (this.vm) ? this.vm.getCheckedNodes(leafOnly) : null;
},
__setReadonly: function(data){
if (this.isReadonly()){
this._loadOptions();
Promise.resolve(this.json.options).then(function(options){
if (data){
var text = this.__getOptionsText(options, data);
this.node.set("text", text);
}
}.bind(this));
}
},
__getOptionsText: function(options, values){
debugger;
if (!!this.json.props.multiple){
var text = [];
values.forEach(function(v){
text = text.concat(this.__getOptionsTextValue(options, v));
}.bind(this));
return text.join(",")
}else{
return this.__getOptionsTextValue(options, values).join(",");
}
},
__getOptionsTextValue: function(options, values, prefix, prefixLabel){
var text = [];
var v = values.join("/");
options.forEach(function(op){
var opValue = (prefix) ? prefix + "/" + op[this.json.props.value] : op[this.json.props.value];
var opLabel = (prefixLabel) ? prefixLabel + "/" + op[this.json.props.label] : op[this.json.props.label];
if (opValue == v) {
text.push(opLabel);
}else if (v.startsWith(opValue) && op[this.json.props.children] && op[this.json.props.children].length){
text = text.concat(this.__getOptionsTextValue(op[this.json.props.children], values, opValue, opLabel));
}
}.bind(this));
if (!this.json.showAllLevels){
return text.map(function(t){
return t.substring(t.indexOf("/")+1, t.length);
});
}else{
return text;
}
}
});
......@@ -27,11 +27,11 @@ MWF.xApplication.process.Xform.Elrate = MWF.APPElrate = new Class(
*/
"elEvents": ["change"]
},
_loadNode: function(){
debugger;
if (this.isReadonly()) this.json.disabled = true;
this._loadNodeEdit();
},
// _loadNode: function(){
// debugger;
// if (this.isReadonly()) this.json.disabled = true;
// this._loadNodeEdit();
// },
_appendVueData: function(){
if (!this.json.max) this.json.max = "";
if (!this.json.isReadonly) this.json.isReadonly = false;
......
......@@ -52,10 +52,10 @@ MWF.xApplication.process.Xform.Elselect = MWF.APPElselect = new Class(
*/
"elEvents": ["focus", "blur", "change", "visible-change", "remove-tag", "clear"]
},
_loadNode: function(){
if (this.isReadonly()) this.json.disabled = true;
this._loadNodeEdit();
},
// _loadNode: function(){
// if (this.isReadonly()) this.json.disabled = true;
// this._loadNodeEdit();
// },
_appendVueData: function(){
// this.form.Macro.environment.data.check(this.json.id);
// this.json[this.json.id] = this._getBusinessData();
......@@ -216,32 +216,52 @@ MWF.xApplication.process.Xform.Elselect = MWF.APPElselect = new Class(
html += "</el-select>";
return html;
},
_afterLoaded: function(){
// _afterLoaded: function(){
// if (this.isReadonly()){
// this.node.hide();
// window.setTimeout(function(){
// var text = "";
// var nodes = this.node.getElements(".el-select__tags-text");
// if (nodes && nodes.length){
// nodes.forEach(function(n){
// text += ((text) ? ", " : "")+n.get("text");
// });
// }
// var node = new Element("div").inject(this.node, "before");
// this.node.destroy();
// this.node = node;
// this.node.set({
// "nodeId": this.json.id,
// "MWFType": this.json.type
// });
// this._loadDomEvents();
// //this.node.removeEvents("click");
// //this.node.empty();
// this.node.set("text", text);
// //this.node.show();
// }.bind(this), 20);
//
// }
// },
__setReadonly: function(data){
if (this.isReadonly()){
this.node.hide();
window.setTimeout(function(){
var text = "";
var nodes = this.node.getElements(".el-select__tags-text");
if (nodes && nodes.length){
nodes.forEach(function(n){
text += ((text) ? ", " : "")+n.get("text");
});
}
var node = new Element("div").inject(this.node, "before");
this.node.destroy();
this.node = node;
this.node.set({
"nodeId": this.json.id,
"MWFType": this.json.type
});
this._loadDomEvents();
//this.node.removeEvents("click");
//this.node.empty();
this.node.set("text", text);
//this.node.show();
}.bind(this), 20);
this._loadOptions();
Promise.resolve(this.json.options).then(function(options){
var values = (o2.typeOf(data) !== "array") ? [data] : data;
var text = this.__getOptionsText(options, values);
this.node.set("text", text.join(","));
}.bind(this));
}
},
__setReadonly: function(data){}
__getOptionsText: function(options, values){
var text = [];
options.forEach(function(op){
if (op.value){
if (values.indexOf(op.value)!=-1) text.push(op.label || op.value);
}else if (op.options && op.options.length){
text = text.concat(this.__getOptionsText(op.options, values));
}
}.bind(this));
return text;
}
});
......@@ -43,10 +43,10 @@ MWF.xApplication.process.Xform.Elslider = MWF.APPElslider = new Class(
* //通过json对象操作Element组件
* json.disabled = true; //设置输入框为禁用
*/
_loadNode: function(){
if (this.isReadonly()) this.json.disabled = true;
this._loadNodeEdit();
},
// _loadNode: function(){
// if (this.isReadonly()) this.json.disabled = true;
// this._loadNodeEdit();
// },
_appendVueData: function(){
this.form.Macro.environment.data.check(this.json.id);
this.json[this.json.id] = this._getBusinessData();
......@@ -97,7 +97,7 @@ MWF.xApplication.process.Xform.Elslider = MWF.APPElslider = new Class(
},
_createElementHtml: function(){
var html = "<el-slider";
html += " v-model=\""+this.json.id+"\"";
html += " v-model=\""+this.json.$id+"\"";
html += " :max=\"max\"";
html += " :min=\"min\"";
html += " :step=\"step\"";
......@@ -140,6 +140,8 @@ MWF.xApplication.process.Xform.Elslider = MWF.APPElslider = new Class(
html += ">";
html += "</el-slider>";
return html;
},
__setReadonly: function(data){}
}
// __setReadonly: function(data){
//
// }
});
......@@ -38,11 +38,11 @@ MWF.xApplication.process.Xform.Elswitch = MWF.APPElswitch = new Class(
* //通过json对象操作Element组件
* json.disabled = true; //设置输入框为禁用
*/
_loadNode: function(){
debugger;
if (this.isReadonly()) this.json.disabled = true;
this._loadNodeEdit();
},
// _loadNode: function(){
// debugger;
// if (this.isReadonly()) this.json.disabled = true;
// this._loadNodeEdit();
// },
_appendVueData: function(){
debugger;
this.form.Macro.environment.data.check(this.json.id);
......@@ -94,7 +94,7 @@ MWF.xApplication.process.Xform.Elswitch = MWF.APPElswitch = new Class(
// },
_createElementHtml: function(){
var html = "<el-switch";
html += " v-model=\""+this.json.id+"\"";
html += " v-model=\""+this.json.$id+"\"";
html += " :width=\"width\"";
html += " :active-text=\"activeText\"";
html += " :inactive-text=\"inactiveText\"";
......@@ -133,5 +133,13 @@ MWF.xApplication.process.Xform.Elswitch = MWF.APPElswitch = new Class(
html += "</el-switch>";
return html;
},
__setReadonly: function(data){}
__setReadonly: function(data){
if (this.isReadonly()){
if (data==="" || data){
this.node.set("text", (this.json.activeText || "true"));
}else{
this.node.set("text", (this.json.inactiveText || "false"));
}
}
}
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册