index.blade.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. @extends('layouts.app')
  2. @section('title')查询-作业类型@endsection
  3. @section('content')
  4. <div id="nav2">
  5. @component('maintenance.menu')@endcomponent
  6. @component('maintenance.processMethod.menu')@endcomponent
  7. </div>
  8. <div class="container-fluid card" id="container">
  9. @if(Session::has('successTip'))
  10. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  11. @endif
  12. <table class="table table-hover table-striped text-nowrap card-body mt-2">
  13. <tr>
  14. <th>序号</th>
  15. <th>类型</th>
  16. <th>单价</th>
  17. <th>单位</th>
  18. <th>创建时间</th>
  19. <th>操作</th>
  20. </tr>
  21. <tr v-for="(method,i) in methods" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  22. <td>@{{ i+1 }}</td>
  23. <td>@{{ method.name }}</td>
  24. <td>@{{ method.unit_price }}</td>
  25. <td>@{{ method.unit_name }}</td>
  26. <td>@{{ method.created_at }}</td>
  27. <td>
  28. @can("作业类型-编辑")<a :href="'{{url('maintenance/processMethod')}}/'+method.id+'/edit'"><button class="btn btn-sm btn-outline-info">改</button></a>@endcan
  29. @can("作业类型-删除")<button class="btn btn-sm btn-outline-danger" @click="destroy(method.id,i,method.name)">删</button>@endcan
  30. </td>
  31. </tr>
  32. </table>
  33. </div>
  34. @stop
  35. @section("lastScript")
  36. <script>
  37. new Vue({
  38. el:"#container",
  39. data:{
  40. methods : [
  41. @foreach($methods as $method)
  42. {
  43. id:"{{$method->id}}",
  44. name:"{{$method->name}}",
  45. unit_price:"{{$method->unit_price}}",
  46. unit_name:"{{$method->unit ? $method->unit->name : ''}}",
  47. created_at:"{{$method->created_at}}",
  48. },
  49. @endforeach
  50. ],
  51. selectTr:0
  52. },
  53. methods:{
  54. destroy(id,index,name){
  55. window.tempTip.confirm("确定要删除"+name+"吗?",()=>{
  56. window.axios.delete("{{url('maintenance/processMethod')}}/"+id)
  57. .then(res=>{
  58. if (res.data.success){
  59. this.$delete(this.methods,index);
  60. window.tempTip.setDuration(2000);
  61. window.tempTip.showSuccess("删除"+name+"成功");
  62. return;
  63. }
  64. window.tempTip.setDuration(3000);
  65. window.tempTip.show(res.data.data);
  66. }).catch(err=>{
  67. window.tempTip.setDuration(3000);
  68. window.tempTip.show("网络错误:"+err);
  69. })
  70. })
  71. }
  72. },
  73. });
  74. </script>
  75. @stop