employeeCtrl.js
7.26 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
(function(angular) {
function employeeCtrl($scope, DTOptionsBuilder, DTColumnBuilder, systemService, $uibModal, $filter, $state,Utils,$rootScope) {
$scope.openCardStatusList = [{id:true,name:'开通'},{id:false,name:'未开通'}];
$scope.fieldName='merchantId';
$scope.fieldName1='accountName';
$scope.dtColumns = [
DTColumnBuilder.newColumn('userId').withOption('width',60).withTitle('用户ID'),
DTColumnBuilder.newColumn('accountName').withOption('width',60).withTitle('登录账号'),
DTColumnBuilder.newColumn('duty').withOption('width',80).withTitle('主要职务'),
DTColumnBuilder.newColumn('name').withOption('width',80).withTitle('姓名/名称'),
DTColumnBuilder.newColumn('isOpenCard').withOption('width',80).withTitle('小程序名片').renderWith(function(e, dt, node, config) {
if(node.isOpenCard == '1'){
return "开通";
}
return "未开通";
}),
DTColumnBuilder.newColumn('photo').withOption('width',80).withTitle('头像').renderWith(function(e, dt, node, config){
if(node.photo){
return '<img src="' + node.photo + '" style="width: 100%;height:60px;">';
}
return "";
}),
DTColumnBuilder.newColumn('phone').withOption('width',100).withTitle('手机号'),
DTColumnBuilder.newColumn('wechatNum').withOption('width',80).withTitle('微信号'),
DTColumnBuilder.newColumn('customerNum').withOption('width',60).withTitle('客户数'),
DTColumnBuilder.newColumn('merchantId').withOption('width',80).withTitle('所属商户号'),
DTColumnBuilder.newColumn('merchantName').withOption('width',80).withTitle('所属商户名称'),
DTColumnBuilder.newColumn('roleList').withOption('width',100).withTitle('角色权限').renderWith(function(e, dt, node, config){
if(node.role){
return node.role.name;
}
return "";
}),
DTColumnBuilder.newColumn('updatedDate').withOption('width',120).withTitle('更新时间').renderWith(function(e, dt, node, config){
return $filter('date')(new Date(node.updatedDate), 'yyyy-MM-dd HH:mm:ss');
}),
DTColumnBuilder.newColumn(null).withTitle(function(){
return '操作';
}).withOption('width', 180).withClass('text-center').renderWith(function(data, type, full, oSettings) {
var str = '<div class="form-inline">'
+'<div class="form-group"><a class="btn btn-link" functional-contrl fc-menu="employee" fc-attrname="resetPasswordBtn" ng-click="resetPwd('+ data.employeeId +')">重置密码</a></div>'
+'<div class="form-group"><a class="btn btn-link" ng-click="addOrUpdate('+ data.employeeId +')">修改资料</a></div>';
if(data.role && !data.role.isSuper){
str +='<div class="form-group"><a class="btn btn-link" functional-contrl fc-menu="role" ng-click="toUpateRoleRight('+ data.role.id +')">修改角色权限</a></div>';
}
if($rootScope.loginUser.isSuper){
str +='<div class="form-group"><a class="btn btn-link" ng-click="bWebappManager(\''+ data.accountName +'\')">小程序功能</a></div>';
}
str += '</div>';
return str;
})
];
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withOption('id','categoryCode')
.withFixedColumns({
leftColumns: 0,
rightColumns: 1
})
$scope.dtInstance = {
serverData : systemService.getEmployeePageList
};
function getParams(){
var obj = {};
if($scope.name){
obj.name = $scope.name;
}
if($scope.fieldName1){
if($scope.fieldValue1){
obj[$scope.fieldName1] = $scope.fieldValue1;
}else {
obj[$scope.fieldName1] = '';
}
}
if($scope.fieldName){
if($scope.fieldValue){
if($scope.fieldName == 'merchantId'){
var m = -1;
if(/^[1-9]\d*$/.test($scope.fieldValue)){
m = parseInt($scope.fieldValue) || -1;
if(m > 2147483647){
m = -1;
}
}
obj[$scope.fieldName] = m;
}else{
obj[$scope.fieldName] = $scope.fieldValue;
}
}else {
obj[$scope.fieldName] = '';
}
}
if($scope.isOpenCard){
obj.isOpenCard = $scope.isOpenCard.id;
}
return obj;
}
//查询
$scope.submitForm = function(){
$scope.dtInstance.query(getParams());
}
$scope.addOrUpdate = function (employeeId) {
$uibModal.open({
templateUrl: 'biz/system/view/employeeAdd.html',
controller: 'employeeAddCtrl',
size: 'lg',
resolve: {
params: function () {
return {'employeeId':employeeId}
}
}
}).result.then(function (data) {
$scope.dtInstance.query(getParams());
},function(){
$scope.dtInstance.query(getParams());
})
};
$scope.resetPwd = function(employeeId){
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'resetPwdModal',
controller: 'resetPwdModalCtrl',
size: 'sm',
resolve: {
'employeeId': employeeId
}
});
}
$scope.exportExcel=function(){
var params = getParams();
Utils.exportExcel2('system/employee/export',params,'员工列表');
};
$scope.toUpateRoleRight=function(roleId){
$state.go('system.userAdmin.roleEdit',{id:roleId});
};
$scope.bWebappManager = function(accountName){
$uibModal.open({
templateUrl: 'biz/system/view/userAppOpen.html',
controller: 'userAppOpenCtrl',
size: 'lg',
resolve: {
params: function () {
return {'accountName':accountName}
}
}
});
};
}
function resetPwdModalCtrl($scope, $uibModalInstance, systemService, employeeId,$uibModal){
$scope.confirm = function() {
$scope.isWorking = true;
systemService.resetEmployeePwd({'employeeId':employeeId}, function(result){
if(result.returnCode == '0'){
$uibModalInstance.close();
$uibModal.open({
templateUrl: 'biz/system/view/clipboard.html',
controller: 'clipboardCtrl',
size: 'md',
resolve: {
params: function () {
return {
message: '重置后的密码为:'+ result.data,
content:result.data,
}
}
}
});
}else{
$uibModalInstance.close();
swal({type: 'error',title: '',text: result.message,closeOnConfirm: false,confirmButtonText: "确定" });
}
$scope.isWorking = false;
});
};
$scope.cancel = function() {
$uibModalInstance.dismiss('cancel');
};
}
angular.module('system').controller('employeeCtrl', employeeCtrl)
.controller('resetPwdModalCtrl', resetPwdModalCtrl)
})(angular);