system-oa/src/main/resources/static/route/mail/send-mail.html
2022-04-06 15:43:31 +08:00

465 lines
22 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<base href="/systemoa/">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
</head>
<body>
<div class="layui-fluid">
<div class="layui-row">
<div class="layui-col-sm12 layui-col-md12">
<div class="layui-card" style="width: 100%">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="layui-row" style="padding: 10px;">
<div class="layui-col-md6">
<button type="button" class="layui-btn layui-btn-sm" lay-submit lay-filter="submitSend">
<i class="fa fa-lg fa-paper-plane-o"></i> 发送
</button>
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm" lay-submit lay-filter="submitDraft">
<i class="fa fa-lg fa-edit"></i> 存草稿
</button>
<a href="javascript:void(0)" id="copy-for-btn" style="color: #1e88e5;text-decoration: underline;margin-left: 50px;">抄送</a>
<a href="javascript:void(0)" id="secret-btn" style="color: #1e88e5;text-decoration: underline;margin-left: 25px;">密送</a>
</div>
</div>
<div class="layui-card-body" style="padding: 10px;">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-form-item">
<label class="layui-form-label"><span style="color: #cc0000;">* </span>收件人</label>
<div class="layui-input-block">
<input type="hidden" id="recipientIds" name="recipientIds" class="layui-input" value="">
<input type="text" id="recipientNames" name="recipientNames" class="layui-input" value=""
style="cursor: pointer" placeholder="点击选择收件人" readonly="readonly" lay-verify="required">
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-form-item">
<label class="layui-form-label"><span style="color: #cc0000;">* </span>主题</label>
<div class="layui-input-block">
<input type="text" id="title" name="title" class="layui-input" value="" placeholder="" maxlength="255" lay-verify="required">
</div>
</div>
</div>
</div>
<div class="layui-row" id="copy-for-div" style="display: none;">
<div class="layui-col-md12">
<div class="layui-form-item">
<label class="layui-form-label">抄送人</label>
<div class="layui-input-block">
<input type="hidden" id="copyForIds" name="copyForIds" class="layui-input" value="">
<input type="text" id="copyForNames" name="copyForNames" class="layui-input" value=""
style="cursor: pointer" placeholder="点击选择抄送人" >
</div>
</div>
</div>
</div>
<div class="layui-row" id="secret-div" style="display: none;">
<div class="layui-col-md12">
<div class="layui-form-item">
<label class="layui-form-label">密送人</label>
<div class="layui-input-block">
<input type="hidden" id="secretIds" name="secretIds" class="layui-input" value="">
<input type="text" id="secretNames" name="secretNames" class="layui-input" value=""
style="cursor: pointer" placeholder="点击选择密送人" >
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-form-text">
<label class="layui-form-label">附件</label>
<div class="layui-input-block">
<input type="hidden" id="mailFiles" name="mailFiles">
<div class="layui-btn-container" id="mailFilesFileBox" style="border: 1px solid #e6e6e6;"></div>
<script id="mailFilesFileDownload" type="text/html">
{{# var fileName = 'mailFiles'; }}
{{# if(d[fileName].length > 0) { }}
{{# var files = d[fileName];}}
{{# for(var i = 0, item = files[i]; item = files[i++];) { }}
<div class="upload-image-box">
<span class="upload-image-span file-down-event" data-id="{{item.fileId}}">
<img src="assets/images/filetype/default-file-img.png" title="点击下载[{{item.fileName}}]" align="加载失败">
</span>
<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-image" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="mailFilesRemoveFile">
<i class="fa fa-trash-o"></i>
</a>
</div>
{{# } }}
{{# } }}
{{# if(d[fileName].length < 1) { }}
<div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">
<a href="javascript:void(0);" lay-form-button data-explain="附件" data-name="mailFiles" lay-filter="mailFilesUploadFile">
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
</a>
</div>
{{# } }}
</script>
</div>
</div>
</div>
<div class="layui-row" style="margin-top: 5px;">
<div class="layui-col-sm12 layui-col-md12">
<div class="layui-form-item layui-form-text">
<div class="layui-input-block">
<div id="richContent"></div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
<script src="assets/js/vendor/wangEditor/wangEditor-fullscreen-plugin.js"></script>
<script src="assets/js/jquery-3.5.1.min.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'animate-numbers', 'form', 'laytpl'], function() {
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var viewerObj = {};
var wangEditorObj = {};
$('.layui-card').height($(window).height() - 30)
function init(){
initRichContentContentRichText();
initMailFilesUploadFile();
}
init();
$(document).on('click', '#copy-for-btn', function(){
$('#copyForIds').val('');
$('#copyForNames').val('');
$('#copy-for-div').toggle();
});
$(document).on('click', '#secret-btn', function(){
$('#secretIds').val('');
$('#secretNames').val('');
$('#secret-div').toggle();
});
// 初始化文件列表
function initFileList(fileName, ids, callback) {
var dataForm = {};
dataForm[fileName] = ids;
form.val('dataForm', dataForm);
if(!ids) {
refreshDownloadTemplet(fileName, []);
if(callback) {
callback(fileName, []);
}
return;
}
top.restAjax.get(top.restAjax.path('api/file/list', []), {
ids: ids
}, null, function(code, data) {
refreshDownloadTemplet(fileName, data);
if(callback) {
callback(fileName, data);
}
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
function refreshDownloadTemplet(fileName, file) {
var dataRander = {};
dataRander[fileName] = file;
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
document.getElementById(fileName +'FileBox').innerHTML = html;
});
}
// 初始化附件上传
function initMailFilesUploadFile() {
var files = $('#mailFiles').val();
initFileList('mailFiles', files, function(fileName) {
});
form.on('button(mailFilesUploadFile)', function(obj) {
var name = this.dataset.name;
var explain = this.dataset.explain;
top.dialog.file({
type: 'file',
title: '上传'+ explain,
width: '400px',
height: '420px',
maxFileCount: '1',
onClose: function() {
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
var files = $('#'+ name).val();
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
if(files.length > 0) {
files += ',';
}
files += file.data;
}
initFileList(name, files, function(fileName) {
});
}
}
});
});
form.on('button(mailFilesRemoveFile)', function(obj) {
var name = this.dataset.name;
var id = this.dataset.id;
var files = $('#'+ name).val().replace(id, '');
files = files.replace(/\,+/g, ',');
if(files.charAt(0) == ',') {
files = files.substring(1);
}
if(files.charAt(files.length - 1) == ',') {
files = files.substring(0, files.length - 1);
}
initFileList(name, files, function(fileName) {
});
});
}
$(document).on('click', '.file-down-event', function(){
var fileId = $(this).data().id;
if( typeof (fileId) != 'undefined' && fileId != ''){
window.open("route/file/download/false/" + fileId);
}
});
// 初始化正文
function initRichContentContentRichText() {
var editor = new wangEditor('#richContent');
// 自定义菜单配置
editor.customConfig.menus = [
//'head', // 标题
'bold', // 粗体
'fontSize', // 字号
'fontName', // 字体
// 'italic', // 斜体
'underline', // 下划线
'strikeThrough', // 删除线
'foreColor', // 文字颜色
// 'backColor', // 背景颜色
'link', // 插入链接
// 'list', // 列表
'justify', // 对齐方式
// 'quote', // 引用
// 'emoticon', // 表情
//'image', // 插入图片
// 'table', // 表格
// 'video', // 插入视频
// 'code', // 插入代码
'undo', // 撤销
'redo' // 重复
];
editor.customConfig.zIndex = 100;
editor.customConfig.uploadImgMaxSize = 5 * 1024 * 1024;
editor.customConfig.uploadImgParamsWithUrl = true;
editor.customConfig.uploadImgMaxLength = 1;
editor.customConfig.uploadFileName = 'image';
editor.customConfig.uploadImgServer = 'api/file/wangeditorimage';
// 创建 & 全屏 & 预览 & 图片加url wangEditor-fullscreen-plugin.js
wangEditor.fullscreen.init('#richContent', editor);
wangEditorObj['richContent'] = editor;
}
// 选择收件人
$(document).on('click', '#recipientNames', function () {
selectSend();
});
function selectSend(){
top.dialog.dialogData.selectedUserIds = $('#recipientIds').val().replaceAll(",","_");
top.dialog.open({
url: top.restAjax.path('route/department/user/select-user', []),
title: '选择收件人',
width: '600px',
height: '500px',
closeBtn: 0,
onClose: function() {
var insertUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(insertUsers.length == 0){
$('#recipientIds').val('');
$('#recipientNames').val('');
return;
}
if(insertUsers.length > 0) {
var recipientIds = '';
var recipientNames = '';
for (var i = 0, item; item = insertUsers[i++];) {
recipientIds += item.userId + ',';
recipientNames += item.userName + '[' + item.username + ']' + ',';
}
if(recipientIds.lastIndexOf(',') != -1){
recipientIds = recipientIds.substring(0, recipientIds.length - 1);
recipientNames = recipientNames.substring(0, recipientNames.length -1);
}
$('#recipientIds').val(recipientIds);
$('#recipientNames').val(recipientNames);
}
}
})
}
// 选择抄送人
$(document).on('click', '#copyForNames', function () {
selectCopyFor();
});
function selectCopyFor(){
top.dialog.dialogData.selectedUserIds = $('#copyForIds').val().replaceAll(",","_");
top.dialog.open({
url: top.restAjax.path('route/department/user/select-user', []),
title: '选择抄送人',
width: '600px',
height: '500px',
closeBtn: 0,
onClose: function() {
var insertUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(insertUsers.length == 0){
$('#copyForIds').val('');
$('#copyForNames').val('');
return;
}
if(insertUsers.length > 0) {
var copyForIds = '';
var copyForNames = '';
for (var i = 0, item; item = insertUsers[i++];) {
copyForIds += item.userId + ',';
copyForNames += item.userName + '[' + item.username + ']' + ',';
}
if(copyForIds.lastIndexOf(',') != -1){
copyForIds = copyForIds.substring(0, copyForIds.length - 1);
copyForNames = copyForNames.substring(0, copyForNames.length -1);
}
$('#copyForIds').val(copyForIds);
$('#copyForNames').val(copyForNames);
}
}
})
}
// 选择密送人
$(document).on('click', '#secretNames', function () {
selectSecret();
});
function selectSecret(){
top.dialog.dialogData.selectedUserIds = $('#secretIds').val().replaceAll(",","_");
top.dialog.open({
url: top.restAjax.path('route/department/user/select-user', []),
title: '选择密送人',
width: '600px',
height: '500px',
closeBtn: 0,
onClose: function() {
var insertUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(insertUsers.length == 0){
$('#secretIds').val('');
$('#secretNames').val('');
return;
}
if(insertUsers.length > 0) {
var secretIds = '';
var secretNames = '';
for (var i = 0, item; item = insertUsers[i++];) {
secretIds += item.userId + ',';
secretNames += item.userName + '[' + item.username + ']' + ',';
}
if(secretIds.lastIndexOf(',') != -1){
secretIds = secretIds.substring(0, secretIds.length - 1);
secretNames = secretNames.substring(0, secretNames.length -1);
}
$('#secretIds').val(secretIds);
$('#secretNames').val(secretNames);
}
}
})
}
form.on('submit(submitSend)', function(formData) {
commitSendMail(formData);
});
form.on('submit(submitDraft)', function(formData) {
commitDraftMail(formData);
});
function commitSendMail(formData){
formData.field['contentRich'] = wangEditorObj['richContent'].txt.html();
formData.field['content'] = wangEditorObj['richContent'].txt.text();
top.dialog.confirm("确认要发送吗?", function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/mail/save-send-mail', []), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg("发送成功", {
time: 0,
btn: [top.dataMessage.button.yes],
shade: 0.3,
yes: function(index) {
window.location.reload();
top.dialog.close(index);
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
}
function commitDraftMail(formData){
formData.field['contentRich'] = wangEditorObj['richContent'].txt.html();
formData.field['content'] = wangEditorObj['richContent'].txt.text();
top.dialog.confirm("确认要保存到草稿箱吗?", function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/mail/save-draft-mail', []), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg("保存成功", {
time: 0,
btn: [top.dataMessage.button.yes],
shade: 0.3,
yes: function(index) {
window.location.reload();
top.dialog.close(index);
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
}
});
</script>
</body>
</html>