|
@@ -36,12 +36,89 @@ app.controller("inspectionScope", [
|
36
|
36
|
api_simple
|
37
|
37
|
) {
|
38
|
38
|
var loginUser = $rootScope.user;
|
39
|
|
- $scope.stateModel = JSON.parse($state.params.model);
|
40
|
|
- console.log($scope.stateModel);
|
41
|
|
- $scope.modelName = $scope.stateModel.modelName || $scope.stateModel.title;
|
42
|
|
- if ($scope.stateModel.model != 1) {
|
43
|
|
- $scope.stateModel.model = 0;
|
|
39
|
+ // 回显数据 start
|
|
40
|
+ $scope.stateModel = {id: $state.params.id};
|
|
41
|
+ $scope.getInspectionById= function () {
|
|
42
|
+ api_user_data.fetchgetData("inspection", $state.params.id).then((res) => {
|
|
43
|
+ console.log(res.data)
|
|
44
|
+ if(res.status == 200){
|
|
45
|
+ $scope.stateModel = res.data;
|
|
46
|
+ console.log($scope.stateModel);
|
|
47
|
+ $scope.modelName = $scope.stateModel.modelName || $scope.stateModel.title;
|
|
48
|
+ if ($scope.stateModel.model != 1) {
|
|
49
|
+ $scope.stateModel.model = 0;
|
|
50
|
+ }
|
|
51
|
+ // 通知规则
|
|
52
|
+ console.log($scope.incidentManageruserList)
|
|
53
|
+ console.log($scope.notice.inspectionMsgRules)
|
|
54
|
+ $scope.notice.user = [];
|
|
55
|
+ var msgRuleIds = $scope.stateModel.msgRules?$scope.stateModel.msgRules.split(','):[];
|
|
56
|
+ var msgUserIds = $scope.stateModel.msgUsers?$scope.stateModel.msgUsers.split(','):[];
|
|
57
|
+ if(msgRuleIds.length){
|
|
58
|
+ msgRuleIds.forEach(v => {
|
|
59
|
+ for (let i = 0; i < $scope.notice.inspectionMsgRules.length; i++) {
|
|
60
|
+ if($scope.notice.inspectionMsgRules[i].id == v){
|
|
61
|
+ $scope.notice.inspectionMsgRules[i].checked = true;
|
|
62
|
+ }
|
|
63
|
+ }
|
|
64
|
+ })
|
|
65
|
+ }
|
|
66
|
+ if(msgUserIds.length){
|
|
67
|
+ msgUserIds.forEach(v => {
|
|
68
|
+ let item = $scope.incidentManageruserList.find(vv => vv.id == v);
|
|
69
|
+ if(item){
|
|
70
|
+ $scope.notice.user.push(item);
|
|
71
|
+ }
|
|
72
|
+ })
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+ }
|
|
76
|
+ });
|
|
77
|
+ };
|
|
78
|
+ console.log($state.params.id)
|
|
79
|
+ // $scope.stateModel = JSON.parse($state.params.model);
|
|
80
|
+ // console.log($scope.stateModel);
|
|
81
|
+ // $scope.modelName = $scope.stateModel.modelName || $scope.stateModel.title;
|
|
82
|
+ // if ($scope.stateModel.model != 1) {
|
|
83
|
+ // $scope.stateModel.model = 0;
|
|
84
|
+ // }
|
|
85
|
+ // 回显数据 end
|
|
86
|
+ // 通知 start
|
|
87
|
+ // 获取事件经理角色的人
|
|
88
|
+ $scope.incidentManageruserList = [];
|
|
89
|
+ $scope.getUserListByRole = function () {
|
|
90
|
+ var postData = {
|
|
91
|
+ idx: 0,
|
|
92
|
+ sum: 1000,
|
|
93
|
+ "user": {
|
|
94
|
+ "roledata": {
|
|
95
|
+ "rolecode": "incident manager"
|
|
96
|
+ },
|
|
97
|
+ "simple": true
|
|
98
|
+ }
|
|
99
|
+ };
|
|
100
|
+ api_user_data.fetchDataList("user", postData).then((res) => {
|
|
101
|
+ $scope.incidentManageruserList = res.list;
|
|
102
|
+ $scope.getInspectionById();
|
|
103
|
+ });
|
|
104
|
+ };
|
|
105
|
+ // 通知规则
|
|
106
|
+ $scope.notice = {
|
|
107
|
+ user: [],
|
|
108
|
+ inspectionMsgRules: []
|
|
109
|
+ }
|
|
110
|
+ $scope.getInspectionMsgRules = function(){
|
|
111
|
+ var postData = {
|
|
112
|
+ key: "inspection_msg_rules",
|
|
113
|
+ type: "list"
|
|
114
|
+ }
|
|
115
|
+ api_wechatfile.getDictionary(postData).then(function (res) {
|
|
116
|
+ $scope.notice.inspectionMsgRules = res.map(v => ({...v, checked:false}));
|
|
117
|
+ $scope.getUserListByRole();
|
|
118
|
+ })
|
44
|
119
|
}
|
|
120
|
+ $scope.getInspectionMsgRules();
|
|
121
|
+ // 通知 end
|
45
|
122
|
$scope.xinzeng = false;
|
46
|
123
|
$scope.shanchu = false;
|
47
|
124
|
$scope.bianji = false;
|
|
@@ -502,6 +579,7 @@ app.controller("inspectionScope", [
|
502
|
579
|
});
|
503
|
580
|
// 保存设置 liaomingming
|
504
|
581
|
$scope.submit1change = function () {
|
|
582
|
+ console.log($scope.notice);
|
505
|
583
|
console.log($scope.copyInspection.tree);
|
506
|
584
|
console.log($scope.stateModel);
|
507
|
585
|
if ($scope.stateModel.model === 0) {
|
|
@@ -558,25 +636,58 @@ app.controller("inspectionScope", [
|
558
|
636
|
$rootScope.isMask = false;
|
559
|
637
|
if (response) {
|
560
|
638
|
if (response.status == 200) {
|
561
|
|
- SweetAlert.swal(
|
562
|
|
- {
|
563
|
|
- title: "暂存成功!",
|
564
|
|
- type: "success",
|
565
|
|
- },
|
566
|
|
- function () {
|
567
|
|
- if(flag){
|
568
|
|
- window.history.back();
|
569
|
|
- }else{
|
570
|
|
- $scope.selectedchangecategory.value = {};
|
571
|
|
- $scope.copyInspection.tree = [];
|
572
|
|
- $scope.changecateObj.changecate = false;
|
573
|
|
- $scope.selectedInspection.isShowZtree = false;
|
574
|
|
- setTimeout(()=>{
|
575
|
|
- $scope.selectedInspection.isShowZtree = true;
|
576
|
|
- },0)
|
|
639
|
+ var filedata = {
|
|
640
|
+ close: "关闭",
|
|
641
|
+ save: "暂存",
|
|
642
|
+ submit: "下一步",
|
|
643
|
+ inspection: $scope.stateModel,
|
|
644
|
+ };
|
|
645
|
+ console.log($scope.notice);
|
|
646
|
+ var inspectionMsgRules = $scope.notice.inspectionMsgRules.filter(v => v.checked);
|
|
647
|
+ var user = $scope.notice.user;
|
|
648
|
+ if(inspectionMsgRules.length){
|
|
649
|
+ filedata.inspection.msgRules = inspectionMsgRules.map(v=>v.id).toString()
|
|
650
|
+ }else{
|
|
651
|
+ delete filedata.inspection.msgRules;
|
|
652
|
+ }
|
|
653
|
+ if(user.length){
|
|
654
|
+ filedata.inspection.msgUsers = user.map(v=>v.id).toString()
|
|
655
|
+ }else{
|
|
656
|
+ delete filedata.inspection.msgUsers;
|
|
657
|
+ }
|
|
658
|
+ // 修改巡检计划 baba
|
|
659
|
+ api_bpm_data
|
|
660
|
+ .addData("inspection", filedata)
|
|
661
|
+ .then(function (response) {
|
|
662
|
+ if (response) {
|
|
663
|
+ if (response.status == 200) {
|
|
664
|
+ SweetAlert.swal(
|
|
665
|
+ {
|
|
666
|
+ title: "暂存成功!",
|
|
667
|
+ type: "success",
|
|
668
|
+ },
|
|
669
|
+ function () {
|
|
670
|
+ if(flag){
|
|
671
|
+ window.history.back();
|
|
672
|
+ }else{
|
|
673
|
+ $scope.selectedchangecategory.value = {};
|
|
674
|
+ $scope.copyInspection.tree = [];
|
|
675
|
+ $scope.changecateObj.changecate = false;
|
|
676
|
+ $scope.selectedInspection.isShowZtree = false;
|
|
677
|
+ setTimeout(()=>{
|
|
678
|
+ $scope.selectedInspection.isShowZtree = true;
|
|
679
|
+ },0)
|
|
680
|
+ }
|
|
681
|
+ }
|
|
682
|
+ );
|
|
683
|
+ } else {
|
|
684
|
+ SweetAlert.swal({
|
|
685
|
+ title: "保存失败!",
|
|
686
|
+ type: "error",
|
|
687
|
+ });
|
|
688
|
+ }
|
577
|
689
|
}
|
578
|
|
- }
|
579
|
|
- );
|
|
690
|
+ });
|
580
|
691
|
} else {
|
581
|
692
|
SweetAlert.swal({
|
582
|
693
|
title: "保存失败!",
|
|
@@ -659,6 +770,20 @@ app.controller("inspectionScope", [
|
659
|
770
|
submit: "下一步",
|
660
|
771
|
inspection: $scope.stateModel,
|
661
|
772
|
};
|
|
773
|
+ console.log($scope.notice);
|
|
774
|
+ var inspectionMsgRules = $scope.notice.inspectionMsgRules.filter(v => v.checked);
|
|
775
|
+ var user = $scope.notice.user;
|
|
776
|
+ if(inspectionMsgRules.length){
|
|
777
|
+ filedata.inspection.msgRules = inspectionMsgRules.map(v=>v.id).toString()
|
|
778
|
+ }else{
|
|
779
|
+ delete filedata.inspection.msgRules;
|
|
780
|
+ }
|
|
781
|
+ if(user.length){
|
|
782
|
+ filedata.inspection.msgUsers = user.map(v=>v.id).toString()
|
|
783
|
+ }else{
|
|
784
|
+ delete filedata.inspection.msgUsers;
|
|
785
|
+ }
|
|
786
|
+ // 修改巡检计划 baba
|
662
|
787
|
api_bpm_data
|
663
|
788
|
.addData("inspection", filedata)
|
664
|
789
|
.then(function (response) {
|
|
@@ -670,13 +795,6 @@ app.controller("inspectionScope", [
|
670
|
795
|
type: "success",
|
671
|
796
|
},
|
672
|
797
|
function () {
|
673
|
|
- // $scope.selectedchangecategory.value = {};
|
674
|
|
- // $scope.copyInspection.tree = [];
|
675
|
|
- // $scope.changecateObj.changecate = false;
|
676
|
|
- // $scope.selectedInspection.isShowZtree = false;
|
677
|
|
- // setTimeout(()=>{
|
678
|
|
- // $scope.selectedInspection.isShowZtree = true;
|
679
|
|
- // },0)
|
680
|
798
|
$state.go("app.inspection.inspectPlan"); //跳转巡检计划列表
|
681
|
799
|
}
|
682
|
800
|
);
|
|
@@ -963,12 +1081,17 @@ app.directive("zTree", function () {
|
963
|
1081
|
function tranListToTreeData(nodes){
|
964
|
1082
|
var arr = nodes.filter((v) => v.pId === 0);
|
965
|
1083
|
arr.forEach((v) => {
|
966
|
|
- v.children = [];
|
|
1084
|
+ // v.children = [];
|
|
1085
|
+ delete v.children;
|
967
|
1086
|
});
|
968
|
|
- arr.forEach((v, i) => {
|
|
1087
|
+ arr.forEach((v) => {
|
969
|
1088
|
nodes.forEach((vv) => {
|
970
|
1089
|
if (vv.pId == v.id) {
|
971
|
|
- arr[i].children.push(vv);
|
|
1090
|
+ if(v.children){
|
|
1091
|
+ v.children.push(vv);
|
|
1092
|
+ }else{
|
|
1093
|
+ v.children = [vv];
|
|
1094
|
+ }
|
972
|
1095
|
}
|
973
|
1096
|
});
|
974
|
1097
|
});
|