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.
 
 
 
 

233 lines
5.7 KiB

  1. /*
  2. yimazsq
  3. 10月31号
  4. 申请报账
  5. * */
  6. var urlstr = base_api + 'index.php';
  7. var listHTML = '';
  8. window.onload = function (){
  9. //请求相关配置信息
  10. reloadData();
  11. }
  12. //页面开始加载配置信息
  13. function reloadData(){
  14. var run_id = getPar('run_id');
  15. var bus_order_id = getPar('bus_order_id');
  16. var tp = 'finance_groupFinance_getAddFinanceBase';
  17. var data = {
  18. tp : tp,
  19. run_id : run_id,
  20. bus_order_id : bus_order_id
  21. };
  22. //请求相关配置信息
  23. $.ajax({
  24. url: urlstr, //请求地址
  25. data: data,
  26. type: "post",
  27. dataType: "json",
  28. async: false,
  29. success: function(data) {
  30. if(data.code == "0") {
  31. ZZLog(data);
  32. replaceData(data);
  33. } else {
  34. ZZAlertInfo(data.info);
  35. }
  36. },
  37. error:function(e){
  38. ZZLog(e);
  39. }
  40. });
  41. }
  42. //替换相关的配置信息
  43. function replaceData(data){
  44. var object_list = data.fee_type;
  45. var object_priceHTML = '<option value="0">请选择</option>';
  46. for(var i = 0; i < object_list.length; i++) {
  47. var str = '<option value="0">请选择</option>';
  48. str = str.replace('0', object_list[i].id);
  49. str = str.replace('请选择', object_list[i].type_name);
  50. object_priceHTML += str;
  51. }
  52. $('.object_price').html(object_priceHTML);
  53. var pay_list = data.settle_type;
  54. var payHTML = '<option value="-1">请选择</option>';
  55. for(var i = 0; i < pay_list.length; i++) {
  56. var str = '<option value="-1">请选择</option>';
  57. str = str.replace('-1', pay_list[i].id);
  58. str = str.replace('请选择', pay_list[i].type_name);
  59. payHTML += str;
  60. }
  61. $('.pay_style').html(payHTML);
  62. var unit_list = data.supply_list;
  63. var unitHTML = '<option value="0">请选择</option>';
  64. for(var i = 0; i < unit_list.length; i++) {
  65. var str = '<option value="0">请选择</option>';
  66. str = str.replace('0', unit_list[i].id);
  67. str = str.replace('请选择', unit_list[i].supplier_name);
  68. unitHTML += str;
  69. }
  70. $('.unit').html(unitHTML);
  71. listHTML = $('#list').html();
  72. $('.unit').comboSelect();
  73. //替换头部信息
  74. $('.date').html(data.run_bus_info.run_date);
  75. var temp_str = data.run_bus_info.line_code_name;
  76. temp_str = temp_str.replace(',','&nbsp;&nbsp;&nbsp;&nbsp;')
  77. $('.line_code').html(temp_str);
  78. $('.people_count').html(data.run_bus_info.saled_count+'人');
  79. }
  80. //新增一条信息
  81. function addInfo(){
  82. $('#list').prepend(listHTML);
  83. $('.unit').comboSelect();
  84. }
  85. //删除一条
  86. function delBtnDidClicked(obj){
  87. $(obj).closest('.list_info').remove();
  88. }
  89. //保存
  90. function saveBtnDidClicked(){
  91. var infostr = '';
  92. var infostr_arr=[];
  93. $('.list_info').each(function(index,dom){
  94. //收支
  95. var payments = $(this).children().find('.payments').val();
  96. //费用科目
  97. var object_price = $(this).children().find('.object_price').val();
  98. //结算单位
  99. var unit = $(this).children().find('.unit').val();
  100. //单价
  101. var price = $(this).children().find('.price').val();
  102. //数量
  103. var count = $(this).children().find('.count').val();
  104. //金额小计
  105. var total_price = $(this).children().find('.total_price').val();
  106. //报账日期
  107. var bill_date = $(this).children().find('.Wdate').val();
  108. //经办人
  109. var handle_people = $(this).children().find('.handle_people').val();
  110. //结算方式
  111. var pay_style = $(this).children().find('.pay_style').val();
  112. //签单号
  113. var sign_no = $(this).children().find('.sign_no').val();
  114. //备注
  115. var remarks = $(this).children().find('.remarks').val();
  116. if (object_price == '0') {
  117. ZZAlertInfo('请完善费用科目的相关报账信息!');
  118. return false;
  119. }
  120. if (!unit) {
  121. ZZAlertInfo('请完善结算单位的相关报账信息!');
  122. return false;
  123. }
  124. if (!price) {
  125. ZZAlertInfo('请完善相关报账的单价信息!',function(){
  126. $(dom).children().find('.price').focus();
  127. });
  128. return false;
  129. }
  130. if (!count) {
  131. ZZAlertInfo('请完善相关报账的数量信息!',function(){
  132. $(dom).children().find('.count').focus();
  133. });
  134. return false;
  135. }
  136. if (!total_price) {
  137. ZZAlertInfo('请完善相关报账的总价信息!',function(){
  138. $(dom).children().find('.total_price').focus();
  139. });
  140. return false;
  141. }
  142. if (!bill_date) {
  143. ZZAlertInfo('请选择相关报账信息的日期!');
  144. return false;
  145. }
  146. if (!handle_people) {
  147. ZZAlertInfo('请填写相关报账信息的经办人!',function(){
  148. $(dom).children().find('.handle_people').focus();
  149. });
  150. return false;
  151. }
  152. if (pay_style == '-1') {
  153. ZZAlertInfo('请选择相关报账信息的结算方式!');
  154. return false;
  155. }
  156. // if (!sign_no) {
  157. // ZZAlertInfo('请填写相关报账信息的签单号!',function(){
  158. // $(dom).children().find('.sign_no').focus();
  159. // });
  160. // return false;
  161. // }
  162. // if (!remarks) {
  163. // ZZAlertInfo('写相关报账信息的备注不能为空!',function(){
  164. // $(dom).children().find('.remarks').focus();
  165. // });
  166. // return false;
  167. // }
  168. var str = '{'+payments+','+object_price+','+unit+','+price+','+count+','+total_price+','+bill_date+','+handle_people+','+pay_style+','+sign_no+','+remarks+'}';
  169. if (str != '') {
  170. infostr_arr.push(str);
  171. // infostr += str;
  172. }
  173. })
  174. infostr=infostr_arr.join('');
  175. if(''==infostr || $('.list_info').length>infostr_arr.length){
  176. return false;
  177. }
  178. var list_count = $('#list').children().length;
  179. if (list_count == 0) {
  180. ZZAlertInfo('无相关的报账信息!');
  181. return false;
  182. }
  183. var run_id = getPar('run_id');
  184. var bus_order_id = getPar('bus_order_id');
  185. var data = {
  186. tp : 'finance_groupFinance_addFinance',
  187. run_id : run_id,
  188. finance_str : infostr,
  189. bus_order_id : bus_order_id
  190. }
  191. //申请报账的提交
  192. ZZLog(data);
  193. $.ajax({
  194. url: urlstr,
  195. data: data,
  196. type: "post",
  197. dataType: "json",
  198. async: false,
  199. success: function(data) {
  200. if(data.code == "0") {
  201. ZZAlertInfo(data.info);
  202. } else {
  203. ZZAlertInfo(data.info);
  204. }
  205. },
  206. error:function(e){
  207. ZZLog(e);
  208. }
  209. });
  210. }