rejectedIndex.js 16 KB

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