🏠 Home 

生成管理单

点击填充数据按钮自动补充表单数据

สคริปต์นี้ไม่ควรถูกติดตั้งโดยตรง มันเป็นคลังสำหรับสคริปต์อื่น ๆ เพื่อบรรจุด้วยคำสั่งเมทา // @require https://update.greasyfork.org/scripts/391578/743766/%E7%94%9F%E6%88%90%E7%AE%A1%E7%90%86%E5%8D%95.js

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