EmailWriteForm.cshtml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. @{
  2. ViewBag.Title = "写邮件表单";
  3. Layout = "~/Views/Shared/_Form.cshtml";
  4. }
  5. <link href="~/Content/scripts/plugins/uploadify/uploadify.css" rel="stylesheet" />
  6. <script src="~/Content/scripts/plugins/uploadify/jquery.uploadify.min.js"></script>
  7. <link href="~/Content/scripts/plugins/simditor/css/simditor.css" rel="stylesheet" />
  8. <script src="~/Content/scripts/plugins/simditor/js/module.min.js"></script>
  9. <script src="~/Content/scripts/plugins/simditor/js/hotkeys.min.js"></script>
  10. <script src="~/Content/scripts/plugins/simditor/js/simditor.min.js"></script>
  11. <link href="~/Content/scripts/plugins/cxColor/css/jquery.cxcolor.css" rel="stylesheet" />
  12. <script src="~/Content/scripts/plugins/cxColor/js/jquery.cxcolor.js"></script>
  13. <script>
  14. var keyValue = request('keyValue');
  15. var editor = null;
  16. var files = [];
  17. $(function () {
  18. editor = new Simditor({
  19. textarea: $('#EmailContent'),
  20. toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent']
  21. });
  22. $("#form-body").height($(window).height() - 46);
  23. $(".simditor .simditor-body").height(300).css({ "overflow": "auto", "min-height": "0" });
  24. initControl();
  25. uploadify();
  26. initUserList();
  27. })
  28. //初始化控件
  29. function initControl() {
  30. //抄送点击事件copysendAreas
  31. $("#btn_copysend").click(function () {
  32. if (!$(this).hasClass("active")) {
  33. $(this).addClass('active').html('删除抄送');
  34. $("#copysendAreas").show();
  35. var _height = 38 + ($("#bccsendAreas").is(':hidden') == true ? 0 : 38);
  36. $(".simditor .simditor-body").height(300 - _height);
  37. } else {
  38. $(this).removeClass('active').html('抄送');
  39. $("#copysendAreas").hide();
  40. var _height = 0 + ($("#bccsendAreas").is(':hidden') == true ? 0 : 38);
  41. $(".simditor .simditor-body").height(300 - _height);
  42. $("#txt_copysend").find('div.mail-send-addresss').html('');
  43. }
  44. });
  45. //密送点击事件
  46. $("#btn_bccsend").click(function () {
  47. if (!$(this).hasClass("active")) {
  48. $(this).addClass('active').html('删除密送');
  49. $("#bccsendAreas").show();
  50. var _height = 38 + ($("#copysendAreas").is(':hidden') == true ? 0 : 38);
  51. $(".simditor .simditor-body").height(300 - _height);
  52. } else {
  53. $(this).removeClass('active').html('密送');
  54. $("#bccsendAreas").hide();
  55. var _height = 0 + ($("#copysendAreas").is(':hidden') == true ? 0 : 38);
  56. $(".simditor .simditor-body").height(300 - _height);
  57. $("#txt_bccsend").find('div.mail-send-addresss').html('');
  58. }
  59. });
  60. //添加(收件人、抄送认、密送人)事件
  61. $('#btn_add_addresss,#btn_add_copysend,#btn_add_bccsend').click(function () {
  62. var $this = $(this).prev('div.form-control');
  63. $this.addClass('active');
  64. $("#selectUserList").animate({ left: 870, speed: 2000 }).show().height($(window).height() - 45).attr('data-type', $(this).attr('id'));
  65. $("#selectUserList_background").show().click(function () {
  66. $this.removeClass('active');
  67. $(this).hide();
  68. $("#selectUserList").animate({ left: 1100, speed: 2000 }).hide();
  69. });
  70. });
  71. //获取表单
  72. if (!!keyValue) {
  73. $.SetForm({
  74. url: "../../PublicInfoManage/Email/GetEmailFormJson",
  75. param: { keyValue: keyValue },
  76. success: function (data) {
  77. $("#form1").SetWebControls(data);
  78. editor.setValue(data.EmailContent);
  79. $("#Theme").attr("color", data.ThemeColor).css("color", data.ThemeColor);
  80. $("#txt_addresss").html(data.AddresssHtml);
  81. $("#txt_copysend").html(data.CopysendHtml);
  82. $("#txt_bccsend").html(data.BccsendHtml);
  83. if ($("#txt_copysend").find('div.mail-send-address').length > 0) {
  84. $("#btn_copysend").trigger("click");
  85. }
  86. if ($("#txt_bccsend").find('div.mail-send-address').length > 0) {
  87. $("#btn_bccsend").trigger("click");
  88. }
  89. }
  90. });
  91. }
  92. }
  93. //初始化加载用户列表
  94. function initUserList() {
  95. var item = {
  96. slimscroll: false,
  97. height: $(window).height() - 46,
  98. url: "../../BaseManage/User/GetTreeJson",
  99. onnodeclick: function (item) {
  100. if (item.Sort == "User") {
  101. var userId = item.id;
  102. var userName = item.text;
  103. var userCode = item.value;
  104. var datatype = $("#selectUserList").attr('data-type');
  105. var _length = $('.mail-send-addresss').find('[data-value=' + userId + ']').length;
  106. if (_length == 0) {
  107. $("#" + datatype).prev('div.form-control').find('.mail-send-addresss').append('<div class="mail-send-address" data-value=' + userId + ' ><div class="mail-send-address-name" title=' + item.title + ' >' + userName + '</div><div title="删除" class="mail-send-address-del" onclick="$(this).parent().remove()">×</div></div>');
  108. }
  109. }
  110. }
  111. };
  112. //初始化
  113. $("#selectUserList").treeview(item);
  114. }
  115. //上传文件
  116. function uploadify() {
  117. $("#uploadify").uploadify({
  118. uploader: '/PublicInfoManage/Email/FileUpload',
  119. swf: '/Content/scripts/plugins/uploadify/uploadify.swf',
  120. buttonText: "上传文件",
  121. height: 30,
  122. width: 90,
  123. removeCompleted: false,
  124. onUploadSuccess: function (file, data, response) {
  125. var da = JSON.parse(data);;
  126. files.push(da.Data);
  127. }
  128. });
  129. $("#uploadify-button").prepend('<i style="opacity: 0.6;" class="fa fa-cloud-upload"></i>&nbsp;');
  130. }
  131. //选择颜色-设置标题色彩
  132. function SelectColorEvent() {
  133. var mycolor = $("#select_color").cxColor();
  134. mycolor.show();
  135. $("#select_color").bind("change", function () {
  136. $("#Theme").css("color", this.value).attr("color", this.value);
  137. });
  138. }
  139. //保存表单
  140. function AcceptClick(SendState) {
  141. var addresssData = [];
  142. var copysendData = [];
  143. var bccsendData = [];
  144. $("#txt_addresss .mail-send-address").each(function() {
  145. addresssData.push($(this).attr('data-value'));
  146. });
  147. $("#txt_copysend .mail-send-address").each(function() {
  148. copysendData.push($(this).attr('data-value'));
  149. });
  150. $("#txt_bccsend .mail-send-address").each(function() {
  151. bccsendData.push($(this).attr('data-value'));
  152. });
  153. if (addresssData.length == 0) {
  154. top.dialogTop('请填写收件人后再发送', 'error');
  155. return false;
  156. }
  157. //if (!$("#copysendAreas").is(':hidden') && copysendData.length == 0) {
  158. // top.dialogTop('请填写抄送人后再发送', 'error');
  159. // return false;
  160. //}
  161. //if (!$("#bccsendAreas").is(':hidden') && bccsendData.length == 0) {
  162. // top.dialogTop('请填写密送人后再发送', 'error');
  163. // return false;
  164. //}
  165. if ($("#Theme").val() == "") {
  166. top.dialogTop('请填写主题后再发送', 'error');
  167. return false;
  168. }
  169. if (!$("#copysendAreas").is(':hidden')) {
  170. $("#txt_copysend .mail-send-address").each(function() {
  171. copysendData.push($(this).attr('data-value'));
  172. });
  173. }
  174. if (!$("#bccsendAreas").is(':hidden')) {
  175. $("#txt_bccsend .mail-send-address").each(function() {
  176. bccsendData.push($(this).attr('data-value'));
  177. });
  178. }
  179. var postData = {
  180. SendState: SendState,
  181. Theme: $("#Theme").val(),
  182. ThemeColor: $('#Theme').attr('color'),
  183. EmailContent: editor.getValue(),
  184. SendPriority: $("#SendPriority").is(":checked") == true ? 1 : 0,
  185. IsReceipt: $("#IsReceipt").is(":checked") == true ? 1 : 0,
  186. IsSmsReminder: $("#IsSmsReminder").is(":checked") == true ? 1 : 0,
  187. AddresssHtml: $("#txt_addresss").html(),
  188. CopysendHtml: $("#txt_copysend").html(),
  189. BccsendHtml: $("#txt_bccsend").html(),
  190. addresssIds: String(addresssData),
  191. copysendIds: String(copysendData),
  192. bccsendIds: String(bccsendData),
  193. Files:JSON.stringify(files)
  194. }
  195. $.SaveForm({
  196. url: "../../PublicInfoManage/Email/SaveEmailForm?keyValue=" + keyValue,
  197. param: postData,
  198. loading: keyValue != "" ? "正在存入草稿..." : "正在发送数据...",
  199. success: function(data) {
  200. $.currentIframe().reload();
  201. }
  202. });
  203. }
  204. </script>
  205. <div id="form-body" style="overflow: auto;">
  206. <div style="margin-top: 20px; margin-right: 30px;">
  207. <table class="form" style="table-layout: auto;">
  208. <tr>
  209. <td class="formTitle" valign="top" style="padding-top: 11px;">收件人</td>
  210. <td class="formValue">
  211. <div id="txt_addresss" class="form-control" style="padding-left: 3px; height: auto; min-height: 28px;">
  212. <div class="mail-send-addresss"></div>
  213. </div>
  214. <span id="btn_add_addresss" class="input-button" title="添加收件人">...</span>
  215. </td>
  216. </tr>
  217. <tr id="copysendAreas" style="display:none">
  218. <td class="formTitle" valign="top" style="padding-top: 11px;">抄送人</td>
  219. <td class="formValue">
  220. <div id="txt_copysend" class="form-control" style="padding-left: 3px;">
  221. <div class="mail-send-addresss"></div>
  222. </div>
  223. <span id="btn_add_copysend" class="input-button" title="添加抄送人">...</span>
  224. </td>
  225. </tr>
  226. <tr id="bccsendAreas" style="display:none">
  227. <td class="formTitle" valign="top" style="padding-top: 11px;">密送人</td>
  228. <td class="formValue">
  229. <div id="txt_bccsend" class="form-control" style="padding-left: 3px;">
  230. <div class="mail-send-addresss"></div>
  231. </div>
  232. <span id="btn_add_bccsend" class="input-button" title="添加密送人">...</span>
  233. </td>
  234. </tr>
  235. <tr>
  236. <td class="formTitle"></td>
  237. <td class="formValue">
  238. <a id="btn_copysend" title="什么是抄送:同时将这一封邮件发送给其他联系人。"
  239. style="color: #95A0AA; cursor: pointer;">抄送</a>&nbsp;
  240. <a id="btn_bccsend" title="什么是密送:同时将这一封邮件发送给其他联系人,但收件人及抄送人不会看到密送人。"
  241. style="color: #95A0AA; cursor: pointer;">密送</a>&nbsp;
  242. <a id="btn_groupsend" title="什么是单独:会对多个人一对一发送。每个人将收到单独发给他/她的邮件。"
  243. style="color: #95A0AA; cursor: pointer;">单独发送</a>&nbsp;
  244. </td>
  245. </tr>
  246. <tr>
  247. <td class="formTitle">主题</td>
  248. <td class="formValue">
  249. <input id="Theme" type="text" class="form-control" style="color: #000000;" />
  250. <span id="select_color" class="input-button" style="width: 18px; margin-top: -9px; height: auto;" title="使用主题彩色" onclick="SelectColorEvent()">
  251. <img src="~/Content/images/large_tiles.png" />
  252. </span>
  253. </td>
  254. </tr>
  255. <tr>
  256. <td class="formTitle" valign="top" style="padding-top: 12px; height: 37px;">附件</td>
  257. <td class="formValue">
  258. <input id="uploadify" name="uploadify" type="file" />
  259. </td>
  260. </tr>
  261. <tr>
  262. <th class="formTitle" valign="top" style="padding-top: 4px;">内容</th>
  263. <td class="formValue">
  264. <textarea id="EmailContent" class="form-control" rows="5"></textarea>
  265. </td>
  266. </tr>
  267. <tr>
  268. <td class="formTitle"></td>
  269. <td class="formValue">
  270. <div class="checkbox user-select" style="color: #95A0AA;">
  271. <label>
  272. <input id="SendPriority" type="checkbox" />
  273. 紧急
  274. </label>
  275. <label>
  276. <input id="IsReceipt" type="checkbox" />
  277. 已读回执
  278. </label>
  279. <label>
  280. <input id="IsSmsReminder" type="checkbox" />
  281. 短信提醒
  282. </label>
  283. </div>
  284. <span style="position: absolute; top: 5px; right: 5px;">发件人:超级管理员(System)</span>
  285. </td>
  286. </tr>
  287. </table>
  288. </div>
  289. </div>
  290. <div class="form-button" id="wizard-actions">
  291. <a class="btn btn-success" onclick="AcceptClick(1)">立即发送</a>
  292. <a class="btn btn-default" onclick="AcceptClick(0)">存草稿箱</a>
  293. <input checked="checked" type="checkbox" id="IsdialogClose" style="vertical-align: middle;margin-bottom:2px; display:none">
  294. </div>
  295. <div id="selectUserList_background" style="display: none; width: 100%; height: 100%; opacity: 0.0; filter: alpha(opacity=00); background: #fff; position: absolute; top: 0; left: 0; z-index: 100;"></div>
  296. <div id="selectUserList" style="box-shadow: 0 0px 12px rgba(0,0,0,.175); position: fixed; top: 0px; left: 1100px; z-index: 101; width: 230px; border-left: 1px solid #ccc; background: #fff; overflow: hidden; overflow-y: auto; display: none;">
  297. </div>