|
- /*
- yimazsq
- 10月31号
- 申请报账
- * */
-
- var urlstr = base_api + 'index.php';
-
- var listHTML = '';
-
- window.onload = function (){
-
- //请求相关配置信息
- reloadData();
-
- }
-
- //页面开始加载配置信息
- function reloadData(){
- var run_id = getPar('run_id');
- var bus_order_id = getPar('bus_order_id');
-
- var tp = 'finance_groupFinance_getAddFinanceBase';
- var data = {
- tp : tp,
- run_id : run_id,
- bus_order_id : bus_order_id
- };
- //请求相关配置信息
- $.ajax({
- url: urlstr, //请求地址
- data: data,
- type: "post",
- dataType: "json",
- async: false,
- success: function(data) {
- if(data.code == "0") {
- ZZLog(data);
- replaceData(data);
- } else {
- ZZAlertInfo(data.info);
- }
- },
- error:function(e){
- ZZLog(e);
- }
- });
- }
-
- //替换相关的配置信息
- function replaceData(data){
- var object_list = data.fee_type;
- var object_priceHTML = '<option value="0">请选择</option>';
- for(var i = 0; i < object_list.length; i++) {
- var str = '<option value="0">请选择</option>';
- str = str.replace('0', object_list[i].id);
- str = str.replace('请选择', object_list[i].type_name);
- object_priceHTML += str;
- }
- $('.object_price').html(object_priceHTML);
-
- var pay_list = data.settle_type;
- var payHTML = '<option value="-1">请选择</option>';
- for(var i = 0; i < pay_list.length; i++) {
- var str = '<option value="-1">请选择</option>';
- str = str.replace('-1', pay_list[i].id);
- str = str.replace('请选择', pay_list[i].type_name);
- payHTML += str;
- }
- $('.pay_style').html(payHTML);
-
-
- var unit_list = data.supply_list;
- var unitHTML = '<option value="0">请选择</option>';
- for(var i = 0; i < unit_list.length; i++) {
- var str = '<option value="0">请选择</option>';
- str = str.replace('0', unit_list[i].id);
- str = str.replace('请选择', unit_list[i].supplier_name);
- unitHTML += str;
- }
- $('.unit').html(unitHTML);
- listHTML = $('#list').html();
- $('.unit').comboSelect();
-
-
- //替换头部信息
- $('.date').html(data.run_bus_info.run_date);
- var temp_str = data.run_bus_info.line_code_name;
- temp_str = temp_str.replace(',',' ')
- $('.line_code').html(temp_str);
- $('.people_count').html(data.run_bus_info.saled_count+'人');
- }
-
-
- //新增一条信息
- function addInfo(){
- $('#list').prepend(listHTML);
- $('.unit').comboSelect();
- }
-
- //删除一条
- function delBtnDidClicked(obj){
- $(obj).closest('.list_info').remove();
- }
-
- //保存
- function saveBtnDidClicked(){
-
- var infostr = '';
- var infostr_arr=[];
- $('.list_info').each(function(index,dom){
- //收支
- var payments = $(this).children().find('.payments').val();
- //费用科目
- var object_price = $(this).children().find('.object_price').val();
- //结算单位
- var unit = $(this).children().find('.unit').val();
- //单价
- var price = $(this).children().find('.price').val();
- //数量
- var count = $(this).children().find('.count').val();
- //金额小计
- var total_price = $(this).children().find('.total_price').val();
- //报账日期
- var bill_date = $(this).children().find('.Wdate').val();
- //经办人
- var handle_people = $(this).children().find('.handle_people').val();
- //结算方式
- var pay_style = $(this).children().find('.pay_style').val();
- //签单号
- var sign_no = $(this).children().find('.sign_no').val();
- //备注
- var remarks = $(this).children().find('.remarks').val();
-
- if (object_price == '0') {
- ZZAlertInfo('请完善费用科目的相关报账信息!');
- return false;
- }
- if (!unit) {
- ZZAlertInfo('请完善结算单位的相关报账信息!');
- return false;
- }
- if (!price) {
- ZZAlertInfo('请完善相关报账的单价信息!',function(){
- $(dom).children().find('.price').focus();
- });
-
- return false;
- }
- if (!count) {
- ZZAlertInfo('请完善相关报账的数量信息!',function(){
- $(dom).children().find('.count').focus();
- });
- return false;
- }
- if (!total_price) {
- ZZAlertInfo('请完善相关报账的总价信息!',function(){
- $(dom).children().find('.total_price').focus();
- });
- return false;
- }
- if (!bill_date) {
- ZZAlertInfo('请选择相关报账信息的日期!');
- return false;
- }
- if (!handle_people) {
- ZZAlertInfo('请填写相关报账信息的经办人!',function(){
- $(dom).children().find('.handle_people').focus();
- });
- return false;
- }
- if (pay_style == '-1') {
- ZZAlertInfo('请选择相关报账信息的结算方式!');
- return false;
- }
- // if (!sign_no) {
- // ZZAlertInfo('请填写相关报账信息的签单号!',function(){
- // $(dom).children().find('.sign_no').focus();
- // });
- // return false;
- // }
- // if (!remarks) {
- // ZZAlertInfo('写相关报账信息的备注不能为空!',function(){
- // $(dom).children().find('.remarks').focus();
- // });
- // return false;
- // }
- var str = '{'+payments+','+object_price+','+unit+','+price+','+count+','+total_price+','+bill_date+','+handle_people+','+pay_style+','+sign_no+','+remarks+'}';
- if (str != '') {
- infostr_arr.push(str);
- // infostr += str;
- }
- })
- infostr=infostr_arr.join('');
- if(''==infostr || $('.list_info').length>infostr_arr.length){
- return false;
- }
- var list_count = $('#list').children().length;
- if (list_count == 0) {
- ZZAlertInfo('无相关的报账信息!');
- return false;
- }
-
- var run_id = getPar('run_id');
- var bus_order_id = getPar('bus_order_id');
- var data = {
- tp : 'finance_groupFinance_addFinance',
- run_id : run_id,
- finance_str : infostr,
- bus_order_id : bus_order_id
- }
- //申请报账的提交
- ZZLog(data);
- $.ajax({
- url: urlstr,
- data: data,
- type: "post",
- dataType: "json",
- async: false,
- success: function(data) {
- if(data.code == "0") {
- ZZAlertInfo(data.info);
- } else {
- ZZAlertInfo(data.info);
- }
- },
- error:function(e){
- ZZLog(e);
- }
- });
-
- }
|