You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

306 lines
7.5 KiB

  1. var org_id = '';
  2. var current = '1';
  3. var batch_id = '';
  4. var status = '';
  5. var page_size = '10';
  6. var currpage_page = '1';
  7. window.onload = function() {
  8. httpBaseInfo();
  9. }
  10. function httpBaseInfo() {
  11. let data = {
  12. type: 'des_ordersource',
  13. ordersource: ''
  14. }
  15. $.ajax({
  16. url: $$.base_api + 'st-xm/control.php',
  17. data: data,
  18. dataType: 'json',
  19. type: 'post',
  20. async: false,
  21. success: res_data => {
  22. $$.ZZLog(res_data);
  23. if(0 != res_data.code) {
  24. $$.alert(res_data.info);
  25. } else {
  26. let org_list = res_data.list;
  27. let temp_html = `<option value="0">请选择</option>`;
  28. org_list.forEach((dict, index) => {
  29. temp_html += `<option value="${dict.org_id}">${dict.org_name}</option>`
  30. });
  31. $('#org_list').html(temp_html);
  32. $('#org_list').comboSelect();
  33. $$.loading();
  34. $$.delay(httpFirstData, 10);
  35. // httpFirstData();
  36. }
  37. },
  38. error: (error) => {
  39. $$.alert($$.infoApiError);
  40. }
  41. })
  42. }
  43. function httpFirstData() {
  44. org_id = $('#org_list').val();
  45. batch_id = $('#amount_id').val();
  46. status = $('#status_type').val();
  47. let first_current = '1';
  48. let tp = 'payment_getBalance';
  49. let data = { tp, current_page: first_current, page_size, org_id, batch_id, status };
  50. $.ajax({
  51. type: "post",
  52. url: $$.base_api + 'application/financeManager/index.php',
  53. async: false,
  54. dataType: 'json',
  55. data: data,
  56. success: res_data => {
  57. $$.closeLoading();
  58. $$.ZZLog(res_data);
  59. if('0' != res_data.code) {
  60. $$.alert(res_data.info);
  61. } else {
  62. let total_page = res_data.data.page.total_page;
  63. let order_list = res_data.data.order_list;
  64. let temp_html = '';
  65. order_list.forEach((dict, index) => {
  66. temp_html += replaceOrderList(dict);
  67. });
  68. if(order_list.length <= 0) {
  69. var html = `<tr style="text-align: center;">
  70. <td style="color: #666;" colspan="8">无查询结果</td>
  71. </tr>`;
  72. $('#order_list').html(html);
  73. } else {
  74. $('#order_list').html(temp_html);
  75. }
  76. if(total_page == '0') {
  77. $('#page_order_list').hide();
  78. } else {
  79. createPage(first_current, total_page);
  80. $('#page_order_list').show();
  81. }
  82. $('#order_list').show();
  83. addHoverEvent();
  84. }
  85. },
  86. error: error => {
  87. $$.closeLoading();
  88. $$.alert($$.infoApiError);
  89. }
  90. });
  91. }
  92. function replaceOrderList(dict) {
  93. let str = '';
  94. switch(dict.status) {
  95. case '1': //待核对
  96. str = `<div><button type="button" class="btn btn-link btn-xs" onclick="rightCheck(${dict.id})">确认核对</button><button type="button" class="btn btn-link btn-xs" onclick="cancelBill(${dict.id})">取消对账</button><button type="button" class="btn btn-link btn-xs" onclick="downloadBill(${dict.id})">下载账单</button></div>`;
  97. break;
  98. case '2': //待结算
  99. str = `<div><button type="button" class="btn btn-link btn-xs" onclick="rightSettlement(${dict.id})">确认结算</button><button type="button" class="btn btn-link btn-xs" onclick="downloadBill(${dict.id})">下载账单</button></div>`;
  100. break;
  101. case '3': //已结算
  102. str = `<button type="button" class="btn btn-link btn-xs" onclick="downloadBill(${dict.id})">下载账单</button></div>`;
  103. break;
  104. case '4': //已取消
  105. str = `<button type="button" class="btn btn-link btn-xs" onclick="downloadBill(${dict.id})">下载账单</button></div>`;
  106. break;
  107. default:
  108. break;
  109. }
  110. let n_dict = JSON.stringify(dict);
  111. let html = `<tr dict='${n_dict}'>
  112. <td>
  113. <div>${dict.start_date}</div>
  114. <div>${dict.end_date}</div>
  115. </td>
  116. <td>${dict.batch_id}</td>
  117. <td>${dict.sett_frequency}</td>
  118. <td><span class="org_info" style="cursor:pointer;">${dict.org_name}</span></td>
  119. <td style="color:red">${dict.price}</td>
  120. <td style="color:red">${dict.reparations_price}</td>
  121. <td>${dict.status_des}</td>
  122. <td>${str}</td>
  123. </tr>`
  124. return html;
  125. }
  126. function createPage(currpage, totalpage) {
  127. $('#page_order_list').createPage({
  128. pageCount: totalpage,
  129. current: currpage,
  130. turndown: 'true',
  131. backFn: function(p) {
  132. currpage_page = p;
  133. $$.loading();
  134. $$.delay(httpData, 10);
  135. }
  136. });
  137. }
  138. function httpData() {
  139. let tp = 'payment_getBalance';
  140. let data = { tp, current_page: currpage_page, page_size, org_id, batch_id, status };
  141. $.ajax({
  142. type: "post",
  143. url: $$.base_api + 'application/financeManager/index.php',
  144. async: false,
  145. dataType: 'json',
  146. data: data,
  147. success: res_data => {
  148. $$.ZZLog(res_data);
  149. $$.closeLoading();
  150. if('0' != res_data.code) {
  151. $$.alert(res_data.info);
  152. } else {
  153. let order_list = res_data.data.order_list;
  154. let temp_html = '';
  155. order_list.forEach((dict, index) => {
  156. temp_html += replaceOrderList(dict);
  157. });
  158. if(order_list.length <= 0) {
  159. var html = `<tr style="text-align: center;">
  160. <td style="color: #666;" colspan="8">无查询结果</td>
  161. </tr>`;
  162. $('#order_list').html(html);
  163. } else {
  164. $('#order_list').html(temp_html);
  165. }
  166. $('#order_list').show();
  167. addHoverEvent();
  168. }
  169. },
  170. error: error => {
  171. $$.closeLoading();
  172. $$.alert($$.infoApiError);
  173. }
  174. });
  175. }
  176. function searchDidClick() {
  177. $$.loading();
  178. $$.delay(httpFirstData, 10);
  179. }
  180. function addHoverEvent() {
  181. $('.org_info').on('mouseover mouseout', function(event) {
  182. if(event.type == 'mouseover') {
  183. let mouthLeft = $(this).parent().offset().left;
  184. let mouthTop = $(this).parent().offset().top;
  185. let td_height = parseInt($(this).parent().css('height').replace('px', ''));
  186. $('#bank_info').css('top', mouthTop - 130 + 'px');
  187. $('#bank_info').css('left', parseInt(mouthLeft + 100) + 'px');
  188. let dict = $(this).parent().parent().attr('dict');
  189. dict = JSON.parse(dict);
  190. $('#cycle').text(dict.sett_frequency);
  191. $('#bank_name').text(dict.account_bank);
  192. $('#bank_id').text(dict.batch_id);
  193. $('#id_name').text(dict.bank_name);
  194. $('#bank_info').show();
  195. } else if(event.type == 'mouseout') {
  196. $('#bank_info').hide();
  197. }
  198. })
  199. }
  200. //确认核对
  201. function rightCheck(id) {
  202. $$.confirm('是否确认已核对完该对账单?', function() {
  203. let data = { tp: 'payment_confirmedBalance', id: id };
  204. $.ajax({
  205. type: "post",
  206. url: $$.base_api + 'application/financeManager/index.php',
  207. async: false,
  208. dataType: 'json',
  209. data: data,
  210. success: res_data => {
  211. $$.ZZLog(res_data);
  212. if('0' != res_data.code) {
  213. $$.alert(res_data.info);
  214. } else {
  215. $$.loading();
  216. httpData();
  217. }
  218. },
  219. error: error => {
  220. $$.alert($$.infoApiError);
  221. }
  222. });
  223. }, function() {
  224. }, function() {
  225. });
  226. }
  227. //取消对账
  228. function cancelBill(id) {
  229. let data = { tp: 'payment_cancelBalance', id: id };
  230. $.ajax({
  231. type: "post",
  232. url: $$.base_api + 'application/financeManager/index.php',
  233. async: false,
  234. dataType: 'json',
  235. data: data,
  236. success: res_data => {
  237. $$.ZZLog(res_data);
  238. if('0' != res_data.code) {
  239. $$.alert(res_data.info);
  240. } else {
  241. $$.loading();
  242. httpData();
  243. }
  244. },
  245. error: error => {
  246. $$.alert($$.infoApiError);
  247. }
  248. });
  249. }
  250. //确认结算
  251. function rightSettlement(id) {
  252. $$.confirm('是否确认已完成打款操作?', function() {
  253. let data = { tp: 'payment_balancing', id: id };
  254. $.ajax({
  255. type: "post",
  256. url: $$.base_api + 'application/financeManager/index.php',
  257. async: false,
  258. dataType: 'json',
  259. data: data,
  260. success: res_data => {
  261. $$.ZZLog(res_data);
  262. if('0' != res_data.code) {
  263. $$.alert(res_data.info);
  264. } else {
  265. $$.loading();
  266. httpData();
  267. }
  268. },
  269. error: error => {
  270. $$.alert($$.infoApiError);
  271. }
  272. });
  273. }, function() {
  274. }, function() {
  275. })
  276. }
  277. //下载账单
  278. function downloadBill(id) {
  279. window.open($$.base_api + 'application/financeManager/index.php?tp=payment_excelBalance&id=' + id);
  280. }