Detail.cshtml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. @using MES.Production.Service;
  2. @using Central.Control.Domain;
  3. @using Ant.Service.Common;
  4. @using CommonToolHelper;
  5. @{
  6. ViewBag.Title = "添加/修改包装";
  7. Layout = "~/Views/Shared/_Layout.cshtml";
  8. }
  9. @model MES.Production.Entity.Entity.YW_Packing
  10. <style>
  11. body {
  12. background-color: white;
  13. }
  14. .changeicon {
  15. float: right;
  16. margin-right: 22px;
  17. position: absolute;
  18. right: -7px;
  19. top: 0px;
  20. border: none;
  21. background-color: #18a689;
  22. color: #FFFFFF;
  23. line-height: 33px;
  24. height: 33px;
  25. }
  26. </style>
  27. <link href="~/Content/uploadone/CSS/webuploader.css" rel="stylesheet" />
  28. <link href="~/Content/uploadone/CSS/bootstrap.min.css" rel="stylesheet" />
  29. <link href="~/Content/uploadone/CSS/uploadstyle.css" rel="stylesheet" />
  30. <link href="~/Content/uploadone/CSS/font-awesome.css" rel="stylesheet" />
  31. <script src="~/Content/uploadone/Script/webuploader.js"></script>
  32. @using (Ajax.BeginForm("Save", null, new AjaxOptions()
  33. {
  34. HttpMethod = "Post",
  35. OnBegin = "SubAjax.Loading",
  36. OnComplete = "SubAjax.Complate",
  37. OnFailure = "SubAjax.Failure",
  38. OnSuccess = "SubAjax.Success"
  39. },
  40. new { @class = "form-horizontal dig-from", @role = "form" }))
  41. {
  42. <div class="wrapper-content">
  43. <div class="panel-body">
  44. <div class="tab-content">
  45. <div id="tab-1" class="tab-pane active">
  46. @Html.HiddenFor(p => p.Id)
  47. <div class="form-group fileUpload">
  48. @Html.Hidden("hidfilename", Model.Img, new { @class = "hidfilename" })
  49. @Html.Hidden("hidfileid", Model.Img, new { @class = "hidfileid" })
  50. <label class="col-lg-3 control-label">包装图片:</label>
  51. <div class="col-lg-8">
  52. <div class="fileNameList">
  53. </div>
  54. <div class="cp_img_jia fileNamePicker"></div>
  55. </div>
  56. </div>
  57. <div class="form-group">
  58. <label class="col-lg-3 control-label">包装名称:</label>
  59. <div class="col-lg-8">
  60. @Html.TextBoxFor(p => p.Name, new { @class = "form-control", @id = "Name", @placeholder = "请输入包装名称", @datatype = "*", @nullmsg = "请输入包装名称!", @errormsg = "请输入包装名称!" })
  61. </div>
  62. </div>
  63. <div class="form-group">
  64. <label class="col-lg-3 control-label">最小容量:</label>
  65. <div class="col-lg-8">
  66. @Html.TextBoxFor(p => p.Min, new { @class = "form-control", @id = "Min", @placeholder = "请输入最小容量", @type = "number", @nullmsg = "请输入最小容量!", @errormsg = "请输入最小容量!" })
  67. </div>
  68. </div>
  69. <div class="form-group">
  70. <label class="col-lg-3 control-label">最大容量:</label>
  71. <div class="col-lg-8">
  72. @Html.TextBoxFor(p => p.Max, new { @class = "form-control", @id = "Max", @placeholder = "请输入最大容量", @type = "number", @nullmsg = "请输入最大容量!", @errormsg = "请输入最大容量!" })
  73. </div>
  74. </div>
  75. <div class="hr-line-dashed">
  76. <div class="form-group m20" style="text-align:center">
  77. <div class="col-sm-2 col-sm-offset-2">
  78. <button class="btn btn-primary btn-save" type="submit"><i class="fa fa-check"></i> <span>确定保存</span></button>
  79. <button class="btn btn-warning" id="btn-dig-close" type="button"><i class="im-undo2"></i> 取消返回</button>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. }
  88. @section scripts{
  89. <script type="text/javascript">
  90. $.fn.extend(
  91. {
  92. FileUpload: function (options) {
  93. $(this).each(function () {
  94. var filename = $(this).find(".hidfilename").val();
  95. if (filename != null && filename != "") {
  96. var headstr = "<div id=\"WU_FILE_0\" class=\"cpup_img upload-state-done\"><img src=\"";
  97. var footstr = "\"><div class=\"upcp_img_jian\"></div><p class=\"progress hide\"><span style=\"width: 100%;\"></span></p></div>";
  98. $(this).find(".fileNameList").html(headstr + filename + footstr);
  99. }
  100. options = options || {};
  101. var applicationPath = "http://" + window.location.host;
  102. var fileId;
  103. var $list = $(this).find('.fileNameList');
  104. var _this = this;
  105. var ratio = window.devicePixelRatio || 1;
  106. var defaultOptions = {
  107. thumbnailWidth: 90 * ratio,
  108. thumbnailHeight: 90 * ratio,
  109. auto: true,
  110. disableGlobalDnd: true,
  111. swf: applicationPath + '/Script/Uploader.swf',
  112. server: applicationPath + '/Sys/Home/UpLoadProcess',
  113. pick: $(_this).find(".fileNamePicker"),
  114. accept: {
  115. title: 'Images',
  116. extensions: 'gif,jpg,jpeg,bmp,png',
  117. mimeTypes: 'image/*'
  118. },
  119. fileNumLimit: 1
  120. };
  121. options = $.extend(options, defaultOptions);
  122. var uploader = WebUploader.create(options);
  123. // 当有文件添加进来的时候
  124. uploader.on('fileQueued', function (file) {
  125. debugger;
  126. var $li = $(
  127. '<div id="' + file.id + '" class="cpup_img">' +
  128. '<img class="jjgimg">' +
  129. '<div class="upcp_img_jian"></div></div>'
  130. );
  131. var $img = $li.find('img');
  132. $list.children().remove();//先清空元素内容
  133. if (fileId != file.id && fileId != null) {
  134. uploader.removeFile(uploader.getFile(fileId, true));
  135. }
  136. fileId = file.id;
  137. $list.append($li);
  138. // 创建缩略图
  139. // 如果为非图片文件,可以不用调用此方法。
  140. // thumbnailWidth x thumbnailHeight 为 100 x 100
  141. uploader.makeThumb(file, function (error, src) {
  142. if (error) {
  143. $img.replaceWith('<span>不能预览</span>');
  144. return;
  145. }
  146. $img.attr('src', src);
  147. }, options.thumbnailWidth, options.thumbnailHeight);
  148. });
  149. //上传压缩宽度
  150. uploader.option('compress', {
  151. width: 700
  152. });
  153. // 文件上传过程中创建进度条实时显示。
  154. uploader.on('uploadProgress', function (file, percentage) {
  155. var $li = $(_this).find('#' + file.id),
  156. $percent = $li.find('.progress span');
  157. // 避免重复创建
  158. if (!$percent.length) {
  159. $percent = $('<p class="progress"><span></span></p>')
  160. .appendTo($li)
  161. .find('span');
  162. }
  163. $percent.css('width', percentage * 100 + '%');
  164. });
  165. // 文件上传成功,给item添加成功class, 用样式标记上传成功。
  166. uploader.on('uploadSuccess', function (file, response) {
  167. debugger;
  168. var imgurl = response.filePath; //上传图片的路径
  169. var fileid = response.fileid; //上传图片的路径
  170. $(_this).find('#' + file.id).addClass('upload-state-done');
  171. $(_this).find(".hidfilename").val(imgurl);
  172. $(_this).find(".jjgimg").attr('src', imgurl);//季健国加为了解决保存一串字符串
  173. $(_this).find(".hidfileid").val(fileid);
  174. });
  175. // 文件上传失败,显示上传出错。
  176. uploader.on('uploadError', function (file) {
  177. var $li = $(_this).find('#' + file.id),
  178. $error = $li.find('div.error');
  179. // 避免重复创建
  180. if (!$error.length) {
  181. $error = $('<div class="error"></div>').appendTo($li);
  182. }
  183. $error.text('上传失败');
  184. });
  185. // 完成上传完了,成功或者失败,先删除进度条。
  186. uploader.on('uploadComplete', function (file) {
  187. $(_this).find('#' + file.id).find('.progress').remove();
  188. });
  189. //所有文件上传完毕
  190. uploader.on("uploadFinished", function () {
  191. //提交表单
  192. });
  193. //开始上传
  194. $(this).find("#ctlUpBtn").click(function () {
  195. uploader.upload();
  196. });
  197. //显示删除按钮
  198. $(this).find(".cpup_img").on("mouseover", function () {
  199. $(this).children(".upcp_img_jian").css('display', 'block');
  200. });
  201. //隐藏删除按钮
  202. $(this).find(".cpup_img").on("mouseout", function () {
  203. $(this).children(".upcp_img_jian").css('display', 'none');
  204. });
  205. //执行删除方法
  206. $list.on("click", ".upcp_img_jian", function () {
  207. debugger;
  208. var Id = $(this).parent().attr("id");
  209. try {
  210. $(_this).find(".hidfilename").val("");
  211. $(_this).find(".hidfileid").val("");
  212. uploader.removeFile(uploader.getFile(Id, true));
  213. }
  214. catch (ex) { }
  215. $(this).parent().remove();
  216. });
  217. });
  218. }
  219. }
  220. );
  221. $(function () {
  222. $(".fileUpload").FileUpload();
  223. $('.form-horizontal').initValidform();
  224. $('.select2').select2();
  225. });
  226. </script>
  227. }