wechatQrcodeCtrl.js
3.63 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
(function(angular) {
function wechatQrcodeCtrl($scope, DTOptionsBuilder, DTColumnBuilder, systemService,$uibModal, $filter, $state,Utils,$rootScope,SweetAlertX) {
$scope.wechatConfigList = [];
$scope.init = function(){
systemService.listWechatConfig({appType:'BIZ'},function(res){
if(res.returnCode == 0){
$scope.wechatConfigList = res.data;
$scope.wechatConfigList.unshift({'wechatAppid':'','wechatName':'全部','id':'0'});
}
});
};
$scope.init();
$scope.dtColumns = [
DTColumnBuilder.newColumn('wechatAppid').withOption('width',120).withTitle('公众号').renderWith(function(e, dt, node, config){
var wechatConfig = $filter('filter')($scope.wechatConfigList, { wechatAppid: node.wechatAppid }, true);
console.log(wechatConfig)
if(wechatConfig && wechatConfig.length > 0){
return wechatConfig[0].wechatName;
}
return "";
}),
DTColumnBuilder.newColumn('remark').withOption('width',120).withTitle('备注'),
DTColumnBuilder.newColumn('number').withOption('width',40).withTitle('数量'),
DTColumnBuilder.newColumn('permanent').withOption('width',80).withTitle('有效期').renderWith(function(e, dt, node, config){
if(node.permanent == 'Y'){
return '永久';
}else if(node.permanent == 'N'){
var text = "临时";
if(node.remainExpireSeconds > 0){
text += "(剩余" + node.remainExpireSeconds + "秒过期)";
}else{
text += "(已过期)";
}
return text;
}
return "";
}),
DTColumnBuilder.newColumn('createdBy').withOption('width',80).withTitle('创建人'),
DTColumnBuilder.newColumn('createdDate').withOption('width',120).withTitle('创建时间').renderWith(function(e, dt, node, config){
return $filter('date')(new Date(node.createdDate), 'yyyy-MM-dd HH:mm:ss');
}),
DTColumnBuilder.newColumn(null).withTitle('操作').withOption('width', 80).withClass('text-center').renderWith(function(e, dt, node, config) {
var str = '<div class="form-inline">'
+'<div class="form-group"><a class="btn btn-link" href="' + e.zipUrl + '" target="_blank">下载</a></div>';
str += '</div>';
return str;
})
];
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withOption('id','id')
.withFixedColumns({
rightColumns: 1
});
$scope.dtInstance = {
serverData : systemService.getWechatQrcodePageList
};
$scope.getParams =function(){
var condition = {};
if($scope.remark){
condition.remark = $scope.remark;
}
if($scope.wechatConfig){
condition.wechatAppid = $scope.wechatConfig.wechatAppid;
}
return {'condition':condition};
}
//查询
$scope.submitForm = function(){
$scope.dtInstance.query($scope.getParams());
}
$scope.createQrcode = function (wechatMenuId) {
$uibModal.open({
templateUrl: 'biz/system/view/wechatManager/wechatQrcodeCreate.html',
controller: 'wechatQrcodeCreateCtrl',
size: 'lg',
resolve: {
params: function () {
return {'wechatMenuId':wechatMenuId}
}
}
}).result.then(function (data) {
$scope.dtInstance.query($scope.getParams());
},function(){
$scope.dtInstance.query($scope.getParams());
})
};
}
angular.module('system').controller('wechatQrcodeCtrl', wechatQrcodeCtrl)
})(angular);