Keine Beschreibung

orderedit.blade.php 34KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. @extends('admin/master')
  2. @section('content')
  3. <body>
  4. @if(count($errors) > 0)
  5. <div class="Huialert Huialert-info" id="error">
  6. @foreach($errors->all() as $error)
  7. <li>{{$error}}</li>
  8. @endforeach
  9. </div>
  10. @endif
  11. <style type="text/css">
  12. #good_sku{
  13. position: absolute;
  14. z-index: 9;
  15. background: #ffffff;
  16. box-shadow: 1px 1px 1px 1px #ccc;
  17. width: calc(100% - 30px);
  18. }
  19. #good_sku li{
  20. font-size: 12px;
  21. line-height: 24px;
  22. cursor: pointer;
  23. padding: 5px 10px;
  24. }
  25. #good_sku li:hover{
  26. background: #eaeaea;
  27. }
  28. </style>
  29. <div class="page-container">
  30. <form id='order-form' action="/admin/fxorder/update" method="post" class="form form-horizontal" enctype="multipart/form-data" onkeypress="return event.keyCode != 13;">
  31. <input type="hidden" name="_token" value="{{ csrf_token() }}" />
  32. <input type='hidden' name='str_query' value="{{$str_query}}"/>
  33. <input type='hidden' name='last_url' value="{{$last_url}}"/>
  34. @if($order)
  35. <input type="hidden" name="id" value="{{$order['id']}}" />
  36. <div class="row cl">
  37. <label class="form-label col-xs-4 col-sm-2">
  38. <font color='red'>* </font>买家姓名:</label>
  39. <div class="formControls col-xs-6 col-sm-6">
  40. <input type="text" class="input-text" value="{{$order['customerName']}}" placeholder="请输入名称" name="customerName">
  41. </div>
  42. </div>
  43. <div class="row cl">
  44. <label class="form-label col-xs-4 col-sm-2">
  45. <font color='red'>* </font>收件人姓名:</label>
  46. <div class="formControls col-xs-6 col-sm-6">
  47. <input type="text" class="input-text" value="{{$order['receiverName']}}" placeholder="" name="receiverName">
  48. </div>
  49. </div>
  50. <div class="row cl">
  51. <label class="form-label col-xs-4 col-sm-2">
  52. <font color='red'>* </font>收件人手机号:</label>
  53. <div class="formControls col-xs-6 col-sm-6">
  54. <input type="text" class="input-text" value="{{$order['receiverMobile']}}" placeholder="" name="receiverMobile">
  55. </div>
  56. </div>
  57. <div class="row cl">
  58. <label class="form-label col-xs-4 col-sm-2">
  59. <font color='red'>* </font>省/直辖市:</label>
  60. <div class="formControls col-xs-6 col-sm-6">
  61. <input type="text" class="input-text" value="{{$order['receiverState']}}" placeholder="" name="receiverState">
  62. </div>
  63. </div>
  64. <div class="row cl">
  65. <label class="form-label col-xs-4 col-sm-2">
  66. <font color='red'>* </font>市:</label>
  67. <div class="formControls col-xs-6 col-sm-6">
  68. <input type="text" class="input-text" value="{{$order['receiverCity']}}" placeholder="" name="receiverCity">
  69. </div>
  70. </div>
  71. <!--div class="row cl">
  72. <label class="form-label col-xs-4 col-sm-2">
  73. 区:</label>
  74. <div class="formControls col-xs-6 col-sm-6">
  75. <input type="text" class="input-text" value="{{$order['receiverDistrict']}}" placeholder="" name="receiverDistrict">
  76. </div>
  77. </div>
  78. <div class="row cl">
  79. <label class="form-label col-xs-4 col-sm-2">
  80. 街道:</label>
  81. <div class="formControls col-xs-6 col-sm-6">
  82. <input type="text" class="input-text" value="{{$order['receiverStreet']}}" placeholder="" name="receiverStreet">
  83. </div>
  84. </div-->
  85. <div class="row cl">
  86. <label class="form-label col-xs-4 col-sm-2">
  87. <font color='red'>* </font>详细地址:</label>
  88. <div class="formControls col-xs-6 col-sm-6">
  89. <input type="text" class="input-text" value="{{$order['receiverAddress']}}" placeholder="" name="receiverAddress">
  90. </div>
  91. </div>
  92. @if($self_role !='分销销售' && $self_role != '分销管理员' )
  93. @if( $order['status']>1 && $self_role !='超级管理员')
  94. <div class="row cl">
  95. <label class="form-label col-xs-4 col-sm-2">
  96. <font color='red'>* </font>商品信息:</label>
  97. <div class="formControls col-xs-6 col-sm-6">
  98. <textarea class="textarea" placeholder="填写商品详细信息,A或B仓必填" readonly="true" >{{$order['goods_note']}}</textarea>
  99. <input type="hidden" name="goods_note" value="{{$order['goods_note']}}" />
  100. </div>
  101. </div>
  102. @else
  103. <div class="row cl">
  104. <label class="form-label col-xs-4 col-sm-2">
  105. <font color='red'>* </font>商品信息:</label>
  106. <div class="formControls col-xs-6 col-sm-6">
  107. <textarea class="textarea" placeholder="填写商品详细信息,A或B仓必填" name="goods_note">{{$order['goods_note']}}</textarea>
  108. </div>
  109. </div>
  110. @endif
  111. @endif
  112. <div class="row cl">
  113. <label class="form-label col-xs-4 col-sm-2">
  114. <font color='red'>* </font>预发货时间:</label>
  115. <div class="formControls col-xs-6 col-sm-6">
  116. <input id="delivery" type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' })" class="input-text Wdate" style="width:22%;text-align:center;" name="delivery_date" value="{{$order['delivery_date']}}"><font color='red'> </font>
  117. </div>
  118. </div>
  119. @if($self_role !='分销销售' && $self_role != '分销管理员' )
  120. <div class="row cl">
  121. <label class="form-label col-xs-4 col-sm-2">
  122. 物流单号:</label>
  123. <div class="formControls col-xs-6 col-sm-6">
  124. <input type="text" class="input-text" value="{{$order['logistics_id']}}" placeholder="" name="logistics_id">
  125. </div>
  126. </div>
  127. @endif
  128. @if($self_role == '超级管理员' || $self_role == '售后管理员')
  129. <div class="row cl">
  130. <label class="form-label col-xs-4 col-sm-2">
  131. <font color='red'>* </font>发货仓库:</label>
  132. <div class="formControls col-xs-6 col-sm-6">
  133. <span class="select-box">
  134. <select size="1" name="warehouse" id='warehouse'>
  135. <option value="0" @if($order['warehouse']=='0') selected @endif>- 请选择 -</option>
  136. <option value="1" @if($order['warehouse']=='1') selected @endif>A仓库</option>
  137. <option value="2" @if($order['warehouse']=='2') selected @endif>B仓库</option>
  138. <option value="3" @if($order['warehouse']=='3') selected @endif>C仓库</option>
  139. </select>
  140. </span>
  141. </div>
  142. </div>
  143. @else
  144. <div class="row cl">
  145. <label class="form-label col-xs-4 col-sm-2">
  146. <font color='red'>* </font>发货仓库:</label>
  147. <div class="formControls col-xs-6 col-sm-6">
  148. @if($order['warehouse']=='1') A仓库 @endif
  149. @if($order['warehouse']=='2') B仓库 @endif
  150. @if($order['warehouse']=='3') C仓库 @endif
  151. <input type="hidden" name="warehouse" id='warehouse' value="{{$order['warehouse']}}"/>
  152. </div>
  153. </div>
  154. @endif
  155. @if($self_role !='销售' && $self_role != '分销销售' && $self_role != '分销管理员' )
  156. <div class="row cl">
  157. <label class="form-label col-xs-4 col-sm-2">
  158. 成本:</label>
  159. <div class="formControls col-xs-6 col-sm-6">
  160. <input type="text" class="input-text" value="{{$order['cost']}}" placeholder="" name="cost">
  161. </div>
  162. </div>
  163. @endif
  164. @if( $order['status'] <2 || !$order['goods'] )
  165. <div class="row cl">
  166. <label class="form-label col-xs-4 col-sm-2">搜索选择商品:</label>
  167. <div class="formControls col-xs-6 col-sm-6">
  168. <input type='text' class="input-text" autocomplete="off" name='goods_name' placeholder="输入关键词搜索商品,C仓必须选择" value=''/>
  169. <ul id="good_sku"></ul>
  170. </div>
  171. </div><br>
  172. @endif
  173. <div class="row cl">
  174. <label class="form-label col-xs-4 col-sm-2">
  175. <font color='red'>* </font>已选择商品:</label>
  176. <div id='goods_o' class="formControls col-xs-6 col-sm-6">
  177. <input class="input-text" id='g_info' type='hidden' name='g_info' value=''/>
  178. @if($order['goods'])
  179. @foreach($order['goods'] as $k=>$good)
  180. <p>{{$good['name']}} 【 规格:{{$good['props_name']}} 价格:¥{{$good['price']}} 库存:{{$good['quantity_str']}}】&nbsp; <input type='hidden' name='skus[]' value="{{$good['sku_id']}}" /><font style="font-weight: bold;"> @if($good['is_weigh']==0) 数量 @else重量 @endif</font> @if($order['status'] < 2)<button style='width:14px;' type='button' onclick="cut_num({{$good['sku_id']}},{{$good['price']}})">-</button><input style='width:45px;' id='gnum{{$good["sku_id"]}}' class='gnums' price='{{$good["price"]}}' is_weigh='{{$good["is_weigh"]}}' quantity='{{$good["quantity"]}}' is_white='{{$good["is_white"]}}' type='text' name='gnum[]' value='{{$good["num"]}}' /><button style='width:14px;' type='button' onclick="add_num({{$good['sku_id']}},{{$good['price']}})">+</button>@if($good['is_weigh']==1)(斤) @endif &nbsp;&nbsp; <button type='button' onclick="del_sku(this,{{$good['sku_id']}},{{$good['price']}})"> 移除</button>@if($good['is_weigh']==1) &nbsp;&nbsp;<font color='red'>(称重商品,至少0.5斤) </font> @endif @else :{{$good["num"]}} @if($good['is_weigh']==1)斤【称重商品】 @endif<input type='hidden' id='gnum{{$good["sku_id"]}}' class='gnums' price='{{$good["price"]}}' name='gnum[]' value='{{$good["num"]}}' /> @endif </p>
  181. @endforeach
  182. @endif
  183. </div>
  184. </div><br>
  185. <div class="row cl">
  186. <label class="form-label col-xs-4 col-sm-2">
  187. 应收金额:</label>
  188. <div class="formControls col-xs-6 col-sm-6">
  189. <span id='should_amount_show'>{{$order['should_amount']}}</span>
  190. <input id='should_amount' type="hidden" class="input-text" value="{{$order['should_amount']}}" placeholder="" name="should_amount">
  191. </div>
  192. </div>
  193. @if( $order['status']>1 && $self_role !='超级管理员')
  194. <div class="row cl">
  195. <label class="form-label col-xs-4 col-sm-2">
  196. <font color='red'>* </font>实付金额:</label>
  197. <div class="formControls col-xs-6 col-sm-6">
  198. <input type="text" class="input-text" value="{{$order['receivedAmount']}}" placeholder="" readonly />
  199. <input type="hidden" id='receivedAmount' class="input-text" value="{{$order['receivedAmount']}}" name="receivedAmount"/>
  200. </div>
  201. </div>
  202. @else
  203. <div class="row cl">
  204. <label class="form-label col-xs-4 col-sm-2">
  205. <font color='red'>* </font>实付金额:</label>
  206. <div class="formControls col-xs-6 col-sm-6">
  207. <input type="text" id='receivedAmount' class="input-text" value="{{$order['receivedAmount']}}" placeholder="" name="receivedAmount">
  208. </div>
  209. </div>
  210. @endif
  211. @if($order['payment_type']=='4')
  212. <div class="row cl">
  213. <label class="form-label col-xs-4 col-sm-2">
  214. <font color='red'>* </font>支付方式:</label>
  215. <div class="formControls col-xs-6 col-sm-6">
  216. <input type="radio" name="payment_type" value="4" checked >
  217. <label for="status-0" style="margin-right: 27px;">充值卡支付</label>
  218. </div>
  219. </div>
  220. @else
  221. <div class="row cl">
  222. <label class="form-label col-xs-4 col-sm-2">
  223. <font color='red'>* </font>支付方式:</label>
  224. <div class="formControls col-xs-6 col-sm-6">
  225. <input type="radio" name="payment_type" value="1" @if($order['payment_type']=='1') checked @endif>
  226. <label for="status-1" style="margin-right: 27px;">微信支付</label>
  227. @if($order['payment_type']=='2')
  228. <input type="radio" name="payment_type" value="2" checked >
  229. <label for="status-0" style="margin-right: 27px;">付款码支付</label>
  230. @endif
  231. <input type="radio" name="payment_type" value="3" @if($order['payment_type']=='3') checked @endif>
  232. <label for="status-0" style="margin-right: 27px;">个体户支付</label>
  233. @if($self_role != '分销销售' && $self_role != '分销管理员')
  234. <input type="radio" name="payment_type" value="4" @if($order['payment_type']=='4') checked @endif>
  235. <label for="status-0" style="margin-right: 27px;">充值卡支付</label>
  236. @endif
  237. </div>
  238. </div>
  239. @endif
  240. @if($order['payment_type'] != 4)
  241. <div class="row cl" style="display: none" id='deposit_div'>
  242. <label class="form-label col-xs-4 col-sm-2">
  243. <font color='red'> </font>充值卡号:</label>
  244. <div class="formControls col-xs-6 col-sm-6">
  245. <input id='deposit_phone_i' type="text" class="input-text" value="{{old('deposit_phone')}}" placeholder="*默认收货人手机号" disabled name="deposit_phone_i">
  246. <input id='deposit_phone' type="hidden" class="input-text" value="{{old('deposit_phone')}}" placeholder="" name="deposit_phone">
  247. <font color='red' id='vip_pay'></font>
  248. </div>
  249. </div>
  250. @else
  251. <div class="row cl" id='deposit_div'>
  252. <label class="form-label col-xs-4 col-sm-2">
  253. <font color='red'> </font>充值卡号:</label>
  254. <div class="formControls col-xs-6 col-sm-6">
  255. {{$deposit_phone}}
  256. <input type="hidden" name='deposit_phone' value="{{$deposit_phone}}" />
  257. <font color='red' id='vip_pay'></font>
  258. </div>
  259. </div>
  260. @endif
  261. <div class="row cl">
  262. <label class="form-label col-xs-4 col-sm-2">
  263. <font color='red'>* </font>是否退补单:</label>
  264. <div class="formControls col-xs-6 col-sm-6">
  265. <input type="radio" name="is_refund" value="0" @if($order['is_refund']=='0') checked @else checked @endif>
  266. <label for="status-1" style="margin-right: 27px;">否</label>
  267. <input type="radio" name="is_refund" value="1" @if($order['is_refund']=='1') checked @endif>
  268. <label for="status-0">是</label>
  269. </div>
  270. </div>
  271. <div class="row cl">
  272. <label class="form-label col-xs-4 col-sm-2">
  273. 应该退补差价:</label>
  274. <div class="formControls col-xs-6 col-sm-6">
  275. <input type="text" class="input-text" value="{{$order['refund_price']}}" placeholder="" name="refund_price">
  276. </div>
  277. </div>
  278. <div class="row cl">
  279. <label class="form-label col-xs-4 col-sm-2">
  280. <font color='red'>* </font>是否退款:</label>
  281. <div class="formControls col-xs-6 col-sm-6">
  282. <input type="radio" name="order_status" value="0" @if($order['order_status']=='0') checked @else checked @endif>
  283. <label for="status-1" style="margin-right: 27px;">否</label>
  284. <input type="radio" name="order_status" value="2" @if($order['order_status']=='2') checked @endif>
  285. <label for="status-2">是</label>
  286. </div>
  287. </div>
  288. <div class="row cl">
  289. <label class="form-label col-xs-4 col-sm-2">
  290. <font color='red'>* </font>下单时间:</label>
  291. <div class="formControls col-xs-6 col-sm-6">
  292. <input id="createTime" type="text" class="input-text" style="width:22%;text-align:center;" name="createTime" value="{{$order['createTime']}}" disabled> <font color='red'> *不可变更 </font>
  293. </div>
  294. </div>
  295. <div class="row cl">
  296. <label class="form-label col-xs-4 col-sm-2">
  297. 买家备注:</label>
  298. <div class="formControls col-xs-6 col-sm-6">
  299. <textarea class="textarea" placeholder="填写买家备注..." name="buyerMemo">{{$order['buyerMemo']}}</textarea>
  300. </div>
  301. </div>
  302. <div class="row cl">
  303. <label class="form-label col-xs-4 col-sm-2">
  304. 卖家备注:</label>
  305. <div class="formControls col-xs-6 col-sm-6">
  306. <textarea class="textarea" placeholder="填写卖家备注..." name="sellerMemo">{{$order['sellerMemo']}}</textarea>
  307. </div>
  308. </div>
  309. @if(0)
  310. @if($self_role !='销售' && $self_role != '分销销售' )
  311. <div class="row cl">
  312. <label class="form-label col-xs-4 col-sm-2">
  313. 选择销售员(不选默认当前用户):</label>
  314. <div class="formControls col-xs-6 col-sm-6">
  315. <span class="select-box">
  316. <select size="1" name="team" id='team'>
  317. <option value="0" @if($order['team_id']=='') selected @endif>选择团队</option>
  318. @foreach($teamlist as $v)
  319. <option value="{{$v['id']}}" @if($order['team_id']==$v['id']) selected @endif>{{$v['name']}}</option>
  320. @endforeach
  321. </select>
  322. <select id='admins' size="1" name="admin_id">
  323. <option value="0" @if($order['admin_id']=='') selected @endif>-- 选择销售 --</option>
  324. @foreach($adminlist as $v)
  325. <option value="{{$v['id']}}" @if($order['admin_id']==$v['id']) selected @endif>{{$v['realname']}}</option>
  326. @endforeach
  327. </select>
  328. &nbsp;&nbsp;
  329. </span>
  330. </div>
  331. </div>
  332. @endif
  333. @endif
  334. @endif
  335. <div class="row cl">
  336. <div class="col-9 col-offset-2">
  337. <button class="btn btn-primary radius" type="button" onclick="to_submit()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>&nbsp;
  338. <button class="btn btn-default" type="reset" onclick="return_index();">&nbsp;&nbsp;返回&nbsp;&nbsp;</button>&nbsp;
  339. </div>
  340. </div>
  341. </form>
  342. </div>
  343. <!--_footer 作为公共模版分离出去-->
  344. <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
  345. <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
  346. <script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
  347. <script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
  348. <!--/_footer 作为公共模版分离出去-->
  349. <!--请在下方写此页面业务相关的脚本-->
  350. <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
  351. <script type="text/javascript">
  352. $(function(){
  353. setTimeout("$('#error').hide()",3000);
  354. $('#team').change(function(){
  355. team = $('#team').val();
  356. if(team==''){
  357. return false;
  358. }
  359. $.ajax({
  360. 'url':'/admin/fxorder/teamAdmins/'+team,
  361. 'type': 'get',
  362. 'dataType':'json',
  363. 'success' : function(data){
  364. str = '<option value=\'0\'>-- 选择销售 --<\/option>';
  365. $.each(data, function(i, va){
  366. str += '<option value="'+va.id+'">' + va.realname +'<\/option>';
  367. })
  368. $('#admins').html(str);
  369. }
  370. });
  371. })
  372. $('input[type=radio][name=payment_type]').change(function () {
  373. var payment_type = $("input[type='radio'][name='payment_type']:checked").val();
  374. if(payment_type==4){
  375. var phone = "{{$order['deposit_phone']}}";
  376. $("#deposit_phone").val(phone);
  377. $("#deposit_phone_i").val(phone);
  378. //获取充值卡余额
  379. var reg = /^1\d{10}$/
  380. if(!reg.test(phone)){
  381. return false;
  382. }
  383. $.ajax({
  384. 'url':'/admin/cust/getBalance/'+phone,
  385. 'type': 'get',
  386. 'success' : function(data){
  387. var str = '【充值卡余额为:'+data+'元】';
  388. $("#vip_pay").html(str);
  389. }
  390. });
  391. $("#deposit_div").show();
  392. }else{
  393. $("#deposit_div").hide();
  394. }
  395. })
  396. });
  397. function getBalance(){
  398. var phone = $("input[name=deposit_phone]").val();
  399. var reg = /^1\d{10}$/
  400. if(!reg.test(phone)){
  401. $("#vip_pay").html('【充值卡余额为:0元】');
  402. return false;
  403. }
  404. //获取充值卡余额
  405. $.ajax({
  406. 'url':'/admin/cust/getBalance/'+phone,
  407. 'type': 'get',
  408. 'success' : function(data){
  409. var str = '【充值卡余额为:'+data+'元】';
  410. $("#vip_pay").html(str);
  411. }
  412. });
  413. }
  414. /*返回*/
  415. function return_index(){
  416. location.href='/admin/fxorder/index';
  417. }
  418. function add_goods(goods_id,sku_id,name,props_name,price,is_weigh,quantity,is_white){
  419. var gnum = $("#gnum"+sku_id).val();
  420. var weigh_unit = '数量';
  421. var weigh_note = '';
  422. var weigh_unit_name = '';
  423. if(is_weigh == 1){
  424. weigh_unit = '重量';
  425. weigh_unit_name = '(斤)';
  426. weigh_note = '<font color=\'red\'> (称重商品,至少0.5斤) <\/font>';
  427. }
  428. if(gnum){
  429. var n = gnum;
  430. n = parseFloat(n)+1
  431. $("#gnum"+sku_id).val(n);
  432. }
  433. else{
  434. var quantity_str = '库存:'+quantity;
  435. if(is_white==1){
  436. quantity_str = '虚拟库存';
  437. }
  438. var str = "<div>"+name+' 【 规格:'+props_name+' 价格:¥'+price+' '+quantity_str+" 】&nbsp; <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+" quantity="+quantity+" is_white="+is_white+" 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+" &nbsp;&nbsp;<button type='button' onclick='del_sku(this, "+sku_id+","+ price + ")'> 移除<\/button> &nbsp;&nbsp;"+weigh_note+"<\/div>";
  439. $("#goods_o").append(str);
  440. sessionStorage.setItem('goods_o_con',$("#goods_o").html());
  441. }
  442. sync_money()
  443. document.getElementById('good_sku').style.display='none'
  444. return false;
  445. }
  446. function add_num(sku_id, price){
  447. var gnum = $("#gnum"+sku_id).val();
  448. var n = gnum;
  449. n = parseFloat(n)+1
  450. $("#gnum"+sku_id).val(n);
  451. sync_money()
  452. return false;
  453. }
  454. function cut_num(sku_id, price){
  455. var gnum = $("#gnum"+sku_id).val();
  456. var n = gnum;
  457. if(n <= 1){
  458. return false;
  459. }
  460. n = parseFloat(n)-1;
  461. $("#gnum"+sku_id).val(n);
  462. sync_money()
  463. return false;
  464. }
  465. function del_sku(obj, sku_id, price){
  466. var gnum = $("#gnum"+sku_id).val();
  467. $(obj).parent().remove();
  468. sync_money();
  469. }
  470. function sync_money(){
  471. var gnums = new Array();
  472. var total = 0;
  473. $('.gnums').each(function(key, value){
  474. var gnum = $(this).val();
  475. var price = $(this).attr('price');
  476. total = total + parseFloat(price) * parseFloat(gnum);
  477. });
  478. if(total>0){
  479. $("#should_amount").val(total);
  480. $("#should_amount_show").html(total);
  481. }else{
  482. $("#should_amount").val('');
  483. $("#should_amount_show").html('');
  484. }
  485. return false;
  486. }
  487. function getGoods(){
  488. var name = $('input[name=goods_name]').val();
  489. if(!name){
  490. return false;
  491. }
  492. $.ajax({
  493. 'url': '/admin/goods/searchSkus?name='+name,
  494. 'type': 'get',
  495. 'dateType': 'json',
  496. success:function(data){
  497. if(data != '0'){
  498. data = eval("("+data+")");
  499. }
  500. }
  501. })
  502. }
  503. $('input[name=goods_name]').on('keyup focus', function(){
  504. var name = $('input[name=goods_name]').val();
  505. if(!name){
  506. return false;
  507. }
  508. $.ajax({
  509. 'url': '/admin/goods/searchSkus',
  510. 'type': 'get',
  511. 'data':{name:name},
  512. 'dateType': 'json',
  513. success:function(data){
  514. if(data != '0'){
  515. data = eval("("+data+")");
  516. var str = '';
  517. for (var i = 0, l = data.length; i < l; i++) {
  518. var item = data[i];
  519. var weigh_t = '';
  520. if(item.is_weigh==1){
  521. weigh_t = '【按半斤称重】';
  522. }
  523. if(item.is_white == 0 && item.quantity <= 0){
  524. weigh_t += '<font color="red">【库存不足】<\/font>';
  525. str += '<li>'+ item.name+'【 规格:'+item.propsName+'&nbsp;&nbsp; 价格:¥'+item.price +' 】'+weigh_t+'<\/li>'
  526. }
  527. else{
  528. str += '<li onclick=\'add_goods('+item.goods_id+','+item.sku_id+',"'+item.name+'","'+item.propsName+'",'+item.price+','+item.is_weigh+','+item.quantity+','+item.is_white+');\'>'+ item.name+'【 规格:'+item.propsName+'&nbsp;&nbsp; 价格:¥'+item.price +' 】'+weigh_t+'<\/li>'
  529. }
  530. // '<p onclick=\'add_goods('+item.goods_id+','+item.sku_id+',"'+item.name+'","'+item.propsName+'",'+item.price+');\'>'+ item.name+' '+item.propsName+' ¥'+item.price +'<\/p>';
  531. }
  532. document.getElementById('good_sku').innerHTML = str;
  533. document.getElementById('good_sku').style.display='block'
  534. // layer.open({
  535. // type: 1,
  536. // area: ['600px', '360px'],
  537. // shadeClose: true, //点击遮罩关闭
  538. // content: str
  539. // });
  540. }
  541. }
  542. })
  543. });
  544. $('body').on('click', function(){
  545. $('input[name=goods_name]').on('click',function(e){
  546. e.stopPropagation();
  547. });
  548. document.getElementById('good_sku').style.display='none'
  549. })
  550. function to_submit(){
  551. if(!form_verify()){
  552. return false;
  553. }
  554. var warehouse = $("#warehouse").val();
  555. if(warehouse == 3){
  556. var if_good = $('.gnums');
  557. if(!if_good.length){
  558. layer.msg('仓库C必须选择商品!',{icon:2,time:1000});
  559. return false;
  560. }
  561. }
  562. $(".btn").attr("disabled",true);
  563. $("#order-form").submit();
  564. return true;
  565. }
  566. function weigh_verify(){
  567. var if_no = 0;
  568. $('.gnums').each(function(key, value){
  569. var gnum = $(this).val();
  570. gnum = parseFloat(gnum);
  571. var is_weigh = $(this).attr('is_weigh');
  572. if(gnum<0.5){
  573. if_no = 1;
  574. return;
  575. }
  576. if(is_weigh == 0 && gnum%1 != 0){
  577. if_no = 2;
  578. return;
  579. }
  580. if(is_weigh == 1 && gnum%0.5 != 0){
  581. if_no = 3;
  582. return;
  583. }
  584. var quantity = $(this).attr('quantity');
  585. var is_white = $(this).attr('is_white');
  586. if(is_white==0 && gnum>quantity){
  587. if_no=4;
  588. return;
  589. }
  590. });
  591. return if_no;
  592. }
  593. function form_verify(){
  594. //验证称重>0.5
  595. var if_no = weigh_verify();
  596. if(if_no > 0){
  597. if(if_no == 1){
  598. layer.msg('商品数量填写有误!',{icon:2,time:1500});
  599. }
  600. if(if_no == 2){
  601. layer.msg('非称重商品数量必须为整数!',{icon:2,time:1500});
  602. }
  603. if(if_no == 3){
  604. layer.msg('称重商品重量必须为0.5的倍数!',{icon:2,time:1500});
  605. }
  606. if(if_no == 4){
  607. layer.msg('商品数量不得大于库存量!',{icon:2,time:1500});
  608. }
  609. return false;
  610. }
  611. //验证充值卡
  612. var old_payment_type = "{{$order['payment_type']}}";
  613. var old_receivedAmount = "{{$order['receivedAmount']}}";
  614. old_receivedAmount = parseFloat(old_receivedAmount);
  615. var is_ok = 1;
  616. var receivedAmount = $("input[name=receivedAmount]").val();
  617. var payment_type = $("input[type='radio'][name='payment_type']:checked").val();
  618. if( payment_type==4 && old_payment_type != 4 ){
  619. var phone = $("input[name=deposit_phone]").val();
  620. if(!phone){
  621. is_ok = 0;
  622. }
  623. //获取充值卡余额
  624. $.ajax({
  625. url:'/admin/cust/getBalance/'+phone,
  626. type: 'get',
  627. async:false,
  628. success : function(data){
  629. data=parseFloat(data);
  630. receivedAmount=parseFloat(receivedAmount);
  631. if(data<receivedAmount){
  632. is_ok = 0;
  633. }else{
  634. is_ok = 1;
  635. }
  636. }
  637. });
  638. if(is_ok==0){
  639. layer.msg('充值卡余额不足,请充值后再进行该操作!',{icon:2,time:1500});
  640. return false;
  641. }
  642. }
  643. if( payment_type==4 && old_payment_type==4 && old_receivedAmount != receivedAmount ){
  644. var phone = "{{$deposit_phone}}"
  645. if(old_receivedAmount < receivedAmount){
  646. //金额增加,判断余额
  647. var money = receivedAmount - old_receivedAmount;
  648. //获取充值卡余额
  649. $.ajax({
  650. url:'/admin/cust/getBalance/'+phone,
  651. type: 'get',
  652. async:false,
  653. success : function(data){
  654. data=parseFloat(data);
  655. money=parseFloat(money);
  656. if(data<money){
  657. is_ok = 0;
  658. }else{
  659. is_ok = 1;
  660. }
  661. }
  662. });
  663. }
  664. if(is_ok==0){
  665. layer.msg('充值卡余额不足,请充值后再进行该操作!',{icon:2,time:1500});
  666. return false;
  667. }
  668. }
  669. return true;
  670. }
  671. </script>
  672. </body>
  673. @endsection