index.blade.php 3.0 KB

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