<div class="form-group"> <label class="col-lg-2 control-label">供應商</label> <div class="col-lg-9"> <div class="input-group input-large"> <select id="supplierId" name="warehouseRecord.supplierId" class="form-control"> #for(item:supplierList) <option value="#(item.id)">#(item.name)</option> #end </select> <span class="input-group-btn"> <button id="btnAddSupplier" type="button" class="btn default" #if(!flag) disabled="disabled" #end href="#res" data-toggle="modal">新增供應商</button> </span> </div> </div> </div> <!-- 添加供應商彈出框 --> <div class="modal fade draggable-modal" id="res" tabindex="-1" role="basic" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title" style="text-align: center;">新增供應商</h4> </div> <div class="modal-body"> <div class="row"> <label class="col-md-3 control-label ">供應商名稱<span class="required" aria-required="true"> * </span> </label> <div class="col-md-4"> <input type="text" class="form-control input-medium" id="name" name="storeSupplier.name" placeholder="請輸入" required /> </div> </div> </div> <div class="modal-body"> <div class="row"> <label class="col-md-3 control-label ">供應商地址</label> <div class="col-md-4"> <input type="text" class="form-control input-medium" id="address" name="storeSupplier.address" placeholder="請輸入" /> </div> </div> </div> <div class="modal-body"> <div class="row"> <label class="col-md-3 control-label "> 聯繫人<span class="required" aria-required="true"> * </span> </label> <div class="col-md-4"> <input type="text" class="form-control input-medium" id="principal" name="storeSupplier.principal" placeholder="請輸入" required /> </div> </div> </div> <div class="modal-body"> <div class="row"> <label class="col-md-3 control-label ">聯繫電話</label> <div class="col-md-4"> <input type="text" class="form-control input-medium" id="phone" name="storeSupplier.phone" placeholder="請輸入" /> </div> </div> </div> <div class="modal-body"> <div class="row"> <label class="col-md-3 control-label ">備註</label> <div class="col-md-4"> <input type="text" class="form-control input-medium" id="remark" name="storeSupplier.remark" placeholder="請輸入" /> </div> </div> </div> <div class="modal-body"></div> <form></form> <div class="modal-footer"> <button type="button" data-dismiss="modal" id="ons" class="btn btn-outline btn-danger">取消</button> <button type="submit" onclick="addSuppli();" class="btn green">確認</button> </div> </div> <!-- /.modal-content --> </div> </div> #end #define js() <script src="#(context)/assets/global/plugins/fuelux/js/spinner.min.js" type="text/javascript"></script> <script src="#(context)/assets/admin/barcode/jquery-barcode.min.js" type="text/javascript"></script> <script> //添加供應商肯定按鈕 的點擊事件 function addSuppli() { var name = $('#name').val(); var principal = $('#principal').val(); var address = $('#address').val(); var phone = $('#phone').val(); var remark = $('#remark').val(); if(name == "" || principal == ""){ bootbox.alert({ message : "供應商名稱或聯繫人不能爲空!", buttons : { ok : { label : '肯定', className : 'btn-success' } } }); return; }else{ $.ajax({ url : "#(context)/goods/storage/addStoreSupplier", type : 'POST', data : { "name" : name, "address" : address, "principal" : principal, "phone" : phone, "remark" : remark }, success : function(data) { debugger; $("#ons").click(); $("#supplierId option").remove(); $.each(data.data.storeSupplist, function(i, obj){ $("#supplierId").append("<option value='"+ obj.id+"'>"+ obj.name +"</option>") }); } }); } } //不刷新頁面 點擊添加供應商的時候 就要把以前填寫過的內容清空 $("#btnAddSupplier").click(function(){ $("#remark").val(""); $("#name").val(""); $("#principal").val(""); $("#address").val(""); $("#phone").val(""); });