update_produce.ftl 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="renderer" content="webkit|ie-comp|ie-stand">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  8. <meta http-equiv="Cache-Control" content="no-siteapp" />
  9. <#include "/base/add_base.ftl">
  10. <link href="${path}/common/lib/jquery.ui/jquery-ui.css" rel="stylesheet" type="text/css" />
  11. <style>
  12. .my-title{font-weight: 500;padding-left: 15px;position: relative;}
  13. .my-title:after{content: '';position: absolute;left: 0;top:12%;width: 3px;height: 80%;background: #32a3d8;}
  14. .my-input{padding: 5px 10px;width: 80%;border:1px solid rgba(0,0,0,.1)}
  15. .input-box{margin: 18px 0;}
  16. .input-dic{float: left;margin:5px 10px 0 0;font-size: 12px;}
  17. .add-list{list-style-type: none;padding: 10px;background-color: #f5f5f5;width: 60%;float: left;margin: 0;}
  18. .my-btn-edit{padding: 6px 20px;background-color: #fff;color: #32a3d8;border: 1px solid #32a3d8;cursor:pointer;margin: 0 10px;}
  19. .my-btn-reset{padding: 6px 20px;width: 150px; background-color: #fff;color: #32a3d8;border: 1px solid #32a3d8;cursor:pointer;margin: 10px 10px 0 10px;}
  20. .my-btn-submit{padding: 6px 20px;width: 150px; background-color: #32a3d8;color: #fff;border: 1px solid #32a3d8;cursor:pointer;margin: 10px 10px 0 10px;}
  21. .add-list>li{margin: 10px 0;}
  22. .cp-list{list-style-type: none;margin: 0;padding: 0;}
  23. .cp-list>li{position: relative; cursor: pointer;clear: both;padding: 15px 0;}
  24. .my-select{border: 1px solid rgba(0,0,0,.1);padding:6px 50px 6px 15px;height: 34px;margin: 0 10px; -webkit-appearance:none;appearance:none;background: url(${path}/common/images/pts/select-1.png) right center no-repeat;background-size:auto 100%;}
  25. input[type=radio]{-webkit-appearance:none;appearance:none;background: url(${path}/common/images/pts/radio-1.png) center center no-repeat;background-size:auto 100%;width: 20px;height: 20px;margin-right: 10px;}
  26. input[type=radio]:checked{-webkit-appearance:none;appearance:none;background: url(${path}/common/images/pts/radio-2.png) center center no-repeat;background-size:auto 100%;width: 20px;height: 20px;margin-right: 10px;}
  27. select{border: 1px solid rgba(0,0,0,.1);border-radius: 5px;padding:6px 35px 6px 5px;height: 32px;-webkit-appearance:none;appearance:none;background: url(${path}/common/images/pts/select-1.png) right center no-repeat !important;background-size:auto 100% !important;margin-right: 10px;width: 85px;}
  28. </style>
  29. <title>修改生产产品- 生产产品管理 - RST</title>
  30. </head>
  31. <body>
  32. <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
  33. <span class="c-gray en">&gt;</span> 产品管理
  34. <span class="c-gray en">&gt;</span> 修改产品
  35. <a class="btn radius r" style="line-height:1.6em;margin-top:3px;background: #58d2ea;color: #fff;" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
  36. </nav>
  37. <form class="form form-horizontal" id="form-admin-addProduce">
  38. <article class="page-container" style="padding-bottom: 80px;">
  39. <div style="padding: 10px;width: 600px;margin: 0 auto;" class="">
  40. <div class="my-title">产品信息</div>
  41. <input type="hidden" name="produceId" value="${produce.produceId!}">
  42. <div class="input-box"><span class="input-dic">产品名称</span><input class="my-input" name="produceName" type="text" value="${produce.produceName!}" placeholder="请输入产品名称,2-20位字符" maxlength="20" required /> </div>
  43. <div class="input-box"><span class="input-dic">产品描述</span><input class="my-input" type="text" name="produceRemake" value="${produce.produceRemake!}" placeholder="请输入产品描述,2-100位字符" maxlength="100" required /> </div>
  44. <div class="input-box "><span class="input-dic">产品特性</span>
  45. <select class="" style="width: 290px;" id="produceFeature" name="produceFeature">
  46. <option value ="A" <#if produce.produceFeature??><#if produce.produceFeature == 'A'>selected="selected"</#if></#if>>国内(A)</option>
  47. <option value ="B" <#if produce.produceFeature??><#if produce.produceFeature == 'B'>selected="selected"</#if></#if>>美国(B)</option>
  48. <option value ="C" <#if produce.produceFeature??><#if produce.produceFeature == 'C'>selected="selected"</#if></#if>>欧洲(C)</option>
  49. <option value ="D" <#if produce.produceFeature??><#if produce.produceFeature == 'D'>selected="selected"</#if></#if>>其他(D)</option>
  50. </select>
  51. </div>
  52. <div class="input-box"><span class="input-dic">产品型号</span><input class="my-input" style="width: 120px;" type="text" name="producePattern" id="producePattern" placeholder="1-3位英文、数字组合" value="${produce.producePattern!}" placeholder="" required maxlength="3" minlength="1"/>-
  53. <input class="my-input" style="width: 120px;" type="text" name="produceModel" id="produceModel" value="${produce.produceModel!}" placeholder="1-3位英文、数字组合" required maxlength="3" minlength="1"/> </div>
  54. <div class="input-box"><span class="input-dic">产品类型</span>
  55. <label><input type="radio" name="produceType" value="1" <#if produce.produceType == 1>checked</#if>>净水机</label>
  56. <label><input type="radio" name="produceType" value="2" <#if produce.produceType == 2>checked</#if>>冲奶机</label>
  57. </div>
  58. <div class="input-box"><span class="input-dic">产品状态</span>
  59. <label><input type="radio" name="produceStatus" value="1" <#if produce.produceStatus == 1>checked</#if>>正在使用</label>
  60. <label><input type="radio" name="produceStatus" value="0" <#if produce.produceStatus == 0>checked</#if>>停止使用</label>
  61. </div>
  62. <div style="background-color:rgba(0,0,0,.1);height: 1px;margin: 15px 0;width: 93%;"></div>
  63. <div class="my-title">节点信息</div>
  64. <ul class="cp-list onrTheProcess" id="sortable">
  65. <#list produce.process as process>
  66. <li id="${process_index + 1}" class="processList">
  67. <input type="hidden" name="processId" value="${process.processId!}">
  68. <input type="hidden" class="processNumber" value="${process_index + 1}">
  69. <div class="input-box"><span class="input-dic process-type">节点类型</span>
  70. <label><input type="radio" name="processType_p${process_index + 1}" value="1" <#if process.processType == 1>checked</#if>>生产工序</label>
  71. <label><input type="radio" name="processType_p${process_index + 1}" value="2" <#if process.processType == 2>checked</#if>>修理工序</label>
  72. <button type="button" class="my-btn-edit" onclick="delProcess(this)">删除节点</button>
  73. </div>
  74. <div class="input-box"><span class="input-dic">节点名称</span><input class="my-input" name="processName" type="text" value="${process.processName!}" placeholder="请输入节点名称,2-20位字符" maxlength="20" required/> </div>
  75. <div class="input-box"><span class="input-dic">节点操作</span>
  76. <ul class="add-list oneTheNode" >
  77. <#list process.nodes as nodes>
  78. <li class="nodeList">
  79. <input type="hidden" name="nodeId" value="${nodes.nodeId!}">
  80. <#--<select class="my-select"><option>1</option></select>-->
  81. <label><input type="radio" name="nodeStatus_p${process_index + 1}_n${nodes_index + 1}" value="1" <#if nodes.nodeStatus == 1>checked</#if>>正常</label>
  82. <label><input type="radio" name="nodeStatus_p${process_index + 1}_n${nodes_index + 1}" value="0" <#if nodes.nodeStatus == 0>checked</#if>>异常</label>
  83. <input class="my-input" name="nodeDes" type="text" value="${nodes.nodeDes!}" placeholder="请输入节点操作描述,2-20位字符" maxlength="20" minlength="2" required/>
  84. <i class="Hui-iconfont" onclick="delNode(this)">&#xe60b;</i>
  85. </li>
  86. </#list>
  87. <li>
  88. <button type="button" class="my-btn-edit" onclick="addProNode(this)">增加节点操作</button>
  89. </li>
  90. </ul>
  91. </div>
  92. </li>
  93. </#list>
  94. </ul>
  95. <div style="clear: both;"></div>
  96. <div style="padding-top: 15px;"><button type="button" class="my-btn-edit" onclick="addProcess(this)">增加节点</button></div>
  97. </div>
  98. </article>
  99. <div style="width: 100%;height: 80px;position: fixed;bottom: 0px;background: #f5f5f5;text-align: center;">
  100. <span style="color: red; margin: 10px;display: block;margin: 0 auto;width:700px;padding-top: 5px;">*说明:如果机器正在生产,请不要修改,待生成完成以后修改;如果信息有误,请联系深圳技术部协助处理。</span>
  101. <div><button type="submit" class="my-btn-submit">确认提交</button></div>
  102. </div>
  103. </form>
  104. <#--<script type="text/javascript" src="${path}/common/lib/ueditor/1.4.3/ueditor.config.js"></script>-->
  105. <#--<script type="text/javascript" src="${path}/common/lib/ueditor/1.4.3/ueditor.all.js"></script>-->
  106. <script type="text/javascript" src="${path}/common/lib/jquery.ui/jquery-ui.js"></script>
  107. <script type="text/javascript">
  108. var check_name = /^[a-zA-Z0-9\u4e00-\u9fa5,.!;,。!;:“”\\"\\ ]+$/;
  109. var cnen_name = /^[a-zA-Z0-9\u4e00-\u9fa5]+$/;
  110. var en_name = /^[a-zA-Z0-9]+$/;
  111. var delProcessIds="",delNodeIds="";
  112. $(function(){
  113. //var validator = $("#signupForm").validate();
  114. $("#form-admin-addProduce").submit(function(){
  115. var produceName = $("#produceName").val();
  116. // if(!(cnen_name.test(produceName))){
  117. // layer.msg('产品名称输入格式不正确', {icon: 5, time: 1000});
  118. // return false;
  119. // }
  120. var produceRemake = $("#produceRemake").val();
  121. // if(!(cnen_name.test(produceRemake))){
  122. // layer.msg('产品描述输入格式不正确', {icon: 5, time: 1000});
  123. // return false;
  124. // }
  125. var producePattern = $("#producePattern").val();
  126. if(!(en_name.test(producePattern))){
  127. layer.msg('产品型号输入格式不正确', {icon: 5, time: 1000});
  128. return false;
  129. }
  130. var produceModel = $("#produceModel").val();
  131. if(!(en_name.test(produceModel))){
  132. layer.msg('产品型号输入格式不正确', {icon: 5, time: 1000});
  133. return false;
  134. }
  135. var flag = true;
  136. // $("input[name='processName']").each(function () {
  137. // if( !(cnen_name.test($(this).val())) ){
  138. // layer.msg('节点名称输入格式不正确', {icon: 5, time: 1000});
  139. // flag = false;
  140. // }
  141. // })
  142. // if(!flag)
  143. // return false;
  144. // $("input[name='nodeDes']").each(function () {
  145. // if( !(check_name.test($(this).val())) ){
  146. // layer.msg('节点操作描述输入格式不正确', {icon: 5, time: 1000});
  147. // flag = false;
  148. // }
  149. // })
  150. // if(!flag)
  151. // return false;
  152. layer.confirm('您确定要修改产品信息吗?', {
  153. btn: ['确定','取消'] //按钮
  154. }, function(){
  155. ajaxReq();
  156. }, function(){
  157. layer.closeAll('dialog');
  158. return false;
  159. });
  160. return false;
  161. })
  162. })
  163. function ajaxReq(){
  164. var data = formatJSON();
  165. $.ajax({
  166. cache: true,
  167. type: "POST",
  168. data: data,
  169. url: "${path}/admin/produce/update_produce",
  170. async: false,
  171. success: function(data){
  172. if (data.returnCode == 200) {
  173. window.location.href = '${path}/admin/produce/_produce_list'
  174. }
  175. },
  176. error: function(XmlHttpRequest, textStatus, errorThrown){
  177. }
  178. });
  179. }
  180. /*将表单format转为JSON*/
  181. function formatJSON() {
  182. var produce = {};
  183. var oneTheProcess = $(".onrTheProcess").find(".processList");
  184. var proessList = new Array();
  185. oneTheProcess.each(function(){
  186. var produceProcess = {};
  187. produceProcess.processName = $(this).find("[name='processName']").val(); //获取工序名称
  188. var processNumber = $(this).find(".processNumber").val();
  189. var processTypeName = "processType_p"+processNumber; //获取工序类型名称
  190. produceProcess.processType = $("input[name="+ processTypeName +"]:checked").val(); //获取工序类型
  191. produceProcess.processId = getDelId($(this),"processId"); //获取工序id
  192. var nodeList = new Array();
  193. var j=1;
  194. $(this).find(".oneTheNode").find(".nodeList").each(function(){
  195. var processNode = {};
  196. processNode.nodeDes = $(this).find("[name='nodeDes']").val(); //获取节点描述
  197. processNode.nodeId = getDelId($(this),"nodeId"); //获取节点操作id
  198. var nodeStatusName = "nodeStatus_p"+processNumber+"_n" +j;
  199. processNode.nodeStatus = $("input[name="+ nodeStatusName +"]:checked").val(); //获取节点状态
  200. nodeList.push(processNode);
  201. j++;
  202. })
  203. produceProcess.json = JSON.stringify(nodeList); //将node变成json存入到工序对象中
  204. //produceProcess.nodes = nodeList;
  205. proessList.push(produceProcess);
  206. })
  207. produce.json = JSON.stringify(proessList); //将工序变成json存入到产品对象中
  208. produce.produceId = $("[name='produceId']").val();//获取产品id
  209. produce.produceName = $("[name='produceName']").val();//获取产品名称
  210. produce.produceRemake = $("[name='produceRemake']").val();//获取产品描述
  211. produce.produceType = $("[name='produceType']:checked").val();//获取产品类型
  212. produce.produceStatus = $("[name='produceStatus']:checked").val();//获取产品状态
  213. produce.produceFeature = $("[name='produceFeature']").val();//获取产品特性
  214. produce.producePattern = $("[name='producePattern']").val();//产品型号
  215. produce.produceModel = $("[name='produceModel']").val();//产品型号
  216. produce.delProcessIds = delProcessIds; //需要删除的工序id
  217. produce.delNodeIds = delNodeIds; //需要删除的节点操作id
  218. return produce;
  219. }
  220. /**
  221. * 获取id
  222. */
  223. function getDelId(node,delIdName){
  224. var delId = $(node).find("[name='"+ delIdName +"']").val();
  225. if(delId == null || delId == "" || typeof(delId)=="undefined" || delId == undefined ){
  226. delId = 0;
  227. }
  228. return delId;
  229. }
  230. /**
  231. * 增加节点操作方法
  232. */
  233. function addProNode(node){
  234. var processNumber = $(node).parents(".processList").find(".processNumber").val(); //获取当前的节点标识
  235. var nodeNumber = $(node).parents(".oneTheNode").find(".nodeList").length + 1; //因为是新加的节点操作所以 +1
  236. var nodeHtml = '<li class="nodeList">'
  237. //+'<select class="my-select"><option>1</option></select>&nbsp;'
  238. +'<label><input type="radio" name="nodeStatus_p'+ processNumber +'_n'+ nodeNumber +'" value="1" checked>正常</label>&nbsp;'
  239. +'<label><input type="radio" name="nodeStatus_p'+ processNumber +'_n'+ nodeNumber +'" value="0">异常</label>&nbsp;'
  240. +'<input class="my-input" name="nodeDes" type="text" value="" placeholder="请输入节点操作描述,2-20位字符" maxlength="20" minlength="2" required/>&nbsp;'
  241. +'<i class="Hui-iconfont" onclick="delNode(this)">&#xe60b;</i>'
  242. +'</li>';
  243. $(node).parent().before(nodeHtml);
  244. }
  245. /**
  246. * 增加工序节点
  247. * @param node
  248. */
  249. function addProcess(node) {
  250. var processNumber = $(".onrTheProcess").find(".processList").length + 1; //因为是新加的工序节点所以 +1
  251. var processHtml = '<li id="'+ processNumber +'" class="processList"><input type="hidden" class="processNumber" value="'+ processNumber +'">'
  252. + '<div class="input-box"><span class="input-dic">节点类型</span>'
  253. + '<label><input type="radio" name="processType_p'+ processNumber +'" value="1" checked>生产工序</label>'
  254. + '<label><input type="radio" name="processType_p'+ processNumber +'" value="2">修理工序</label>'
  255. + '<button type="button" class="my-btn-edit" onclick="delProcess(this)">删除节点</button>'
  256. + '</div>'
  257. + '<div class="input-box"><span class="input-dic">节点名称</span><input class="my-input" name="processName" type="text" value="" placeholder="请输入节点名称,2-20位字符" maxlength="20" required/> </div>'
  258. + '<div class="input-box"><span class="input-dic">节点操作</span>'
  259. + '<ul class="add-list oneTheNode">'
  260. + '<li class="nodeList">'
  261. // + '<select class="my-select"><option>1</option></select>&nbsp;'
  262. + '<label><input type="radio" name="nodeStatus_p'+ processNumber +'_n1" value="1" checked>正常</label>&nbsp;'
  263. + '<label><input type="radio" name="nodeStatus_p'+ processNumber +'_n1" value="0">异常</label>&nbsp;'
  264. + '<input class="my-input" name="nodeDes" type="text" value="" placeholder="请输入节点操作描述,2-20位字符" maxlength="20" minlength="2" required/>&nbsp;'
  265. + '<i class="Hui-iconfont" onclick="delNode(this)">&#xe60b;</i>'
  266. + '</li>'
  267. + '<li><button type="button" class="my-btn-edit" onclick="addProNode(this)">增加节点操作</button></li>'
  268. + '</ul>'
  269. + '</div>'
  270. + '</li>';
  271. $(".onrTheProcess").append(processHtml);
  272. }
  273. /**
  274. * 删除工序节点
  275. * @param node
  276. */
  277. function delProcess(node) {
  278. var processNumber = $(node).parents(".onrTheProcess").find(".processList").length;
  279. if(parseInt(processNumber) < 2){
  280. layer.msg('至少要有一个节点!',{icon: 5,time:3000});
  281. }else{
  282. var processId = $(node).parents(".processList").find("[name='processId']").val();
  283. if(processId != null && processId != "" && typeof(processId)!="undefined"){
  284. delProcessIds += processId+",";
  285. }
  286. $(node).parents(".processList").find("[name='nodeId']").each(function(){
  287. var nodeId = $(this).val();
  288. if(nodeId != null && nodeId != "" && typeof(nodeId)!="undefined"){
  289. delNodeIds += nodeId +",";
  290. }
  291. });
  292. $(node).parents(".processList").remove();
  293. }
  294. }
  295. /**
  296. * 删除节点操作
  297. * @param node
  298. */
  299. function delNode(node){
  300. var nodesNumber = $(node).parents(".oneTheNode").find(".nodeList").length;
  301. if(parseInt(nodesNumber) < 2){
  302. layer.msg('至少要有一个节点操作!',{icon: 5,time:3000});
  303. }else{
  304. var nodeId = $(node).parents(".nodeList").find("[name='nodeId']").val();
  305. if(nodeId != null && nodeId != "" && typeof(nodeId)!="undefined"){
  306. delNodeIds += nodeId +",";
  307. }
  308. $(node).parents(".nodeList").remove();
  309. }
  310. }
  311. </script>
  312. <script>
  313. $(function() {
  314. //在ajax拉取数据append()之后再初始化拖拽排序
  315. $( "#sortable" ).sortable({
  316. revert: true,
  317. containment: "parent"
  318. });
  319. $( "ul, li" ).disableSelection();
  320. });
  321. // //确认提交事件,获取每个li的id
  322. // $(document).on('click', '.my-btn-submit', function() {
  323. // $("#sortable>li").each(function(){
  324. // console.log($(this).attr("id"));
  325. // });
  326. // });
  327. </script>
  328. </body>
  329. </html>