index.blade.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. @extends('layouts.app')
  2. @section('title')指定分配-订单管理@endsection
  3. @section('content')
  4. <div class="container-fluid d-none" id="container">
  5. @include("order.index._importModal")
  6. <div class="card">
  7. <div class="card-body">
  8. <button class="btn btn-outline-info mb-1" data-toggle="modal" data-target="#importModal">导入</button>
  9. <table class="table table-striped table-hover td-min-width-80" id="table">
  10. <tr v-for="(model,i) in models" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  11. <td><span>@{{ i+1 }}</span></td>
  12. <td><span>@{{ model.orderNumber }}</span></td>
  13. <td><span>@{{ model.barcode }}</span></td>
  14. <td><span>@{{ model.amount }}</span></td>
  15. <td><span>@{{ model.producedAt }}</span></td>
  16. <td><span>@{{ model.validAt }}</span></td>
  17. <td><span>@{{ model.batchNumber }}</span></td>
  18. <td><span>@{{ model.location }}</span></td>
  19. <td><span>@{{ model.region }}</span></td>
  20. <td><span>@{{ model.createdAt }}</span></td>
  21. <td><span>@{{ model.userName }}</span></td>
  22. </tr>
  23. </table>
  24. </div>
  25. </div>
  26. {{$assigns->links()}}
  27. </div>
  28. @endsection
  29. @section('lastScript')
  30. <script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>{{--新版2--}}
  31. <script>
  32. new Vue({
  33. el:"#container",
  34. data:{
  35. models:[
  36. @foreach($assigns as $assign)
  37. {
  38. orderNumber:"{{$assign->order ? $assign->order->code : ''}}",
  39. barcode:"{{$assign->commodity ? $assign->commodity->barcode : ''}}",
  40. amount:"{{$assign->amount}}",
  41. producedAt:"{{$assign->produced_at}}",
  42. validAt:"{{$assign->valid_at}}",
  43. batchNumber:"{{$assign->batch_number}}",
  44. location:"{{$assign->location}}",
  45. region:"{{$assign->region}}",
  46. createdAt:"{{$assign->created_at}}",
  47. userName:"{{$assign->user ? $assign->user->name : 'system'}}",
  48. },
  49. @endforeach
  50. ],
  51. isShowError : false,
  52. errors:[],
  53. selectTr:''
  54. },
  55. mounted(){
  56. $("#container").removeClass("d-none");
  57. let column = [
  58. {name:'orderNumber',value: '订单编号'},
  59. {name:'barcode',value: '商品条码'},
  60. {name:'amount',value: '数量', neglect: true},
  61. {name:'producedAt',value: '生产日期'},
  62. {name:'validAt',value: '失效日期'},
  63. {name:'batchNumber',value: '批次号'},
  64. {name:'location',value: '库位'},
  65. {name:'region',value: '库区'},
  66. {name:'createdAt',value: '导入日期'},
  67. {name:'userName',value: '操作人'},
  68. ];
  69. new Header({
  70. el: "table",
  71. name: "orderIndex",
  72. column: column,
  73. data: this.models,
  74. }).init();
  75. },
  76. methods:{
  77. selectFile(){
  78. $("#file").click();
  79. },
  80. importAssign(e){
  81. let file=e.target.files[0];
  82. if (!file){
  83. window.tempTip.setDuration(3000);
  84. window.tempTip.setIndex(1099);
  85. window.tempTip.show("未选择文件");
  86. return;
  87. }
  88. let formData = new FormData();
  89. formData.append("file",file);
  90. window.tempTip.setIndex(1099);
  91. window.tempTip.setDuration(9999);
  92. window.tempTip.waitingTip("执行中,请耐心等候......");
  93. window.axios.post('{{url('order/index/commodityAssign/import')}}',formData,{
  94. 'Content-Type':'multipart/form-data'
  95. })
  96. .then(res=>{
  97. if (res.data.success) {
  98. this.errors = res.data.errors;
  99. this.isShowError = true;
  100. window.tempTip.cancelWaitingTip();
  101. window.tempTip.setDuration(2000);
  102. if (res.data.data.length>0) {
  103. this.models.unshift.apply(this.models,res.data.data);
  104. if (this.models.length>50) {
  105. this.models = this.models.slice(50);
  106. }
  107. window.tempTip.showSuccess("导入成功!");
  108. }else {
  109. window.tempTip.setDuration(3000);
  110. window.tempTip.show("导入失败!");
  111. }
  112. return;
  113. }
  114. window.tempTip.cancelWaitingTip();
  115. window.tempTip.setDuration(3000);
  116. window.tempTip.show(res.data.data);
  117. }).catch(err=> {
  118. window.tempTip.cancelWaitingTip();
  119. window.tempTip.setDuration(3000);
  120. window.tempTip.show("网络错误:"+err);
  121. })
  122. }
  123. },
  124. });
  125. </script>
  126. @endsection