You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

238 lines
8.5 KiB

  1. @{
  2. ViewBag.Title = "Index";
  3. Layout = "~/Views/Shared/_Form.cshtml";
  4. }
  5. <style>
  6. #ISO {
  7. width: 10px;
  8. }
  9. </style>
  10. <link href="~/Content/js/select2/select2.min.css" rel="stylesheet" />
  11. <script src="~/Content/js/select2/select2.min.js"></script>
  12. <script>
  13. var ID = $.request("ID");
  14. var MouldNumber = $.request("MouldNumber");
  15. //var WarehouseName = decodeURI($.getUrlParam("WarehouseName"));
  16. var MouldCode = $.request("MouldCode");
  17. var Describe = $.request("Describe");
  18. var MouldName = decodeURI($.request("MouldName"));
  19. //状态
  20. var Status = decodeURI($.request("Status"));
  21. //上限
  22. var UpperLimit = $.request("UpperLimit");
  23. //下限
  24. var LowerLimit = $.request("LowerLimit");
  25. var Picture = "";
  26. $(function () {
  27. debugger;
  28. InitControl();
  29. InitControl1();
  30. if (ID != "") {
  31. $("#sel_MouldNumber").val([MouldNumber]).trigger("change");
  32. $("#sel_MajorStates").val([Status]).trigger("change");
  33. $("#MouldName").val(MouldName);
  34. $("#MouldCode").val(MouldCode);
  35. $("#UpperLimit").val(UpperLimit);
  36. $("#LowerLimit").val(LowerLimit);
  37. }
  38. });
  39. $.getUrlParam = function (name) {
  40. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  41. var r = window.location.search.substr(1).match(reg);
  42. if (r != null) return unescape(r[2]); return null;
  43. }
  44. ;
  45. function InitControl() {
  46. debugger;
  47. var $VenCode = $("#sel_MouldNumber");
  48. $VenCode.select2({
  49. allowClear: true,
  50. escapeMarkup: function (m) {
  51. return m;
  52. }
  53. });
  54. $.ajax({
  55. url: "/Boxes/BasicSettings/GetMouldNumber" + "?" + Math.random(),
  56. dataType: "json",
  57. async: false,
  58. success: function (data) {
  59. $.each(data, function (index, item) {
  60. $VenCode.append("<option value='" + item.MouldNumber + "'>" + item.MouldNumber + "</option>");
  61. });
  62. }
  63. });
  64. }
  65. function InitControl1() {
  66. debugger;
  67. var $VenCode = $("#sel_MajorStates");
  68. $VenCode.select2({
  69. allowClear: true,
  70. escapeMarkup: function (m) {
  71. return m;
  72. }
  73. });
  74. $.ajax({
  75. url: "/Boxes/BasicSettings/GetType?tableName=" + "ICSMouldAccount" + "&" + Math.random(),
  76. dataType: "json",
  77. async: false,
  78. success: function (data) {
  79. $.each(data, function (index, item) {
  80. $VenCode.append("<option value='" + item.TypeName + "'>" + item.TypeName + "</option>");
  81. });
  82. }
  83. });
  84. }
  85. function submitForm() {
  86. if (!$('#form1').formValid()) {
  87. return false;
  88. }
  89. var MouldCode = $("#MouldCode").val();//模具代码
  90. var MouldNumber = $("#sel_MouldNumber").find("option:selected").text();//模具编码
  91. var MouldName = $("#MouldName").val();//模具名称
  92. //状态
  93. var Status = $("#sel_MajorStates").find("option:selected").text();
  94. //上限
  95. var UpperLimit = $("#UpperLimit").val();
  96. //下限
  97. var LowerLimit = $("#LowerLimit").val();
  98. var objArr = {
  99. ID: ID,
  100. MouldCode: MouldCode,
  101. MouldNumber: MouldNumber,
  102. MouldName: MouldName,
  103. Picture: Picture,
  104. Status: Status,
  105. UpperLimit: UpperLimit,
  106. LowerLimit, LowerLimit
  107. }
  108. debugger;
  109. if (ID != "") {
  110. $.submitForm({
  111. url: "/Boxes/BasicSettings/UpdateMouldAccount" + "?" + Math.random(),
  112. param: { keyValue: JSON.stringify(objArr) },
  113. success: function () {
  114. $.currentWindow().$("#gridList").trigger("reloadGrid");
  115. }
  116. })
  117. } else {
  118. $.submitForm({
  119. url: "/Boxes/BasicSettings/InsertMouldAccount" + "?" + Math.random(),
  120. param: { keyValue: JSON.stringify(objArr) },
  121. success: function () {
  122. $.currentWindow().$("#gridList").trigger("reloadGrid");
  123. }
  124. })
  125. }
  126. }
  127. //导入
  128. function btn_Introduction() {
  129. debugger;
  130. $("#FileUp").click();
  131. }
  132. function btnUpLoad(up) {
  133. var form = new FormData(document.getElementById("form1"));
  134. $.ajax({
  135. url: "/Boxes/BasicSettings/UpLoadFileImport?" + Math.random(),
  136. type: "post",
  137. data: form,
  138. dataType: "json",
  139. contentType: false,
  140. processData: false,
  141. success: function (data) {
  142. Picture = data.data;
  143. if (data.data == "上传成功!") {
  144. alert("上传成功");
  145. }
  146. else {
  147. alert(data.message);
  148. }
  149. },
  150. error: function (aa) {
  151. alert("上传失败:" + aa);
  152. }
  153. });
  154. }
  155. $(".u-file-btn").on("change", "input[type='file']", function () {
  156. var filePath = $(this).val();
  157. if (filePath.indexOf("xls") != -1 || filePath.indexOf("xlsx") != -1) {
  158. var arr = filePath.split('\\');
  159. var fileName = arr[arr.length - 1];
  160. document.getElementById("showFileName").innerText = fileName;
  161. } else {
  162. document.getElementById("showFileName").innerText = "";
  163. alert("您未上传文件,或者您上传文件类型有误!");
  164. return false
  165. }
  166. })
  167. </script>
  168. <form id="form1">
  169. <div style="padding-top: 50px; margin-right: 50px;">
  170. <table class="form">
  171. <tr>
  172. <th class="formTitle"><span style="color: red;">*</span>模具编码:</th>
  173. <td style="width:150px">
  174. <select id="sel_MouldNumber" name="sel_MouldNumber" class="form-control select2 required" style="width: 135px; height: 25px;" placeholder="模具编码" required></select>
  175. <input type="hidden" id="hidetext" />
  176. </td>
  177. <th class="formTitle" style="width: 108px;"><span style="color: red;">*</span>模具代码:</th>
  178. <td class="formValue">
  179. <input id="MouldCode" name="MouldCode" type="text" class="form-control " style="width: 155px;" maxlength="10" placeholder="模具代码" required />
  180. </td>
  181. </tr>
  182. <tr>
  183. <th class="formTitle"><span style="color: red;">*</span>名称:</th>
  184. <td class="formValue">
  185. <input id="MouldName" name="MouldName" type="text" class="form-control required" maxlength="10" placeholder="名称" required />
  186. </td>
  187. <th class="formTitle"><span style="color: red;">*</span>状态:</th>
  188. <td style="width:150px">
  189. <select id="sel_MajorStates" name="sel_MajorStates" class="form-control select2 required" style="width: 135px; height: 25px;" placeholder="状态" required></select>
  190. <input type="hidden" id="hidetext" />
  191. </tr>
  192. <tr>
  193. <th class="formTitle"><span style="color: red;">*</span>上限值:</th>
  194. <td class="formValue">
  195. <input id="UpperLimit" name="UpperLimit" type="text" class="form-control required" maxlength="10" placeholder="上限值" required />
  196. </td>
  197. <th class="formTitle">图片文件名称:</th>
  198. <td class="formValue">
  199. <div id="u-file-c" class="u-file-btn">
  200. <input id="FileUp" name="FileUp" type="file" style="display:none;" accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" onchange="btnUpLoad(this)" />
  201. <a id="NF-Introduction" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_Introduction()">上传</a>
  202. </div>
  203. </td>
  204. <td>
  205. <label id="showFileName"></label>
  206. </td>
  207. </tr>
  208. <tr>
  209. <th class="formTitle"><span style="color: red;">*</span>下限值:</th>
  210. <td class="formValue">
  211. <input id="LowerLimit" name="LowerLimit" type="text" class="form-control required" maxlength="10" placeholder="下限值" required />
  212. </td>
  213. </tr>
  214. </table>
  215. </div>
  216. </form>