EmailWriteForm.cshtml 14 KB

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