|
- /*
- yimazsq
- 11月03号
- 修改报账
- * */
-
- var urlstr = base_api + 'index.php';
-
- var listHTML = '';
- var bus_order_id = getPar('bus_order_id');
- var run_id = getPar('run_id');
- var user_type = window.getStorage('user_type');
-
- window.onload = function(){
-
-
- // reloadInfoData();
- reloadListData();
- }
-
- //请求配置信息
- function reloadInfoData(){
- var data = {
- tp : 'finance_groupFinance_getAddFinanceBase',
- bus_order_id : bus_order_id,
- run_id : run_id
- }
-
- $.ajax({
- url: urlstr,
- data: data,
- type: "post",
- dataType: "json",
- async: false,
- success: function(data) {
- if(data.code == "0") {
- ZZLog(data);
- replaceInfoData(data);
- } else {
- ZZAlertInfo(data.info);
- }
- },
- error:function(e){
- ZZLog(e);
- }
- });
-
- }
-
-
- //替换相关的配置信息
- function replaceInfoData(data){
- if(user_type == 0)
- $("#save_btn").html('审核');
- 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 reloadListData(){
- var data = {
- tp : 'finance_groupFinance_getFinanceInfo',
- bus_order_id : bus_order_id,
- run_id : run_id
- }
-
- $.ajax({
- url: urlstr,
- data: data,
- type: "post",
- dataType: "json",
- async: false,
- success: function(data) {
- if(data.code == "0") {
- ZZLog(data);
- replaceInfoData(data.data_info);
- replaceListData(data);
- } else {
- ZZAlertInfo(data.info);
- }
-
- //根据状态隐藏新增和保存按钮
- var sta = getPar('ac');
- if(sta == 'view'){
- $("#add_btn").hide();
- $("#save_btn").hide();
- $(".del_btn").hide();
- }
- },
- error:function(e){
- ZZLog(e);
- }
- });
- }
-
- //替换列表的信息
- function replaceListData(data){
- var count = data.finance_list.length;
- var listinfo = data.finance_list;
- var newHTML = '';
- for (var i = 0 ; i < count ; i ++) {
- var tempHTML = listHTML;
- newHTML += tempHTML;
- }
- $('#list').html(newHTML);
- $('.list_info').each(function(i,dom){
- $(dom).children().find('.payments').val(listinfo[i].payment_type);
- $(dom).children().find('.object_price').val(listinfo[i].fee_type);
- $(dom).children().find('.unit').val(listinfo[i].supplier_id);
- $(dom).children().find('.price').val(listinfo[i].unit_price);
- $(dom).children().find('.count').val(listinfo[i].num);
- $(dom).children().find('.total_price').val(listinfo[i].total_price);
- $(dom).children().find('.Wdate').val(listinfo[i].finance_date);
- $(dom).children().find('.handle_people').val(listinfo[i].finance_man);
- $(dom).children().find('.pay_style').val(listinfo[i].settle_type);
- $(dom).children().find('.sign_no').val(listinfo[i].sign_order_id);
- $(dom).children().find('.remarks').val(listinfo[i].remark);
- $(dom).attr('valuestr',listinfo[i].id);
- $('.unit').comboSelect();
- })
- }
-
-
-
- //新增一条信息
- 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();
-
- var value = $(this).attr('valuestr');
-
- 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 = '{'+value+','+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_updateFinanceInfo',
- run_id : run_id,
- finance_str : infostr,
- bus_order_id : bus_order_id,
- operate : user_type == 0?'check':'update'
- }
- //申请报账的提交
- ZZLog(data);
- if(user_type == 0){
- ZZConfirm('该操作将会提交当前的报账信息并通过审核,确认操作吗?', function () {
- $.ajax({
- url: urlstr,
- data: data,
- type: "post",
- dataType: "json",
- async: false,
- success: function(data) {
- ZZLog(data);
- if(data.code == "0") {
- ZZAlertInfo(data.info);
- setTimeout(function(){window.location = '/web/financialStatement/group_statement.html';}, 1500);
- } else {
- ZZAlertInfo(data.info);
- }
- },
- error:function(e){
- ZZLog(e);
- }
- });
- })
- }else{
- $.ajax({
- url: urlstr,
- data: data,
- type: "post",
- dataType: "json",
- async: false,
- success: function(data) {
- ZZLog(data);
- if(data.code == "0") {
- ZZAlertInfo(data.info);
- } else {
- ZZAlertInfo(data.info);
- }
- },
- error:function(e){
- ZZLog(e);
- }
- });
-
- }
-
- }
|