12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552 |
- app.controller('knowledgeManagerCtrl', ["$rootScope", "$scope", "$http", "i18nService", "$state", "$timeout", "$interval", "SweetAlert", "$window", "$modal", "FileUploader", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_user_data", "api_solution", "api_bpm_domain", "$stateParams","api_zsk","api_configure_data", function($rootScope, $scope, $http, i18nService, $state, $timeout, $interval, SweetAlert, $window, $modal, FileUploader, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data, api_solution, api_bpm_domain, $stateParams,api_zsk,api_configure_data) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- var loginUser = $rootScope.user;
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = true;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalPagination = true;
- // $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- $scope.gridOptions.rowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function(row) {
- return row.id;
- };
- var mun = $scope.gridOptions.paginationPageSize;
- $scope.transferTime = function(time) {
- return moment(time).format('YYYY-MM-DD ');
- }
- //jry数据传递
- $scope.jry_knowipt="";
- if($scope.fenye==undefined){
- $scope.fenye=0;
- }
- // console.log($scope.jry_knowipt);
- $scope.jry_todata={
- "idx":$scope.fenye,
- "sum":10,
- "solution":{
- "keywords":"",
- "solutionType":{"id":''},
- "status":{"id":""}
- }
- }
- // $scope.$watch("jry_knowipt",function(val){
- // // console.log(val)
- // $scope.jry_todata={
- // "idx":$scope.fenye,
- // "sum":10,
- // "solution":{
- // "keywords":val
- // }
- // }
- // })
- $scope.transferStatus = function(status) {
- var statusLabel = "不合法的状态";
- if (status.value == 1) {
- statusLabel = "待审核";
- } else if (status.value == 2) {
- statusLabel = "已发布";
- } else if (status.value == 3) {
- statusLabel = "已驳回";
- } else if (status.value == 4) {
- statusLabel = "已停用";
- } else if (status.value == 5) {
- statusLabel = "已驳回";
- } else if (status.value == 6) {
- statusLabel = "已拒绝";
- }
- return statusLabel;
- }
- $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.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.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: 50
- },
- { name: 'solutionnumber', displayName: '编号', width: '10%' },
- { name: 'solutionType.typeName', displayName: '类别', width: '8%' },
- { name: 'title', displayName: '标题', width: '10%' },
- { name: 'visionNumber', displayName: '版本号', width: '10%' },
- { name: 'keywords', displayName: '关键字', width: '10%' },
- { name: 'status', displayName: '状态', cellTemplate: '<div class="ui-grid-cell-contents">{{grid.appScope.transferStatus(row.entity.status)}}</div>', width: '8%' },
- { name: 'createUser.name', displayName: '创建人', width: '8%' },
- { name: 'createtime', cellTemplate: '<div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.createtime)}}</div>', displayName: '创建日期', width: '12%' },
- { name: '操作', width: 345, cellTemplate: '<gridoperator item="row.entity" colobject="col">' },
- ];
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- var filtersData = $scope.allfilterData;
- // console.log(filtersData);
- console.log(newPage);
- $scope.fenye=newPage-1;
- $scope.jry_todata.idx=newPage-1;
- // $scope.jry_todata={
- // "idx":$scope.fenye,
- // "sum":10
- // }
- console.log($scope.fenye);
- filtersData.pageIndex = newPage - 1;
- var data = { pageIndex: newPage - 1 };
- var dataFilter = angular.extend(data, filtersData);
- dataFilter.status = filtersData.status;
- // $scope.refreshListData('expand-right', dataFilter);
- // if (JSON.parse(sessionStorage.getItem("searchKnowledge")).pageIndex != dataFilter.pageIndex) {
- // $scope.refreshListData('expand-right', dataFilter);
- // }
- // $scope.refreshListData('expand-right', $scope.jry_todata);
- api_zsk.jry_get_list($scope.jry_todata,"solution").then(function(data) {
- var myData = Restangular.stripRestangular(data);
- // console.log("myData="+JSON.stringify(myData));
- $scope.gridOptions.totalItems = myData.totalNum;
- if (myData.error && myData.status == 200) {
- $scope.myData = [];
- } else {
- if (angular.isArray(myData.list)) {
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]['item'] = i + 1 + $scope.jry_todata.idx * $scope.jry_todata.sum
- }
- } else {
- SweetAlert.swal({
- title: "数据为空",
- text: myData.list,
- type: "warning"
- });
- }
- }
- // $scope.ldloading[style.replace('-', '_')] = false;
- }
- // , function() {
- // $scope.ldloading[style.replace('-', '_')] = false;
- // }
- );
- });
- };
- var fildate = {
- key: 'null',
- status: 0,
- pageIndex: 0,
- pageSum: mun,
- //treeIds:'[]',
- userId: loginUser.id
- }
- $scope.knowledge = {};
- $scope.inspecttype = {};
- $scope.my_datalist = {};
- $scope.searchstate = 0;
- $scope.selectedItems = [];
- // $scope.knowledge.type = { id: 1, label: "应用系统" }
- $scope.my_data = [];
- this.selectRowFunction = function(data) {};
- $scope.my_tree = tree = {};
- $scope.try_async_load = function() {
- $scope.my_data = [];
- $scope.doing_async = true;
- // api_user_data.fetchDataList('group', { "idx": 0, "sum": 1000 }).then(function(response) {
- // var myData = Restangular.stripRestangular(response);
- // var list = myData.list;
- // var objects = [];
- // for (var i = 0; i < list.length; i++) {
- // var object = {};
- // object.id = list[i].id;
- // if (list[i].parent == 0) {
- // object.parent = "#";
- // } else {
- // object.parent = list[i].parent;
- // }
- // object.text = list[i].groupName;
- // object.typeName = "group";
- // object.state = {
- // "opened": true
- // };
- // objects.push(object);
- // }
- // $scope.groups = objects;
- // });
- // api_solution.findSolutionTypeActions(loginUser.id).then(function(response) {
- //JRY
- api_zsk.jry_get_list({"idx":0,"sum":1000},"solutionType").then(function(response) {
- if (response.status == 200) {
- var data = response.list;
- // console.log('data='+JSON.stringify(data));
- var objects = [];
- for (var i = 0; i < data.length; i++) {
- var object = {};
- object.id = data[i].id;
- if (data[i].pid != 0) {
- object.parent = data[i].pid;
- }
- // if (object.parent == 0) {
- // object.parent = "#";
- // }
- object.label = data[i].typeName;
- object.actions = data[i].actions; //权限部分
- 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);
- if (JSON.parse(sessionStorage.getItem("searchKnowledge")) && JSON.parse(sessionStorage.getItem("searchKnowledge")).treeIds) {
- angular.forEach($scope.my_data, function(item) {
- if (item.id == JSON.parse(sessionStorage.getItem("searchKnowledge")).treeIds) {
- $scope.knowledge.type = item
- }
- })
- }
- // if (JSON.parse(sessionStorage.getItem("searchKnowledgetype")) && JSON.parse(sessionStorage.getItem("searchKnowledgetype")).type) {
- // angular.forEach($scope.my_data, function(item, index) {
- // if (JSON.parse(sessionStorage.getItem("searchKnowledgetype")).type.id == item.id) {
- // $scope.my_data[index].selected = true;
- // }
- // })
- // }
- $scope.my_datalist = angular.copy($scope.my_data);
- $scope.tree_data = angular.copy($scope.my_data);
- if ($scope.my_data.length > 0) {
- $scope.doing_async = false;
- }
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- });
- $scope.showAddSolutionType = false; //添加知识类型 按钮
- $scope.showReviewKnowledgeType = false; //审核知识类型 按钮
- };
- $scope.try_async_load();
- $scope.ldloading = {};
- // console.log($scope.fenye);
- $scope.refreshListData = function(style, filterData) {
- $scope.ldloading[style.replace('-', '_')] = true;
- api_zsk.jry_get_list(filterData,"solution").then(function(data) {
- var myData = Restangular.stripRestangular(data);
- // console.log("myData="+JSON.stringify(myData));
- $scope.gridOptions.totalItems = myData.totalNum;
- if (myData.error && myData.status == 200) {
- $scope.myData = [];
- } else {
- if (angular.isArray(myData.list)) {
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]['item'] = i + 1 + $scope.jry_todata.idx * $scope.jry_todata.sum
- }
- } else {
- // SweetAlert.swal({
- // title: "数据为空",
- // text: myData.list,
- // type: "warning"
- // });
- }
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- }, function() {
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- }
- //导入
- $scope.importopen = function() { //导入触发事件
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/import.html',
- controller: function($scope, $modalInstance, FileUploader) {
- var importUploader = $scope.importUploader = new FileUploader({
- url: api_solution.upload().getRequestedUrl(),
- });
- importUploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- importUploader.onAfterAddingFile = function(fileItem) {
- console.info('onAfterAddingFile', fileItem);
- };
- importUploader.onAfterAddingAll = function(addedFileItems) {
- console.info('onAfterAddingAll', addedFileItems);
- };
- importUploader.onProgressItem = function(fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- importUploader.onProgressAll = function(progress) {
- console.info('onProgressAll', progress);
- };
- importUploader.onSuccessItem = function(fileItem, response, status, headers) {
- if (response.status == 200) {
- SweetAlert.swal({
- title: "导入成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- }, function() {
- // $scope.ldloading.contract_overlay = false;
- $rootScope.isMask = false;
- $scope.refreshListData('expand-right', $scope.jry_todata);
- });
- } else {
- // $scope.ldloading.contract_overlay = false;
- $rootScope.isMask = false;
- SweetAlert.swal({
- title: "导入失败!",
- text: response.error,
- type: "error"
- })
- }
- console.info('onSuccessItem', fileItem, response, status, headers);
- };
- importUploader.onErrorItem = function(fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- SweetAlert.swal({
- title: "系统错误!",
- text: "系统错误,请稍候重试!",
- type: "error"
- });
- };
- importUploader.onCancelItem = function(fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- importUploader.onCompleteItem = function(fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- importUploader.onCompleteAll = function() {
- console.info('onCompleteAll');
- };
- $scope.ldloading = {};
- $rootScope.isMask = false;
- $scope.import = function(style) {
- // $scope.ldloading[style.replace('-', '_')] = true;
- $modalInstance.dismiss('cancel');
- $rootScope.isMask = true;
- importUploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.formData.push({ 'fileName': item.file.name });
- item.formData.push({ 'type': "dataImport" });
- console.info('onBeforeUploadItem', item);
- };
- importUploader.uploadAll();
- }
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- importUploader: function() {
- return $scope.importUploader;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem) {}
- })
- }
- //知识库下载
- $scope.export = function() {
- var modalInstance = $modal.open({
- // templateUrl: 'assets/views/knowledge/tpl/knowledgegetdown.html',
- templateUrl: 'assets/views/system/tpl/getdown.html',
- controller: function($scope, $modalInstance) {
- $scope.key = {};
- $scope.title = '知识库下载';
- $scope.lable = '下载类型';
- $scope.onChange = function(key) {
- $scope.key = key;
- }
- $scope.downmodel = [{ id: 1, name: "模版下载" }, { id: 2, name: "数据导出" }]
- $scope.ok = function() {
- $modalInstance.close($scope.key);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem) {
- var selectedItemId = "知识库模版";
- if (selectedItem.id == 2) {
- selectedItemId = "知识库数据";
- }
- var filadata = { 'model': selectedItem.id };
- $http({
- url: api_solution.export({ 'model': 1 }).getRequestedUrl(),
- method: 'POST',
- data: JSON.stringify(filadata),
- headers: {
- // 'Content-type': 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function(data, status, headers, config) {
- // $scope.ldloading.zoom_in = false;
- var file = new Blob([data], {
- type: 'application/vnd.ms-excel'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = selectedItemId + '.xlsx';
- document.body.appendChild(a);
- a.click();
- }).error(function(data, status, headers, config) {
- // $scope.ldloading.zoom_in = false;
- console.log(data);
- });
- }
- });
- }
- $scope.createKnowledge = function() {
- var data = { model: { knowledge: { createUserId: loginUser.id, status: 1 } } };
- // var data = { model: { knowledge: { createUser: {id:loginUser.id}, status: 1 } } };
- $state.go('app.knowledge.create', { formKey: 'knowledge_create', service: 'api_solution', 'model': JSON.stringify(data) })
- }
- $scope.onDblClick = function(row) {
- // api_solution.findSolutionById(row.entity.id).then(function(response) {
- // var data = { model: { knowledge: response.data } };
- // if (!isNaN(data.model.knowledge.vision)) {
- // data.model.knowledge.vision = 'V' + String(data.model.knowledge.vision);
- // }
- console.log(row)
- api_solution.jry_getHistory({"idx":0,"sum":999,"solution":{"solutionnumber":row.entity.solutionnumber}}).then(function(res1){
- $state.go('app.knowledge.detail', { formKey: 'knowledge_detail', service: 'api_solution', 'model': JSON.stringify({"model":{"knowledge":row.entity}}),'history': JSON.stringify(res1.list)})
- })
- }
- // 编辑
- $scope.editSolution = function(item) {
- // api_solution.findSolutionById(id).then(function(response) {
- // var data = { model: { knowledge: response.data } };
- // if (!isNaN(data.model.knowledge.vision)) {
- // data.model.knowledge.vision = 'V' + String(data.model.knowledge.vision);
- // }
- api_solution.jry_getHistory({"idx":0,"sum":999,"solution":{"solutionnumber":item.solutionnumber}}).then(function(res1){
- $state.go('app.knowledge.editor', { formKey: 'knowledge_editor', service: 'api_solution', 'model': JSON.stringify({"model":{"knowledge":item}}),'history': JSON.stringify(res1.list)})
- })
- console.log(item);
- }
- //升级
- $scope.leve = function(item) {
- // api_solution.findSolutionById(id).then(function(response) {
- // var data = { model: { knowledge: response.data } };
- // if (!isNaN(data.model.knowledge.vision)) {
- // data.model.knowledge.vision = 'V' + String(data.model.knowledge.vision);
- // }
- // console.log(item);
- api_solution.jry_getHistory({"idx":0,"sum":999,"solution":{"solutionnumber":item.solutionnumber}}).then(function(res1){
- // console.log(res1)
- api_solution.jry_leveVision(item.id).then(function(res){
- console.log(res);
- item.visionNumber=res.data;
- console.log(item);
- $state.go('app.knowledge.leve', { formKey: 'knowledge_leve', service: 'api_solution', 'model': JSON.stringify({"model":{"knowledge":item}}),'history': JSON.stringify(res1.list)})
- })
- })
- }
- $scope.commentSolution = function(id) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/knowledge/tpl/commentknowledge.html',
- controller: function($scope, $http, $modalInstance, APIService, uploader, currentUser, Alert, MomentFormat, loginUser) {
- $scope.isManage = false;
- angular.forEach(loginUser.role, function(item) {
- if (item.rolecode == "solution") {
- $scope.isManage = true;
- }
- })
- $scope.examineKnowledge = function(item) {
- APIService.updModel("solutionReview", { "solutionReview": { "status": 2, "id": item.id } }).then(function(response) {
- if (response && response.status == "200") {
- SweetAlert.swal({
- title: "审核通过!",
- text: "知识库评论审核成功!",
- type: "success"
- }, function() {
- loadData();
- });
- } else {
- SweetAlert.swal({
- title: "审核失败",
- text: "知识库评论审核失败!",
- type: "error"
- });
- }
- })
- }
- $scope.reviewKnowledge = function(item) {
- APIService.updModel("updSolutionReviewByIds", { "type": 2, "status": 2, "ids": id }).then(function(response) {
- if (response && response.status == "200") {
- SweetAlert.swal({
- title: "审核通过!",
- text: "知识库评论审核成功!",
- type: "success"
- }, function() {
- loadData();
- });
- } else {
- SweetAlert.swal({
- title: "审核失败",
- text: "知识库评论审核失败!",
- type: "error"
- });
- }
- })
- }
- $scope.removeKnowledge = function(item) {
- APIService.updModel("solutionReview", { "solutionReview": { "status": 3, "id": item.id } }).then(function(response) {
- if (response && response.status == "200") {
- SweetAlert.swal({
- title: "删除成功!",
- text: "知识库评论删除成功!",
- type: "success"
- }, function() {
- loadData();
- });
- } else {
- SweetAlert.swal({
- title: "删除失败",
- text: "知识库评论删除失败!",
- type: "error"
- });
- }
- })
- }
- var loadData = function() {
- $scope.visions = [];
- $scope.entity = {};
- $scope.showCommentScore = true;
- $scope.comments = [];
- // APIService.findSolutionReviewById(loginUser.id, solution.id, 0, 1000).then(function(response) {
- APIService.fetchDataList('solutionReview', { 'idx': 0, 'sum': 1000, 'solutionReview': { 'solutionId': id, 'userId': loginUser.id } }).then(function(response) {
- if (response.status != "500") {
- var data = response.list;
- if (angular.isDefined(response.result)) { $scope.showCommentScore = false; }
- for (var i = 0; i < data.length; i++) {
- var object = {};
- object.id = data[i].id;
- object.name = data[i].userName;
- object.status = data[i].status;
- if (data[i].reviewScore > 0) {
- object.score = data[i].reviewScore;
- }
- // object.content=data[i].review;
- var ss = data[i].review;
- var s1 = "";
- if (ss != null) {
- var index = ss.indexOf("<p>");
- var indexs = ss.indexOf("</p>");
- s1 = ss.substring(index + 3, indexs);
- }
- object.content = s1;
- // object.score=data[i].reviewScore;
- object.time = moment(data[i].reviewTime).format('YYYY-MM-DD HH:mm:ss');
- // console.log('object.time='+JSON.stringify(object));
- $scope.comments.push(object);
- }
- }
- });
- APIService.findSolutionById(id).then(function(response) {
- var datas = response.data;
- $scope.entity = {
- "id": datas.id,
- "title": datas.title,
- "keys": datas.keywords,
- "type": datas.typeId,
- "range": datas.solutionRange,
- "number": datas.solutionNumber,
- "content": datas.content,
- "createrUserId": datas.createUserId,
- "createTime": datas.createtime,
- "status": datas.status,
- "hits": datas.hits,
- "relateId": datas.relateId,
- "vision": datas.vision,
- "vision2": "V" + datas.vision,
- // "fileContent":datas.fileContent,
- "replies": datas.replies,
- "scores": datas.scores,
- "hits": datas.hits,
- "fileName": datas.fileName,
- "typeName": datas.typeDTO.typeName
- };
- console.log(datas)
- console.log($scope.entity);
- });
- }
- loadData();
- $scope.options = {
- language: 'zh-cn',
- allowedContent: true,
- entities: false
- };
- $scope.uploader = uploader;
- $scope.getdown = function(filename) {
- $http({
- url: APIService.getSolutionDowpath(id).getRequestedUrl(),
- method: 'GET',
- headers: {
- //'Content-type' : 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function(data, status, headers, config) {
- var file = new Blob([data], {
- type: 'application/octet-stream'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- 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) {
- console.log(data);
- });
- }
- $scope.ranges = [{
- "id": 1,
- "name": "全局"
- }, {
- "id": 3,
- "name": "组"
- }];
- // $scope.ok = function() {
- // $modalInstance.close($scope.entity);
- // };
- $scope.cancel = function() {
- // api_solution.findSolutions($scope.entity.id).then(function(response){
- // var data6=response.data[0];
- // for(var j=0;j<=$scope.solutionBBS.length;j++){
- // if($scope.solutionBBS.length>0&&$scope.solutionBBS[j].id==$scope.entity.id){
- // $scope.solutionBBS[j].replies=data6.replies;
- // $scope.solutionBBS[j].hits=data6.hits;
- // $scope.solutionBBS[j].scores=data6.scores;
- // break;
- // }
- // }
- // });
- $modalInstance.close($scope.entity.id);
- };
- $scope.saveComment = function(reviewcontent, score) {
- $scope.entity['reviewcontent'] = reviewcontent;
- $scope.entity['score'] = score;
- $modalInstance.close($scope.entity);
- }
- },
- size: 'lg',
- resolve: {
- APIService: function() {
- return api_solution;
- },
- uploader: function() {
- return $scope.uploader;
- },
- currentUser: function() {
- return loginUser.id;
- },
- Alert: function() {
- return SweetAlert;
- },
- MomentFormat: function() {
- return moment;
- },
- loginUser: function() {
- return loginUser;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem.title) {
- var solutionId = selectedItem.id;
- var reviewContent = selectedItem.reviewcontent;
- // if(solutionId==null){
- var reviewScore;
- if (selectedItem.score) { reviewScore = selectedItem.score.toFixed(1) }
- var data = {
- id: null,
- solutionId: solutionId,
- userId: loginUser.id,
- review: reviewContent,
- reviewScore: reviewScore,
- reviewTime: new Date()
- };
- api_solution.addSolutionReview(data).then(function(response) {
- var status = response.status;
- console.log(response)
- console.log('$scope.apClient=' + JSON.stringify(status));
- if (status == "200") {
- SweetAlert.swal({
- title: "评论知识库!",
- text: "评论知识库成功!",
- type: "success"
- }, function() {
- api_solution.findSolutions(selectedItem.id).then(function(response) {
- var data6 = response.data[0];
- for (var j = 0; j <= $scope.solutionBBS.length; j++) {
- if ($scope.solutionBBS.length > 0 && $scope.solutionBBS[j].id == selectedItem.id) {
- $scope.solutionBBS[j].replies = data6.replies;
- $scope.solutionBBS[j].hits = data6.hits;
- $scope.solutionBBS[j].scores = data6.scores;
- break;
- }
- }
- });
- });
- } else {
- SweetAlert.swal({
- title: "评论知识库!",
- text: "评论知识库失败!",
- type: "error"
- });
- }
- });
- }
- });
- }
- //停用
- $scope.jry_close=function(item){
- // console.log(item);
- // item.status.id=74;
- // item["recalluser"]={id:loginUser.id};
- // item["recalltime"]=moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
- // delete(item["item"]);
- // item.renewtime=moment(item.renewtime).format('YYYY-MM-DD HH:mm:ss');
- // $scope.jry_tingyong={"solution":item};
- SweetAlert.swal({
- title: "",
- text: "是否确认将编号【"+item.solutionnumber+"】停用?停用后此知识不会公布在外!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确认停用",
- cancelButtonText: "取消操作",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- item.status.id=74;
- item["recalluser"]={id:loginUser.id};
- item["recalltime"]=moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
- delete(item["item"]);
- item.renewtime=moment(item.renewtime).format('YYYY-MM-DD HH:mm:ss');
- $scope.jry_tingyong={"solution":item};
- api_solution.jry_updateSolution($scope.jry_tingyong).then(function(){
- SweetAlert.swal("操作成功!", "该知识已停用", "success");
- $scope.myData=[];
- $scope.refreshListData('expand-right',$scope.jry_todata);
- })
- } else {
- SweetAlert.swal("操作取消", "该知识安全", "error");
- }
- });
- }
- //审核
- $scope.jry_shenhe=function(item){
- api_solution.jry_getHistory({"idx":0,"sum":999,"solution":{"solutionnumber":item.solutionnumber}}).then(function(res1){
- $state.go('app.knowledge.jry_shenhe', { formKey: 'knowledge_shenhe', service: 'api_solution', 'model': JSON.stringify({"model":{"knowledge":item}}),'history': JSON.stringify(res1.list)})
- })
- }
- // 历史记录
- $scope.jry_lishi=function(item){
- $state.go('app.knowledge.jry_lishi', { formKey: 'knowledge_lishi', service: 'api_solution', 'model': JSON.stringify({"model":{"knowledge":item}})})
- }
- $scope.approvalSolution = function(data,id, outTimePower) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/knowledge/tpl/approvalknowledge.html',
- controller: function($scope, $modalInstance, APIService, Alert, workGroups, uploader, tree_data, outTimePower) {
- $scope.wgroups = workGroups;
- $scope.type_handler = function(branch) {
- $scope.typeIds = branch.id;
- // console.log(branch);
- };
- $scope.type_data = tree_data;
- $scope.uploader = uploader;
- var loadData = function() {
- $scope.visions = [];
- // APIService.findSolutionById(id).then(function(response) {
- // var data = response.data;
- $scope.visions = data;
- //console.log(datas);
- // var data={};
- // for(var i=0;i<datas.length-1;i++){
- // if(id==datas[i].id){
- // data=datas[i];
- // }
- // }
- $scope.entity = {
- "id": data.id,
- "title": data.title,
- "keys": data.keywords,
- "typeId": data.typeId,
- "range": data.solutionRange,
- "number": data.solutionNumber,
- "content": data.content,
- "createrUserId": data.createrUserId,
- "createrUserName": data.createrUserName,
- "createTime": data.createTime,
- "status": data.status,
- "hits": data.hits,
- "relateId": data.relateId,
- "vision": data.vision,
- "outtime": outTimePower,
- // "filePic":$scope.filePic,
- "typeName": data.typename,
- "fileName": data.fileName
- };
- // var typeName;
- // APIService.getSolutionType(data.typeId).then(function(responseData){
- // var dd=responseData.data;
- // typeName=dd.typeName;
- // console.log('$scope.entity_2='+JSON.stringify($scope.entity));
- $scope.nowEntity = data;
- $scope.couldReview = true;
- $scope.showOutTime = true;
- $scope.fabu = false;
- $scope.shenhe = false;
- $scope.fabulabel = false;
- $scope.chexiao = false;
- $scope.shouquan = false;
- //$scope.shou=false;
- if ($scope.nowEntity.status != 1) { //状态只有是 待审核状态 才能进行审核
- $scope.couldReview = false;
- }
- if ($scope.nowEntity.status == 1) {
- $scope.shenhe = true;
- if ($scope.entity.range == 3) {
- $scope.shouquan = true;
- $scope.multipleDemo = {};
- // api_solution.findSolutionGroup($scope.entity.id).then(function(response){
- // $scope.multipleDemo = {};
- // var data = response.data;
- // var item = [];
- // $scope.multipleDemo.id = $scope.entity.id;
- // for(var i=0;i<$scope.group.length;i++){
- // for(var j=0;j<data.length;j++){
- // if(data[j].groupId == $scope.group[i].id){
- // item[item.length] = $scope.group[i];
- // break;
- // }
- // }
- // }
- // $scope.multipleDemo.item = item;
- // $scope.multipleDemo;
- // });
- }
- }
- if ($scope.nowEntity.status == 2) {
- $scope.fabu = true;
- $scope.fabulabel = true;
- }
- if ($scope.nowEntity.status == 3) {
- $scope.fabu = false;
- $scope.chexiao = true;
- $scope.showOutTime = false;
- }
- // if($scope.nowEntity.status==4){
- // $scope.fabu=true;
- // $scope.chexiao = true;
- // }
- if (($scope.nowEntity.status == 2) && outTimePower) { //表示状态为已通过
- $scope.showOutTime = false;
- }
- // APIService.getTree($scope.typeIds,$scope.groupIds,$scope.actionType).then(function(response){
- // var objectR=[];
- // var objectL=[];
- // var data=response.data;
- // var map=data.map;
- // var inList=map.inList;
- // var outList=map.outList;
- // if(inList!=null){
- // for(var i=0;i<inList.length;i++){
- // var object=inList[i];
- // var entity={
- // "id":object[0],
- // "name":object[1],
- // "value":object[1]
- // }
- // objectR.push(entity);//已选
- // }
- // }
- // if(outList!=null){
- // for(var i=0;i<outList.length;i++){
- // var object=outList[i];
- // var entity={
- // "id":object[0],
- // "name":object[1],
- // "value":object[1]
- // }
- // objectL.push(entity);//未选
- // }
- // }
- // $scope.peopleR=objectR;
- // $scope.peopleL=objectL;
- // });
- // });
- // });
- }
- $scope.closeAlert = function(index) {
- $scope.alerts.splice(index, 1);
- };
- $scope.test = false;
- $scope.getin = false;
- $scope.verifySolutions = function(type, reason) {
- var publishRange = angular.element("#publishRange").val();
- if (publishRange == "") {
- publishRange = 0;
- }
- var status = "";
- var statusName = "";
- if (type == "success") { //审核通过
- status = 2;
- statusName = "审核通过";
- } else if (type == "failed") { //审核驳回
- status = 5;
- statusName = "审核驳回";
- } else if (type == "reject") { //审核拒绝
- status = 6;
- statusName = "审核拒绝";
- } else if (type == "outtime") { //过时
- status = 4;
- statusName = "撤销";
- } else if (type = "publish") { //发布
- status = 3;
- statusName = "发布";
- }
- // APIService.updateSolutionStatus({id:$scope.nowEntity.id,status:status,renewUserId:loginUser.id,publishRange:0,reject:reason}).then(function(response){
- // var status=response.status;
- // if(status=="200"){
- // Alert.swal({
- // title: statusName+"知识库",
- // text: statusName+'成功',
- // type: "warning"
- // });
- // }else{
- // Alert.swal({
- // title: statusName+"知识库",
- // text: statusName+'失败',
- // type: "warning"
- // });
- // }
- // $modalInstance.dismiss('cancel');
- // });
- $scope.entity.status = status;
- $scope.entity['statusName'] = statusName;
- $scope.entity['reason'] = reason;
- $modalInstance.close($scope.entity);
- };
- $scope.group = [];
- api_user_data.fetchDataList('group', { 'idx': 0, 'sum': 1000 }).then(function(result) {
- $scope.my_datas = convertParentToChildList(result['list']);
- var nata = [];
- for (var i = 0; i < $scope.my_datas.length; i++) {
- nata.push({
- 'groupname': $scope.my_datas[i].groupName,
- 'id': $scope.my_datas[i].id
- })
- $scope.group = nata;
- }
- })
- $scope.saveright = function(multipleDemo) {
- // console.log(multipleDemo);
- // if(angular.isUndefined(multipleDemo)){
- // Alert.swal({
- // title: "授权知识库!",
- // text: "授权知识库成功!",
- // type: "success"
- // });
- // }
- $scope.entity['multipleDemo'] = multipleDemo;
- }
- $scope.options = {
- language: 'zh-cn',
- allowedContent: true,
- entities: false
- };
- $scope.onReady = function() {
- // ...
- };
- $scope.ranges = [{
- "id": 1,
- "name": "全局"
- }, {
- "id": 3,
- "name": "组"
- }];
- // $scope.ok = function() {
- // var data = {};
- // $modalInstance.close($scope.entity);
- // };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- loadData();
- },
- // size: 'sm',
- resolve: {
- APIService: function() {
- return api_solution;
- },
- Alert: function() {
- return SweetAlert;
- },
- workGroups: function() {
- return $scope.groups;
- },
- uploader: function() {
- return $scope.uploader;
- },
- tree_data: function() {
- return angular.copy($scope.tree_data);
- },
- outTimePower: function() {
- return outTimePower;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem) {
- // console.log(selectedItem);
- if (selectedItem.status == 2 && selectedItem.range == 3) {
- // console.log(selectedItem.multipleDemo.item);
- if (angular.isUndefined(selectedItem.multipleDemo.item) || selectedItem.multipleDemo.item == "") {
- SweetAlert.swal({
- title: "授权为空",
- text: "请选择本知识授权组",
- type: "error"
- });
- } else {
- var item = [];
- for (var i = 0; i < selectedItem.multipleDemo.item.length; i++) {
- item[i] = selectedItem.multipleDemo.item[i].id;
- }
- api_solution.saveSolutionGroup(selectedItem.id, item).then(function(response) {
- $scope.data4 = response;
- if ($scope.data4.status == "200") {
- var filedata = { solution: { id: selectedItem.id, status: selectedItem.status, renewUserId: loginUser.id, publishrange: 0, reject: selectedItem.reason } }
- api_solution.updateSolutionStatus(filedata).then(function(response) {
- $scope.data5 = response;
- console.log($scope.data4);
- console.log($scope.data4)
- if ($scope.data5.status == "200") {
- SweetAlert.swal({
- title: "审核知识库",
- text: '审核成功',
- type: "success"
- }, function() {
- $scope.reload();
- });
- } else {
- SweetAlert.swal({
- title: "审核知识库",
- text: '审核失败',
- type: "warning"
- });
- }
- });
- } else {
- SweetAlert.swal({
- title: "授权",
- text: '授权失败',
- type: "warning"
- });
- }
- });
- }
- } else {
- var filedata = { solution: { id: selectedItem.id, status: selectedItem.status, renewUserId: loginUser.id, publishrange: 0, reject: selectedItem.reason } }
- api_solution.updateSolutionStatus(filedata).then(function(response) {
- // console.log(response);
- var status = response.status;
- if (response.status == "200") {
- // if(status=="200"){
- SweetAlert.swal({
- title: selectedItem.statusName + "知识库",
- text: selectedItem.statusName + '成功',
- type: "success",
- }, function() {
- $scope.reload();
- });
- } else {
- SweetAlert.swal({
- title: statusName + "知识库",
- text: statusName + '失败',
- type: "warning"
- });
- }
- });
- }
- }
- })
- }
- $scope.publishSolution = function(id, outTimePower) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/knowledge/tpl/publishknowledge.html',
- controller: function($scope, $modalInstance, APIService, Alert, workGroups, uploader, outTimePower) {
- $scope.group = [];
- api_user_data.fetchDataList('group', { 'idx': 0, 'sum': 1000 }).then(function(result) {
- $scope.my_datas = convertParentToChildList(result['list']);
- var nata = [];
- for (var i = 0; i < $scope.my_datas.length; i++) {
- nata.push({
- 'groupname': $scope.my_datas[i].groupName,
- 'id': $scope.my_datas[i].id
- })
- $scope.group = nata;
- }
- })
- $scope.options = {
- language: 'zh-cn',
- allowedContent: true,
- entities: false
- };
- $scope.onReady = function() {
- // ...
- };
- $scope.ranges = [{
- "id": 1,
- "name": "全局"
- }, {
- "id": 3,
- "name": "组"
- }];
- $scope.ok = function() {
- var data = {};
- $modalInstance.close($scope.entity);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- loadData();
- },
- size: 'lg',
- resolve: {
- APIService: function() {
- return api_solution;
- },
- Alert: function() {
- return SweetAlert;
- },
- workGroups: function() {
- return $scope.groups;
- },
- uploader: function() {
- return $scope.uploader;
- },
- tree_data: function() {
- return angular.copy($scope.tree_data);
- },
- outTimePower: function() {
- return outTimePower;
- }
- }
- });
- }
- var apple_selected, tree, treedata_avm, treedata_geography;
- //$scope.selectedTreeNode = {};
- $scope.onFilterCallback = function(branch) {
- $scope.selectedItems[0] = {};
- // $scope.selectedTreeNode = branch;
- // $scope.refreshListData('expand-right', filterData);
- };
- // $scope.my_data = [];
- $scope.tree_data = [];
- $scope.my_tree = tree = {};
- 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
- var parentNode = 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?
- 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];
- //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;
- }
- // api_solution.addNotFile({ status:status,renewUserId:loginUser.id,publishRange:0,reject:reason}).then(function(response){
- // var myData = Restangular.stripRestangular(response);
- // console.log('myData='+JSON.stringify(myData));
- // })
- var uploader = $scope.uploader = new FileUploader({
- url: api_solution.upload().getRequestedUrl(),
- alias: "file",
- removeAfterUpload: true,
- queueLimit: 10
- // headers : {
- // }
- });
- // console.log('uploader='+JSON.stringify(uploader));
- // var uploader_1 = $scope.uploader = new FileUploader({
- // url:api_solution.addNotFile().getRequestedUrl(),
- // alias:"file",
- // removeAfterUpload:true,
- // queueLimit:1
- // });
- // console.log('$scope.uploader.queue='+JSON.stringify(uploader.queue.file.name));
- $scope.removeKnowledgeType = function() {
- var b = $scope.my_tree.get_selected_branch();
- if (b != null) {
- SweetAlert.swal({
- title: "确认删除?",
- text: "删除数据后,将不能恢复该数据!",
- type: "warning",
- cancelButtonText: "取消",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确认删除!"
- }, function(isConfirm) {
- if (isConfirm) {
- api_solution.removeSolutionType(b.id).then(function(response) {
- if (response.status == 204) {
- $scope.try_async_load();
- SweetAlert.swal({
- title: "删除成功!",
- confirmButtonColor: "#007AFF"
- });
- } else {
- SweetAlert.swal({
- title: "删除失败!",
- text: response.data,
- confirmButtonColor: "#007AFF"
- });
- }
- });
- }
- });
- } else {
- SweetAlert.swal({
- title: "删除数据错误",
- text: "无法删除,请选中一个知识库类型!",
- type: "warning"
- });
- }
- }
- $scope.editKnowledgeType = function(flag, size) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/knowledge/tpl/newknowledgetype.html',
- controller: function($scope, $modalInstance, selectNode, parentNode, isCreate, Alert) {
- $scope.editNode = {};
- if (angular.isDefined(selectNode)) {
- $scope.editNode.id = selectNode.id;
- $scope.editNode.typeName = selectNode.label;
- }
- // console.log('parentNode='+JSON.stringify(parentNode));
- // if(parentNode==null){
- // alert("请选择要添加类别的父类")
- // }
- if (angular.isDefined(parentNode) && (parentNode != null)) {
- $scope.editNode.pid = parentNode.id;
- $scope.parentName = parentNode.label;
- $scope.ok = function() {
- var data = {};
- if (isCreate) {
- data = {
- flag: isCreate,
- typeName: $scope.editNode.typeName,
- pid: $scope.editNode.pid
- }
- } else {
- data = {
- flag: isCreate,
- id: $scope.editNode.id,
- typeName: $scope.editNode.typeName,
- pid: $scope.editNode.pid
- }
- }
- $modalInstance.close(data);
- };
- } else {
- Alert.swal({
- title: "操作错误",
- text: "请选择要添加类别的父类!",
- type: "warning"
- })
- return undefined;
- }
- $scope.ok = function() {
- $modalInstance.close($scope.entity);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: size,
- resolve: {
- selectNode: function() {
- if (!flag) {
- return $scope.my_tree.get_selected_branch();
- } else {
- return undefined;
- }
- },
- parentNode: function() {
- if (flag) {
- return $scope.my_tree.get_selected_branch();
- } else {
- var b = $scope.my_tree.get_selected_branch();
- if (b != null) {
- return $scope.my_tree.get_parent_branch(b);
- }
- return undefined;
- }
- },
- isCreate: function() {
- return flag;
- },
- Alert: function() {
- return SweetAlert;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem) {
- if (selectedItem.flag) {
- api_solution.addSolutionType({ "pid": selectedItem.pid, "typeName": selectedItem.typeName }).then(function(response) {
- var myData = Restangular.stripRestangular(response);
- var data = myData.data;
- if (myData.status == 201) {
- $scope.try_async_load();
- SweetAlert.swal({
- title: "操作成功",
- text: "操作成功!",
- type: "success"
- });
- }
- })
- } else {
- api_solution.updateSolutionType({ "id": selectedItem.id, "pid": selectedItem.pid, "typeName": selectedItem.typeName }).then(function(response) {
- var myData = Restangular.stripRestangular(response);
- var data = myData.data;
- if (myData.status == 201) {
- $scope.try_async_load();
- SweetAlert.swal({
- title: "操作成功",
- text: "操作成功!",
- type: "success"
- });
- }
- })
- }
- }
- });
- }
- // var filterData = {
- // key: 'null',
- // status: 0,
- // pageIndex: 0,
- // pageSum: mun,
- // //treeIds:'[]',
- // userId: loginUser.id
- // }
- // if ($stateParams.fromstate && $stateParams.fromstate != "") {
- // $scope.allfilterData = JSON.parse($stateParams.fromstate);
- // } else {
- // $scope.allfilterData = {
- // key: 'null',
- // status: 0,
- // pageIndex: 0,
- // pageSum: mun,
- // userId: loginUser.id
- // }
- // }
- $scope.allfilterData = {
- key: 'null',
- status: 0,
- pageIndex: 0,
- pageSum: mun,
- userId: loginUser.id
- }
- $scope.statuses = [
- { status: 1, label: '待审核' },
- { status: 2, label: '已发布' },
- { status: 3, label: '已驳回' },
- { status: 4, label: '已停用' },
- { status: 5, label: '已驳回' },
- { status: 6, label: '已拒绝' }
- ];
- // $scope.$watch('searchSolutionInput', function(oldvalue, newvalue) {
- // // console.log(' oldvalue='+JSON.stringify( oldvalue));
- // // console.log(' newvalue='+JSON.stringify( newvalue));
- // // if(oldvalue==newvalue) return;
- // if (angular.isUndefined(oldvalue) || oldvalue == '') {
- // filterData.key = 'null';
- // } else {
- // filterData.key = oldvalue;
- // }
- // });
- $scope.filterSolutionStatus = function(filterStatus) {
- // filterData = $scope.allfilterData;
- $scope.searchstate = filterStatus;
- // filterData.status = filterStatus;
- // var fildata = {};
- // if (sessionStorage.searchKnowledge) {
- // filterData = JSON.parse(sessionStorage.getItem("searchKnowledge"));
- // $scope.gridOptions.paginationCurrentPage = 1;
- // filterData.pageIndex = 0;
- // } else {
- // filterData = defaultFilterData;
- // }
- // var tempData = angular.copy(filterData);
- // tempData.status = filterStatus;
- // $scope.allfilterData = tempData;
- // $stateParams.fromstate = JSON.stringify($scope.allfilterData);
- // sessionStorage['searchknowledge'] = JSON.stringify(tempData);
- $scope.jry_todata.solution.status.id=filterStatus;
- $scope.refreshListData('expand-right', $scope.jry_todata);
- }
- $scope.myKeyup = function(e) {
- var keyCode = window.event ? e.keyCode : e.which;
- if (keyCode == 13) {
- $scope.searchSolution();
- }
- };
- // $scope.searchstate = 0;
- $scope.searchSolution = function() {
- console.log($scope.jry_knowipt);
- $scope.jry_todata.solution.keywords=$scope.jry_knowipt;
- $scope.jry_todata.solution.solutionType.id=$scope.solutionTypeId;
- // if (sessionStorage['searchKnowledge']) {
- // filterData = JSON.parse(sessionStorage.getItem("searchKnowledge"));
- // }
- // if (item.type) {
- // // filterData['treeIds'] = "";
- // filterData['treeIds'] = item.type.id;
- // } else {
- // delete filterData.treeIds;
- // }
- // if (item.searchSolutionInput) {
- // // angular.extend(filterData['key'], item.searchSolutionInput)
- // filterData['key'] = item.searchSolutionInput;
- // } else {
- // filterData['key'] = null;
- // }
- // sessionStorage['searchKnowledgetype'] = JSON.stringify(item);
- $scope.refreshListData('expand-right', $scope.jry_todata);
- }
- // window.onbeforeunload = function(event) {
- // $state.go('app.knowledge.manager', {})
- // alert("文本")
- // // $scope.refreshListData('expand-right', filterData);
- // }
- $scope.reload = function(item) {
- // var reshfildata = {};
- // if (item) { reshfildata = JSON.parse(item) }
- if (sessionStorage['searchKnowledge']) {
- $scope.allfilterData = JSON.parse(sessionStorage.getItem("searchKnowledge"));
- // if (JSON.parse(sessionStorage.getItem("searchKnowledge")).treeIds) {
- // $scope.knowledge = {
- // "type": JSON.parse(sessionStorage.getItem("searchKnowledge")).treeIds
- // };
- // }
- // if () {
- // }
- // $scope.knowledge = angular.extend($scope.knowledge, { 'type': JSON.parse(sessionStorage.getItem("searchKnowledge")).treeIds });
- if (JSON.parse(sessionStorage.getItem("searchKnowledge")).key) {
- $scope.knowledge = angular.extend($scope.knowledge, { 'searchSolutionInput': JSON.parse(sessionStorage.getItem("searchKnowledge")).key });
- }
- }
- $scope.refreshListData('expand-right',$scope.jry_todata);
- }
- $scope.reloaddata = function() {
- sessionStorage['searchKnowledgetype'] = JSON.stringify({});
- // $scope.jry_todata={
- // "idx":$scope.fenye,
- // "sum":10,
- // "solution":{
- // "keywords":"",
- // "solutionType":{"id":''},
- // "status":{"id":""}
- // }
- // }
- $scope.jry_todata.solution.solutionType.id="";
- $scope.jry_todata.solution.keywords="";
- $scope.jry_knowipt="";
- $scope.knowledge = {};
- $scope.try_async_load();
- $scope.allfilterData.treeIds = 0;
- $scope.reload(JSON.stringify(fildate));
- }
- // $scope.refreshListData('expand-right', $scope.allfilterData);
- $scope.reload()
- //树形图
- var apple_selected, tree, treedata_avm, treedata_geography;
- $scope.my_tree_handler = function(branch) {
- //var _ref;
- var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
- api_cmdb.query({ 'sign': classify }).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- // console.log(myData.data.node);
- if (myData.data && myData.status == 200) {
- var ret = myData.data;
- redrawSvg(myData);
- }
- });
- };
- $scope.my_data = [];
- 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
- var parentNode = 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?
- 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.my_tree = tree = {};
- $scope.try_async_load = function() {
- $scope.my_data = [];
- $scope.select_treedata = [];
- $scope.doing_async = true;
- api_zsk.jry_get_list({"idx":0,"sum":1000},"solutionType").then(function(result) {
- //console.log(result['list']);
- $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
- $scope.doing_async = false;
- // tree.expand_all();
- //console.log(treelist);
- });
- };
- $scope.select_treedata = [];
- $scope.propTypeOptions = [];
- $scope.try_async_load();
- $scope.onFilterremove = function(item) {
- console.log(item)
- }
- // 资产分类
- $scope.onFilterCallback = function(item) {
- console.log($scope.cifilter_classic);
- console.log(item.id);
- // $scope.jry_todata.solution.solutionType.id=item.id;
- $scope.solutionTypeId=item.id;
- // if (angular.isDefined(item.children) && item.children.length >= 1) {
- // //not valid
- // } else {
- // var tempclassify = item.prefix.toLowerCase() + item.sign;
- // $scope.gridApi.grid.options.paginationCurrentPage = 1;
- // $scope.cifilter_classic = tempclassify;
- // var memoryfilterData = {
- // "sign": tempclassify,
- // "idx": 0,
- // "sum": $scope.gridOptions.paginationPageSize
- // }
- // angular.extend($scope.memoryfilterData, memoryfilterData)
- // // $scope.memoryfilterData=memoryfilterData;
- // $scope.refreshData('expand-right', $scope.memoryfilterData);
- // // 专有属性
- // api_configure_form.renderTabForm(tempclassify).then(function(data){
- // var myData = Restangular.stripRestangular(data);
- // $scope.propTypeOptions = myData[2].form.fields;
- // // console.log($scope.propTypeOptions)
- // });
- // }
- }
- }]);
- app.controller('knowledgeForumCtrl', ["$rootScope", "$scope", "$filter", "ngTableParams", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "moment", "Restangular", "api_solution", function($rootScope, $scope, $filter, ngTableParams, $state, $timeout, $interval, $modal, SweetAlert, moment, Restangular, api_solution) {
- var loginUser = $rootScope.user;
- $scope.clses = [{
- id: 6,
- cls: 'danger'
- }, {
- id: 2,
- cls: 'warning'
- }, {
- id: 3,
- cls: 'success'
- },
- {
- id: 4,
- cls: 'primary'
- }, {
- id: 5,
- cls: 'info'
- }, {
- id: 1,
- cls: 'danger'
- }
- ];
- $scope.showlist = true;
- $scope.myKeyup = function(e, searchInput) {
- var keyCode = window.event ? e.keyCode : e.which;
- if (keyCode == 13) {
- $scope.searchSolution(searchInput);
- }
- };
- $scope.searchSolution = function(searchKey, page) {
- console.log(page)
- if (searchKey == "") {
- if (angular.isDefined(page)) {
- if (page == 0) {
- page = 1;
- } else if (page == $scope.pages + 1) {
- page = $scope.pages;
- }
- } else {
- tempPage = page = 0;
- $scope.solutionBBS = [];
- }
- // api_solution.queryBBSSolutions(tempPage, 7, 'createtime', loginUser.id, searchKey).then(function(response) {
- api_solution.fetchDataList("solution", { 'idx': 0, 'sum': 7, 'solution': { 'searchType': 2, 'keywords': searchKey, createUserId: loginUser.id } }).then(function(response) {
- // api_solution.fetchDataList("solution", { 'idx': 0, 'sum': 7, 'solution': { 'searchType': 2, 'keywords': searchKey, createUser: {id:loginUser.id} } }).then(function(response) {
- var myData = Restangular.stripRestangular(response);
- var status = myData.status;
- if (status == "500") {
- $scope.solutionBBS = [];
- } else if (status == "200" && myData.list) {
- sereshdata(response, searchKey);
- }
- });
- } else if (searchKey != "" && searchKey.length > 1) {
- // if (angular.isDefined(page)) {
- // if (page == 0) {
- // page = 1;
- // } else if (page == $scope.pages + 1) {
- // page = $scope.pages;
- // }
- // tempPage = page - 1;
- // } else {
- // tempPage = page = 0;
- // $scope.solutionBBS = [];
- // }
- // if(page==0){
- // page=1;
- // }else if(page==$scope.pages+1){
- // page=$scope.pages;
- // }
- api_solution.fetchDataList("solution", { 'idx': 0, 'sum': 7, 'solution': { 'searchType': 2, 'keywords': searchKey, createUserId: loginUser.id } }).then(function(response) {
- // api_solution.fetchDataList("solution", { 'idx': 0, 'sum': 7, 'solution': { 'searchType': 2, 'keywords': searchKey, createUser: {id:loginUser.id} } }).then(function(response) {
- var myData = Restangular.stripRestangular(response);
- $scope.solutionBBS = [];
- $scope.currentPage = 1;
- $scope.pages = 0;
- $scope.num = response.totalNum;
- sereshdata(response, searchKey);
- // var status = myData.status;
- // if (status == "500") {
- // $scope.solutionBBS = [];
- // } else if (status == "200" && myData.list) {
- // var data = myData.list;
- // var count = myData.totalNum;
- // $scope.pages = parseInt(count / 7) + 1;
- // if (page == 0) {
- // $scope.currentPage = page + 1;
- // } else {
- // $scope.currentPage = page;
- // }
- // if (data.length > 0) {
- // $scope.solutionBBS = [];
- // for (var i = 0; i < data.length; i++) {
- // data[i].creationTime = getLocalTime(data[i].createtime);
- // data[i].releasetime = getLocalTime(data[i].releasetime);
- // if (data[i].solutionReviewDTO.reviewTime == null) {
- // data[i].solutionReviewDTO.reviewTime = "暂无回复";
- // } else {
- // data[i].solutionReviewDTO.reviewTime = getLocalTime(data[i].solutionReviewDTO.reviewTime);
- // }
- // if (data[i].solutionReviewDTO.userName == null) {
- // data[i].solutionReviewDTO.userName = "暂无回复人";
- // }
- // // if (i == 0) {
- // // data[i].index = 1;
- // // } else if (i == 1) {
- // // data[i].index = 2;
- // // } else if (i == 2) {
- // // data[i].index = 3;
- // // } else {
- // // data[i].index = 4;
- // // }
- // $scope.solutionBBS.push(data[i]);
- // // reshdata($scope.solutionBBS);
- // }
- // }
- // }
- });
- }
- }
- // $scope.$watch('searchInput',function(newvalue, oldvalue){
- // if(newvalue == oldvalue) return;
- // $scope.searchSolution(newvalue);
- // });
- //BBS列表切换
- $scope.changeShowList = function(val) {
- $scope.showlist = !$scope.showlist;
- }
- $scope.solutionBBS = [];
- $scope.hotRankings = [];
- $scope.scoreRankings = [];
- $scope.solutionScores = [];
- $scope.currentPage = 1;
- $scope.pages = 0;
- $scope.num = 0;
- function sereshdata(item, key) {
- $scope.tableParams = new ngTableParams({
- page: 1, // show first page
- count: 7, // count per page
- data: item.list
- }, {
- total: item.totalNum, // length of data
- getData: function($defer, params) {
- api_solution.fetchDataList("solution", { 'idx': params.page() - 1, 'sum': 7, 'solution': { 'searchType': 2, 'keywords': key, createUserId: loginUser.id } }).then(function(response) {
- // api_solution.fetchDataList("solution", { 'idx': params.page() - 1, 'sum': 7, 'solution': { 'searchType': 2, 'keywords': key, createUser: {id:loginUser.id} } }).then(function(response) {
- var data = response.list;
- for (var i = 0; i < data.length; i++) {
- data[i].creationTime = getLocalTime(data[i].createtime);
- data[i].releasetime = getLocalTime(data[i].releasetime);
- if (data[i].solutionReviewDTO.reviewTime == null) {
- data[i].solutionReviewDTO.reviewTime = "暂无回复";
- } else {
- data[i].solutionReviewDTO.reviewTime = getLocalTime(data[i].solutionReviewDTO.reviewTime);
- }
- if (data[i].solutionReviewDTO.userName == null) {
- data[i].solutionReviewDTO.userName = "暂无回复人";
- }
- $scope.solutionBBS.push(data[i]);
- }
- $defer.resolve(data.slice((0) * params.count(), params.page() * params.count()));
- })
- }
- });
- }
- // function reshdata(item, key) {
- // $scope.tableParams = new ngTableParams({
- // page: 1, // show first page
- // count: 3 // count per page
- // }, {
- // total: item.totalNum, // length of data
- // getData: function($defer, params) {
- // // api_solution.fetchBBSSolutions(params.page() - 1, 7, "createtime", loginUser.id).then(function(response) {
- // var orderedData = params.sorting() ? $filter('orderBy')(item.list, params.orderBy()) : item.list;
- // $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- // }
- // });
- // }
- // api_solution.fetchBBSSolutions(0, 7, "createtime", loginUser.id).then(function(response) {
- api_solution.fetchDataList("solution", { 'idx': 0, 'sum': 7, 'solution': { 'searchType': 2, createUserId: loginUser.id } }).then(function(response) {
- // api_solution.fetchDataList("solution", { 'idx': 0, 'sum': 7, 'solution': { 'searchType': 2, createUser: {id:loginUser.id} } }).then(function(response) {
- if (response.status == 200) {
- $scope.solutionBBS = [];
- var data = response.list;
- $scope.num = response.totalNum;
- // for (var i = 0; i < data.length; i++) {
- // data[i].creationTime = getLocalTime(data[i].createtime);
- // data[i].releasetime = getLocalTime(data[i].releasetime);
- // if (data[i].solutionReviewDTO.reviewTime == null) {
- // data[i].solutionReviewDTO.reviewTime = "暂无回复";
- // } else {
- // data[i].solutionReviewDTO.reviewTime = getLocalTime(data[i].solutionReviewDTO.reviewTime);
- // }
- // if (data[i].solutionReviewDTO.userName == null) {
- // data[i].solutionReviewDTO.userName = "暂无回复人";
- // }
- // $scope.solutionBBS.push(data[i]);
- // }
- sereshdata(response);
- // $scope.tableParams = new ngTableParams({
- // page: 1, // show first page
- // count: 7 // count per page
- // }, {
- // total: response.totalNum, // length of data
- // getData: function($defer, params) {
- // api_solution.fetchBBSSolutions(params.page() - 1, 7, "createtime", loginUser.id).then(function(data) {
- // var myData = data.list;
- // $defer.resolve(myData.slice((0) * params.count(), params.page() * params.count()));
- // })
- // }
- // });
- }
- })
- api_solution.fetchBBSSolutions(0, 5, "scores", loginUser.id).then(function(response) {
- $scope.solutionBBS1 = [];
- var myData = Restangular.stripRestangular(response);
- var data = myData.list;
- for (var i = 0; i < data.length; i++) {
- data[i].creationTime = getLocalTime(data[i].creationTime);
- data[i].lastReplyTime = getLocalTime(data[i].lastReplyTime);
- if (i == 0) {
- data[i].index = 1;
- } else if (i == 1) {
- data[i].index = 2;
- } else if (i == 2) {
- data[i].index = 3;
- } else {
- data[i].index = 4;
- }
- $scope.solutionScores.push(data[i]);
- }
- });
- $scope.todayHits = 0;
- $scope.lastHits = 0;
- api_solution.fetchDataList('solutionDayBrowser', { 'idx': 0, 'sum': 10 }).then(function(response) {
- if (response.status == 200 && response.list) {
- if (response.list[0].todayBrowser) {
- $scope.todayHits = response.list[0].todayBrowser;
- }
- if (response.list[0].beforeDayBrowser) {
- $scope.lastHits = response.list[0].beforeDayBrowser;
- }
- }
- })
- api_solution.hotRanking(1).then(function(response) {
- var myData = Restangular.stripRestangular(response);
- var data = myData.list;
- console.log(data);
- $scope.hotRankings = [];
- $scope.hotArray = [];
- for (var i = 0; i < data.length; i++) {
- data[i].approvetime = getLocalTime(data[i].solutionDTO.approvetime);
- if (i == 0) {
- data[i].index = 1;
- } else if (i == 1) {
- data[i].index = 2;
- } else if (i == 2) {
- data[i].index = 3;
- } else {
- data[i].index = 4;
- }
- $scope.hotRankings.push(data[i]);
- $scope.hotArray.push(data[i].totalBrowse);
- }
- if ($scope.hotArray.length > 0) {
- $scope.tophot = $scope.hotArray.join(',');
- }
- //$scope
- //$scope.hotArray=[275,490,397,487,339,403,402,312,300,294,411,367,319,416,355,416,371,479,279,361,312,269,402,327,474,422,375,283,384,372];
- //热点排行榜
- // $("#stats-sparklines-2").pixelSparkline($scope.hotArray, {
- // type: 'bar',
- // height: '36px',
- // width: '100%',
- // barSpacing: 2,
- // zeroAxis: false,
- // barColor: '#ffffff'
- // });
- });
- api_solution.hotRanking(2).then(function(response) {
- var myData = Restangular.stripRestangular(response);
- var data = myData.list;
- $scope.scoreRankings = [];
- $scope.scoreArray = [];
- for (var i = 0; i < data.length; i++) {
- data[i].approvetime = getLocalTime(data[i].solutionDTO.approvetime);
- if (i == 0) {
- data[i].index = 1;
- } else if (i == 1) {
- data[i].index = 2;
- } else if (i == 2) {
- data[i].index = 3;
- } else {
- data[i].index = 4;
- }
- $scope.scoreRankings.push(data[i]);
- $scope.scoreArray.push(data[i].totalScore);
- }
- if ($scope.scoreArray.length > 0) {
- $scope.topscore = $scope.scoreArray.join(',');
- }
- //$scope.scoreArray=[275,490,397,487,339,403,402,312,300];
- //评分排行榜
- // $("#stats-sparklines-3").pixelSparkline($scope.scoreArray, {
- // type: 'line',
- // width: '100%',
- // height: '45px',
- // fillColor: '',
- // lineColor: '#fff',
- // lineWidth: 2,
- // spotColor: '#ffffff',
- // minSpotColor: '#ffffff',
- // maxSpotColor: '#ffffff',
- // highlightSpotColor: '#ffffff',
- // highlightLineColor: '#ffffff',
- // spotRadius: 4,
- // highlightLineColor: '#ffffff'
- // });
- });
- var getLocalTime = function(time) {
- return moment(time).format('YYYY-MM-DD HH:mm:ss');
- // console("time="+time)
- }
- $scope.commentshowSolution = function(solution) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/knowledge/tpl/commentknowledge.html',
- controller: function($scope, $http, $modalInstance, APIService, uploader, currentUser, Alert, MomentFormat, loginUser) {
- $scope.isManage = false;
- angular.forEach(loginUser.role, function(item) {
- if (item.rolecode == "solution") {
- $scope.isManage = true;
- }
- })
- $scope.examineKnowledge = function(item) {
- APIService.updModel("solutionReview", { "solutionReview": { "status": 2, "id": item.id } }).then(function(response) {
- if (response && response.status == "200") {
- SweetAlert.swal({
- title: "审核通过!",
- text: "知识库评论审核成功!",
- type: "success"
- }, function() {
- loadData();
- });
- } else {
- SweetAlert.swal({
- title: "审核失败",
- text: "知识库评论审核失败!",
- type: "error"
- });
- }
- })
- }
- $scope.reviewKnowledge = function(item) {
- APIService.updModel("updSolutionReviewByIds", { "type": 2, "status": 2, "ids": solution.id }).then(function(response) {
- if (response && response.status == "200") {
- SweetAlert.swal({
- title: "审核通过!",
- text: "知识库评论审核成功!",
- type: "success"
- }, function() {
- loadData();
- });
- } else {
- SweetAlert.swal({
- title: "审核失败",
- text: "知识库评论审核失败!",
- type: "error"
- });
- }
- })
- }
- $scope.removeKnowledge = function(item) {
- APIService.updModel("solutionReview", { "solutionReview": { "status": 3, "id": item.id } }).then(function(response) {
- if (response && response.status == "200") {
- SweetAlert.swal({
- title: "删除成功!",
- text: "知识库评论删除成功!",
- type: "success"
- }, function() {
- loadData();
- });
- } else {
- SweetAlert.swal({
- title: "删除失败",
- text: "知识库评论删除失败!",
- type: "error"
- });
- }
- })
- }
- var loadData = function() {
- $scope.visions = [];
- $scope.entity = {};
- $scope.showCommentScore = true;
- $scope.comments = [];
- // APIService.findSolutionReviewById(loginUser.id, solution.id, 0, 1000).then(function(response) {
- APIService.fetchDataList('solutionReview', { 'idx': 0, 'sum': 1000, 'solutionReview': { 'solutionId': solution.id, 'userId': loginUser.id } }).then(function(response) {
- if (response.status != "500") {
- var data = response.list;
- if (angular.isDefined(response.result)) { $scope.showCommentScore = false; }
- for (var i = 0; i < data.length; i++) {
- var object = {};
- object.id = data[i].id;
- object.name = data[i].userName;
- object.status = data[i].status;
- if (data[i].reviewScore > 0) {
- object.score = data[i].reviewScore;
- }
- // object.content=data[i].review;
- var ss = data[i].review;
- var s1 = "";
- if (ss != null) {
- var index = ss.indexOf("<p>");
- var indexs = ss.indexOf("</p>");
- s1 = ss.substring(index + 3, indexs);
- }
- object.content = s1;
- // object.score=data[i].reviewScore;
- object.time = moment(data[i].reviewTime).format('YYYY-MM-DD HH:mm:ss');
- // console.log('object.time='+JSON.stringify(object));
- $scope.comments.push(object);
- }
- }
- });
- APIService.findSolutionById(solution.id).then(function(response) {
- var datas = response.data;
- $scope.entity = {
- "id": datas.id,
- "title": datas.title,
- "keys": datas.keywords,
- "type": datas.typeId,
- "range": datas.solutionRange,
- "number": datas.solutionNumber,
- "content": datas.content,
- "createrUserId": datas.createUserId,
- "createTime": datas.createtime,
- "status": datas.status,
- "hits": datas.hits,
- "relateId": datas.relateId,
- "vision": datas.vision,
- "vision2": "V" + datas.vision,
- // "fileContent":datas.fileContent,
- "replies": datas.replies,
- "scores": datas.scores,
- "hits": datas.hits,
- "fileName": datas.fileName,
- "typeName": datas.typeDTO.typeName
- };
- console.log(datas)
- console.log($scope.entity);
- });
- }
- loadData();
- $scope.options = {
- language: 'zh-cn',
- allowedContent: true,
- entities: false
- };
- $scope.uploader = uploader;
- $scope.getdown = function(filename) {
- $http({
- url: APIService.getSolutionDowpath(solution.id).getRequestedUrl(),
- method: 'GET',
- headers: {
- //'Content-type' : 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function(data, status, headers, config) {
- var file = new Blob([data], {
- type: 'application/octet-stream'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- 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) {
- console.log(data);
- });
- }
- $scope.ranges = [{
- "id": 1,
- "name": "全局"
- }, {
- "id": 3,
- "name": "组"
- }];
- // $scope.ok = function() {
- // $modalInstance.close($scope.entity);
- // };
- $scope.cancel = function() {
- // api_solution.findSolutions($scope.entity.id).then(function(response){
- // var data6=response.data[0];
- // for(var j=0;j<=$scope.solutionBBS.length;j++){
- // if($scope.solutionBBS.length>0&&$scope.solutionBBS[j].id==$scope.entity.id){
- // $scope.solutionBBS[j].replies=data6.replies;
- // $scope.solutionBBS[j].hits=data6.hits;
- // $scope.solutionBBS[j].scores=data6.scores;
- // break;
- // }
- // }
- // });
- $modalInstance.close($scope.entity.id);
- };
- $scope.saveComment = function(reviewcontent, score) {
- $scope.entity['reviewcontent'] = reviewcontent;
- $scope.entity['score'] = score;
- $modalInstance.close($scope.entity);
- }
- },
- size: 'lg',
- resolve: {
- APIService: function() {
- return api_solution;
- },
- uploader: function() {
- return $scope.uploader;
- },
- currentUser: function() {
- return loginUser.id;
- },
- Alert: function() {
- return SweetAlert;
- },
- MomentFormat: function() {
- return moment;
- },
- loginUser: function() {
- return loginUser;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem.title) {
- var solutionId = selectedItem.id;
- var reviewContent = selectedItem.reviewcontent;
- // if(solutionId==null){
- var reviewScore;
- if (selectedItem.score) { reviewScore = selectedItem.score.toFixed(1) }
- var data = {
- id: null,
- solutionId: solutionId,
- userId: loginUser.id,
- review: reviewContent,
- reviewScore: reviewScore,
- reviewTime: new Date()
- };
- api_solution.addSolutionReview(data).then(function(response) {
- var status = response.status;
- console.log(response)
- console.log('$scope.apClient=' + JSON.stringify(status));
- if (status == "200") {
- SweetAlert.swal({
- title: "评论知识库!",
- text: "评论知识库成功!",
- type: "success"
- }, function() {
- api_solution.findSolutions(selectedItem.id).then(function(response) {
- var data6 = response.data[0];
- for (var j = 0; j <= $scope.solutionBBS.length; j++) {
- if ($scope.solutionBBS.length > 0 && $scope.solutionBBS[j].id == selectedItem.id) {
- $scope.solutionBBS[j].replies = data6.replies;
- $scope.solutionBBS[j].hits = data6.hits;
- $scope.solutionBBS[j].scores = data6.scores;
- break;
- }
- }
- });
- });
- } else {
- SweetAlert.swal({
- title: "评论知识库!",
- text: "评论知识库失败!",
- type: "error"
- });
- }
- });
- }
- });
- }
- //TODO
- $('#attach-check').on('change', function() {
- $('#attach').toggleClass('hidden');
- });
- $('#attachcheck1').on('change', function() {
- $('#attachdiv1').toggleClass('hidden');
- });
- $('#attachcheck2').on('change', function() {
- $('#attachdiv2').toggleClass('hidden');
- });
- }]);
- app.filter('index', function() {
- return function(array) {
- return (array || []).map(function(item, index) {
- item.order = index + 1;
- return item;
- });
- };
- });
- app.controller('GridOperatorCtrl', ["$rootScope",'$http', '$scope', function($rootScope,$http, $scope, $event) {
- // if ($scope.item.actions != "" && $scope.item.actions != null) { //1:查看,2:操作(改);3:审核;4.过期;发布更新
- // if ($scope.item.actions.indexOf("1") >= 0) { //查看权限
- // $scope.item.detailPower = true;
- // } else {
- // $scope.item.detailPower = false;
- // }
- // if ($scope.item.status == 4) {
- // $scope.item.commentPower = true;
- // } else {
- // $scope.item.commentPower = false;
- // }
- // if ($scope.item.actions.indexOf("2") >= 0) { //操作(改)
- // if ($scope.item.status == 1 || $scope.item.status == 5 || $scope.item.status == 3 || $scope.item.status == 4) {
- // $scope.item.updatePower = true;
- // }
- // } else {
- // $scope.item.updatePower = false;
- // }
- // if ($scope.item.actions.indexOf("3") >= 0) { //审核
- // if ($scope.item.status == 1) {
- // $scope.item.reviewPower = true;
- // }
- // } else {
- // $scope.item.reviewPower = false;
- // }
- // if ($scope.item.actions.indexOf("4") >= 0) { //过期与发布
- // if ($scope.item.status == 2) {
- // $scope.item.updatePower = true;
- // $scope.item.outTimePower = true;
- // }
- // if ($scope.item.status == 3) { //已发布的才能评论
- // $scope.item.publishnotPower = true;
- // } else {
- // $scope.item.publishnotPower = false;
- // }
- // } else {
- // $scope.item.outTimePower = false;
- // }
- // }
- // if ($scope.item.status == 3) { //已发布的才能评论
- // // $scope.item.publishnotPower = true;
- // $scope.item.commontPower = true;
- // } else {
- // $scope.item.commontPower = false;
- // // $scope.item.publishnotPower = false;
- // }
- // // console.log($scope.item.status + " " + $scope.item.commontPower);
- $scope.edit = function() {
- $scope.colobject.grid.appScope.editSolution($scope.item);
- // console.log($scope.colobject);
- //$scope.doEdit($scope.item.id);
- }
- $scope.leve=function(){
- $scope.colobject.grid.appScope.leve($scope.item);
- }
- // $scope.comment = function() {
- // $scope.colobject.grid.appScope.commentSolution($scope.item.id);
- // //$scope.doComment($scope.item.id);
- // }
- $scope.approval = function() {
- $scope.colobject.grid.appScope.jry_shenhe($scope.item);
- //$scope.doApproval($scope.item.id,$scope.item.outTimePower);
- }
- $scope.publish = function() {
- $scope.colobject.grid.appScope.jry_lishi($scope.item);
- //$scope.doApproval($scope.item.id,$scope.item.outTimePower);
- }
- $scope.publishnot = function() {
- $scope.colobject.grid.appScope.jry_close($scope.item);
- //$scope.doApproval($scope.item.id,$scope.item.outTimePower);
- }
- // $scope.detail = function() {
- // $scope.colobject.grid.appScope.detailSolution($scope.item.id);
- // // console.log($scope.colobject);
- // }
- var jry_loginUser=$rootScope.user;
- $scope.ZZKGLY=false;
- for(var i=0;i<jry_loginUser.role.length;i++){
- // console.log(i);
- if(jry_loginUser.role[i].role=="知识库管理员"&&jry_loginUser.role[i].rolecode=="solution"){
- $scope.ZZKGLY=true;
- }
- }
- //编辑权限判断
- $scope.jry_bj=function(){
- if($scope.item.status.name=="待审核"&&$scope.item.createUser.id==jry_loginUser.id){
- return true
- }else if($scope.item.status.name=="已驳回"&&$scope.item.createUser.id==jry_loginUser.id){
- return true
- }else if($scope.item.status.name=="已驳回"&&$scope.ZZKGLY){
- return true
- }else{
- return false
- }
- }
- // 升级权限判断
- $scope.jry_sj=function(){
- if($scope.item.status.name=="已发布"&&$scope.item.createUser.id==jry_loginUser.id){
- return true
- }else{
- return false
- }
- }
- // 审核权限判断
- $scope.jry_sh=function(){
- if($scope.item.status.name=="待审核"&&$scope.ZZKGLY){
- return true
- }else{
- return false
- }
- }
- // 历史记录权限判断
- $scope.jry_lsjl=function(){
- return true
- }
- // 停用权限判断
- $scope.jry_ty=function(){
- if($scope.item.status.name=="已发布"&&$scope.ZZKGLY){
- return true
- }else{
- return false
- }
- }
- }]);
- app.directive('gridoperator', function() {
- return {
- restrict: 'E',
- scope: {
- item: '=',
- colobject: '='
- // doEdit: '&',
- // doComment: '&',
- // doApproval: '&'
- },
- controller: 'GridOperatorCtrl',
- template: '<div class="links cl-effect-1 ui-grid-cell-contents pull-left">' +
- // // '<a ng-click="edit()" ng-show="{{item.updatePower}}" tooltip="编辑" tooltip-placement="right"><i class="fa fa-pencil-square-o forestgreen"></i></a>' +
- // '<a ng-click="edit()" ng-show="{{item.updatePower}}" class="bianjifont" >编辑</a>' +
- // // '<a ng-click="comment()" ng-show="{{item.commontPower}}" tooltip="评论" tooltip-placement="right"><i class="fa fa-send gold"></i></a>' +
- // '<a ng-click="comment()" ng-show="{{item.commontPower}}" class="printfont" >评论</a>' +
- // // '<a ng-click="approval()" ng-show="{{item.reviewPower}}" tooltip="审核" tooltip-placement="right"><i class="fa fa-ellipsis-v orangered"></i></a>' +
- // '<a ng-click="approval()" ng-show="{{item.reviewPower}}" class="fontcolor-five" >审核</a>' +
- // // '<a ng-click="publish()" ng-show="{{item.outTimePower}}" tooltip="发布" tooltip-placement="right"><i class="ti-clipboard steelblue"></i></a>' +
- // '<a ng-click="publish()" ng-show="{{item.outTimePower}}" class="handlefont" >发布</a>' +
- // // '<a ng-click="publishnot()" ng-show="{{item.publishnotPower}}" tooltip="撤销" tooltip-placement="right"><i class=" ti-brush-alt royalblue"></i></a>' +
- // '<a ng-click="publishnot()" ng-show="{{item.publishnotPower}}" class="fontcolor-seven" >撤销</a>' +
- // '<a ng-click="edit()" ng-show="{{item.updatePower}}" tooltip="编辑" tooltip-placement="right"><i class="fa fa-pencil-square-o forestgreen"></i></a>' +
- // '<a ng-click="edit()" class="bianjifont" >编辑</a>' +
- // // '<a ng-click="comment()" ng-show="{{item.commontPower}}" tooltip="评论" tooltip-placement="right"><i class="fa fa-send gold"></i></a>' +
- // '<a ng-click="comment()" class="printfont" >评论</a>' +
- // // '<a ng-click="approval()" ng-show="{{item.reviewPower}}" tooltip="审核" tooltip-placement="right"><i class="fa fa-ellipsis-v orangered"></i></a>' +
- // '<a ng-click="approval()" class="fontcolor-five" >审核</a>' +
- // // '<a ng-click="publish()" ng-show="{{item.outTimePower}}" tooltip="发布" tooltip-placement="right"><i class="ti-clipboard steelblue"></i></a>' +
- // '<a ng-click="publish()" class="handlefont" >发布</a>' +
- // // '<a ng-click="publishnot()" ng-show="{{item.publishnotPower}}" tooltip="撤销" tooltip-placement="right"><i class=" ti-brush-alt royalblue"></i></a>' +
- // '<a ng-click="publishnot()" class="fontcolor-seven" >撤销</a>' +
- '<a ng-click="edit()" class="bianjifont" ng-show="jry_bj()">编辑</a>' +
- // '<a ng-click="comment()" ng-show="{{item.commontPower}}" tooltip="评论" tooltip-placement="right"><i class="fa fa-send gold"></i></a>' +
- // '<a ng-click="comment()" class="printfont" >评论</a>' +
- '<a ng-click="leve()" class="printfont" ng-show="jry_sj()">升级</a>' +
- // '<a ng-click="approval()" ng-show="{{item.reviewPower}}" tooltip="审核" tooltip-placement="right"><i class="fa fa-ellipsis-v orangered"></i></a>' +
- '<a ng-click="approval()" class="fontcolor-five" ng-show="jry_sh()">审核</a>' +
- // '<a ng-click="publish()" ng-show="{{item.outTimePower}}" tooltip="发布" tooltip-placement="right"><i class="ti-clipboard steelblue"></i></a>' +
- // '<a ng-click="publish()" class="handlefont" >发布</a>' +
- '<a ng-click="publish()" class="handlefont" ng-show="jry_lsjl()">历史记录</a>' +
- // '<a ng-click="publishnot()" ng-show="{{item.publishnotPower}}" tooltip="撤销" tooltip-placement="right"><i class=" ti-brush-alt royalblue"></i></a>' +
- '<a ng-click="publishnot()" class="fontcolor-seven" ng-show="jry_ty()">停用</a>' +
- '</div>'
- };
- });
|