index.blade.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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">
  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. },
  52. methods:{
  53. destroy(id,index,name){
  54. window.tempTip.confirm("确定要删除"+name+"吗?",()=>{
  55. window.axios.delete("{{url('maintenance/processMethod')}}/"+id)
  56. .then(res=>{
  57. if (res.data.success){
  58. this.$delete(this.methods,index);
  59. window.tempTip.setDuration(2000);
  60. window.tempTip.showSuccess("删除"+name+"成功");
  61. return;
  62. }
  63. window.tempTip.setDuration(3000);
  64. window.tempTip.show(res.data.data);
  65. }).catch(err=>{
  66. window.tempTip.setDuration(3000);
  67. window.tempTip.show("网络错误:"+err);
  68. })
  69. })
  70. }
  71. },
  72. });
  73. </script>
  74. @stop