'use strict'; /** * controller for User Profile Example */ app.controller('indexesCtrl', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_schedule", "api_bpm_data","api_doc_data","api_user_data","api_wechatfile","$stateParams","api_bpm_domain","$http", function($rootScope, $scope, $state, $timeout, $interval, $modal, SweetAlert, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_schedule, api_bpm_data,api_doc_data,api_user_data,api_wechatfile,$stateParams,api_bpm_domain,$http) { $scope.langs = i18nService.getAllLangs(); $scope.lang = 'zh-cn'; i18nService.setCurrentLang($scope.lang); var loginUser = $rootScope.user; var defaultFilterData = { "assignee": loginUser.id, // "assignee": "1", "idx": 0, "sum": 10, "status": '', "searchType": "todo" }; var inspectListParameter = { "assignee": loginUser.id, // "assignee": "1", "idx": 0, "sum": 10, "status": '' }; // $scope.memoryfilterData = { // "idx": 0, // "sum": 10 // } //ui-grid设置 $scope.gridOptions = {}; $scope.gridOptions.data = 'myData'; $scope.gridOptions.enableColumnResizing = true; $scope.gridOptions.enableFiltering = true; $scope.gridOptions.enableGridMenu = false; $scope.gridOptions.enableSelectAll = false; $scope.gridOptions.enableRowSelection = true; $scope.gridOptions.showGridFooter = true; $scope.gridOptions.showColumnFooter = false; $scope.gridOptions.fastWatch = true; $scope.gridOptions.useExternalFiltering = true; $scope.gridOptions.useExternalPagination = true; $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100]; $scope.gridOptions.paginationPageSize = 10; $scope.gridOptions.multiSelect = true; // $scope.gridOptions.rowTemplate = '
123
"; $scope.gridOptions.rowIdentity = function(row) { return row.id; }; $scope.gridOptions.getRowIdentity = function(row) { return row.id; }; $scope.transferColor = function(item) { var color = "icon iconfont icon-zhengchang greenfont"; if (item && item.colourInfo) { if (item.colourInfo.id == 1) { color = "icon iconfont icon-yiyuqi redfont"; } else if (item.colourInfo.id == 2) { color = "iconfont icon-yuqixinxiu yellofont"; } } else { // color = "white"; } return color; } $scope.transfertip = function(item) { var tip = "正常"; if (item && item.colourInfo) { if (item.colourInfo.id == 1) { tip = "逾期"; } else if (item.colourInfo.id == 2) { tip = "即将逾期"; } } else { // color = "white"; } return tip; } $scope.gridOptions.columnDefs = [ // { // name: 'id', // displayName: '', // width: 40, // enableFiltering: false, // cellTemplate: '
' + // '
' // }, { name: 'item', displayName: '序号', width: '5%', cellTemplate: '
' + '
{{row.entity.item}}
' + '
', enableFiltering: false }, { name: 'fileName', displayName: '文档名称', width: '20%', enableFiltering: false }, { name: 'fileType', displayName: '文档格式', width: '10%', enableFiltering: false }, { name: 'fileSize', displayName: '大小', width: '10%', enableFiltering: false, cellTemplate: '
' + '
{{row.entity.fileSize/1024/1024|number:2}}MB
' + '
' }, { name: 'strUpdateTime', displayName: '更新时间', width: '15%', enableFiltering: false }, { name: 'fileVersion', displayName: '版本号', width: '8%', enableFiltering: false }, { name: '操作', width: '32%', enableFiltering: false, cellTemplate: '
' + '删除' + '下载' + // '更新' + '查看历史' + // '' + '
' }, ]; // 查看历史 $scope.seeHistory=function(getData){ var modalInstance = $modal.open({ backdrop: false, templateUrl: 'assets/views/customform/tpl/ui-jry_file_history.html', controller: function($scope, scope, $modalInstance,api_doc_data,SweetAlert) { var loginUser = $rootScope.user; $scope.langs = i18nService.getAllLangs(); $scope.lang = 'zh-cn'; i18nService.setCurrentLang($scope.lang); $scope.gridOptions = {}; $scope.gridOptions.data = 'myData'; $scope.gridOptions.enableColumnResizing = true; $scope.gridOptions.enableGridMenu = false; $scope.gridOptions.enableRowSelection = true; $scope.gridOptions.showGridFooter = true; $scope.gridOptions.showColumnFooter = false; $scope.gridOptions.fastWatch = true; $scope.gridOptions.useExternalFiltering = true; $scope.gridOptions.useExternalPagination = true; $scope.gridOptions.paginationPageSizes = [50]; $scope.gridOptions.paginationPageSize = 50; $scope.gridOptions.multiSelect = true; $scope.gridOptions.rowIdentity = function (row) { return row.id; }; $scope.gridOptions.getRowIdentity = function (row) { return row.id; }; $scope.gridOptions.columnDefs = [ { name: 'item', displayName: '序号', width: "10%", cellTemplate: '
' + '
{{row.entity.item}}
' + '
' }, { name: 'fileName', displayName: '文档名称', width: "30%", enableFiltering: false , cellTemplate: '
' + '
{{row.entity.fileName}}
' + '
' }, { name: 'fileVersion', displayName: '文档历史版本', width: "15%", enableFiltering: false , cellTemplate: '
' + '
{{row.entity.fileVersion}}
' + '
' }, { name: 'fileSize', displayName: '大小', width: '10%', enableFiltering: false, cellTemplate: '
' + '
{{row.entity.fileSize/1024/1024|number:2}}MB
' + '
' }, { name: 'strUpdateTime', displayName: '修改时间', width: "25%", enableFiltering: false , cellTemplate: '
' + '
{{row.entity.strUpdateTime}}
' + '
' }, { name: '编辑', cellTemplate: '
' + '下载' + '
', enableFiltering: false } ]; // 下载 $scope.down=function(listData){ console.log(listData) var data={ fileVersion:listData.fileVersion, fileId:getData.id }; var filename=listData.fileName+"."+getData.fileType; var wt_url_down = api_doc_data.download().getRequestedUrl() $http({ url: wt_url_down, method: 'POST', data:data, headers: { 'Accept': '*/*' }, responseType: 'arraybuffer' }).success(function (res) { // console.log(res); var file = new Blob([res], { type: 'application/octet-stream' }); var fileURL = URL.createObjectURL(file); console.log(fileURL); var a = document.createElement('a'); a.href = fileURL; a.target = '_blank'; a.download = filename; document.body.appendChild(a); a.click(); } ).error(function (data, status, headers, config) { }); } $scope.myData = []; $scope.getListData=function(){ var data={ fileId:getData.id } api_doc_data.fileVersion(data).then(function(res){ $scope.myData=res.list; angular.forEach($scope.myData,function(item,index){ $scope.myData[index].id=index; }) for (var i = 0; i < $scope.myData.length; i++) { $scope.myData[i]['item'] = i + 1 } $scope.gridOptions['totalItems'] = $scope.myData.length; }) } $scope.getListData(); $scope.cancel = function() { $modalInstance.dismiss('cancel'); } }, size: 'lg', resolve: { scope: function() { return $scope; }, }, backdrop:true }); } // 文件下载 $scope.doc_down=function(getData){ var data={ fileVersion:getData.fileVersion, fileId:getData.id }; var filename=getData.fileName+"."+getData.fileType; var wt_url_down = api_doc_data.download().getRequestedUrl() $http({ url: wt_url_down, method: 'POST', data:data, headers: { 'Accept': '*/*' }, responseType: 'arraybuffer' }).success(function (res) { // console.log(res); var file = new Blob([res], { type: 'application/octet-stream' }); var fileURL = URL.createObjectURL(file); console.log(fileURL); var a = document.createElement('a'); a.href = fileURL; a.target = '_blank'; a.download = filename; document.body.appendChild(a); a.click(); } ).error(function (data, status, headers, config) { }); } // 列表删除 $scope.list_delete=function(data){ // console.log(data); var data={ indexId:$scope.modify_data.id, fileid:[data.id] }; SweetAlert.swal({ title: "确认删除?", text: "删除的数据不可恢复,请确认继续操作!", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "继续删除", cancelButtonText: "取消操作", closeOnConfirm: false, closeOnCancel: false }, function (isConfirm) { if (isConfirm) { api_doc_data.data("deleteIndexFile",data).then(function (response) { if (response.status == 200) { SweetAlert.swal("操作成功!", "数据已经被删除.", "success"); $scope.refreshData('expand-right', $scope.jry_filterdata); } else { SweetAlert.swal("操作失败!", "数据暂时无法被删除,请稍候重试", "error"); } }); } else { SweetAlert.swal("操作取消", "数据安全", "error"); } }); } // $scope.addData = function() { // $state.go('app.inspection.inspectList.editor', { // formKey: 'inspectionform', // service: 'api_bpm_data' // }); // } $scope.selectRowFunction = function(data) { var filedata={ model:{inspectionProcessActual:data} } $state.go('app.inspection.inspectListEditor', { "taskId": data.taskId, "processInstanceId": data.processInstanceId, "pdKey": data.processKey, "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit, // "formUiName": data.inspection.inspectionTypeDTO.formUiName, "model" : JSON.stringify(filedata) }); }; $scope.lookFunction = function(data) { var filedata={ model:{inspectionProcessActual:data} // model:data } $state.go('app.inspection.inspectListdetail', { "formKey": data.inspection.inspectionTypeDTO.formUiName, "dataId": data.id, "taskId": data.taskId, "processInstanceId": data.processInstanceId, "pdKey": data.processKey, // "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit, "formUiName": data.inspection.inspectionTypeDTO.formUiName, "model" : JSON.stringify(filedata) }); }; $scope.selected = { items: [] } $scope.editted = { items: [] } //更换目录打开 $scope.open_files_change=function(){ console.log($scope.selected.items); if($scope.selected.items.length==0){ SweetAlert.swal({ title: "操作失败!", text: "请勾选至少一条文件", type: "error" }) }else{ var modalInstance = $modal.open({ backdrop: false, templateUrl: 'assets/views/customform/tpl/ui-jry_files_change.html', controller: function($scope, scope, $modalInstance,api_doc_data,SweetAlert) { // console.log(scope.selected.items); $scope.files_num=scope.selected.items.length;//文件夹的个数 $scope.search_tree_ipt="";//搜索框 $scope.change_file_name="";//更换的文件夹名称 $scope.change_file_id="";//更换的文件夹id //下拉树搜索 $scope.search_tree_fn=function(){ var data = { "idx": 0, "sum": 1000 ,documentFolder:{"name":$scope.search_tree_ipt}}; api_doc_data.fetchDataList('documentFolder', data).then(function(res){ $scope.search_tree_data=res.list }) } //搜出来的树点击 $scope.left_search_tree_cli=function(idx,val){ $scope.left_search_index=idx; $scope.change_file_name=val.label;//更换的文件夹名称 $scope.change_file_id=val.id;//更换的文件夹id } // 选中的文件夹 $scope.my_tree_handler=function(data){ console.log(data); $scope.change_file_name=data.label;//更换的文件夹名称 $scope.change_file_id=data.id;//更换的文件夹id } function convertListToTree(data, treeMap) { var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup var root = null; //Initially set our loop to null //loop over data for (var i = 0; i < data.length; i++) { var datum = data[i]; //each node will have children, so let's give it a "children" poperty datum.children = []; //add an entry for this node to the map so that any future children can //lookup the parent idToNodeMap[datum.id] = datum; //Does this node have a parent? // console.log("datum="+JSON.stringify(datum)) if (typeof datum.parent === "undefined"||datum.parent===null) { //Doesn't look like it, so this node is the root of the tree root = datum; treeMap[datum.id] = root; } else { //This node has a parent, so let's look it up using the id parentNode = idToNodeMap[datum.parent.id]; //We don't need this property, so let's delete it. // delete datum.parent; //Let's add the current node as a child of the parent node. parentNode.children.push(datum); } } return root; } function convertParentToChildList(data) { var treeMap = {}; var list = []; convertListToTree(data, treeMap); angular.forEach(treeMap, function(item) { list.push(item); }); return list; } $scope.parentdata = {}; $scope.try_async_load = function() { $scope.my_data = []; $scope.doing_async = true; var data = { "idx": 0, "sum": 1000 }; api_doc_data.fetchDataList('documentIndex', data).then(function(response) { var data = response.list; var objects = []; $scope.parentdata = data; for (var i = 0; i < data.length; i++) { var object = {}; object.id = data[i].id; if (angular.isDefined(data[i].parent)) { object.parent = data[i].parent; } if (angular.isDefined(data[i].hasArea)) { object.hasArea = data[i].hasArea; } if (angular.isDefined(data[i].hasSimple)) { object.hasSimple = data[i].hasSimple; } if (angular.isDefined(data[i].group)) { object.group = data[i].group; } if (angular.isDefined(data[i].priority)) { object.priority = data[i].priority; } object.label = data[i].name; // object.actions = data[i][3]; //权限部分 // object.group = "1"; // object.user = "2"; object.state = { "opened": true }; object.typeName = "type"; // if() // if (object.actions.indexOf("2") >= 0) { //知识库类型 具有增加权限--系统管理员 $scope.showAddSolutionType = true; // } // if (object.actions.indexOf("5") >= 0) { //知识库类型 具有授权权限--系统管理员 $scope.showReviewKnowledgeType = true; // } objects.push(object); } $scope.my_data = convertParentToChildList(objects); $scope.tree_data = angular.copy($scope.my_data); // if ($scope.my_data.length > 0) { $scope.doing_async = false; // } }); }; $scope.try_async_load(); $scope.ok = function(item) { // console.log(scope.selected.items); if($scope.change_file_id==""){ SweetAlert.swal({ title: "操作失败!", text: "请选择需要更换的文件夹", type: "error" }) }else{ var selectIdsArr=[]; for(var i=0;i0){ SweetAlert.swal("删除失败!", "请先删除该文件夹的子级", "error"); $scope.big_back=false; $('.deleteTree_box').fadeOut(); }else{ api_user_data.rmvData("documentIndex",[$scope.modify_data.id]).then(function (response) { if (response.status == 200) { SweetAlert.swal("操作成功!", "数据已经被删除.", "success"); $scope.modify_data=""; $scope.myData = []; $scope.removeFileNum=0; $scope.try_async_load(); $scope.big_back=false; $('.deleteTree_box').fadeOut(); } else { SweetAlert.swal("操作失败!", "数据暂时无法被删除,请稍候重试", "error"); $scope.big_back=false; $('.deleteTree_box').fadeOut(); } }); } }else{ SweetAlert.swal("删除失败!", "密码错误", "error"); } } // 文档格式下拉框 $scope.get_file_format=function(){ var data={ "type":"list", "key":"file_type" } api_wechatfile.getDictionary(data).then(function(res){ $scope.file_format=res }) } $scope.get_file_format() // 列表搜索按钮 $scope.list_search=function(){ console.log($scope.jry_filterdata); if($scope.fileTypeObj.fileType1&&$scope.fileTypeObj.fileType1.name){ $scope.jry_filterdata.fileType=$scope.fileTypeObj.fileType1.name } $scope.refreshData('expand-right', $scope.jry_filterdata); } // 文档格式 $scope.fileTypeObj={} // 清空 $scope.clean=function(){ $scope.jry_filterdata.fileName=""; $scope.jry_filterdata.content=""; $scope.fileTypeObj={}; $scope.jry_filterdata.fileType=""; $scope.refreshData('expand-right', $scope.jry_filterdata); } // // 树 var apple_selected, tree, treedata_avm, my_datatreedata_geography,parentNode; $scope.adddata = {}; // $scope.add_file_parent={}; var childdata = {}; // function convertchildToTree(datum) { // $scope.subdata = {}; // if (datum.parent) { // $scope.subdata = { 'id': datum.id, 'category': datum.label, 'parent': datum.parent, 'hasArea': datum.hasArea, 'hasSimple': datum.hasSimple, 'group': datum.group, 'priority': datum.priority } // } else { // $scope.subdata = { 'id': datum.id, 'category': datum.label, 'group': datum.group, 'hasSimple': datum.hasSimple, 'hasArea': datum.hasArea, 'priority': datum.priority } // } // } $scope.fenye=0; $scope.jry_filterdata={ "idx":$scope.fenye, "sum":10, "type":"index" }; // if(localStorage.getItem("rememberData")){ // $scope.jry_filterdata=JSON.parse(localStorage.getItem("rememberData")); // $scope.refreshData('expand-right', $scope.jry_filterdata); // } //左边树 $scope.my_tree_handler = function(branch) { console.log(branch); $scope.left_tree_select=branch; $scope.modify_data=$scope.left_tree_select; // var data={ // "idx":0, // "sum":10, // documentFile:{"folder":branch.id} // }; $scope.jry_filterdata["indexId"]=branch.id $scope.refreshData('expand-right', $scope.jry_filterdata); $scope.selected.items=[];//复选框清空 }; // function convertListToTree(data, treeMap) { // var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup // var root = null; //Initially set our loop to null // //loop over data // for (var i = 0; i < data.length; i++) { // var datum = data[i]; // //each node will have children, so let's give it a "children" poperty // datum.children = []; // //add an entry for this node to the map so that any future children can // //lookup the parent // idToNodeMap[datum.id] = datum; // //Does this node have a parent? // // console.log("datum="+JSON.stringify(datum)) // if (typeof datum.parent === "undefined"||datum.parent===null) { // //Doesn't look like it, so this node is the root of the tree // root = datum; // treeMap[datum.id] = root; // } else { // //This node has a parent, so let's look it up using the id // parentNode = idToNodeMap[datum.parent.id]; // //We don't need this property, so let's delete it. // // delete datum.parent; // //Let's add the current node as a child of the parent node. // parentNode.children.push(datum); // } // } // return root; // } // function convertParentToChildList(data) { // var treeMap = {}; // var list = []; // convertListToTree(data, treeMap); // angular.forEach(treeMap, function(item) { // list.push(item); // }); // return list; // } function convertParentToChildList(data) { var treeMap = []; var list = []; var idToNodeMap = {}; var root = null; for (var i = 0; i < data.length; i++) { var datum = data[i]; datum.children = []; idToNodeMap[datum.id] = datum; if (typeof datum.parent === "undefined"||datum.parent===null) { root = datum; treeMap.push(root); } else { parentNode = idToNodeMap[datum.parent.id]; parentNode.children.push(datum); } } return treeMap; } // 新增父类返回 $scope.onAddFilterCallback = function(item){ console.log(item); $(".parent_bring_box").fadeOut(); $scope.add_parent=item; } // 修改父类返回 $scope.onEditFilterCallback=function(item){ console.log(item); $scope.edit_parent=item; } $scope.parentdata = {}; $scope.try_async_load = function() { $scope.my_data = []; $scope.doing_async = true; var data = { "idx": 0, "sum": 1000 }; api_doc_data.fetchDataList('documentIndex', data).then(function(response) { var data = response.list; var objects = []; $scope.parentdata = data; for (var i = 0; i < data.length; i++) { var object = {}; object.id = data[i].id; if (angular.isDefined(data[i].parent)) { object.parent = data[i].parent; } if (angular.isDefined(data[i].hasArea)) { object.hasArea = data[i].hasArea; } if (angular.isDefined(data[i].hasSimple)) { object.hasSimple = data[i].hasSimple; } if (angular.isDefined(data[i].group)) { object.group = data[i].group; } if (angular.isDefined(data[i].priority)) { object.priority = data[i].priority; } object.label = data[i].name; // object.actions = data[i][3]; //权限部分 // object.group = "1"; // object.user = "2"; object.state = { "opened": true }; object.typeName = "type"; // if() // if (object.actions.indexOf("2") >= 0) { //知识库类型 具有增加权限--系统管理员 $scope.showAddSolutionType = true; // } // if (object.actions.indexOf("5") >= 0) { //知识库类型 具有授权权限--系统管理员 $scope.showReviewKnowledgeType = true; // } objects.push(object); } $scope.my_data = convertParentToChildList(objects); $scope.tree_data = angular.copy($scope.my_data); // if ($scope.my_data.length > 0) { $scope.doing_async = false; // } }); }; $scope.closethis = function(formdata) { formdata.category = ""; formdata.parent.category = ""; }; $scope.try_async_load(); // $scope.refreshData('expand-right', $scope.jry_filterdata); }]);