|
|
@@ -1,177 +1,592 @@
|
|
|
define(['app/app'], function (app) {
|
|
|
|
|
|
//应收对账单列表
|
|
|
- app.register.controller('PurchaseApCheckCtrl', ['$rootScope', '$scope', 'B2bFaApCheck', 'BaseService', 'ngTableParams', 'toaster', 'B2bReportService', 'Symbol', 'B2bCurrentRole', function ($rootScope, $scope, FaApCheck, BaseService, ngTableParams, toaster, ReportService, Symbol, CurrentRole) {
|
|
|
- BaseService.scrollBackToTop();
|
|
|
- $rootScope.active = 'vendor_pay_center';
|
|
|
- // 获取当前用户是否为普通用户
|
|
|
- CurrentRole.isUser({}, {}, function (data) {
|
|
|
- $scope.isUser = data.isUser;
|
|
|
- });
|
|
|
- $scope.dateZoneText = '不限';
|
|
|
- $scope.condition = {dateZone: 1};
|
|
|
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
|
|
|
- $scope.active = 'todo';
|
|
|
-
|
|
|
- /* 时间筛选初始化*/
|
|
|
- var fromDate = new Date();
|
|
|
- var toDate = new Date();
|
|
|
- fromDate.setMonth(fromDate.getMonth() - 1);
|
|
|
- fromDate.setHours(0, 0, 0, 0);
|
|
|
- toDate.setHours(23, 59, 59, 999);
|
|
|
- $scope.condition.dateFrom = fromDate;
|
|
|
- $scope.condition.dateTo = toDate;
|
|
|
-
|
|
|
- //打印 对账单
|
|
|
- $scope.print = function (check) {
|
|
|
- var newPage = window.open("about:blank");
|
|
|
- FaApCheck.printPermission({}, function () {
|
|
|
- FaApCheck.printCount({id: check.id}, {});//增加打印此次
|
|
|
- ReportService.print(check.custUu, 'PURCCHECK', 'where purc$apcheck.pa_id =' + check.id, newPage);
|
|
|
- }, function (response) {
|
|
|
- newPage.close();
|
|
|
- toaster.pop('error', '打印失败', response.data);
|
|
|
+ app.register.controller('PurchaseApCheckCtrl', ['$rootScope', '$scope', 'B2bFaApCheck', 'BaseService', 'ngTableParams', 'toaster', 'B2bReportService', 'Symbol', 'B2bCurrentRole', 'B2bDecimalNumber', '$filter', '$state',function ($rootScope, $scope, FaApCheck, BaseService, ngTableParams, toaster, ReportService, Symbol, CurrentRole, DecimalNumber, $filter, $state) {
|
|
|
+ BaseService.scrollBackToTop();
|
|
|
+ // 获取当前用户是否为普通用户
|
|
|
+ $rootScope.active = 'vendor_pay_center';
|
|
|
+ CurrentRole.isUser({}, {}, function (data) {
|
|
|
+ $scope.isUser = data.isUser;
|
|
|
});
|
|
|
- };
|
|
|
+ $scope.dateZoneText = '不限';
|
|
|
+ $scope.condition = {dateZone: 1};
|
|
|
+ $scope.currency = Symbol.currency;//将币别转化为对应的符号
|
|
|
+ $scope.active = 'all';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /* 时间筛选初始化*/
|
|
|
+ var fromDate = new Date();
|
|
|
+ var toDate = new Date();
|
|
|
+ fromDate.setMonth(fromDate.getMonth() - 1);
|
|
|
+ fromDate.setHours(0, 0, 0, 0);
|
|
|
+ toDate.setHours(23, 59, 59, 999);
|
|
|
+ $scope.condition.dateFrom = fromDate;
|
|
|
+ $scope.condition.dateTo = toDate;
|
|
|
+
|
|
|
+ //打印 对账单
|
|
|
+ $scope.print = function (check) {
|
|
|
+ var newPage = window.open("about:blank");
|
|
|
+ FaApCheck.printPermission({}, function () {
|
|
|
+ FaApCheck.printCount({id: check.id}, {});//增加打印此次
|
|
|
+ ReportService.print(check.custUu, 'PURCCHECK', 'where purc$apcheck.pa_id =' + check.id, newPage);
|
|
|
+ }, function (response) {
|
|
|
+ newPage.close();
|
|
|
+ toaster.pop('error', '打印失败', response.data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ //状态
|
|
|
+ $scope.setActive = function (state) {
|
|
|
+ if ($scope.active != state) {
|
|
|
+ $scope.active = state;
|
|
|
+ if ($scope.tableParams.page() == 1)
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ else
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.showNotCheck = false
|
|
|
+ }
|
|
|
+ };
|
|
|
+ $scope.changeDateZone = function (zone) {
|
|
|
+ $scope.condition.dateZone = zone;
|
|
|
+ $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
|
|
|
+ $scope.condition.$dateZoneOpen = false;
|
|
|
+ getDateCondition(zone, $scope.condition);
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ //获取应收对账单全部
|
|
|
+ $scope.tableParams = new ngTableParams({
|
|
|
+ page: 1,
|
|
|
+ count: 20,
|
|
|
+ sorting: {
|
|
|
+ recordDate: 'desc'
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total: 0,
|
|
|
+ counts: [5, 10, 25, 50],
|
|
|
+ getData: function ($defer, params) {
|
|
|
+ $scope.loading = true;
|
|
|
+ var pageParams = params.url();
|
|
|
+
|
|
|
+ pageParams.searchFilter = { // 筛选条件
|
|
|
+ keyword: $scope.keyword,
|
|
|
+ fromDate: getDateTime($scope.condition.dateFrom),
|
|
|
+ endDate: getDateTime($scope.condition.dateTo)
|
|
|
+ };
|
|
|
+ if ($scope.active === 'all') {
|
|
|
+ pageParams.keyword = $scope.keyword
|
|
|
+ FaApCheck.customer(BaseService.parseParams(pageParams), function (page) {
|
|
|
+ $scope.loading = false;
|
|
|
+ if (page) {
|
|
|
+ params.total(page.totalElement);
|
|
|
+ $defer.resolve(page.content);
|
|
|
+ }
|
|
|
+ $scope.ALLList = page.content
|
|
|
+ $scope.infoCommon = page
|
|
|
+ $scope.infoCommon.all = page.content.length
|
|
|
+ $scope.totalCount = page.totalElement;
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ FaApCheck[getState($scope.active)](BaseService.parseParams(pageParams), function (page) {
|
|
|
+ $scope.loading = false;
|
|
|
+ if (page) {
|
|
|
+ params.total(page.totalElement);
|
|
|
+ $scope.data = $defer.resolve(page.content);
|
|
|
+ $scope.infoCommon = page
|
|
|
+ $scope.infoCommon.all = page.content.length
|
|
|
+ $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //获得各分类未阅读数量
|
|
|
+ var getUnreadCount = function () {
|
|
|
+ FaApCheck.getUnreadCount(null, function(data){
|
|
|
+ $scope.unread = data;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ getUnreadCount();
|
|
|
+
|
|
|
+ //设置单据已读
|
|
|
+ $scope.setOrdersRead = function (id) {
|
|
|
+ // 如果单据本身已读,则不发送请求修改数据
|
|
|
+ if (!$scope.isUnread(id)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var sourceId = [];
|
|
|
+ sourceId.push(id);
|
|
|
+ FaApCheck.setRead({}, sourceId, function (message) {
|
|
|
+ getUnreadCount();
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ //获取未读单据id
|
|
|
+ var getUnreadIds = function (){
|
|
|
+ FaApCheck.getUnreadIds({}, "", function (message) {
|
|
|
+ $scope.unreadCode = message.content;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ getUnreadIds();
|
|
|
+ //判断单据是否未读
|
|
|
+ $scope.isUnread = function (id){
|
|
|
+ for (var i in $scope.unreadCode) {
|
|
|
+ if (id == $scope.unreadCode[i]) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.openDatePicker = function ($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ item[openParam] = !item[openParam];
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.openFilterDatePicker = function ($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ item[openParam] = !item[openParam];
|
|
|
+ if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 计算单据的商品总数
|
|
|
+ $scope.getTotalProd = function (check) {
|
|
|
+ var total = 0;
|
|
|
+ if (check.items) {
|
|
|
+ angular.forEach(check.items, function (value) {
|
|
|
+ total += value.checkQty;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return total;
|
|
|
+ };
|
|
|
|
|
|
- //状态
|
|
|
- $scope.setActive = function (state) {
|
|
|
- if ($scope.active != state) {
|
|
|
- $scope.active = state;
|
|
|
- if ($scope.tableParams.page() == 1)
|
|
|
+ // 搜索框回车
|
|
|
+ $scope.onSearch = function () {
|
|
|
+ $scope.tableParams.page(1);
|
|
|
$scope.tableParams.reload();
|
|
|
- else
|
|
|
+ };
|
|
|
+
|
|
|
+ // 选择查找日期
|
|
|
+ $scope.onDateCondition = function () {
|
|
|
$scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 导出
|
|
|
+ $scope.exportXls = function () {
|
|
|
+ FaApCheck.exportXls({}, {}, function (data) {
|
|
|
+ if (data.success){
|
|
|
+ window.location.href = 'sale/apCheck/xls/list?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.data = [];// 列表数据
|
|
|
+
|
|
|
+ $scope.condition = {
|
|
|
+ $fromOpened: false
|
|
|
}
|
|
|
- };
|
|
|
- $scope.changeDateZone = function (zone) {
|
|
|
- $scope.condition.dateZone = zone;
|
|
|
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
|
|
|
- $scope.condition.$dateZoneOpen = false;
|
|
|
- getDateCondition(zone, $scope.condition);
|
|
|
- $scope.tableParams.page(1);
|
|
|
- $scope.tableParams.reload();
|
|
|
- };
|
|
|
|
|
|
- //获取应收对账单全部
|
|
|
- $scope.tableParams = new ngTableParams({
|
|
|
- page: 1,
|
|
|
- count: 20,
|
|
|
- sorting: {
|
|
|
- recordDate: 'desc'
|
|
|
+ $scope.openDatePicker = function ($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ item[openParam] = !item[openParam];
|
|
|
}
|
|
|
- }, {
|
|
|
- total: 0,
|
|
|
- counts: [5, 10, 25, 50],
|
|
|
- getData: function ($defer, params) {
|
|
|
- $scope.loading = true;
|
|
|
- var pageParams = params.url();
|
|
|
- pageParams.searchFilter = { // 筛选条件
|
|
|
- keyword: $scope.keyword,
|
|
|
- fromDate: getDateTime($scope.condition.dateFrom),
|
|
|
- endDate: getDateTime($scope.condition.dateTo)
|
|
|
- };
|
|
|
- FaApCheck[getState($scope.active)](BaseService.parseParams(pageParams), function (page) {
|
|
|
- $scope.loading = false;
|
|
|
- if (page) {
|
|
|
- params.total(page.totalElement);
|
|
|
- $scope.data = $defer.resolve(page.content);
|
|
|
- $scope.infoCommon = page
|
|
|
- $scope.infoCommon.all = page.content.length
|
|
|
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
|
|
|
+
|
|
|
+ // 客户联想词
|
|
|
+ $scope.getSimilarCustomers = function (value) {
|
|
|
+ if (value) {
|
|
|
+ return Vendor.getSimilarCustomers({keyword: value}).$promise.then(function (data) {
|
|
|
+ return data.map(function (item) {
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.onAssociateCustomerClick = function (vendor) {
|
|
|
+ if (vendor.apcheck == 0) {
|
|
|
+ toaster.pop('info', '提示', '该客户暂未启用平台对账功能');
|
|
|
+ $scope.suuorname = '';
|
|
|
+ } else {
|
|
|
+ $scope.suuorname = vendor.custName;
|
|
|
}
|
|
|
- }, function (response) {
|
|
|
- $scope.loading = false;
|
|
|
- toaster.pop('error', '数据加载失败', response.data);
|
|
|
- });
|
|
|
}
|
|
|
- });
|
|
|
|
|
|
- //获得各分类未阅读数量
|
|
|
- var getUnreadCount = function () {
|
|
|
- FaApCheck.getUnreadCount(null, function(data){
|
|
|
- $scope.unread = data;
|
|
|
- });
|
|
|
- };
|
|
|
- getUnreadCount();
|
|
|
+ //查找客户
|
|
|
+ $scope.searchCust = function (suuorname) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: 'static/tpl/index/fa/apcheck_customer.html',
|
|
|
+ controller: 'SearchCustInfoCtrl',
|
|
|
+ size: 'lg',
|
|
|
+ resolve: {
|
|
|
+ suuorname: function () {
|
|
|
+ return suuorname;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function (customer) {
|
|
|
+ $scope.suuorname = customer.myEnterprise.enName;
|
|
|
+ });
|
|
|
|
|
|
- //设置单据已读
|
|
|
- $scope.setOrdersRead = function (id) {
|
|
|
- // 如果单据本身已读,则不发送请求修改数据
|
|
|
- if (!$scope.isUnread(id)){
|
|
|
- return;
|
|
|
}
|
|
|
- var sourceId = [];
|
|
|
- sourceId.push(id);
|
|
|
- FaApCheck.setRead({}, sourceId, function (message) {
|
|
|
- getUnreadCount();
|
|
|
- });
|
|
|
- };
|
|
|
|
|
|
- //获取未读单据id
|
|
|
- var getUnreadIds = function (){
|
|
|
- FaApCheck.getUnreadIds({}, "", function (message) {
|
|
|
- $scope.unreadCode = message.content;
|
|
|
- });
|
|
|
- };
|
|
|
- getUnreadIds();
|
|
|
- //判断单据是否未读
|
|
|
- $scope.isUnread = function (id){
|
|
|
- for (var i in $scope.unreadCode) {
|
|
|
- if (id == $scope.unreadCode[i]) {
|
|
|
- return true;
|
|
|
- }
|
|
|
+ $scope.showNotCheck = false
|
|
|
+ $scope.goToMNs = function(item) {
|
|
|
+ $scope.chooseItem = item;
|
|
|
+ $scope.showNotCheck = true
|
|
|
+ $scope.suuorname = item.myEnterprise.enName
|
|
|
+ this.searchOrder()
|
|
|
}
|
|
|
- };
|
|
|
|
|
|
- $scope.openDatePicker = function ($event, item, openParam) {
|
|
|
- $event.preventDefault();
|
|
|
- $event.stopPropagation();
|
|
|
- item[openParam] = !item[openParam];
|
|
|
- };
|
|
|
+ // 点击筛选根据条件选择数据
|
|
|
+ // 默认本月
|
|
|
+ $scope.sdateTo = new Date();
|
|
|
+ $scope.sdateFrom = new Date($scope.sdateTo.getFullYear(), $scope.sdateTo.getMonth(), 1);
|
|
|
+ $scope.thisMouth = $scope.sdateTo.getFullYear() +'-'+ ($scope.sdateTo.getMonth() + 1)
|
|
|
+ $scope.condition.uuorname = '';
|
|
|
+ // $scope.condition.dateFrom = '';
|
|
|
+ // $scope.condition.dateTo = '';
|
|
|
+ $scope.condition.venduuorname = '';
|
|
|
+ $scope.condition.factory = '';
|
|
|
+ $scope.condition.prodtitle = '';
|
|
|
+ $scope.condition.prodspec = '';
|
|
|
+
|
|
|
+ $scope.searchOrder = function (check) {
|
|
|
+ $scope.data = [];
|
|
|
+ $scope.checkboxes.checked = false;
|
|
|
+ $scope.totalMoney = 0;
|
|
|
+ $scope.condition.uuorname = $scope.suuorname;
|
|
|
+ $scope.condition.factory = $scope.factory
|
|
|
+ $scope.condition.prodtitle = $scope.prodtitle;
|
|
|
+ $scope.condition.prodspec = $scope.prodspec;
|
|
|
+ // $scope.condition.dateFrom = ($scope.sdateFrom || 0);
|
|
|
+ $scope.thisdatato = ($scope.sdateTo || 0);
|
|
|
+ if ($scope.thisdatato != 0) {
|
|
|
+ $scope.condition.dateTo = (new Date($scope.thisdatato.valueOf()) || 0);
|
|
|
+ } else {
|
|
|
+ $scope.condition.dateTo = ($scope.sdateTo || 0);
|
|
|
+ }
|
|
|
+ $scope.condition.venduuorname = $scope.vuuorname;
|
|
|
+ if ($scope.condition.dateTo != null || $scope.keywordXls != null) {
|
|
|
+
|
|
|
+ // $scope.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
|
|
|
+ // $scope.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
|
|
|
+ $scope.searchKeyWord = {
|
|
|
+ receiveName: $scope.receiveName,
|
|
|
+ factory: $scope.factory,
|
|
|
+ prodTitle: $scope.prodTitle,
|
|
|
+ prodSpec: $scope.prodSpec,
|
|
|
+ taxRate: $scope.taxRate,
|
|
|
+ suuorname: $scope.suuorname
|
|
|
+ }
|
|
|
+ $scope.exportKeywords = encodeURIComponent($scope.searchKeyWord);
|
|
|
+ // $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
|
|
|
+ // $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
|
|
|
+ // if (!$scope.suuorname) {
|
|
|
+ // toaster.pop('warning', '提示', '请先选择客户');
|
|
|
+ // document.getElementById('suuorname').focus();//光标默认在客户
|
|
|
+ // } else {
|
|
|
+ $scope.loading = true;
|
|
|
+ FaApCheck.getAllByKeywords({
|
|
|
+ // fromDate: $scope.fromDate,
|
|
|
+ // endDate: $scope.endDate,
|
|
|
+ receiveName: $scope.receiveName,
|
|
|
+ factory: $scope.factory,
|
|
|
+ prodTitle: $scope.prodTitle,
|
|
|
+ prodSpec: $scope.prodSpec,
|
|
|
+ taxRate: $scope.taxRate,
|
|
|
+ checkDate: $scope.thisMouth,
|
|
|
+ suuorname: $scope.suuorname
|
|
|
+ }, function (data) {
|
|
|
+ if (data.length > 0) {
|
|
|
+ angular.forEach(data, function (item) {
|
|
|
+ item.$selected = true;
|
|
|
+ });
|
|
|
+ $scope.data = data;
|
|
|
+ $scope.checkboxes.checked = true;
|
|
|
+ $scope.getTotalMoney();
|
|
|
+ } else {
|
|
|
+ toaster.pop('info', '提示', '当前没有需要对账记录');
|
|
|
+ }
|
|
|
+ $scope.loading = false;
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ });
|
|
|
+ // }
|
|
|
+ }
|
|
|
|
|
|
- $scope.openFilterDatePicker = function ($event, item, openParam) {
|
|
|
- $event.preventDefault();
|
|
|
- $event.stopPropagation();
|
|
|
- item[openParam] = !item[openParam];
|
|
|
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
|
|
|
- $scope.tableParams.reload();
|
|
|
}
|
|
|
- };
|
|
|
|
|
|
- // 计算单据的商品总数
|
|
|
- $scope.getTotalProd = function (check) {
|
|
|
- var total = 0;
|
|
|
- if (check.items) {
|
|
|
- angular.forEach(check.items, function (value) {
|
|
|
- total += value.checkQty;
|
|
|
- });
|
|
|
+ $scope.exportApcheckList = function() {
|
|
|
+ var url = 'sale/apCheck/xls?fromDate=' + $scope.fromDate + '&endDate=' + $scope.endDate;
|
|
|
+ if (angular.isDefined($scope.receiveName)) {
|
|
|
+ url = url + '&receiveName=' + $scope.receiveName;
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.factory)) {
|
|
|
+ url = url + '&factory=' + $scope.factory;
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.prodTitle)) {
|
|
|
+ url = url + '&prodTitle=' + $scope.prodTitle;
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.prodSpec)) {
|
|
|
+ url = url + '&prodSpec=' + $scope.prodSpec;
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.suuorname)) {
|
|
|
+ url = url + '&suuorname=' + $scope.suuorname;
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.taxRate)) {
|
|
|
+ url = url + '&receiveName=' + $scope.taxRate;
|
|
|
+ }
|
|
|
+ window.location.href = url;
|
|
|
}
|
|
|
- return total;
|
|
|
- };
|
|
|
|
|
|
- // 搜索框回车
|
|
|
- $scope.onSearch = function () {
|
|
|
- $scope.tableParams.page(1);
|
|
|
- $scope.tableParams.reload();
|
|
|
- };
|
|
|
+ /**
|
|
|
+ * 点击勾选框,选中要转应收对账单的订单
|
|
|
+ * */
|
|
|
+ $scope.totalMoney = 0;
|
|
|
+ $scope.checkboxes = {
|
|
|
+ checked: false
|
|
|
+ };
|
|
|
|
|
|
- // 选择查找日期
|
|
|
- $scope.onDateCondition = function () {
|
|
|
- $scope.tableParams.page(1);
|
|
|
- $scope.tableParams.reload();
|
|
|
- };
|
|
|
+ // 点击勾选全部的复选框
|
|
|
+ $scope.checkAll = function () {
|
|
|
+ $scope.totalMoney = 0;
|
|
|
+ $scope.filteredData = $filter('filter')($scope.data, $scope.condition.prodtitle || $scope.condition.uuorname || $scope.condition.venduuorname || $scope.condition.prodspec || $scope.condition.factory);
|
|
|
+ // var dateFrom = $scope.condition.dateFrom;
|
|
|
+ // var dateTo = $scope.condition.dateTo;
|
|
|
+ angular.forEach($scope.filteredData, function (item) {
|
|
|
+ // if ((item.pidate >= dateFrom || dateFrom == '') && (item.pidate < dateTo || dateTo == '')) {
|
|
|
+ item.$selected = $scope.checkboxes.checked;
|
|
|
+ // }
|
|
|
+ });
|
|
|
+ $scope.getTotalMoney();
|
|
|
+ };
|
|
|
|
|
|
- // 导出
|
|
|
- $scope.exportXls = function () {
|
|
|
- FaApCheck.exportXls({}, {}, function (data) {
|
|
|
- if (data.success){
|
|
|
- window.location.href = BaseService.getB2bUrl() + '/sale/apCheck/xls/list?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
|
|
|
- }
|
|
|
- }, function (response) {
|
|
|
- toaster.pop('error', '数据加载失败', response.data);
|
|
|
- });
|
|
|
- }
|
|
|
+ //获取已选单据总金额
|
|
|
+ $scope.getTotalMoney = function () {
|
|
|
+ $scope.totalMoney = 0;
|
|
|
+ angular.forEach($scope.data, function (check) {
|
|
|
+ if (check.$selected) {
|
|
|
+ var price = DecimalNumber.accMul((check.thischeckqty || 0), (check.orderprice || 0));
|
|
|
+ $scope.totalMoney += Math.round(price * 100) / 100;
|
|
|
+ } else {
|
|
|
+ $scope.totalMoney += 0;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 点击其中一个明细的复选框
|
|
|
+ $scope.checkOne = function (check) {
|
|
|
+ var result = true;
|
|
|
+ angular.forEach($scope.data, function (item) {
|
|
|
+ if (item.$selected != true) {
|
|
|
+ result = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.checkboxes.checked = result;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.haveSelected = false;
|
|
|
+
|
|
|
+ //生成应收对账单
|
|
|
+ $scope.createApCheck = function () {
|
|
|
+ //保存应收对账单主记录字段
|
|
|
+ $scope.apCheck = {
|
|
|
+ custUu: '',
|
|
|
+ custName: '',
|
|
|
+ enUu: '',
|
|
|
+ apDate: '',
|
|
|
+ beginDate: '',
|
|
|
+ endDate: '',
|
|
|
+ checkStatus: '未对账',
|
|
|
+ checkAmount: 0,
|
|
|
+ currency: '',
|
|
|
+ rate: '',
|
|
|
+ items: [],
|
|
|
+ taxrate: ''
|
|
|
+ };
|
|
|
+ //保存来源单据相关信息
|
|
|
+ var sourceInfos = [];
|
|
|
+
|
|
|
+
|
|
|
+ //所允许的本次对账最大最小数量
|
|
|
+ $scope.data.maxThisCheckQty = 0;
|
|
|
+ $scope.data.minThisCheckQty = 0;
|
|
|
+
|
|
|
+ $scope.sameCust = true;
|
|
|
+ $scope.validQty = true;
|
|
|
+ $scope.loading = true;
|
|
|
+
|
|
|
+ angular.forEach($scope.data, function (check) {
|
|
|
+ //保存应收对账单明细行数据
|
|
|
+ $scope.item = {
|
|
|
+ inoutno: '',
|
|
|
+ inoutnodetno: '',
|
|
|
+ orderCode: '',
|
|
|
+ orderClass: '',
|
|
|
+ orderDetno: '',
|
|
|
+ price: '',
|
|
|
+ checkQty: '',
|
|
|
+ amount: '',
|
|
|
+ sourceId: '',
|
|
|
+ sourceTable: '',
|
|
|
+ oldYCheckQty: '',
|
|
|
+ status: 0,
|
|
|
+ receiveCode: '',
|
|
|
+ receiveName: '',
|
|
|
+ prodCode: '',
|
|
|
+ prodTitle: '',
|
|
|
+ prodUnit: '',
|
|
|
+ prodSpec: '',
|
|
|
+ taxrate: '',
|
|
|
+ sendcode: '',
|
|
|
+ whname: '',
|
|
|
+ custUserUU: ''
|
|
|
+ };
|
|
|
+
|
|
|
+ //应收对账单明细行来源表信息
|
|
|
+ $scope.sourceInfo = {
|
|
|
+ sourceId: '',
|
|
|
+ sourceTable: '',
|
|
|
+ newYCheckQty: ''
|
|
|
+ };
|
|
|
+
|
|
|
+ //此次对账后新的已转数
|
|
|
+ $scope.newYCheckQty = 0;
|
|
|
+ if (check.$selected == true) {
|
|
|
+ $scope.apCheck.custName = check.custname;
|
|
|
+ $scope.apCheck.enUu = check.enuu;
|
|
|
+ $scope.apCheck.checkAmount += (check.thischeckqty || 0) * (check.orderprice || 0);
|
|
|
+ $scope.apCheck.apDate = check.pidate;
|
|
|
+ $scope.apCheck.rate = check.rate;
|
|
|
+
|
|
|
+ //必须是同一家客户才能生成对账单,否则提示错误
|
|
|
+ if ($scope.apCheck.custUu == '') {
|
|
|
+ $scope.apCheck.custUu = check.custuu;
|
|
|
+ } else if ($scope.apCheck.custUu !== check.custuu) {
|
|
|
+ $scope.sameCust = false;
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '请选择同一家客户');
|
|
|
+ }
|
|
|
+
|
|
|
+ //必须是相同币别才能生成对账单,否则提示错误
|
|
|
+ if ($scope.apCheck.currency == '') {
|
|
|
+ $scope.apCheck.currency = check.currency;
|
|
|
+ } else if ($scope.apCheck.currency !== check.currency) {
|
|
|
+ $scope.sameCust = false;
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '请选择同一种币别');
|
|
|
+ }
|
|
|
+
|
|
|
+ //必须是相同税率才能生成对账单,否则提示错误
|
|
|
+ if (!angular.isNumber($scope.apCheck.taxrate)) {
|
|
|
+ $scope.apCheck.taxrate = check.taxrate;
|
|
|
+ } else if ($scope.apCheck.taxrate != check.taxrate) {
|
|
|
+ $scope.sameCust = false;
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '请选择相同的税率');
|
|
|
+ }
|
|
|
+
|
|
|
+ //本次对账数量必须小于总对账数量
|
|
|
+ if (check.qty > 0) {
|
|
|
+ $scope.data.maxThisCheckQty = check.qty;
|
|
|
+ $scope.data.minThisCheckQty = 0;
|
|
|
+ if (check.qty - (check.ycheckqty || 0) < check.thischeckqty || check.thischeckqty < 0 || check.thischeckqty == 0) {
|
|
|
+ $scope.validQty = false;
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '本次对账数量,填写有误!');
|
|
|
+ }
|
|
|
+ } else if (check.qty < 0) {
|
|
|
+ $scope.data.maxThisCheckQty = 0;
|
|
|
+ $scope.data.minThisCheckQty = check.qty;
|
|
|
+ if (((-check.qty) - (-check.ycheckqty) < (-check.thischeckqty)) || check.thischeckqty > 0 || check.thischeckqty == 0) {
|
|
|
+ $scope.validQty = false;
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '本次对账数量,填写有误!');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取筛选时间的开始时间为对账的开始时间
|
|
|
+ $scope.apCheck.beginDate = $scope.fromDate;
|
|
|
+
|
|
|
+ //获取筛选的截止时间为对账的截止时间
|
|
|
+ $scope.apCheck.endDate = $scope.endDate;
|
|
|
+
|
|
|
+ //应收对账单明细行数据
|
|
|
+ $scope.item.orderCode = check.ordercode;
|
|
|
+ $scope.item.orderClass = check.piclass;
|
|
|
+ $scope.item.orderDetno = check.orderdetno;
|
|
|
+ $scope.item.price = check.orderprice;
|
|
|
+ $scope.item.checkQty = check.thischeckqty;
|
|
|
+ $scope.item.amount = (check.thischeckqty || 0) * (check.orderprice || 0);
|
|
|
+ $scope.item.sourceId = check.sourceid;
|
|
|
+ $scope.item.sourceTable = check.sourcetable;
|
|
|
+ $scope.item.oldYCheckQty = check.ycheckqty;
|
|
|
+ $scope.item.prodCode = check.prodcode;
|
|
|
+ $scope.item.prodTitle = check.prodtitle;
|
|
|
+ $scope.item.prodSpec = check.prodspec;
|
|
|
+ $scope.item.prodUnit = check.produnit;
|
|
|
+ $scope.item.inoutno = check.inoutno;
|
|
|
+ $scope.item.inoutnodetno = check.detno;
|
|
|
+ $scope.item.taxrate = check.taxrate;
|
|
|
+ $scope.item.receiveCode = check.receivecode;
|
|
|
+ $scope.item.receiveName = check.receivename;
|
|
|
+ $scope.item.sendcode = check.sendcode;
|
|
|
+ $scope.item.whname = check.whname;
|
|
|
+ $scope.item.custUserUU = check.custuseruu;
|
|
|
+
|
|
|
+ //来源表相关信息
|
|
|
+ $scope.sourceInfo.sourceid = check.sourceid;
|
|
|
+ $scope.sourceInfo.sourcetable = check.sourcetable;
|
|
|
+ $scope.sourceInfo.newYCheckQty = ((check.ycheckqty || 0) + check.thischeckqty);
|
|
|
+
|
|
|
+ sourceInfos.push($scope.sourceInfo);
|
|
|
+ $scope.apCheck.items.push($scope.item);
|
|
|
+ $scope.haveSelected = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //保存生成的应收对账单
|
|
|
+ $scope.saveApCheck = function () {
|
|
|
+ if ($scope.apCheck.items.length == 0) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '请先选择需要对账的数据');
|
|
|
+ } else {
|
|
|
+ FaApCheck.saveApCheck({}, $scope.apCheck, function (data) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('success', '成功', '生成应收对账成功');
|
|
|
+ $state.go('fa_apCheck_detail', {id: data.id}, {reload: true});
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '生成对账单失败', response.data);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ //如果是同一家客户,生成对账单的同时,关闭模态框
|
|
|
+ if ($scope.sameCust && $scope.validQty) {
|
|
|
+ $scope.saveApCheck();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 将日期转化为整数日期
|