|
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;
|
}
|