1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297 |
- '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 = '<div style="background: red"><a>123</a></div';
- // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.onDblClick(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
- $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: '<div>' +
- // '<div class="ui-grid-cell-contents" tooltip={{grid.appScope.transfertip(row.entity.ruleColour)}} tooltip-placement="right"><i style="font-size: 18px !important;" class="{{grid.appScope.transferColor(row.entity.ruleColour)}}"></i></div></div>'
- // },
- {
- name: 'item',
- displayName: '序号',
- width: '5%',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
- '</div>',
- enableFiltering: false
- },
- {
- name: 'fileName',
- displayName: '文档名称',
- width: '20%',
- enableFiltering: false
- },
- {
- name: 'fileType',
- displayName: '文档格式',
- width: '10%',
- enableFiltering: false
- },
- {
- name: 'fileSize',
- displayName: '大小',
- width: '10%',
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.fileSize/1024/1024|number:2}}MB</div>' +
- '</div>'
- },
- {
- name: 'strUpdateTime',
- displayName: '更新时间',
- width: '15%',
- enableFiltering: false
- },
- {
- name: 'fileVersion',
- displayName: '版本号',
- width: '8%',
- enableFiltering: false
- },
- {
- name: '操作',
- width: '32%',
- enableFiltering: false,
- cellTemplate: '<div class="cl-effect-1 ui-grid-cell-contents pull-left">' +
- '<a ng-click="grid.appScope.list_delete(row.entity)" tooltip="删除" tooltip-placement="left">删除</a>' +
- '<a ng-click="grid.appScope.doc_down(row.entity)" tooltip="下载" tooltip-placement="left" class="bianjifont">下载</a>' +
- // '<a ng-click="grid.appScope.selectRowFunction(row.entity)" tooltip="更新" tooltip-placement="right" class="bianjifont">更新</a>' +
- '<a ng-click="grid.appScope.seeHistory(row.entity)" tooltip="查看历史" tooltip-placement="left" class="bianjifont">查看历史</a>' +
- // '<a ng-show="{{!row.entity.state==1}}" ng-click="grid.appScope.selectRowFunction(row.entity)" tooltip="编辑" tooltip-placement="left"><i class="fa fa-pencil-square-o"/></a>' +
- '</div>'
- },
- ];
- // 查看历史
- $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: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
- '</div>'
- },
- {
- name: 'fileName',
- displayName: '文档名称',
- width: "30%",
- enableFiltering: false ,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.fileName}}</div>' +
- '</div>'
- },
- {
- name: 'fileVersion',
- displayName: '文档历史版本',
- width: "15%",
- enableFiltering: false ,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.fileVersion}}</div>' +
- '</div>'
- },
- {
- name: 'fileSize',
- displayName: '大小',
- width: '10%',
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.fileSize/1024/1024|number:2}}MB</div>' +
- '</div>'
- },
- {
- name: 'strUpdateTime', displayName: '修改时间', width: "25%", enableFiltering: false ,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.strUpdateTime}}</div>' +
- '</div>'
- },
- {
- name: '编辑',
- cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
- '<a ng-click="grid.appScope.down(row.entity)">下载</a>' +
- '</div></div>',
- 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;i<scope.selected.items.length;i++){
- selectIdsArr.push(scope.selected.items[i].id)
- };
- api_doc_data.jry_indexesChange(scope.modify_data.id,$scope.change_file_id,selectIdsArr).then(function(res){
- if(res.status==200){
- SweetAlert.swal({
- title: "更换成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function() {
- $modalInstance.dismiss('cancel');
- scope.refreshData('expand-right', scope.jry_filterdata);
- });
- }else{
- SweetAlert.swal({
- title: "更换失败!",
- text: "系统错误,请稍后再试!",
- type: "error"
- })
- }
- })
- }
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- scope: function() {
- return $scope;
- },
- },
- backdrop:true
- });
- }
- }
- //分页控制
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- var filterData = JSON.parse(sessionStorage.inspectListParameter);
- $scope.jry_filterdata.idx = newPage - 1;
- $scope.jry_filterdata.sum = pageSize;
- $scope.refreshData('expand-right', $scope.jry_filterdata);
- });
- // 复选框单选
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- // console.log(data);
- if (data.isSelected) {
- data.grid.appScope.selected.items.push(data.entity);
- } else {
- for (var i = 0; i <= data.grid.appScope.selected.items.length; i++) {
- if (data.grid.appScope.selected.items[i].id == data.entity.id) {
- data.grid.appScope.selected.items.splice(i, 1);
- break;
- }
- }
- };
- // $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
- });
- // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- // data.grid.appScope.selected.items = data.entity
- // console.log(data);
- // });
- }
- //本地存储
- sessionStorage.inspectListParameter = JSON.stringify(inspectListParameter);
- // var data = JSON.parse(sessionStorage.inspectListParameter);
- // sessionStorage.inspectListParameter = JSON.stringify(data);
- $scope.ldloading = {};
- // //搜索事件
- // $scope.searchinspectlist = function(item) {
- // var filterData = JSON.parse(sessionStorage.inspectListParameter);
- // if (item.type) {
- // filterData.status = item.type.id;
- // }
- // if (item.title||item.title=="") {
- // filterData.title = item.title;
- // }
- // // filterData.status = item;
- // sessionStorage.inspectListParameter = JSON.stringify(filterData);
- // $scope.refreshData('expand-right', filterData);
- // };
- // //搜索栏点击事件
- // $scope.searchstate = 'todo';
- // $scope.onChange = function(searchType) {
- // $scope.searchstate = searchType;
- // var filterData = JSON.parse(sessionStorage.inspectListParameter);
- // filterData.searchType = searchType;
- // sessionStorage.inspectListParameter = JSON.stringify(filterData);
- // $scope.refreshData('expand-right', filterData);
- // }
- // $scope.reload = function() {
- // var filterData = JSON.parse(sessionStorage.inspectListParameter);
- // $scope.refreshData('expand-right', filterData);
- // }
- $scope.removeFileNum=0;//删除文件夹下文件的个数
- $scope.refreshData = function(style, filterData) {
- $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- $scope.myData = [];
- $scope.memoryfilterData = filterData;
- api_doc_data.selectContent(filterData).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.removeFileNum=myData.totalNum;
- if (angular.isArray(myData.list)) {
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- //添加序号
- $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- }
- // else {
- // $scope.ldloading[style.replace('-', '_')] = false;
- // SweetAlert.swal({
- // title: "数据为空",
- // text: myData.data,
- // type: "warning"
- // });
- // }
- }, function() {
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- };
- // 新增弹框
- $scope.add_file_name="";//新增文件夹名称
- $scope.add_parent="";//新增所选父名称
- $scope.edit_parent="";//修改所选父名称
- $scope.left_tree_select="";//左边树选择
- $scope.modify_data="";//修改树
- $scope.search_tree_ipt="";//左侧下拉树搜索框
- $scope.search_tree_data="";//左侧下拉树搜出来数据
- $scope.modify_file_name="";//修改内容
- $scope.big_back=false;//大蒙版
- $scope.addparent=false;//新增父类开关
- $scope.add_duoci=false;//防止新增保存多次
- $scope.delete_password="";//删除树确认删除密码
- $scope.file_manage="";//文档管理员
- // $scope.add_box=false;//新增弹框
- // 打开引入
- $scope.open_introduce=function(){
- if($scope.modify_data==""){
- SweetAlert.swal({
- title: "操作失败!",
- text: "请选择需引入文件夹",
- type: "error"
- })
- }else{
- // localStorage.setItem("rememberData",JSON.stringify($scope.jry_filterdata));
- $state.go('app.file.open_indexes', { fileMessage:JSON.stringify($scope.modify_data) });
- }
- }
- // console.log(localStorage.getItem('haha'))
- //新增保存
- $scope.add_save=function(){
- // console.log($scope.add_file_parent)
- if($scope.addparent==false){
- var data={
- documentIndex:{
- name:$scope.add_file_name,
- }
- };
- if($scope.add_file_name==""){
- SweetAlert.swal({
- title: "操作失败!",
- text: "必填项不能为空",
- type: "error"
- })
- }else{
- $scope.add_duoci=true;
- if($scope.add_duoci==true){
- api_user_data.addData("documentIndex",data).then(function(res){
- if(res.status==200){
- if(res.data.error){
- $scope.big_back=false;//大蒙版
- $scope.addparent=false;
- $scope.add_file_name="";
- $scope.modify_data="";
- $(".add_new_box").fadeOut();
- $(".parent_bring_box").fadeOut();
- $scope.try_async_load();
- $scope.add_parent="";
- SweetAlert.swal({
- title: "新增失败!",
- text: res.data.error,
- type: "error"
- })
- $scope.add_duoci=false;
- }else{
- $scope.big_back=false;//大蒙版
- $scope.addparent=false;
- $scope.add_file_name="";
- $scope.modify_data="";
- $(".add_new_box").fadeOut();
- $(".parent_bring_box").fadeOut();
- $scope.try_async_load();
- $scope.add_parent="";
- SweetAlert.swal({
- title: "新增成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- })
- $scope.add_duoci=false;
- }
- }else{
- $scope.big_back=false;//大蒙版
- $scope.addparent=false;
- $scope.add_file_name="";
- $scope.add_parent="";
- $scope.modify_data="";
- $(".add_new_box").fadeOut();
- $(".parent_bring_box").fadeOut();
- $scope.try_async_load();
- SweetAlert.swal({
- title: "新增失败!",
- text: "系统错误",
- type: "error"
- })
- $scope.add_duoci=false;
- }
- })
- }
- }
- }else if($scope.addparent==true){
- var data={
- documentIndex:{
- name:$scope.add_file_name,
- parent:{id:$scope.add_parent.id}
- }
- };
- if($scope.add_file_name==""||$scope.add_parent==""||$scope.add_parent==undefined){
- SweetAlert.swal({
- title: "操作失败!",
- text: "必填项不能为空",
- type: "error"
- })
- }else{
- $scope.add_duoci=true;
- if($scope.add_duoci==true){
- api_user_data.addData("documentIndex",data).then(function(res){
- if(res.status==200){
- if(res.data.error){
- $scope.big_back=false;//大蒙版
- $scope.addparent=false;
- $scope.add_file_name="";
- $(".add_new_box").fadeOut();
- $(".parent_bring_box").fadeOut();
- $scope.try_async_load();
- $scope.add_parent="";
- $scope.modify_data="";
- SweetAlert.swal({
- title: "新增失败!",
- text: res.data.error,
- type: "error"
- })
- $scope.add_duoci=false;
- }else{
- $scope.big_back=false;//大蒙版
- $scope.addparent=false;
- $scope.add_file_name="";
- $(".add_new_box").fadeOut();
- $(".parent_bring_box").fadeOut();
- $scope.try_async_load();
- $scope.add_parent="";
- $scope.modify_data="";
- SweetAlert.swal({
- title: "新增成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- })
- $scope.add_duoci=false;
- }
- }else{
- $scope.big_back=false;//大蒙版
- $scope.addparent=false;
- $scope.add_file_name="";
- $scope.add_parent="";
- $scope.modify_data="";
- $(".add_new_box").fadeOut();
- $(".parent_bring_box").fadeOut();
- $scope.try_async_load();
- SweetAlert.swal({
- title: "新增失败!",
- text: "系统错误",
- type: "error"
- })
- $scope.add_duoci=false;
- }
- })
- }
- }
- }
- }
- // 关闭新增弹框
- $scope.close_add_box=function(){
- $scope.big_back=false;//大蒙版
- // $scope.add_box=false;//新增弹框
- $(".add_new_box").fadeOut();
- $(".parent_bring_box").fadeOut();
- $scope.add_file_name="";
- $scope.addparent=false;
- }
- // 打开新增弹框
- $scope.open_add_box=function(){
- $scope.big_back=true;//大蒙版
- // $scope.add_box=true;//新增弹框
- if($scope.modify_data){
- $scope.addparent=true;
- $scope.add_parent=$scope.modify_data;
- $(".parent_bring_box").fadeIn();
- }
- $(".add_new_box").fadeIn();
- }
- $scope.parent_bring_box_hide=function(){
- $(".parent_bring_box").fadeOut();
- $scope.add_parent=""
- }
- // 编辑
- // 打开编辑弹框
- $scope.open_modify_box=function(){
- if($scope.modify_data==""){
- SweetAlert.swal({
- title: "打开失败!",
- text: "请先选择某一项",
- type: "error"
- })
- }else{
- $scope.big_back=true;//大蒙版
- $(".modify_box").fadeIn();
- // console.log($scope.modify_data);
- $scope.modify_file_name=$scope.modify_data.label;
- }
- }
- //编辑保存
- $scope.modify_save=function(){
- if($scope.modify_data.id==$scope.edit_parent.id){
- SweetAlert.swal({
- title: "修改失败!",
- text: "更换的父类不能为自己",
- type: "error"
- })
- }else{
- if($scope.editparent){
- var data={
- documentIndex:{
- name:$scope.modify_file_name,
- id:$scope.modify_data.id,
- parent:{"id":$scope.edit_parent.id}
- }
- }
- }else if($scope.modify_data.parent&&!$scope.editparent){
- var data={
- documentIndex:{
- name:$scope.modify_file_name,
- id:$scope.modify_data.id,
- parent:{"id":$scope.modify_data.parent.id}
- }
- }
- }else{
- var data={
- documentIndex:{
- name:$scope.modify_file_name,
- id:$scope.modify_data.id
- }
- }
- }
- if($scope.modify_file_name==""){
- SweetAlert.swal({
- title: "修改失败!",
- text: "修改值不能为空",
- type: "error"
- })
- }else if($scope.editparent&&!$scope.edit_parent){
- SweetAlert.swal({
- title: "修改失败!",
- text: "父类名称不能为空",
- type: "error"
- })
- }else{
- api_user_data.updData("documentIndex",data).then(function(res){
- if(res.status==200){
- if(res.data.error){
- $scope.big_back=false;//大蒙版
- $scope.modify_data="";
- $(".modify_box").fadeOut();
- $scope.try_async_load();
- $scope.search_tree_ipt="";
- SweetAlert.swal({
- title: "修改失败!",
- text: res.data.error,
- type: "error"
- })
- }else{
- $scope.big_back=false;//大蒙版
- $scope.modify_data="";
- $(".modify_box").fadeOut();
- $scope.try_async_load();
- $scope.search_tree_ipt="";
- SweetAlert.swal({
- title: "修改成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- })
- }
- $scope.edit_parent="";//修改父类名称
- $scope.editparent=false; //修改父类按钮
- }else{
- $scope.big_back=false;//大蒙版
- $(".modify_box").fadeOut();
- SweetAlert.swal({
- title: "修改失败!",
- text: "系统错误",
- type: "error"
- })
- $scope.edit_parent="";//修改父类名称
- $scope.editparent=false; //修改父类按钮
- }
- })
- }
- }
- }
- //关闭编辑弹框
- $scope.close_modify_box=function(){
- $scope.big_back=false;//大蒙版
- $scope.edit_parent="";//修改父类名称
- $scope.editparent=false;//修改父类按钮
- $(".modify_box").fadeOut()
- }
- //左侧下拉树搜索
- $scope.search_tree_fn=function(){
- var data = { "idx": 0, "sum": 1000 ,documentIndex:{"name":$scope.search_tree_ipt}};
- api_doc_data.fetchDataList('documentIndex', data).then(function(res){
- $scope.search_tree_data=res.list
- })
- }
- //左侧搜出来的树点击
- $scope.left_search_tree_cli=function(idx,val){
- $scope.left_search_index=idx;
- $scope.left_tree_select=val;
- $scope.modify_data=val;
- $scope.modify_data["label"]=val.name;
- $scope.jry_filterdata["indexId"]=val.id;
- $scope.refreshData('expand-right', $scope.jry_filterdata);
- $scope.selected.items=[];//复选框清空
- }
- for(var i=0;i<loginUser.role.length;i++){
- if(loginUser.role[i].role=="文档管理员"){
- $scope.file_manage="ok"
- }
- }
- //删除树
- $scope.rmvData_tree=function(){
- if($scope.file_manage=="ok"){
- if($scope.modify_data==""){
- SweetAlert.swal("操作失败!", "请先选择某一项", "error");
- }else{
- SweetAlert.swal({
- title: "提示!",
- text: "该文件夹下有"+$scope.removeFileNum+"条数据,删除的数据不可恢复,请确认继续操作!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "继续删除",
- cancelButtonText: "取消操作",
- closeOnConfirm: true,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- SweetAlert.swal({
- title: "提示!",
- text: "删除的数据不可恢复,请确认继续操作!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "继续删除",
- cancelButtonText: "取消操作",
- closeOnConfirm: true,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- $scope.delete_password="";
- $scope.big_back=true;
- $('.deleteTree_box').fadeIn();
- } else {
- SweetAlert.swal("操作取消", "数据安全", "error");
- }
- });
- } else {
- SweetAlert.swal("操作取消", "数据安全", "error");
- }
- });
- }
- }else{
- SweetAlert.swal("操作失败", "你不是文档管理员,无法进行删除操作!", "error");
- }
- }
- //删除取消
- $scope.close_delete_box=function(){
- $scope.big_back=false;
- $('.deleteTree_box').fadeOut();
- SweetAlert.swal("操作取消", "数据安全", "error");
- }
- // 删除确定
- $scope.delete_sure=function(){
- if($scope.delete_password==loginUser.pwd){
- if($scope.modify_data.children.length>0){
- 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);
- }]);
|