rejectedIndex.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. let vueList=new Vue({
  2. el:"#list",
  3. data:{
  4. filterParams:{created_at:'',owner_id:'',order_number:'',logistic_number_return:'',mobile_sender:'',barcode_goods:'',id_logistic_return:'',
  5. is_checked:'',created_at_start:'',created_at_end:'',id_quality_label:'',is_loaded:'',checked_numbers:'',paginate:'50'},
  6. checkBoxAll:[],
  7. rejectedBills:rejectedBills,
  8. rejectedBills_checkBoxes:[],
  9. owners:owners,
  10. logistics:logistics,
  11. qualityLabels:qualityLabels,
  12. },
  13. mounted:function(){
  14. $(".tooltipTarget").tooltip({'trigger':'hover'});
  15. this.initInputs();
  16. $('#list').removeClass('d-none');
  17. },
  18. methods:{
  19. filterRun:function(){
  20. let form=$("<form method='get'></form>");
  21. this.filterParams['page']='';
  22. for(let key in this.filterParams){
  23. if(this.filterParams[key]){
  24. form.append($("<input type='hidden' name='"+key+"' value='"+this.filterParams[key]+"'>"));
  25. }
  26. }
  27. $("body").append(form);
  28. form.submit();
  29. },
  30. searchByFilters:function(e){
  31. this.filterRun();
  32. },
  33. created_at_startChange:function(e){
  34. this.filterParams.created_at_start=e.target.value;
  35. this.filterRun();
  36. },
  37. created_at_endChange:function(e){
  38. this.filterParams.created_at_end=e.target.value;
  39. this.filterRun();
  40. },
  41. owner_idChange:function(e){
  42. this.filterParams.owner_id=e.target.value;
  43. this.filterRun();
  44. },
  45. is_checkedChange:function(e){
  46. this.filterParams.is_checked=e.target.value;
  47. this.filterRun();
  48. },
  49. id_quality_labelChange:function(e){
  50. this.filterParams.id_quality_label=e.target.value;
  51. this.filterRun();
  52. },
  53. is_loadedChange:function(e){
  54. this.filterParams.is_loaded=e.target.value;
  55. this.filterRun();
  56. },
  57. id_logistic_return_change:function(e){
  58. this.filterParams.id_logistic_return=e.target.value;
  59. this.filterRun();
  60. },
  61. initInputs:function(){
  62. let data=this;
  63. // let uriParts = decodeURI(location.href).split("?");
  64. // if(uriParts.length>1){
  65. // let params = uriParts[1].split('&');
  66. // params.forEach(function(paramPair){
  67. // let pair=paramPair.split('=');
  68. // let key = pair[0], val = pair[1];
  69. // $('input[name="'+key+'"]').val(val);
  70. // $('select[name="'+key+'"]').val(val);
  71. // data.filterParams[key]=val;
  72. // });
  73. // }
  74. for(let key in paginateParams){
  75. let val = paginateParams[key];
  76. $('input[name="'+key+'"]').val(val);
  77. $('select[name="'+key+'"]').val(val);
  78. data.filterParams[key]=val;
  79. }
  80. },
  81. edit:function(e){
  82. let id = $(e.target).parents('tr').attr('data-id');
  83. let editFullUri = editUrl+id+"/edit";
  84. // location.href = editFullUri;
  85. let form=$('<form action=\"'+editFullUri+'\" method="post" target="_blank"></form>');
  86. form.append('<input type="hidden" name="filterParams" value=\''+JSON.stringify(this.filterParams)+'\'/>');
  87. form.append(csrfInput);
  88. $('body').append(form);
  89. form.submit();
  90. },
  91. destroy:function(rejectedBill){
  92. if(!confirm('确定要删除退货信息“' + rejectedBill.owner.name+':'+rejectedBill.logistic_number_return+ '”吗?')){return;}
  93. let data=this;
  94. let url = destroyUrl+rejectedBill.id;
  95. axios.delete(url,{id:rejectedBill.id})
  96. .then(function (response) {
  97. if(response.data.success){
  98. for (let i = 0; i < data.rejectedBills.length; i++) {
  99. if (data.rejectedBills[i].id===rejectedBill.id){
  100. data.rejectedBills.splice(i,1);
  101. break;
  102. }
  103. }
  104. tempTip.setDuration(1000);
  105. tempTip.showSuccess('删除退货信息"'+rejectedBill.owner.name+':'+rejectedBill.logistic_number_return+'"成功!')
  106. }else{
  107. tempTip.setDuration(1000);
  108. tempTip.show('删除退货信息"'+rejectedBill.owner.name+':'+rejectedBill.logistic_number_return+'"失败!')
  109. }
  110. })
  111. .catch(function (err) {
  112. tempTip.setDuration(3000);
  113. tempTip.show('删除退货信息失败!'+'网络错误:' + err);
  114. console.log(err);
  115. });
  116. },
  117. submitFilterOnEnter:function(e){
  118. if(e.key==='Enter'){
  119. this.filterRun();
  120. }
  121. },
  122. created_at_startEntering:function(e){
  123. if(e.key==='Enter'){
  124. this.created_at_startChange(e)
  125. }
  126. },
  127. created_at_endEntering:function(e){
  128. if(e.key==='Enter'){
  129. this.created_at_endChange(e)
  130. }
  131. },
  132. owner_idEntering:function(e){
  133. if(e.key==='Enter'){
  134. e.target.value=$('#owner_id').val();
  135. this.owner_idChange(e);
  136. e.target.value='';
  137. }
  138. },
  139. locateOwner:function (e) {
  140. str = e.target.value.trim()
  141. if (str==='')return ;
  142. $("#owner_id option").attr("selected",false);
  143. let selectingOption=$("#owner_id").find("option:contains("+str+")").eq(0);
  144. selectingOption.attr("selected",true);
  145. this.filterParams.owner_id=selectingOption.val();
  146. },
  147. mobile_senderEntering:function(e){
  148. this.filterParams.mobile_sender=e.target.value;
  149. if(e.key==='Enter'){
  150. this.filterRun();
  151. }
  152. },
  153. order_numberEntering:function(e){
  154. this.filterParams.order_number=e.target.value;
  155. if(e.key==='Enter'){
  156. this.filterRun();
  157. }
  158. },
  159. barcode_goodsEntering:function(e){
  160. this.filterParams.barcode_goods=e.target.value;
  161. if(e.key==='Enter'){
  162. this.filterRun();
  163. }
  164. },
  165. checked_numbersEntering:function(e){
  166. this.filterParams.checked_numbers=e.target.value;
  167. if(e.key==='Enter'){
  168. this.filterRun();
  169. }
  170. },
  171. logistic_number_returnEntering:function(e){
  172. this.filterParams.logistic_number_return=e.target.value;
  173. if(e.key==='Enter'){
  174. this.filterRun();
  175. }
  176. },
  177. logistic_numberEntering:function(e){
  178. this.filterParams.logistic_number=e.target.value;
  179. if(e.key==='Enter'){
  180. this.filterRun();
  181. }
  182. },
  183. cancelCheckConfirmAll:function(){
  184. $('#checkConfirmingAll').tooltip('hide');
  185. setTimeout(function () {
  186. $(".tooltipTarget").tooltip({'trigger':'hover'})
  187. }, 10);
  188. this.checkBoxAll=false;
  189. this.rejectedBills.forEach(function(rejectedBill){
  190. if(rejectedBill.is_checked===-1)
  191. rejectedBill.is_checked='0';
  192. })
  193. },
  194. setIsLoaded_batch:function(val){
  195. let _this=this;
  196. if(_this.rejectedBills_checkBoxes.length===0){
  197. tempTip.show('没有勾选记录');
  198. $(e.target).val("");
  199. return;
  200. }
  201. let is_loaded=0;
  202. let is_loadedLabel='否';
  203. if(parseInt(val)===1){
  204. is_loaded=1;
  205. is_loadedLabel='是';
  206. }else if(parseInt(val)===2){
  207. is_loaded=2;
  208. is_loadedLabel='待推单';
  209. }else if(parseInt(val)===4){
  210. is_loaded=4;
  211. is_loadedLabel='待确认';
  212. }else if(val==="null"){
  213. is_loaded='null';
  214. is_loadedLabel='无需入库';
  215. }
  216. if(!confirm("确定要标记所有勾选入库情况为'"+is_loadedLabel+"'吗")){return;}
  217. axios.post(ajaxCheckUrl,{ids:_this.rejectedBills_checkBoxes,is_loaded:is_loaded}).then(function(response){
  218. if(response.data.success){
  219. _this.rejectedBills_checkBoxes.forEach(function(id){
  220. _this.rejectedBills.forEach(function(bill){
  221. if(bill.id===id){
  222. bill.is_loaded=is_loaded;
  223. }
  224. });
  225. });
  226. tempTip.setDuration(1000);
  227. tempTip.showSuccess('修改勾选记录的入库状态成功');
  228. }else{
  229. tempTip.setDuration(2500);
  230. tempTip.show('修改勾选记录的入库状态失败,错误:'+response.data.fail_info);
  231. }
  232. }).catch(function (e) {
  233. alert('网络连接错误:'+e);
  234. tempTip.setDuration(2500);
  235. tempTip.show('审核勾选内容失败,网络连接错误:'+e);
  236. console.log(e);
  237. });
  238. $(e.target).val("")
  239. },
  240. checkBoxAllToggle:function(e){
  241. let _this=this;
  242. if(_this.rejectedBills_checkBoxes.length>=this.rejectedBills.length){
  243. _this.rejectedBills_checkBoxes=[];
  244. _this.checkBoxAll=[];
  245. }
  246. else{
  247. _this.rejectedBills_checkBoxes=[];
  248. this.rejectedBills.forEach(function(bill){
  249. _this.rejectedBills_checkBoxes.push(bill.id);
  250. _this.checkBoxAll=[1];
  251. });
  252. }
  253. },
  254. checkAll:function(){
  255. let _this=this;
  256. if(_this.rejectedBills_checkBoxes.length===0){
  257. tempTip.show('没有勾选记录');
  258. return
  259. }
  260. if(!confirm("确定要标记所有勾选内容为'已审核'吗")){return;}
  261. axios.post(ajaxCheckAllURL,{ids:_this.rejectedBills_checkBoxes}).then(function(response){
  262. if(response.data.success){
  263. response.data.rejecteds.forEach(function (rejected) {
  264. _this.rejectedBills.forEach(function(rejectedBill){
  265. if(parseInt(rejectedBill.id)===parseInt(rejected.id)){
  266. rejectedBill.is_checked=1;
  267. rejectedBill.checked_numbers=rejected.checked_numbers;
  268. }
  269. });
  270. });
  271. tempTip.setDuration(1000);
  272. tempTip.showSuccess('审核勾选内容成功');
  273. }else{
  274. tempTip.setDuration(2500);
  275. tempTip.show('审核勾选内容失败,错误:'+response.data.fail_info);
  276. }
  277. }).catch(function (e) {
  278. alert('网络连接错误:'+e);
  279. tempTip.setDuration(2500);
  280. tempTip.show('审核勾选内容失败,网络连接错误:'+e);
  281. console.log(e);
  282. })
  283. },
  284. confirmBeStored:function($e,id){
  285. let _this=this;
  286. axios.post(ajaxConfirmBeStoredUrl,{id:id}).then(function(response){
  287. if(response.data.success){
  288. _this.rejectedBills.forEach(function(rejectedBill){
  289. if(rejectedBill.id===id){
  290. rejectedBill.is_loaded=1;
  291. }
  292. });
  293. tempTip.setDuration(1000);
  294. tempTip.showSuccess('确认入库成功');
  295. }else{
  296. tempTip.setDuration(2500);
  297. tempTip.okWindow('数据异常无法确认!请在WMS确定入库状态后,勾选该条目手动修改相应入库状态!','知道了')
  298. }
  299. }).catch(function (e) {
  300. alert('确认失败,网络连接错误:'+e);
  301. tempTip.setDuration(2500);
  302. tempTip.show('确认失败,网络连接错误:'+e);
  303. console.log(e);
  304. })
  305. },
  306. finishAll:function(){
  307. let _this=this;
  308. if(_this.rejectedBills_checkBoxes.length===0){
  309. tempTip.show('没有勾选记录');
  310. return
  311. }
  312. if(!confirm("确定要标记所有勾选内容为'已完结'吗")){return;}
  313. axios.post(ajaxFinishAllUrl,{ids:_this.rejectedBills_checkBoxes}).then(function(response){
  314. if(response.data.success){
  315. _this.rejectedBills.forEach(function(rejectedBill){
  316. _this.rejectedBills_checkBoxes.forEach(function (checkedId) {
  317. if(rejectedBill.id===checkedId){
  318. rejectedBill.is_finished=1;
  319. }
  320. });
  321. });
  322. tempTip.setDuration(1000);
  323. tempTip.showSuccess('标记勾选内容为完结成功');
  324. }else{
  325. tempTip.setDuration(2500);
  326. tempTip.show('标记勾选内容为完结失败,错误:'+response.data.fail_info);
  327. }
  328. }).catch(function (e) {
  329. alert('网络连接错误:'+e);
  330. tempTip.setDuration(2500);
  331. tempTip.show('标记勾选内容完结失败,网络连接错误:'+e);
  332. console.log(e);
  333. })
  334. },
  335. exportExcel:function(val){
  336. let _this=this;
  337. let form;
  338. if(parseInt(val)===1){
  339. if(_this.rejectedBills_checkBoxes.length===0){
  340. tempTip.show('没有勾选记录');
  341. return;
  342. }
  343. form=$('<form action=\"'+exportExcelURL+'\" method="post" target="_blank"></form>');
  344. form.append('<input type="hidden" name="ids" value=\''+JSON.stringify(_this.rejectedBills_checkBoxes)+'\'/>');
  345. form.append('<input type="hidden" name="created_at_start" value=\''+JSON.stringify(_this.created_at_start)+'\'/>');
  346. form.append('<input type="hidden" name="created_at_end" value=\''+JSON.stringify(_this.created_at_end)+'\'/>');
  347. }
  348. if(parseInt(val)===2){
  349. if(!confirm("确定要导出当前条件下全部页的结果吗?")){return;}
  350. if(total>100000){
  351. tempTip.okWindow('当前导出记录超过100000条,将不会导出已完结的记录','知道了')
  352. }
  353. form=$('<form action=\"'+exportExcelOnFilterParamsURL+'\" method="post" target="_blank"></form>');
  354. form.append('<input type="hidden" name="filterParams" value=\''+JSON.stringify(_this.filterParams)+'\'/>');
  355. }
  356. form.append(csrfInput);
  357. $('#list').append(form);
  358. form.submit();
  359. tempTip.setDuration(5000);
  360. tempTip.showSuccess("导出成功,如无结果则是被浏览器拦截新窗口,请尝试再次请求,或关闭浏览器对当前页面的弹出窗口拦截")
  361. },
  362. setPaginate:function(e){
  363. let _this=this;
  364. // let val=$(e.target).val();
  365. this.filterParams.paginate=e.target.value;
  366. this.filterRun();
  367. },
  368. },
  369. computed:{
  370. isBeingFilterConditions:function(){
  371. for(let key in this.filterParams){
  372. if(this.filterParams[key]){
  373. if(key==='paginate')continue;
  374. if(key==='page')continue;
  375. return true
  376. }
  377. }
  378. return false;
  379. }
  380. },
  381. filters:{
  382. yesNo:function (val) {
  383. if(!val||val===0||val==='0'){return '否'}
  384. return '是'
  385. },
  386. yesNoIsLoaded:function (val) {
  387. switch(val){
  388. case 0:case '0':return '否';
  389. case 1:case '1':return '是';
  390. case 2:case '2':return '待推单';
  391. case 3:case '3':return '交互异常';
  392. case 4:case '4':return '待确认';
  393. case null:case 'null':return '无需入库';
  394. }
  395. return '';
  396. }
  397. }
  398. });