clockAudit.blade.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. @extends('layouts.app')
  2. @section('title')打卡审核-人事管理@endsection
  3. @section('content')
  4. <div class="container-fluid" id="list">
  5. <div class="card col-md visible-on">
  6. <div class="card-body p-0">
  7. <div v-if="userDutyChecks&&userDutyChecks.length>=1">
  8. <table class="table table-striped table-bordered text-nowrap" v-for="day in date" >
  9. <thead class="thead-light" >
  10. <tr class="text-center">
  11. <th v-if="day==0" colspan="11">@{{ day | toDate}}</th>
  12. <th v-if="day==-1" colspan="11">@{{ day | toDate}}</th>
  13. <th v-if="day==-2" colspan="11">@{{ day | toDate}}</th>
  14. </tr>
  15. <tr>
  16. <td>序号</td>
  17. <td>姓名</td>
  18. @can('人事管理-门卫审核')<td>门卫审核</td>@endcan
  19. <td>组长审核</td>
  20. <td >打卡时间</td>
  21. <td>打卡类型</td>
  22. <td>手机号</td>、
  23. <td>劳务所</td>
  24. <td>工作组</td>
  25. <td>异常</td>
  26. <td>合计工时</td>
  27. </tr>
  28. </thead>
  29. <tbody>
  30. <tr v-for="(userDutyCheck,i) in userDutyChecks" v-if="whichDay(userDutyCheck.checked_at)==day">
  31. <td>@{{ i+1 }}</td>
  32. <td ><span v-if="userDutyCheck.user_detail">@{{ userDutyCheck.user_detail.full_name }}</span></td>
  33. @can('人事管理-门卫审核')<td>
  34. <span v-if="userDutyCheck.type=='登入'">
  35. <b v-if="userDutyCheck.verify_user_id" class="text-success">已审核</b>
  36. <button v-else @click="storeClockAudit(userDutyCheck.id,userDutyCheck.type)" class="btn btn-primary w-80">审核</button>
  37. </span>
  38. </td>@endcan
  39. <td>
  40. <span v-if="userDutyCheck.type=='登入'">
  41. <b v-if="userDutyCheck.group_user_id" class="text-success">已审核</b>
  42. @can('人事管理-组长审核')
  43. <button v-else @click="storeGroupAudit(userDutyCheck.id,userDutyCheck.type)" class="btn btn-primary w-80">组长审核</button>
  44. @endcan
  45. </span>
  46. </td>
  47. <td>@{{ userDutyCheck.checked_at.substring(11,16) }}</td>
  48. <td>
  49. @can('人事管理-审核类型')
  50. <button v-if="!userDutyCheck.isChangingType" class="btn btn-sm btn-outline-secondary text-center" @click="dutyCheckType($event,userDutyCheck)" :data_id="userDutyCheck.id">@{{ userDutyCheck.type }}</button>
  51. <select v-else v-model="userDutyCheck.type" :data_id="userDutyCheck.id"
  52. @change="isException(userDutyCheck.id,userDutyCheck.user_id,userDutyCheck.checked_at,userDutyCheck.type)" class="form-control" style="width: 100px">
  53. <option value="登入">登入</option>
  54. <option value="登出">登出</option>
  55. </select>
  56. @else
  57. <span class="text-center">@{{ userDutyCheck.type }}</span>
  58. @endcan
  59. </td>
  60. <td class="text-muted"><span v-if="userDutyCheck.user_detail">@{{ userDutyCheck.user_detail.mobile_phone }}</span></td>
  61. <td ><span v-if="userDutyCheck.userLabor">@{{ userDutyCheck.userLabor.labor_company.name }}</span></td>
  62. <td class="font-weight-bold"><span v-if="userDutyCheck.user_workgroup">
  63. @{{ userDutyCheck.user_workgroup.name }}</span></td>
  64. <td>@{{ userDutyCheck.exception }}</td>
  65. <td>@{{ userDutyCheck.duration_man_hour }}</td>
  66. </tr>
  67. </tbody>
  68. </table>
  69. </div>
  70. <div class="text-center" v-else><h3>暂无任何打卡记录!</h3></div>
  71. </div>
  72. </div>
  73. </div>
  74. @endsection
  75. @section('lastScript')
  76. <script>
  77. new Vue({
  78. el:"#list",
  79. data:{
  80. date:[0,-1,-2],
  81. dateStr:'',
  82. userDutyChecks:[
  83. @foreach($userDutyChecks as $userDutyCheck)
  84. {id:'{{$userDutyCheck->id}}',user_id:'{{$userDutyCheck->user_id}}',
  85. checked_at:'{{$userDutyCheck->checked_at}}',
  86. isChangingType:false,
  87. type:'{{$userDutyCheck->type}}',verify_user_id:'{{$userDutyCheck->verify_user_id}}',group_user_id:'{{$userDutyCheck->group_user_id}}',
  88. exception:'',duration_man_hour:'',@if($userDutyCheck->userWorkgroup)user_workgroup:{!! $userDutyCheck->userWorkgroup !!}, @endif
  89. @if($userDutyCheck->userDetail)user_detail:{!! $userDutyCheck->userDetail !!}, @endif
  90. @if($userDutyCheck->userLabor)userLabor:{!! $userDutyCheck->userLabor !!}, @endif},
  91. @endforeach
  92. ],
  93. permittingWorkgroups:{!! $permittingWorkgroups !!},
  94. },
  95. {{--mounted(){--}}
  96. {{-- initEcho();--}}
  97. {{-- this.permittingWorkgroups.forEach(function(workgroup){--}}
  98. {{-- Echo.channel('{{$laravelEchoPrefix}}'+workgroup.token).listen('ClockinEvent',(e)=>{--}}
  99. {{-- window.location.reload();--}}
  100. {{-- });--}}
  101. {{-- Echo.channel('{{$laravelEchoPrefix}}'+workgroup.token).listen('ClockoutEvent',(e)=>{--}}
  102. {{-- window.location.reload();--}}
  103. {{-- });--}}
  104. {{-- });--}}
  105. {{--},--}}
  106. methods:{
  107. // 打卡类型修改
  108. dutyCheckType:function (e,userDutyCheck) {
  109. let target = $(e.target);
  110. userDutyCheck.isChangingType=true;
  111. let select = target.next('select');
  112. select.focus();
  113. },
  114. updateDutyCheckType:function (id,type) {
  115. let _this = this;
  116. let ajaxUrl= '{{url("personnel/checking-in/updateDutyCheckType")}}';
  117. axios.post(ajaxUrl,{'id':id,'type':type}).then(function (response) {
  118. if(response.data.success){
  119. _this.userDutyChecks.every(function (userDutyCheck) {
  120. if (userDutyCheck.id==id){
  121. userDutyCheck.type=response.data.data.type;
  122. userDutyCheck.isChangingType=false;
  123. return false;
  124. }
  125. return true;
  126. });
  127. tempTip.setDuration(2000);
  128. tempTip.showSuccess('打卡类型修改成功');
  129. }else{
  130. tempTip.setDuration(3000);
  131. tempTip.show('打卡类型修改失败!'+response.data.fail_info);
  132. }
  133. }).catch(function (err) {
  134. tempTip.setDuration(3000);
  135. tempTip.show('打卡类型修改失败!网络异常:'+err);
  136. });
  137. },
  138. whichDay(dateStr){
  139. let nowDate=new Date();
  140. let targetDate=new Date(dateStr);
  141. if(nowDate.getMonth()!=targetDate.getMonth()){
  142. if (new Date(targetDate.setDate(targetDate.getDate()+1))==nowDate){
  143. return -1;
  144. }
  145. if (new Date(targetDate.setDate(targetDate.getDate()+2))==nowDate){
  146. return -2;
  147. }
  148. }
  149. let diffOfDays=targetDate.getDate()-nowDate.getDate();
  150. return diffOfDays;
  151. },
  152. store(id,type,url){
  153. },
  154. //门卫审核
  155. storeClockAudit(id,type){
  156. let url='{{url("personnel/checking-in/storeClockAudit")}}';
  157. let _this=this;
  158. axios.post(url,{id:id,type:type})
  159. .then(function (response) {
  160. if (!response.data.success){
  161. tempTip.setDuration(3000);
  162. tempTip.show(response.data.data);
  163. return;
  164. }
  165. _this.userDutyChecks.every(function (userDutyCheck) {
  166. if (userDutyCheck.id==id){
  167. userDutyCheck.verify_user_id=response.data.data;
  168. tempTip.setDuration(3000);
  169. tempTip.showSuccess('审核通过!');
  170. return false
  171. }
  172. return true;
  173. });
  174. }).catch(function (err) {
  175. tempTip.setDuration(4000);
  176. tempTip.show('审核失败!网络错误:'+err);
  177. });
  178. },
  179. //组长打卡审核
  180. storeGroupAudit(id,type){
  181. let url='{{url("personnel/checking-in/storeGroupAudit")}}';
  182. let _this=this;
  183. axios.post(url,{id:id,type:type})
  184. .then(function (response) {
  185. if (!response.data.success){
  186. tempTip.setDuration(3000);
  187. tempTip.show(response.data.data);
  188. return;
  189. }
  190. _this.userDutyChecks.every(function (userDutyCheck) {
  191. if (userDutyCheck.id==id){
  192. userDutyCheck.group_user_id=response.data.data;
  193. tempTip.setDuration(3000);
  194. tempTip.showSuccess('审核通过!');
  195. return false
  196. }
  197. return true;
  198. });
  199. }).catch(function (err) {
  200. tempTip.setDuration(4000);
  201. tempTip.show('审核失败!网络错误:'+err);
  202. });
  203. },
  204. isException(id,user_id,checked_at,type){
  205. let _this=this;
  206. _this.updateDutyCheckType(id,type);
  207. axios.post('{{url("personnel/checking-in/isException")}}',{id:id,user_id:user_id,checked_at:checked_at,type:type})
  208. .then(function (response) {
  209. _this.userDutyChecks.every(function (userDutyCheck) {
  210. if (userDutyCheck.id==id){
  211. userDutyCheck.exception=response.data.exception;
  212. userDutyCheck.duration_man_hour=response.data.duration_man_hour;
  213. return false
  214. }
  215. return true;
  216. });
  217. }).catch(function (err) {
  218. tempTip.setDuration(4000);
  219. tempTip.show('校验失败!网络错误:'+err);
  220. });
  221. }
  222. },
  223. filters:{
  224. toDate:function(val){
  225. let dd = new Date();
  226. dd.setDate(dd.getDate()+val);//获取AddDayCount天后的日期
  227. let y = dd.getFullYear();
  228. let m = dd.getMonth()+1;//获取当前月份的日期
  229. let d = dd.getDate();
  230. return y+'-'+(m<10?'0'+m:m)+'-'+d;
  231. }
  232. }
  233. });
  234. </script>
  235. @endsection