rejectedIndex.js 16 KB

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