seimin пре 3 година
родитељ
комит
c11ed33a90

+ 66 - 2
assets/js/controllers/system/organizationdesign/placeCtrl.js

@@ -1,4 +1,4 @@
1
-app.controller('placeCtrl', ["$rootScope", "$scope", "$http", "$state", "$timeout", "$interval", "SweetAlert", "$modal", "FileUploader", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_user_data", function ($rootScope, $scope, $http, $state, $timeout, $interval, SweetAlert, $modal, FileUploader, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data) {
1
+app.controller('placeCtrl', ["$rootScope", "$scope", "$http", "$state", "$timeout", "$interval", "SweetAlert", "$modal", "FileUploader", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_user_data","api_cmdb2", function ($rootScope, $scope, $http, $state, $timeout, $interval, SweetAlert, $modal, FileUploader, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data,api_cmdb2) {
2 2
     $scope.langs = i18nService.getAllLangs();
3 3
     $scope.lang = 'zh-cn';
4 4
     $scope.cancles = true;
@@ -593,5 +593,69 @@ app.controller('placeCtrl', ["$rootScope", "$scope", "$http", "$state", "$timeou
593 593
     //      });
594 594
     //  }
595 595
 
596
-
596
+    // 2021
597
+    //导入模板
598
+    $scope.importDataTpl = function () {
599
+        var wt_url = api_user_data.importData1('areaPlace').getRequestedUrl();
600
+        var form = new FormData();
601
+        var file = document.getElementById("importTplIpt").files[0];
602
+        form.append('filename', file.name)
603
+        form.append('file', file);
604
+        console.log(document.getElementById("importTplIpt").files)
605
+        $http({
606
+            method: 'POST',
607
+            url: wt_url,
608
+            data: form,
609
+            headers: { 'Content-Type': undefined },
610
+            transformRequest: angular.identity
611
+        }).success(function (data) {
612
+            document.getElementById("importTplIpt").outerHTML = document.getElementById("importTplIpt").outerHTML;
613
+            if (data.status == 200) {
614
+                SweetAlert.swal({
615
+                    title: "导入成功",
616
+                    confirmButtonColor: "#007AFF",
617
+                    type: "success"
618
+                }, function (flag) {
619
+                    $scope.reset();
620
+                });
621
+            } else {
622
+                SweetAlert.swal({
623
+                    title: "导入失败",
624
+                    text: data.error,
625
+                    type: "error"
626
+                });
627
+            }
628
+        }).error(function (data) {
629
+            document.getElementById("importTplIpt").outerHTML = document.getElementById("importTplIpt").outerHTML;
630
+            SweetAlert.swal({
631
+                title: "导入失败",
632
+                text: data.error,
633
+                type: "error"
634
+            });
635
+        })
636
+    };
637
+    //导出模板
638
+    $scope.exportDataTpl = function () {
639
+        var wt_url = api_cmdb2.exportData1("downDataModels/operationSystem", {}).getRequestedUrl()
640
+        $http({
641
+            url: wt_url,
642
+            method: 'POST',
643
+            headers: {
644
+                'Accept': '*/*'
645
+            },
646
+            responseType: 'arraybuffer'
647
+        }).success(function (data, status, headers, config) {
648
+            var fileName = headers("Content-Disposition").split(";")[1].split("filename=")[1];
649
+            var file = new Blob([data], {
650
+                type: 'application/vnd.ms-excel'
651
+            });
652
+            var fileURL = URL.createObjectURL(file);
653
+            var a = document.createElement('a');
654
+            a.href = fileURL;
655
+            a.target = '_blank';
656
+            a.download = decodeURIComponent(fileName);
657
+            document.body.appendChild(a);
658
+            a.click();
659
+        }).error(function (data, status, headers, config) { });
660
+    };
597 661
 }]);

+ 3 - 0
assets/js/main.js

@@ -551,6 +551,9 @@ app.factory('api_user_data', ['UserRestangular', function (UserRestangular) {
551 551
         importData: function () {
552 552
             return dataService.one('/importData');
553 553
         },
554
+        importData1: function (type) {
555
+            return dataService.one('/importData/'+type);
556
+        },
554 557
         fetchDataList: function (model, data) {
555 558
             return dataService.customPOST(data, 'fetchDataList/' + model, {});
556 559
         },

+ 19 - 3
assets/views/system/organization/place.html

@@ -1,4 +1,13 @@
1 1
 <style>
2
+    #importTplIpt {
3
+        position: absolute;
4
+        top: 0;
5
+        right: 0;
6
+        left: 0;
7
+        bottom: 0;
8
+        opacity: 0;
9
+    }
10
+
2 11
     .mainDiv {
3 12
         /* background: red; */
4 13
         /* padding: 14px; */
@@ -45,6 +54,7 @@
45 54
         border-radius: 4px;
46 55
         margin-right: 10px;
47 56
         font-size: 14px;
57
+        position: relative;
48 58
     }
49 59
 
50 60
     .mainDiv-head-right {
@@ -213,7 +223,7 @@
213 223
         <!-- 谁固定谁在前 -->
214 224
         <div class="mainDivRight">
215 225
             <div class="mainDiv-head">
216
-                    <i style="font-size: 18px !important;" class="icon iconfont icon-quyu bluefont"></i>
226
+                <i style="font-size: 18px !important;" class="icon iconfont icon-quyu bluefont"></i>
217 227
                 <span>{{areaname}} 区域下的地点</span>
218 228
                 <div class="mainDiv-head-right">
219 229
                     <div class="btn btn_search" ng-click="addplace(areaData)" ng-show="xinzeng">新增</div>
@@ -229,7 +239,8 @@
229 239
                     <img src="./assets/images/place/icon_quesheng.png" alt="">
230 240
                     <p class="handlefont">请选择区域</p>
231 241
                 </div>
232
-                <div class="mainDiv-body-3" style="cursor: pointer;" ng-repeat="area in outplace" ng-click="clickplace(area);">
242
+                <div class="mainDiv-body-3" style="cursor: pointer;" ng-repeat="area in outplace"
243
+                    ng-click="clickplace(area);">
233 244
                     <div class="" ng-hide="editShow">
234 245
                         <!-- <div class=""> -->
235 246
                         <i style="font-size: 18px !important; margin-right: 10px;"
@@ -280,6 +291,10 @@
280 291
                 <div class="mainDiv-head-right">
281 292
                     <!-- <span class="mainDivLeft-span span-1 pointfont" ng-click="openmodel()">下载模板</span>
282 293
                     <span class="mainDivLeft-span span-2 pointfont" ng-click="importopen()">导入</span> -->
294
+                    <span class="mainDivLeft-span span-2 pointfont">
295
+                        导入
296
+                    <input type="file" id="importTplIpt" value="导入模板" onchange="angular.element(this).scope().importDataTpl();">
297
+                    </span>
283 298
                     <div class="btn btn_search" ng-click="addArea()" ng-show="xinzeng" ng-disabled="!cancles">新增</div>
284 299
                 </div>
285 300
 
@@ -289,7 +304,8 @@
289 304
                     <i style="font-size: 18px !important;" class="icon iconfont icon-quyu bluefont"></i>
290 305
                     <span>武汉大势恒通</span>
291 306
                 </div> -->
292
-                <div class="mainDiv-body-2" style="cursor: pointer;" ng-repeat="area in outarea" ng-click="ckickrow(area)">
307
+                <div class="mainDiv-body-2" style="cursor: pointer;" ng-repeat="area in outarea"
308
+                    ng-click="ckickrow(area)">
293 309
                     <div class="" ng-hide="editShow">
294 310
                         <span>{{ (area.area || '添加区域') | uppercase }}</span>
295 311
                         <div class="mainDiv-head-right">