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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
 
window.submitUrl = "/Pages/business/SeckillInfoEdit.aspx"; //设置当前页的提交路径
window.FastKeyDistinctived = true; //例外快捷键(不使用通用快捷键)
/*
获取数据
*/
function GetData(isReturnJson) {
    try {
        var data = {
            BusinessInfoName: "",
            PrintTypeId: "14",
            BusinessContent: document.getElementById('txtBusinessContent').value,
            Contacts: document.getElementById('txtContacts').value,
            ContactPhone: document.getElementById('txtContactPhone').value,
            QQ: document.getElementById('txtQQ').value,
            EndTime: document.getElementById('txtEndTime').value,
            State: document.getElementById('selState').value,
            Remark: ""
        };
    } catch (ex) {
        global.DealDataException(ex); return;
    }
    var keyid = document.getElementById('txtKeyid').value;
 
   // if (!keyid &&document.getElementById('ckIsSaveAndPublish').checked) { data['State'] = -1; } //勾选了保存时发布后将状态保存为发布
    if (keyid) {
        data.Keyid = keyid;
    } else {
    }
    window.NoneData = window.NoneData ? window.NoneData : data;
    return isReturnJson ? data : window.ConvertJsonToString(data);
}
/*
设置数据到界面
*/
function SetData(data) {
    window.SetJsonToDom(data);
    //document.getElementById('selPrintTypes').value = data.PrintTypeId;
    document.getElementById('selState').value = data.State;
    window.IsNoName = !data.BusinessInfoName;
    document.getElementById('ckIsSaveAndPublish').checked = !data.Keyid;
 
}
/*
验证界面
*/
function ValidateForm() {
    if (window.isShower) return false; else;
    document.getElementById('btnSave').focus();
    var txtEndTime = document.getElementById('txtEndTime');
    if (!txtEndTime) return; else;
    if (Date.Parse(txtEndTime.value) <= Date_ForDay()) {
        alertMsg('截止日期不能小于当前时间');
        txtEndTime.focus();
        return false;
    }
    return verfy_form(document.forms[0]);
}
 
/*
保存(新增/修改)
*/
function Save() {
    if (!ValidateForm()) return; else;
    GetData();
    
    CallServer({ Target: "SaveInfo", RequestParams: GetData() }, function (data, textStatus) {
 
        DefaultSuccessCallback(data, textStatus);
        window.Saved = '1' == data;
    });
}
 
 
 
var keyDownHook = new KeyBehaviorHook('keydown');
keyDownHook.Regist(window.Keys.S, "Save()", window.WithKey.Ctrl); //Ctrl+s 保存
keyDownHook.Regist(window.Keys.Enter, "Save()", window.WithKey.Ctrl); //Ctrl+Enter 保存
keyDownHook.Regist(window.Keys.R, "ClearData()", window.WithKey.Ctrl); //Ctrl+R 重置
keyDownHook.Regist(window.Keys.Q, "CloseOpenWindow(window.Saved)", window.WithKey.Ctrl); //Ctrl+Q 退出(Quit)
 
$(function () {
    keyDownHook.Binding();
    global.SetReqMsg(); //设置空信息提示 
    //    var txtTemp1 = document.createElement('input');
    //    txtTemp1.style.display = 'none';
    //    top.frmright.document.appendChild(txtTemp1);
    //    $(document).keydown(function (e) { alert(e.keycode); });
    //    txtTemp1.focus();
    try {
        var thisForm = document.forms[0];
        var data = document.getElementById('txtModeldata').value;
        var tr_sap = document.getElementById('tr_sap');
        if (tr_sap)
            tr_sap.style.display = data ? 'none' : '';
 
        if (data) {
            window.NoneData = eval('[' + data + ']')[0];
            window.NoneData.EndTime = window.NoneData.EndTime.ToString('yyyy-MM-dd HH:mm');
            if (thisForm && thisForm.id == 'formShower') { ShowData(); return; } //当是展示页面引用该js时用 
        } else
            GetData();
 
        var id = $("#txtKeyid").val();
        if (id != "") {
            $("#stateTr").show();
        }
    } catch (e) {
        GetData();
    }
 
    ClearData();
});
/*
清空界面值
*/
function ClearData() {
    if (window.NoneData && !window.isShower) {
        var isNew = false;
        window.NoneData.EndTime = (isNew = window.NoneData.EndTime) ? window.NoneData.EndTime : new Date().ToFuture({ day: 1 }).ToString('yyyy-MM-dd');
        SetData(window.NoneData);
        window.NoneData.EndTime = isNew ? window.NoneData.EndTime : '';
    } else {
        ReLoad();
    }
}
 
 
/*
显示信息
*/
function ShowData() {
    window.isShower = true;
    window.NoneData.PrintTypeName = window.NoneData.PrintType.PrintName;
    //    window.NoneData.StateName = window.NoneData.StateType.Name;
    window.NoneData.SellerName = window.NoneData.MemberBasic.Name;
    window.NoneData.CreateTime = window.NoneData.CreateTime.ToString('yyyy-MM-dd');
    window.NoneData.LastUpdateTime = window.NoneData.LastUpdateTime.ToString('yyyy-MM-dd');
    window.SetJsonToDom(window.NoneData, 'spn', "innerHTML");
 
 
}
function printTypeChange(sel) {
    var txtBusinessInfoName = document.getElementById('txtBusinessInfoName');
    txtBusinessInfoName.value = window.IsNoName ? (sel.value ? sel.options[sel.selectedIndex].text : '') : txtBusinessInfoName.value;
 
}