Detail.cshtml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. @{
  2. ViewBag.Title = "Detail";
  3. Layout = "~/Views/Shared/_Layout.cshtml";
  4. }
  5. @using MES.Production.Service;
  6. @using Central.Control.Domain;
  7. @using Ant.Service.Common;
  8. @using Ant.Service.Common.Enums;
  9. @using MES.Production.Entity;
  10. @using CommonToolHelper;
  11. @model Ent_YW_Notice
  12. <style>
  13. body {
  14. background-color: white;
  15. }
  16. .changeicon {
  17. float: right;
  18. margin-right: -15px;
  19. position: absolute;
  20. right: -7px;
  21. top: 0px;
  22. border: none;
  23. background-color: #18a689;
  24. color: #FFFFFF;
  25. line-height: 33px;
  26. height: 33px;
  27. }
  28. </style>
  29. <link href="~/Content/uploadone/CSS/webuploader.css" rel="stylesheet" />
  30. <link href="~/Content/uploadone/CSS/bootstrap.min.css" rel="stylesheet" />
  31. <link href="~/Content/uploadone/CSS/uploadstyle.css" rel="stylesheet" />
  32. <link href="~/Content/uploadone/CSS/font-awesome.css" rel="stylesheet" />
  33. <script src="~/Content/js/jquery/jquery-1.8.2.min.js"></script>
  34. <script src="~/Content/uploadone/Script/webuploader.js"></script>
  35. <!-- 配置文件 -->
  36. <script type="text/javascript" src="~/Content/ueditor/utf8-net/ueditor.config.js"></script>
  37. <!-- 编辑器源码文件 -->
  38. <script type="text/javascript" src="~/Content/ueditor/utf8-net/ueditor.all.js"></script>
  39. @using (Ajax.BeginForm("Save", null, new AjaxOptions()
  40. {
  41. HttpMethod = "Post",
  42. OnBegin = "SubAjax.Loading",
  43. OnComplete = "SubAjax.Complate",
  44. OnFailure = "SubAjax.Failure",
  45. OnSuccess = "SubAjax.Success"
  46. }, new { @class = "form-horizontal dig-from", @role = "form" }))
  47. {
  48. <div class="wrapper-content">
  49. @Html.Hidden("hidfilename", Model.ImgUrl)@*Html.Hidden("hidfilename", new HtmlString(ViewBag.imgurl))*@
  50. @Html.Hidden("hidfileid", Model.ImgUrl)
  51. <div class="panel-body">
  52. <div class="tab-content">
  53. <div id="tab-1" class="tab-pane active">
  54. <div class="form-group">
  55. <label class="col-lg-3 control-label">公告名称:</label>
  56. <div class="col-lg-8">
  57. @Html.HiddenFor(p => p.ID)
  58. @Html.TextBoxFor(p => p.Title, new { @class = "form-control", @id = "POSTNAME", @placeholder = "请输入公告名称", @datatype = "*", @nullmsg = "请输入岗位名称!", @errormsg = "请输入岗位名称!" })
  59. </div>
  60. </div>
  61. <div class="clearfix f-hafl">
  62. <div class="col-hafl">
  63. <div class="form-group">
  64. <label class="col-lg-3 control-label">用户类型:</label>
  65. <div class="col-lg-8">
  66. <select id="RoleId" name="RoleId" class="input-sm form-control input-s-sm inline" >
  67. @{ var post = ViewData["postType"] as List<SYS_CODE>;
  68. foreach (var item in post)
  69. {
  70. <option value="@item.CODEVALUE" @(Model.RoleId == Convert.ToInt32(item.CODEVALUE) ? "selected" : "")>@item.NAMETEXT</option>
  71. }
  72. }
  73. </select>
  74. </div>
  75. </div>
  76. </div>
  77. @*<div class="col-hafl">
  78. <div class="form-group">
  79. <label class="col-lg-3 control-label" style="width:29% !important; padding-left:5px; padding-right:5px;">显示顺序:</label>
  80. <div class="col-lg-8">
  81. @Html.TextBoxFor(p => p.RoleId, new { @class = "form-control", @placeholder = "请输入显示顺序", @datatype = "n1-10", @nullmsg = "请输入显示顺序!", @errormsg = "显示顺序必须是数字!" })
  82. </div>
  83. </div>
  84. </div>*@
  85. @*<div class="col-hafl">
  86. <div class="form-group">
  87. <label class="col-lg-3 control-label">公告类型:</label>
  88. <div class="col-lg-8" style="width:45% !important">
  89. <select id="RoleId" name="RoleId" class="input-sm form-control input-s-sm inline" style="width:auto;">
  90. <option value="10" @(Model.Noticetype == 1 ? "selected" : "")>文字消息</option>
  91. <option value="25" @(Model.Noticetype == 2 ? "selected" : "")>图文消息</option>
  92. </select>
  93. </div>
  94. </div>
  95. </div>*@
  96. </div>
  97. <div class="form-group">
  98. <label class="col-lg-3 control-label">公告内容:</label>
  99. <div class="col-lg-8">
  100. <script id="container" name="content" type="text/plain">
  101. @(new HtmlString(ViewBag.html))
  102. </script>
  103. <script type="text/javascript">
  104. var editor = UE.getEditor('container')
  105. </script>
  106. </div>
  107. </div>
  108. <div class="form-group">
  109. <label class="col-lg-3 control-label">上传公告图片:</label>
  110. <div class="col-lg-8">
  111. <div id="fileNameList">
  112. </div>
  113. <div class="cp_img_jia" id="fileNamePicker"></div>
  114. </div>
  115. </div>
  116. <div class="hr-line-dashed">
  117. <div class="form-group m20">
  118. <div class="col-sm-2 col-sm-offset-2">
  119. <button class="btn btn-primary btn-save" type="submit"><i class="fa fa-check"></i> <span>确定保存</span></button>
  120. <button class="btn btn-warning" id="btn-dig-close" type="button"><i class="im-undo2"></i> 取消返回</button>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. }
  129. @section scripts{
  130. <script type="text/javascript">
  131. var applicationPath = "http://" + window.location.host;
  132. $(function () {
  133. var filename = document.getElementById("hidfilename").value;
  134. if (filename != null && filename != "") {
  135. //alert(filename);
  136. var headstr = "<div id=\"WU_FILE_0\" class=\"cpup_img upload-state-done\"><img src=\"";
  137. var footstr = "\"><div class=\"upcp_img_jian\"></div><p class=\"progress hide\"><span style=\"width: 100%;\"></span></p></div>";
  138. document.getElementById("fileNameList").innerHTML = headstr + filename + footstr;
  139. }
  140. var $ = jQuery, fileId,
  141. $list = $('#fileNameList'),
  142. // 优化retina, 在retina下这个值是2
  143. ratio = window.devicePixelRatio || 1,
  144. // 缩略图大小
  145. thumbnailWidth = 90 * ratio,
  146. thumbnailHeight = 90 * ratio,
  147. // Web Uploader实例
  148. uploader;
  149. uploader = WebUploader.create({
  150. // 选完文件后,是否自动上传。
  151. auto: true,
  152. disableGlobalDnd: true,
  153. // swf文件路径
  154. swf: applicationPath + '/Script/Uploader.swf',
  155. // 文件接收服务端。
  156. //server: applicationPath + '/Home/UpLoadProcess',
  157. server: applicationPath + '/Sys/Home/UpLoadProcess',
  158. // 选择文件的按钮。可选。
  159. // 内部根据当前运行是创建,可能是input元素,也可能是flash.
  160. pick: '#fileNamePicker',
  161. //只允许选择图片
  162. accept: {
  163. title: 'Images',
  164. extensions: 'gif,jpg,jpeg,bmp,png',
  165. mimeTypes: 'image/*'
  166. }
  167. });
  168. // 当有文件添加进来的时候
  169. uploader.on('fileQueued', function (file) {
  170. var $li = $(
  171. '<div id="' + file.id + '" class="cpup_img">' +
  172. '<img id="jjgimg">' +
  173. '<div class="upcp_img_jian"></div></div>'
  174. ),
  175. $img = $li.find('img');
  176. $list.children().remove();//先清空元素内容
  177. if (fileId != file.id && fileId != null) {
  178. //alert(fileId);
  179. uploader.removeFile(uploader.getFile(fileId, true));
  180. }
  181. fileId = file.id;
  182. // $list为容器jQuery实例
  183. $list.append($li);
  184. // 创建缩略图
  185. // 如果为非图片文件,可以不用调用此方法。
  186. // thumbnailWidth x thumbnailHeight 为 100 x 100
  187. uploader.makeThumb(file, function (error, src) {
  188. if (error) {
  189. $img.replaceWith('<span>不能预览</span>');
  190. return;
  191. }
  192. //alert(src);
  193. //alert(file);
  194. $img.attr('src', src);
  195. }, thumbnailWidth, thumbnailHeight);
  196. });
  197. //上传压缩宽度
  198. uploader.option('compress', {
  199. width: 700
  200. });
  201. // 文件上传过程中创建进度条实时显示。
  202. uploader.on('uploadProgress', function (file, percentage) {
  203. var $li = $('#' + file.id),
  204. $percent = $li.find('.progress span');
  205. // 避免重复创建
  206. if (!$percent.length) {
  207. $percent = $('<p class="progress"><span></span></p>')
  208. .appendTo($li)
  209. .find('span');
  210. }
  211. $percent.css('width', percentage * 100 + '%');
  212. });
  213. // 文件上传成功,给item添加成功class, 用样式标记上传成功。
  214. uploader.on('uploadSuccess', function (file, response) {
  215. //alert(file.name);//原来文件名
  216. //alert(response.id);//文件路径
  217. var imgurl = response.filePath; //上传图片的路径
  218. var fileid = response.fileid; //上传图片的路径
  219. console.log(response.id);
  220. console.log(imgurl);
  221. $('#' + file.id).addClass('upload-state-done');
  222. //alert(document.getElementById("fileNameList").innerHTML.replace('class="progress"', 'class="progress hide"'));
  223. $("#hidfilename").val(imgurl);
  224. $("#jjgimg").attr('src', imgurl);//季健国加为了解决保存一串字符串
  225. $("#hidfileid").val(fileid);
  226. });
  227. // 文件上传失败,显示上传出错。
  228. uploader.on('uploadError', function (file) {
  229. var $li = $('#' + file.id),
  230. $error = $li.find('div.error');
  231. // 避免重复创建
  232. if (!$error.length) {
  233. $error = $('<div class="error"></div>').appendTo($li);
  234. }
  235. $error.text('上传失败');
  236. });
  237. // 完成上传完了,成功或者失败,先删除进度条。
  238. uploader.on('uploadComplete', function (file) {
  239. $('#' + file.id).find('.progress').remove();
  240. });
  241. //所有文件上传完毕
  242. uploader.on("uploadFinished", function () {
  243. //提交表单
  244. });
  245. //开始上传
  246. $("#ctlUpBtn").click(function () {
  247. uploader.upload();
  248. });
  249. //显示删除按钮
  250. $(".cpup_img").on("mouseover", function () {
  251. $(this).children(".upcp_img_jian").css('display', 'block');
  252. });
  253. //隐藏删除按钮
  254. $(".cpup_img").on("mouseout", function () {
  255. $(this).children(".upcp_img_jian").css('display', 'none');
  256. });
  257. //执行删除方法
  258. $list.on("click", ".upcp_img_jian", function () {
  259. var Id = $(this).parent().attr("id");
  260. try {
  261. uploader.removeFile(uploader.getFile(Id, true));
  262. }
  263. catch (ex) { }
  264. $(this).parent().remove();
  265. });
  266. $('.form-horizontal').initValidform();
  267. $('.select2').select2();
  268. //分配部门
  269. $('#changeDpt').click(function () {
  270. var vals = $('#hiddpt').val();
  271. top.dialog({
  272. url: '/Sys/Department/GetSelectDpt',
  273. title: '选择景点',
  274. width: 450,
  275. height: 500,
  276. data: vals, // 给 iframe 的数据
  277. onclose: function () {
  278. if (this.returnValue != 'no') {
  279. $('#hiddpt').val(this.returnValue.split('|')[0]);
  280. $('#dpt').html(this.returnValue.split('|')[1]);
  281. //清理岗位
  282. $('#hidpost').val('');
  283. $('#post').html('');
  284. }
  285. },
  286. oniframeload: function () {
  287. }
  288. }).showModal();
  289. return false;
  290. });
  291. //分配岗位
  292. $('#changePost').click(function () {
  293. var dptid = $('#DPTID').val() + ',' + $('#hiddpt').val();
  294. if ($('#DPTID').val() == '' && $('#hiddpt').val() == '') {
  295. dig.alertError('提示', '请选择部门后再选择岗位');
  296. return;
  297. }
  298. var vals = $('#hidpost').val();
  299. top.dialog({
  300. url: '/Sys/Post/PostUser?dptid=' + dptid,
  301. title: '分配岗位',
  302. width: 500,
  303. height: 500,
  304. data: vals, // 给 iframe 的数据
  305. onclose: function () {
  306. if (this.returnValue != 'no') {
  307. $('#hidpost').val(this.returnValue.split('|')[0]);
  308. $('#post').html(this.returnValue.split('|')[1]);
  309. }
  310. },
  311. oniframeload: function () {
  312. }
  313. }).showModal();
  314. return false;
  315. });
  316. });
  317. </script>
  318. }