createReplenishClock.blade.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. @extends('layouts.app')
  2. @section('title')录入补卡@endsection
  3. @section('content')
  4. <div id="nav2">
  5. @component('process.menu')@endcomponent
  6. @component('process.checking-in.menuChecking-in')@endcomponent
  7. </div>
  8. <div class="container-fluid mt-3" id="list">
  9. <div class="card col-md-10 offset-md-1">
  10. <div class="card-body">
  11. <div class="form-group row">
  12. <input v-model="full_name" class="col-6 offset-2 form-control" type="text" placeholder="按名称搜索临时工">
  13. <button @click="checkUserLabors()" class="col-2 btn btn-info">搜索</button>
  14. </div>
  15. <table v-if="userLabors.length>0" class="col-10 offset-1 mt-3 table table-bordered table-hover text-nowrap">
  16. <thead class="thead-light">
  17. <tr>
  18. <th>名称</th>
  19. <th>电话</th>
  20. <th>劳务所</th>
  21. <th>最近打卡时间</th>
  22. <th>输入补卡时间</th>
  23. <th>类型</th>
  24. <th>操作</th>
  25. </tr>
  26. </thead>
  27. <tbody>
  28. <tr v-for="userLabor in userLabors">
  29. <td>@{{ userLabor.full_name }}</td>
  30. <td>@{{ userLabor.mobile_phone }}</td>
  31. <td>@{{ userLabor.user_labor_company }}</td>
  32. <td>
  33. <ul class="p-0 m-0 list-unstyled list-inline">
  34. <li v-for="user_duty_check in userLabor.user_duty_checks"><small>@{{ user_duty_check.checked_at }}</small></li>
  35. </ul>
  36. </td>
  37. <td >
  38. <input v-model="userLabor.userDutyCheck_date" type="date" class="form-control-sm" style="width: 150px"><br>
  39. <input v-model="userLabor.userDutyCheck_time" type="time" class="form-control-sm mt-2" style="width: 150px" ><br>
  40. <small v-if="errors.checked_at && errors.checked_at.length>0 " class="text-danger">@{{ errors.checked_at[0] }}</small>
  41. </td>
  42. <td>
  43. <select :class="{ 'is-invalid' : errors.type && errors.type.length>0 }" v-model="userLabor.userDutyCheck_type" class="form-control">
  44. <option value="">请选择</option>
  45. <option value="登入">登入</option>
  46. <option value="登出">登出</option>
  47. </select>
  48. </td>
  49. <td><button @click="storeReplenishClock(userLabor)" class="btn btn-info w-100">提交补卡</button></td>
  50. </tr>
  51. </tbody>
  52. </table>
  53. </div>
  54. </div>
  55. </div>
  56. @endsection
  57. @section('lastScript')
  58. <script>
  59. new Vue({
  60. el:"#list",
  61. data:{
  62. full_name:'',
  63. userLabors:[],
  64. errors:{'checked_at':[],'type':[],},
  65. },
  66. methods:{
  67. checkUserLabors(){
  68. let full_name=this.full_name;
  69. let _this=this;
  70. if (!full_name){
  71. tempTip.setDuration(3000);
  72. tempTip.show('请输入临时工全名进行搜索!');
  73. return;
  74. }
  75. axios.post("{{url('process/checkUserLabors')}}",{full_name:full_name})
  76. .then(function (response) {
  77. if (response.data.success){
  78. if (response.data.data.length<1){
  79. tempTip.setDuration(3000);
  80. tempTip.show('暂无此人打卡信息!');
  81. return;
  82. }
  83. response.data.data.every(function (userLabor) {
  84. userLabor['userDutyCheck_type']='';
  85. userLabor['userDutyCheck_date']='';
  86. userLabor['userDutyCheck_time']='';
  87. return true;
  88. });
  89. _this.userLabors=response.data.data;
  90. }
  91. }).catch(function (err) {
  92. tempTip.setDuration(4000);
  93. tempTip.show('搜索临时工打卡记录失败!网络错误:'+err);
  94. });
  95. },
  96. storeReplenishClock(userLabor){
  97. let checked_at=userLabor.userDutyCheck_date+" "+userLabor.userDutyCheck_time;
  98. if(!confirm('确定要提交'+userLabor.full_name+"在“"+userLabor.userDutyCheck_date+'”的补卡吗?')){return};
  99. let user_id=userLabor.user_id;
  100. let type=userLabor.userDutyCheck_type;
  101. let _this=this;
  102. axios.post("{{url('process/storeReplenishClock')}}",{user_id:user_id,checked_at:checked_at,type:type})
  103. .then(function (response) {
  104. if (response.data.success){
  105. _this.userLabors.every(function (userLabor) {
  106. if (userLabor.user_id==userLabor.user_id) {
  107. userLabor.user_duty_checks.splice((userLabor.user_duty_checks.length)-1,1);
  108. userLabor.user_duty_checks.unshift(response.data.data);
  109. return false;
  110. }
  111. return true;
  112. });
  113. tempTip.setDuration(3000);
  114. tempTip.showSuccess(userLabor.full_name+'的补卡成功!');
  115. _this.errors={'checked_at':[],'type':[],};
  116. return;
  117. }
  118. _this.errors=response.data.data;
  119. }).catch(function (err) {
  120. tempTip.setDuration(4000);
  121. tempTip.show('录入补卡失败!网络错误:'+err);
  122. });
  123. },
  124. },
  125. });
  126. </script>
  127. @endsection