|
@@ -6,7 +6,7 @@
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
|
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
|
|
|
<meta http-equiv="Cache-Control" content="no-siteapp" />
|
|
|
- <#include "/base/add_base.ftl">
|
|
|
+<#include "/base/add_base.ftl">
|
|
|
<link href="${path}/common/lib/jquery.ui/jquery-ui.css" rel="stylesheet" type="text/css" />
|
|
|
<style>
|
|
|
.my-title{font-weight: 500;padding-left: 15px;position: relative;}
|
|
@@ -28,41 +28,52 @@
|
|
|
<body>
|
|
|
<article class="page-container">
|
|
|
<form class="form form-horizontal" id="form-admin-addProduce">
|
|
|
- <div style="padding: 10px;">
|
|
|
+ <div style="padding: 10px;width: 600px;margin: 0 auto;" class="">
|
|
|
<div class="my-title">产品信息</div>
|
|
|
- <div class="input-box"><span class="input-dic">产品名称</span><input class="my-input" name="produceName" type="text" value="" placeholder="请输入产品名称"/> </div>
|
|
|
- <div class="input-box"><span class="input-dic">产品描述</span><input class="my-input" type="text" name="produceRemake" value="" placeholder="请输入产品描述"/> </div>
|
|
|
+ <input type="hidden" name="produceId" value="${produce.produceId!}">
|
|
|
+ <div class="input-box"><span class="input-dic">产品名称</span><input class="my-input" name="produceName" type="text" value="${produce.produceName!}" placeholder="请输入产品名称"/> </div>
|
|
|
+ <div class="input-box"><span class="input-dic">产品描述</span><input class="my-input" type="text" name="produceRemake" value="${produce.produceRemake!}" placeholder="请输入产品描述"/> </div>
|
|
|
<div style="background-color:rgba(0,0,0,.1);height: 1px;margin: 15px 0;"></div>
|
|
|
<div class="my-title">节点信息</div>
|
|
|
|
|
|
+
|
|
|
<ul class="cp-list onrTheProcess" id="sortable">
|
|
|
- <li id="1" class="processList">
|
|
|
- <input type="hidden" class="processNumber" value="1">
|
|
|
- <div class="input-box"><span class="input-dic">节点类型</span>
|
|
|
- <label><input type="radio" name="processType_p1" value="1">生产工序</label>
|
|
|
- <label><input type="radio" name="processType_p1" value="2">修理工序</label>
|
|
|
- </div>
|
|
|
- <div class="input-box"><span class="input-dic">节点名称</span><input class="my-input" name="processName" type="text" value="" placeholder="请输入产品名称"/> </div>
|
|
|
- <div class="input-box"><span class="input-dic">节点操作</span>
|
|
|
- <ul class="add-list oneTheNode" >
|
|
|
- <li class="nodeList">
|
|
|
- <select class="my-select"><option>1</option></select>
|
|
|
- <label><input type="radio" name="nodeStatus_p1_n1" value="1">正常</label>
|
|
|
- <label><input type="radio" name="nodeStatus_p1_n1" value="0">异常</label>
|
|
|
- <input class="my-input" name="nodeDes" type="text" value="" placeholder="请输入节点描述,2-10位中文" maxlength="10"/>
|
|
|
- </li>
|
|
|
- <li>
|
|
|
- <button type="button" class="my-btn-edit" onclick="addProNode(this)">增加节点操作</button>
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
- </div>
|
|
|
- </li>
|
|
|
+ <#list produce.process as process>
|
|
|
+ <li id="${process_index + 1}" class="processList">
|
|
|
+ <input type="hidden" name="processId" value="${process.processId!}">
|
|
|
+ <input type="hidden" class="processNumber" value="${process_index + 1}">
|
|
|
+ <div class="input-box"><span class="input-dic process-type">节点类型</span>
|
|
|
+ <label><input type="radio" name="processType_p${process_index + 1}" value="1" <#if process.processType == 1>checked</#if>>生产工序</label>
|
|
|
+ <label><input type="radio" name="processType_p${process_index + 1}" value="2" <#if process.processType == 2>checked</#if>>修理工序</label>
|
|
|
+ <button type="button" class="my-btn-edit" onclick="delProcess(this)">删除节点</button>
|
|
|
+ </div>
|
|
|
+ <div class="input-box"><span class="input-dic">节点名称</span><input class="my-input" name="processName" type="text" value="${process.processName!}" placeholder="请输入节点名称"/> </div>
|
|
|
+ <div class="input-box"><span class="input-dic">节点操作</span>
|
|
|
+ <ul class="add-list oneTheNode" >
|
|
|
+ <#list process.nodes as nodes>
|
|
|
+ <li class="nodeList">
|
|
|
+ <input type="hidden" name="nodeId" value="${nodes.nodeId!}">
|
|
|
+ <#--<select class="my-select"><option>1</option></select>-->
|
|
|
+ <label><input type="radio" name="nodeStatus_p${process_index + 1}_n${nodes_index + 1}" value="1" <#if nodes.nodeStatus == 1>checked</#if>>正常</label>
|
|
|
+ <label><input type="radio" name="nodeStatus_p${process_index + 1}_n${nodes_index + 1}" value="0" <#if nodes.nodeStatus == 0>checked</#if>>异常</label>
|
|
|
+ <input class="my-input" name="nodeDes" type="text" value="${nodes.nodeDes!}" placeholder="请输入节点操作描述,2-10位中文" maxlength="10"/>
|
|
|
+ <i class="Hui-iconfont" onclick="delNode(this)"></i>
|
|
|
+ </li>
|
|
|
+ </#list>
|
|
|
+ <li>
|
|
|
+ <button type="button" class="my-btn-edit" onclick="addProNode(this)">增加节点操作</button>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+ </#list>
|
|
|
</ul>
|
|
|
|
|
|
+
|
|
|
<div style="clear: both;"></div>
|
|
|
<div><button type="button" class="my-btn-edit" onclick="addProcess(this)">增加节点</button></div>
|
|
|
<div>
|
|
|
- <button type="reset" class="my-btn-reset">重置</button><button type="submit" class="my-btn-submit">确认提交</button>
|
|
|
+ <button type="reset" class="my-btn-reset" >重置</button><button type="submit" class="my-btn-submit">确认提交</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
@@ -73,6 +84,8 @@
|
|
|
<script type="text/javascript" src="${path}/common/lib/jquery.ui/jquery-ui.js"></script>
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
+ var delProcessIds="",delNodeIds="";
|
|
|
+
|
|
|
//动态显示隐藏所属菜单
|
|
|
$(document).on('click', '.menuSubid input[type=radio]', function() {
|
|
|
isSelectShow($(this).val())
|
|
@@ -91,8 +104,7 @@
|
|
|
focusCleanup:true,
|
|
|
success:"valid",
|
|
|
submitHandler:function(form){
|
|
|
- debugger;
|
|
|
- $.post(root_path + "/admin/produce/save_produce", formatJSON(),function(result){
|
|
|
+ $.post(root_path + "/admin/produce/update_produce", formatJSON(),function(result){
|
|
|
if (result.returnCode != 200 || result.returnCode != 200) {
|
|
|
layer.msg('录入失败,请重试!',{icon: 5,time:3000});
|
|
|
} else {
|
|
@@ -106,26 +118,27 @@
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- /*将表单format为JSON*/
|
|
|
+ /*将表单format转为JSON*/
|
|
|
function formatJSON() {
|
|
|
- debugger;
|
|
|
var produce = {};
|
|
|
|
|
|
var oneTheProcess = $(".onrTheProcess").find(".processList");
|
|
|
var proessList = new Array();
|
|
|
- var i=1;
|
|
|
oneTheProcess.each(function(){
|
|
|
var produceProcess = {};
|
|
|
produceProcess.processName = $(this).find("[name='processName']").val(); //获取工序名称
|
|
|
- var processTypeName = "processType_p"+i; //获取工序类型名称
|
|
|
+ var processNumber = $(this).find(".processNumber").val();
|
|
|
+ var processTypeName = "processType_p"+processNumber; //获取工序类型名称
|
|
|
produceProcess.processType = $("input[name="+ processTypeName +"]:checked").val(); //获取工序类型
|
|
|
+ produceProcess.processId = getDelId($(this),"processId"); //获取工序id
|
|
|
|
|
|
var nodeList = new Array();
|
|
|
var j=1;
|
|
|
$(this).find(".oneTheNode").find(".nodeList").each(function(){
|
|
|
var processNode = {};
|
|
|
processNode.nodeDes = $(this).find("[name='nodeDes']").val(); //获取节点描述
|
|
|
- var nodeStatusName = "nodeStatus_p"+i+"_n" +j;
|
|
|
+ processNode.nodeId = getDelId($(this),"nodeId"); //获取节点操作id
|
|
|
+ var nodeStatusName = "nodeStatus_p"+processNumber+"_n" +j;
|
|
|
processNode.nodeStatus = $("input[name="+ nodeStatusName +"]:checked").val(); //获取节点状态
|
|
|
nodeList.push(processNode);
|
|
|
j++;
|
|
@@ -133,27 +146,42 @@
|
|
|
produceProcess.json = JSON.stringify(nodeList); //将node变成json存入到工序对象中
|
|
|
//produceProcess.nodes = nodeList;
|
|
|
proessList.push(produceProcess);
|
|
|
- i++;
|
|
|
})
|
|
|
produce.json = JSON.stringify(proessList); //将工序变成json存入到产品对象中
|
|
|
+
|
|
|
+ produce.produceId = $("[name='produceId']").val();//获取产品id
|
|
|
produce.produceName = $("[name='produceName']").val();//获取产品名称
|
|
|
produce.produceRemake = $("[name='produceRemake']").val();//获取产品描述
|
|
|
-// var s = JSON.stringify(produce);
|
|
|
-// alert(s)
|
|
|
+
|
|
|
+ produce.delProcessIds = delProcessIds; //需要删除的工序id
|
|
|
+ produce.delNodeIds = delNodeIds; //需要删除的节点操作id
|
|
|
return produce;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取id
|
|
|
+ */
|
|
|
+ function getDelId(node,delIdName){
|
|
|
+ debugger;
|
|
|
+ var delId = $(node).find("[name='"+ delIdName +"']").val();
|
|
|
+ if(delId == null || delId == "" || typeof(delId)=="undefined" || delId == undefined ){
|
|
|
+ delId = 0;
|
|
|
+ }
|
|
|
+ return delId;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 增加节点操作方法
|
|
|
*/
|
|
|
function addProNode(node){
|
|
|
var processNumber = $(node).parents(".processList").find(".processNumber").val(); //获取当前的节点标识
|
|
|
var nodeNumber = $(node).parents(".oneTheNode").find(".nodeList").length + 1; //因为是新加的节点操作所以 +1
|
|
|
var nodeHtml = '<li class="nodeList">'
|
|
|
- +'<select class="my-select"><option>1</option></select> '
|
|
|
+ //+'<select class="my-select"><option>1</option></select> '
|
|
|
+'<label><input type="radio" name="nodeStatus_p'+ processNumber +'_n'+ nodeNumber +'" value="1">正常</label> '
|
|
|
+'<label><input type="radio" name="nodeStatus_p'+ processNumber +'_n'+ nodeNumber +'" value="0">异常</label> '
|
|
|
- +'<input class="my-input" name="nodeDes" type="text" value="" placeholder="请输入节点描述,2-10位中文" maxlength="10"/>'
|
|
|
+ +'<input class="my-input" name="nodeDes" type="text" value="" placeholder="请输入节点操作描述,2-10位中文" maxlength="10"/> '
|
|
|
+ +'<i class="Hui-iconfont" onclick="delNode(this)"></i>'
|
|
|
+'</li>';
|
|
|
$(node).parent().before(nodeHtml);
|
|
|
}
|
|
@@ -163,20 +191,22 @@
|
|
|
* @param node
|
|
|
*/
|
|
|
function addProcess(node) {
|
|
|
- var processNumber = $(node).parents(".onrTheProcess").find("processList").length + 1; //因为是新加的工序节点所以 +1
|
|
|
+ var processNumber = $(".onrTheProcess").find(".processList").length + 1; //因为是新加的工序节点所以 +1
|
|
|
var processHtml = '<li id="'+ processNumber +'" class="processList"><input type="hidden" class="processNumber" value="'+ processNumber +'">'
|
|
|
+ '<div class="input-box"><span class="input-dic">节点类型</span>'
|
|
|
- + '<label><input type="radio" name="processType_p2" value="1">生产工序</label>'
|
|
|
- + '<label><input type="radio" name="processType_p2" value="2">修理工序</label>'
|
|
|
+ + '<label><input type="radio" name="processType_p'+ processNumber +'" value="1">生产工序</label>'
|
|
|
+ + '<label><input type="radio" name="processType_p'+ processNumber +'" value="2">修理工序</label>'
|
|
|
+ + '<button type="button" class="my-btn-edit" onclick="delProcess(this)">删除节点</button>'
|
|
|
+ '</div>'
|
|
|
- + '<div class="input-box"><span class="input-dic">第二节点</span><input class="my-input" name="processName" type="text" value="" placeholder="请输入产品名称"/> </div>'
|
|
|
+ + '<div class="input-box"><span class="input-dic">节点名称</span><input class="my-input" name="processName" type="text" value="" placeholder="请输入节点名称"/> </div>'
|
|
|
+ '<div class="input-box"><span class="input-dic">节点操作</span>'
|
|
|
+ '<ul class="add-list oneTheNode">'
|
|
|
+ '<li class="nodeList">'
|
|
|
- + '<select class="my-select"><option>1</option></select> '
|
|
|
+ // + '<select class="my-select"><option>1</option></select> '
|
|
|
+ '<label><input type="radio" name="nodeStatus_p'+ processNumber +'_n1" value="1">正常</label> '
|
|
|
+ '<label><input type="radio" name="nodeStatus_p'+ processNumber +'_n1" value="0">异常</label> '
|
|
|
- + '<input class="my-input" name="nodeDes" type="text" value="" placeholder="请输入节点描述,2-10位中文" maxlength="10"/>'
|
|
|
+ + '<input class="my-input" name="nodeDes" type="text" value="" placeholder="请输入节点操作描述,2-10位中文" maxlength="10"/> '
|
|
|
+ + '<i class="Hui-iconfont" onclick="delNode(this)"></i>'
|
|
|
+ '</li>'
|
|
|
+ '<li><button type="button" class="my-btn-edit" onclick="addProNode(this)">增加节点操作</button></li>'
|
|
|
+ '</ul>'
|
|
@@ -184,6 +214,34 @@
|
|
|
+ '</li>';
|
|
|
$(".onrTheProcess").append(processHtml);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除工序节点
|
|
|
+ * @param node
|
|
|
+ */
|
|
|
+ function delProcess(node) {
|
|
|
+ debugger;
|
|
|
+ var processNumber = $(node).parents(".onrTheProcess").find(".processList").length;
|
|
|
+ if(parseInt(processNumber) < 2){
|
|
|
+ layer.msg('至少要有一个节点!',{icon: 5,time:3000});
|
|
|
+ }else{
|
|
|
+ $(node).parents(".processList").remove();
|
|
|
+ //delProcessIds += delProcessIds+",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除节点操作
|
|
|
+ * @param node
|
|
|
+ */
|
|
|
+ function delNode(node){
|
|
|
+ var nodesNumber = $(node).parents(".oneTheNode").find(".nodeList").length;
|
|
|
+ if(parseInt(nodesNumber) < 2){
|
|
|
+ layer.msg('至少要有一个节点操作!',{icon: 5,time:3000});
|
|
|
+ }else{
|
|
|
+ $(node).parents(".nodeList").remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
</script>
|
|
|
|
|
|
<script>
|