create.blade.php 9.8 KB

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