|
|
@@ -4,7 +4,7 @@ define(['app/app'], function (app) {
|
|
|
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';
|
|
|
+ $rootScope.active = 'vendor_pay_center'
|
|
|
CurrentRole.isUser({}, {}, function (data) {
|
|
|
$scope.isUser = data.isUser;
|
|
|
});
|
|
|
@@ -12,9 +12,9 @@ define(['app/app'], function (app) {
|
|
|
$scope.condition = {dateZone: 1};
|
|
|
$scope.currency = Symbol.currency;//将币别转化为对应的符号
|
|
|
$scope.active = 'all';
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ $scope.apCheckCondition = {
|
|
|
+ $open: false
|
|
|
+ }
|
|
|
/* 时间筛选初始化*/
|
|
|
var fromDate = new Date();
|
|
|
var toDate = new Date();
|
|
|
@@ -74,25 +74,28 @@ define(['app/app'], function (app) {
|
|
|
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)
|
|
|
+ endDate: getDateTime($scope.condition.dateTo),
|
|
|
+ keyword: $scope.keyword
|
|
|
};
|
|
|
+ pageParams.keyword = $scope.keyword;
|
|
|
if ($scope.active === 'all') {
|
|
|
pageParams.keyword = $scope.keyword
|
|
|
var _fromDate = $scope.thisMouthOut + '-01 00:00:00'
|
|
|
- var _d = new Date(_fromDate)
|
|
|
+ // var _d = new Date(_fromDate)
|
|
|
+ _fromDate = _fromDate.replace(/-/g,'/')
|
|
|
+ var _d = new Date(_fromDate)
|
|
|
_d.setDate(1)
|
|
|
_d.setMonth(_d.getMonth() + 1)
|
|
|
_d.setDate(_d.getDate() - 1)
|
|
|
var _endDate = _d.getFullYear() + '-' + (_d.getMonth() + 1) + '-' + _d.getDate() + ' 00:00:00'
|
|
|
+ _endDate = _endDate.replace(/-/g,'/')
|
|
|
+ _fromDate = _fromDate.replace(/-/g,'/')
|
|
|
_endDate = new Date(_endDate).getTime()
|
|
|
_fromDate = new Date(_fromDate).getTime()
|
|
|
pageParams.searchFilter.fromDate = _fromDate
|
|
|
pageParams.searchFilter.endDate = _endDate
|
|
|
-
|
|
|
FaApCheck.customer(BaseService.parseParams(pageParams), function (page) {
|
|
|
$scope.loading = false;
|
|
|
page.content && page.content.forEach(function(list) {
|
|
|
@@ -110,14 +113,30 @@ define(['app/app'], function (app) {
|
|
|
}
|
|
|
})
|
|
|
list.totalCount = _k
|
|
|
+
|
|
|
+ var _MonthTodoCountArr = []
|
|
|
+ list.thisMonthTodoCount && list.thisMonthTodoCount.forEach(function(item) {
|
|
|
+ if (item.amount > 0) {
|
|
|
+ _MonthTodoCountArr.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ list.thisMonthTodoCount = _MonthTodoCountArr
|
|
|
+
|
|
|
+ var _MonthDoneCountArr = []
|
|
|
+ list.thisMonthDoneCount && list.thisMonthDoneCount.forEach(function(item) {
|
|
|
+ if (item.amount > 0) {
|
|
|
+ _MonthDoneCountArr.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ list.thisMonthDoneCount = _MonthDoneCountArr
|
|
|
})
|
|
|
if (page) {
|
|
|
params.total(page.totalElement);
|
|
|
$defer.resolve(page.content);
|
|
|
}
|
|
|
- $scope.ALLList = page.content
|
|
|
$scope.infoCommon = page
|
|
|
- $scope.infoCommon.all = page.content && page.content.length
|
|
|
+ $scope.infoCommon.all = page.content.length
|
|
|
+ $scope.ALLList = page.content
|
|
|
$scope.totalCount = page.totalElement;
|
|
|
}, function (response) {
|
|
|
$scope.loading = false;
|
|
|
@@ -129,8 +148,7 @@ define(['app/app'], function (app) {
|
|
|
if (page) {
|
|
|
params.total(page.totalElement);
|
|
|
$scope.data = $defer.resolve(page.content);
|
|
|
- $scope.infoCommon = page
|
|
|
- $scope.infoCommon.all = page.content && page.content.length
|
|
|
+
|
|
|
$scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
|
|
|
}
|
|
|
}, function (response) {
|
|
|
@@ -205,7 +223,8 @@ define(['app/app'], function (app) {
|
|
|
};
|
|
|
|
|
|
// 搜索框回车
|
|
|
- $scope.onSearch = function () {
|
|
|
+ $scope.onSearch = function (keyword) {
|
|
|
+ $scope.keyword = keyword;
|
|
|
$scope.tableParams.page(1);
|
|
|
$scope.tableParams.reload();
|
|
|
};
|
|
|
@@ -283,6 +302,7 @@ define(['app/app'], function (app) {
|
|
|
$scope.showNotCheck = true
|
|
|
$scope.suuorname = item.myEnterprise.enName
|
|
|
$scope.customerUU = item.myEnterprise.uu
|
|
|
+ $scope.thisMouth = $scope.thisMouthOut
|
|
|
this.searchOrder()
|
|
|
}
|
|
|
|
|
|
@@ -322,15 +342,16 @@ define(['app/app'], function (app) {
|
|
|
$scope.condition.venduuorname = $scope.vuuorname;
|
|
|
if ($scope.condition.dateTo != null || $scope.keywordXls != null) {
|
|
|
|
|
|
- $scope.fromDate = $scope.apCheckCondition.dateFrom ? $scope.apCheckCondition.dateFrom.getTime() : null;
|
|
|
- $scope.endDate = $scope.apCheckCondition.dateTo ? $scope.apCheckCondition.dateTo.getTime() : 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
|
|
|
+ suuorname: $scope.suuorname,
|
|
|
+ customerUU: $scope.customerUU
|
|
|
}
|
|
|
$scope.exportKeywords = encodeURIComponent($scope.searchKeyWord);
|
|
|
// $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
|
|
|
@@ -339,6 +360,8 @@ define(['app/app'], function (app) {
|
|
|
// toaster.pop('warning', '提示', '请先选择客户');
|
|
|
// document.getElementById('suuorname').focus();//光标默认在客户
|
|
|
// } else {
|
|
|
+ $scope.fromDate = $scope.apCheckCondition.dateFrom ? $scope.apCheckCondition.dateFrom.getTime() : null;
|
|
|
+ $scope.endDate = $scope.apCheckCondition.dateTo ? $scope.apCheckCondition.dateTo.getTime() : null;
|
|
|
$scope.loading = true;
|
|
|
var _params = {}
|
|
|
if ($scope.apCheckCondition.$open) {
|
|
|
@@ -367,24 +390,42 @@ define(['app/app'], function (app) {
|
|
|
}
|
|
|
}
|
|
|
FaApCheck.getAllByKeywords(_params, function (data) {
|
|
|
+ $scope.checkMain = data;
|
|
|
if (data.details.length > 0) {
|
|
|
angular.forEach(data.details, function (item) {
|
|
|
item.$selected = true;
|
|
|
});
|
|
|
var _mouthArr = []
|
|
|
- data.thisMonthCount.forEach(function(item) {
|
|
|
+ data.thisMonthCount && data.thisMonthCount.forEach(function(item) {
|
|
|
if (item.amount > 0) {
|
|
|
_mouthArr.push(item)
|
|
|
}
|
|
|
})
|
|
|
data.thisMonthCount = _mouthArr
|
|
|
var _totalArr = []
|
|
|
- data.totalCount.forEach(function(item) {
|
|
|
+ data.totalCount && data.totalCount.forEach(function(item) {
|
|
|
if (item.amount > 0) {
|
|
|
_totalArr.push(item)
|
|
|
}
|
|
|
})
|
|
|
data.totalCount = _totalArr
|
|
|
+
|
|
|
+ var _MonthTodoCountArr = []
|
|
|
+ data.thisMonthTodoCount && data.thisMonthTodoCount.forEach(function(item) {
|
|
|
+ if (item.amount > 0) {
|
|
|
+ _MonthTodoCountArr.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ data.thisMonthTodoCount = _MonthTodoCountArr
|
|
|
+
|
|
|
+ var _MonthDoneCountArr = []
|
|
|
+ data.thisMonthDoneCount && data.thisMonthDoneCount.forEach(function(item) {
|
|
|
+ if (item.amount > 0) {
|
|
|
+ _MonthDoneCountArr.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ data.thisMonthDoneCount = _MonthDoneCountArr
|
|
|
+
|
|
|
$scope.dataInfo = data
|
|
|
$scope.data = data.details;
|
|
|
$scope.checkboxes.checked = true;
|
|
|
@@ -410,8 +451,8 @@ define(['app/app'], function (app) {
|
|
|
if (angular.isDefined($scope.thisMouth)) {
|
|
|
url = url + '&checkDate=' + $scope.thisMouth;
|
|
|
}
|
|
|
- if (angular.isDefined($scope.receiveName)) {
|
|
|
- url = url + '&receiveName=' + $scope.receiveName;
|
|
|
+ if (angular.isDefined($scope.customerUU)) {
|
|
|
+ url = url + '&customerUU=' + $scope.customerUU;
|
|
|
}
|
|
|
if (angular.isDefined($scope.factory)) {
|
|
|
url = url + '&factory=' + $scope.factory;
|
|
|
@@ -422,9 +463,6 @@ define(['app/app'], function (app) {
|
|
|
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 + '&taxRate=' + $scope.taxRate;
|
|
|
}
|
|
|
@@ -445,10 +483,11 @@ define(['app/app'], function (app) {
|
|
|
$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;
|
|
|
+ if (item.haveChecked !== 1) {
|
|
|
+ // if ((item.pidate >= dateFrom || dateFrom == '') && (item.pidate < dateTo || dateTo == '')) {
|
|
|
+ item.$selected = $scope.checkboxes.checked;
|
|
|
+ }
|
|
|
// }
|
|
|
});
|
|
|
$scope.getTotalMoney();
|
|
|
@@ -458,20 +497,22 @@ define(['app/app'], function (app) {
|
|
|
$scope.getTotalMoney = function () {
|
|
|
$scope.totalMoney = 0;
|
|
|
angular.forEach($scope.data, function (check) {
|
|
|
- if (check.$selected) {
|
|
|
+ // if (check.$selected) {
|
|
|
var price = DecimalNumber.accMul((check.thischeckqty || 0), (check.orderprice || 0));
|
|
|
$scope.totalMoney += Math.round(price * 100) / 100;
|
|
|
- } else {
|
|
|
- $scope.totalMoney += 0;
|
|
|
- }
|
|
|
+ // } else {
|
|
|
+ // $scope.totalMoney += 0;
|
|
|
+ // }
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
// 点击其中一个明细的复选框
|
|
|
$scope.checkOne = function (check) {
|
|
|
+ if (check.haveChecked === 1) {
|
|
|
+ return
|
|
|
+ }
|
|
|
check.$selected = !check.$selected
|
|
|
-
|
|
|
$scope.Checkall()
|
|
|
};
|
|
|
$scope.stopPrevent = function(e) {
|
|
|
@@ -491,6 +532,7 @@ define(['app/app'], function (app) {
|
|
|
});
|
|
|
$scope.checkboxes.checked = result;
|
|
|
}
|
|
|
+
|
|
|
$scope.haveSelected = false;
|
|
|
|
|
|
//生成应收对账单
|
|
|
@@ -546,7 +588,8 @@ define(['app/app'], function (app) {
|
|
|
taxrate: '',
|
|
|
sendcode: '',
|
|
|
whname: '',
|
|
|
- custUserUU: ''
|
|
|
+ custUserUU: '',
|
|
|
+ sourceDate: ''
|
|
|
};
|
|
|
|
|
|
//应收对账单明细行来源表信息
|
|
|
@@ -558,7 +601,7 @@ define(['app/app'], function (app) {
|
|
|
|
|
|
//此次对账后新的已转数
|
|
|
$scope.newYCheckQty = 0;
|
|
|
- if (check.$selected == true) {
|
|
|
+ if (check.$selected == true && !check.haveChecked) {
|
|
|
$scope.apCheck.custName = check.custname;
|
|
|
$scope.apCheck.enUu = check.enuu;
|
|
|
$scope.apCheck.checkAmount += (check.thischeckqty || 0) * (check.orderprice || 0);
|
|
|
@@ -612,10 +655,10 @@ define(['app/app'], function (app) {
|
|
|
}
|
|
|
|
|
|
//获取筛选时间的开始时间为对账的开始时间
|
|
|
- $scope.apCheck.beginDate = $scope.fromDate;
|
|
|
+ // $scope.apCheck.beginDate = $scope.fromDate;
|
|
|
|
|
|
//获取筛选的截止时间为对账的截止时间
|
|
|
- $scope.apCheck.endDate = $scope.endDate;
|
|
|
+ // $scope.apCheck.endDate = $scope.endDate;
|
|
|
|
|
|
//应收对账单明细行数据
|
|
|
$scope.item.orderCode = check.ordercode;
|
|
|
@@ -639,7 +682,7 @@ define(['app/app'], function (app) {
|
|
|
$scope.item.sendcode = check.sendcode;
|
|
|
$scope.item.whname = check.whname;
|
|
|
$scope.item.custUserUU = check.custuseruu;
|
|
|
-
|
|
|
+ $scope.item.sourceDate = check.pidate
|
|
|
//来源表相关信息
|
|
|
$scope.sourceInfo.sourceid = check.sourceid;
|
|
|
$scope.sourceInfo.sourcetable = check.sourcetable;
|
|
|
@@ -650,7 +693,25 @@ define(['app/app'], function (app) {
|
|
|
$scope.haveSelected = true;
|
|
|
}
|
|
|
});
|
|
|
+ if ($scope.apCheckCondition.$open) {
|
|
|
+ $scope.fromDate = $scope.apCheckCondition.dateFrom ? $scope.apCheckCondition.dateFrom.getTime() : null;
|
|
|
+ $scope.endDate = $scope.apCheckCondition.dateTo ? $scope.apCheckCondition.dateTo.getTime() : null;
|
|
|
+ } else {
|
|
|
+ var _isShowApcheckList = $scope.thisMouth + '-01'
|
|
|
+ var _time1 = _isShowApcheckList
|
|
|
+ _time1 = _time1.replace(/-/g, '/')
|
|
|
+ var _d = new Date(_time1)
|
|
|
+ _d.setDate(1)
|
|
|
+ _d.setMonth(_d.getMonth() + 1)
|
|
|
+ _d.setDate(_d.getDate() - 1)
|
|
|
|
|
|
+ // 获取筛选时间的开始时间为对账的开始时间
|
|
|
+ var _time2 = _isShowApcheckList
|
|
|
+ _time2 = _time2.replace(/-/g, '/')
|
|
|
+ $scope.fromDate = new Date(_time2).getTime()
|
|
|
+ // 获取筛选的截止时间为对账的截止时间
|
|
|
+ $scope.endDate = _d.getTime()
|
|
|
+ }
|
|
|
//保存生成的应收对账单
|
|
|
$scope.saveApCheck = function () {
|
|
|
if ($scope.apCheck.items.length == 0) {
|
|
|
@@ -660,7 +721,7 @@ define(['app/app'], function (app) {
|
|
|
FaApCheck.saveApCheck({}, $scope.apCheck, function (data) {
|
|
|
$scope.loading = false;
|
|
|
toaster.pop('success', '成功', '生成应收对账成功');
|
|
|
- $state.go('fa_apCheck_detail', {id: data.id}, {reload: true});
|
|
|
+ $state.go('fa.apCheck_detail', {id: data.id}, {reload: true});
|
|
|
}, function (response) {
|
|
|
$scope.loading = false;
|
|
|
toaster.pop('error', '生成对账单失败', response.data);
|
|
|
@@ -672,14 +733,12 @@ define(['app/app'], function (app) {
|
|
|
if ($scope.sameCust && $scope.validQty) {
|
|
|
$scope.saveApCheck();
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
+ }
|
|
|
// 新增
|
|
|
$scope.MouthOutShow = true
|
|
|
$scope.MouthinShow = true
|
|
|
- $scope.apCheckCondition = {
|
|
|
- $open: false
|
|
|
- }
|
|
|
$scope.apCheckopenFilterDatePicker = function ($event, item, openParam) {
|
|
|
$event.preventDefault();
|
|
|
$event.stopPropagation();
|
|
|
@@ -690,7 +749,10 @@ define(['app/app'], function (app) {
|
|
|
};
|
|
|
$scope.addMouth = function(val) {
|
|
|
var _sp = new Date()
|
|
|
- var _time = new Date($scope.thisMouth)
|
|
|
+ // var _time = new Date($scope.thisMouth)
|
|
|
+ var _time = $scope.thisMouth + '-01'
|
|
|
+ _time = _time.replace(/-/g,'/')
|
|
|
+ _time = new Date(_time)
|
|
|
_time.setMonth(_time.getMonth() + val)
|
|
|
_time.setDate(1)
|
|
|
_time.setMonth(_time.getMonth() + 1)
|
|
|
@@ -702,12 +764,16 @@ define(['app/app'], function (app) {
|
|
|
}
|
|
|
$scope.thisMouth = _time.getFullYear() + '-' + (_time.getMonth() + 1)
|
|
|
$scope.apCheckCondition.$open = false
|
|
|
- $scope.searchOrder()
|
|
|
+ // $scope.searchOrder()
|
|
|
}
|
|
|
|
|
|
$scope.addMouthOut = function(val) {
|
|
|
var _sp = new Date()
|
|
|
- var _time = new Date($scope.thisMouthOut)
|
|
|
+ var _time = $scope.thisMouthOut + '-01'
|
|
|
+ _time = _time.replace(/-/g,'/')
|
|
|
+ _time = new Date(_time)
|
|
|
+ // var _time = new Date($scope.thisMouthOut)
|
|
|
+ // var _time = new Date($scope.thisMouthOut.replace(/-/g,'/'))
|
|
|
_time.setMonth(_time.getMonth() + val)
|
|
|
_time.setDate(1)
|
|
|
_time.setMonth(_time.getMonth() + 1)
|
|
|
@@ -718,8 +784,8 @@ define(['app/app'], function (app) {
|
|
|
$scope.MouthOutShow = true
|
|
|
}
|
|
|
$scope.thisMouthOut = _time.getFullYear() + '-' + (_time.getMonth() + 1)
|
|
|
- $scope.tableParams.page(1);
|
|
|
- $scope.tableParams.reload();
|
|
|
+ // $scope.tableParams.page(1);
|
|
|
+ // $scope.tableParams.reload();
|
|
|
}
|
|
|
|
|
|
$scope.hideshowNotCheck = function() {
|
|
|
@@ -729,6 +795,7 @@ define(['app/app'], function (app) {
|
|
|
$scope.$watch('thisMouthOut', function(newVal, oldVal) {
|
|
|
var _fromDate = new Date()
|
|
|
var _d = new Date(_fromDate)
|
|
|
+ // var _d = new Date(_fromDate.replace(/-/g,'/'))
|
|
|
_d.setDate(1)
|
|
|
_d.setMonth(_d.getMonth() + 1)
|
|
|
_d.setDate(_d.getDate() - 1)
|
|
|
@@ -740,7 +807,11 @@ define(['app/app'], function (app) {
|
|
|
return
|
|
|
}
|
|
|
if (newVal !== oldVal) {
|
|
|
- var _d = new Date(newVal)
|
|
|
+ // var _d = new Date(newVal)
|
|
|
+ var _d = newVal + '-01'
|
|
|
+ _d = _d.replace(/-/g,'/')
|
|
|
+ _d = new Date(_d)
|
|
|
+ // var _d = new Date(newVal.replace(/-/g,'/'))
|
|
|
_d.setDate(1)
|
|
|
_d.setMonth(_d.getMonth() + 1)
|
|
|
_d.setDate(_d.getDate() - 1)
|
|
|
@@ -757,6 +828,7 @@ define(['app/app'], function (app) {
|
|
|
$scope.$watch('thisMouth', function(newVal, oldVal) {
|
|
|
var _fromDate = new Date()
|
|
|
var _d = new Date(_fromDate)
|
|
|
+ // var _d = new Date(_fromDate.replace(/-/g,'/'))
|
|
|
_d.setDate(1)
|
|
|
_d.setMonth(_d.getMonth() + 1)
|
|
|
_d.setDate(_d.getDate() - 1)
|
|
|
@@ -768,7 +840,11 @@ define(['app/app'], function (app) {
|
|
|
return
|
|
|
}
|
|
|
if (newVal !== oldVal) {
|
|
|
- var _d = new Date(newVal)
|
|
|
+ // var _d = new Date(newVal)
|
|
|
+ var _d = newVal + '-01'
|
|
|
+ _d = _d.replace(/-/g,'/')
|
|
|
+ _d = new Date(_d)
|
|
|
+ // var _d = new Date(newVal.replace(/-/g,'/'))
|
|
|
_d.setDate(1)
|
|
|
_d.setMonth(_d.getMonth() + 1)
|
|
|
_d.setDate(_d.getDate() - 1)
|
|
|
@@ -783,7 +859,6 @@ define(['app/app'], function (app) {
|
|
|
})
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 将日期转化为整数日期
|
|
|
*/
|