Ver código fonte

巡检优化

seimin 2 anos atrás
pai
commit
c00aef1f60

+ 1 - 1
assets/js/config.router.js

@@ -1402,7 +1402,7 @@ app.config(['$authProvider', '$httpProvider', '$stateProvider', '$urlRouterProvi
1402 1402
 
1403 1403
             //巡检管理>巡检范围设置
1404 1404
             .state('app.inspectionScope', {
1405
-                url: '/inspectionScope/{model}',
1405
+                url: '/inspectionScope/{id}',
1406 1406
                 templateUrl: "assets/views/inspect/inspectionScope.html",
1407 1407
                 resolve: loadSequence('ui.select', 'multi.select.tree', 'angularBootstrapNavTree', 'spin', 'ladda', 'angular-ladda', 'inspectionScopeCtrl'),
1408 1408
                 title: 'Nav Manager',

+ 2 - 2
assets/js/controllers/inspect/inspectForm.js

@@ -636,7 +636,7 @@ sysFormly.controller('SystemformCtrl', ['$rootScope', '$scope', '$parse', '$filt
636 636
                                             // }, function() {
637 637
                                             //     $state.go($scope.formData.cancelUrl);
638 638
                                             // });
639
-                                            $state.go('app.inspectionScope',{ 'model': JSON.stringify(resData.data) });//跳转巡检范围设置-编辑
639
+                                            $state.go('app.inspectionScope',{ 'id': resData.data.id });//跳转巡检范围设置-编辑
640 640
                                         } else {
641 641
                                             SweetAlert.swal({
642 642
                                                 title: "提交失败",
@@ -670,7 +670,7 @@ sysFormly.controller('SystemformCtrl', ['$rootScope', '$scope', '$parse', '$filt
670 670
                                             // }, function() {
671 671
                                             //     $state.go($scope.formData.cancelUrl);
672 672
                                             // });
673
-                                            $state.go('app.inspectionScope',{ 'model': JSON.stringify(resData.data) });//跳转巡检范围设置-新增
673
+                                            $state.go('app.inspectionScope',{ 'id': resData.data.id });//跳转巡检范围设置-新增
674 674
                                         } else {
675 675
                                             SweetAlert.swal({
676 676
                                                 title: "系统错误",

+ 156 - 33
assets/js/controllers/inspect/inspectionScopeCtrl.js

@@ -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
         });

+ 25 - 2
assets/views/inspect/inspectionScope.html

@@ -533,7 +533,7 @@
533 533
                 
534 534
                         <div class="mainDivRight" ng-if="changecateObj.changecate && copyInspection.tree.length">
535 535
                             <div class="mainDiv-head">
536
-                                <!-- <span>服务目录修改</span> -->
536
+                                <span>默认组和默认人</span>
537 537
                             </div>
538 538
                             <div class="mainDiv-body">
539 539
                                 <div class="tab-mainDiv-body-lineDiv-50">
@@ -570,7 +570,7 @@
570 570
                 
571 571
                         <div class="mainDivRight" ng-if="!(changecateObj.changecate && copyInspection.tree.length)">
572 572
                             <div class="mainDiv-head">
573
-                                <span>操作提示</span>
573
+                                <span>默认组和默认人</span>
574 574
                             </div>
575 575
                             <div class="mainDiv-body">
576 576
                                 <div class="mainDiv-body-noList">
@@ -578,6 +578,29 @@
578 578
                                     <p class="handlefont">请选择巡检范围</p>
579 579
                                 </div>
580 580
                             </div>
581
+                            <div class="mainDiv-head">
582
+                                <span>通知规则</span>
583
+                            </div>
584
+                            <div class="mainDiv-body" style="padding: 16px;">
585
+                                <div>
586
+                                    <label>通知人:</label>
587
+                                    <ui-select class="tab-mainDiv-body-content" ng-model="notice.user"
588
+                                        theme="bootstrap" multiple>
589
+                                        <ui-select-match placeholder="">
590
+                                            {{$item.name}}
591
+                                        </ui-select-match>
592
+                                        <ui-select-choices repeat="item in incidentManageruserList | filter: $select.search">
593
+                                            <div ng-bind-html="item.name | highlight: $select.search"></div>
594
+                                        </ui-select-choices>
595
+                                    </ui-select>
596
+                                </div>
597
+                                <div style="margin-top: 8px;">
598
+                                    <label>通知选项:</label>
599
+                                    <div ng-repeat="item in notice.inspectionMsgRules">
600
+                                        <label style="cursor: pointer;"><input type="checkbox" name="inspectionMsgRules" ng-model="item.checked" style="position: relative;top:2px;margin-right:2px;">{{item.name}}</label>
601
+                                    </div>
602
+                                </div>
603
+                            </div>
581 604
                         </div>
582 605
                     </div>   
583 606
                 </div>