|
@@ -22,19 +22,7 @@
|
|
|
href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont"></i></a>
|
|
|
</nav>
|
|
|
<article class="page-container" style="padding: 10px;width: 600px;margin: 0 auto;">
|
|
|
- <form action="" method="post" class="form form-horizontal" id="form-member-add">
|
|
|
-
|
|
|
- <div class="row cl">
|
|
|
- <label class="form-label col-xs-4 col-sm-3">修改基础:</label>
|
|
|
- <div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
|
|
|
- <select class="select" size="1" name="bomId">
|
|
|
- <option value="0">不选择</option>
|
|
|
- <option value="1">净水机</option>
|
|
|
- <option value="2">冲奶机</option>
|
|
|
- </select>
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <form action="${path}/admin/bom/save_bom" method="post" class="form form-horizontal" id="form-bom-add">
|
|
|
|
|
|
<div class="row cl">
|
|
|
<label class="form-label col-xs-4 col-sm-3">所属产品:</label>
|
|
@@ -42,7 +30,7 @@
|
|
|
<select class="select" size="1" name="produceId">
|
|
|
<#if produceList?? && (produceList?size > 0) >
|
|
|
<#list produceList as produce>
|
|
|
- <option value="${produce.produceId!}" <#if produceId??><#if produceId ==produce.produceId >selected="selected"</#if></#if>>${produce.produceName!}</option>
|
|
|
+ <option value="${produce.produceId}" <#if produceId??><#if produceId ==produce.produceId >selected="selected"</#if></#if>>${produce.produceName}</option>
|
|
|
</#list>
|
|
|
<#else>
|
|
|
<option value="">暂时没有产品,需要到生产产品页面添加产品</option>
|
|
@@ -53,10 +41,18 @@
|
|
|
</div>
|
|
|
|
|
|
<div class="row cl">
|
|
|
+ <label class="form-label col-xs-4 col-sm-3">修改基础:</label>
|
|
|
+ <div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
|
|
|
+ <select class="select" size="1" name="bomId">
|
|
|
+ </select>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="row cl">
|
|
|
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>Bom名称:</label>
|
|
|
<div class="formControls col-xs-8 col-sm-9">
|
|
|
- <input type="text" class="input-text" value="" id="bomName" name="bomName"
|
|
|
- placeholder="请输入1-30位的名称,支持中文、字母、数字">
|
|
|
+ <input type="text" class="input-text" value="" id="bomName" name="bomName" placeholder="请输入1-30位的名称,支持中文、字母、数字" datatype="/^[a-zA-Z0-9\u4e00-\u9fa5]{1,30}$/" errormsg="请输入1-30位的名称,支持中文、字母、数字!">
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
@@ -64,7 +60,7 @@
|
|
|
<label class="form-label col-xs-4 col-sm-3">备注:</label>
|
|
|
<div class="formControls col-xs-8 col-sm-9">
|
|
|
<textarea name="bomRemarks" id="bomRemarks" cols="" rows="" class="textarea"
|
|
|
- placeholder="Bom单备注,最多支持100字符" onKeyUp="$.Huitextarealength(this,100)"></textarea>
|
|
|
+ placeholder="Bom单备注,最多支持100字符" onKeyUp="$.Huitextarealength(this,100)" ></textarea>
|
|
|
<p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -72,6 +68,7 @@
|
|
|
<div class="row cl">
|
|
|
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>Bom零件清单:</label>
|
|
|
<div class="formControls col-xs-8 col-sm-9 components">
|
|
|
+ <input type="hidden" id="bomComponentJson" name="bomComponentJson">
|
|
|
<table class="table table-border table-bordered table-bg table-hover table-sort">
|
|
|
<thead>
|
|
|
<tr class="text-c">
|
|
@@ -80,31 +77,17 @@
|
|
|
<th width="20">操作</th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
- <tbody>
|
|
|
- <tr class="text-c">
|
|
|
- <td>
|
|
|
- <select class="select" size="1" name="bomId" style="height: 30px;">
|
|
|
- <option value="">选择零件</option>
|
|
|
- <option value="1">净水机</option>
|
|
|
- </select>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <input type="text" class="input-text" value="" id="bomName" name="bomName" placeholder="零件数量">
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <a style="" href="javascript:void(0);" title="编辑" onclick="">
|
|
|
- <i class="Hui-iconfont"></i>
|
|
|
- </a>
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
+ <tbody id="componentaAll">
|
|
|
+
|
|
|
</tbody>
|
|
|
</table>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
+
|
|
|
<div class="row cl">
|
|
|
<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
|
|
|
- <input class="btn btn-primary radius" type="button" value=" 新增零件 " onclick="addComponents()">
|
|
|
+ <input class="btn btn-primary radius" type="button" value=" 新增零件 " onclick="addComponents('#','')">
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
@@ -121,87 +104,210 @@
|
|
|
</article>
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
- $(function () {
|
|
|
- $('.skin-minimal input').iCheck({
|
|
|
- checkboxClass: 'icheckbox-blue',
|
|
|
- radioClass: 'iradio-blue',
|
|
|
- increaseArea: '20%'
|
|
|
- });
|
|
|
-
|
|
|
- $("#form-member-add").validate({
|
|
|
- rules: {
|
|
|
- bomId: {
|
|
|
- required: true
|
|
|
- },
|
|
|
- produceId: {
|
|
|
- required: true
|
|
|
- },
|
|
|
- bomName: {
|
|
|
- required: true,
|
|
|
- minlength:1,
|
|
|
- maxlength:30
|
|
|
- },
|
|
|
- bomRemarks: {
|
|
|
- required: true,
|
|
|
- maxlength:30
|
|
|
+ $(function(){
|
|
|
+ $("#form-bom-add").Validform({
|
|
|
+ tiptype: function (msg, o, cssctl) {
|
|
|
+ if (o.type == 3) {//失败
|
|
|
+ layer.msg(msg, {icon: 5, time: 3000});
|
|
|
+ $(window).scrollTop(o.obj.offset().top - 40);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ datatype: {//自定义验证类型
|
|
|
+ "select": function (gets, obj, curform, regxp) {
|
|
|
+ if (gets == "") {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
- onkeyup: false,
|
|
|
- focusCleanup: true,
|
|
|
- success: "valid",
|
|
|
- submitHandler: function (form) {
|
|
|
- //$(form).ajaxSubmit();
|
|
|
- var index = parent.layer.getFrameIndex(window.name);
|
|
|
- //parent.$('.btn-refresh').click();
|
|
|
- parent.layer.close(index);
|
|
|
+ ignoreHidden: true,
|
|
|
+ tipSweep: true, //若为true,则只在表单提交时验证
|
|
|
+ ajaxPost: true, //异步提交
|
|
|
+ beforeCheck: function (curform) { //验证通过之前执行的函数
|
|
|
+ },
|
|
|
+ beforeSubmit: function (curform) { //验证通过之后执行的函数
|
|
|
+ var ptsBomComponentsList = new Array();
|
|
|
+ $("#componentaAll").find("tr").each(function (){
|
|
|
+ var ptsBomComponents = {};
|
|
|
+ ptsBomComponents.componentsId = $(this).find("[name='comName']").eq(0).val();
|
|
|
+ ptsBomComponents.bomComponentsQuantity = $(this).find("[name='comNumber']").eq(0).val();
|
|
|
+ ptsBomComponentsList.push(ptsBomComponents);
|
|
|
+ })
|
|
|
+ $("#bomComponentJson").val(JSON.stringify(ptsBomComponentsList));
|
|
|
+ },
|
|
|
+ callback: function (data) {//异步回调函数
|
|
|
+ if (data) {
|
|
|
+ var index = layer.alert(data.resultMsg, function () {
|
|
|
+ if (data.Success) {
|
|
|
+ location.href = "${path}/admin/bom/_bom_list";
|
|
|
+ } else {
|
|
|
+ layer.close(index);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
- });
|
|
|
+ })
|
|
|
+
|
|
|
|
|
|
- var allComponents;
|
|
|
+ var allComponents; //所有零件的集合
|
|
|
+
|
|
|
+ $(function () {
|
|
|
+ /*添加页面初始化,添加一个零件选择框*/
|
|
|
+ addComponents("#","");
|
|
|
+
|
|
|
+ var produceId = $("[name='produceId']").val();
|
|
|
+ getBomByProduce(produceId);
|
|
|
+
|
|
|
+ /*监听产品选择*/
|
|
|
+ $("[name='produceId']").change(function(){
|
|
|
+ var produceId = $(this).val();
|
|
|
+ getBomByProduce(produceId);
|
|
|
+ })
|
|
|
+
|
|
|
+ /*监听修改基础 bom单*/
|
|
|
+ $("[name='bomId']").change(function(){
|
|
|
+ var bomId = $(this).val();
|
|
|
+ getBom(bomId);
|
|
|
+ })
|
|
|
+ })
|
|
|
|
|
|
/* 添加零件 */
|
|
|
- function addComponents() {
|
|
|
- var tbody = $(".tbody");
|
|
|
+ function addComponents(componentsId,number) {
|
|
|
+ var tbody = $("#componentaAll");
|
|
|
|
|
|
- if(allComponents == null){ //获取
|
|
|
- allComponents = listComponent();
|
|
|
+ if(allComponents == null){ //获取零件列表
|
|
|
+ var produceId = $("[name='produceId']").val();
|
|
|
+ allComponents = listComponent(produceId);
|
|
|
+ }
|
|
|
+ var opHtml = '';
|
|
|
+ for(var i=0;i<allComponents.length;i++){
|
|
|
+ var components = allComponents[i];
|
|
|
+ var isSelect = '';
|
|
|
+ if(componentsId == components.componentsId){
|
|
|
+ isSelect = 'selected="selected"';
|
|
|
+ }
|
|
|
+ opHtml += '<option value="'+ components.componentsId +'" '+ isSelect +'>'+ components.componentsName +'('+ components.componentsNo + ')</option>';
|
|
|
}
|
|
|
-
|
|
|
var html = '<tr class="text-c"> '
|
|
|
+'<td> '
|
|
|
- +'<select class="select" size="1" name="" style="height: 30px;"> '
|
|
|
- +'<option value="">选择零件</option> '
|
|
|
- +' '
|
|
|
+ +'<select class="select" size="1" name="comName" style="height: 30px;"> '
|
|
|
+ +''
|
|
|
+ + opHtml
|
|
|
+'</select> '
|
|
|
+'</td> '
|
|
|
+'<td> '
|
|
|
- +'<input type="text" class="input-text" value="" id="" name="" placeholder="零件数量"> '
|
|
|
+ +'<input type="text" class="input-text" value="'+ number +'" id="" name="comNumber" placeholder="零件数量" datatype="n1-3" errormsg="零件数量不能超过999件!"> '
|
|
|
+'</td> '
|
|
|
+'<td> '
|
|
|
- +'<a style="" href="javascript:void(0);" title="编辑" onclick=""> '
|
|
|
+ +'<a style="" href="javascript:void(0);" title="删除" onclick="delComponent(this,1)"> '
|
|
|
+'<i class="Hui-iconfont"></i> '
|
|
|
+'</a> '
|
|
|
+'</td> '
|
|
|
+'</tr>';
|
|
|
-
|
|
|
+ tbody.append(html);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*删除零件 type=all时删除所有的零件 */
|
|
|
+ function delComponent(node,type) {
|
|
|
+ if(type == "all"){
|
|
|
+ $("#componentaAll").find("tr").each(function () {
|
|
|
+ $(this).remove();
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ $(node).parent().parent().remove();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/*获取所有的零件*/
|
|
|
- function listComponent() {
|
|
|
+ function listComponent(produceId) {
|
|
|
+ var list = new Array();
|
|
|
+ $.ajax({
|
|
|
+ type: "POST",
|
|
|
+ data: {
|
|
|
+ produceId : produceId
|
|
|
+ },
|
|
|
+ url: "${path}/admin/bom/get_listComponents",
|
|
|
+ async: false,
|
|
|
+ success: function(data){
|
|
|
+ if (data.returnCode == 200) {
|
|
|
+ list = data.returnMsg.ptsComponentsList;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function(XmlHttpRequest, textStatus, errorThrown){
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*根据产品id,获取bom集合*/
|
|
|
+ function getBomByProduce(produceId){
|
|
|
+ $.ajax({
|
|
|
+ type: "POST",
|
|
|
+ data: {
|
|
|
+ produceId : produceId
|
|
|
+ },
|
|
|
+ url: "${path}/admin/bom/get_listBom",
|
|
|
+ async: false,
|
|
|
+ success: function(data){
|
|
|
+ var html = '<option value="">不选择</option>';
|
|
|
+ if (data.returnCode == 200) {
|
|
|
+ var bomList = data.returnMsg.ptsBomsList;
|
|
|
+ for(var i=0;i<bomList.length;i++){
|
|
|
+ html += '<option value="'+ bomList[i].bomId +'">'+ bomList[i].bomName +'</option>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(data.returnCode != 200 || data.returnMsg.ptsBomsList <1){
|
|
|
+ defaultAllInput();
|
|
|
+ }
|
|
|
+ $("[name='bomId']").html(html);
|
|
|
+ },
|
|
|
+ error: function(XmlHttpRequest, textStatus, errorThrown){
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /*获取bom信息,赋值在页面上*/
|
|
|
+ function getBom(bomId){
|
|
|
+ var bom = new Object();
|
|
|
$.ajax({
|
|
|
type: "POST",
|
|
|
- data: data,
|
|
|
- url: "${path}/admin/employee/get_listComponents",
|
|
|
+ data: {
|
|
|
+ bomId : bomId
|
|
|
+ },
|
|
|
+ url: "${path}/admin/bom/get_bom",
|
|
|
async: false,
|
|
|
success: function(data){
|
|
|
if (data.returnCode == 200) {
|
|
|
- window.location.href = '${path}//admin/employee/_employee_list'
|
|
|
+ bom = data.returnMsg.ptsBom;
|
|
|
}
|
|
|
},
|
|
|
error: function(XmlHttpRequest, textStatus, errorThrown){
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ if(bom != null && bom.bomId != null){
|
|
|
+ $("#bomName").val(bom.bomName);
|
|
|
+ $("#bomRemarks").val(bom.bomRemarks);
|
|
|
+ delComponent(0,"all");
|
|
|
+ var components = bom.ptsBomComponentsList;
|
|
|
+ if(components != null && components.length > 0){
|
|
|
+ for(var i=0;i<components.length;i++){
|
|
|
+ addComponents(components[i].componentsId,components[i].bomComponentsQuantity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ defaultAllInput();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*当选择产品或者bom不选择时,都需要重置所有的输入框和表格*/
|
|
|
+ function defaultAllInput() {
|
|
|
+ $("#bomName").val("");
|
|
|
+ $("#bomRemarks").val("");
|
|
|
+ delComponent(0,"all");
|
|
|
+ addComponents("#","");
|
|
|
}
|
|
|
</script>
|
|
|
<!--/请在上方写此页面业务相关的脚本-->
|