瀏覽代碼

巡检优化

seimin 2 年之前
父節點
當前提交
0b49429fdd

+ 4 - 1
assets/js/controllers/customform/customformCtrl.js

@@ -9900,12 +9900,15 @@ appFormly.config(function config(formlyConfigProvider) {
9900 9900
           5 * 60 * 1000
9901 9901
         );
9902 9902
         if ($scope.model[$scope.options.key]) {
9903
-        } else {
9903
+        } else if($scope.options.key === 'planStartTime' || $scope.options.key === 'planEndTime'){
9904
+          $scope.model[$scope.options.key] = '';
9905
+        }else{
9904 9906
           $scope.model[$scope.options.key] = $filter("date")(
9905 9907
             new Date(new Date().getTime()),
9906 9908
             $scope.options.templateOptions.datepickerPopup
9907 9909
           );
9908 9910
         }
9911
+        
9909 9912
         $scope.options.initialValue = $scope.model[$scope.options.key];
9910 9913
         $scope.endOpen = true;
9911 9914
         $scope.datepicker = {};

+ 42 - 0
assets/js/controllers/inspect/inspectPlanCtrl.js

@@ -180,6 +180,7 @@ app.controller('inspectPlanCtrl', ["$rootScope", "$scope", "$state", "$timeout",
180 180
                 // '<a ng-click="grid.appScope.runFunction(row.entity)" tooltip={{row.entity.runStatus}} tooltip-placement="left"><i class={{row.entity.style}}/></a>' +
181 181
                 '<a ng-click="grid.appScope.runFunction(row.entity)"  ng-show="{{row.entity.status.name==\'执行中\'&&grid.appScope.zantingzhixing}}"   class="bianjifont">暂停计划</a>' +
182 182
                 '<a ng-click="grid.appScope.runFunction(row.entity)" ng-show="{{row.entity.status.name==\'暂停中\'&&grid.appScope.zantingzhixing}}"   class="bianjifont">继续执行</a>' +
183
+                '<a ng-click="grid.appScope.executeOnce(row.entity)"  ng-show="{{row.entity.status.name!=\'配置中\'}}"  class="bianjifont">执行一次</a>' +
183 184
                 '</div>'
184 185
         },
185 186
         // { name: 'planTime2', displayName: '截止时间', width: 160, enableFiltering: false },
@@ -215,6 +216,47 @@ app.controller('inspectPlanCtrl', ["$rootScope", "$scope", "$state", "$timeout",
215 216
         });
216 217
 
217 218
     };
219
+    //执行一次
220
+    $scope.executeOnce = function (data) {
221
+        console.log(data);
222
+        var modalInstance = $modal.open({
223
+            // templateUrl: 'assets/views/inspect/changRun.html',
224
+            templateUrl: 'assets/views/delete.html',
225
+            // size: "sm",
226
+            controller: function ($scope, $modalInstance) {
227
+                $scope.title = '提示';
228
+                $scope.connect = '是否执行一次该巡检计划?';
229
+
230
+                $scope.ok = function () {
231
+                    $modalInstance.close(data);
232
+                };
233
+
234
+                $scope.cancel = function () {
235
+                    $modalInstance.dismiss('cancel');
236
+                };
237
+            },
238
+            size: 'sm'
239
+        })
240
+
241
+        modalInstance.result.then(function (result) {
242
+            console.log(result);
243
+            if (result) {
244
+                api_bpm_data.executeOnce({inspection:data}).then(function (response) {
245
+                    if(response.status == 200){
246
+                        SweetAlert.swal({
247
+                            title: "操作成功!",
248
+                            type: "success",
249
+                        });
250
+                    }else{
251
+                        SweetAlert.swal({
252
+                            title: "操作失败!",
253
+                            type: "error",
254
+                        });
255
+                    }
256
+                })
257
+            }
258
+        });
259
+    };
218 260
     //跳转到查看列表
219 261
     $scope.seeFunction = function (data) {
220 262
         var filedata = {

+ 109 - 30
assets/js/controllers/inspect/inspectionScopeCtrl.js

@@ -525,6 +525,78 @@ app.controller("inspectionScope", [
525 525
       }
526 526
       $scope.saveCommon($scope);
527 527
     };
528
+    // 暂存
529
+    $scope.submit1change_save = function (flag) {
530
+      $rootScope.isMask = true;
531
+      var arr = $scope.TreeToArr($scope.copyInspection.tree, []);
532
+      $scope.stateModel.modelName = $scope.modelName;
533
+      $scope.stateModel.typeIds = arr.map((v) => v.id).toString();
534
+      arr = arr.map((v) => ({
535
+        inspection: $scope.stateModel.id,
536
+        inspectionType: v.id,
537
+        inspectionTypeName: v.name,
538
+        parent: v.parent,
539
+        user: v.user?v.user.id:undefined,
540
+        userName: v.user?v.user.name:undefined,
541
+        group: v.group?v.group.id:undefined,
542
+        groupName: v.group?v.group.groupName:undefined,
543
+      }));
544
+      // 一条都没选择
545
+      if (arr.length === 0) {
546
+        arr.push({ inspection: $scope.stateModel.id });
547
+      }
548
+      console.log(arr);
549
+      // return;
550
+      api_simple.addListData("inspectionBind", arr).then(function (response) {
551
+        $rootScope.isMask = false;
552
+        if (response) {
553
+          if (response.status == 200) {
554
+            SweetAlert.swal(
555
+              {
556
+                title: "暂存成功!",
557
+                type: "success",
558
+              },
559
+              function () {
560
+                if(flag){
561
+                  window.history.back();
562
+                }else{
563
+                  $scope.selectedchangecategory.value = {};
564
+                  $scope.copyInspection.tree = [];
565
+                  $scope.changecateObj.changecate = false;
566
+                  $scope.selectedInspection.isShowZtree = false;
567
+                  setTimeout(()=>{
568
+                      $scope.selectedInspection.isShowZtree = true;
569
+                  },0)
570
+                }
571
+              }
572
+            );
573
+          } else {
574
+            SweetAlert.swal({
575
+              title: "保存失败!",
576
+              type: "error",
577
+            });
578
+          }
579
+        }
580
+      });
581
+    };
582
+    // 上一步
583
+    $scope.submit1change_prev = function(){
584
+      SweetAlert.swal(
585
+        {
586
+          title: "您是否暂存当前设置!",
587
+          type: "warning",
588
+          showCancelButton: true,
589
+          confirmButtonColor: "#DD6B55",
590
+          confirmButtonText: "是",
591
+          cancelButtonText: "否",
592
+        },
593
+        function (isConfirm) {
594
+          if (isConfirm) {
595
+            $scope.submit1change_save(true);
596
+          }
597
+        }
598
+      );
599
+    }
528 600
     $scope.closeModel = function () {
529 601
       $state.go("app.inspection.inspectPlan"); //跳转巡检计划列表
530 602
     };
@@ -547,6 +619,7 @@ app.controller("inspectionScope", [
547 619
         });
548 620
         return;
549 621
       }
622
+      $rootScope.isMask = true;
550 623
       var arr = $scope.TreeToArr($scope.copyInspection.tree, []);
551 624
       $scope.stateModel.modelName = $scope.modelName;
552 625
       $scope.stateModel.typeIds = arr.map((v) => v.id).toString();
@@ -567,6 +640,7 @@ app.controller("inspectionScope", [
567 640
       console.log(arr);
568 641
       // return;
569 642
       api_simple.addListData("inspectionBind", arr).then(function (response) {
643
+        $rootScope.isMask = false;
570 644
         if (response) {
571 645
           if (response.status == 200) {
572 646
             $scope.stateModel.status = { id: 120 }; //强制扭转状态为正常
@@ -745,12 +819,26 @@ app.directive("zTree", function () {
745 819
                   node.checked = true;
746 820
                   //注:设置checked属性之后,一定要更新该节点
747 821
                   zTree.updateNode(node);
822
+                  console.log($scope.copyInspectionType)
748 823
                   // 展开
749
-                  zTree.expandNode(node);
750
-                  setTimeout(() => {
751
-                    zTreeOnCheck(null, null, node);
752
-                  }, 0);
824
+                  // zTree.expandNode(node);
825
+                  // setTimeout(() => {
826
+                  //   zTreeOnCheck(null, null, node);
827
+                  // }, 0);
753 828
                 });
829
+                //展示选中的数据
830
+                var arr = [];
831
+                $scope.cachehttp.forEach(v=>{
832
+                  arr.push({
833
+                    id: v.inspectionType,
834
+                    name: v.inspectionTypeName,
835
+                    group: v.group?{id:v.group,groupName:v.groupName}:undefined,
836
+                    user: v.user?{id:v.user,name:v.userName}:undefined,
837
+                    parent: v.parent ? { id: v.parent.inspectionType } : undefined,
838
+                    pId: v.parent ? v.parent.inspectionType : 0,
839
+                  });
840
+                })
841
+                $scope.copyInspectionType = tranListToTreeData(arr);
754 842
               });
755 843
             // ==================end================
756 844
           });
@@ -840,17 +928,6 @@ app.directive("zTree", function () {
840 928
         var nodes_arr = treeObj.getCheckedNodes(true);
841 929
         var nodes = angular.copy(nodes_arr);
842 930
         console.log(nodes);
843
-        var arr = nodes.filter((v) => v.pId === 0);
844
-        arr.forEach((v) => {
845
-          v.children = [];
846
-        });
847
-        arr.forEach((v, i) => {
848
-          nodes.forEach((vv) => {
849
-            if (vv.pId == v.id) {
850
-              arr[i].children.push(vv);
851
-            }
852
-          });
853
-        });
854 931
         if ($scope.cachehttp && $scope.cachehttp.length) {
855 932
           var result = angular.copy($scope.cachehttp);
856 933
           zTreeOnCheckCommon(result, nodes);
@@ -867,6 +944,20 @@ app.directive("zTree", function () {
867 944
             });
868 945
         }
869 946
       }
947
+      function tranListToTreeData(nodes){
948
+        var arr = nodes.filter((v) => v.pId === 0);
949
+        arr.forEach((v) => {
950
+          v.children = [];
951
+        });
952
+        arr.forEach((v, i) => {
953
+          nodes.forEach((vv) => {
954
+            if (vv.pId == v.id) {
955
+              arr[i].children.push(vv);
956
+            }
957
+          });
958
+        });
959
+        return arr;
960
+      }
870 961
       // 点击复选框-common
871 962
       function zTreeOnCheckCommon(result, nodes) {
872 963
         // 如果有值,则不覆盖
@@ -884,8 +975,8 @@ app.directive("zTree", function () {
884 975
           result = result.map((v) => ({
885 976
             id: v.inspectionType,
886 977
             name: v.inspectionTypeName,
887
-            group: {id:v.group,groupName:v.groupName},
888
-            user: {id:v.user,name:v.userName},
978
+            group: v.group?{id:v.group,groupName:v.groupName}:undefined,
979
+            user: v.user?{id:v.user,name:v.userName}:undefined,
889 980
             parent: v.parent ? { id: v.parent.inspectionType } : undefined,
890 981
             pId: v.parent ? v.parent.inspectionType : 0,
891 982
           }));
@@ -898,19 +989,7 @@ app.directive("zTree", function () {
898 989
             }
899 990
           }
900 991
         }
901
-        var arr = nodes.filter((v) => v.pId === 0);
902
-        arr.forEach((v) => {
903
-          v.children = [];
904
-        });
905
-        arr.forEach((v, i) => {
906
-          nodes.forEach((vv) => {
907
-            if (vv.pId == v.id) {
908
-              arr[i].children.push(vv);
909
-            }
910
-          });
911
-        });
912
-        console.log(arr);
913
-        $scope.copyInspectionType = arr;
992
+        $scope.copyInspectionType = tranListToTreeData(nodes);
914 993
       }
915 994
     },
916 995
   };

+ 4 - 0
assets/js/main.js

@@ -947,6 +947,10 @@ app.factory('api_bpm_data', ['BpmRestangular', function (BpmRestangular) {
947 947
     var inspectionProcessActual = BpmRestangular.all("InspectionProcessActual");
948 948
     var solutionService = BpmRestangular.all("solution");
949 949
     return {
950
+        // 执行一次
951
+        executeOnce: function (data) {
952
+            return dataService.customPOST(data, 'triggerInspection');
953
+        },
950 954
         // 获取首页今日上班清空
951 955
         getManagerIndexInfo: function (data) {
952 956
             return dataService.customPOST(data, 'getManagerIndexInfo');

+ 3 - 1
assets/views/inspect/inspectionScope.html

@@ -583,7 +583,9 @@
583 583
                 <!-- 巡检范围结束 -->
584 584
             </div>
585 585
             <div class="inspection_btns col-xs-12">
586
-                <div class="btn btn_search" ng-click="submit1change()" ng-show="xinzeng">执行巡检计划</div>
586
+                <div class="btn btn_search" ng-click="submit1change_prev()" ng-show="xinzeng">上一步</div>
587
+                <div class="btn btn_search" ng-click="submit1change()" ng-show="xinzeng">开始计划</div>
588
+                <div class="btn btn_search" ng-click="submit1change_save()" ng-show="xinzeng">暂存</div>
587 589
                 <div class="btn btn_remove" ng-class="isMousedown?'btn_removeMousedown':''" ng-click="closeModel()" ng-show="shanchu">关闭</div>
588 590
             </div>
589 591
         </div>