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