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