hn_cloud_web/smz-web/js/work/person/accessFieldInform.js

85 lines
3.8 KiB
JavaScript

var form;
var idNumber = localStorage.getItem("id");
var proId = localStorage.getItem("proId");
var subId = localStorage.getItem("subId");
var orgId = localStorage.getItem("orgId");
var type = localStorage.getItem("type");
var einTime = localStorage.getItem("einTime");
$(function () {
if(type == '1'){
document.getElementById("outNum").style.display = "none";
document.getElementById("outTime").style.margin = "24% 0% 0% 13%";
}else {
var idNumberArr = idNumber.split(",");
$("#num").html(idNumberArr.length);
document.getElementById("outNum").style.display = "block";
document.getElementById("outTime").style.margin = "10% 0% 0% 13%";
}
});
layui.use(['form', 'laydate'], function () {
form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
var laydate = layui.laydate;
form.render();
form.verify({});
var today=new Date();
var yeard=today.getFullYear();
var monthd=(today.getMonth()+1)>9?(today.getMonth()+1):'0'+(today.getMonth()+1);
var dayd=today.getDate()>9?today.getDate():'0'+today.getDate();
var hourd=today.getHours()>9?today.getHours():'0'+today.getHours();
var mind=today.getMinutes()>9?today.getMinutes():'0'+today.getMinutes();
var scd=today.getSeconds()>9?today.getSeconds():'0'+today.getSeconds();
var submitTime=yeard+'-'+monthd+'-'+dayd+" "+hourd+":"+mind+":"+scd;
$("#exitTime").attr('value',submitTime);
// laydate.render({
// elem: '#exitTime' //指定元素 元素选择器
// , type: 'datetime' //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
// , trigger: 'click'
// , format: 'yyyy-MM-dd HH:mm:ss' //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss
// , btns: ['clear', 'now', 'confirm'] //选择框右下角显示的按钮 清除-现在-确定
// , done: function (value, date) {//时间回调
// console.log(value);
// console.log(date);
// }
// , min: einTime
// });
// 验证成功后才会执行下面的操作
form.on('submit(formDemo)', function (data) {
data.field.idNumber = idNumber;
data.field.proId = proId;
data.field.subId = subId;
data.field.orgId = orgId;
exitRecord(data);
});
});
// 出场
function exitRecord(formData) {
// form请求地址
var formUrl = ctxPath + "/WorkRecord/updateBatchWorkRecordStatus";
$.ajax({
type: 'POST',
async: false, // 默认异步true,false表示同步
url: formUrl, // 请求地址
contentType: "application/json; charset=utf-8",
dataType: 'json', // 服务器返回数据类型
data: JSON.stringify(formData.field), //获取提交的表单字段
success: function (data) {
if (data.resMsg == '保存成功') {
parent.layer.alert('出场成功', {icon: 1, time: 2000}, function () {
var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
parent.layer.close(index); //再执行关闭
window.parent.example.ajax.reload( null, false ); // 刷新页面
});
} else {
parent.layer.msg('出场失败', {icon: 2});
var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
parent.layer.close(index); //再执行关闭
window.parent.example.ajax.reload( null, false ); // 刷新页面
}
},
error: function (XMLHttpRequest, textStatus, e) {
layer.msg('数据请求发生异常,请稍后重试', {icon: 16, scrollbar: false});
}
});
}