index.blade.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. <span v-if="userLabor.user_detail && userLabor.user_detail.black_status==0">
  97. <button class="btn btn-sm btn-outline-secondary" @click="black(userLabor.user_id)">拉黑</button>
  98. </span>
  99. <span v-if="userLabor.user_detail && userLabor.user_detail.black_status==1">
  100. <button class="btn btn-sm btn-outline-secondary" @click="cancelBlack(userLabor.user_id)">取消拉黑</button>
  101. </span>
  102. @endcan
  103. @can('临时工-删除')
  104. <button class="btn btn-sm btn-outline-danger" @click="destroy(userLabor)">删</button> @endcan
  105. <button class="btn btn-sm btn-outline-dark" @click="workRecord(userLabor.user_id)">劳务记录</button>
  106. <button class="btn btn-sm btn-outline-dark" @click="clockRecord(userLabor.user_id)">打卡记录</button>
  107. </td>
  108. <td>
  109. @can('临时工')
  110. <span v-if="userLabor.is_relieve_facility">
  111. <button class="btn btn-sm btn-outline-secondary" @click="relieve(userLabor.user_id,userLabor.user_detail.full_name)">解</button>
  112. </span>
  113. @endcan
  114. </td>
  115. </tr>
  116. </table>
  117. {{$userLabors->links()}}
  118. </div>
  119. </div>
  120. @endsection
  121. @section('lastScript')
  122. <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
  123. <script>
  124. new Vue({
  125. el:"#list",
  126. data:{
  127. userLabors:[
  128. @foreach( $userLabors as $userLabor )
  129. {{-- {!! $userLabor !!},--}}
  130. {user_id:'{{$userLabor->user_id}}',@if($userLabor->userDetail)user_detail:{!! $userLabor->userDetail !!}, @endif
  131. is_relieve_facility:'{{$userLabor->is_relieve_facility}}',
  132. },
  133. @endforeach
  134. ],
  135. processDailyParticipants:[],
  136. userDutyChecks:[],
  137. selectTr:0
  138. },
  139. mounted(){
  140. let data=[
  141. [
  142. {name: 'name', type: 'input', tip: '可支持多姓名查找,模糊搜索可在左侧增加百分号(%)进行', placeholder: '姓名'},
  143. ]
  144. ];
  145. this.form = new query({
  146. el: "#form_div",
  147. condition: data,
  148. });
  149. this.form.init();
  150. },
  151. methods:{
  152. show(user_id){
  153. window.open("{{url('maintenance/userLabor')}}/"+user_id);
  154. },
  155. black(user_id){
  156. let _this=this;
  157. axios.post("{{url('maintenance/userLabor/black')}}",{user_id:user_id})
  158. .then(function (response) {
  159. if (response.data.error){
  160. tempTip.setDuration(3000);
  161. tempTip.show(response.data.error);
  162. return;
  163. }else {
  164. _this.userLabors.forEach(function (userLabor){
  165. if (userLabor.user_id==response.data.data.user_id){
  166. userLabor.user_detail=response.data.data.user_detail;
  167. _this.$forceUpdate();
  168. }
  169. })
  170. tempTip.setDuration(3000);
  171. tempTip.showSuccess('拉黑临时工成功!');
  172. }
  173. }).catch(function (err) {
  174. tempTip.setDuration(3000);
  175. tempTip.show('拉黑临时工失败!网络错误:' + err);
  176. });
  177. },
  178. cancelBlack(user_id){
  179. let _this=this;
  180. axios.post("{{url('maintenance/userLabor/cancelBlack')}}",{user_id:user_id})
  181. .then(function (response) {
  182. if (response.data.error){
  183. tempTip.setDuration(3000);
  184. tempTip.show(response.data.error);
  185. return;
  186. }else {
  187. _this.userLabors.forEach(function (userLabor){
  188. if (userLabor.user_id==response.data.data.user_id){
  189. userLabor.user_detail=response.data.data.user_detail;
  190. _this.$forceUpdate();
  191. }
  192. })
  193. tempTip.setDuration(3000);
  194. tempTip.showSuccess('取消拉黑临时工成功!');
  195. }
  196. }).catch(function (err) {
  197. tempTip.setDuration(3000);
  198. tempTip.show('取消拉黑临时工失败!网络错误:' + err);
  199. });
  200. },
  201. workRecord(user_id){
  202. let _this=this;
  203. axios.post("{{url('maintenance/userLabor/getWorkRecord')}}",{user_id:user_id})
  204. .then(function (response) {
  205. if (response.data.error){
  206. tempTip.setDuration(3000);
  207. tempTip.show(response.data.error);
  208. return;
  209. }
  210. _this.processDailyParticipants=response.data;
  211. $("#workRecord").modal('show');
  212. }).catch(function (err) {
  213. tempTip.setDuration(3000);
  214. tempTip.show('获取劳务记录失败!网络错误:' + err);
  215. });
  216. },
  217. clockRecord(user_id){
  218. let _this=this;
  219. axios.post("{{url('maintenance/userLabor/getClockRecord')}}",{user_id:user_id})
  220. .then(function (response) {
  221. if (response.data.error){
  222. tempTip.setDuration(3000);
  223. tempTip.show(response.data.error);
  224. return;
  225. }
  226. _this.userDutyChecks=response.data;
  227. $("#clockRecord").modal('show');
  228. }).catch(function (err) {
  229. tempTip.setDuration(3000);
  230. tempTip.show('获取打卡记录失败!网络错误:' + err);
  231. });
  232. },
  233. edit:function(id){
  234. location.href = "{{url('maintenance/userLabor')}}/"+id+"/edit";
  235. },
  236. destroy:function(userLabor){
  237. if(!confirm('确定要删除临时工“' + userLabor.user_detail.full_name + '”吗?')){return};
  238. let _this=this;
  239. let user_id=userLabor.user_id;
  240. let url = "{{url('maintenance/userLabor')}}/"+user_id;
  241. axios.delete(url)
  242. .then(function (response) {
  243. if(response.data.success){
  244. _this.userLabors.every(function (userLabor,i) {
  245. if (userLabor.user_id==user_id){
  246. _this.userLabors.splice(i,1);
  247. return false;
  248. }
  249. return true;
  250. });
  251. tempTip.setDuration(3000);
  252. tempTip.showSuccess('删除临时工成功!');
  253. return;
  254. }
  255. tempTip.setDuration(3000);
  256. tempTip.show('删除临时工失败!');
  257. })
  258. .catch(function (err) {
  259. tempTip.setDuration(3000);
  260. tempTip.show('删除临时工失败!'+'网络错误:' + err);
  261. });
  262. },
  263. conversion:function(userLabor){
  264. if(!confirm('确定要将临时工“' + userLabor.user_detail.full_name + '”转正吗?')){return};
  265. let _this=this;
  266. let user_id=userLabor.user_id;
  267. let url = "{{url('maintenance/userLabor/conversion')}}";
  268. axios.post(url,{user_id:user_id}).then(function (response) {
  269. if(response.data.success){
  270. _this.userLabors.every(function (userLabor,i) {
  271. if (userLabor.user_id==user_id){
  272. _this.userLabors.splice(i,1);
  273. return false;
  274. }
  275. return true;
  276. });
  277. tempTip.setDuration(3000);
  278. tempTip.showSuccess('转正临时工成功!');
  279. return;
  280. }
  281. tempTip.setDuration(3000);
  282. tempTip.show('转正临时工失败!');
  283. })
  284. .catch(function (err) {
  285. tempTip.setDuration(3000);
  286. tempTip.show('转正临时工失败!'+'网络错误:' + err);
  287. });
  288. },
  289. relieve(user_id,full_name){
  290. let _this=this;
  291. axios.post('{{url('maintenance/userLabor/relieve')}}',{user_id:user_id})
  292. .then((response)=>{
  293. if (response.data.error){
  294. tempTip.setDuration(3000);
  295. tempTip.show(response.data.error);
  296. return;
  297. }
  298. if (response.data.success){
  299. _this.userLabors.every(function (userLabor) {
  300. if (userLabor.user_id==response.data.userLabor.user_id){
  301. userLabor.is_relieve_facility=response.data.userLabor.is_relieve_facility;
  302. return false;
  303. }
  304. return true;
  305. });
  306. tempTip.setDuration(3000);
  307. tempTip.showSuccess('已解除“'+full_name+'”的绑定设备!');
  308. // return;
  309. }
  310. }).catch((err)=>{
  311. tempTip.setDuration(3000);
  312. tempTip.show('解绑失败!网络错误:' + err);
  313. });
  314. }
  315. }
  316. });
  317. </script>
  318. @endsection