/// /// /// module System{ export var SystemListController = controller('SystemListController', ['$scope', '$location', '$http', '$templateCache', 'Upload', 'NgTableParams', 'ngDialog', ($scope, $location, $http, $templateCache, Upload, NgTableParams, ngDialog) => { shareInit($scope); // 表头显示的信息 $scope.columns= [ { field: 'id', title: '操作', show: true}, { field: "object", title: "采集对象", filter: { object: "select" }, filterData: booleanChoose(), show: true }, { field: "city", title: "市", filter: { city: 'text' }, show: true }, { field: "county", title: "区/县", filter: { county: 'text' }, show: true }, { field: "regionalismCode", title: "行政区划代码", filter: {regionalismCode: 'text'}, show: true }, { field: "level", title: "级次", filter: { level: "select" }, filterData: levelType(), show: true }, { field: "systemCode", title: "系统编码", filter: { systemCode: "text" }, show: true }, { field: "systemName", title: "信息系统名称", filter: { systemName: "text" }, show: true }, { field: "contactsPerson", title: "联系人", filter: { contactsPerson: "text" }, show: true }, { field: "contactsMethod", title: "联系方式", filter: { contactsMethod: "text" }, show: true }, { field: "databaseType", title: "数据库类型", filter: { databaseType: "select" }, filterData: databaseType(), show: true}, { field: "userSql", title: "oracle用户名表空间", filter: { userSql: "select" }, filterData: booleanChoose(), show: true}, { field: "checkSql", title: "支付信息标准表脚本", filter: { checkSql: "select" }, filterData: booleanChoose(), show: true}, { field: "execSql", title: "可执行标准表脚本", filter: { execSql: "select" }, filterData: booleanChoose(), show: true}, ]; $scope.model = [{ id: 1, object: '是', city: '南京市', county: '玄武区', regionalismCode: '321001', level: '市级', systemCode: '5', systemName: '非税系统', contactsPerson: '唐僧', contactsMethod: '15575170786', databaseType: 'oracle', userSql: '是', checkSql: '是', execSql: '是' }, { id: 2, object: '是', city: '南京市', county: '浦口区', regionalismCode: '321011', level: '市级', systemCode: '5', systemName: '预算执行', contactsPerson: '唐僧', contactsMethod: '15675170786', databaseType: 'oracle', userSql: '是', checkSql: '是', execSql: '是' }] // 点击查看按钮事件处理函数 $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 = (files) =>{ var r = new Resumable({ target:'/java/console/api/fileOperation/file/upload', chunkSize:1*1024*1024, simultaneousUploads:4, testChunks: true, throttleProgressCallbacks:1, method: "octet" }); if(!r.support){ throw "当前浏览器不支持Resumable.js文件上传"; }else{ console.log(files); angular.forEach(files, (file) => { r.addFile(file); }) r.on('fileAdded', function(file){ console.log(file); r.upload(); }); r.on('complete', function(){ // Hide pause/resume when the upload has completed console.log("文件上传完毕"); }); r.on('fileProgress', function(file){ // Handle progress for both the file and the overall upload //$('.resumable-file-'+file.uniqueIdentifier+' .resumable-file-progress').html(Math.floor(file.progress()*100) + '%'); //$('.progress-bar').css({width:Math.floor(r.progress()*100) + '%'}); console.log(Math.floor(r.progress()*100) + '%'); }); } } //excel下载 $scope.downLoadExcelFile = () =>{ $http.get('/java/console/api/fileOperation/file/download', { responseType: 'arraybuffer' }) .success( function(data, status, headers) { var octetStreamMime = 'application/octet-stream'; var success = false; // Get the headers headers = headers(); // Get the filename from the x-filename header or default to "服务列表" var filename = headers['x-filename'] || '服务列表.xls'; // Determine the content type from the header or default to "application/octet-stream" var contentType = headers['content-type'] || octetStreamMime; try{ // Try using msSaveBlob if supported console.log("Trying saveBlob method ..."); var blob = new Blob([data], { type: contentType }); if(navigator.msSaveBlob) navigator.msSaveBlob(blob, filename); else { // Try using other saveBlob implementations, if available var saveBlob = navigator["webkitSaveBlob"] || navigator["mozSaveBlob"] || navigator["saveBlob"]; if(saveBlob === undefined) throw "Not supported"; saveBlob(blob, filename); } console.log("saveBlob succeeded"); success = true; } catch(ex){ console.log("saveBlob method failed with the following exception:"); console.log(ex); } if(!success){ // Get the blob url creator var urlCreator = window.URL || window["webkitURL"] || window["mozURL"] || window["msURL"]; if(urlCreator){ // Try to use a download link var link = document.createElement('a'); if('download' in link){ // Try to simulate a click try{ // Prepare a blob URL console.log("Trying download link method with simulated click ..."); var blob = new Blob([data], { type: contentType }); var url = urlCreator.createObjectURL(blob); link.setAttribute('href', url); // Set the download attribute (Supported in Chrome 14+ / Firefox 20+) link.setAttribute("download", filename); // Simulate clicking the download link var event = document.createEvent('MouseEvents'); event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null); link.dispatchEvent(event); console.log("Download link method with simulated click succeeded"); success = true; }catch(ex) { console.log("Download link method with simulated click failed with the following exception:"); console.log(ex); } } if(!success){ // Fallback to window.location method try{ // Prepare a blob URL // Use application/octet-stream when using window.location to force download console.log("Trying download link method with window.location ..."); var blob = new Blob([data], { type: octetStreamMime }); var url = urlCreator.createObjectURL(blob); window.location = url; console.log("Download link method with window.location succeeded"); success = true; }catch(ex){ console.log("Download link method with window.location failed with the following exception:"); console.log(ex); } } } } if(!success){ // Fallback to window.open method console.log("No methods worked for saving the arraybuffer, using last resort window.open"); window.open('_blank', ''); } }).error(function(data, status) { console.log("Request failed with status: " + status); // Optionally write the error out to scope $scope.errorDetails = "Request failed with status: " + status; }); } //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: '县'}]; } }]) }