2016-10-20 17:55:29 +08:00
|
|
|
|
(function ($) {
|
|
|
|
|
DataEntity = function (options) {
|
|
|
|
|
this.options = $.extend({ map: {} }, options);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
DataEntity.VERSION = "1.0";
|
|
|
|
|
DataEntity.Author = "Argo Zhang";
|
|
|
|
|
DataEntity.Email = "argo@163.com";
|
|
|
|
|
|
|
|
|
|
DataEntity.prototype = {
|
|
|
|
|
load: function (value) {
|
|
|
|
|
for (name in this.options.map) {
|
2016-11-08 11:08:10 +08:00
|
|
|
|
var ctl = $("#" + this.options.map[name]);
|
|
|
|
|
if (ctl.hasClass('selectpicker')) ctl.selectpicker('val', value[name]);
|
|
|
|
|
else ctl.val(value[name]);
|
2016-10-20 17:55:29 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
reset: function () {
|
|
|
|
|
for (name in this.options.map) {
|
2016-11-08 16:31:23 +08:00
|
|
|
|
var ctl = $("#" + this.options.map[name]);
|
|
|
|
|
if (ctl.hasClass('selectpicker')) ctl.selectpicker('val', "");
|
|
|
|
|
else ctl.val("");
|
2016-10-20 17:55:29 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
get: function () {
|
|
|
|
|
var target = {};
|
|
|
|
|
for (name in this.options.map) {
|
2016-11-08 16:31:23 +08:00
|
|
|
|
var ctl = $("#" + this.options.map[name]);
|
|
|
|
|
if (ctl.hasClass('selectpicker')) target[name] = ctl.selectpicker('val');
|
|
|
|
|
else target[name] = ctl.val();
|
2016-10-20 17:55:29 +08:00
|
|
|
|
}
|
|
|
|
|
return target;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}(jQuery));
|