168 lines
7.7 KiB
Plaintext
168 lines
7.7 KiB
Plaintext
@using WX.CRM.WebHelper
|
||
@{
|
||
ViewBag.Title = "发送短信";
|
||
Layout = "~/Views/Shared/_EasyUI_Layout.cshtml";
|
||
}
|
||
<script src="~/Scripts/jquery.form.js"></script>
|
||
<link href="~/Content/main.css" rel="stylesheet" />
|
||
|
||
@{string erroMessage = ViewBag.erroMessage as string; }
|
||
@if (!string.IsNullOrWhiteSpace(erroMessage))
|
||
{
|
||
<div>@Html.Raw(erroMessage)</div>
|
||
}
|
||
else
|
||
{
|
||
<div data-options="region:'north',border:false" style="height:30px;">
|
||
<div class="mvctool" style="background-color: #d2e0f2; border-color: #8db2e3; padding:5px;">
|
||
<span class="mvctool_title">客户ID:@Html.Raw(Request.QueryString["resId"])</span>
|
||
</div>
|
||
</div>
|
||
<div data-options="region:'west',split:true" style="width:400px; border-left: none;">
|
||
<div class="easyui-layout" data-options="fit:true">
|
||
<div data-options="region:'west',split:true,collapsible:false,title:'模版类型'" style="width: 200px; border-top: none;border-bottom:none;">
|
||
<ul id="ulMsgSubType"></ul>
|
||
</div>
|
||
<div data-options="region:'center',title:'短信模版'" style="border-right: none; border-top: none; border-bottom: none;">
|
||
<ul id="ulTemplate" style="margin:5px 0px 5px 5px;"></ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div data-options="region:'center',title:'模版内容'">
|
||
<form name="form1" id="from1" method="post">
|
||
<input id="msgTypeCode" name="msgTypeCode" type="hidden" value="CRMSMS0001" />
|
||
<input id="msgSubTypeCode" name="msgSubTypeCode" type="hidden" value="" />
|
||
<input id="resId" name="resId" type="hidden" value="@Html.Raw(Request.QueryString["resId"])" />
|
||
<input id="para" name="para" type="hidden" value="" />
|
||
<div id="divTemplate" style="margin:5px;"></div>
|
||
</form>
|
||
</div>
|
||
|
||
<script>
|
||
$(function () {
|
||
$('#ulMsgSubType').tree({
|
||
url: "/Sms/MsgSubType/GetMsgCrmTreeList",
|
||
lines: true,
|
||
onSelect: function (node) {
|
||
document.getElementById("ulTemplate").innerHTML = "";
|
||
document.getElementById("divTemplate").innerHTML = "";
|
||
if (!isNaN(node.id)) {
|
||
$("#msgTypeCode").val(node.typeCode);
|
||
$("#msgSubTypeCode").val(node.subTypeCode);
|
||
GetTemplate(node.id);
|
||
}
|
||
}
|
||
|
||
});
|
||
});
|
||
function GetTemplate(msgSubType) {
|
||
$.r_post("/Sms/MsgTemplate/GetTemplate?subTypeId=" + msgSubType, function (data) {
|
||
if (data.result == true) {
|
||
var vhmtml = "";
|
||
$(data.template).each(function (i, temp) {
|
||
vhmtml += "<li><a onclick='BindTemplateMessage(\"" + temp.PKID + "\")' title='" + temp.TITLE + "' template='" + temp.PKID + "' href='javascript:void(0);'>" + temp.TITLE + "</a><input type=\"hidden\" id=\"HTemplate" + temp.PKID + "\" value=\"" + temp.TEMPLATE + "\" /><input type=\"hidden\" id=\"HParam" + temp.PKID + "\" value=\"" + temp.TPARAM + "\" /></li>"
|
||
});
|
||
$("#ulTemplate").html(vhmtml);
|
||
|
||
} else {
|
||
$("#ulTemplate").html(data.message)
|
||
}
|
||
|
||
|
||
}, "json");
|
||
}
|
||
function BindTemplateMessage(id) {
|
||
var template = document.getElementById("HTemplate" + id).value;
|
||
var param = document.getElementById("HParam" + id).value;
|
||
var strMessage = "";
|
||
strMessage = "模版内容:</br><textarea id=\"txtMessage\" name=\"txtMessage\" rows=\"5\" style=\"width:280px\" readonly=\"readonly\">" + template + "</textarea></br></br>";
|
||
|
||
var strParam = "";
|
||
if (param.length > 0) {
|
||
strMessage = strMessage + "短信内容:</br><textarea id=\"txtNewMessage\" name=\"txtNewMessage\" rows=\"5\" style=\"width:280px\" readonly=\"readonly\"></textarea></br></br>"
|
||
var arr = param.split(",");
|
||
for (var i = 0; i < arr.length; i++) {
|
||
strParam = strParam + arr[i] + "<input type=\"text\" id=\"txt" + i + "\" /></br></br>";
|
||
}
|
||
}
|
||
else {
|
||
strMessage = strMessage + "短信内容:</br><textarea id=\"txtNewMessage\" name=\"txtNewMessage\" rows=\"5\" style=\"width:280px\" readonly=\"readonly\">" + template + "</textarea></br></br>"
|
||
}
|
||
if (strParam.length > 0) {
|
||
strParam = strParam + "</br><input type=\"button\" class='btn btn-primary' value=\"生成短信\" onclick='CreateNewMessage(\"" + id + "\")' />"
|
||
}
|
||
strMessage = strMessage + strParam + "<input type=\"button\" class='btn btn-primary' value=\"发送短信\" style=\"margin-left:50px;\" onclick='return Post();'/>";
|
||
|
||
document.getElementById("divTemplate").innerHTML = strMessage;
|
||
}
|
||
|
||
function CreateNewMessage(id) {
|
||
var template = document.getElementById("HTemplate" + id).value;
|
||
var param = document.getElementById("HParam" + id).value;
|
||
if (param.length > 0) {
|
||
|
||
var paraData = "";
|
||
|
||
var arr = param.split(",");
|
||
for (var i = 0; i < arr.length; i++) {
|
||
var txt = document.getElementById("txt" + i).value;
|
||
if (txt.length < 1) {
|
||
alert("请输入:" + arr[i]);
|
||
return;
|
||
}
|
||
paraData += txt + ",";
|
||
//template = template.replace(arr[i], arr[i] + txt);
|
||
template = template.replace("{" + arr[i] + "}", txt);
|
||
}
|
||
|
||
paraData = paraData.substring(0, paraData.length - 1);
|
||
document.getElementById("para").value = paraData;
|
||
|
||
document.getElementById("txtNewMessage").value = template;
|
||
}
|
||
}
|
||
|
||
function Post() {
|
||
var message = document.getElementById("txtNewMessage").value;
|
||
//if (message.length > 175) {
|
||
// alert("短信内容超过175个字符,请修改短信模板!");
|
||
// return false;
|
||
//} else if (message.length > 0 && message.length <= 185) {
|
||
if (message.length > 0) {
|
||
$.r_ajax({
|
||
url: "/Sms/MsgTemplate/SendMsg",
|
||
type: "POST",
|
||
data: $("#from1").serialize(),
|
||
dataType: "json",
|
||
loading: true,
|
||
success: function (data) {
|
||
if (data.result == true) {
|
||
//frameReturnByMes("短信发送成功!");
|
||
layui.use('layer', function () {
|
||
var layer = layui.layer;
|
||
layer.msg("短信发送成功!");
|
||
});
|
||
reload();
|
||
} else {
|
||
//frameReturnByMes(data.retMessage);
|
||
layui.use('layer', function () {
|
||
var layer = layui.layer;
|
||
layer.msg(data.retMessage);
|
||
});
|
||
}
|
||
}
|
||
});
|
||
} else {
|
||
alert("请输入替换内容!");
|
||
return false;
|
||
}
|
||
}
|
||
function reload() {
|
||
document.getElementById("ulTemplate").innerHTML = "";
|
||
document.getElementById("divTemplate").innerHTML = "";
|
||
}
|
||
function frameReturnByMes(mes) {
|
||
$.messageBox5s('提示', mes);
|
||
}
|
||
</script>
|
||
} |