🏠 Home 

资金申请单

根据类目明细填充资金申请单

สคริปต์นี้ไม่ควรถูกติดตั้งโดยตรง มันเป็นคลังสำหรับสคริปต์อื่น ๆ เพื่อบรรจุด้วยคำสั่งเมทา // @require https://update.greasyfork.org/scripts/391579/743768/%E8%B5%84%E9%87%91%E7%94%B3%E8%AF%B7%E5%8D%95.js

  1. // ==UserScript==
  2. // @name 资金申请单
  3. // @version 0.1
  4. // @description 根据类目明细填充资金申请单
  5. // @author cfl
  6. // @match http://*/zj/add
  7. // @match https://*/zj/add
  8. // @match http://*/zj/update/*
  9. // @match https://*/zj/update/*
  10. // @grant none
  11. // ==/UserScript==
  12. (function() {
  13. 'use strict';
  14. var $ = window.$;
  15. var detialType_default = $('#detialType').val()
  16. var data = "<div id='pad_data' class='btn btn-info' style='margin-left:10px'>填充数据</div>";
  17. if(typeof(detialType_default) != "undefined"){
  18. $('input[name="money_from"]').attr('readonly', true);
  19. $('input[name="contract"]').attr('readonly', true);
  20. $('input[name="order_num"]').attr('readonly', true);
  21. $('input[name="trim_vin"]').attr('readonly', true);
  22. $('input[name="zj_note"]').attr('readonly', true);
  23. }
  24. /* $('input[name="money_from"]').attr('readonly', true);
  25. $('input[name="contract"]').attr('readonly', true);
  26. $('input[name="order_num"]').attr('readonly', true);
  27. $('input[name="trim_vin"]').attr('readonly', true);
  28. $('input[name="zj_note"]').attr('readonly', true);*/
  29. if(detialType_default){
  30. //修改时禁用表单
  31. if($('#pad_data').length>0){
  32. }else{
  33. $('button[type="submit"]').after(data);
  34. }
  35. pad_date(detialType_default);
  36. }else{
  37. $('#detialType').on('change',function(){
  38. var detialType = $('#detialType').val();
  39. if(detialType != ''){
  40. $('input[name="money_from"]').val('');
  41. // $('input[name="get_unit"]').val('');
  42. $('input[name="contract"]').val('');
  43. $('input[name="order_num"]').val('');
  44. $('input[name="trim_vin"]').val('');
  45. $('input[name="zj_note"]').val('');
  46. $('.ms-sel-ctn').remove('.ms-sel-item ');
  47. if($('#pad_data').length>0){
  48. }else{
  49. $('button[type="submit"]').after(data);
  50. }
  51. pad_date(detialType);
  52. }else{
  53. if($('#pad_data').length>0){
  54. $('#pad_data').remove();
  55. }
  56. }
  57. })
  58. }
  59. function pad_date(detialType){
  60. //填充数据
  61. $('#pad_data').click(function(){
  62. var money_from = []; //资金用途
  63. var get_unit = []; // 收款单位
  64. var zj_note = []; //备注
  65. var contract = [];//合同号
  66. var order_num = [];//订单号
  67. var zhanwei_num = []; //展位号
  68. var order_zhanwei = [];
  69. var shuidan_num = []; //税单号
  70. var shuidan_chejia=[]; //税单号_车架号
  71. var trim_vin = [];//税单号_车架号
  72. var data_more = "见明细";
  73. var contract_xin = [];
  74. var contract_xie = [];
  75. var currency = []; //币种
  76. var rate = []; //汇率
  77. var currency_amount = []; //本币金额
  78. var chexing = []; //车型
  79. var remark_note = [];
  80. var remark_chexing = [];
  81. $('#addNew tbody tr').each(function(){
  82. $.each($(this).find(':input'),function(){
  83. var name = $(this).attr('name');
  84. var value = $(this).val();
  85. switch(name){
  86. case 'client[]':
  87. if($.inArray(value,get_unit)==-1){
  88. get_unit.push(value);
  89. };break;
  90. case 'note[]':
  91. if($.inArray(value,zj_note)==-1){
  92. zj_note.push(value);
  93. };break;
  94. case '商圈号[]':
  95. case '合同号[]':
  96. case '质保手册号[]':
  97. if($.inArray(value,contract)==-1){
  98. contract.push(value);
  99. };break;
  100. case '电子订单号[]':
  101. case '房间号[]':
  102. case '配件原厂编码[]':
  103. if($.inArray(value,order_num) ==-1){
  104. order_num.push(value);
  105. };break;
  106. case '展位号[]':
  107. if($.inArray(value,zhanwei_num) ==-1 ){
  108. zhanwei_num.push(value);
  109. };break;
  110. case '车架号[]':
  111. if($.inArray(value,trim_vin) ==-1){
  112. trim_vin.push(value);
  113. };break;
  114. case '税单号[]':
  115. if($.inArray(value,shuidan_num) ==-1){
  116. shuidan_num.push(value);
  117. };break;
  118. case 'type3[]':
  119. if($.inArray($(this).find(':selected').text(),money_from) == -1){
  120. if($(this).find(':selected').text()!= ''){
  121. money_from.push($(this).find(':selected').text());
  122. }
  123. };break;
  124. case '信用证号[]':
  125. if($.inArray(value,contract_xin) ==-1){
  126. contract_xin.push(value);
  127. };break;
  128. case '协议号[]':
  129. if($.inArray(value,contract_xie) ==-1){
  130. contract_xie.push(value);
  131. };break;
  132. case '币种[]':
  133. if(value){
  134. currency.push(value);
  135. }
  136. break;
  137. case '汇率[]':
  138. if(value != ''){
  139. rate.push(value);
  140. }
  141. break;
  142. case '明细金额[]':
  143. if(value){
  144. currency_amount.push(value);
  145. }
  146. break;
  147. case '车型[]':
  148. if($.inArray(value,chexing) ==-1){
  149. chexing.push(value);
  150. };break;
  151. }
  152. })
  153. })
  154. var remark_more = [];
  155. if(currency.length>0 && currency.length<2){
  156. if(rate.length > 0 && rate[0]){
  157. remark_more.push(currency[0] + ':'+rate[0]+' ');
  158. }else{
  159. remark_more.push(currency[0]+' ');
  160. }
  161. }else{
  162. $('input[name="zj_note"]').val(data_more);
  163. }
  164. if(remark_more.length == 1){
  165. var data = '';
  166. if(zj_note.length>0){
  167. data = zj_note[0]+' '+ remark_more[0];
  168. }
  169. if(currency_amount.length >0){
  170. data += currency_amount[0];
  171. }
  172. remark_note.push(data);console.log(remark_note);
  173. $('input[name="zj_note"]').val(remark_note);
  174. }
  175. if(zhanwei_num.length >0 ){
  176. if(order_num.length>0){
  177. if(zhanwei_num.length==order_num.length){
  178. $.each(zhanwei_num,function(i,v){
  179. var item = '';
  180. if(v == ''){
  181. item = order_num[i];
  182. }else if(order_num[i] == ''){
  183. item = v;
  184. }else{
  185. if(v == order_num[i]){
  186. item = v;
  187. }else{
  188. item = v+'/'+order_num[i];
  189. }
  190. }
  191. order_zhanwei.push(item);
  192. })
  193. }else if(zhanwei_num.length > order_num.length){
  194. $.each(zhanwei_num,function(i,v){
  195. $.each(order_num,function(ii,vv){
  196. var item = '';
  197. if(i<=ii){
  198. if(vv == ''){
  199. item = v;
  200. }else{
  201. item = v+'/'+vv;
  202. }
  203. order_zhanwei.push(item);
  204. }else{
  205. order_zhanwei.push(v);
  206. }
  207. })
  208. })
  209. }else if(zhanwei_num.length < order_num.length){
  210. $.each(order_num,function(i,v){
  211. $.each(zhanwei_num,function(ii,vv){
  212. var item = '';
  213. if(i<=ii){
  214. if(v == ''){
  215. item = vv
  216. }else{
  217. console.log(vv);
  218. console.log(v);
  219. if(vv == ''){
  220. item = v;
  221. }else{
  222. item = vv+'/'+v;
  223. }
  224. }
  225. console.log(item);
  226. order_zhanwei.push(item);
  227. }else{
  228. order_zhanwei.push(v);
  229. }
  230. })
  231. })
  232. }
  233. }else{
  234. order_zhanwei = zhanwei_num;
  235. }
  236. }
  237. if(shuidan_num.length>0){
  238. if(trim_vin.length>0){
  239. if(shuidan_num.length == trim_vin.length){
  240. $.each(shuidan_num,function(i,v){
  241. var item = '';
  242. if(v == ''){
  243. item = trim_vin[i];
  244. }else if(trim_vin[i]==''){
  245. item = v;
  246. }else{
  247. if(v == trim_vin[i]){
  248. item = v ;
  249. }else{
  250. item = v + '/' + trim_vin[i];
  251. }
  252. }
  253. shuidan_chejia.push(item);
  254. })
  255. }else if(shuidan_num.length > trim_vin.length){
  256. $.each(shuidan_num,function(i,v){
  257. $.each(trim_vin,function(ii,vv){
  258. if(i <= ii){
  259. if(vv == ''){
  260. shuidan_chejia.push(v);
  261. }else{
  262. shuidan_chejia.push(v + '/'+ vv)
  263. }
  264. }else{
  265. shuidan_chejia.push(v);
  266. }
  267. })
  268. })
  269. }else if(shuidan_num.length < trim_vin.length){
  270. $.each(trim_vin,function(i,v){
  271. $.each(shuidan_num,function(ii,vv){
  272. if(i <= ii){
  273. if(v == ''){
  274. shuidan_chejia.push(vv);
  275. }else{
  276. if(v == vv){
  277. shuidan_chejia.push(v);
  278. }else{
  279. if(vv == ''){
  280. shuidan_chejia.push(v);
  281. }else{
  282. shuidan_chejia.push(v + '/' + vv);
  283. }
  284. }
  285. }
  286. }else{
  287. shuidan_chejia.push(v);
  288. }
  289. })
  290. })
  291. }
  292. }else{
  293. shuidan_chejia = shuidan_num;
  294. }
  295. }
  296. if(contract_xie.length>0){
  297. if(contract_xin.length>0){
  298. if(contract_xie.length == contract_xin.length){
  299. $.each(contract_xie,function(i,v){
  300. var item = '';
  301. if(v == ''){
  302. item = contract_xin[i];
  303. }else if(contract_xin[i]==''){
  304. item = v;
  305. }else{
  306. if(v == contract_xin[i]){
  307. item = v ;
  308. }else{
  309. item = v + '/' + contract_xin[i];
  310. }
  311. }
  312. contract.push(item);
  313. })
  314. }else if(contract_xie.length > contract_xin.length){
  315. $.each(contract_xie,function(i,v){
  316. $.each(contract_xin,function(ii,vv){
  317. if(i <= ii){
  318. console.log(v);
  319. console.log(vv);
  320. if(vv == ''){
  321. contract.push(v);
  322. }else{
  323. if(v ==''){
  324. contract.push(vv)
  325. }else{
  326. contract.push(v + '/' + vv);
  327. }
  328. }
  329. }else{
  330. contract.push(v);
  331. }
  332. })
  333. })
  334. }else if(contract_xie.length < contract_xin.length){
  335. $.each(contract_xin,function(i,v){
  336. $.each(contract_xie,function(ii,vv){
  337. if(i <= ii){
  338. if(v == ''){
  339. contract.push(vv);
  340. }else{
  341. if(v == vv){
  342. contract.push(v);
  343. }else{
  344. if(vv == ''){
  345. contract.push(v);
  346. }else{
  347. contract.push(vv + '/' + v);
  348. }
  349. }
  350. }
  351. }else{
  352. contract.push(v);
  353. }
  354. })
  355. })
  356. }
  357. }else{
  358. contract = contract_xie;
  359. }
  360. }else{
  361. if(contract_xin.length>0){
  362. contract = contract_xin
  363. }
  364. }
  365. if(zj_note.length >0 ){
  366. if(chexing.length>0){
  367. if(zj_note.length==chexing.length){
  368. $.each(zj_note,function(i,v){
  369. var item = '';
  370. if(v == ''){
  371. item = chexing[i];
  372. }else if(chexing[i] == ''){
  373. item = v;
  374. }else{
  375. if(v == chexing[i]){
  376. item = v;
  377. }else{
  378. item = v+'/'+chexing[i];
  379. }
  380. }
  381. remark_note.push(item);
  382. })
  383. }else if(zj_note.length > chexing.length){
  384. $.each(zj_note,function(i,v){
  385. $.each(chexing,function(ii,vv){
  386. var item = '';
  387. if(i<=ii){
  388. if(vv == ''){
  389. item = v;
  390. }else{
  391. item = v+'/'+vv;
  392. }
  393. remark_note.push(item);
  394. }else{
  395. remark_note.push(v);
  396. }
  397. })
  398. })
  399. }else if(zj_note.length < chexing.length){
  400. $.each(chexing,function(i,v){
  401. $.each(zj_note,function(ii,vv){
  402. var item = '';
  403. if(i<=ii){
  404. if(v == ''){
  405. item = vv
  406. }else{
  407. if(vv == ''){
  408. item = v;
  409. }else{
  410. item = vv+'/'+v;
  411. }
  412. }
  413. remark_note.push(item);
  414. }else{
  415. remark_note.push(v);
  416. }
  417. })
  418. })
  419. }
  420. }else{
  421. remark_note = zj_note;
  422. }
  423. }
  424. // console.log(shuidan_num);
  425. // console.log(trim_vin);
  426. // console.log(shuidan_chejia);
  427. /* 资金用途 */
  428. if(money_from.length >0&&money_from.length<=2){
  429. $('input[name="money_from"]').val(money_from.join(' '));
  430. }else if(money_from.length>2){
  431. $('input[name="money_from"]').val(data_more)
  432. };
  433. /* 收款单位 */
  434. /* if(get_unit.length >0&&get_unit.length<=2){
  435. $('input[name="get_unit"]').val(get_unit.join(' '));
  436. }else if(get_unit.length >2){
  437. $('input[name="get_unit"]').val(data_more)
  438. };*/
  439. /* 合同号 */
  440. if(contract.length >0&&contract.length<=2){
  441. $('input[name="contract"]').val(contract.join(' '));
  442. }else if(contract.length>2){
  443. $('input[name="contract"]').val(data_more);
  444. };
  445. /* 备注 */
  446. if(currency.length == 0 && remark_note.length >0&&remark_note.length<=2){
  447. $('input[name="zj_note"]').val(remark_note.join(' '));
  448. }else if(remark_note.length >2){
  449. $('input[name="zj_note"]').val(data_more)
  450. };
  451. /* 订单号/展位号 */
  452. if(order_zhanwei.length >0 && order_zhanwei.length<=2){
  453. $('input[name="order_num"]').val(order_zhanwei.join(' '));
  454. }else if(order_zhanwei.length > 2){
  455. $('input[name="order_num"]').val(data_more);
  456. }else{
  457. if(order_num.length >0&&order_num.length<=2){
  458. $('input[name="order_num"]').val(order_num.join(' '));
  459. }else if(order_num.length>2){
  460. $('input[name="order_num"]').val(data_more)
  461. };
  462. }
  463. /*税单_车架号*/
  464. if(shuidan_chejia.length >0&&shuidan_chejia.length<=2){
  465. $('input[name="trim_vin"]').val(shuidan_chejia.join(' '));
  466. }else if(shuidan_chejia.length>2){
  467. $('input[name="trim_vin"]').val(data_more)
  468. }else{
  469. if(trim_vin.length >0&&trim_vin.length<=2){
  470. $('input[name="trim_vin"]').val(trim_vin.join(' '));
  471. }else if(trim_vin.length>2){
  472. $('input[name="trim_vin"]').val(data_more)
  473. };
  474. }
  475. })
  476. }
  477. })();