createReplenishClock.blade.php 6.7 KB

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