123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- @extends('admin/master')
- @section('content')
- <body>
- @if(count($errors) > 0)
- <div class="Huialert Huialert-info" id="error">
- @foreach($errors->all() as $error)
- <li>{{$error}}</li>
- @endforeach
- </div>
- @endif
- <div class="page-container">
- <form action="/admin/customer/giftStore" method="post" class="form form-horizontal" enctype="multipart/form-data">
- <input type="hidden" name="_token" value="{{ csrf_token() }}" />
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2"><font color='red'>* </font>搜索选择商品:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type='text' class="input-text" autocomplete="off" name='goods_name' placeholder="输入关键词搜索商品,C仓必须选择" value="{{old('goods_name')}}"/>
- <ul id="good_sku"></ul>
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>已选择商品:</label>
- <div id='goods_o' name='goods_o_con' class="formControls col-xs-6 col-sm-6">
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- 类型:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <select style="text-align:center" id='type' name="type" class="select-box">
- <option value="1" @if(old('type')==1) selected @endif>生日赠礼</option>
- <option value="0" @if(old('type')==0) selected @endif>12月赠礼</option>
- </select>
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- 日期:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM' })" autocomplete="off" class="input-text Wdate" name="mtime" value="{{old('mtime')}}">
- <br>
- </div>
- </div>
- <div class="row cl">
- <div class="col-9 col-offset-2">
- <button class="btn btn-primary radius" type="submit" value=" 提交 "> 提交 </button>
- <button class="btn btn-default" type="reset" onclick="return_index();"> 返回 </button>
- {{--<a href="javascript:void(0)" class="btn btn-default radius" onclick="redirect('{{url('/admin/admin/all')}}')">返回并查看结果</a>--}}
- </div>
- </div>
- </form>
- </div>
- <!--_footer 作为公共模版分离出去-->
- <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
- <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
- <script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
- <script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
- <!--/_footer 作为公共模版分离出去-->
- <!--请在下方写此页面业务相关的脚本-->
- <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
- <script type="text/javascript">
- $(function(){
- setTimeout("$('#error').hide()",3000);
- var dtime = today();
- $('#createTime').val(dtime);
- var tdate = today_date();
- $('#delivery').val(tdate);
- $('#category').change(function(){
- category = $('#category').val();
- if(category==''){
- return false;
- }
- $.ajax({
- 'url':'/admin/order/categoods/'+category,
- 'type': 'get',
- 'dataType':'json',
- 'success' : function(data){
- str = '<option value=\'0\'>-- 选择商品 --<\/option>';
- $.each(data, function(i, va){
- var props = va.props_name;
- if(props != ''){
- props = '【' + props + '】';
- }
- var price = va.price;
- if(price > 0){
- price = '【¥' + price + '元】';
- }else{
- price = '';
- }
- str += '<option value="'+va.id+'">' + va.goods_name + props + price +'<\/option>';
- })
- $('#goods').html(str);
- }
- });
- })
- });
- function add_goods(goods_id,sku_id,name,props_name,price,is_weigh){
- //只可以选择一种商品
- var length = $('#goods_o').children().length;
- if(length > 0){
- alert('只可以添加一个商品,请先移除现有商品');
- return false;
- }
- var gnum = $("#gnum"+sku_id).val();
- var weigh_unit = '数量';
- var weigh_note = '';
- var weigh_unit_name = '';
- if(is_weigh == 1){
- weigh_unit = '重量';
- weigh_unit_name = '(斤)';
- weigh_note = '<font color=\'red\'> (称重商品,至少0.5斤) <\/font>';
- }
- if(gnum){
- var n = gnum;
- n = parseFloat(n)+1
- $("#gnum"+sku_id).val(n);
- }
- else{
- var str = "<div>"+name+' 【 规格:'+props_name+' 价格:¥'+price+" 】 <input type='hidden' name='skus[]' value="+sku_id+" \/><font style=\"font-weight: bold;\">"+weigh_unit+" <\/font><button style='width:14px;' type='button' onclick=\"cut_num("+sku_id+","+ price + ","+ is_weigh +")\">-<\/button><div style=\"display:inline-block\" id='gnum_con"+ sku_id +"' ><input style='width:40px;' id='gnum"+ sku_id +"' class='gnums' onkeyup='sync_money();' price="+price+" is_weigh="+is_weigh+" type=\'text\' name=\'gnum[]\' value=1 \/><\/div><button style='width:14px;' type='button' onclick=\"add_num("+sku_id+","+ price + ","+ is_weigh +")\">+<\/button>"+weigh_unit_name+" <button type='button' onclick='del_sku(this, "+sku_id+","+ price + ")'> 移除<\/button> "+weigh_note+"<\/div>";
- $("#goods_o").append(str);
- sessionStorage.setItem('goods_o_con',$("#goods_o").html());
- }
- sync_money()
- document.getElementById('good_sku').style.display='none'
- return false;
- }
- function add_num(sku_id, price, is_weigh){
- var gnum = $("#gnum"+sku_id).val();
- var n = gnum;
- n = parseFloat(n)+1
- $("#gnum"+sku_id).val(n);
- $("#gnum_con" + sku_id).html("<input style='width:40px;' id='gnum"+ sku_id +"' class='gnums' onkeyup='sync_money();' price="+price+" is_weigh="+is_weigh+" type=\'text\' name=\'gnum[]\' value=" + n + " \/>")
- sessionStorage.setItem('goods_o_con',$("#goods_o").html());
- sync_money()
- return false;
- }
- function cut_num(sku_id, price, is_weigh){
- var gnum = $("#gnum"+sku_id).val();
- var n = gnum;
- if(n == 1){
- return false;
- }
- n = parseFloat(n)-1;
- $("#gnum"+sku_id).val(n);
- $("#gnum_con" + sku_id).html("<input style='width:40px;' id='gnum"+ sku_id +"' class='gnums' onkeyup='sync_money();' price="+price+" is_weigh="+is_weigh+" type=\'text\' name=\'gnum[]\' value=" + n + " \/>")
- sessionStorage.setItem('goods_o_con',$("#goods_o").html());
- sync_money()
- return false;
- }
- function del_sku(obj, sku_id, price){
- //console.log(obj)
- var gnum = $("#gnum"+sku_id).val();
- $(obj).parent().remove();
- sessionStorage.setItem('goods_o_con',$("#goods_o").html());
- sync_money();
- }
- function sync_money(){
- var gnums = new Array();
- var total = 0;
- $('.gnums').each(function(key, value){
- var gnum = $(this).val();
- var price = $(this).attr('price');
- total = total + parseFloat(price) * parseFloat(gnum);
- });
- if(total>0){
- $("#should_amount").val(total);
- $("#should_amount_show").html(total);
- }else{
- $("#should_amount").val('');
- $("#should_amount_show").html('');
- }
- return false;
- }
- function today(){
- var today=new Date();
- var h=today.getFullYear();
- var m=today.getMonth()+1;
- var d=today.getDate();
- var hh=today.getHours();
- var mm=today.getMinutes();
- var ss=today.getSeconds();
- m= m<10?"0"+m:m;
- d= d<10?"0"+d:d;
- hh = hh < 10 ? "0" + hh:hh;
- mm = mm < 10 ? "0" + mm:mm;
- ss = ss < 10 ? "0" + ss:ss;
- return h+"-"+m+"-"+d+" "+hh+":"+mm+":"+ss;
- }
- function today_date(){
- var today=new Date();
- var h=today.getFullYear();
- var m=today.getMonth()+1;
- var d=today.getDate();
- var hh=today.getHours();
- var mm=today.getMinutes();
- var ss=today.getSeconds();
- m= m<10?"0"+m:m;
- d= d<10?"0"+d:d;
- hh = hh < 10 ? "0" + hh:hh;
- mm = mm < 10 ? "0" + mm:mm;
- ss = ss < 10 ? "0" + ss:ss;
- return h+"-"+m+"-"+d;
- }
- function getGoods(){
- var name = $('input[name=goods_name]').val();
- if(!name){
- return false;
- }
- $.ajax({
- 'url': '/admin/goods/searchSkus?name='+name,
- 'type': 'get',
- 'dateType': 'json',
- success:function(data){
- if(data != '0'){
- data = eval("("+data+")");
- }
- }
- })
- }
- function to_verify(){
- if(!form_verify()){
- return false;
- }
- $("input[name=status]").val('1');
- var warehouse = $("#warehouse").val();
- if(warehouse == 3){
- var if_good = $('.gnums');
- if(!if_good.length){
- layer.msg('仓库C必须选择商品!',{icon:2,time:1500});
- return false;
- }
- }
- $(".btn").attr("disabled",true);
- //console.log('disabled')
- $("#order-form").submit();
- return true;
- }
- // $("#goods_o").append(sessionStorage.getItem('goods_o_con'));
- $('input[name=goods_name]').on('keyup focus', function(){
- var name = $('input[name=goods_name]').val();
- if(!name){
- return false;
- }
- $.ajax({
- 'url': '/admin/goods/searchSkus?name='+name,
- 'type': 'get',
- 'dateType': 'json',
- success:function(data){
- if(data != '0'){
- data = eval("("+data+")");
- var str = '';
- for (var i = 0, l = data.length; i < l; i++) {
- var item = data[i];
- var weigh_t = '';
- if(item.is_weigh==1){
- weigh_t = '【按半斤称重】';
- }
- if(item.is_white == 0 && item.quantity <= 0){
- weigh_t += '<font color="red">【库存不足】<\/font>';
- str += '<li>'+ item.name+'【 规格:'+item.propsName+' 价格:¥'+item.price +' 】'+weigh_t+'<\/li>'
- }
- else{
- str += '<li onclick=\'add_goods('+item.goods_id+','+item.sku_id+',"'+item.name+'","'+item.propsName+'",'+item.price+','+item.is_weigh+');\'>'+ item.name+'【 规格:'+item.propsName+' 价格:¥'+item.price +' 】'+weigh_t+'<\/li>'
- }
- // '<p onclick=\'add_goods('+item.goods_id+','+item.sku_id+',"'+item.name+'","'+item.propsName+'",'+item.price+');\'>'+ item.name+' '+item.propsName+' ¥'+item.price +'<\/p>';
- }
- document.getElementById('good_sku').innerHTML = str;
- document.getElementById('good_sku').style.display='block'
- }
- }
- })
- });
- $("body").on('click', function(){
- $('input[name=goods_name]').on('click',function(e){
- e.stopPropagation();
- });
- document.getElementById('good_sku').style.display='none'
- })
- function weigh_verify(){
- var if_no = 0;
- $('.gnums').each(function(key, value){
- var gnum = $(this).val();
- gnum = parseFloat(gnum);
- var is_weigh = $(this).attr('is_weigh');
- if(gnum<0.5){
- if_no = 1;
- return;
- }
- if(is_weigh == 0 && gnum%1 != 0){
- if_no = 2;
- return;
- }
- if(is_weigh == 1 && gnum%0.5 != 0){
- if_no = 3;
- return;
- }
- });
- return if_no;
- }
- /*返回*/
- function return_index(){
- location.href='/admin/customer/giftList';
- }
- </script>
- </body>
- @endsection
|