create.blade.php 9.8 KB

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