productDetailCtrl.js
4.8 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
(function (angular) {
function productDetailCtrl($scope,productService,$stateParams,$state,$http,$sce,$uibModal) {
$scope.productId = $stateParams.id;
$scope.type = $stateParams.type;
$scope.showEdit = false;
$scope.qrCodeCheck = false;
switch($scope.type){
case '1':
$scope.source = '产品管理';
$scope.name = '查看与修改';
break;
case '2':
$scope.source = '产品查看';
$scope.name = '查看';
break;
case '3':
$scope.source = '产品维护';
$scope.name = '查看';
break;
}
$scope.getProductById=function(){
productService.getProductById({'id':$scope.productId},function(res){
$scope.productInfo = res.data;
if ($scope.type == 3 && $scope.productInfo.status == 5) {
$scope.qrCodeCheck = true;
}
if($scope.productInfo.status == 5){
// 已经上架不给修改
$scope.showEdit = false;
}else if($scope.type == 2 || ($scope.type == 3 && ($scope.productInfo.status != 1 && $scope.productInfo.status != 3))){
// 产品查看不行 产品维护时候不是待供应商完善和审核不通过不给修改
$scope.showEdit = false;
}else{
$scope.showEdit = true;
}
$scope.productInfo.description = $sce.trustAsHtml($scope.productInfo.description);
});
};
/*$scope.toPreview = function (){
console.log("点击图像")
}
*/
//点击图片时放大显示图片
$scope.changePic=function($event){
var img=$event.srcElement || $event.target;
angular.element("#bigimage")[0].src=img.src;
// console.log("点击"+angular.element("#bigimage")[0]);
angular.element("#js-imgview")[0].style.display="block";
angular.element("#js-imgview-mask")[0].style.display="block";
}
//点击图片时放小显示图片
$scope.closePic =function(){
angular.element("#js-imgview")[0].style.display="none";
angular.element("#js-imgview-mask")[0].style.display="none";
}
$scope.toEdit = function(){
$state.go('electronicDirectory.productUpdate',{id:$scope.productId,type:$scope.type});
};
$scope.openAuditDialog = function(id){
console.log(id)
var params = {};
params.ids = id;
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'productDetailAuditModal',
controller: 'productDetailAuditCtrl',
size: '40sm',
resolve: {
params: params
}
}).result.then(function(){
$scope.getProductById();
});
};
$scope.backClickEvent=function(){
switch($scope.type){
case '1':
$state.go('electronicDirectory.productManager',{supplierCode:''});
break;
case '2':
$state.go('electronicDirectory.productView');
break;
case '3':
$state.go('electronicDirectory.productMaintenance');
break;
}
};
$scope.qrCodeCheckOut = function () {
if ($scope.type == 2) {
$scope.qrCodeCheck = true;
}
}
$scope.init=function(){
$scope.getProductById();
$scope.qrCodeCheckOut();
$scope.qrImage = 'setmining/productInfo/qrcode?id='+$scope.productId;
};
$scope.init();
}
function productDetailAuditCtrl($scope, $uibModalInstance, productService, params){
$scope.auditSelect = '4';
$scope.confirm = function(queryParams) {
$scope.isWorking = true;
params.status = $scope.auditSelect;
params.auditReason = $scope.auditReason;
productService.changeStatus(params, function(result){
if(result.returnCode == '0'){
$uibModalInstance.close();
swal({type: 'success',title: '',text: result.message,closeOnConfirm: false,confirmButtonText: "确定",timer: 3000});
}else{
$uibModalInstance.close();
swal({type: 'error',title: '',text: result.message,closeOnConfirm: false,confirmButtonText: "确定",timer: 3000 });
}
$scope.isWorking = false;
});
};
$scope.cancel = function() {
$uibModalInstance.dismiss('cancel');
dtInstance.query();
};
}
angular.module('electronicDirectory',['ngSanitize'])
.controller('productDetailCtrl', productDetailCtrl)
.controller('productDetailAuditCtrl', productDetailAuditCtrl);
})(angular);