@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>LeaveForm</title>
<style>
</style>
<link href="~/Content/upload.css" rel="stylesheet" />
<script src="~/Scripts/jquery.1.10.2.min.js"></script>
<script src="/scripts/jquery/jquery.iframe-transport.js"></script>
<script src="/scripts/jquery/jquery.ui.widget.js"></script>
<script src="/scripts/jquery/jquery.xdr-transport.js"></script>
<script src="/scripts/jquery/jquery.fileupload.js"></script>
<script>
function GetCookie(cname) {
var strCookie = document.cookie;
//没有找到
if (strCookie.indexOf(";") != 0) {
strCookie = strCookie + ";";
}
var c = document.cookie.split(";");//数组包含yjs_id=fDE1NzEwMzk0Mzg2NzI;code=1IVJAM
var name = cname + "=";
for (var i = 0; i < c.length; i++) {
var ca = c[i].trim();//去掉空格
if (ca.indexOf(name) == 0) {//查找是否存在,如果存在返回0不存在返回-1
return ca.substring(name.length, ca.length);//sumString(开始查找的位置,查找的长度是多少)
}
}
return "";
}
$(function () {
//获取cookie中的显示用户名
$("#txtDisplayName").val(GetCookie("displayName"));
$("#txtAccount").val(GetCookie("account"));
var date = new Date();
$("#txtDeptName").val(GetCookie("DeptName"));
$("#txtDate").val(date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate());
$("input[type=file]").fileupload({
done: function (e, result) {
//done方法就是上传完毕的回调函数,其他回调函数可以自行查看api
//注意result要和jquery的ajax的data参数区分,这个对象包含了整个请求信息
//返回的数据在result.result中,假设我们服务器返回了一个json对象
//json对象{"newName": "sss", "oldName": "sdf"}
var resultJson = $.parseJSON(result.result)
$(e.target).attr("value", resultJson.newName);
var uploadDiv = $(e.target).parent().parent().parent();
uploadDiv.find(".filestate").show().text(resultJson.oldName);
},
progressall: function (e, data) {
var maxWidth = 200;
var percent = (data.loaded / data.total * 100).toFixed(2);
var progress = parseInt(data.loaded / data.total * maxWidth, 10);
var uploadDiv = $(e.target).parent().parent().parent();
uploadDiv.find(".progress").show();
uploadDiv.find(".bar").css("width", progress);
uploadDiv.find(".progresspercent").show().text(percent + "%");
}
});
});
//计算天数
function DateDiff(sDate1, sDate2) {
var oDate1, oDate2, iDays
oDate1 = new Date(sDate1);
oDate2 = new Date(sDate2);
console.log(sDate1);
console.log(sDate2)
iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24);
return iDays;
}
function CalcDay() {
var txtBeginDdate = $("#txtBeginDdate").val();
var txtEndDate = $("#txtEndDate").val();
$("#txtDay").val(DateDiff(txtBeginDdate, txtEndDate) + 1);
}
function LeaveSubmit() {
var txtAccount = $("#txtAccount").val();
var txtDisplayName = $("#txtDisplayName").val();
var txtDeptName = $("#txtDeptName").val();
var approveAccount = "tianyou.xiang";
var approveName = "项天佑";
var txtBeginDdate = $("#txtBeginDdate").val();
var txtEndDate = $("#txtEndDate").val();
var txtDay = $("#txtDay").val();
var txtDesc = $("#txtDesc").val();
var dropType = $("#dropType").val();
$.ajax({
url: "http://localhost:56848/api/LeaveSubmit",
data: { AppAccount: txtAccount, AppName: txtDisplayName, AppDetp: txtDeptName, ApproveAccount: approveAccount, ApproveName: approveName, StartDate: txtBeginDdate, EndDate: txtEndDate, day: txtDay, _Desc: txtDesc, LeaveType: dropType },
type: "post",
dataType: "text",
success: function (result) {
}
});
}
</script>
</head>
<body>
<div style="margin:0">
<div align="center" style="font-size:20px">请假申请流程</div>
<div class="upload clearfix">
<div class="uploadbtnBox clearfix">
<a href="javascript:;" class="a-upload">
<input type="file" data-url="/Handler/upload.ashx" name="files" value="" id="file1"
/>点击上传
</a>
</div>
<div class="filestate">
文件名
</div>
<div class="progresspercent">
</div>
<div class="progress">
<div class="bar" style=" 0%;">
</div>
</div>
</div>
<div align="center" style="auto">
<table border="1px" cellpadding="0" cellspacing="0">
<tr><td colspan="4" style="font-weight:100">基本信息</td></tr>
<tr>
<td>申请单号:</td>
<td><input type="text" id="txtLeaveNumber" value="---申请单号自动生成----" disabled /></td>
<td>申请人:</td>
<td>
<input type="text" id="txtDisplayName" disabled />
<input type="hidden" id="txtAccount" />
</td>
</tr>
<tr>
<td>所在部门:</td>
<td><input type="text" id="txtDeptName" disabled /></td>
<td>申请日期:</td>
<td>
<input type="text" id="txtDate" disabled />
</td>
</tr>
<tr><td colspan="4" style="font-weight:100">申请信息</td></tr>
<tr>
<td>假期类型:</td>
<td colspan="3">
<select id="dropType">
<option value="年假">年假</option>
<option value="事假">事假</option>
</select>
</td>
</tr>
<tr>
<td>请假开始日期:</td>
<td>
<input type="date" id="txtBeginDdate" onclick="CalcDay()">
</td>
<td>请假结束日期</td>
<td><input id="txtEndDate" type="date" onclick="CalcDay()" /></td>
</tr>
<tr>
<td>请假天数:</td>
<td colspan="3"><input type="text" disabled id="txtDay" /></td>
</tr>
<tr>
<td>描述:</td>
<td colspan="3"><textarea rows="5" id="txtDesc" cols="20"></textarea></td>
</tr>
</table>
</div>
<div align="left" style="margin-left:500px">
<input type="button" onclick="LeaveSubmit()" value="提交表单" />
</div>
</div>
</body>
</html>