receipt.js 16 KB

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