routingCtrl.js
7.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
(function (angular) {
function routingCtrl($scope, $rootScope, $state, toaster, routeConfig, DTColumnBuilder, DTOptionsBuilder, $uibModal, $http, Utils,financeService) {
//分页常量
let pageSize = 10;
$scope.previousName = '上一页';
$scope.nextName = '下一页';
$scope.currentPage = 1
$scope.maxSize = 10;
$scope.totalItems = 0
// 线下对账搜索参数
$scope.searchForm = {}
// 线上分账搜索参数
$scope.sForm = {}
// 菜单焦点
$scope.menuActive = 1;
// 菜单列表
$scope.menusList = [{id:1,name:'线下对账'},{id:2,name:'线上分账'}];
// 列表数据
$scope.dataList = []
// 统计数据
$scope.staticInfo = {}
// 时间绑定对象
$scope.divisionTime = []
// 分账时间类型 1:分账时间 2:订单支付时间
$scope.timeType = "1";
// 分账状态
$scope.statusList = {
1:'待分账',
2:'分账中',
3:'分账成功',
4:'分账失败'
}
// 分账类型
$scope.typeList = {
1:'线下对账',
2:'线上分账'
}
// 工厂常量
$scope.showMerchant = true;
$scope.factoryMerchantId = '';
$scope.provinceMerchantId = '';
$scope.cityMerchantId = '';
$scope.shopMerchantId = '';
//菜单点击事件
$scope.menusEvent = function(e){
$scope.menuActive = e.id;
$scope.searchForm = {};
$scope.currentPage = 1;
$scope.totalItems = 0
$scope.factoryMerchantId = '';
$scope.provinceMerchantId = '';
$scope.cityMerchantId = '';
$scope.shopMerchantId = '';
$scope.getList()
$scope.getStatic()
}
// 日期选择处理
$scope.drOptions = {
opens: 'right',
eventHandlers: {
'apply.daterangepicker':function(ev, picker){
$scope.searchForm.paySuccessDateStartDate = picker.startDate.format('YYYY-MM-DD HH:mm:ss');
$scope.searchForm.paySuccessDateEndDate = picker.endDate.format('YYYY-MM-DD HH:mm:ss');
$scope.searchForm.divisionTime = {
startDate: picker.startDate.format('YYYY-MM-DD') + ' 00:00:00',
endDate: picker.endDate.format('YYYY-MM-DD') + ' 23:59:59'
}
$scope.$apply()
},
'cancel.daterangepicker': function (ev, picker) {
// console.log('666666666666666')
$scope.searchForm.paySuccessDateStartDate = '';
$scope.searchForm.paySuccessDateEndDate = '';
$scope.searchForm.divisionTime = {
startDate:'',
endDate:''
}
$scope.$apply()
}
}
};
// 日期选择处理
$scope.dtOptions = {
opens: 'right',
eventHandlers: {
'apply.daterangepicker':function(ev, picker){
if($scope.timeType == 2){
$scope.searchForm.paySuccessDateStartDate = picker.startDate.format('YYYY-MM-DD HH:mm:ss');
$scope.searchForm.paySuccessDateEndDate = picker.endDate.format('YYYY-MM-DD HH:mm:ss');
}else{
$scope.searchForm.divisionStartDate = picker.startDate.format('YYYY-MM-DD HH:mm:ss');
$scope.searchForm.divisionEndDate = picker.endDate.format('YYYY-MM-DD HH:mm:ss');
}
$scope.searchForm.divisionTime = {
startDate: picker.startDate.format('YYYY-MM-DD') + ' 00:00:00',
endDate: picker.endDate.format('YYYY-MM-DD') + ' 23:59:59'
}
$scope.$apply()
},
'cancel.daterangepicker': function (ev, picker) {
$scope.searchForm.paySuccessDateStartDate = '';
$scope.searchForm.paySuccessDateEndDate = '';
$scope.searchForm.divisionStartDate = '';
$scope.searchForm.divisionEndDate = '';
$scope.searchForm.divisionTime = {}
$scope.$apply()
}
}
};
// 获取参数
function getParams(){
let oParams = {};
let o = JSON.parse(JSON.stringify($scope.searchForm));
oParams.pageSize = pageSize;
oParams.pageNum = $scope.currentPage;
o.shopMerchantId = $scope.factoryMerchantId;
if($scope.provinceMerchantId){
o.shopMerchantId = $scope.provinceMerchantId
}
if($scope.cityMerchantId){
o.shopMerchantId = $scope.cityMerchantId
}
if($scope.shopMerchantId){
o.shopMerchantId = $scope.shopMerchantId
}
// console.log($scope.factoryMerchantId);
// console.log($scope.provinceMerchantId);
// console.log($scope.cityMerchantId);
// console.log($scope.shopMerchantId);
delete o.divisionTime;
o.divisionType = $scope.menuActive;
oParams.condition = o;
return oParams;
}
// 获取线下对账列表
$scope.getList = function(){
let oParams = getParams();
financeService.getListWithPage(oParams,function(res){
// console.log(res)
let obj = res.data || {};
let list = obj.list || [];
$scope.dataList = list;
for(let i = 0; i < $scope.dataList.length; i++) {
$scope.dataList[i].upgradeGoodsName = $scope.dataList[i].goods.length ? '' : '-'
$scope.dataList[i].upgradeGoodsCommodityCode = $scope.dataList[i].goods.length ? '' : '-'
for (let j = 0; j < $scope.dataList[i].goods.length; j++) {
$scope.dataList[i].upgradeGoodsName = $scope.dataList[i].upgradeGoodsName + (j != 0 ? '/' : '') + $scope.dataList[i].goods[j].upgradeGoodsName
$scope.dataList[i].upgradeGoodsCommodityCode = $scope.dataList[i].upgradeGoodsCommodityCode + (j != 0 ? '/' : '') + $scope.dataList[i].goods[j].upgradeGoodsCommodityCode
}
}
$scope.totalItems = obj.total||0;
if(obj.total){
$scope.totalPage = (obj.total/pageSize)<1?1:Math.ceil((obj.total/pageSize));
}
})
}
//重置
$scope.rest = function(){
$scope.searchForm = {};
$scope.currentPage = 1;
$scope.showMerchant = false;
//$scope.divisionTime = []
$scope.factoryMerchantId = '';
$scope.provinceMerchantId = '';
$scope.cityMerchantId = '';
$scope.shopMerchantId = '';
$scope.$broadcast("reset")
$scope.onSearch();
}
// 获取分账统计数据
$scope.getStatic = function(){
let oParams = getParams().condition;
financeService.getCount(oParams,function(res){
console.log(res)
$scope.staticInfo = res.data || {}
})
}
// 导出excel
$scope.downExcel = function () {
var params = getParams().condition
// exportForm('orderDivision/exportGoodsOrderDivisionPage', params);
// Utils.exportExcel2('orderDivision/exportGoodsOrderDivisionPage',params,'分账报表列表');
financeService.exportFinanceList(params,function(res){
var data = JSON.parse(res.data)
aToExport(data.data)
})
}
function aToExport(url) {
var a = document.createElement('a')
a.setAttribute('id', 'exportToExport')
a.setAttribute('href', url)
a.setAttribute('target', '_blank')
document.body.appendChild(a)
a.click()
}
// 搜索
$scope.onSearch = function(){
$scope.getList()
$scope.getStatic()
}
// 监听时间切换
$scope.onChange = function(){
let o = $scope.searchForm;
delete o.divisionStartDate;
delete o.divisionEndDate;
delete o.paySuccessDateStartDate;
delete o.paySuccessDateEndDate;
delete o.divisionTime;
$scope.searchForm.divisionTime = [];
$scope.searchForm = o;
console.log($scope.searchForm)
}
// 初始化函数
$scope.init = function(){
$scope.getList()
$scope.getStatic()
}
$scope.init()
}
angular.module('finance').controller('routingCtrl', routingCtrl);
})(angular);