receipt.js 17 KB

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