index.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. @extends('layouts.app')
  2. @section('title')临时工@endsection
  3. @section('content')
  4. <span id="nav2">
  5. @component('maintenance.menu')@endcomponent
  6. </span>
  7. <div class="container-fluid card" id="list">
  8. <div class="card-body">
  9. @if(Session::has('successTip'))
  10. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  11. @endif
  12. <div id="form_div"></div>
  13. <div class="modal fade" id="workRecord" tabindex="-1" role="dialog" aria-hidden="true">
  14. <div class="modal-dialog">
  15. <div class="modal-content" style="width: 800px">
  16. <div class="modal-header">
  17. <button type="button" class="close pull-right" data-dismiss="modal" aria-hidden="true">&times;</button>
  18. </div>
  19. <div class="modal-body m-auto">
  20. <table class="table-sm table-bordered table-striped text-nowrap">
  21. <thead class="thead-light">
  22. <tr>
  23. <td>二次加工单号</td>
  24. <td>开始时间</td>
  25. <td>结束时间</td>
  26. <td>计件数</td>
  27. <td>计件单价</td>
  28. <td>计时数</td>
  29. <td>计时单价</td>
  30. </tr>
  31. </thead>
  32. <tbody>
  33. <tr v-for="processDailyParticipant in processDailyParticipants">
  34. <td v-if="processDailyParticipant.process_daily">@{{ processDailyParticipant.process_daily.process_code }}</td>
  35. <td>@{{ processDailyParticipant.started_at }}</td>
  36. <td>@{{ processDailyParticipant.ended_at }}</td>
  37. <td>@{{ processDailyParticipant.unit_count }}</td>
  38. <td>@{{ processDailyParticipant.unit_price }}</td>
  39. <td>@{{ processDailyParticipant.hour_count }}</td>
  40. <td>@{{ processDailyParticipant.hour_price }}</td>
  41. </tr>
  42. </tbody>
  43. </table>
  44. </div>
  45. <div class="modal-footer">
  46. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  47. </div>
  48. </div><!-- /.modal-content -->
  49. </div><!-- /.modal -->
  50. </div>
  51. <div class="modal fade" id="clockRecord" tabindex="-1" role="dialog" aria-hidden="true">
  52. <div class="modal-dialog">
  53. <div class="modal-content">
  54. <div class="modal-header">
  55. <button type="button" class="close pull-right" data-dismiss="modal" aria-hidden="true">&times;</button>
  56. </div>
  57. <div class="modal-body m-auto">
  58. <table class="table-sm table-bordered table-striped text-nowrap">
  59. <thead class="thead-light">
  60. <tr>
  61. <td>打卡时间</td>
  62. <td>打卡类型</td>
  63. <td>记录类型</td>
  64. </tr>
  65. </thead>
  66. <tbody>
  67. <tr v-for="userDutyCheck in userDutyChecks">
  68. <td>@{{ userDutyCheck.checked_at }}</td>
  69. <td>@{{ userDutyCheck.type }}</td>
  70. <td>@{{ userDutyCheck.source }}</td>
  71. </tr>
  72. </tbody>
  73. </table>
  74. </div>
  75. <div class="modal-footer">
  76. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  77. </div>
  78. </div><!-- /.modal-content -->
  79. </div><!-- /.modal -->
  80. </div>
  81. <table class="table table-striped table-sm" >
  82. <tr>
  83. <th>序号</th>
  84. <th>姓名</th>
  85. <th>电话</th>
  86. <th>详情</th>
  87. <th>操作</th>
  88. <th>解除绑定设备</th>
  89. </tr>
  90. <tr v-for="(userLabor,i) in userLabors">
  91. <td>@{{ i+1 }}</td>
  92. <td class="text-muted"><span v-if="userLabor.user_detail">@{{userLabor.user_detail.full_name}}</span></td>
  93. <td><span v-if="userLabor.user_detail">@{{userLabor.user_detail.mobile_phone}}</span></td>
  94. <td><u class="text-info" style="cursor:pointer" @click="show(userLabor.user_id)">查看详情</u></td>
  95. <td>
  96. @can('临时工-编辑')
  97. <button class="btn btn-sm btn-outline-primary" @click="edit(userLabor.user_id)">改</button>@endcan
  98. @can('临时工-删除')
  99. <button class="btn btn-sm btn-outline-danger" @click="destroy(userLabor)">删</button> @endcan
  100. <button class="btn btn-sm btn-outline-dark" @click="workRecord(userLabor.user_id)">劳务记录</button>
  101. <button class="btn btn-sm btn-outline-dark" @click="clockRecord(userLabor.user_id)">打卡记录</button>
  102. </td>
  103. <td>
  104. @can('临时工')
  105. <span v-if="userLabor.is_relieve_facility">
  106. <button class="btn btn-sm btn-outline-secondary" @click="relieve(userLabor.user_id,userLabor.user_detail.full_name)">解</button>
  107. </span>
  108. @endcan
  109. </td>
  110. </tr>
  111. </table>
  112. {{$userLabors->links()}}
  113. </div>
  114. </div>
  115. @endsection
  116. @section('lastScript')
  117. <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
  118. <script>
  119. new Vue({
  120. el:"#list",
  121. data:{
  122. userLabors:[
  123. @foreach( $userLabors as $userLabor )
  124. {{-- {!! $userLabor !!},--}}
  125. {user_id:'{{$userLabor->user_id}}',@if($userLabor->userDetail)user_detail:{!! $userLabor->userDetail !!}, @endif
  126. is_relieve_facility:'{{$userLabor->is_relieve_facility}}',
  127. },
  128. @endforeach
  129. ],
  130. processDailyParticipants:[],
  131. userDutyChecks:[],
  132. },
  133. mounted(){
  134. let data=[
  135. [
  136. {name: 'user_name', type: 'input', tip: '姓名:可在左侧增加百分号(%)进行模糊搜索', placeholder: '姓名'},
  137. ]
  138. ];
  139. this.form = new query({
  140. el: "#form_div",
  141. condition: data,
  142. });
  143. this.form.init();
  144. },
  145. methods:{
  146. show(user_id){
  147. window.open("{{url('maintenance/userLabor')}}/"+user_id);
  148. },
  149. workRecord(user_id){
  150. let _this=this;
  151. axios.post("{{url('maintenance/userLabor/getWorkRecord')}}",{user_id:user_id})
  152. .then(function (response) {
  153. if (response.data.error){
  154. tempTip.setDuration(3000);
  155. tempTip.show(response.data.error);
  156. return;
  157. }
  158. _this.processDailyParticipants=response.data;
  159. $("#workRecord").modal('show');
  160. }).catch(function (err) {
  161. tempTip.setDuration(3000);
  162. tempTip.show('获取劳务记录失败!网络错误:' + err);
  163. });
  164. },
  165. clockRecord(user_id){
  166. let _this=this;
  167. axios.post("{{url('maintenance/userLabor/getClockRecord')}}",{user_id:user_id})
  168. .then(function (response) {
  169. if (response.data.error){
  170. tempTip.setDuration(3000);
  171. tempTip.show(response.data.error);
  172. return;
  173. }
  174. _this.userDutyChecks=response.data;
  175. $("#clockRecord").modal('show');
  176. }).catch(function (err) {
  177. tempTip.setDuration(3000);
  178. tempTip.show('获取打卡记录失败!网络错误:' + err);
  179. });
  180. },
  181. edit:function(id){
  182. location.href = "{{url('maintenance/userLabor')}}/"+id+"/edit";
  183. },
  184. destroy:function(userLabor){
  185. if(!confirm('确定要删除临时工“' + userLabor.user_detail.full_name + '”吗?')){return};
  186. let _this=this;
  187. let user_id=userLabor.user_id;
  188. let url = "{{url('maintenance/userLabor')}}/"+user_id;
  189. axios.delete(url)
  190. .then(function (response) {
  191. if(response.data.success){
  192. _this.userLabors.every(function (userLabor,i) {
  193. if (userLabor.user_id==user_id){
  194. _this.userLabors.splice(i,1);
  195. return false;
  196. }
  197. return true;
  198. });
  199. tempTip.setDuration(3000);
  200. tempTip.showSuccess('删除临时工成功!');
  201. return;
  202. }
  203. tempTip.setDuration(3000);
  204. tempTip.show('删除临时工失败!');
  205. })
  206. .catch(function (err) {
  207. tempTip.setDuration(3000);
  208. tempTip.show('删除临时工失败!'+'网络错误:' + err);
  209. });
  210. },
  211. relieve(user_id,full_name){
  212. let _this=this;
  213. axios.post('{{url('maintenance/userLabor/relieve')}}',{user_id:user_id})
  214. .then((response)=>{
  215. if (response.data.error){
  216. tempTip.setDuration(3000);
  217. tempTip.show(response.data.error);
  218. return;
  219. }
  220. if (response.data.success){
  221. _this.userLabors.every(function (userLabor) {
  222. if (userLabor.user_id==response.data.userLabor.user_id){
  223. userLabor.is_relieve_facility=response.data.userLabor.is_relieve_facility;
  224. return false;
  225. }
  226. return true;
  227. });
  228. tempTip.setDuration(3000);
  229. tempTip.showSuccess('已解除“'+full_name+'”的绑定设备!');
  230. // return;
  231. }
  232. }).catch((err)=>{
  233. tempTip.setDuration(3000);
  234. tempTip.show('解绑失败!网络错误:' + err);
  235. });
  236. }
  237. }
  238. });
  239. </script>
  240. @endsection