You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
3.1 KiB
96 lines
3.1 KiB
11 months ago
|
layui.use(['form', 'layer', 'laydate', 'upload'], function () {
|
||
|
var form = layui.form
|
||
|
layer = parent.layer === undefined ? layui.layer : top.layer,
|
||
|
$ = layui.jquery;
|
||
|
var laydate = layui.laydate; //时间控件
|
||
|
var upload = layui.upload; ///得到 upload 对象
|
||
|
//时间控件
|
||
|
/* laydate.render({
|
||
|
elem: '.Ntime', //指定元素
|
||
|
type: 'time'
|
||
|
});*/
|
||
|
laydate.render({
|
||
|
elem: '.ShowTime', //指定元素
|
||
|
type: 'datetime',
|
||
|
range: true
|
||
|
});
|
||
|
//实例化富文本编辑器控件
|
||
|
var um = UM.getEditor('container', {
|
||
|
autoHeight: true
|
||
|
});
|
||
|
|
||
|
//附件上传
|
||
|
upload.render({
|
||
|
elem: '.UP',
|
||
|
url: '../../ashx/FileUpHandler.ashx', //必填项
|
||
|
method: 'post', //可选项。HTTP类型,默认post
|
||
|
data: {}, //可选项。额外的参数,如:{id: 123, abc: 'xxx'}
|
||
|
accept: 'file',
|
||
|
done: function (res, index, upload) {
|
||
|
if (res.state == 'SUCCESS')
|
||
|
var item = this.item;
|
||
|
item.addClass("layui-btn-warm");
|
||
|
item.context.innerText = "附件已上传";
|
||
|
// top.layer.msg("附件上传成功");
|
||
|
$(".UPUrl").val(res.url);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
//提交
|
||
|
form.on("submit(AddEdit)", function (data) {
|
||
|
var contextText = UM.getEditor('container').getContent(); // getPlainTxt(); //获取文本编辑器值
|
||
|
var userTime = $(".UsersTime").val();
|
||
|
//弹出loading
|
||
|
var index = layer.msg('数据提交中,请稍候', { icon: 16, time: false, shade: 0.8 });
|
||
|
//提交信息
|
||
|
$.post("../../ashx/NoticeHandler.ashx", {
|
||
|
Action: $(".Action").val(),
|
||
|
ID: $(".ID").val(),
|
||
|
Title: $(".Title").val(),
|
||
|
Ntype: $(".Ntype").val(),
|
||
|
Ntime: $(".Ntime").val(),
|
||
|
Nuser: $(".Nuser").val(),
|
||
|
Norg: $(".Norg").val(),
|
||
|
State: $(".State").val(),
|
||
|
ShowTime: $(".ShowTime").val(), //up还没写
|
||
|
up: $(".UPUrl").val(),
|
||
|
contextText: contextText,
|
||
|
random: new Date().getTime() //随机参数
|
||
|
}, function (res) {
|
||
|
res = $.parseJSON(res);
|
||
|
if (res.code == 1) {
|
||
|
top.layer.msg(res.msg);
|
||
|
layer.close(index);
|
||
|
//刷新父页面
|
||
|
parent.location.reload();
|
||
|
} else {
|
||
|
layer.close(index);
|
||
|
layer.msg(res.msg);
|
||
|
}
|
||
|
});
|
||
|
layer.close(index);
|
||
|
return false;
|
||
|
})
|
||
|
|
||
|
//格式化时间
|
||
|
function filterTime(val) {
|
||
|
if (val < 10) {
|
||
|
return "0" + val;
|
||
|
} else {
|
||
|
return val;
|
||
|
}
|
||
|
}
|
||
|
//定时发布
|
||
|
|
||
|
|
||
|
|
||
|
//获取时间
|
||
|
function getTime() {
|
||
|
var time = new Date();
|
||
|
var submitTime = time.getFullYear() + '-' + filterTime(time.getMonth() + 1) + '-' + filterTime(time.getDate()) + ' ' + filterTime(time.getHours()) + ':' + filterTime(time.getMinutes()) + ':' + filterTime(time.getSeconds());
|
||
|
$(".Ntime").val(submitTime);
|
||
|
}
|
||
|
getTime();
|
||
|
})
|