js 练习

 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="req_form.aspx.cs" Inherits="req_form" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Assembly Name="CodeArt.SharePoint.CamlQuery, Version=1.0.0.0, Culture=neutral, PublicKeyToken=43536cfde91ea799" %>
<%@ Assembly Name="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" %>
<asp:content id="ContentHead" contentplaceholderid="PlaceHolderAdditionalPageHead" runat="server">
<link href="../css/commom_shenergy_form.css" rel="stylesheet" />
<link href="../css/jquery-ui.css" rel="stylesheet" />
<link href="../themes/default/easyui.css" rel="stylesheet" />
<link href="../css/alert.css" rel="stylesheet" />
<link href="../css/Huploadify.css" rel="stylesheet" />
<script src="../js/jquery-1.11.3.min.js"></script>
<script src="../js/jquery-ui-1.10.4.custom.min.js"></script>
<script src="../js/jquery.easyui.min.js"></script>
<script src="../js/jquery-ui-timepicker-addon.js"></script>
<script src="../js/jquery.ui.datepicker-zh-CN.js"></script>
<script src="../js/jquery-ui-timepicker-zh-CN.js"></script>
<script src="../js/jquery-ui-timepicker-addon.js"></script>
<script src="../js/jquery.Huploadify.js"></script>
<script src="../js/jquery.form.js"></script>
<script src="../js/jquery.alert.js"></script>
<script src="../js/commom_shenergy.js"></script>
<link href="../css/king-table.css" rel="stylesheet" />
<style>
.right .tableDiv span
{
display: inline-block;
width: 85px;
font-family: 'Microsoft YaHei';
} </style>
<script type="text/javascript">
$(function ()
{
$('.left>ul>li').click(function (event){$(this).toggleClass("leftblock").next('ul').slideToggle(300).siblings("ul").slideUp(300); });
$('.check>.currentdefault').click(function (event) { $(this).toggleClass('tianjia').siblings(); });
$('.HYGM button').click(function (event) { $(this).toggleClass('current').siblings().removeClass('current');});
$('.cspan1 button').click(function (event) { $(this).toggleClass('current').siblings().removeClass('current'); });
$('.textBottom button').click(function (event) { $(this).toggleClass('current').siblings().removeClass('current');});
$(".currentdefault").click(function (event) { $(this).toggleClass("current").siblings().removeClass("current")});
$(".check>.currentdefault").click(function (event) { $(this).toggleClass("current").siblings(); });
$("#hide").click(function () {
$(".c_div_showhidenotify").hide();
}); $("#show").click(function () {
$(".c_div_showhidenotify").show();
});
$("input[name='act_start_time'],input[name='act_stop_time']").datetimepicker();//datetimepicker
meetroomQuery();
function meetroomQuery() { var urlajax = "../Handler/HandlerComMeetRoomsList.ashx?MeetRoomsFlag=All"
$.ajax(
{
url: urlajax,//submit to HandlerMeetRoomApplyForm.ashx page
type: "post",
async: false,
dataType: "json",
data: { method: "Add" },
success: function (arr) {
var en = {}; for (var i = 0; i < arr.length; i++) {
$('.cselect2').append("<option value='" + arr[i].MeetRoomsId + "'>" + arr[i].MeetRoomsName + "</option>");
}
//$(".cselect2").prepend("<option value='0' selected='selected'>--请选择--</option>"); },
error: function (XMLHttpRequest, textStatus, errorThrown) { console.log("新增失败=>" + textStatus); alert('新增失败!'); }
});
}
});
</script>
</asp:content>
<asp:content id="Content1" contentplaceholderid="PlaceHolderMain" runat="Server">
<div class="wrap">
<div class="contentDiv">
<div class="inCon">
<div class="right">
<div class="InRight"></div>
<div class="tableDiv" style="height:200%">
<span class="spanhead c_margintop">会议室名称:</span>
<select class="cselect2"></select><br>
<span class="spanhead c_margintop">会议时间:</span>
<input name="act_start_time" type="text"id="meetingStartTime" class="text-box"
value="2016/12/28 16:08" placeholder="开始时间≥当前时间" title="开始时间≥当前时间" readonly="readonly" style="cursor:pointer;"/>
<input name="act_stop_time" type="text" id="meetingStopTime" class="text-box"
value="2016/12/30 16:08" placeholder="结束时间>开始时间" title="结束时间>开始时间" readonly="readonly" style="cursor:pointer;"/><br>
<span class="spanhead c_margintop">会议要求:</span>
<textarea id="textid1" placeholder="会议安排要求">会议要求</textarea>
<br>
<span class="spanhead c_margintop">会议备注:</span>
<textarea id="textid2" placeholder="会议备注">会议备注</textarea> <br>
<span class="spanhead c_margintop">会议人员:</span><br />
<div style="width:1200px;height:300px;margin-left: 80px;">
<div style="margin:10px 0">
<a href="#" class="easyui-linkbutton" onclick="insert()">添加内部人员</a>
<a href="#" class="easyui-linkbutton" onclick="insert2()"style="margin-left: 320px;">添加外部人员</a>
</div>
<div class="aa" style="width: 450px; float: left;">
<table id="tt" ></table>
</div>
<div class="aa" style="width: 550px;float: left">
<table id="tt2" ></table>
</div>
</div>
<div class="c_div_IssendNotify" id="id_div_IssendNotify">
<span class="c_span_IssendNotifyTitle">会议通知:</span>
<span class="currentdefault current" id="show">是</span>
<span class="currentdefault" id="hide">否</span>
<div class="c_div_showhidenotify" style="margin-left: 80px;">
<textarea class="c_txtr_title" placeholder="通知标题">通知标题</textarea><br />
<textarea class="c_txtr_content" placeholder="通知内容">通知内容</textarea><br />
</div>
</div>
<div> </div> <div id="id_div_upload"class="c_div_upload" >上传材料:</div> <%--<div class="mybtn" id="btnUpdate">更新会议室</div>--%>
<div class="c_div_save_submit_return" style="text-align:center;line-height:18px">
<div class="c_div_save diyi"" id="id_div_save" >保存会议申请</div>
<div class="c_div_submit dier" id="id_div_submit">提交会议申请</div>
<div class="c_div_return disan" id="id_div_return"onclick="javascript:history.go(-1);">返回</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script> var url = window.location.href;
var entity = {};
function GetQueryString(name)
{
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
var urlpara = GetQueryString("MeetAppId");
console.log("==>modify para====");
if (urlpara != null && urlpara.toString().length >= 1) //
{
console.log("==>entry form_Update_pages!");
$(function () {
Query();
$(".InRight").text("会议申请更新");
$(".c_div_submit").text("提交会议申请更新");
$(".c_div_submit").bind("click", submitUpdate);
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
console.log("entry form_query!");
function Query() {
var urlajax = "../Handler/HandlerMeetingApplicantList.ashx?MeetAppFlag=Detail&MeetAppId=" + urlpara;
modifyPara();
$.ajax({
url: urlajax,//Query
success: function (arr)
{
alert(arr)
for (var i = 0; i < arr.length; i++)
{
$(".cselect1").val(en.MeetRoomsName);
$(".cselect2").val(en.MeetRoomsCheckEmployer);
var span1 = $("#span1").find("span");
for (var j = 0; j < span1.length; j++)
{
if ($(span1[j]).text() == en.MeetRoomsState)
{
$(span1[j]).toggleClass('current').siblings().removeClass('current');
}
}
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert('查询错误!');
}
});
}
console.log("==>entry form_Update submit");
function submitUpdate() {
console.log("test submitUpdate start!");
modifyPara();
entity.MeetRoomsId = urlpara;
var urlajax = "../Handler/HandlerMeetingApplicant.ashx?MeetAppFlag=Update&"
$.ajax({
url: urlajax,//submit to HandlerMeetRoomApplyForm.ashx page
type: "post",
async: false,
dataType: "text",
data: { method: "Update",req: JSON.stringify(entity) },
success: function (arr)
{
if (arr)
{
console.log("更新返回值:" + arr);
window.location.href = './req_list.aspx';
}
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{
alert('错误!');
}
});
}
});
}
else
{
console.log("=>entry form_Add_pages!");
$(function ()
{
$("input[name='act_start_time'],input[name='act_stop_time']").datetimepicker();//datetimepicker
$(".InRight").text("新增会议申请");
$(".c_div_submit").text("提交会议申请申请");
$(".c_div_submit").bind("click", submitDo);
function submitDo()
{
var entity = {};
var MeetRoomsId = $(".cselect2").val();//会议室名称
if (MeetRoomsId == 0 || MeetRoomsId==null)
{
alert("请选择会议室"); return false;
}
var MeetAppStartT = $("#meetingStartTime").val();
if (MeetAppStartT =="" || MeetAppStartT == null) {
alert("请选择开始时间"); return false;
}
var MeetAppEndT = $("#meetingStopTime").val();
if (MeetAppEndT == "" || MeetAppEndT == null) {
alert("请选择结束时间"); return false;
}
var MeetAppFixedClaims = $("#textid1").val();
if (MeetAppFixedClaims == "" || MeetAppFixedClaims == null) {
alert("请填写会议要求"); return false;
}
var MeetAppRemark = $("#textid2").val();
if (MeetAppRemark == "" || MeetAppRemark == null) {
alert("请填写会议内容"); return false;
}
var MeetAppSendMeetNotice = $(".c_div_IssendNotify > .current").html();
var MeetNoticeTitle = $(".c_txtr_title").val();
var MeetNoticeContent = $(".c_txtr_content").val();
if (MeetAppSendMeetNotice == "是")
{
if (MeetNoticeTitle == "" || MeetNoticeTitle == null) {
alert("请填写会议通知标题"); return false;
}
if (MeetNoticeContent == "" || MeetNoticeContent == null) {
alert("请填写会议通知内容"); return false;
}
}
entity.MeetRoomsId = MeetRoomsId;
entity.MeetRoomsId = MeetRoomsId,
entity.MeetAppStartT = MeetAppStartT,
entity.MeetAppEndT = MeetAppEndT,
entity.MeetAppFixedClaims = MeetAppFixedClaims,
entity.MeetAppRemark = MeetAppRemark,
entity.MeetNoticeTitle = MeetNoticeTitle,
entity.MeetNoticeContent = MeetNoticeContent,
entity.MeetAppSendMeetNotice = MeetAppSendMeetNotice; /*-------------内部人员----------------------------*/
var rowsData = $('#tt').datagrid('getRows');
var insideusers = [];
if (rowsData == "" || rowsData == null) { alert("请选择会议内部人员"); return false; }
$.each(rowsData, function (i) {
var loc = {
"MeetInsiderTitle": rowsData[i].MeetInsiderTitle,
"MeetInsiderPeo": rowsData[i].MeetInsiderPeo
};
insideusers.push(loc);
});
entity.ListInsider = insideusers; /*-------------外部人员----------------------------*/
var rowsDatatt2 = $('#tt2').datagrid('getRows');
var outsideusers = [];
$.each(rowsDatatt2, function (i) {
var loc = {
"MeetOutsidersTitle": rowsDatatt2[i].MeetOutsidersTitle,
"MeetUnitName": rowsDatatt2[i].MeetUnitName,
"MeetOutsidersTel": rowsDatatt2[i].MeetOutsidersTel,
"MeetOutsidersMail": rowsDatatt2[i].MeetOutsidersMail
};
outsideusers.push(loc);
});
entity.ListOutsiders = outsideusers; /*-------------会议通知----------------------------*/
entity.MeetNotice = {};
entity.MeetNotice.MeetNoticeTitle = MeetNoticeTitle;
entity.MeetNotice.MeetNoticeContent = MeetNoticeContent;
/*-------------会议材料----------------------------*/
var MeetMaterialId = "";
entity.MeetMaterialId = MeetMaterialId;
var urlajax = "../Handler/HandlerMeetingApplicant.ashx?MeetAppFlag=Add"
$.ajax(
{
url: urlajax,//submit to HandlerMeetRoomApplyForm.ashx page
type: "post",
async: false,
dataType: "json",
data: { method: "Add", req: JSON.stringify(entity) },
success: function (arr)
{
alert("新增成功11=>" + urlajax + JSON.stringify(entity).toLocaleString() +
"==>" + "返回标识符:" + arr.ResultMsg + "返回结果:" + arr.ResultMsg);
// window.location.href = './req_list.aspx'; },
error: function (XMLHttpRequest, textStatus, errorThrown) {
console.log("新增失败=>" + textStatus); alert('新增失败!');
}
});
}
});
} </script>
<script>
$(function()
{
$('#id_div_upload').Huploadify({
dataType: "json",
auto: true,
fileTypeExts: '*.*;',
multi: true,
formData: { key: 123456, key2: 'vvvv' },
fileSizeLimit: 9999,
showUploadedPercent: true,//是否实时显示上传的百分比,如20%
showUploadedSize: true,
removeTimeout: 9999999,
uploader: '../Handler/HandlerMeetingMaterial.ashx?MeetMaterialFlag=Add',
onUploadStart: function () {
console.log('开始上传');
},
onInit: function () {
console.log('初始化');
},
onUploadComplete: function (result) { var str = JSON.stringify(result);
console.log(str);
// var str = eval('[{ResultMsg: "OK", ResultFlag: "5"}]');
//$.each(str, function () {
// alert(this.ResultMsg + this.ResultFlag);
//}); },
onUploadSuccess: function (result)
{
var str = JSON.stringify(result);
alert("上传成功!"+str);
},
onDelete: function (file) {
console.log('删除的文件:' + file);
console.log(file);
}
}); });
$(function()
{
$('#tt').datagrid(
{
title: '内部人员',
//iconCls: 'icon-edit',
width:420,
height: 250,
singleSelect: true,
idField: 'itemid',
// url: '../Handler/HandlerMeetingInsider.ashx?MeetInsiderFlag=Add',
columns: [[
//{ field: 'No', title: '序号', width: 60 },
{ field: 'MeetInsiderTitle', title: '姓名', width:100, editor: 'text', align: 'center'},
{ field: 'MeetInsiderPeo', title: '会议人员', width: 120, align: 'center', editor: 'text' },
{
field: 'action', title: '操作', width: 80, align: 'center',
formatter: function (value, row, index) {
if (row.editing) {
var s = '<a href="#" onclick="saverow(this)">保存</a> ';
var c = '<a href="#" onclick="cancelrow(this)">取消</a>';
return s + c;
} else {
var e = '<a href="#" onclick="editrow(this)">编辑</a> ';
var d = '<a href="#" onclick="deleterow(this)">删除</a>';
return e + d;
}
}
}
]],
onBeforeEdit: function (index, row) {
row.editing = true;
updateActions(index);
},
onAfterEdit: function (index, row) {
row.editing = false;
updateActions(index);
},
onCancelEdit: function (index, row) {
row.editing = false;
updateActions(index);
}
}); });
$(function () {
$('#tt2').datagrid(
{
title: '外部人员',
//iconCls: 'icon-edit',
width: 500,
height: 250,
singleSelect: true,
idField: 'itemid',
// url: '../Handler/HandlerMeetingOutsiders.ashx?MeetOutsidersFlag=Add',
columns: [[
//{ field: 'No', title: '序号', width: 50 },
{ field: 'MeetOutsidersTitle', title: '姓名', width: 100, editor: 'text', align: 'center' },
{ field: 'MeetUnitName', title: '单位名称', width: 100, editor: 'text', align: 'center' },
{ field: 'MeetOutsidersTel', title: '手机号', width: 100, editor: 'text', align: 'center' },
{ field: 'MeetOutsidersMail', title: '邮箱', width: 80, editor: 'text', align: 'center' }, {
field: 'action', title: '操作', width: 80, align: 'center',
formatter: function (value, row, index) {
if (row.editing) {
var s = '<a href="#" onclick="saverow2(this)">保存</a> ';
var c = '<a href="#" onclick="cancelrow2(this)">取消</a>';
return s + c;
} else {
var e = '<a href="#" onclick="editrow2(this)">编辑</a> ';
var d = '<a href="#" onclick="deleterow2(this)">删除</a>';
return e + d;
}
}
}
]],
onBeforeEdit: function (index, row) {
row.editing = true;
updateActions2(index);
},
onAfterEdit: function (index, row) {
row.editing = false;
updateActions2(index);
},
onCancelEdit: function (index, row) {
row.editing = false;
updateActions2(index);
}
}); });
function updateActions(index) {
$('#tt').datagrid('updateRow', {
index: index,
row: {}
});
}
function getRowIndex(target) {
var tr = $(target).closest('tr.datagrid-row');
return parseInt(tr.attr('datagrid-row-index'));
}
function editrow(target) {
$('#tt').datagrid('beginEdit', getRowIndex(target));
}
function deleterow(target) {
$.messager.confirm('确定', '你确定吗?', function (r) {
if (r) {
$('#tt').datagrid('deleteRow', getRowIndex(target));
}
});
}
function saverow(target) {
$('#tt').datagrid('endEdit', getRowIndex(target)); }
function cancelrow(target) {
$('#tt').datagrid('cancelEdit', getRowIndex(target));
}
function insert()
{
var row = $('#tt').datagrid('getSelected');
if (row) {
var index = $('#tt').datagrid('getRowIndex', row);
} else {
index = 0;
}
$('#tt').datagrid('insertRow', {
index: index,
row: {
status: 'P'
}
});
$('#tt').datagrid('selectRow', index);
$('#tt').datagrid('beginEdit', index);
}
function updateActions2(index) {
$('#tt2').datagrid('updateRow', {
index: index,
row: {}
});
}
function getRowIndex2(target) {
var tr = $(target).closest('tr.datagrid-row');
return parseInt(tr.attr('datagrid-row-index'));
}
function editrow2(target) {
$('#tt2').datagrid('beginEdit', getRowIndex2(target));
}
function deleterow2(target) {
$.messager.confirm('确定', '你确定吗?', function (r) {
if (r) {
$('#tt2').datagrid('deleteRow', getRowIndex2(target));
}
});
}
function saverow2(target) {
$('#tt2').datagrid('endEdit', getRowIndex2(target)); }
function cancelrow2(target) {
$('#tt2').datagrid('cancelEdit', getRowIndex2(target));
}
function insert2() {
var row = $('#tt2').datagrid('getSelected');
if (row) {
var index = $('#tt2').datagrid('getRowIndex', row);
} else {
index = 0;
}
$('#tt2').datagrid('insertRow', {
index: index,
row: {
status: 'P'
}
});
$('#tt2').datagrid('selectRow', index);
$('#tt2').datagrid('beginEdit', index);
}
function addMeetingInsider() { var rowsData = $('#tt').datagrid('getRows');
var json = [];
var loc;
$.each(rowsData, function (i) {
loc = { "MeetInsiderTitle": rowsData[i].MeetInsiderTitle,
"MeetInsiderPeo": rowsData[i].MeetInsiderPeo };
json.push(loc);
});
json = JSON.stringify(json); //转换成json数据
alert(json);
var urlajax = "../Handler/HandlerMeetingInsider.ashx?MeetInsiderFlag=Add";
$.ajax(
{
url: urlajax,
type: "post",
async: false,
dataType: "json",
data: { method: "Add", req: JSON.stringify(json) },
success: function (arr) {
console.log("新增成功=>"
+ urlajax + JSON.stringify(entity).toLocaleString() +
"==>" + "返回标识符:" + arr.ResultMsg + "返回结果:" + arr.ResultMsg);
if (arr.ResultFlag == "0") {
alert("新增成功");
}
else { alert("未知错误"); }
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{ console.log("新增失败=>" + textStatus); alert('新增失败!'); }
});
}
function addMeetingOutsiders()
{
var rowsData = $('#tt2').datagrid('getRows');
var json = [];
var loc;
$.each(rowsData, function (i) {
loc = { "MeetOutsidersTitle": rowsData[i].MeetOutsidersTitle,
"MeetUnitName": rowsData[i].MeetUnitName,
"MeetOutsidersTel": rowsData[i].MeetOutsidersTel,
"MeetOutsidersMail": rowsData[i].MeetOutsidersMail
};
json.push(loc);
});
json = JSON.stringify(json); //转换成json数据
alert(json);
var urlajax = "../Handler/HandlerMeetingOutsiders.ashx?MeetOutsidersId=Add";
$.ajax(
{
url: urlajax,//submit to HandlerMeetRoomApplyForm.ashx page
type: "post",
async: false,
dataType: "json",
data: { method: "Add", req: JSON.stringify(entity) },
success: function (arr) {
console.log("新增成功=>" + urlajax +
JSON.stringify(entity).toLocaleString() + "==>" +
"返回标识符:" + arr.ResultMsg + "返回结果:" + arr.ResultMsg);
if (arr.ResultFlag == "0") {
alert("新增成功");
//window.location.href = './req_list.aspx';
}
else { alert("未知错误"); }
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{ console.log("新增失败=>" + textStatus); alert('新增失败!'); }
});
}
</script>
</asp:content>
上一篇:【LeetCode】—— 多数元素


下一篇:1.3打擂台