receipt.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. function check(){
  2. if (confirm("确认是否提交本次报销单,点击确定提交开始审批,点击取消关闭本窗口。"))
  3. return true;
  4. else return false;
  5. }
  6. function receiptYear(){
  7. var form = $('#up');
  8. $('#year').val($('#Y').val());
  9. form.submit();
  10. }
  11. function receiptDate(){
  12. var form = $('#up');
  13. //$('#year').val($('#date').val());
  14. form.submit();
  15. }
  16. function reportCatePM(){
  17. var name=$('#reportCate').val();
  18. $("option[node-all='true']").show();
  19. if(name=='ALL'){
  20. $("tr[node-all='true']").show();
  21. $("option[node-all='true']").show();
  22. }else{
  23. $("tr[node-all='true']").hide();
  24. $("option[node-all='true']").hide();
  25. $("option[node-cate='"+name+"']").show();
  26. $("tr[node-boxCate='"+name+"']").show();
  27. }
  28. }
  29. function reportPM(){
  30. var name=$('#report').val();
  31. if(name=='ALL')
  32. $("tr[node-all='true']").show();
  33. else{
  34. $("tr[node-all='true']").hide();
  35. $("tr[node-box='"+name+"']").show();
  36. }
  37. }
  38. function receiptMoth(){
  39. var form = $('#up');
  40. $('#year').val($('#Y').val());
  41. $('#month').val($('#M').val());
  42. //alert($('#M').val());
  43. form.submit();
  44. }
  45. function receiptDay(){
  46. var form = $('#up');
  47. $('#year').val($('#Y').val());
  48. $('#month').val($('#M').val());
  49. $('#day').val($('#D').val());
  50. form.submit();
  51. }
  52. function receiptSop(){
  53. var form = $('#up');
  54. $('#year').val($('#Y').val());
  55. $('#month').val($('#M').val());
  56. $('#day').val($('#D').val());
  57. $('#sop').val($('#S').val());
  58. form.submit();
  59. }
  60. function updateApprovalReceipt(status,rid){
  61. var form = $('#verifyOpinion_'+rid);
  62. $('#status_'+rid).val(status);
  63. $("input[name='amount']").val($('#amount').val());
  64. form.submit();
  65. }
  66. function setExeReceipt(tr,rid){
  67. var form = $('#implement'+tr);
  68. var amount=$('#amount'+tr).val();
  69. var accountBank=$('#accountBankSelect'+tr).val();
  70. if(amount=='')
  71. return alert('请填写汇款金额');
  72. $("#amountInp"+tr).val(amount);
  73. $("#accountBank"+tr).val(accountBank);
  74. //form.submit();
  75. }
  76. function expensesDefray(status,rid){
  77. var form = $('#verifyOpinion_'+rid);
  78. $('#status_'+rid).val(status);
  79. form.submit();
  80. }
  81. function showOpinion(receiptOrder){
  82. //console.log(receiptOrder);
  83. $('#orderBody').html('读取中');
  84. var url="/ajaxGetReceiptOrder";
  85. $.ajax({
  86. url:url,
  87. type: "post",
  88. cache: false,
  89. dataType: "json",
  90. data: {
  91. receiptOrder:receiptOrder
  92. },
  93. global: true,
  94. success: function(data){
  95. if(data.status==1)
  96. $('#orderBody').html(data.receiptHtml);
  97. else
  98. $('#orderBody').html('没找到信息');
  99. },
  100. error:function(err){
  101. }
  102. });
  103. }
  104. $(function() {
  105. $('select[node-implement]').change(function(){
  106. //$item=$(this).attr('value');
  107. // var action = $('#up').attr("action");
  108. // action=encodeURI(action+'/'+$item);
  109. // $('#up').attr("action",action);
  110. $('#up').submit();
  111. });
  112. $('button[node-qmk="tm"]').click(function(){
  113. var id=$(this).attr('data');
  114. $('#'+id).attr('value',$('#'+id).attr('data-tm'));
  115. });
  116. $('a[node-ReceiptBack="true"]').click(function(){
  117. var rid=$(this).attr("p-d");
  118. var opinion=$('#opinion_'+rid).val();
  119. var url="/approvalChe";
  120. $.ajax({
  121. url:url,
  122. type: "post",
  123. cache: false,
  124. dataType: "json",
  125. data: {
  126. rid:rid,
  127. opinion:opinion
  128. },
  129. global: true,
  130. success: function(data){
  131. if(data.status==2){
  132. alert('参数错误');
  133. }else{
  134. window.location.href="/approvalExpenses/pendApproval";
  135. }
  136. },
  137. error:function(err){
  138. }
  139. });
  140. });
  141. $("a[id^=examine]").click(function(){
  142. var rid=$(this).attr('data');
  143. var url="/ajaxExamine";
  144. $.ajax({
  145. url:url,
  146. type: "post",
  147. cache: false,
  148. dataType: "json",
  149. data: {
  150. rid:rid
  151. },
  152. success: function(data){
  153. if(data.status==0){
  154. alert('参数错误');
  155. }
  156. if(data.receipt.hasOwnProperty("rid")){
  157. if(data.receipt.Rtype==1){
  158. window.location.href="/expensesEdi/"+data.receipt.rid;
  159. }else if(data.receipt.Rtype==0){
  160. window.location.href="/receiptburEdi/"+data.receipt.rid;
  161. }else if(data.receipt.Rtype==2){
  162. window.location.href="/remitApproval/"+data.receipt.rid;
  163. }else if(data.receipt.Rtype==3){
  164. window.location.href="/receiptTrain/approval/"+data.receipt.ridKey+".html";
  165. }
  166. }else
  167. alert('没有需要审批的费用');
  168. },
  169. error:function(err){
  170. }
  171. });
  172. });
  173. $("a[id^=examineExe]").click(function(){
  174. var rid=$(this).attr('data');
  175. var url="/ajaxExamineExe";
  176. $.ajax({
  177. url:url,
  178. type: "post",
  179. cache: false,
  180. dataType: "json",
  181. data: {
  182. rid:rid
  183. },
  184. global: true,
  185. success: function(data){
  186. if(data.status==0){
  187. alert('参数错误');
  188. }
  189. var count=data.receipt.length;
  190. console.log(data.receipt.Rtype);
  191. if(count!=0){
  192. if(data.receipt.Rtype==0){
  193. window.location.href="/implement/receipt/"+data.receipt.ridKey+".html";
  194. }else if(data.receipt.Rtype==1){
  195. window.location.href="/implement/loan/"+data.receipt.ridKey+".html";
  196. }else if(data.receipt.Rtype==2){
  197. window.location.href="/implement/public/"+data.receipt.ridKey+".html";
  198. }else if(data.receipt.Rtype==3){
  199. }
  200. //
  201. }else
  202. alert('没有需要审批的费用');
  203. console.log(data);
  204. },
  205. error:function(err){
  206. }
  207. });
  208. });
  209. $("input[id^='agency_']").change(function() {
  210. $i=0;
  211. $("input[id^='agency_']").each(function(i){
  212. $i+=parseFloat(this.value);
  213. });
  214. $("#agencyResult").html("¥"+$i.toFixed(2));
  215. $("#agencyR").val($i.toFixed(2));
  216. var travelR=parseFloat($("#travelR").val());
  217. var trainR=parseFloat($("#trainR").val());
  218. var otherR=parseFloat($("#otherR").val());
  219. var RS=parseFloat($i)+parseFloat(travelR)+parseFloat(trainR)+parseFloat(otherR);
  220. $("#RS").html("¥"+RS.toFixed(2));
  221. });
  222. $("input[id^='travel_']").change(function() {
  223. $i=0;
  224. $("input[id^='travel_']").each(function(i){
  225. $i+=parseFloat(this.value);
  226. });
  227. $("#travelResult").html("¥"+$i.toFixed(2));
  228. $("#travelR").val($i.toFixed(2));
  229. var agencyR=$("#agencyR").val();
  230. var trainR=parseFloat($("#trainR").val());
  231. var otherR=parseFloat($("#otherR").val());
  232. var RS=parseFloat($i)+parseFloat(agencyR)+trainR+otherR;
  233. $("#RS").html("¥"+RS.toFixed(2));
  234. });
  235. $("input[id^='train_']").change(function() {
  236. $i=0;
  237. $("input[id^='train_']").each(function(i){
  238. $i+=parseFloat(this.value);
  239. });
  240. $("#trainResult").html("¥"+$i.toFixed(2));
  241. $("#trainR").val($i.toFixed(2));
  242. var agencyR=$("#agencyR").val();
  243. var otherR=parseFloat($("#otherR").val());
  244. var travelR=parseFloat($("#travelR").val());
  245. var RS=parseFloat($i)+parseFloat(agencyR)+travelR+otherR;
  246. $("#RS").html("¥"+RS.toFixed(2));
  247. });
  248. $("input[id^='other_']").change(function() {
  249. $i=0;
  250. $("input[id^='other_']").each(function(i){
  251. $i+=parseFloat(this.value);
  252. });
  253. $("#otherResult").html("¥"+$i.toFixed(2));
  254. $("#otherR").val($i.toFixed(2));
  255. var agencyR=$("#agencyR").val();
  256. var travelR=parseFloat($("#travelR").val());
  257. var trainR=parseFloat($("#trainR").val());
  258. var RS=parseFloat($i)+parseFloat(agencyR)+parseFloat(travelR)+parseFloat(trainR);
  259. $("#RS").html("¥"+RS.toFixed(2));
  260. });
  261. $("a[id^='getStaffInfo']").click(function(){
  262. var username=$(this).attr('data');
  263. var url="/getStaffInfo";
  264. $.ajax({
  265. url:url,
  266. type: "post",
  267. cache: false,
  268. dataType: "json",
  269. data: {
  270. username:username
  271. },
  272. global: true,
  273. success: function(data){
  274. if(data.success){
  275. alert('请重新登录');
  276. }
  277. $('#staffInfo').html(data.html);
  278. $('#staffInfo').show();
  279. $('#longleLog').hide();
  280. $('#clientInfo').hide();
  281. $('#changeCompany').hide();
  282. },
  283. error:function(err){
  284. }
  285. });
  286. });
  287. $("a[id^='getClientInfo']").click(function(){
  288. var client=$(this).attr('data');
  289. var url="/getClientInfo";
  290. $.ajax({
  291. url:url,
  292. type: "post",
  293. cache: false,
  294. dataType: "json",
  295. data: {
  296. client:client
  297. },
  298. global: true,
  299. success: function(data){
  300. if(data.success){
  301. alert('请重新登录');
  302. }
  303. $('#clientInfo').html(data.html);
  304. $('#clientInfo').show();
  305. $('#staffInfo').hide();
  306. $('#longleLog').hide();
  307. $('#addClient').hide();
  308. $('#changeCompany').hide();
  309. autoFlashHeight();
  310. },
  311. error:function(err){
  312. autoFlashHeight();
  313. }
  314. });
  315. });
  316. $("a[id^='getCompanyInfo']").click(function(){
  317. alert('dd');
  318. });
  319. $("a[id^='getLongleLog_']").click(function() {
  320. var lid=$(this).attr('data');
  321. var url="/ajaxGetLongle";
  322. $.ajax({
  323. url:url,
  324. type: "post",
  325. cache: false,
  326. dataType: "json",
  327. data: {
  328. lid:lid
  329. },
  330. global: true,
  331. success: function(data){
  332. if(data.success==false){
  333. alert('请重新登录');
  334. }
  335. $("#klid").val(data.klid);
  336. $("#longleTitle").html(data.longle.key_num);
  337. var lka='<a href="javascript:void(0)" onclick="getStaffInfo(\''+data.longle.responsible+'\')" >'+data.longle.responsible+'</a>';
  338. $("#longleResponsible").html(lka);
  339. var kk="";
  340. if(data.longle.alloted_time!="")
  341. kk="期限:"+data.longle.alloted_time;
  342. $("#longleStatus").html(data.longle.statusT+"/"+data.longle.product+"/("+data.longle.version+")"+kk);
  343. $("#LongleLogHtml").html(data.longleLogHtml);
  344. if(data.longle.status>=3){
  345. $("#longleStatus_5").attr('disabled',false);
  346. $("#longleStatus_6").attr('disabled',false);
  347. $("#longleStatus_7").attr('disabled',false);
  348. $("#longleStatus_8").attr('disabled',false);
  349. }
  350. $('#staffInfo').hide();
  351. $("#longleLog").show();
  352. $('#clientInfo').hide();
  353. autoFlashHeight();
  354. },
  355. error:function(err){
  356. // easyDialog.open({
  357. // container : { content : '请输入正确的参数'},
  358. // autoClose : 1500,
  359. // overlay : false
  360. // });
  361. }
  362. });
  363. });
  364. $("a[node-invoice='INFO']").click(function() {
  365. var postData = $(this).attr("data-isKey");
  366. $("div[loading-msg='true']").html("<img src='/global/img/loadIco.gif' />");
  367. $("#nc").html('illegal request');
  368. var url = "/ajaxGetReceiptDetails";
  369. $.ajax({
  370. url : url,
  371. type : "post",
  372. cache : false,
  373. dataType : "json",
  374. data : {
  375. serial : postData
  376. },
  377. global : true,
  378. success : function(data) {
  379. if (data.status == 1) {
  380. //$("div[loading-msg='true']").html("");
  381. $("#nc").html(data.html);
  382. }
  383. },
  384. error : function(err) {
  385. $("div[loading-msg='true']").html("");
  386. }
  387. });
  388. });
  389. $("form[name='recepitAdd']").validator({
  390. timely: 3,
  391. focusCleanup: true,
  392. theme:"yellow_top",
  393. rules: {
  394. remittanceBankType: function() {
  395. var rbt=$('select[node-rbt]').val();
  396. if(rbt==0)
  397. return false;
  398. return true;
  399. }
  400. },
  401. fields: {
  402. 'verify': 'required; ',
  403. 'explanation':'required; ',
  404. 'remittanceName':'required; ',
  405. 'bankName':'required; ',
  406. 'bankNumber':'required; ',
  407. 'coupletNumber':'required(remittanceBankType); '
  408. }
  409. });
  410. $("select[node-rbt]").change(function(){
  411. var rbt=$(this).val();
  412. if(rbt==0){
  413. $("tr[node-cn]").hide();
  414. }else if(rbt==1){
  415. $("tr[node-cn]").show();
  416. }
  417. });
  418. //培训班结算
  419. $("form[name='receiptTrainAdd']").validator({
  420. timely: 3,
  421. focusCleanup: true,
  422. theme:"yellow_top",
  423. rules: {
  424. remittanceBankType: function() {
  425. var rbt=$('select[node-rbt]').val();
  426. if(rbt==0)
  427. return false;
  428. return true;
  429. }
  430. },
  431. fields: {
  432. 'verify': 'required; ',
  433. 'explanation':'required; ',
  434. 'remittanceName':'required; ',
  435. 'bankName':'required; ',
  436. 'bankNumber':'required; ',
  437. 'coupletNumber':'required(remittanceBankType); ',
  438. 'trainName':'required; ',
  439. 'trainStartDate':'required; ',
  440. 'trainEndDate':'required; ',
  441. //'participants':'required; ',
  442. //'freeParticipants':'required; ',
  443. 'trainAddress':'required; ',
  444. }
  445. });
  446. //培训班结算-添加支出
  447. $("form[name='receiptTrainItemAdd']").validator({
  448. timely: 3,
  449. focusCleanup: true,
  450. theme:"yellow_right",
  451. fields: {
  452. 'price': 'required; ',
  453. 'date':'required; ',
  454. 'inputer':'required; '
  455. }
  456. });
  457. //培训班结算-添加讲师
  458. $("form[name='receiptTrainLecturerAdd']").validator({
  459. timely: 3,
  460. focusCleanup: true,
  461. theme:"yellow_right",
  462. fields: {
  463. 'ltype':'required; ',
  464. 'lecturerName':'required; ',
  465. 'price': 'required; ',
  466. 'schoolDay':'required; '
  467. }
  468. });
  469. $("a[getReceiptLoan]").click(function() {
  470. $.ajax({
  471. url:"/ajaxGetReceiptTrainLoan",
  472. type: "post",
  473. cache: false,
  474. dataType: "json",
  475. data: {
  476. },
  477. global: true,
  478. success: function(data){
  479. var html='';
  480. for(var i=0;i<data.receiptLoanList.length;i++){
  481. html +='<option value="'+data.receiptLoanList[i].ridKey+'">'+data.receiptLoanList[i].receiptOrder+' ¥'+data.receiptLoanList[i].sum+'</option>';
  482. }
  483. $("select[receiptLoanSelect]").html(html);
  484. },
  485. error:function(err){}
  486. });
  487. });
  488. $("a[getReceiptInvoice]").click(function() {
  489. $.ajax({
  490. url:"/ajaxGetInvoiceTrainByEnd",
  491. type: "post",
  492. cache: false,
  493. dataType: "json",
  494. data: {
  495. },
  496. global: true,
  497. success: function(data){
  498. var html='';
  499. for(var i=0;i<data.invoiceTrainingList.length;i++){
  500. html +='<option value="'+data.invoiceTrainingList[i].itidKey+'">'+data.invoiceTrainingList[i].trainDate+'&nbsp;'+data.invoiceTrainingList[i].trainName+'</option>';
  501. }
  502. $("select[receiptInvoieSelect]").html(html);
  503. },
  504. error:function(err){}
  505. });
  506. });
  507. //h5文件上传
  508. var numFilesUploaded=0;
  509. $("input[enclosurFile]").change(function() {
  510. var form_data = new FormData();
  511. var file_data = $(this).prop("files")[0];
  512. form_data.append("Filename", file_data.name);
  513. form_data.append("Filedata", file_data);
  514. $.ajax({
  515. type: "POST",
  516. url: "/swfupload",
  517. dataType : "json",
  518. processData: false, // 注意:让jQuery不要处理数据
  519. contentType: false, // 注意:让jQuery不要设置contentType
  520. data: form_data
  521. }).success(function(msg) {
  522. var status = document.getElementById("divStatus");
  523. numFilesUploaded+=1;
  524. status.innerHTML = file_data.name+"上传成功 <br/>"+numFilesUploaded+" 个文件已上传.";
  525. var en=$('#enclosurName').val();
  526. if (en!='')
  527. $('#enclosurName').val(en+'-'+msg.filename);
  528. else
  529. $('#enclosurName').val(msg.filename);
  530. //页面展示上传内容
  531. var tr = document.createElement("tr");
  532. tr.id=msg.id;
  533. var td1 = document.createElement("td");
  534. td1.innerHTML = '<a href="#" target="_blank">'+file_data.name+'</a>';
  535. var td2 = document.createElement("td");
  536. td2.innerHTML = toDecimal2(file_data.size/1024)+'kb';
  537. var td3 = document.createElement("td");
  538. td3.innerHTML = '<a href="javascript:void(0)" onclick="delEnclosurName(\''+msg.filename+'\',\''+msg.id+'\')" >删除</a>';
  539. tr.appendChild(td1);
  540. tr.appendChild(td2);
  541. tr.appendChild(td3);
  542. var kt=document.getElementById('KT');
  543. if(kt!=null)
  544. kt.appendChild(tr);
  545. }).fail(function(msg) {
  546. //console.log(msg);
  547. });
  548. });
  549. })
  550. function delEnclosurByKey(id){
  551. var url = "/ajaxRemEnclousur";
  552. $.ajax({
  553. url : url,
  554. type : "post",
  555. cache : false,
  556. dataType : "json",
  557. data : {
  558. key : id
  559. },
  560. global : true,
  561. success : function(data) {
  562. if (data.status == 1) {
  563. $('#'+id).remove();
  564. }
  565. },
  566. error : function(err) {
  567. }
  568. });
  569. }
  570. function toDecimal2(x) {
  571. var f = parseFloat(x);
  572. if (isNaN(f)) {
  573. return false;
  574. }
  575. var f = Math.round(x*100)/100;
  576. var s = f.toString();
  577. var rs = s.indexOf('.');
  578. if (rs < 0) {
  579. rs = s.length;
  580. s += '.';
  581. }
  582. while (s.length <= rs + 2) {
  583. s += '0';
  584. }
  585. return s;
  586. }
  587. function delEnclosurName(name,id){
  588. var en=$('#enclosurName').val();
  589. var newName=en.replace(name,'');
  590. $('#enclosurName').val(newName);
  591. $('#'+id).remove();
  592. }
  593. function selectToolTipCl(name){
  594. var e = is_ie ? event : selectToolTipCl.caller.arguments[0];
  595. obj = is_ie ? e.srcElement : e.target;
  596. var arr = document.getElementsByName(name);
  597. var k = arr.length;
  598. for ( var i = 0; i < k; i++) {
  599. arr[i].checked = obj.checked;
  600. }
  601. $('#addToolTag').hide();
  602. }
  603. function selectTagCl(name){
  604. var e = is_ie ? event : selectTagCl.caller.arguments[0];
  605. obj = is_ie ? e.srcElement : e.target;
  606. var arr = document.getElementsByName(name);
  607. var k = arr.length;
  608. for ( var i = 0; i < k; i++) {
  609. arr[i].checked = obj.checked;
  610. }
  611. }
  612. function checkall(name) {
  613. var e = is_ie ? event : checkall.caller.arguments[0];
  614. obj = is_ie ? e.srcElement : e.target;
  615. var arr = document.getElementsByName(name);
  616. var k = arr.length;
  617. for ( var i = 0; i < k; i++) {
  618. arr[i].checked = obj.checked;
  619. }
  620. }
  621. if (is_ie)
  622. document.documentElement.addBehavior("#default#userdata");
  623. var userAgent = navigator.userAgent.toLowerCase();
  624. var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);