index.blade.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. @extends('layouts.app')
  2. @section('title')查询-临时工@endsection
  3. @section('content')
  4. <div class="container-fluid card" id="list">
  5. <div class="card-body">
  6. @if(Session::has('successTip'))
  7. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  8. @endif
  9. <div id="form_div"></div>
  10. <div class="modal fade" id="workRecord" tabindex="-1" role="dialog" aria-hidden="true">
  11. <div class="modal-dialog">
  12. <div class="modal-content" style="width: 800px">
  13. <div class="modal-header">
  14. <button type="button" class="close pull-right" data-dismiss="modal" aria-hidden="true">&times;</button>
  15. </div>
  16. <div class="modal-body m-auto">
  17. <table class="table-sm table-bordered table-striped text-nowrap">
  18. <thead class="thead-light">
  19. <tr>
  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="(processDailyParticipant,i) in processDailyParticipants" >
  31. <td v-if="processDailyParticipant.process_daily">@{{ processDailyParticipant.process_daily.process_code }}</td>
  32. <td>@{{ processDailyParticipant.started_at }}</td>
  33. <td>@{{ processDailyParticipant.ended_at }}</td>
  34. <td>@{{ processDailyParticipant.unit_count }}</td>
  35. <td>@{{ processDailyParticipant.unit_price }}</td>
  36. <td>@{{ processDailyParticipant.hour_count }}</td>
  37. <td>@{{ processDailyParticipant.hour_price }}</td>
  38. </tr>
  39. </tbody>
  40. </table>
  41. </div>
  42. <div class="modal-footer">
  43. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  44. </div>
  45. </div><!-- /.modal-content -->
  46. </div><!-- /.modal -->
  47. </div>
  48. <div class="modal fade" id="clockRecord" tabindex="-1" role="dialog" aria-hidden="true">
  49. <div class="modal-dialog">
  50. <div class="modal-content">
  51. <div class="modal-header">
  52. <button type="button" class="close pull-right" data-dismiss="modal" aria-hidden="true">&times;</button>
  53. </div>
  54. <div class="modal-body m-auto">
  55. <table class="table-sm table-bordered table-striped text-nowrap">
  56. <thead class="thead-light">
  57. <tr>
  58. <td>打卡时间</td>
  59. <td>打卡类型</td>
  60. <td>记录类型</td>
  61. </tr>
  62. </thead>
  63. <tbody>
  64. <tr v-for="userDutyCheck in userDutyChecks">
  65. <td>@{{ userDutyCheck.checked_at }}</td>
  66. <td>@{{ userDutyCheck.type }}</td>
  67. <td>@{{ userDutyCheck.source }}</td>
  68. </tr>
  69. </tbody>
  70. </table>
  71. </div>
  72. <div class="modal-footer">
  73. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  74. </div>
  75. </div><!-- /.modal-content -->
  76. </div><!-- /.modal -->
  77. </div>
  78. <table class="table table-striped table-sm" >
  79. <tr>
  80. <th>序号</th>
  81. <th>姓名</th>
  82. <th>电话</th>
  83. <th>详情</th>
  84. <th>操作</th>
  85. <th>解除绑定设备</th>
  86. </tr>
  87. <tr v-for="(userLabor,i) in userLabors" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  88. <td>@{{ i+1 }}</td>
  89. <td class="text-muted"><span v-if="userLabor.user_detail">@{{userLabor.user_detail.full_name}}</span></td>
  90. <td><span v-if="userLabor.user_detail">@{{userLabor.user_detail.mobile_phone}}</span></td>
  91. <td><u class="text-info" style="cursor:pointer" @click="show(userLabor.user_id)">查看详情</u></td>
  92. <td>
  93. @can('临时工-编辑')
  94. <button class="btn btn-sm btn-outline-primary" @click="edit(userLabor.user_id)">改</button>
  95. <button class="btn btn-sm btn-outline-success" @click="conversion(userLabor)">转正</button>
  96. @endcan
  97. @can('临时工-删除')
  98. <button class="btn btn-sm btn-outline-danger" @click="destroy(userLabor)">删</button> @endcan
  99. <button class="btn btn-sm btn-outline-dark" @click="workRecord(userLabor.user_id)">劳务记录</button>
  100. <button class="btn btn-sm btn-outline-dark" @click="clockRecord(userLabor.user_id)">打卡记录</button>
  101. </td>
  102. <td>
  103. @can('临时工')
  104. <span v-if="userLabor.is_relieve_facility">
  105. <button class="btn btn-sm btn-outline-secondary" @click="relieve(userLabor.user_id,userLabor.user_detail.full_name)">解</button>
  106. </span>
  107. @endcan
  108. </td>
  109. </tr>
  110. </table>
  111. {{$userLabors->links()}}
  112. </div>
  113. </div>
  114. @endsection
  115. @section('lastScript')
  116. <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
  117. <script>
  118. new Vue({
  119. el:"#list",
  120. data:{
  121. userLabors:[
  122. @foreach( $userLabors as $userLabor )
  123. {{-- {!! $userLabor !!},--}}
  124. {user_id:'{{$userLabor->user_id}}',@if($userLabor->userDetail)user_detail:{!! $userLabor->userDetail !!}, @endif
  125. is_relieve_facility:'{{$userLabor->is_relieve_facility}}',
  126. },
  127. @endforeach
  128. ],
  129. processDailyParticipants:[],
  130. userDutyChecks:[],
  131. selectTr:0
  132. },
  133. mounted(){
  134. let data=[
  135. [
  136. {name: '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. conversion:function(userLabor){
  212. if(!confirm('确定要将临时工“' + userLabor.user_detail.full_name + '”转正吗?')){return};
  213. let _this=this;
  214. let user_id=userLabor.user_id;
  215. let url = "{{url('maintenance/userLabor/conversion')}}";
  216. axios.post(url,{user_id:user_id}).then(function (response) {
  217. if(response.data.success){
  218. _this.userLabors.every(function (userLabor,i) {
  219. if (userLabor.user_id==user_id){
  220. _this.userLabors.splice(i,1);
  221. return false;
  222. }
  223. return true;
  224. });
  225. tempTip.setDuration(3000);
  226. tempTip.showSuccess('转正临时工成功!');
  227. return;
  228. }
  229. tempTip.setDuration(3000);
  230. tempTip.show('转正临时工失败!');
  231. })
  232. .catch(function (err) {
  233. tempTip.setDuration(3000);
  234. tempTip.show('转正临时工失败!'+'网络错误:' + err);
  235. });
  236. },
  237. relieve(user_id,full_name){
  238. let _this=this;
  239. axios.post('{{url('maintenance/userLabor/relieve')}}',{user_id:user_id})
  240. .then((response)=>{
  241. if (response.data.error){
  242. tempTip.setDuration(3000);
  243. tempTip.show(response.data.error);
  244. return;
  245. }
  246. if (response.data.success){
  247. _this.userLabors.every(function (userLabor) {
  248. if (userLabor.user_id==response.data.userLabor.user_id){
  249. userLabor.is_relieve_facility=response.data.userLabor.is_relieve_facility;
  250. return false;
  251. }
  252. return true;
  253. });
  254. tempTip.setDuration(3000);
  255. tempTip.showSuccess('已解除“'+full_name+'”的绑定设备!');
  256. // return;
  257. }
  258. }).catch((err)=>{
  259. tempTip.setDuration(3000);
  260. tempTip.show('解绑失败!网络错误:' + err);
  261. });
  262. }
  263. }
  264. });
  265. </script>
  266. @endsection