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.
122 lines
5.0 KiB
122 lines
5.0 KiB
/**
|
|
* Created by yixian on 2017-02-05.
|
|
*/
|
|
define(['angular','decimal'], function (angular,decimal) {
|
|
'use strict';
|
|
var app = angular.module('partnerInvoice', ['ui.router']);
|
|
app.config(['$stateProvider', function ($stateProvider) {
|
|
$stateProvider.state('partner_invoice', {
|
|
url: '/partner/invoice',
|
|
templateUrl: '/static/invoice/templates/invoice_assistant.html',
|
|
controller: 'partnerInvoiceApp'
|
|
})
|
|
}]);
|
|
app.controller('partnerInvoiceApp', ['$scope', '$http','$filter', 'commonDialog', function ($scope, $http,$filter, commonDialog) {
|
|
$scope.params = {channel:'ALL',clearing_status:-1};
|
|
$scope.today = new Date();
|
|
$scope.pagination = {};
|
|
$scope.today = new Date();
|
|
$scope.clients = [$scope.currentUser.client];
|
|
if ($scope.currentUser.client.has_children) {
|
|
$scope.params.client_ids = [$scope.currentUser.client.client_id];
|
|
$http.get('/client/partner_info/sub_partners').then(function (resp) {
|
|
var clientList = resp.data;
|
|
clientList.forEach(function (client) {
|
|
$scope.clients.push(client);
|
|
});
|
|
})
|
|
};
|
|
$scope.chooseClient = function (clientId) {
|
|
$scope.chooseClientId = clientId;
|
|
$scope.params.client_ids = [clientId];
|
|
$scope.loadTradeLogs(1);
|
|
};
|
|
$scope.chooseToday = function () {
|
|
$scope.params.datefrom = $scope.params.dateto = new Date();
|
|
$scope.loadTradeLogs(1);
|
|
};
|
|
$scope.chooseYesterday = function () {
|
|
var yesterday = new Date();
|
|
yesterday.setDate(yesterday.getDate() - 1);
|
|
$scope.params.datefrom = $scope.params.dateto = yesterday;
|
|
$scope.loadTradeLogs(1);
|
|
};
|
|
$scope.chooseLast7Days = function () {
|
|
$scope.params.dateto = new Date();
|
|
var day = new Date();
|
|
day.setDate(day.getDate() - 7);
|
|
$scope.params.datefrom = day;
|
|
$scope.loadTradeLogs(1);
|
|
};
|
|
$scope.thisMonth = function () {
|
|
$scope.params.dateto = new Date();
|
|
var monthBegin = new Date();
|
|
monthBegin.setDate(1);
|
|
$scope.params.datefrom = monthBegin;
|
|
$scope.loadTradeLogs(1);
|
|
};
|
|
$scope.lastMonth = function () {
|
|
var monthFinish = new Date();
|
|
monthFinish.setDate(0);
|
|
$scope.params.dateto = monthFinish;
|
|
var monthBegin = new Date();
|
|
monthBegin.setDate(0);
|
|
monthBegin.setDate(1);
|
|
$scope.params.datefrom = monthBegin;
|
|
$scope.loadTradeLogs(1);
|
|
};
|
|
$scope.loadTradeLogs = function (page) {
|
|
var params = angular.copy($scope.params);
|
|
if (params.datefrom) {
|
|
params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd');
|
|
}else {
|
|
alert("请选择开始时间");
|
|
return;
|
|
}
|
|
if (params.dateto) {
|
|
params.dateto = $filter('date')(params.dateto, 'yyyyMMdd');
|
|
}else {
|
|
alert("请选择结束时间");
|
|
return;
|
|
}
|
|
params.page = page || $scope.pagination.page || 1;
|
|
$http.get('/partner/invoice/trans_flow', {params: params}).then(function (resp) {
|
|
$scope.tradeLogs = resp.data.data;
|
|
$scope.tradeLogs.forEach(function (log) {
|
|
if(log.total_surcharge){
|
|
log.total_surcharge = decimal.add(log.total_surcharge,log.tax_amount).toFixed(2);
|
|
}
|
|
});
|
|
$scope.pagination = resp.data.pagination;
|
|
$scope.analysis = resp.data.analysis;
|
|
$scope.total_surcharge = decimal.add($scope.analysis.total_surcharge,$scope.analysis.tax_amount).toFixed(2);
|
|
$scope.analysis.refund_fee = angular.copy(Math.abs($scope.analysis.refund_fee));
|
|
}, function (resp) {
|
|
commonDialog.alert({title: 'Search failed', content: resp.data.message, type: 'error'});
|
|
});
|
|
};
|
|
|
|
$scope.export = function (type,page) {
|
|
var url='/partner/invoice/trans_flow/pdf';
|
|
var connectSymbol = '?';
|
|
|
|
var params = angular.copy($scope.params);
|
|
if (params.datefrom) {
|
|
params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd');
|
|
url += connectSymbol + 'datefrom=' + params.datefrom;
|
|
connectSymbol = '&';
|
|
}
|
|
if (params.dateto) {
|
|
params.dateto = $filter('date')(params.dateto, 'yyyyMMdd');
|
|
url += connectSymbol + 'dateto=' + params.dateto;
|
|
connectSymbol = '&';
|
|
}
|
|
params.page = page || $scope.pagination.page || 1;
|
|
url += connectSymbol + 'page=' + params.page;
|
|
url+="&channel=ALL&clearing_status=-1";
|
|
return url;
|
|
|
|
}
|
|
}]);
|
|
return app;
|
|
}); |