rejectedIndex.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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. mobile_senderChange:function(e){
  54. this.filterParams.mobile_sender=e.target.value;
  55. this.filterRun();
  56. },
  57. checked_numbersChange:function(e){
  58. this.filterParams.checked_numbers=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. 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. order_numberEntering:function(e){
  143. if(e.key==='Enter'){
  144. this.filterParams.order_number=e.target.value;
  145. this.filterRun();
  146. }
  147. },
  148. barcode_goodsEntering:function(e){
  149. if(e.key==='Enter'){
  150. this.filterParams.barcode_goods=e.target.value;
  151. this.filterRun();
  152. }
  153. },
  154. logistic_number_returnEntering:function(e){
  155. if(e.key==='Enter'){
  156. this.filterParams.logistic_number_return=e.target.value;
  157. this.filterRun();
  158. }
  159. },
  160. logistic_numberEntering:function(e){
  161. if(e.key==='Enter'){
  162. this.filterParams.logistic_number=e.target.value;
  163. this.filterRun();
  164. }
  165. },
  166. cancelCheckConfirmAll:function(){
  167. $('#checkConfirmingAll').tooltip('hide');
  168. setTimeout(function () {
  169. $(".tooltipTarget").tooltip({'trigger':'hover'})
  170. }, 10);
  171. this.checkBoxAll=false;
  172. this.rejectedBills.forEach(function(rejectedBill){
  173. if(rejectedBill.is_checked===-1)
  174. rejectedBill.is_checked='0';
  175. })
  176. },
  177. setIsLoaded_batch:function(e){
  178. let _this=this;
  179. if(_this.rejectedBills_checkBoxes.length===0){
  180. tempTip.show('没有勾选记录');
  181. $(e.target).val("");
  182. return;
  183. }
  184. let val=$(e.target).val();
  185. let is_loaded=0;
  186. let is_loadedLabel='否';
  187. if(val==="1"){
  188. is_loaded=1;
  189. is_loadedLabel='是';
  190. }else if(val==="2"){
  191. is_loaded=2;
  192. is_loadedLabel='待推单';
  193. }else if(val==="null"){
  194. is_loaded='null';
  195. is_loadedLabel='无需入库';
  196. }
  197. if(!confirm("确定要标记所有勾选入库情况为'"+is_loadedLabel+"'吗")){return;}
  198. axios.post(ajaxCheckUrl,{ids:_this.rejectedBills_checkBoxes,is_loaded:is_loaded}).then(function(response){
  199. if(response.data.success){
  200. _this.rejectedBills_checkBoxes.forEach(function(id){
  201. _this.rejectedBills.forEach(function(bill){
  202. if(bill.id===id){
  203. bill.is_loaded=is_loaded;
  204. }
  205. });
  206. });
  207. tempTip.setDuration(1000);
  208. tempTip.showSuccess('修改勾选记录的入库状态成功');
  209. }else{
  210. tempTip.setDuration(2500);
  211. tempTip.show('修改勾选记录的入库状态失败,错误:'+response.data.fail_info);
  212. }
  213. }).catch(function (e) {
  214. alert('网络连接错误:'+e);
  215. tempTip.setDuration(2500);
  216. tempTip.show('审核勾选内容失败,网络连接错误:'+e);
  217. console.log(e);
  218. });
  219. $(e.target).val("")
  220. },
  221. checkBoxAllToggle:function(e){
  222. let _this=this;
  223. if(_this.rejectedBills_checkBoxes.length>=this.rejectedBills.length){
  224. _this.rejectedBills_checkBoxes=[];
  225. _this.checkBoxAll=[];
  226. }
  227. else{
  228. _this.rejectedBills_checkBoxes=[];
  229. this.rejectedBills.forEach(function(bill){
  230. _this.rejectedBills_checkBoxes.push(bill.id);
  231. _this.checkBoxAll=[1];
  232. });
  233. }
  234. },
  235. checkAll:function(){
  236. let _this=this;
  237. if(_this.rejectedBills_checkBoxes.length===0){
  238. tempTip.show('没有勾选记录');
  239. return
  240. }
  241. if(!confirm("确定要标记所有勾选内容为'已审核'吗")){return;}
  242. axios.post(ajaxCheckAllURL,{ids:_this.rejectedBills_checkBoxes}).then(function(response){
  243. if(response.data.success){
  244. response.data.rejecteds.forEach(function (rejected) {
  245. _this.rejectedBills.forEach(function(rejectedBill){
  246. if(parseInt(rejectedBill.id)===parseInt(rejected.id)){
  247. rejectedBill.is_checked=1;
  248. rejectedBill.checked_numbers=rejected.checked_numbers;
  249. }
  250. });
  251. });
  252. tempTip.setDuration(1000);
  253. tempTip.showSuccess('审核勾选内容成功');
  254. }else{
  255. tempTip.setDuration(2500);
  256. tempTip.show('审核勾选内容失败,错误:'+response.data.fail_info);
  257. }
  258. }).catch(function (e) {
  259. alert('网络连接错误:'+e);
  260. tempTip.setDuration(2500);
  261. tempTip.show('审核勾选内容失败,网络连接错误:'+e);
  262. console.log(e);
  263. })
  264. },
  265. finishAll:function(){
  266. let _this=this;
  267. if(_this.rejectedBills_checkBoxes.length===0){
  268. tempTip.show('没有勾选记录');
  269. return
  270. }
  271. if(!confirm("确定要标记所有勾选内容为'已完结'吗")){return;}
  272. axios.post(ajaxFinishAllUrl,{ids:_this.rejectedBills_checkBoxes}).then(function(response){
  273. if(response.data.success){
  274. _this.rejectedBills.forEach(function(rejectedBill){
  275. _this.rejectedBills_checkBoxes.forEach(function (checkedId) {
  276. if(rejectedBill.id===checkedId){
  277. rejectedBill.is_finished=1;
  278. }
  279. });
  280. });
  281. tempTip.setDuration(1000);
  282. tempTip.showSuccess('标记勾选内容为完结成功');
  283. }else{
  284. tempTip.setDuration(2500);
  285. tempTip.show('标记勾选内容为完结失败,错误:'+response.data.fail_info);
  286. }
  287. }).catch(function (e) {
  288. alert('网络连接错误:'+e);
  289. tempTip.setDuration(2500);
  290. tempTip.show('标记勾选内容完结失败,网络连接错误:'+e);
  291. console.log(e);
  292. })
  293. },
  294. exportExcel:function(e){
  295. let _this=this;
  296. let val=$(e.target).val();
  297. $(e.target).val("");
  298. let form;
  299. if(val==="1"){
  300. if(_this.rejectedBills_checkBoxes.length===0){
  301. tempTip.show('没有勾选记录');
  302. return;
  303. }
  304. form=$('<form action=\"'+exportExcelURL+'\" method="post" target="_blank"></form>');
  305. form.append('<input type="hidden" name="ids" value=\''+JSON.stringify(_this.rejectedBills_checkBoxes)+'\'/>');
  306. }
  307. if(val==="2"){
  308. if(!confirm("确定要导出当前条件下全部页的结果吗?")){return;}
  309. if(total>100000){
  310. tempTip.okWindow('当前导出记录超过100000条,将不会导出已完结的记录','知道了')
  311. }
  312. form=$('<form action=\"'+exportExcelOnFilterParamsURL+'\" method="post" target="_blank"></form>');
  313. form.append('<input type="hidden" name="filterParams" value=\''+JSON.stringify(_this.filterParams)+'\'/>');
  314. }
  315. form.append(csrfInput);
  316. $('#list').append(form);
  317. form.submit();
  318. tempTip.setDuration(5000);
  319. tempTip.showSuccess("导出成功,如无结果则是被浏览器拦截新窗口,请尝试再次请求,或关闭浏览器对当前页面的弹出窗口拦截")
  320. },
  321. setPaginate:function(e){
  322. let _this=this;
  323. // let val=$(e.target).val();
  324. this.filterParams.paginate=e.target.value;
  325. this.filterRun();
  326. },
  327. },
  328. computed:{
  329. isBeingFilterConditions:function(){
  330. for(let key in this.filterParams){
  331. if(this.filterParams[key]){
  332. if(key==='paginate')continue;
  333. if(key==='page')continue;
  334. return true
  335. }
  336. }
  337. return false;
  338. }
  339. },
  340. filters:{
  341. yesNo:function (val) {
  342. if(!val||val===0||val==='0'){return '否'}
  343. return '是'
  344. },
  345. yesNoIsLoaded:function (val) {
  346. switch(val){
  347. case 0:case '0':return '否';
  348. case 1:case '1':return '是';
  349. case 2:case '2':return '待推单';
  350. case null:case 'null':return '无需入库';
  351. }
  352. return '';
  353. }
  354. }
  355. });