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.
 
 
 
 

308 lines
7.6 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 = 'gathering_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:#0db910">${dict.price}</td>
  120. <td style="color:red">${dict.commission_price}</td>
  121. <td style="color:red">${dict.reparations_price}</td>
  122. <td>${dict.status_des}</td>
  123. <td>${str}</td>
  124. </tr>`
  125. return html;
  126. }
  127. function createPage(currpage, totalpage) {
  128. $('#page_order_list').createPage({
  129. pageCount: totalpage,
  130. current: currpage,
  131. turndown: 'true',
  132. backFn: function(p) {
  133. currpage_page = p;
  134. $$.loading();
  135. $$.delay(httpData, 10);
  136. }
  137. });
  138. }
  139. function httpData() {
  140. let tp = 'gathering_getBalance';
  141. let data = { tp, current_page: currpage_page, page_size, org_id, batch_id, status };
  142. $.ajax({
  143. type: "post",
  144. url: $$.base_api + 'application/financeManager/index.php',
  145. async: false,
  146. dataType: 'json',
  147. data: data,
  148. success: res_data => {
  149. $$.ZZLog(res_data);
  150. $$.closeLoading();
  151. if('0' != res_data.code) {
  152. $$.alert(res_data.info);
  153. } else {
  154. let order_list = res_data.data.order_list;
  155. let temp_html = '';
  156. order_list.forEach((dict, index) => {
  157. temp_html += replaceOrderList(dict);
  158. });
  159. if(order_list.length <= 0) {
  160. var html = `<tr style="text-align: center;">
  161. <td style="color: #666;" colspan="8">无查询结果</td>
  162. </tr>`;
  163. $('#order_list').html(html);
  164. } else {
  165. $('#order_list').html(temp_html);
  166. }
  167. $('#order_list').show();
  168. addHoverEvent();
  169. }
  170. },
  171. error: error => {
  172. $$.closeLoading();
  173. $$.alert($$.infoApiError);
  174. }
  175. });
  176. }
  177. function searchDidClick() {
  178. $$.loading();
  179. $$.delay(httpFirstData, 10);
  180. }
  181. function addHoverEvent() {
  182. $('.org_info').on('mouseover mouseout', function(event) {
  183. if(event.type == 'mouseover') {
  184. let mouthLeft = $(this).parent().offset().left;
  185. let mouthTop = $(this).parent().offset().top;
  186. let td_height = parseInt($(this).parent().css('height').replace('px', ''));
  187. $('#bank_info').css('top', mouthTop - 130 + 'px');
  188. $('#bank_info').css('left', parseInt(mouthLeft + 100) + 'px');
  189. let dict = $(this).parent().parent().attr('dict');
  190. dict = JSON.parse(dict);
  191. $('#cycle').text(dict.sett_frequency);
  192. $('#bank_name').text(dict.account_bank);
  193. $('#bank_id').text(dict.batch_id);
  194. $('#id_name').text(dict.bank_name);
  195. $('#bank_info').show();
  196. } else if(event.type == 'mouseout') {
  197. $('#bank_info').hide();
  198. }
  199. })
  200. }
  201. //确认核对
  202. function rightCheck(id) {
  203. $$.confirm('是否确认已核对完该对账单?', function() {
  204. let data = { tp: 'gathering_confirmedBalance', id: id };
  205. $.ajax({
  206. type: "post",
  207. url: $$.base_api + 'application/financeManager/index.php',
  208. async: false,
  209. dataType: 'json',
  210. data: data,
  211. success: res_data => {
  212. $$.ZZLog(res_data);
  213. if('0' != res_data.code) {
  214. $$.alert(res_data.info);
  215. } else {
  216. $$.loading();
  217. httpData();
  218. }
  219. },
  220. error: error => {
  221. $$.alert($$.infoApiError);
  222. }
  223. });
  224. }, function() {
  225. }, function() {
  226. });
  227. }
  228. //取消对账
  229. function cancelBill(id) {
  230. let data = { tp: 'gathering_cancelBalance', id: id };
  231. $.ajax({
  232. type: "post",
  233. url: $$.base_api + 'application/financeManager/index.php',
  234. async: false,
  235. dataType: 'json',
  236. data: data,
  237. success: res_data => {
  238. $$.ZZLog(res_data);
  239. if('0' != res_data.code) {
  240. $$.alert(res_data.info);
  241. } else {
  242. $$.loading();
  243. httpData();
  244. }
  245. },
  246. error: error => {
  247. $$.alert($$.infoApiError);
  248. }
  249. });
  250. }
  251. //确认结算
  252. function rightSettlement(id) {
  253. $$.confirm('是否确认已完成打款操作?', function() {
  254. let data = { tp: 'gathering_balancing', id: id };
  255. $.ajax({
  256. type: "post",
  257. url: $$.base_api + 'application/financeManager/index.php',
  258. async: false,
  259. dataType: 'json',
  260. data: data,
  261. success: res_data => {
  262. $$.ZZLog(res_data);
  263. if('0' != res_data.code) {
  264. $$.alert(res_data.info);
  265. } else {
  266. $$.loading();
  267. httpData();
  268. }
  269. },
  270. error: error => {
  271. $$.alert($$.infoApiError);
  272. }
  273. });
  274. }, function() {
  275. }, function() {
  276. });
  277. }
  278. //下载账单
  279. function downloadBill(id) {
  280. window.open($$.base_api + 'application/financeManager/index.php?tp=gathering_excelBalance&id=' + id);
  281. }