index.blade.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. @extends('layouts.app')
  2. @section('title','卸货任务')
  3. @section('content')
  4. <div id="list" class="d-none container-fluid">
  5. <div id="form_div" style="min-width: 2250px"></div>
  6. <div class="form-inline mt-1" id="btn">
  7. <span class="dropdown">
  8. <button type="button" class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget"
  9. :class="[checkData.length>0?'btn-dark text-light':'']"
  10. data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">导出Excel
  11. </button>
  12. <div class="dropdown-menu">
  13. <a class="dropdown-item" @click="dischargeTaskExport(false)" href="javascript:">导出勾选内容</a>
  14. <a class="dropdown-item" @click="dischargeTaskExport(true)" href="javascript:">导出所有页</a>
  15. </div>
  16. </span>
  17. <span class="ml-1">
  18. @can('人事管理-卸货-创建')
  19. <button type="button" class="btn btn-outline-dark btn-sm form-control-sm tooltipTarget" @click="showCreateTaskModal(true)" style="background: #dad7e8;">创建任务</button>
  20. @endcan
  21. </span>
  22. @can('人事管理-卸货-创建')
  23. <span class="ml-1">
  24. <button type="button" class="btn btn-outline-primary btn-sm form-control-sm tooltipTarget"
  25. @click="importModal"
  26. >批量导入</button>
  27. </span>
  28. @endcan
  29. </div>
  30. @include('personnel.discharge.task._import')
  31. @include('personnel.discharge.task._table')
  32. @can('人事管理-卸货-创建')
  33. @include('personnel.discharge.task._createTask')
  34. @endcan
  35. @can('人事管理-卸货-编辑')
  36. @include('personnel.discharge.task._executeTask')
  37. @endcan
  38. </div>
  39. @endsection
  40. @section('lastScript')
  41. <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
  42. <script type="text/javascript" src="{{mix('js/queryForm/export.js')}}"></script>
  43. <script>
  44. let dischargeTaskVue = new Vue({
  45. el: "#list",
  46. data: {
  47. dischargeTasks: {!! $dischargeTasks->toJson()!!}['data'],
  48. isPersonnel:{!! $personnel !!},
  49. owners:{!! $owners !!},
  50. ownerFilter: [],
  51. facilitators:{!! $facilitators !!},
  52. warehouses:{!! $warehouses !!},
  53. facilitatorsFilter: [],
  54. addTask: {income_at:null},
  55. executingTack: {},
  56. taskError:{},
  57. uploadErrors:[],
  58. taskTypes: [
  59. {name: 0, value: "装车"},
  60. {name: 1, value: "卸车"},
  61. {name: 2, value: "翻托"},
  62. {name: 3, value: "包膜"},
  63. ],
  64. units: [
  65. {name: 0, value: 'm3'},
  66. {name: 1, value: '吨'},
  67. {name: 2, value: '托'},
  68. {name: 3, value: '件'},
  69. ],
  70. status: [
  71. {name: 0, value: '创建'},
  72. {name: 1, value: '接单'},
  73. // {name: 2, value: '作业中'},
  74. {name: 3, value: '完成'},
  75. ],
  76. isUpdate: false,
  77. checkData: [],
  78. selectIndex: '',
  79. selectTr:0,
  80. },
  81. created() {
  82. this.owners.forEach(function (owner, index, array) {
  83. array[index] = {
  84. name: owner.id,
  85. value: owner.name,
  86. };
  87. });
  88. this.ownerFilter = JSON.parse(JSON.stringify(this.owners));
  89. this.facilitatorsFilter = JSON.parse(JSON.stringify(this.facilitators));
  90. this.dischargeTasks.forEach(function(task,index,self){
  91. self[index]['btnText'] = '查';
  92. });
  93. },
  94. mounted() {
  95. $('#list').removeClass('d-none');
  96. $(".tooltipTarget").tooltip({'trigger': 'hover'});
  97. let _this = this;
  98. let data = [[
  99. {
  100. name: 'owner_id', type: 'select_multiple_select', tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的客户'],
  101. placeholder: ['货主', '定位或多选货主'],
  102. data: _this.owners
  103. },
  104. {name: 'created_at_start', type: 'dateTime', tip: '创建开始日期'},
  105. {name: 'created_at_end', type: 'dateTime', tip: '创建结束日期'},
  106. {name: 'numbers', type: 'input', tip: '可支持多入库单号,模糊搜索可在两侧增加百分号(%)进行',placeholder:'入库单号'},
  107. {name: 'status', type: 'select', tip: '状态' , data: _this.status,placeholder:'状态'},
  108. {name: 'income_remark', type: 'input', tip: '备注' , data: _this.status,placeholder:'备注'}
  109. ]];
  110. this.form = new query({
  111. el: '#form_div',
  112. condition: data,
  113. appendDom : "btn",
  114. paginations:[ 50, 100, 200, 500,1000,20],
  115. })
  116. this.form.init();
  117. this.$forceUpdate();
  118. },
  119. watch: {
  120. checkData: {
  121. handler() {
  122. if (this.checkData.length === this.dischargeTasks.length) {
  123. document.querySelector('#selectAll').checked = true;
  124. } else {
  125. document.querySelector('#selectAll').checked = false;
  126. }
  127. },
  128. deep: true
  129. },
  130. },
  131. methods: {
  132. getUnit(type) {
  133. let unit = ''
  134. this.units.forEach(function (item) {
  135. if (item.name === type) unit = item.value;
  136. });
  137. return unit;
  138. },
  139. getType(value) {
  140. let type = ''
  141. this.taskTypes.forEach(function (item) {
  142. if (item.name === value) type = item.value;
  143. });
  144. return type;
  145. },
  146. getStatus(value) {
  147. let status = '';
  148. this.status.forEach(function (item) {
  149. if (item.name === value) status = item.value;
  150. })
  151. return status;
  152. },
  153. checkAll(e) {
  154. if (!e.target.checked) this.checkData = [];
  155. else {
  156. this.dischargeTasks.forEach((el, i) => {
  157. if (this.checkData.indexOf(el['id']) === -1) this.checkData.push(el['id']);
  158. });
  159. }
  160. },
  161. // 创建任务 modals
  162. showCreateTaskModal(isDisplay) {
  163. $('owner-name-filter').val('');
  164. if (isDisplay){
  165. if(!this.isUpdate)this.addTask.income_at = moment().format('YYYY-MM-DDTHH:mm');
  166. this.$forceUpdate();
  167. $("#createdModal").modal('show');
  168. } else {
  169. this.isUpdate = false;
  170. $("#createdModal").modal('hide');
  171. }
  172. },
  173. // 执行任务 modal
  174. showExecutingTaskModal(index, isDisplay, task) {
  175. $('owner-name-filter').val('');
  176. this.executingTack = JSON.parse(JSON.stringify(task));
  177. this.selectIndex = index;
  178. if (isDisplay) {
  179. this.executingTack.expenditure_at = moment().format('YYYY-MM-DDTHH:mm');
  180. this.isUpdate = true;
  181. this.$forceUpdate();
  182. $("#executingTaskModal").modal('show');
  183. } else {
  184. this.isUpdate = false;
  185. this.selectIndex = null;
  186. $("#executingTaskModal").modal('hide');
  187. }
  188. },
  189. // 编辑任务 modal
  190. showUpdateTaskModal(index, isDisplay, task) {
  191. this.isUpdate = true;
  192. this.selectIndex = Number(index);
  193. this.addTask = JSON.parse(JSON.stringify(task));
  194. this.showCreateTaskModal(isDisplay)
  195. },
  196. // 创建任务
  197. createTask(index) {
  198. console.log(this.addTask);
  199. if (this.isUpdate) {
  200. this.updateCurrentTask(index);
  201. return
  202. }
  203. this.addTask['income_total_cost'] = Number(this.addTask['income_unit_price']) * Number(this.addTask.income_amount);
  204. this.addTask['status'] = 0;
  205. let url = '{{url('apiLocal/personnel/discharge/task/store')}}';
  206. tempTip.setDuration(2000);
  207. tempTip.setIndex(999);
  208. axios.post(url, this.addTask).then(res => {
  209. if (res.data.success) {
  210. tempTip.showSuccess("添加卸货任务成功")
  211. this.dischargeTasks.unshift(res.data.data);
  212. this.showCreateTaskModal(false);
  213. this.addTask = {};
  214. return ;
  215. }
  216. if(res.data.errors){
  217. this.taskError = res.data.errors ;
  218. return ;
  219. }
  220. tempTip.show(res.data.message ?? (res.data.data ?? '添加卸货任务失败'));
  221. }).catch(err => {
  222. tempTip.show(err);
  223. });
  224. },
  225. // 执行任务
  226. executedTask(dischargeTask, index) {
  227. let url = '{{url('apiLocal/personnel/discharge/task/updateFacilitator')}}';
  228. tempTip.setDuration(2000);
  229. tempTip.setIndex(9999);
  230. dischargeTask['income_total_cost'] = Number(dischargeTask['income_unit_price']) * (dischargeTask['income_amount']);
  231. dischargeTask['status'] = 1;
  232. axios.put(url, dischargeTask).then(res => {
  233. if (res.data.success) {
  234. this.$set(this.dischargeTasks, index, res.data.data);
  235. this.showExecutingTaskModal(null,false,null);
  236. tempTip.showSuccess("任务操作成功");
  237. this.selectIndex = null;
  238. this.executingTack = {};
  239. return;
  240. }
  241. if(res.data.errors){
  242. this.taskError = res.data.errors;
  243. return ;
  244. }
  245. tempTip.show(res.data.data);
  246. }).catch(err => {
  247. tempTip.show(err);
  248. })
  249. },
  250. // 编辑当前任务
  251. updateCurrentTask(addTask,index) {
  252. // 更新
  253. let url = '{{url('apiLocal/personnel/discharge/task/update')}}';
  254. tempTip.setDuration(2000);
  255. tempTip.setIndex(2000);
  256. axios.put(url, addTask).then(res => {
  257. if (res.data.success) {
  258. tempTip.showSuccess("修改成功")
  259. this.showCreateTaskModal(false);
  260. this.$set(this.dischargeTasks, index, res.data.data);
  261. this.addTask = {};
  262. this.selectIndex = null;
  263. return;
  264. }
  265. res.data.message ? tempTip.show(res.data.message) : null;
  266. }).catch(err => {
  267. tempTip.show(err);
  268. });
  269. this.selectIndex = null;
  270. },
  271. updateCurrentTaskColumn(task,index,column,$e){
  272. let url = '{{url('apiLocal/personnel/discharge/task/updateColumn')}}';
  273. tempTip.setDuration(2000);
  274. tempTip.setIndex(99);
  275. let value = $($e.target).val();
  276. let data = {id:task.id};
  277. data[column] = value;
  278. window.axios.put(url, data).then(res => {
  279. if (res.data.success) {
  280. if(res.data.data.status === 3)res.data.data.btnText = '查';
  281. this.$set(this.dischargeTasks, index, res.data.data);
  282. tempTip.showSuccess("修改成功")
  283. this.addTask = {};
  284. this.selectIndex = null;
  285. return;
  286. }else if(res.data.errors){
  287. tempTip.show(res.data.errors);
  288. return;
  289. }
  290. tempTip.show(res.data.data)
  291. this.$set(this.dischargeTasks, index, task);
  292. }).catch(err => {
  293. tempTip.show(err);
  294. });
  295. this.selectIndex = null;
  296. },
  297. // 删除当前任务
  298. deleteTask(index, dischargeTask) {
  299. if (!confirm("是否删除当前任务")) {
  300. return
  301. }
  302. let url = '{{url('apiLocal/personnel/discharge/task/delete/?id=')}}'+dischargeTask['id'];
  303. tempTip.setDuration(2000);
  304. tempTip.setIndex(99);
  305. axios.delete(url).then(res => {
  306. if (res.data.success) {
  307. this.$delete(this.dischargeTasks, index);
  308. tempTip.showSuccess('删除成功')
  309. return
  310. }
  311. tempTip.show('删除失败!' + res.data.data)
  312. }).catch(err => {
  313. tempTip.show(err);
  314. });
  315. },
  316. // 下载
  317. dischargeTaskExport(isExportAll) {
  318. let url = '{{url('personnel/discharge/task/export')}}';
  319. let token = '{{ csrf_token() }}';
  320. excelExport(isExportAll, this.checkData, url, this.sum, token);
  321. },
  322. // 筛选货主
  323. filterOwner(e) {
  324. let value = $(e.target).val();
  325. if (value === '') {
  326. this.ownerFilter = JSON.parse(JSON.stringify(this.owners));
  327. this.addTask.owner_id = null;
  328. }
  329. else {
  330. this.ownerFilter = this.owners.filter(function (owner) {
  331. return owner.value.indexOf(value) !== -1;
  332. });
  333. if(this.ownerFilter.length > 0)this.addTask.owner_id =this.ownerFilter[0]['name'];
  334. else this.addTask.owner_id = null;
  335. }
  336. },
  337. // 筛选装卸队
  338. filterProviders(e) {
  339. let value = $(e.target).val();
  340. if (value === '') this.facilitatorsFilter = JSON.parse(JSON.stringify(this.facilitators));
  341. else {
  342. let facilitators = JSON.parse(JSON.stringify(this.facilitators));
  343. this.facilitatorsFilter = facilitators.filter(function (item) {
  344. return item.name.indexOf(value) !== -1;
  345. });
  346. if(this.facilitatorsFilter.length > 0){
  347. this.executingTack.facilitator_id =this.facilitatorsFilter[0]['id'];
  348. }
  349. }
  350. },
  351. getReceiptUrl(id){
  352. return '{{url('personnel/discharge/task/receipt')}}'+'/?id='+id;
  353. },
  354. showReceipt(task){
  355. window.open(this.getReceiptUrl(task.id));
  356. },
  357. // 批量导入
  358. importDischarge(){
  359. window.tempTip.setIndex(1999);
  360. let formData = new FormData();
  361. let file = document.querySelector('#importFile').files[0];
  362. if(file==null){
  363. window.tempTip.show('请选择上传文件');
  364. }
  365. formData.append('file',file);
  366. let url = '{{url('apiLocal/personnel/discharge/task/import')}}';
  367. window.axios.post(url,formData,{
  368. 'Content-Type': 'multipart/form-data'
  369. }).then(res=>{
  370. if(res.data.success){
  371. window.tempTip.showSuccess(res.data.message ? res.data.message : '导入成功!刷新页面显示');
  372. return ;
  373. }else if(res.data.errors){
  374. window.tempTip.show('导入创建卸货任务失败!,详情请看列表')
  375. this.uploadErrors = res.data.errors;
  376. return ;
  377. }
  378. window.tempTip.show('导入失败!'+(res.data.message ? res.data.message : ''));
  379. }).catch(err=>{
  380. window.tempTip.show(err);
  381. });
  382. },
  383. importModal(){
  384. document.querySelector('#importFile').file = [];
  385. $('#importModal').modal('show');
  386. },
  387. cancelImport(){
  388. this.uploadErrors = [];
  389. $('#importModal').modal('hide');
  390. document.querySelector('#importFile').value = null;
  391. }
  392. }
  393. })
  394. </script>
  395. @endsection