create.blade.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. @extends('layouts.app')
  2. @section('title')手动录入-包裹管理@endsection
  3. @section('content')
  4. <span id="nav2">
  5. @component('package.menu')@endcomponent
  6. @component('package.weigh.menu')@endcomponent
  7. </span>
  8. <div class="container-fluid" id="package">
  9. <div class="card col-md-8 offset-md-2">
  10. <div class="card-body">
  11. <form method="POST" id="form" action="{{ url('package') }}">
  12. @csrf
  13. @if(Session::has('successTip'))
  14. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  15. @endif
  16. @if(Session::has('successError'))
  17. <div class="alert alert-danger h1">{{Session::get('successError')}}</div>
  18. @endif
  19. <ul class="nav nav-tabs col-8 offset-2" style="transform: scale(0.97)">
  20. <li class="nav-item" @click="windowSwitchBatch">
  21. <a class="nav-link" :class="[windowStatus.batch_input ?'active' : '']" href="#">波次号</a></li>
  22. <li class="nav-item" @click="windowSwitchLogistic">
  23. <a class="nav-link" :class="[windowStatus.logistic_input ?'active' : '']" href="#">快递单号</a></li>
  24. <li class="nav-item" @click="windowSwitchOrder">
  25. <a class="nav-link" :class="[windowStatus.order_input ?'active' : '']" href="#">订单号</a></li>
  26. </ul>
  27. <div class="" v-if="windowStatus.logistic_input">
  28. <div class="form-group row">
  29. <label for="name" class="col-2 col-form-label text-right">快递单号</label>
  30. <div class="col-8">
  31. <input id="input" type="text" class="form-control @error('logistic_number') is-invalid @enderror"
  32. name="logistic_number" autocomplete="off" value="{{ old('logistic_number')}}">
  33. @error('logistic_number')
  34. <span class="invalid-feedback" role="alert">
  35. <strong>{{ $errors->first('logistic_number') }}</strong>
  36. </span>
  37. @enderror
  38. </div>
  39. </div>
  40. </div>
  41. <div class="" v-if="windowStatus.order_input">
  42. <div class="form-group row">
  43. <label for="order_code" class="col-2 col-form-label text-right text-info">订单号</label>
  44. <div class="col-8">
  45. <input id="input" type="text" class="form-control @error('order_code') is-invalid @enderror"
  46. name="order_code" autocomplete="off" value="{{ old('order_code')}}">
  47. @error('order_code')
  48. <span class="invalid-feedback" role="alert">
  49. <strong>{{ $errors->first('order_code') }}</strong>
  50. </span>
  51. @enderror
  52. </div>
  53. </div>
  54. </div>
  55. <div class="text-danger" v-if="windowStatus.batch_input">
  56. <div class="form-group row">
  57. <label for="batch_number" class="col-2 col-form-label text-right">波次号</label>
  58. <div class="col-8">
  59. <input type="text" id="input" class="form-control @error('batch_number') is-invalid @enderror"
  60. name="batch_number" autocomplete="off" value="{{ old('batch_number')}}">
  61. @error('batch_number')
  62. <span class="invalid-feedback" role="alert">
  63. <strong>{{ $errors->first('batch_number') }}</strong>
  64. </span>
  65. @enderror
  66. </div>
  67. </div>
  68. </div>
  69. <div class="form-group row">
  70. <label for="weight" class="col-2 col-form-label text-right">重量</label>
  71. <div class="col-8">
  72. <input type="text" id="input" class="form-control @error('weight') is-invalid @enderror"
  73. name="weight" autocomplete="off" value="{{ old('weight')}}">
  74. @error('weight')
  75. <span class="invalid-feedback" role="alert">
  76. <strong>{{ $errors->first('weight') }}</strong>
  77. </span>
  78. @enderror
  79. </div>
  80. </div>
  81. <div class="form-group row" v-if="windowStatus.batch_input">
  82. <label for="weight" class="col-2 col-form-label text-right">强行当作活动波次</label>
  83. <div class="col-8">
  84. <input type="checkbox" class="form-control-sm" name="is_same_pack_batch" v-model="inputting.is_same_pack_batch">
  85. </div>
  86. </div>
  87. <div class="form-group row">
  88. <label for="paper_box_id" class="col-2 col-form-label text-right">纸箱</label>
  89. <div class="col-8 form-inline">
  90. <select name="paper_box_id" class="form-control @error('paper_box_id') is-invalid @enderror" v-model="paperBox_id" style="width: 30%;">
  91. <option v-for="paperBox in paperBoxes" :value="paperBox.id">@{{paperBox.model}}</option>
  92. </select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  93. <input class="form-control-sm" name="search" style="width: 150px" placeholder="搜索定位" @input="paperBox_seek">&nbsp;&nbsp;&nbsp;
  94. </div>
  95. </div>
  96. <div class="form-group row">
  97. <div class="col-8 offset-2">
  98. <input type="button" @click="x" class="btn btn-success form-control" value="提交"/>
  99. </div>
  100. </div>
  101. </form>
  102. </div>
  103. </div>
  104. </div>
  105. @endsection
  106. @section('lastScript')
  107. <script>
  108. let vue=new Vue({
  109. el:"#package",
  110. data:{
  111. inputting:{is_same_pack_batch:false},
  112. paperBoxes:[
  113. @foreach($paperBoxes as $paperBox)
  114. {id:'{{$paperBox->id}}',model:'{{$paperBox->model}}'},
  115. @endforeach
  116. ],
  117. paperBox_id:'',
  118. windowStatus:{logistic_input:'{{old('logistic_number')}}', batch_input:'{{old('batch_number')}}',order_input:'{{old('order_code')}}'}
  119. },
  120. mounted:function(){
  121. if (!this.windowStatus.logistic_input && !this.windowStatus.batch_input && !this.windowStatus.order_input){
  122. this.windowStatus.batch_input=true;
  123. }
  124. },
  125. methods:{
  126. paperBox_seek:function (e) {
  127. let _this=this;
  128. let $val=e.target.value;
  129. if($val==='')_this.paperBox_id='';
  130. else
  131. _this.paperBoxes.forEach(function (paperBox) {
  132. if (paperBox.model.includes($val)){
  133. _this.paperBox_id=paperBox.id;
  134. }
  135. });
  136. },
  137. windowSwitchLogistic:function (e) {
  138. this.windowStatus.logistic_input=true;
  139. this.windowStatus.batch_input=false;
  140. this.inputting.is_same_pack_batch=false;
  141. this.windowStatus.order_input=false;
  142. },
  143. windowSwitchBatch:function (e) {
  144. this.windowStatus.logistic_input=false;
  145. this.windowStatus.batch_input=true;
  146. this.inputting.is_same_pack_batch=false;
  147. this.windowStatus.order_input=false;
  148. },
  149. windowSwitchOrder:function (e) {
  150. this.windowStatus.order_input=true;
  151. this.windowStatus.logistic_input=false;
  152. this.windowStatus.batch_input=false;
  153. this.inputting.is_same_pack_batch=false;
  154. },
  155. x:function (e) {
  156. if(this.inputting.is_same_pack_batch){
  157. if(!confirm('当前波次将被强行当作活动波次处理,该操作会将波次内所有订单重量统一,请确定您的操作无误!')){
  158. return false;
  159. }
  160. }
  161. $(e.target).parents('form').submit();
  162. return true;
  163. },
  164. },
  165. });
  166. $("#form").on("keydown","input",function(){
  167. let e = event || window.event;
  168. if(e && e.keyCode==13) {
  169. let inputs = $("#form #input");
  170. let idx = inputs.index(this); // 获取当前焦点输入框所处的位置
  171. if (idx == inputs.length - 1) { // 判断是否是最后一个输入框
  172. $("#form").submit(); // 提交表单
  173. } else {
  174. inputs[idx + 1].focus(); // 设置焦点
  175. inputs[idx + 1].select(); // 选中文字
  176. }
  177. }
  178. });
  179. </script>
  180. @endsection