Reply_wev8.js
3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
define(['mUtil', "Component"],function(mUtil, Component) {
var Reply = function(options) {
Component.super(this, options);
this.type = "Reply";
this.tpl = this.type + "_html";
this.css = this.type + "_css";
var vm = this.viewModel = {
btnName : "",//按钮名称
isShow : true,//是否显示
autoSave : true,//自动保存
actionUrl : "",//手动保存提交url
tablename : "",
datasource : "",
placeholder : "",
modelid : "",
params : [],
callback : null
};
this.mounted = function(){
var that = this;
var type = this.type;
var $abbr = this.$el,
$page = this.$container,
$comp = $abbr.children(".wev-comp-" + type);
this.$once("moveComponent", function() {
var $pageFooter = $page.children(".page-footer"),
$pageContent = $page.children(".page-content");
if (!$pageFooter.length) {
$pageFooter = $("<div class=\"page-footer\"></div>");
$pageContent.after($pageFooter);
}
if (!$abbr.parent().hasClass("page-footer")) {
$abbr.find("script").remove();
$pageFooter.append($abbr).show();
}
if (vm.isShow == true) {// 默认显示
$comp.show();
}
if ($pageFooter.height()) {
$pageFooter.attr("footer-height", $pageFooter.height());
$pageContent.css("bottom", $pageFooter.height() + "px");
} else {
if ($pageFooter.attr("footer-height")) {
$pageContent.css("bottom", $pageFooter.attr("footer-height") + "px");
} else {
$pageContent.css("bottom", "0px");
}
}
});
var $btn = $(".wev-reply-btn", $comp);
$btn.click(function(e){
if (!$(".wev-reply-content", $comp).val()){
mUtil.getLabel(5284, "内容不能为空",function(msg){
Mobile_NS.msg(msg);
});
return;
}
if($btn.hasClass("disabled")) return;
var $form = $(".wev-reply-form", $comp);
var actionUrl = vm.autoSave ? mUtil.getActionUrl(type, {action : "saveReplyData"}, that.pageid) : vm.actionUrl;
var data = $form.serialize();
$btn.addClass("disabled");
mUtil.getJSON(actionUrl, data, function(res) {
$form[0].reset();
vm.callback && mUtil.eval(vm.callback, that.pageid);
$btn.removeClass("disabled");
}, function(errMsg) {
mUtil.getLabel(4710, "保存失败",function(msg){
Mobile_NS.msg(errMsg || msg);
});
$btn.removeClass("disabled");
});
e.stopPropagation();
});
};
/*先暂时不要这三个方法。
Mobile_NS.replyPageHide = function(){
$comp.hide();
};
Mobile_NS.replyPageShow = function(callbackFn, jsonObj){
_callback = callbackFn;
if(jsonObj) Mobile_NS.replyDataSet(jsonObj);
$comp.show();
};
Mobile_NS.replyDataSet = function(jsonObj){
var $form = $(".wev-reply-form", $comp);
for(var key in jsonObj){
var value = jsonObj[key];
$input = $("input[paramkey="+key+"]", $form);
if($input.length > 0){
$input[0].value = value;
}
}
};
*/
};
return Component.init(Reply);
});