<apex:page id="Page" standardController="Mail_Merge__c" extensions="SendEmailController" sidebar="false" showHeader="false" action="{!init}" title="SendEmail">
|
|
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
|
|
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
|
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
|
<apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
|
<apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
|
|
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no"/>
|
<style type="text/css">
|
.tableCss{
|
width: 100%;
|
border: 0;
|
}
|
.errorMessage{
|
font-size: 15px;
|
color:#FF0000;
|
}
|
.title{
|
height: 30px;
|
background-color: #DFE6F0;
|
}
|
.title font{
|
font-size:15px;
|
color:#607799;
|
}
|
</style>
|
<script>
|
|
function formSubmit(){
|
testFile();
|
}
|
function openPDF(){
|
//var typeId = "{!mail.RECORD__c}";
|
var baseUrl = j$(escapeVfId("baseUrl")).value();
|
window.open(baseUrl + '/apex/QuotesPDF?id={!mail.RECORD__c}');
|
}
|
function openSearchMemberPage(lineNum){
|
var baseUrl = j$(escapeVfId("baseUrl")).value();
|
//var repairId = j$(escapeVfId("repairId")).value();
|
window.open(baseUrl + '/apex/SearchMemberPage?lineNum='+lineNum,'pselect', 'width=600,height=450,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=1', true);
|
}
|
function refreshPage(lineNum,memberId,memberName,memberEmail){
|
/*var memberNameId = "memberName"+lineNum;
|
var memberEmailId = "memberEmail"+lineNum;
|
j$(escapeVfId(memberNameId)).attr("value",memberName);
|
j$(escapeVfId(memberEmailId)).attr("value",memberEmail);*/
|
addMemberData(lineNum,memberId,memberName,memberEmail);
|
}
|
function statusChabge(linenumNum,type){
|
var toId = "Page:messageForm:lineDataList:"+linenumNum+":"+"to";
|
var ccId = "Page:messageForm:lineDataList:"+linenumNum+":"+"cc";
|
var bccId = "Page:messageForm:lineDataList:"+linenumNum+":"+"bcc";
|
var toValue = j$(escapeVfId(toId)).value();
|
var ccValue = j$(escapeVfId(ccId)).value();
|
var bccValue = j$(escapeVfId(bccId)).value();
|
j$(escapeVfId(toId)).attr("checked",false);
|
j$(escapeVfId(ccId)).attr("checked",false);
|
j$(escapeVfId(bccId)).attr("checked",false);
|
//这个if判断,保证三个收件人类型有一个时选中的,不可以三个都为不勾选
|
//if(toValue == ""&&ccValue==""&&bccValue==""){
|
if(type == "to"){
|
j$(escapeVfId(toId)).attr("checked",true);
|
}
|
if(type == "cc"){
|
j$(escapeVfId(ccId)).attr("checked",true);
|
}
|
if(type == "bcc"){
|
j$(escapeVfId(bccId)).attr("checked",true);
|
}
|
//}
|
//下边三个if,三个勾选框互斥,只能勾选一个
|
/*if(type == "to"){
|
j$(escapeVfId(ccId)).attr("checked",false);
|
j$(escapeVfId(bccId)).attr("checked",false);
|
}
|
if(type == "cc"){
|
j$(escapeVfId(toId)).attr("checked",false);
|
j$(escapeVfId(bccId)).attr("checked",false);
|
}
|
if(type == "bcc"){
|
j$(escapeVfId(toId)).attr("checked",false);
|
j$(escapeVfId(ccId)).attr("checked",false);
|
}*/
|
}
|
|
//dialog 弹窗 start
|
var popupBox;
|
popupBox = new SimpleDialog("SpeedDialogId", false); // 不可拖动
|
popupBox.createDialog();
|
function openFile(){
|
// alert('111111111');
|
// uploadFileS();
|
popupBox.setTitle("请选择要上传的图片!");
|
popupBox.importContentNode(document.getElementById("Page:messageForm:popupBox"));
|
popupBox.show(document.getElementById("Page:messageForm:popupBox"));
|
document.getElementById("Page:messageForm:popupBox").style.display = 'block';
|
|
|
}
|
//dialog 弹窗 end
|
|
//上传图片
|
function saveAttachment(){
|
var maxFileSize = 4350000; //Base64 编码以后最大的文件字节数
|
var attachmentBody; //附件内容
|
var attachmentName; //附件名称
|
var attachmentType; //附件名称
|
var attachmentSize; //附件大小
|
var parentId = j$(escapeVfId("parentId")).value();
|
// 获取上传图片的数量
|
var size = document.getElementById("file_input").files.length;
|
if (size > 0) {
|
var nameList = [];
|
var typeList = [];
|
var bodyList = [];
|
for(var i = 0;i < size;i++){
|
var fbody = document.getElementById("file_input").files[i];
|
attachmentName = fbody.name;
|
if(fbody.size <= maxFileSize) {
|
attachmentType = fbody.type;
|
nameList.push(attachmentName);
|
typeList.push(attachmentType);
|
var fileReader = new FileReader();
|
fileReader.readAsBinaryString(fbody);
|
fileReader.onload = function(e) {
|
bodyList.push(window.btoa(this.result));
|
}
|
fileReader.onerror = function(e) {
|
alert("上传失败,请重新尝试");
|
}
|
fileReader.onabort = function(e) {
|
alert("上传失败,请重新尝试");
|
}
|
} else {
|
alert("Base64 编码最大允许4.3M文件,"+attachmentName + '过大无法上传');
|
}
|
|
|
}
|
if (nameList.length > 0) {
|
//使用RemoteAction上传附件
|
Visualforce.remoting.Manager.invokeAction(
|
'{!$RemoteAction.SendEmailController.AddAttachment}',
|
nameList,
|
typeList,
|
bodyList,
|
parentId,
|
function(result,event) {
|
|
if(result == '文件上传成功'){
|
alert(result);
|
RefreshPage();
|
} else if (result == null){
|
result = '文件上传失败,请重新上传';
|
alert(result);
|
RefreshPage();
|
} else {
|
alert(result);
|
}
|
|
});
|
|
}
|
|
}
|
|
|
}
|
</script>
|
<div style="width : 100%;">
|
<div style="width : 70%; margin: auto;">
|
<apex:form id="messageForm">
|
<input type="hidden" id="baseUrl" value="{!baseUrl}"/>
|
<input type="hidden" id="parentId" value="{!Id}"/>
|
<input type="hidden" id="isOnClick" value="{!isOnClick}"/>
|
<apex:actionFunction name="addMemberData" action="{!addMemberData}" reRender="messageForm">
|
<apex:param name="lineNum" assignTo="{!lineNum}" value="" />
|
<apex:param name="memberId" assignTo="{!memberId}" value="" />
|
<apex:param name="memberName" assignTo="{!memberName}" value="" />
|
<apex:param name="memberEmail" assignTo="{!memberEmail}" value="" />
|
</apex:actionFunction>
|
<!-- 图片批量上传 保存Email -->
|
<apex:actionFunction name="uploadFileS" action="{!uploadFileS}" reRender="messageForm" oncomplete="openFile();"/>
|
<!-- 图片批量上传 刷新页面 -->
|
<apex:actionFunction name="RefreshPage" action="{!RefreshPage}" reRender="messageForm"/>
|
<apex:actionFunction name="deleteFile" reRender="fileForm">
|
<!-- <apex:param name="lineNum" assignTo="{!lineNum}" value="" /> -->
|
</apex:actionFunction>
|
|
<div style="width: 100%">
|
<div class="errorMessage" style="margin-left: 39%">
|
<span id="errorMessage">{!errorMessage}</span>
|
</div>
|
</div>
|
|
<div style="width: 100%;">
|
<table class="tableCss">
|
<tr class="title">
|
<th colspan="2"><font>Recipients</font></th>
|
</tr>
|
<tr>
|
<th style="width: 20%;text-align:center;">FROM:</th>
|
<td><apex:outputText value="{!mail.FROM__c}" style="width: 40%"/></td>
|
</tr>
|
</table>
|
</div>
|
<div style="width: 50%;margin-left: 20%;">
|
<!-- style="border:1px solid #000000;" -->
|
<table class="tableCss">
|
<thead>
|
<tr>
|
<th style="width: 25%;text-align:center;">email</th>
|
<th style="width: 10%;text-align:center;">name</th>
|
<th style="width: 5%;text-align:center;">TO</th>
|
<th style="width: 5%;text-align:center;">CC</th>
|
<th style="width: 5%;text-align:center;">BCC</th>
|
<th style="width: 5%;text-align:center;"></th>
|
</tr>
|
</thead>
|
<tbody id="memberBody">
|
<apex:repeat id="lineDataList" value="{!memberLineDatas}" var="lineData">
|
<tr style="text-align:center;">
|
<td>
|
<input type="hidden" id="memberName{!lineData.lineNum}" value="{!lineData.name}" />
|
<apex:inputText value="{!lineData.emailAddress}" /></td>
|
<td><apex:inputText value="{!lineData.name}" /></td>
|
<td><apex:inputCheckbox onclick="statusChabge({!lineData.lineNum},'to')" id="to" value="{!lineData.to}"/></td>
|
<td><apex:inputCheckbox onclick="statusChabge({!lineData.lineNum},'cc')" id="cc" value="{!lineData.cc}"/></td>
|
<td><apex:inputCheckbox onclick="statusChabge({!lineData.lineNum},'bcc')" id="bcc" value="{!lineData.bcc}"/></td>
|
<td><apex:commandButton onclick="blockme();" action="{!deLine}" reRender="messageForm" value="delete" oncomplete="unblockUI();" disabled="{!isOnClick}">
|
<apex:param name="lineNum" assignTo="{!lineNum}" value="{!lineData.lineNum}" />
|
</apex:commandButton></td>
|
<td>
|
<apex:commandButton onclick="openSearchMemberPage({!lineData.lineNum});" value="Search" disabled="{!isOnClick}">
|
|
</apex:commandButton>
|
</td>
|
</tr>
|
</apex:repeat>
|
</tbody>
|
<thead>
|
<tr style="text-align:center;">
|
<td><apex:commandButton id="addLine" onclick="blockme();" action="{!addLine}" reRender="messageForm" value="ADD Member" oncomplete="unblockUI();" disabled="{!isOnClick}"></apex:commandButton></td>
|
</tr>
|
</thead>
|
</table>
|
</div>
|
<div style="width: 100%">
|
<table class="tableCss">
|
<tr class="title">
|
<th colspan="2"><font>Message</font></th>
|
</tr>
|
<tr>
|
<th style="width: 20%;text-align:center;">Date Time:</th>
|
<td><apex:inputField value="{!mail.DATE__c}" style="width: 40%"/></td>
|
</tr>
|
<!-- <tr>
|
<th style="width: 20%;text-align:center;">RECORD:</th>
|
<td><apex:inputField value="{!mail.RECORD__c}" style="width: 40%"/></td>
|
</tr>
|
<tr>
|
<th style="width: 20%;text-align:center;">RECORD TYPE:</th>
|
<td><apex:inputField value="{!mail.RECORD_TYPE__c}" style="width: 40%"/></td>
|
</tr> -->
|
<tr>
|
<th style="text-align:center;width: 20%;">SUBJECT:</th>
|
<td><apex:inputField value="{!mail.SUBJECT__c}" style="width: 40%"/></td>
|
</tr>
|
<tr>
|
<th style="text-align:center;width: 20%;">MESSAGE:</th>
|
<td><apex:inputField style="height: 200px;width: 60%" value="{!mail.MESSAGE__c}"/></td>
|
</tr>
|
</table>
|
</div>
|
<!-- </apex:form>
|
<apex:form id="fileForm"> -->
|
<div style="width: 100%">
|
<table class="tableCss">
|
<tr class="title">
|
<th colspan="2"><font>Attachments</font></th>
|
</tr>
|
|
<tr>
|
<td>
|
<apex:commandButton value="Upload Attachment" action="{!uploadFile}" disabled="{!isOnClick}">
|
</apex:commandButton>
|
<apex:panelGroup >
|
<apex:commandButton onclick="uploadFileS();return false;" value="图片批量上传" disabled="{!isOnClick}"/>
|
</apex:panelGroup>
|
</td>
|
</tr>
|
</table>
|
</div>
|
<div style="margin-left: 5px;">
|
<!-- border:1px solid #000000; -->
|
<table class="tableCss" style="width: 80%">
|
<tr style="text-align:center;">
|
<th style="text-align:center;width: 33%;">File Name</th>
|
<th style="text-align:center;width: 33%;">Upload Time</th>
|
<th style="text-align:center;width: 33%;">File Size</th>
|
</tr>
|
<apex:repeat id="attachmentList" value="{!attachmentList}" var="attachment">
|
<tr style="text-align:center; vertical-align: middle;">
|
<!-- <td><input value="{!attachment.Name}" readonly="readonly" style="border:none;"/></td> -->
|
<td><apex:outputLink value="/{!attachment.Id}">{!attachment.Name}</apex:outputLink></td>
|
<td><apex:inputField value="{!attachment.CreatedDate}"/></td>
|
<td><apex:inputField value="{!attachment.BodyLength}"/></td>
|
<td id="{!attachment.Id}">
|
<apex:commandButton id="deleteFile" value="delete" action="{!deleteFile}" reRender="messageForm" onclick="blockme();" oncomplete="unblockUI();" disabled="{!isOnClick}">
|
<apex:param name="fileId" assignTo="{!fileId}" value="{!attachment.Id}" />
|
</apex:commandButton>
|
</td>
|
</tr>
|
</apex:repeat>
|
</table>
|
</div>
|
|
<div style="width: 30%;height: 5%;margin-left: 30%;margin-top: middle;">
|
<apex:outputPanel rendered="{!IF(type == 'Quotes', true, false)}">
|
<apex:commandButton id="open" value="查看报价单" onclick="openPDF()" style="width: 49%;height: 5%" />
|
<apex:commandButton id="addPDf" value="添加报价单" action="{!addPDF}" onclick="blockme();" oncomplete="unblockUI();" reRender="messageForm" style="width: 49%;height: 5%" disabled="{!isOnClick}"/>
|
</apex:outputPanel>
|
<apex:commandButton id="test" action="{!SendEmail}" value="Send Mail" onclick="blockme();" oncomplete="unblockUI();" reRender="messageForm" style="width: 99%;height: 5%" disabled="{!isOnClick}">
|
<apex:param name="handleType" assignTo="{!handleType}" value="send" />
|
</apex:commandButton>
|
</div>
|
<apex:outputPanel id="popupBox" layout="block" style="display:none">
|
|
<input type="file" id="file_input" name="attFile" multiple="true"/><br/>
|
<center>
|
<apex:commandButton value="确认" onclick="saveAttachment(); return false;" style="width: 20%; margin: 20px 10px 0px 10px" />
|
<apex:commandButton value="取消" onclick="popupBox.hide();" style="width: 20%; margin: 20px 10px 0px 10px" />
|
</center>
|
</apex:outputPanel>
|
</apex:form>
|
</div>
|
</div>
|
</apex:page>
|