invoice.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. var notify = null;
  2. var isNotifyShowing = false;
  3. var isError = false;
  4. $(function() {
  5. Notification.requestPermission(function(status) {});
  6. // 轮询查找是否有未处理的审批
  7. var permission = Notification.permission;
  8. if (permission === 'granted') {
  9. var interval = setInterval(checkNotify, 90000);//
  10. if (isError) {
  11. clearInterval(interval);
  12. }
  13. }
  14. });
  15. /**
  16. * 获取未审批数量
  17. */
  18. function checkNotify() {
  19. $.ajax({
  20. url: '/ajaxInvoicePushNotice',
  21. type: 'get',
  22. data: '',
  23. dataType: 'json',
  24. error: function() {
  25. console.log('数据错误');
  26. isError = true;
  27. },
  28. success: function(response) {
  29. var isNotice = response.isNotice;
  30. if (isNotice && !isNotifyShowing) {
  31. notify = new Notification("你有发票需要审批", {
  32. // icon: '/global/img/wen.png111',
  33. body: '点击本消息可跳转至审批页',
  34. silent: true
  35. });
  36. notify.onclick = function() {
  37. notify.close();
  38. window.location.href = '/invoiceApproval';
  39. };
  40. notify.onshow = function () {
  41. isNotifyShowing = true;
  42. };
  43. notify.onclose = function () {
  44. isNotifyShowing = false;
  45. };
  46. }
  47. }
  48. });
  49. }
  50. //
  51. function receiptYear(){
  52. var form = $('#up');
  53. $('#year').val($('#Y').val());
  54. form.submit();
  55. }
  56. function sures()
  57. {
  58. if(confirm('请确认核销该发票,核销后不可更改!'))
  59. return true;
  60. else
  61. return false;
  62. }
  63. $(function() {
  64. $('select[node-iryChange]').change(function() {
  65. var year=$(this).val();
  66. var month="All";
  67. var irmMebSea=$('input[data-irmMebSea]').val();
  68. var action = $('#iras').attr("action");
  69. action=encodeURI(action+'/'+year+'/'+month+"/"+irmMebSea);
  70. $('#iras').attr("action",action);
  71. $('#iras').submit();
  72. });
  73. $('select[node-irmChange]').change(function() {
  74. var month=$(this).val();
  75. var year=$('select[node-iryChange]').val();
  76. var irmMebSea=$('input[data-irmMebSea]').val();
  77. var action = $('#iras').attr("action");
  78. action=encodeURI(action+'/'+year+'/'+month+"/"+irmMebSea);
  79. $('#iras').attr("action",action);
  80. $('#iras').submit();
  81. });
  82. /**
  83. * 废弃方法
  84. $('button[node-irmMebSea]').click(function() {
  85. var month=$('select[node-irmChange]').val();
  86. var year=$('select[node-iryChange]').val();
  87. var irmMebSea=$('input[data-irmMebSea]').val();
  88. var action = $('#iras').attr("action");
  89. action=encodeURI(action+'/'+year+'/'+month+"/"+irmMebSea);
  90. $('#iras').attr("action",action);
  91. $('#iras').submit();
  92. });
  93. */
  94. $('input[refreshData=time]').click(function() {
  95. $('#iras').submit();
  96. });
  97. $('button[node-iramMebSea]').click(function() {
  98. var irmMebSea=$('input[data-irmMebSea]').val();
  99. var action = $('#ira').attr("action");
  100. action=encodeURI(action+"/"+irmMebSea);
  101. $('#ira').attr("action",action);
  102. $('#ira').submit();
  103. });
  104. $('a[node-express="untread"]').click(function() {
  105. $('td[node-express="msg"]').html($(this).attr('title'));
  106. });
  107. $("input[name='untreadPost']").click(function() {
  108. $("table[post-box='ture']").hide();
  109. });
  110. $("input[node-untread='post']").click(function() {
  111. //$("table[post-box='ture']").show();
  112. });
  113. $("a[node-approval^='approval']").click(function() {
  114. $("input[name='status']").val($(this).attr("diss-data"));
  115. $("form[name='invoiceApproval']").submit();
  116. });
  117. $("a[node-invoice='droppedInvoice']").click(function() {
  118. $("input[name='droppedIidKey']").val($(this).attr("diss-data"));
  119. });
  120. $("a[node-invoice='untreadInvoice']").click(function() {
  121. $("input[name='untreadIidKey']").val($(this).attr("diss-data"));
  122. });
  123. $('a[bind-receivables="true"]').click(function() {
  124. console.log('ddd');
  125. });
  126. $("button[invoice-search='title']").click(function() {
  127. var title=$("input[name='searchTitle']").val();
  128. if(title==''){
  129. alert('请填写开票单位');
  130. return '';
  131. }
  132. $("div[node-invoiceHtml='true']").html('');
  133. var url = "/ajaxGetInvoiceReceivablesByTitle";
  134. $.ajax({
  135. url : url,
  136. type : "post",
  137. cache : false,
  138. dataType : "json",
  139. data : {
  140. title : title
  141. },
  142. global : true,
  143. success : function(data) {
  144. if (data.status == 1) {
  145. $("div[node-invoiceHtml='true']").html(data.invoiceHtml);
  146. }
  147. },
  148. error : function(err) {
  149. }
  150. });
  151. });
  152. //
  153. $("a[bind-invoice='receivables']").click(function() {
  154. var key = $(this).attr("node-key");
  155. $("input[name='key']").val('');
  156. $("div[node-receivablesHtml='true']").html('');
  157. $("div[node-invoiceHtml='true']").html('');
  158. $("blockquote[node-search='invoice']").hide();
  159. var url = "/ajaxGetInvoiceReceivablesByIrid";
  160. $.ajax({
  161. url : url,
  162. type : "post",
  163. cache : false,
  164. dataType : "json",
  165. data : {
  166. irid : key
  167. },
  168. global : true,
  169. success : function(data) {
  170. if (data.status == 1) {
  171. $("div[node-receivablesHtml='true']").html(data.receivablesHtml);
  172. $("div[node-invoiceHtml='true']").html(data.invoiceHtml);
  173. $("input[name='key']").val(data.irkey);
  174. if(data.isInvoice)
  175. $("blockquote[node-search='invoice']").show();
  176. else
  177. $("blockquote[node-search='invoice']").hide();
  178. } else{
  179. $("input[name='key']").val('');
  180. $("div[node-receivablesHtml='true']").html('');
  181. $("div[node-invoiceHtml='true']").html('');
  182. $("blockquote[node-search='invoice']").hide();
  183. }
  184. },
  185. error : function(err) {
  186. }
  187. });
  188. });
  189. $("a[node-post='express']").click(function() {
  190. var postData = $(this).attr("post-data");
  191. $("input[name='iidKey']").val(postData);
  192. $("div[loading-msg='true']").html("<img src='/global/img/loadIco.gif' />");
  193. var url = "/ajaxGetInvoicePostDetail";
  194. $.ajax({
  195. url : url,
  196. type : "post",
  197. cache : false,
  198. dataType : "json",
  199. data : {
  200. iidKey : postData
  201. },
  202. global : true,
  203. success : function(data) {
  204. if (data.status == 1) {
  205. $("td[recipients-data='true']").html(data.invoiceDetail.recipients);
  206. $("td[recipientsPhone-data='true']").html(data.invoiceDetail.recipientsPhone);
  207. $("td[recipientsAddress-data='true']").html(data.invoiceDetail.recipientsAddress);
  208. $("td[mailItems-data='true']").html(data.invoiceDetail.mailItems);
  209. $("div[loading-msg='true']").html("");
  210. } else
  211. $("div[loading-msg='true']").html("illegal request");
  212. },
  213. error : function(err) {
  214. }
  215. });
  216. });
  217. $("a[node-post='express-msg']").click(function() {
  218. var postData = $(this).attr("post-data");
  219. $("div[loading-msg='express-msg']").html("<img src='/global/img/loadIco.gif' />");
  220. var url = "/ajaxGetInvoicePostDetail";
  221. $.ajax({
  222. url : url,
  223. type : "post",
  224. cache : false,
  225. dataType : "json",
  226. data : {
  227. iidKey : postData
  228. },
  229. global : true,
  230. success : function(data) {
  231. if (data.status == 1) {
  232. $("td[recipients-data='express-msg']").html(data.invoiceDetail.recipients);
  233. $("td[recipientsPhone-data='express-msg']").html(data.invoiceDetail.recipientsPhone);
  234. $("td[recipientsAddress-data='express-msg']").html(data.invoiceDetail.recipientsAddress);
  235. $("td[mailItems-data='express-msg']").html(data.invoiceDetail.mailItems);
  236. $("td[actualItems-data='express-msg']").html(data.invoiceDetail.actualItems);
  237. $("td[expressCompany-data='express-msg']").html(data.invoiceDetail.expressCompany);
  238. $("td[expressNumber-data='express-msg']").html(data.invoiceDetail.expressNumber+"&nbsp;<a target='_blank' href='http://www.kuaidi100.com/chaxun?com="+data.invoiceDetail.expressCom+"&nu="+data.invoiceDetail.expressNumber+"'>点击查询快递信息</a>");
  239. $("div[loading-msg='express-msg']").html("");
  240. } else
  241. $("div[loading-msg='express-msg']").html("illegal request");
  242. },
  243. error : function(err) {
  244. }
  245. });
  246. });
  247. $("select[name='receivablesCategory']").click(function() {
  248. var cid = $("select[name='receivablesCategory'] option:selected").attr("post-data");
  249. var url = "/ajaxGetStaffByCategory";
  250. $.ajax({
  251. url : url,
  252. type : "post",
  253. cache : false,
  254. dataType : "json",
  255. data : {
  256. cid : cid
  257. },
  258. global : true,
  259. success : function(data) {
  260. if (data.status == 1) {
  261. $("select[name='receivablesStaff']").html(data.html);
  262. }
  263. //else
  264. // $("div[loading-msg='true']").html("illegal request");
  265. },
  266. error : function(err) {
  267. }
  268. });
  269. });
  270. $('a[node-receivables="true"]').click(function() {
  271. var postData = $(this).attr("data-key");
  272. var url = "/ajaxGetInvoiceReceivables";
  273. $.ajax({
  274. url : url,
  275. type : "post",
  276. cache : false,
  277. dataType : "json",
  278. data : {
  279. key : postData
  280. },
  281. global : true,
  282. success : function(data) {
  283. if (data.status == 1) {
  284. $("input[name='key']").val(postData);
  285. $("td[node-receivablesSerial]").html(data.detail.receivablesSerial);
  286. $("td[node-inputStaff]").html(data.detail.inputStaff+"&nbsp;"+data.detail.date);
  287. $("td[node-price]").html("<b>"+data.detail.receivablesPrice+"</b>");
  288. $("td[node-message]").html(data.detail.receivablesMessage);
  289. $("td[node-bank]").html(data.detail.receivablesBank);
  290. $("td[node-date]").html(data.detail.receivablesDate);
  291. }
  292. },
  293. error : function(err) {
  294. }
  295. });
  296. });
  297. /**
  298. * 废弃
  299. $('a[node-recording="true"]').click(function() {
  300. var postData = $(this).attr("data-key");
  301. $("input[name='key']").val(postData);
  302. $("input[name='invoiceKey']").val("");
  303. $("p[node-msg='true']").hide();
  304. $("p[node-loading='true']").hide();
  305. $('tbody[data-invoice="myClaim"]').html("");
  306. var url = "/ajaxGetInvoiceByStaff";
  307. $.ajax({
  308. url : url,
  309. type : "post",
  310. cache : false,
  311. dataType : "json",
  312. data : {
  313. key : postData
  314. },
  315. global : true,
  316. success : function(data) {
  317. if (data.status == 1) {
  318. $('tbody[data-invoice="myClaim"]').html(data.html);
  319. }
  320. },
  321. error : function(err) {
  322. }
  323. });
  324. });
  325. */
  326. /**
  327. * 废弃
  328. $('a[node-receivalbles="bind"]').click(function() {
  329. var postData = $(this).attr("diss-data");
  330. $("input[name='key']").val(postData);
  331. $("input[name='invoiceKey']").val("");
  332. $("p[node-msg='true']").hide();
  333. $("p[node-msg='true2']").hide();
  334. $("p[node-loading='true']").hide();
  335. $('tbody[data-invoice="myReceivables"]').html("");
  336. var url = "/ajaxGetReceivalblesByStaff";
  337. $.ajax({
  338. url : url,
  339. type : "post",
  340. cache : false,
  341. dataType : "json",
  342. data : {
  343. key : postData
  344. },
  345. global : true,
  346. success : function(data) {
  347. if (data.status == 1) {
  348. $('tbody[data-invoice="myReceivables"]').html(data.html);
  349. $('tbody[box-enter="true"]').html(data.html2);
  350. if(data.priceStatus == 1){
  351. $('p[node-msg="true"]').html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
  352. $('p[node-msg="true"]').show();
  353. }else if(data.priceStatus == 2&& data.isReceivables != 0){
  354. $('p[node-msg="true"]').html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。");
  355. $('p[node-msg="true"]').show();
  356. }
  357. if(data.isReceivables == 0){
  358. $('p[node-msg="true2"]').html("该发票还没有入账,请先进行选择收款入账");
  359. $('p[node-msg="true2"]').show();
  360. }
  361. }
  362. },
  363. error : function(err) {
  364. }
  365. });
  366. });
  367. */
  368. $("a[node-invoiceReceivables='INFO']").click(function() {
  369. var postData = $(this).attr("data-isKey");
  370. var po='IRTC';
  371. $("div[loading-msg='true']").html("<img src='/global/img/loadIco.gif' />");
  372. var url = "/ajaxGetInvoiceInfoByType";
  373. $.ajax({
  374. url : url,
  375. type : "post",
  376. cache : false,
  377. dataType : "json",
  378. data : {
  379. serial : postData,
  380. type:po
  381. },
  382. global : true,
  383. success : function(data) {
  384. if (data.status == 1) {
  385. $("div[loading-msg='true']").html("");
  386. $("#inKey").val(data.iidKey);
  387. $("#irtc").html(data.html);
  388. $("input[name=receivablesPrice]").val(data.receivablesPrice);
  389. $("input[name=receivablesMessage]").val(data.receivablesMessage);
  390. $("input[name=receivablesDate]").val(data.receivablesDate);
  391. } else
  392. $("div[loading-msg='true']").html("illegal request");
  393. },
  394. error : function(err) {
  395. $("div[loading-msg='true']").html("");
  396. }
  397. });
  398. });
  399. $("a[node-invoiceLoss='INFO']").click(function() {
  400. var postData = $(this).attr("data-isKey");
  401. var po='IRTC';
  402. $("div[loading-msg='true']").html("<img src='/global/img/loadIco.gif' />");
  403. var url = "/ajaxGetInvoiceInfoByType";
  404. $.ajax({
  405. url : url,
  406. type : "post",
  407. cache : false,
  408. dataType : "json",
  409. data : {
  410. serial : postData,
  411. loss:true,
  412. type:po
  413. },
  414. global : true,
  415. success : function(data) {
  416. if (data.status == 1) {
  417. $("div[loading-msg='true']").html("");
  418. $("#inKey").val(data.iidKey);
  419. $("#irtc").html(data.html);
  420. $("input[name=receivablesPrice]").val(data.receivablesPrice);
  421. $("input[name=receivablesMessage]").val(data.receivablesMessage);
  422. $("input[name=receivablesDate]").val(data.receivablesDate);
  423. } else
  424. $("div[loading-msg='true']").html("illegal request");
  425. },
  426. error : function(err) {
  427. $("div[loading-msg='true']").html("");
  428. }
  429. });
  430. });
  431. $("a[node-invoice='INFO']").click(function() {
  432. var postData = $(this).attr("data-isKey");
  433. var type =$(this).attr("data-type");
  434. var po='INVOICE';
  435. if(type=='receivables')
  436. po='RECEIVABLES';
  437. $("div[loading-msg='true']").html("<img src='/global/img/loadIco.gif' />");
  438. var url = "/ajaxGetInvoiceInfoByType";
  439. $.ajax({
  440. url : url,
  441. type : "post",
  442. cache : false,
  443. dataType : "json",
  444. data : {
  445. serial : postData,
  446. type:po
  447. },
  448. global : true,
  449. success : function(data) {
  450. if (data.status == 1) {
  451. $("div[loading-msg='true']").html("");
  452. if(type=='receivables')
  453. $("#nr").html(data.html);
  454. else
  455. $("#nc").html(data.html);
  456. } else
  457. $("div[loading-msg='true']").html("illegal request");
  458. },
  459. error : function(err) {
  460. $("div[loading-msg='true']").html("");
  461. }
  462. });
  463. });
  464. $("a[node-alter]").click(function() {
  465. var postData = $(this).attr("data-isKey");
  466. //$("div[loading-msg='true']").html("<img src='/global/img/loadIco.gif' />");
  467. var url = "/ajaxGetInvoiceReceivablesByStaff";
  468. $.ajax({
  469. url : url,
  470. type : "post",
  471. cache : false,
  472. dataType : "json",
  473. data : {
  474. postData : postData
  475. },
  476. global : true,
  477. success : function(data) {
  478. if (data.status == 1) {
  479. $("input[name='claimKey']").val(postData);
  480. $("select[html-category]").html(data.categoryHtml);
  481. $("select[html-staff]").html(data.staffHtml);
  482. } else
  483. $("div[loading-msg='categoryStaff']").html("illegal request");
  484. },
  485. error : function(err) {
  486. $("div[loading-msg='true']").html("");
  487. }
  488. });
  489. });
  490. $("a[node-unBundLing]").click(function() {
  491. var postData = $(this).attr("data-isKey");
  492. $("input[id='unBundKey']").val(postData);
  493. });
  494. $("a[node-irUpdate]").click(function() {
  495. var postData = $(this).attr("data-isKey");
  496. //$("div[loading-msg='true']").html("<img src='/global/img/loadIco.gif' />");
  497. var url = "/ajaxGetInvoiceReceivablesByStaff";
  498. $.ajax({
  499. url : url,
  500. type : "post",
  501. cache : false,
  502. dataType : "json",
  503. data : {
  504. postData : postData
  505. },
  506. global : true,
  507. success : function(data) {
  508. if (data.status == 1) {
  509. $("input[name='receivablesPrice']").val(data.detail.receivablesPrice);
  510. $("input[name='receivablesMessage']").val(data.detail.receivablesMessage);
  511. $("input[name='receivablesDate']").val(data.detail.receivablesDate);
  512. $("select[html-rbank]").html(data.rbankHtml);
  513. $("input[id='claimuKey']").val(postData);
  514. $("select[html-rcategory]").html(data.categoryHtml);
  515. $("select[html-rstaff]").html(data.staffHtml);
  516. } else
  517. $("div[loading-msg='categoryStaff']").html("illegal request");
  518. },
  519. error : function(err) {
  520. $("div[loading-msg='true']").html("");
  521. }
  522. });
  523. });
  524. $("a[node-post='upEm']").click(function() {
  525. var postData = $(this).attr("post-data");
  526. $("div[loading-msg='express-msg']").html("<img src='/global/img/loadIco.gif' />");
  527. var url = "/ajaxGetInvoicePostDetail";
  528. $.ajax({
  529. url : url,
  530. type : "post",
  531. cache : false,
  532. dataType : "json",
  533. data : {
  534. iidKey : postData
  535. },
  536. global : true,
  537. success : function(data) {
  538. if (data.status == 1) {
  539. $("input[name='iidKey']").val(postData);
  540. $("td[recipients-data='express-msgU']").html(data.invoiceDetail.recipients);
  541. $("td[recipientsPhone-data='express-msgU']").html(data.invoiceDetail.recipientsPhone);
  542. $("td[recipientsAddress-data='express-msgU']").html(data.invoiceDetail.recipientsAddress);
  543. $("td[mailItems-data='express-msgU']").html(data.invoiceDetail.mailItems);
  544. $("textarea[actualItems-data='express-msgU']").val(data.invoiceDetail.actualItems);
  545. $("select[name='express']").html(data.invoiceDetail.eaHtml);
  546. $("input[expressNumber-data='express-msgU']").val(data.invoiceDetail.expressNumber);
  547. $("div[loading-msg='express-msg']").html("");
  548. } else
  549. $("div[loading-msg='express-msg']").html("illegal request");
  550. },
  551. error : function(err) {
  552. }
  553. });
  554. });
  555. })