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.
 
 
 
 

356 lines
8.9 KiB

  1. $(document).ready(function() {
  2. $(".form_date").datetimepicker({
  3. format: 'yyyy-mm-dd',
  4. autoclose: true,
  5. minView: 2,
  6. pickerPosition: "bottom-left"
  7. });
  8. });
  9. var start_date = '';
  10. var end_date = '';
  11. var org_id = '';
  12. var date_type = '1';
  13. var more_search = '';
  14. var page_size = '10';
  15. var currpage_page = '1';
  16. window.onload = function() {
  17. httpBaseInfo();
  18. }
  19. function httpBaseInfo() {
  20. let data = {
  21. type: 'des_ordersource',
  22. ordersource: ''
  23. }
  24. $.ajax({
  25. url: $$.base_api + 'st-xm/control.php',
  26. data: data,
  27. dataType: 'json',
  28. type: 'post',
  29. async: false,
  30. success: res_data => {
  31. $$.ZZLog(res_data);
  32. if(0 != res_data.code) {
  33. $$.alert(res_data.info);
  34. } else {
  35. let org_list = res_data.list;
  36. let temp_html = `<option value="0">请选择</option>`;
  37. org_list.forEach((dict, index) => {
  38. temp_html += `<option value="${dict.org_id}">${dict.org_name}</option>`
  39. });
  40. $('#org_list').html(temp_html);
  41. $('#org_list').comboSelect();
  42. // $$.loading();
  43. $$.delay(httpFirstData, 10);
  44. // httpFirstData();
  45. }
  46. },
  47. error: (error) => {
  48. $$.alert($$.infoApiError);
  49. }
  50. });
  51. let data1 = { tp: 'reparations_getMemoArr' };
  52. $.ajax({
  53. url: $$.base_api + 'application/financeManager/index.php',
  54. data: data1,
  55. dataType: 'json',
  56. type: 'post',
  57. async: false,
  58. success: res_data => {
  59. $$.ZZLog(res_data);
  60. if(0 != res_data.code) {
  61. $$.alert(res_data.info);
  62. } else {
  63. let list = res_data.list;
  64. let temp_html = `<option value="0">请选择</option>`;
  65. list.forEach((dict, index) => {
  66. temp_html += `<option value="${dict.memo_id}" info="${dict.memo}">${dict.memo_title}</option>`
  67. });
  68. $('#cancel_reason').html(temp_html);
  69. $('#cancel_reason').comboSelect();
  70. }
  71. },
  72. error: (error) => {
  73. $$.alert($$.infoApiError);
  74. }
  75. });
  76. }
  77. function httpFirstData() {
  78. start_date = $('#beforeDate').val();
  79. end_date = $('#currentDate').val();
  80. org_id = $('#org_list').val();
  81. more_search = $('#more_search').val();
  82. let first_current = '1';
  83. let tp = 'reparations_getList';
  84. let data = { start_date, end_date, org_id, more_search, current_page: first_current, page_size, tp, date_type }
  85. $.ajax({
  86. type: "post",
  87. url: $$.base_api + 'application/financeManager/index.php',
  88. async: false,
  89. dataType: 'json',
  90. data: data,
  91. success: res_data => {
  92. $$.closeLoading();
  93. $$.ZZLog(res_data);
  94. if('0' != res_data.code) {
  95. $$.alert(res_data.info);
  96. } else {
  97. let total_page = res_data.data.page.total_page;
  98. let order_list = res_data.data.order_list;
  99. let temp_html = '';
  100. order_list.forEach((dict, index) => {
  101. temp_html += replaceOrderList(dict);
  102. });
  103. if(order_list.length <= 0) {
  104. var html = `<tr style="text-align: center;">
  105. <td style="color: #666;" colspan="8">无查询结果</td>
  106. </tr>`;
  107. $('#order_list').html(html);
  108. } else {
  109. $('#order_list').html(temp_html);
  110. }
  111. if(total_page == '0') {
  112. $('#page_order_list').hide();
  113. } else {
  114. createPage(first_current, total_page);
  115. $('#page_order_list').show();
  116. }
  117. $('#order_list').show();
  118. }
  119. },
  120. error: error => {
  121. $$.closeLoading();
  122. $$.alert($$.infoApiError);
  123. }
  124. });
  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 = 'reparations_getList';
  140. let data = { start_date, end_date, org_id, more_search, current_page: currpage_page, page_size, tp, date_type }
  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. }
  168. },
  169. error: error => {
  170. $$.closeLoading();
  171. $$.alert($$.infoApiError);
  172. }
  173. });
  174. }
  175. function searchDidClick() {
  176. $$.loading();
  177. $$.delay(httpFirstData, 10);
  178. }
  179. function replaceOrderList(dict) {
  180. let n_dict = JSON.stringify(dict);
  181. let html = `<tr dict='${n_dict}'>
  182. <td>${dict.create_time}</td>
  183. <td>${dict.order_id}</td>
  184. <td>${dict.PARENT_PROD_NAME}</td>
  185. <td>${dict.SUPPLIER_NAME}</td>
  186. <td>${dict.reparations}</td>
  187. <td>${dict.date}</td>
  188. <td>${dict.memo}</td>
  189. <td><div><button type="button" class="btn btn-link btn-xs" data-toggle="modal" data-target=".bs-example-modal-lg" onclick="addIndemnity(${dict.order_id},'edit')">编辑</button><button type="button" class="btn btn-link btn-xs" onclick="delDidClick(${dict.order_id})">删除</button></div></td>
  190. </tr>`
  191. return html;
  192. }
  193. function addIndemnity(id, status) {
  194. if(status == 'add') {
  195. $('#div_title').text('添加赔款');
  196. $('#prod_info').html('请输入订单号进行查询');
  197. $('#reparation_div').val('');
  198. $('#reparation_date').val('');
  199. $('#order_div').val('');
  200. $('#reason').val('');
  201. $('#div_search').show();
  202. $('#order_div').removeAttr('readonly');
  203. $('#order_div').css('border-width', '2');
  204. $('#cancel_reason').val('0');
  205. $('#cancel_reason').comboSelect();
  206. } else {
  207. $('#div_title').text('编辑赔款');
  208. // $('#cancel_reason').val('0');
  209. // $('#cancel_reason').comboSelect();
  210. searchOrderById(id);
  211. $('#div_search').hide();
  212. $('#order_div').val(id);
  213. $('#order_div').attr('readonly', 'readonly');
  214. $('#order_div').css('border-width', '0');
  215. }
  216. }
  217. //赔款订单查询 -- 新增
  218. function divSearchDidClick() {
  219. let order_id = $('#order_div').val();
  220. searchOrderById(order_id);
  221. }
  222. //根据订单查询
  223. function searchOrderById(order_id) {
  224. let tp = 'reparations_getOrderInfo';
  225. let data = { order_id, tp };
  226. $.ajax({
  227. type: "post",
  228. url: $$.base_api + 'application/financeManager/index.php',
  229. async: false,
  230. dataType: 'json',
  231. data: data,
  232. success: res_data => {
  233. $$.ZZLog(res_data);
  234. if('0' != res_data.code) {
  235. $$.alert('未查询到订单');
  236. } else {
  237. $('#m_save').show();
  238. let data = res_data.data;
  239. $('#prod_info').html(data.PARENT_PROD_NAME);
  240. $('#reparation_div').val(data.reparations);
  241. $('#reparation_date').val(data.date);
  242. $('#reason').val(data.memo);
  243. // console.log(data.memo_title);
  244. // if (data.memo_title == '') {
  245. // console.log($('#cancel_reason').find("option:selected").text());
  246. // $('#cancel_reason option[text=请选择]').attr("selected",'selected');
  247. // } else{
  248. //
  249. // console.log($('#cancel_reason').find("option:selected").text());
  250. // $("#cancel_reason option[text="+data.memo_title+"]").attr("selected",'selected');
  251. // }
  252. // $("#cancel_reason option[value="+data.memo_id+"]").attr("selected",true);
  253. $('#cancel_reason').val(data.memo_id);
  254. $('#cancel_reason').comboSelect();
  255. }
  256. },
  257. error: error => {
  258. $$.alert('未查询到订单');
  259. }
  260. });
  261. }
  262. //保存
  263. function saveDidClick() {
  264. let order_id = $('#order_div').val();
  265. let reparations = $('#reparation_div').val();
  266. let m_date = $('#reparation_date').val();
  267. let memo = $('#reason').val();
  268. let memo_title = $('#cancel_reason').find("option:selected").text();
  269. let memo_id = $('#cancel_reason').val();
  270. let tp = 'reparations_setReparations';
  271. if(memo == '') {
  272. $$.alert('赔款原因不能为空');
  273. return;
  274. }
  275. let data = { tp, order_id, reparations, date: m_date, memo, memo_id, memo_title };
  276. $.ajax({
  277. type: "post",
  278. url: $$.base_api + 'application/financeManager/index.php',
  279. async: false,
  280. dataType: 'json',
  281. data: data,
  282. success: res_data => {
  283. $$.ZZLog(res_data);
  284. if('0' != res_data.code) {
  285. $$.alert('设置赔款失败');
  286. } else {
  287. $('#indemnity_info').modal('hide');
  288. httpData();
  289. $$.alert('设置赔款成功');
  290. }
  291. },
  292. error: error => {
  293. $$.alert('设置赔款成功');
  294. }
  295. });
  296. }
  297. function changeOrder() {
  298. $('#m_save').hide();
  299. $('#prod_info').html('请输入订单号进行查询');
  300. $('#reparation_div').val('');
  301. $('#reparation_date').val('');
  302. $('#reason').val('');
  303. }
  304. function delDidClick(order_id) {
  305. $$.confirm('是否确定删除赔款?', function() {
  306. let tp = 'reparations_del';
  307. let data = { order_id, tp };
  308. $.ajax({
  309. type: "post",
  310. url: $$.base_api + 'application/financeManager/index.php',
  311. async: false,
  312. dataType: 'json',
  313. data: data,
  314. success: res_data => {
  315. $$.ZZLog(res_data);
  316. if('0' != res_data.code) {
  317. $$.alert('删除失败');
  318. } else {
  319. $$.alert('删除成功');
  320. httpData();
  321. }
  322. },
  323. error: error => {
  324. $$.alert('删除失败');
  325. }
  326. });
  327. }, function() {
  328. }, function() {
  329. })
  330. }