/// /// /// /// /// /// /// module System{ export var SystemListController = controller('SystemListController', ['$scope', '$location', '$http', '$templateCache', 'Upload', 'NgTableParams', 'ngDialog', 'SystemModel', ($scope, $location, $http, $templateCache, Upload, NgTableParams, ngDialog, SystemModel) => { shareInit($scope); $scope.modelServices = SystemModel; $scope.modelServices.updateExcelInfo(); $scope.model = SystemModel.systemInfoList; // 表头显示的信息 $scope.columns= [ { field: 'id', title: '操作', show: true}, { field: "collection", title: "采集对象", filter: { collection: "select" }, filterData: booleanChoose(), show: true }, { field: "cityName", title: "市", filter: { cityName: 'text' }, show: true }, { field: "districtName", title: "区/县", filter: { districtName: 'text' }, show: true }, { field: "areaCode", title: "行政区划代码", filter: {areaCode: 'text'}, show: true }, { field: "areaLevel", title: "地区级次", filter: { areaLevel: "select" }, filterData: levelType(), show: true }, { field: "sysName", title: "信息系统名称", filter: { sysName: "text" }, show: true }, { field: "departmentManager", title: "联系人", filter: { departmentManager: "text" }, show: true }, { field: "managerContacts", title: "联系方式", filter: { managerContacts: "text" }, show: true }, { field: "dataBaseType", title: "数据库类型", filter: { dataBaseType: "select" }, filterData: databaseType(), show: true}, { field: "userTablespaceStatus", title: "oracle用户名表空间", filter: { userTablespaceStatus: "select" }, filterData: booleanChoose(), show: true}, { field: "checkoutPayStatus", title: "支付信息标准表脚本", filter: { checkoutPayStatus: "select" }, filterData: booleanChoose(), show: true}, { field: "checkoutIndicateStatus", title: "可执行标准表脚本", filter: { checkoutIndicateStatus: "select" }, filterData: booleanChoose(), show: true}, ]; // 点击查看按钮事件处理函数 $scope.viewClick = (selected) => { ngDialog.open({ template: 'systemInfo.html', controller: 'Configs.SystemInfoController', width: 790, closeByDocument: false, data: selected, className: 'ngdialog-theme-default' }); } // 表数据 $scope.tableParams = new NgTableParams({count: 25}, { counts: [25, 50, 100], dataset: $scope.model }); // 文件上传 $scope.upLoadExcelFile = () => { Configs.FileInputPlugin((files) =>{ var fileNameList = []; //获取文件名列表 angular.forEach(files, (file) => { fileNameList.push(file.name); }); Configs.create_mask(); Kubernetes.create_locadEffect("正在上传文件..."); var target = document.getElementById('loading'); var spinner = new Spinner(Kubernetes.loadConfigs()).spin(target); var r = new Resumable({ target:'/java/console/api/fileOperation/file/upload', chunkSize:1*1024*1024, simultaneousUploads:4, testChunks: false, throttleProgressCallbacks:1, method: "octet" /*headers: { "Content-Type": "application/x-www-form-urlencoded;charset=utf-8" }*/ }); if(!r.support){ throw "当前浏览器不支持Resumable.js文件上传"; }else{ angular.forEach(files, (file) => { r.addFile(file); }) r.on('fileAdded', function(file){ r.upload(); }); r.on('complete', function(){ $('#loadmsg').html("所以文件上传完毕,正在读取文件中的数据,此过程时间可能会较长,请稍等..."); $.ajax({ type: "POST", url: UrlHelpers.join("/java/console/api/fileOperation/importExcel"), timeout: 8000 * fileNameList.length, dataType: 'json', data: JSON.stringify(fileNameList), contentType: "application/json; charset=utf-8", complete: (XMLHttpRequest, textStatus) =>{ $("#load").remove(); Kubernetes.removeMask(); if(XMLHttpRequest.status == 200){ Configs.customAlert("提示", "操作成功: 本次excel文件录入成功!", '',null, 0, "success"); }else{ Configs.customAlert("提示", "操作失败: 本次excel文件录入失败", '',null, 0, "error"); } }, success : (data) =>{ $scope.model = SystemModel.systemInfoList = data.data; $scope.tableParams.settings({ dataset: $scope.model }); }, error: (MLHttpRequest, textStatus, errorThrown) =>{ //Configs.customAlert("提示", "操作失败: 本次excel文件录入失败, " + textStatus, '',null, 0, "error"); } }); }); r.on('fileProgress', function(file){ $('#loadmsg').html("上传文件:" + file.fileName + " " + Math.floor(r.progress()*100) + '%'); //Kubernetes.create_locadEffect("上传文件:" + file.name + " " + Math.floor(r.progress()*100) + '%'); //创建数据加载效果层 }); //解决不同重复选择相同文件 var element = document.getElementById("file-uploads"); if(null != element) element.outerHTML = element.outerHTML; } }, true); } $scope.upLoadExcelFiles = (files) =>{ var fileNameList = []; //获取文件名列表 angular.forEach(files, (file) => { fileNameList.push(file.name); }); Configs.create_mask(); Kubernetes.create_locadEffect("正在上传文件..."); var target = document.getElementById('loading'); var spinner = new Spinner(Kubernetes.loadConfigs()).spin(target); var r = new Resumable({ target:'/java/console/api/fileOperation/file/upload', chunkSize:1*1024*1024, simultaneousUploads:4, testChunks: false, throttleProgressCallbacks:1, method: "octet" /*headers: { "Content-Type": "application/x-www-form-urlencoded;charset=utf-8" }*/ }); if(!r.support){ throw "当前浏览器不支持Resumable.js文件上传"; }else{ angular.forEach(files, (file) => { r.addFile(file); }) r.on('fileAdded', function(file){ r.upload(); }); r.on('complete', function(){ $('#loadmsg').html("所以文件上传完毕,正在读取文件中的数据,此过程时间可能会较长,请稍等..."); $.ajax({ type: "POST", url: UrlHelpers.join("/java/console/api/fileOperation/importExcel"), timeout: 8000 * fileNameList.length, dataType: 'json', data: JSON.stringify(fileNameList), contentType: "application/json; charset=utf-8", complete: (XMLHttpRequest, textStatus) =>{ $("#load").remove(); Kubernetes.removeMask(); if(XMLHttpRequest.status == 200){ Configs.customAlert("提示", "操作成功: 本次excel文件录入成功!", '',null, 0, "success"); }else{ Configs.customAlert("提示", "操作失败: 本次excel文件录入失败", '',null, 0, "error"); } }, success : (data) =>{ $scope.model = SystemModel.systemInfoList = data.data; $scope.tableParams.settings({ dataset: $scope.model }); }, error: (MLHttpRequest, textStatus, errorThrown) =>{ //Configs.customAlert("提示", "操作失败: 本次excel文件录入失败, " + textStatus, '',null, 0, "error"); } }); }); r.on('fileProgress', function(file){ $('#loadmsg').html("上传文件:" + file.fileName + " " + Math.floor(r.progress()*100) + '%'); //Kubernetes.create_locadEffect("上传文件:" + file.name + " " + Math.floor(r.progress()*100) + '%'); //创建数据加载效果层 }); //解决不同重复选择相同文件 var element = document.getElementById("file-uploads"); element.outerHTML = element.outerHTML; } } //excel下载 $scope.downLoadExcelFile = () =>{ Configs.downloadFile($scope, $http, '/java/console/api/fileOperation/file/download'); } $scope.downloadFilePackage = () =>{ Configs.create_mask(); Kubernetes.create_locadEffect("正在下载文件,请稍等..."); var target = document.getElementById('loading'); var spinner = new Spinner(Kubernetes.loadConfigs()).spin(target); Configs.downloadFile($scope, $http, '/java/console/api/filePackage/download', () =>{ $("#load").remove(); Kubernetes.removeMask(); }); } //boolean选择条件:是/否 function booleanChoose(){ return [{id: '是', title: '是'}, {id: '否', title: '否'}]; } // 数据库类型选择条件:oracle/sqlServer function databaseType(){ return [{id: 'oracle', title: 'ORACLE'}, {id: 'sqlServer', title: 'SQLSERVER'}]; } //level选择条件 function levelType(){ return [{id: '省', title: '省'}, {id: '市', title: '市'}, {id: '县', title: '县'}]; } }]) }