username@email.com
2022-01-21 b18a7c8e54b51a5caa400e55cb8cc428c0301a0c
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
 
window.submitUrl = "/Pages/business/DemandDescribeEdit.aspx"; //设置当前页的提交路径
window.FastKeyDistinctived = true; //例外快捷键(不使用通用快捷键)
/*
获取数据
*/
function GetData(isReturnJson) {
 
    try {
 
 
        var data = {
            DemandName: document.getElementById('txtDemandName').value,
            DemandDemand: document.getElementById('txtDemandDemand').value,
            PrintTypeId: document.getElementById('selPrintTypes').value,
            EndTime: document.getElementById('txtEndTime').value,
            State: document.getElementById('selState').value,
            CallTypeId: document.getElementById('selCallTypes').value,
            Remark: document.getElementById('txtRemark').value
        };
    } catch (e) {
        return;
    }
    var keyid = document.getElementById('txtKeyid').value;
 
    if (!keyid && document.getElementById('ckIsSaveAndPublish').checked) { data['State'] = -1; } //勾选了保存时发布后将状态保存为发布
    if (keyid)
        data.Keyid = keyid;
    window.NoneData = window.NoneData ? window.NoneData : data;
    return isReturnJson ? data : window.ConvertJsonToString(data);
}
/*
设置数据到界面
*/
function SetData(data) {
 
    data.LastUpdateTime = data.LastUpdateTime ? 'string' == typeof (data.LastUpdateTime) ? data.LastUpdateTime : data.LastUpdateTime.ToString('yyyy-MM-dd') : '';
    window.SetJsonToDom(data);
    document.getElementById('selPrintTypes').value = data.PrintTypeId;
    document.getElementById('selState').value = data.State;
    document.getElementById('selCallTypes').value = data.CallTypeId;
    document.getElementById('txtEndTime').value = new Date().ToFuture({ day: 1 }).ToString('yyyy-MM-dd');
    window.IsNoName = !data.DemandName;
    document.getElementById('ckIsSaveAndPublish').checked = !data.Keyid;
    printTypeChange(document.getElementById('selPrintTypes'));
 
}
/*
验证界面
*/
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;
    CallServer({ Target: "SaveInfo", RequestParams: GetData() }, function (data, textStatus) {
 
        DefaultSuccessCallback(data, textStatus);
        window.Saved = '1' == data;
    });
}
/*
删除
*/
function Delete() {
    if (confirm("是否删除选中数据?"))
        CallServer({ Target: "DeleteDictionaryById", id: document.getElementById("txtId").value });
}
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();
    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');
            if (thisForm && thisForm.id == 'formShower') { ShowData(); return; } //当是展示页面引用该js时用 
        } else {
            GetData();
        }
    } catch (e) {
        GetData();
    }
 
    ClearData();
});
/*
清空界面值
*/
function ClearData() {
    if (window.NoneData && !window.isShower) { SetData(window.NoneData); }
    else {
        ReLoad();
    }
}
 
 
/*
显示信息
*/
function ShowData() {
 
    window.isShower = true;
    window.NoneData.PrintTypeName = window.NoneData.PrintType.PrintName;
    //    window.NoneData.StateName = window.NoneData.StateType.Name;
    window.NoneData.CallTypeName = window.NoneData.CallType.Name;
    window.NoneData.MemberName = 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 txtDemandName = document.getElementById('txtDemandName');
    txtDemandName.value = window.IsNoName ? (sel.value ? sel.options[sel.selectedIndex].text + '' : '') : txtDemandName.value;
}