mitao
2024-04-30 ab4ea7b8f10c9b66aed9c2ea161a08b25c3851a7
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
/**
 * 初始化公告详情对话框
 */
var TNoticeInfoDlg = {
    tNoticeInfoData : {},
    editor: null,
    validFields: {
        title: Feng.def_valid_info( true, null, null, null, {
            stringLength: {
                max: 50,
                message: "最多支持50个字符"
            }
        }),
        coverPlan: Feng.def_valid_info(true),
        content: Feng.def_valid_info(true)
    }
};
 
/**
 * 清除数据
 */
TNoticeInfoDlg.clearData = function() {
    this.tNoticeInfoData = {};
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
TNoticeInfoDlg.set = function(key, val) {
    this.tNoticeInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
TNoticeInfoDlg.get = function(key) {
    return $("#" + key).val();
}
 
/**
 * 关闭此对话框
 */
TNoticeInfoDlg.close = function() {
    parent.layer.close(window.parent.TNotice.layerIndex);
}
 
/**
 * 收集数据
 */
TNoticeInfoDlg.collectData = function() {
    this
    .set('id')
    .set('title')
    .set('source', this.sourceRadio.getValue())
    .set('coverPlan')
    .set('content');
}
 
/**
 * 提交添加
 */
TNoticeInfoDlg.addSubmit = function() {
 
    this.clearData();
    this.collectData();
 
    if ( !Feng.check_form( "formId")) { return; }
 
    Feng.base_ajax( "/tNotice/add", this.tNoticeInfoData, function ( data) {
        Feng.success( "添加成功");
        TNoticeInfoDlg.close();
        parent.TNotice.search();
    });
 
}
 
/**
 * 提交修改
 */
TNoticeInfoDlg.editSubmit = function() {
 
    this.clearData();
    this.collectData();
 
    if ( !Feng.check_form( "formId")) { return; }
 
    Feng.base_ajax( "/tNotice/update", this.tNoticeInfoData, function ( data) {
        Feng.success( "修改成功");
        TNoticeInfoDlg.close();
        parent.TNotice.search();
    });
}
 
$(function() {
    Feng.initValidator( "formId", TNoticeInfoDlg.validFields);
});