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.
 
 
 
 

329 lines
8.7 KiB

  1. /*
  2. yimazsq
  3. 11月03号
  4. 修改报账
  5. * */
  6. var urlstr = base_api + 'index.php';
  7. var listHTML = '';
  8. var bus_order_id = getPar('bus_order_id');
  9. var run_id = getPar('run_id');
  10. var user_type = window.getStorage('user_type');
  11. window.onload = function(){
  12. // reloadInfoData();
  13. reloadListData();
  14. }
  15. //请求配置信息
  16. function reloadInfoData(){
  17. var data = {
  18. tp : 'finance_groupFinance_getAddFinanceBase',
  19. bus_order_id : bus_order_id,
  20. run_id : run_id
  21. }
  22. $.ajax({
  23. url: urlstr,
  24. data: data,
  25. type: "post",
  26. dataType: "json",
  27. async: false,
  28. success: function(data) {
  29. if(data.code == "0") {
  30. ZZLog(data);
  31. replaceInfoData(data);
  32. } else {
  33. ZZAlertInfo(data.info);
  34. }
  35. },
  36. error:function(e){
  37. ZZLog(e);
  38. }
  39. });
  40. }
  41. //替换相关的配置信息
  42. function replaceInfoData(data){
  43. if(user_type == 0)
  44. $("#save_btn").html('审核');
  45. var object_list = data.fee_type;
  46. var object_priceHTML = '<option value="0">请选择</option>';
  47. for(var i = 0; i < object_list.length; i++) {
  48. var str = '<option value="0">请选择</option>';
  49. str = str.replace('0', object_list[i].id);
  50. str = str.replace('请选择', object_list[i].type_name);
  51. object_priceHTML += str;
  52. }
  53. $('.object_price').html(object_priceHTML);
  54. var pay_list = data.settle_type;
  55. var payHTML = '<option value="-1">请选择</option>';
  56. for(var i = 0; i < pay_list.length; i++) {
  57. var str = '<option value="-1">请选择</option>';
  58. str = str.replace('-1', pay_list[i].id);
  59. str = str.replace('请选择', pay_list[i].type_name);
  60. payHTML += str;
  61. }
  62. $('.pay_style').html(payHTML);
  63. var unit_list = data.supply_list;
  64. var unitHTML = '<option value="0">请选择</option>';
  65. for(var i = 0; i < unit_list.length; i++) {
  66. var str = '<option value="0">请选择</option>';
  67. str = str.replace('0', unit_list[i].id);
  68. str = str.replace('请选择', unit_list[i].supplier_name);
  69. unitHTML += str;
  70. }
  71. $('.unit').html(unitHTML);
  72. listHTML = $('#list').html();
  73. $('.unit').comboSelect();
  74. //替换头部信息
  75. $('.date').html(data.run_bus_info.run_date);
  76. var temp_str = data.run_bus_info.line_code_name;
  77. temp_str = temp_str.replace(',','&nbsp;&nbsp;&nbsp;&nbsp;')
  78. $('.line_code').html(temp_str);
  79. $('.people_count').html(data.run_bus_info.saled_count+'人');;
  80. }
  81. //请求列表信息
  82. function reloadListData(){
  83. var data = {
  84. tp : 'finance_groupFinance_getFinanceInfo',
  85. bus_order_id : bus_order_id,
  86. run_id : run_id
  87. }
  88. $.ajax({
  89. url: urlstr,
  90. data: data,
  91. type: "post",
  92. dataType: "json",
  93. async: false,
  94. success: function(data) {
  95. if(data.code == "0") {
  96. ZZLog(data);
  97. replaceInfoData(data.data_info);
  98. replaceListData(data);
  99. } else {
  100. ZZAlertInfo(data.info);
  101. }
  102. //根据状态隐藏新增和保存按钮
  103. var sta = getPar('ac');
  104. if(sta == 'view'){
  105. $("#add_btn").hide();
  106. $("#save_btn").hide();
  107. $(".del_btn").hide();
  108. }
  109. },
  110. error:function(e){
  111. ZZLog(e);
  112. }
  113. });
  114. }
  115. //替换列表的信息
  116. function replaceListData(data){
  117. var count = data.finance_list.length;
  118. var listinfo = data.finance_list;
  119. var newHTML = '';
  120. for (var i = 0 ; i < count ; i ++) {
  121. var tempHTML = listHTML;
  122. newHTML += tempHTML;
  123. }
  124. $('#list').html(newHTML);
  125. $('.list_info').each(function(i,dom){
  126. $(dom).children().find('.payments').val(listinfo[i].payment_type);
  127. $(dom).children().find('.object_price').val(listinfo[i].fee_type);
  128. $(dom).children().find('.unit').val(listinfo[i].supplier_id);
  129. $(dom).children().find('.price').val(listinfo[i].unit_price);
  130. $(dom).children().find('.count').val(listinfo[i].num);
  131. $(dom).children().find('.total_price').val(listinfo[i].total_price);
  132. $(dom).children().find('.Wdate').val(listinfo[i].finance_date);
  133. $(dom).children().find('.handle_people').val(listinfo[i].finance_man);
  134. $(dom).children().find('.pay_style').val(listinfo[i].settle_type);
  135. $(dom).children().find('.sign_no').val(listinfo[i].sign_order_id);
  136. $(dom).children().find('.remarks').val(listinfo[i].remark);
  137. $(dom).attr('valuestr',listinfo[i].id);
  138. $('.unit').comboSelect();
  139. })
  140. }
  141. //新增一条信息
  142. function addInfo(){
  143. $('#list').prepend(listHTML);
  144. $('.unit').comboSelect();
  145. }
  146. //删除一条
  147. function delBtnDidClicked(obj){
  148. $(obj).closest('.list_info').remove();
  149. }
  150. //保存
  151. function saveBtnDidClicked(){
  152. var infostr = '';
  153. var infostr_arr=[];
  154. $('.list_info').each(function(index,dom){
  155. //收支
  156. var payments = $(this).children().find('.payments').val();
  157. //费用科目
  158. var object_price = $(this).children().find('.object_price').val();
  159. //结算单位
  160. var unit = $(this).children().find('.unit').val();
  161. //单价
  162. var price = $(this).children().find('.price').val();
  163. //数量
  164. var count = $(this).children().find('.count').val();
  165. //金额小计
  166. var total_price = $(this).children().find('.total_price').val();
  167. //报账日期
  168. var bill_date = $(this).children().find('.Wdate').val();
  169. //经办人
  170. var handle_people = $(this).children().find('.handle_people').val();
  171. //结算方式
  172. var pay_style = $(this).children().find('.pay_style').val();
  173. //签单号
  174. var sign_no = $(this).children().find('.sign_no').val();
  175. //备注
  176. var remarks = $(this).children().find('.remarks').val();
  177. var value = $(this).attr('valuestr');
  178. if (object_price == '0') {
  179. ZZAlertInfo('请完善费用科目的相关报账信息!');
  180. return false;
  181. }
  182. if (!unit) {
  183. ZZAlertInfo('请完善结算单位的相关报账信息!');
  184. return false;
  185. }
  186. if (!price) {
  187. ZZAlertInfo('请完善相关报账的单价信息!',function(){
  188. $(dom).children().find('.price').focus();
  189. });
  190. return false;
  191. }
  192. if (!count) {
  193. ZZAlertInfo('请完善相关报账的数量信息!',function(){
  194. $(dom).children().find('.count').focus();
  195. });
  196. return false;
  197. }
  198. if (!total_price) {
  199. ZZAlertInfo('请完善相关报账的总价信息!',function(){
  200. $(dom).children().find('.total_price').focus();
  201. });
  202. return false;
  203. }
  204. if (!bill_date) {
  205. ZZAlertInfo('请选择相关报账信息的日期!');
  206. return false;
  207. }
  208. if (!handle_people) {
  209. ZZAlertInfo('请填写相关报账信息的经办人!',function(){
  210. $(dom).children().find('.handle_people').focus();
  211. });
  212. return false;
  213. }
  214. if (pay_style == '-1') {
  215. ZZAlertInfo('请选择相关报账信息的结算方式!');
  216. return false;
  217. }
  218. // if (!sign_no) {
  219. // ZZAlertInfo('请填写相关报账信息的签单号!',function(){
  220. // $(dom).children().find('.sign_no').focus();
  221. // });
  222. // return false;
  223. // }
  224. // if (!remarks) {
  225. // ZZAlertInfo('写相关报账信息的备注不能为空!',function(){
  226. // $(dom).children().find('.remarks').focus();
  227. // });
  228. // return false;
  229. // }
  230. var str = '{'+value+','+payments+','+object_price+','+unit+','+price+','+count+','+total_price+','+bill_date+','+handle_people+','+pay_style+','+sign_no+','+remarks+'}';
  231. if (str != '') {
  232. infostr_arr.push(str);
  233. // infostr += str;
  234. }
  235. })
  236. infostr=infostr_arr.join('');
  237. if(''==infostr || $('.list_info').length>infostr_arr.length){
  238. return false;
  239. }
  240. var list_count = $('#list').children().length;
  241. if (list_count == 0) {
  242. ZZAlertInfo('无相关的报账信息!');
  243. return false;
  244. }
  245. var run_id = getPar('run_id');
  246. var bus_order_id = getPar('bus_order_id');
  247. var data = {
  248. tp : 'finance_groupFinance_updateFinanceInfo',
  249. run_id : run_id,
  250. finance_str : infostr,
  251. bus_order_id : bus_order_id,
  252. operate : user_type == 0?'check':'update'
  253. }
  254. //申请报账的提交
  255. ZZLog(data);
  256. if(user_type == 0){
  257. ZZConfirm('该操作将会提交当前的报账信息并通过审核,确认操作吗?', function () {
  258. $.ajax({
  259. url: urlstr,
  260. data: data,
  261. type: "post",
  262. dataType: "json",
  263. async: false,
  264. success: function(data) {
  265. ZZLog(data);
  266. if(data.code == "0") {
  267. ZZAlertInfo(data.info);
  268. setTimeout(function(){window.location = '/web/financialStatement/group_statement.html';}, 1500);
  269. } else {
  270. ZZAlertInfo(data.info);
  271. }
  272. },
  273. error:function(e){
  274. ZZLog(e);
  275. }
  276. });
  277. })
  278. }else{
  279. $.ajax({
  280. url: urlstr,
  281. data: data,
  282. type: "post",
  283. dataType: "json",
  284. async: false,
  285. success: function(data) {
  286. ZZLog(data);
  287. if(data.code == "0") {
  288. ZZAlertInfo(data.info);
  289. } else {
  290. ZZAlertInfo(data.info);
  291. }
  292. },
  293. error:function(e){
  294. ZZLog(e);
  295. }
  296. });
  297. }
  298. }