knowledgeCtrl.js 112 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552
  1. 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) {
  2. $scope.langs = i18nService.getAllLangs();
  3. $scope.lang = 'zh-cn';
  4. i18nService.setCurrentLang($scope.lang);
  5. var loginUser = $rootScope.user;
  6. $scope.gridOptions = {};
  7. $scope.gridOptions.data = 'myData';
  8. $scope.gridOptions.enableColumnResizing = true;
  9. $scope.gridOptions.enableFiltering = false;
  10. $scope.gridOptions.enableGridMenu = false;
  11. $scope.gridOptions.enableRowSelection = true;
  12. $scope.gridOptions.showGridFooter = true;
  13. $scope.gridOptions.showColumnFooter = true;
  14. $scope.gridOptions.fastWatch = true;
  15. $scope.gridOptions.useExternalPagination = true;
  16. // $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  17. $scope.gridOptions.paginationPageSizes = [10];
  18. $scope.gridOptions.paginationPageSize = 10;
  19. $scope.gridOptions.multiSelect = false;
  20. $scope.gridOptions.rowIdentity = function(row) {
  21. return row.id;
  22. };
  23. $scope.gridOptions.getRowIdentity = function(row) {
  24. return row.id;
  25. };
  26. var mun = $scope.gridOptions.paginationPageSize;
  27. $scope.transferTime = function(time) {
  28. return moment(time).format('YYYY-MM-DD ');
  29. }
  30. //jry数据传递
  31. $scope.jry_knowipt="";
  32. if($scope.fenye==undefined){
  33. $scope.fenye=0;
  34. }
  35. // console.log($scope.jry_knowipt);
  36. $scope.jry_todata={
  37. "idx":$scope.fenye,
  38. "sum":10,
  39. "solution":{
  40. "keywords":"",
  41. "solutionType":{"id":''},
  42. "status":{"id":""}
  43. }
  44. }
  45. // $scope.$watch("jry_knowipt",function(val){
  46. // // console.log(val)
  47. // $scope.jry_todata={
  48. // "idx":$scope.fenye,
  49. // "sum":10,
  50. // "solution":{
  51. // "keywords":val
  52. // }
  53. // }
  54. // })
  55. $scope.transferStatus = function(status) {
  56. var statusLabel = "不合法的状态";
  57. if (status.value == 1) {
  58. statusLabel = "待审核";
  59. } else if (status.value == 2) {
  60. statusLabel = "已发布";
  61. } else if (status.value == 3) {
  62. statusLabel = "已驳回";
  63. } else if (status.value == 4) {
  64. statusLabel = "已停用";
  65. } else if (status.value == 5) {
  66. statusLabel = "已驳回";
  67. } else if (status.value == 6) {
  68. statusLabel = "已拒绝";
  69. }
  70. return statusLabel;
  71. }
  72. $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>";
  73. $scope.gridOptions.columnDefs = [{
  74. name: 'item',
  75. displayName: '序号',
  76. width: 50
  77. },
  78. { name: 'solutionnumber', displayName: '编号', width: '10%' },
  79. { name: 'solutionType.typeName', displayName: '类别', width: '8%' },
  80. { name: 'title', displayName: '标题', width: '10%' },
  81. { name: 'visionNumber', displayName: '版本号', width: '10%' },
  82. { name: 'keywords', displayName: '关键字', width: '10%' },
  83. { name: 'status', displayName: '状态', cellTemplate: '<div class="ui-grid-cell-contents">{{grid.appScope.transferStatus(row.entity.status)}}</div>', width: '8%' },
  84. { name: 'createUser.name', displayName: '创建人', width: '8%' },
  85. { name: 'createtime', cellTemplate: '<div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.createtime)}}</div>', displayName: '创建日期', width: '12%' },
  86. { name: '操作', width: 345, cellTemplate: '<gridoperator item="row.entity" colobject="col">' },
  87. ];
  88. $scope.gridOptions.onRegisterApi = function(gridApi) {
  89. $scope.gridApi = gridApi;
  90. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  91. var filtersData = $scope.allfilterData;
  92. // console.log(filtersData);
  93. console.log(newPage);
  94. $scope.fenye=newPage-1;
  95. $scope.jry_todata.idx=newPage-1;
  96. // $scope.jry_todata={
  97. // "idx":$scope.fenye,
  98. // "sum":10
  99. // }
  100. console.log($scope.fenye);
  101. filtersData.pageIndex = newPage - 1;
  102. var data = { pageIndex: newPage - 1 };
  103. var dataFilter = angular.extend(data, filtersData);
  104. dataFilter.status = filtersData.status;
  105. // $scope.refreshListData('expand-right', dataFilter);
  106. // if (JSON.parse(sessionStorage.getItem("searchKnowledge")).pageIndex != dataFilter.pageIndex) {
  107. // $scope.refreshListData('expand-right', dataFilter);
  108. // }
  109. // $scope.refreshListData('expand-right', $scope.jry_todata);
  110. api_zsk.jry_get_list($scope.jry_todata,"solution").then(function(data) {
  111. var myData = Restangular.stripRestangular(data);
  112. // console.log("myData="+JSON.stringify(myData));
  113. $scope.gridOptions.totalItems = myData.totalNum;
  114. if (myData.error && myData.status == 200) {
  115. $scope.myData = [];
  116. } else {
  117. if (angular.isArray(myData.list)) {
  118. $scope.myData = myData.list;
  119. for (var i = 0; i < $scope.myData.length; i++) {
  120. $scope.myData[i]['item'] = i + 1 + $scope.jry_todata.idx * $scope.jry_todata.sum
  121. }
  122. } else {
  123. SweetAlert.swal({
  124. title: "数据为空",
  125. text: myData.list,
  126. type: "warning"
  127. });
  128. }
  129. }
  130. // $scope.ldloading[style.replace('-', '_')] = false;
  131. }
  132. // , function() {
  133. // $scope.ldloading[style.replace('-', '_')] = false;
  134. // }
  135. );
  136. });
  137. };
  138. var fildate = {
  139. key: 'null',
  140. status: 0,
  141. pageIndex: 0,
  142. pageSum: mun,
  143. //treeIds:'[]',
  144. userId: loginUser.id
  145. }
  146. $scope.knowledge = {};
  147. $scope.inspecttype = {};
  148. $scope.my_datalist = {};
  149. $scope.searchstate = 0;
  150. $scope.selectedItems = [];
  151. // $scope.knowledge.type = { id: 1, label: "应用系统" }
  152. $scope.my_data = [];
  153. this.selectRowFunction = function(data) {};
  154. $scope.my_tree = tree = {};
  155. $scope.try_async_load = function() {
  156. $scope.my_data = [];
  157. $scope.doing_async = true;
  158. // api_user_data.fetchDataList('group', { "idx": 0, "sum": 1000 }).then(function(response) {
  159. // var myData = Restangular.stripRestangular(response);
  160. // var list = myData.list;
  161. // var objects = [];
  162. // for (var i = 0; i < list.length; i++) {
  163. // var object = {};
  164. // object.id = list[i].id;
  165. // if (list[i].parent == 0) {
  166. // object.parent = "#";
  167. // } else {
  168. // object.parent = list[i].parent;
  169. // }
  170. // object.text = list[i].groupName;
  171. // object.typeName = "group";
  172. // object.state = {
  173. // "opened": true
  174. // };
  175. // objects.push(object);
  176. // }
  177. // $scope.groups = objects;
  178. // });
  179. // api_solution.findSolutionTypeActions(loginUser.id).then(function(response) {
  180. //JRY
  181. api_zsk.jry_get_list({"idx":0,"sum":1000},"solutionType").then(function(response) {
  182. if (response.status == 200) {
  183. var data = response.list;
  184. // console.log('data='+JSON.stringify(data));
  185. var objects = [];
  186. for (var i = 0; i < data.length; i++) {
  187. var object = {};
  188. object.id = data[i].id;
  189. if (data[i].pid != 0) {
  190. object.parent = data[i].pid;
  191. }
  192. // if (object.parent == 0) {
  193. // object.parent = "#";
  194. // }
  195. object.label = data[i].typeName;
  196. object.actions = data[i].actions; //权限部分
  197. object.group = "1";
  198. object.user = "2";
  199. object.state = {
  200. "opened": true
  201. };
  202. object.typeName = "type";
  203. // if()
  204. // if (object.actions.indexOf("2") >= 0) { //知识库类型 具有增加权限--系统管理员
  205. // $scope.showAddSolutionType = true;
  206. // }
  207. // if (object.actions.indexOf("5") >= 0) { //知识库类型 具有授权权限--系统管理员
  208. // $scope.showReviewKnowledgeType = true;
  209. // }
  210. objects.push(object);
  211. }
  212. $scope.my_data = convertParentToChildList(objects);
  213. if (JSON.parse(sessionStorage.getItem("searchKnowledge")) && JSON.parse(sessionStorage.getItem("searchKnowledge")).treeIds) {
  214. angular.forEach($scope.my_data, function(item) {
  215. if (item.id == JSON.parse(sessionStorage.getItem("searchKnowledge")).treeIds) {
  216. $scope.knowledge.type = item
  217. }
  218. })
  219. }
  220. // if (JSON.parse(sessionStorage.getItem("searchKnowledgetype")) && JSON.parse(sessionStorage.getItem("searchKnowledgetype")).type) {
  221. // angular.forEach($scope.my_data, function(item, index) {
  222. // if (JSON.parse(sessionStorage.getItem("searchKnowledgetype")).type.id == item.id) {
  223. // $scope.my_data[index].selected = true;
  224. // }
  225. // })
  226. // }
  227. $scope.my_datalist = angular.copy($scope.my_data);
  228. $scope.tree_data = angular.copy($scope.my_data);
  229. if ($scope.my_data.length > 0) {
  230. $scope.doing_async = false;
  231. }
  232. } else {
  233. SweetAlert.swal({
  234. title: "系统错误!",
  235. text: "请刷新重试!",
  236. type: "error"
  237. });
  238. }
  239. });
  240. $scope.showAddSolutionType = false; //添加知识类型 按钮
  241. $scope.showReviewKnowledgeType = false; //审核知识类型 按钮
  242. };
  243. $scope.try_async_load();
  244. $scope.ldloading = {};
  245. // console.log($scope.fenye);
  246. $scope.refreshListData = function(style, filterData) {
  247. $scope.ldloading[style.replace('-', '_')] = true;
  248. api_zsk.jry_get_list(filterData,"solution").then(function(data) {
  249. var myData = Restangular.stripRestangular(data);
  250. // console.log("myData="+JSON.stringify(myData));
  251. $scope.gridOptions.totalItems = myData.totalNum;
  252. if (myData.error && myData.status == 200) {
  253. $scope.myData = [];
  254. } else {
  255. if (angular.isArray(myData.list)) {
  256. $scope.myData = myData.list;
  257. for (var i = 0; i < $scope.myData.length; i++) {
  258. $scope.myData[i]['item'] = i + 1 + $scope.jry_todata.idx * $scope.jry_todata.sum
  259. }
  260. } else {
  261. // SweetAlert.swal({
  262. // title: "数据为空",
  263. // text: myData.list,
  264. // type: "warning"
  265. // });
  266. }
  267. }
  268. $scope.ldloading[style.replace('-', '_')] = false;
  269. }, function() {
  270. $scope.ldloading[style.replace('-', '_')] = false;
  271. });
  272. }
  273. //导入
  274. $scope.importopen = function() { //导入触发事件
  275. var modalInstance = $modal.open({
  276. templateUrl: 'assets/views/import.html',
  277. controller: function($scope, $modalInstance, FileUploader) {
  278. var importUploader = $scope.importUploader = new FileUploader({
  279. url: api_solution.upload().getRequestedUrl(),
  280. });
  281. importUploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
  282. console.info('onWhenAddingFileFailed', item, filter, options);
  283. };
  284. importUploader.onAfterAddingFile = function(fileItem) {
  285. console.info('onAfterAddingFile', fileItem);
  286. };
  287. importUploader.onAfterAddingAll = function(addedFileItems) {
  288. console.info('onAfterAddingAll', addedFileItems);
  289. };
  290. importUploader.onProgressItem = function(fileItem, progress) {
  291. console.info('onProgressItem', fileItem, progress);
  292. };
  293. importUploader.onProgressAll = function(progress) {
  294. console.info('onProgressAll', progress);
  295. };
  296. importUploader.onSuccessItem = function(fileItem, response, status, headers) {
  297. if (response.status == 200) {
  298. SweetAlert.swal({
  299. title: "导入成功!",
  300. confirmButtonColor: "#007AFF",
  301. type: "success"
  302. }, function() {
  303. // $scope.ldloading.contract_overlay = false;
  304. $rootScope.isMask = false;
  305. $scope.refreshListData('expand-right', $scope.jry_todata);
  306. });
  307. } else {
  308. // $scope.ldloading.contract_overlay = false;
  309. $rootScope.isMask = false;
  310. SweetAlert.swal({
  311. title: "导入失败!",
  312. text: response.error,
  313. type: "error"
  314. })
  315. }
  316. console.info('onSuccessItem', fileItem, response, status, headers);
  317. };
  318. importUploader.onErrorItem = function(fileItem, response, status, headers) {
  319. console.info('onErrorItem', fileItem, response, status, headers);
  320. SweetAlert.swal({
  321. title: "系统错误!",
  322. text: "系统错误,请稍候重试!",
  323. type: "error"
  324. });
  325. };
  326. importUploader.onCancelItem = function(fileItem, response, status, headers) {
  327. console.info('onCancelItem', fileItem, response, status, headers);
  328. };
  329. importUploader.onCompleteItem = function(fileItem, response, status, headers) {
  330. console.info('onCompleteItem', fileItem, response, status, headers);
  331. };
  332. importUploader.onCompleteAll = function() {
  333. console.info('onCompleteAll');
  334. };
  335. $scope.ldloading = {};
  336. $rootScope.isMask = false;
  337. $scope.import = function(style) {
  338. // $scope.ldloading[style.replace('-', '_')] = true;
  339. $modalInstance.dismiss('cancel');
  340. $rootScope.isMask = true;
  341. importUploader.onBeforeUploadItem = function(item) {
  342. angular.extend(item.headers, $rootScope.getSession());
  343. item.formData.push({ 'fileName': item.file.name });
  344. item.formData.push({ 'type': "dataImport" });
  345. console.info('onBeforeUploadItem', item);
  346. };
  347. importUploader.uploadAll();
  348. }
  349. $scope.cancel = function() {
  350. $modalInstance.dismiss('cancel');
  351. };
  352. },
  353. size: 'sm',
  354. resolve: {
  355. importUploader: function() {
  356. return $scope.importUploader;
  357. }
  358. }
  359. });
  360. modalInstance.result.then(function(selectedItem) {
  361. if (selectedItem) {}
  362. })
  363. }
  364. //知识库下载
  365. $scope.export = function() {
  366. var modalInstance = $modal.open({
  367. // templateUrl: 'assets/views/knowledge/tpl/knowledgegetdown.html',
  368. templateUrl: 'assets/views/system/tpl/getdown.html',
  369. controller: function($scope, $modalInstance) {
  370. $scope.key = {};
  371. $scope.title = '知识库下载';
  372. $scope.lable = '下载类型';
  373. $scope.onChange = function(key) {
  374. $scope.key = key;
  375. }
  376. $scope.downmodel = [{ id: 1, name: "模版下载" }, { id: 2, name: "数据导出" }]
  377. $scope.ok = function() {
  378. $modalInstance.close($scope.key);
  379. };
  380. $scope.cancel = function() {
  381. $modalInstance.dismiss('cancel');
  382. };
  383. },
  384. size: 'sm',
  385. });
  386. modalInstance.result.then(function(selectedItem) {
  387. if (selectedItem) {
  388. var selectedItemId = "知识库模版";
  389. if (selectedItem.id == 2) {
  390. selectedItemId = "知识库数据";
  391. }
  392. var filadata = { 'model': selectedItem.id };
  393. $http({
  394. url: api_solution.export({ 'model': 1 }).getRequestedUrl(),
  395. method: 'POST',
  396. data: JSON.stringify(filadata),
  397. headers: {
  398. // 'Content-type': 'application/xls',
  399. 'Accept': '*/*'
  400. },
  401. responseType: 'arraybuffer'
  402. }).success(function(data, status, headers, config) {
  403. // $scope.ldloading.zoom_in = false;
  404. var file = new Blob([data], {
  405. type: 'application/vnd.ms-excel'
  406. });
  407. //trick to download store a file having its URL
  408. var fileURL = URL.createObjectURL(file);
  409. var a = document.createElement('a');
  410. a.href = fileURL;
  411. a.target = '_blank';
  412. a.download = selectedItemId + '.xlsx';
  413. document.body.appendChild(a);
  414. a.click();
  415. }).error(function(data, status, headers, config) {
  416. // $scope.ldloading.zoom_in = false;
  417. console.log(data);
  418. });
  419. }
  420. });
  421. }
  422. $scope.createKnowledge = function() {
  423. var data = { model: { knowledge: { createUserId: loginUser.id, status: 1 } } };
  424. // var data = { model: { knowledge: { createUser: {id:loginUser.id}, status: 1 } } };
  425. $state.go('app.knowledge.create', { formKey: 'knowledge_create', service: 'api_solution', 'model': JSON.stringify(data) })
  426. }
  427. $scope.onDblClick = function(row) {
  428. // api_solution.findSolutionById(row.entity.id).then(function(response) {
  429. // var data = { model: { knowledge: response.data } };
  430. // if (!isNaN(data.model.knowledge.vision)) {
  431. // data.model.knowledge.vision = 'V' + String(data.model.knowledge.vision);
  432. // }
  433. console.log(row)
  434. api_solution.jry_getHistory({"idx":0,"sum":999,"solution":{"solutionnumber":row.entity.solutionnumber}}).then(function(res1){
  435. $state.go('app.knowledge.detail', { formKey: 'knowledge_detail', service: 'api_solution', 'model': JSON.stringify({"model":{"knowledge":row.entity}}),'history': JSON.stringify(res1.list)})
  436. })
  437. }
  438. // 编辑
  439. $scope.editSolution = function(item) {
  440. // api_solution.findSolutionById(id).then(function(response) {
  441. // var data = { model: { knowledge: response.data } };
  442. // if (!isNaN(data.model.knowledge.vision)) {
  443. // data.model.knowledge.vision = 'V' + String(data.model.knowledge.vision);
  444. // }
  445. api_solution.jry_getHistory({"idx":0,"sum":999,"solution":{"solutionnumber":item.solutionnumber}}).then(function(res1){
  446. $state.go('app.knowledge.editor', { formKey: 'knowledge_editor', service: 'api_solution', 'model': JSON.stringify({"model":{"knowledge":item}}),'history': JSON.stringify(res1.list)})
  447. })
  448. console.log(item);
  449. }
  450. //升级
  451. $scope.leve = function(item) {
  452. // api_solution.findSolutionById(id).then(function(response) {
  453. // var data = { model: { knowledge: response.data } };
  454. // if (!isNaN(data.model.knowledge.vision)) {
  455. // data.model.knowledge.vision = 'V' + String(data.model.knowledge.vision);
  456. // }
  457. // console.log(item);
  458. api_solution.jry_getHistory({"idx":0,"sum":999,"solution":{"solutionnumber":item.solutionnumber}}).then(function(res1){
  459. // console.log(res1)
  460. api_solution.jry_leveVision(item.id).then(function(res){
  461. console.log(res);
  462. item.visionNumber=res.data;
  463. console.log(item);
  464. $state.go('app.knowledge.leve', { formKey: 'knowledge_leve', service: 'api_solution', 'model': JSON.stringify({"model":{"knowledge":item}}),'history': JSON.stringify(res1.list)})
  465. })
  466. })
  467. }
  468. $scope.commentSolution = function(id) {
  469. var modalInstance = $modal.open({
  470. templateUrl: 'assets/views/knowledge/tpl/commentknowledge.html',
  471. controller: function($scope, $http, $modalInstance, APIService, uploader, currentUser, Alert, MomentFormat, loginUser) {
  472. $scope.isManage = false;
  473. angular.forEach(loginUser.role, function(item) {
  474. if (item.rolecode == "solution") {
  475. $scope.isManage = true;
  476. }
  477. })
  478. $scope.examineKnowledge = function(item) {
  479. APIService.updModel("solutionReview", { "solutionReview": { "status": 2, "id": item.id } }).then(function(response) {
  480. if (response && response.status == "200") {
  481. SweetAlert.swal({
  482. title: "审核通过!",
  483. text: "知识库评论审核成功!",
  484. type: "success"
  485. }, function() {
  486. loadData();
  487. });
  488. } else {
  489. SweetAlert.swal({
  490. title: "审核失败",
  491. text: "知识库评论审核失败!",
  492. type: "error"
  493. });
  494. }
  495. })
  496. }
  497. $scope.reviewKnowledge = function(item) {
  498. APIService.updModel("updSolutionReviewByIds", { "type": 2, "status": 2, "ids": id }).then(function(response) {
  499. if (response && response.status == "200") {
  500. SweetAlert.swal({
  501. title: "审核通过!",
  502. text: "知识库评论审核成功!",
  503. type: "success"
  504. }, function() {
  505. loadData();
  506. });
  507. } else {
  508. SweetAlert.swal({
  509. title: "审核失败",
  510. text: "知识库评论审核失败!",
  511. type: "error"
  512. });
  513. }
  514. })
  515. }
  516. $scope.removeKnowledge = function(item) {
  517. APIService.updModel("solutionReview", { "solutionReview": { "status": 3, "id": item.id } }).then(function(response) {
  518. if (response && response.status == "200") {
  519. SweetAlert.swal({
  520. title: "删除成功!",
  521. text: "知识库评论删除成功!",
  522. type: "success"
  523. }, function() {
  524. loadData();
  525. });
  526. } else {
  527. SweetAlert.swal({
  528. title: "删除失败",
  529. text: "知识库评论删除失败!",
  530. type: "error"
  531. });
  532. }
  533. })
  534. }
  535. var loadData = function() {
  536. $scope.visions = [];
  537. $scope.entity = {};
  538. $scope.showCommentScore = true;
  539. $scope.comments = [];
  540. // APIService.findSolutionReviewById(loginUser.id, solution.id, 0, 1000).then(function(response) {
  541. APIService.fetchDataList('solutionReview', { 'idx': 0, 'sum': 1000, 'solutionReview': { 'solutionId': id, 'userId': loginUser.id } }).then(function(response) {
  542. if (response.status != "500") {
  543. var data = response.list;
  544. if (angular.isDefined(response.result)) { $scope.showCommentScore = false; }
  545. for (var i = 0; i < data.length; i++) {
  546. var object = {};
  547. object.id = data[i].id;
  548. object.name = data[i].userName;
  549. object.status = data[i].status;
  550. if (data[i].reviewScore > 0) {
  551. object.score = data[i].reviewScore;
  552. }
  553. // object.content=data[i].review;
  554. var ss = data[i].review;
  555. var s1 = "";
  556. if (ss != null) {
  557. var index = ss.indexOf("<p>");
  558. var indexs = ss.indexOf("</p>");
  559. s1 = ss.substring(index + 3, indexs);
  560. }
  561. object.content = s1;
  562. // object.score=data[i].reviewScore;
  563. object.time = moment(data[i].reviewTime).format('YYYY-MM-DD HH:mm:ss');
  564. // console.log('object.time='+JSON.stringify(object));
  565. $scope.comments.push(object);
  566. }
  567. }
  568. });
  569. APIService.findSolutionById(id).then(function(response) {
  570. var datas = response.data;
  571. $scope.entity = {
  572. "id": datas.id,
  573. "title": datas.title,
  574. "keys": datas.keywords,
  575. "type": datas.typeId,
  576. "range": datas.solutionRange,
  577. "number": datas.solutionNumber,
  578. "content": datas.content,
  579. "createrUserId": datas.createUserId,
  580. "createTime": datas.createtime,
  581. "status": datas.status,
  582. "hits": datas.hits,
  583. "relateId": datas.relateId,
  584. "vision": datas.vision,
  585. "vision2": "V" + datas.vision,
  586. // "fileContent":datas.fileContent,
  587. "replies": datas.replies,
  588. "scores": datas.scores,
  589. "hits": datas.hits,
  590. "fileName": datas.fileName,
  591. "typeName": datas.typeDTO.typeName
  592. };
  593. console.log(datas)
  594. console.log($scope.entity);
  595. });
  596. }
  597. loadData();
  598. $scope.options = {
  599. language: 'zh-cn',
  600. allowedContent: true,
  601. entities: false
  602. };
  603. $scope.uploader = uploader;
  604. $scope.getdown = function(filename) {
  605. $http({
  606. url: APIService.getSolutionDowpath(id).getRequestedUrl(),
  607. method: 'GET',
  608. headers: {
  609. //'Content-type' : 'application/xls',
  610. 'Accept': '*/*'
  611. },
  612. responseType: 'arraybuffer'
  613. }).success(function(data, status, headers, config) {
  614. var file = new Blob([data], {
  615. type: 'application/octet-stream'
  616. });
  617. //trick to download store a file having its URL
  618. var fileURL = URL.createObjectURL(file);
  619. var a = document.createElement('a');
  620. a.href = fileURL;
  621. a.target = '_blank';
  622. a.download = filename;
  623. document.body.appendChild(a);
  624. a.click();
  625. }).error(function(data, status, headers, config) {
  626. console.log(data);
  627. });
  628. }
  629. $scope.ranges = [{
  630. "id": 1,
  631. "name": "全局"
  632. }, {
  633. "id": 3,
  634. "name": "组"
  635. }];
  636. // $scope.ok = function() {
  637. // $modalInstance.close($scope.entity);
  638. // };
  639. $scope.cancel = function() {
  640. // api_solution.findSolutions($scope.entity.id).then(function(response){
  641. // var data6=response.data[0];
  642. // for(var j=0;j<=$scope.solutionBBS.length;j++){
  643. // if($scope.solutionBBS.length>0&&$scope.solutionBBS[j].id==$scope.entity.id){
  644. // $scope.solutionBBS[j].replies=data6.replies;
  645. // $scope.solutionBBS[j].hits=data6.hits;
  646. // $scope.solutionBBS[j].scores=data6.scores;
  647. // break;
  648. // }
  649. // }
  650. // });
  651. $modalInstance.close($scope.entity.id);
  652. };
  653. $scope.saveComment = function(reviewcontent, score) {
  654. $scope.entity['reviewcontent'] = reviewcontent;
  655. $scope.entity['score'] = score;
  656. $modalInstance.close($scope.entity);
  657. }
  658. },
  659. size: 'lg',
  660. resolve: {
  661. APIService: function() {
  662. return api_solution;
  663. },
  664. uploader: function() {
  665. return $scope.uploader;
  666. },
  667. currentUser: function() {
  668. return loginUser.id;
  669. },
  670. Alert: function() {
  671. return SweetAlert;
  672. },
  673. MomentFormat: function() {
  674. return moment;
  675. },
  676. loginUser: function() {
  677. return loginUser;
  678. }
  679. }
  680. });
  681. modalInstance.result.then(function(selectedItem) {
  682. if (selectedItem.title) {
  683. var solutionId = selectedItem.id;
  684. var reviewContent = selectedItem.reviewcontent;
  685. // if(solutionId==null){
  686. var reviewScore;
  687. if (selectedItem.score) { reviewScore = selectedItem.score.toFixed(1) }
  688. var data = {
  689. id: null,
  690. solutionId: solutionId,
  691. userId: loginUser.id,
  692. review: reviewContent,
  693. reviewScore: reviewScore,
  694. reviewTime: new Date()
  695. };
  696. api_solution.addSolutionReview(data).then(function(response) {
  697. var status = response.status;
  698. console.log(response)
  699. console.log('$scope.apClient=' + JSON.stringify(status));
  700. if (status == "200") {
  701. SweetAlert.swal({
  702. title: "评论知识库!",
  703. text: "评论知识库成功!",
  704. type: "success"
  705. }, function() {
  706. api_solution.findSolutions(selectedItem.id).then(function(response) {
  707. var data6 = response.data[0];
  708. for (var j = 0; j <= $scope.solutionBBS.length; j++) {
  709. if ($scope.solutionBBS.length > 0 && $scope.solutionBBS[j].id == selectedItem.id) {
  710. $scope.solutionBBS[j].replies = data6.replies;
  711. $scope.solutionBBS[j].hits = data6.hits;
  712. $scope.solutionBBS[j].scores = data6.scores;
  713. break;
  714. }
  715. }
  716. });
  717. });
  718. } else {
  719. SweetAlert.swal({
  720. title: "评论知识库!",
  721. text: "评论知识库失败!",
  722. type: "error"
  723. });
  724. }
  725. });
  726. }
  727. });
  728. }
  729. //停用
  730. $scope.jry_close=function(item){
  731. // console.log(item);
  732. // item.status.id=74;
  733. // item["recalluser"]={id:loginUser.id};
  734. // item["recalltime"]=moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
  735. // delete(item["item"]);
  736. // item.renewtime=moment(item.renewtime).format('YYYY-MM-DD HH:mm:ss');
  737. // $scope.jry_tingyong={"solution":item};
  738. SweetAlert.swal({
  739. title: "",
  740. text: "是否确认将编号【"+item.solutionnumber+"】停用?停用后此知识不会公布在外!",
  741. type: "warning",
  742. showCancelButton: true,
  743. confirmButtonColor: "#DD6B55",
  744. confirmButtonText: "确认停用",
  745. cancelButtonText: "取消操作",
  746. closeOnConfirm: false,
  747. closeOnCancel: false
  748. }, function (isConfirm) {
  749. if (isConfirm) {
  750. item.status.id=74;
  751. item["recalluser"]={id:loginUser.id};
  752. item["recalltime"]=moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
  753. delete(item["item"]);
  754. item.renewtime=moment(item.renewtime).format('YYYY-MM-DD HH:mm:ss');
  755. $scope.jry_tingyong={"solution":item};
  756. api_solution.jry_updateSolution($scope.jry_tingyong).then(function(){
  757. SweetAlert.swal("操作成功!", "该知识已停用", "success");
  758. $scope.myData=[];
  759. $scope.refreshListData('expand-right',$scope.jry_todata);
  760. })
  761. } else {
  762. SweetAlert.swal("操作取消", "该知识安全", "error");
  763. }
  764. });
  765. }
  766. //审核
  767. $scope.jry_shenhe=function(item){
  768. api_solution.jry_getHistory({"idx":0,"sum":999,"solution":{"solutionnumber":item.solutionnumber}}).then(function(res1){
  769. $state.go('app.knowledge.jry_shenhe', { formKey: 'knowledge_shenhe', service: 'api_solution', 'model': JSON.stringify({"model":{"knowledge":item}}),'history': JSON.stringify(res1.list)})
  770. })
  771. }
  772. // 历史记录
  773. $scope.jry_lishi=function(item){
  774. $state.go('app.knowledge.jry_lishi', { formKey: 'knowledge_lishi', service: 'api_solution', 'model': JSON.stringify({"model":{"knowledge":item}})})
  775. }
  776. $scope.approvalSolution = function(data,id, outTimePower) {
  777. var modalInstance = $modal.open({
  778. templateUrl: 'assets/views/knowledge/tpl/approvalknowledge.html',
  779. controller: function($scope, $modalInstance, APIService, Alert, workGroups, uploader, tree_data, outTimePower) {
  780. $scope.wgroups = workGroups;
  781. $scope.type_handler = function(branch) {
  782. $scope.typeIds = branch.id;
  783. // console.log(branch);
  784. };
  785. $scope.type_data = tree_data;
  786. $scope.uploader = uploader;
  787. var loadData = function() {
  788. $scope.visions = [];
  789. // APIService.findSolutionById(id).then(function(response) {
  790. // var data = response.data;
  791. $scope.visions = data;
  792. //console.log(datas);
  793. // var data={};
  794. // for(var i=0;i<datas.length-1;i++){
  795. // if(id==datas[i].id){
  796. // data=datas[i];
  797. // }
  798. // }
  799. $scope.entity = {
  800. "id": data.id,
  801. "title": data.title,
  802. "keys": data.keywords,
  803. "typeId": data.typeId,
  804. "range": data.solutionRange,
  805. "number": data.solutionNumber,
  806. "content": data.content,
  807. "createrUserId": data.createrUserId,
  808. "createrUserName": data.createrUserName,
  809. "createTime": data.createTime,
  810. "status": data.status,
  811. "hits": data.hits,
  812. "relateId": data.relateId,
  813. "vision": data.vision,
  814. "outtime": outTimePower,
  815. // "filePic":$scope.filePic,
  816. "typeName": data.typename,
  817. "fileName": data.fileName
  818. };
  819. // var typeName;
  820. // APIService.getSolutionType(data.typeId).then(function(responseData){
  821. // var dd=responseData.data;
  822. // typeName=dd.typeName;
  823. // console.log('$scope.entity_2='+JSON.stringify($scope.entity));
  824. $scope.nowEntity = data;
  825. $scope.couldReview = true;
  826. $scope.showOutTime = true;
  827. $scope.fabu = false;
  828. $scope.shenhe = false;
  829. $scope.fabulabel = false;
  830. $scope.chexiao = false;
  831. $scope.shouquan = false;
  832. //$scope.shou=false;
  833. if ($scope.nowEntity.status != 1) { //状态只有是 待审核状态 才能进行审核
  834. $scope.couldReview = false;
  835. }
  836. if ($scope.nowEntity.status == 1) {
  837. $scope.shenhe = true;
  838. if ($scope.entity.range == 3) {
  839. $scope.shouquan = true;
  840. $scope.multipleDemo = {};
  841. // api_solution.findSolutionGroup($scope.entity.id).then(function(response){
  842. // $scope.multipleDemo = {};
  843. // var data = response.data;
  844. // var item = [];
  845. // $scope.multipleDemo.id = $scope.entity.id;
  846. // for(var i=0;i<$scope.group.length;i++){
  847. // for(var j=0;j<data.length;j++){
  848. // if(data[j].groupId == $scope.group[i].id){
  849. // item[item.length] = $scope.group[i];
  850. // break;
  851. // }
  852. // }
  853. // }
  854. // $scope.multipleDemo.item = item;
  855. // $scope.multipleDemo;
  856. // });
  857. }
  858. }
  859. if ($scope.nowEntity.status == 2) {
  860. $scope.fabu = true;
  861. $scope.fabulabel = true;
  862. }
  863. if ($scope.nowEntity.status == 3) {
  864. $scope.fabu = false;
  865. $scope.chexiao = true;
  866. $scope.showOutTime = false;
  867. }
  868. // if($scope.nowEntity.status==4){
  869. // $scope.fabu=true;
  870. // $scope.chexiao = true;
  871. // }
  872. if (($scope.nowEntity.status == 2) && outTimePower) { //表示状态为已通过
  873. $scope.showOutTime = false;
  874. }
  875. // APIService.getTree($scope.typeIds,$scope.groupIds,$scope.actionType).then(function(response){
  876. // var objectR=[];
  877. // var objectL=[];
  878. // var data=response.data;
  879. // var map=data.map;
  880. // var inList=map.inList;
  881. // var outList=map.outList;
  882. // if(inList!=null){
  883. // for(var i=0;i<inList.length;i++){
  884. // var object=inList[i];
  885. // var entity={
  886. // "id":object[0],
  887. // "name":object[1],
  888. // "value":object[1]
  889. // }
  890. // objectR.push(entity);//已选
  891. // }
  892. // }
  893. // if(outList!=null){
  894. // for(var i=0;i<outList.length;i++){
  895. // var object=outList[i];
  896. // var entity={
  897. // "id":object[0],
  898. // "name":object[1],
  899. // "value":object[1]
  900. // }
  901. // objectL.push(entity);//未选
  902. // }
  903. // }
  904. // $scope.peopleR=objectR;
  905. // $scope.peopleL=objectL;
  906. // });
  907. // });
  908. // });
  909. }
  910. $scope.closeAlert = function(index) {
  911. $scope.alerts.splice(index, 1);
  912. };
  913. $scope.test = false;
  914. $scope.getin = false;
  915. $scope.verifySolutions = function(type, reason) {
  916. var publishRange = angular.element("#publishRange").val();
  917. if (publishRange == "") {
  918. publishRange = 0;
  919. }
  920. var status = "";
  921. var statusName = "";
  922. if (type == "success") { //审核通过
  923. status = 2;
  924. statusName = "审核通过";
  925. } else if (type == "failed") { //审核驳回
  926. status = 5;
  927. statusName = "审核驳回";
  928. } else if (type == "reject") { //审核拒绝
  929. status = 6;
  930. statusName = "审核拒绝";
  931. } else if (type == "outtime") { //过时
  932. status = 4;
  933. statusName = "撤销";
  934. } else if (type = "publish") { //发布
  935. status = 3;
  936. statusName = "发布";
  937. }
  938. // APIService.updateSolutionStatus({id:$scope.nowEntity.id,status:status,renewUserId:loginUser.id,publishRange:0,reject:reason}).then(function(response){
  939. // var status=response.status;
  940. // if(status=="200"){
  941. // Alert.swal({
  942. // title: statusName+"知识库",
  943. // text: statusName+'成功',
  944. // type: "warning"
  945. // });
  946. // }else{
  947. // Alert.swal({
  948. // title: statusName+"知识库",
  949. // text: statusName+'失败',
  950. // type: "warning"
  951. // });
  952. // }
  953. // $modalInstance.dismiss('cancel');
  954. // });
  955. $scope.entity.status = status;
  956. $scope.entity['statusName'] = statusName;
  957. $scope.entity['reason'] = reason;
  958. $modalInstance.close($scope.entity);
  959. };
  960. $scope.group = [];
  961. api_user_data.fetchDataList('group', { 'idx': 0, 'sum': 1000 }).then(function(result) {
  962. $scope.my_datas = convertParentToChildList(result['list']);
  963. var nata = [];
  964. for (var i = 0; i < $scope.my_datas.length; i++) {
  965. nata.push({
  966. 'groupname': $scope.my_datas[i].groupName,
  967. 'id': $scope.my_datas[i].id
  968. })
  969. $scope.group = nata;
  970. }
  971. })
  972. $scope.saveright = function(multipleDemo) {
  973. // console.log(multipleDemo);
  974. // if(angular.isUndefined(multipleDemo)){
  975. // Alert.swal({
  976. // title: "授权知识库!",
  977. // text: "授权知识库成功!",
  978. // type: "success"
  979. // });
  980. // }
  981. $scope.entity['multipleDemo'] = multipleDemo;
  982. }
  983. $scope.options = {
  984. language: 'zh-cn',
  985. allowedContent: true,
  986. entities: false
  987. };
  988. $scope.onReady = function() {
  989. // ...
  990. };
  991. $scope.ranges = [{
  992. "id": 1,
  993. "name": "全局"
  994. }, {
  995. "id": 3,
  996. "name": "组"
  997. }];
  998. // $scope.ok = function() {
  999. // var data = {};
  1000. // $modalInstance.close($scope.entity);
  1001. // };
  1002. $scope.cancel = function() {
  1003. $modalInstance.dismiss('cancel');
  1004. };
  1005. loadData();
  1006. },
  1007. // size: 'sm',
  1008. resolve: {
  1009. APIService: function() {
  1010. return api_solution;
  1011. },
  1012. Alert: function() {
  1013. return SweetAlert;
  1014. },
  1015. workGroups: function() {
  1016. return $scope.groups;
  1017. },
  1018. uploader: function() {
  1019. return $scope.uploader;
  1020. },
  1021. tree_data: function() {
  1022. return angular.copy($scope.tree_data);
  1023. },
  1024. outTimePower: function() {
  1025. return outTimePower;
  1026. }
  1027. }
  1028. });
  1029. modalInstance.result.then(function(selectedItem) {
  1030. if (selectedItem) {
  1031. // console.log(selectedItem);
  1032. if (selectedItem.status == 2 && selectedItem.range == 3) {
  1033. // console.log(selectedItem.multipleDemo.item);
  1034. if (angular.isUndefined(selectedItem.multipleDemo.item) || selectedItem.multipleDemo.item == "") {
  1035. SweetAlert.swal({
  1036. title: "授权为空",
  1037. text: "请选择本知识授权组",
  1038. type: "error"
  1039. });
  1040. } else {
  1041. var item = [];
  1042. for (var i = 0; i < selectedItem.multipleDemo.item.length; i++) {
  1043. item[i] = selectedItem.multipleDemo.item[i].id;
  1044. }
  1045. api_solution.saveSolutionGroup(selectedItem.id, item).then(function(response) {
  1046. $scope.data4 = response;
  1047. if ($scope.data4.status == "200") {
  1048. var filedata = { solution: { id: selectedItem.id, status: selectedItem.status, renewUserId: loginUser.id, publishrange: 0, reject: selectedItem.reason } }
  1049. api_solution.updateSolutionStatus(filedata).then(function(response) {
  1050. $scope.data5 = response;
  1051. console.log($scope.data4);
  1052. console.log($scope.data4)
  1053. if ($scope.data5.status == "200") {
  1054. SweetAlert.swal({
  1055. title: "审核知识库",
  1056. text: '审核成功',
  1057. type: "success"
  1058. }, function() {
  1059. $scope.reload();
  1060. });
  1061. } else {
  1062. SweetAlert.swal({
  1063. title: "审核知识库",
  1064. text: '审核失败',
  1065. type: "warning"
  1066. });
  1067. }
  1068. });
  1069. } else {
  1070. SweetAlert.swal({
  1071. title: "授权",
  1072. text: '授权失败',
  1073. type: "warning"
  1074. });
  1075. }
  1076. });
  1077. }
  1078. } else {
  1079. var filedata = { solution: { id: selectedItem.id, status: selectedItem.status, renewUserId: loginUser.id, publishrange: 0, reject: selectedItem.reason } }
  1080. api_solution.updateSolutionStatus(filedata).then(function(response) {
  1081. // console.log(response);
  1082. var status = response.status;
  1083. if (response.status == "200") {
  1084. // if(status=="200"){
  1085. SweetAlert.swal({
  1086. title: selectedItem.statusName + "知识库",
  1087. text: selectedItem.statusName + '成功',
  1088. type: "success",
  1089. }, function() {
  1090. $scope.reload();
  1091. });
  1092. } else {
  1093. SweetAlert.swal({
  1094. title: statusName + "知识库",
  1095. text: statusName + '失败',
  1096. type: "warning"
  1097. });
  1098. }
  1099. });
  1100. }
  1101. }
  1102. })
  1103. }
  1104. $scope.publishSolution = function(id, outTimePower) {
  1105. var modalInstance = $modal.open({
  1106. templateUrl: 'assets/views/knowledge/tpl/publishknowledge.html',
  1107. controller: function($scope, $modalInstance, APIService, Alert, workGroups, uploader, outTimePower) {
  1108. $scope.group = [];
  1109. api_user_data.fetchDataList('group', { 'idx': 0, 'sum': 1000 }).then(function(result) {
  1110. $scope.my_datas = convertParentToChildList(result['list']);
  1111. var nata = [];
  1112. for (var i = 0; i < $scope.my_datas.length; i++) {
  1113. nata.push({
  1114. 'groupname': $scope.my_datas[i].groupName,
  1115. 'id': $scope.my_datas[i].id
  1116. })
  1117. $scope.group = nata;
  1118. }
  1119. })
  1120. $scope.options = {
  1121. language: 'zh-cn',
  1122. allowedContent: true,
  1123. entities: false
  1124. };
  1125. $scope.onReady = function() {
  1126. // ...
  1127. };
  1128. $scope.ranges = [{
  1129. "id": 1,
  1130. "name": "全局"
  1131. }, {
  1132. "id": 3,
  1133. "name": "组"
  1134. }];
  1135. $scope.ok = function() {
  1136. var data = {};
  1137. $modalInstance.close($scope.entity);
  1138. };
  1139. $scope.cancel = function() {
  1140. $modalInstance.dismiss('cancel');
  1141. };
  1142. loadData();
  1143. },
  1144. size: 'lg',
  1145. resolve: {
  1146. APIService: function() {
  1147. return api_solution;
  1148. },
  1149. Alert: function() {
  1150. return SweetAlert;
  1151. },
  1152. workGroups: function() {
  1153. return $scope.groups;
  1154. },
  1155. uploader: function() {
  1156. return $scope.uploader;
  1157. },
  1158. tree_data: function() {
  1159. return angular.copy($scope.tree_data);
  1160. },
  1161. outTimePower: function() {
  1162. return outTimePower;
  1163. }
  1164. }
  1165. });
  1166. }
  1167. var apple_selected, tree, treedata_avm, treedata_geography;
  1168. //$scope.selectedTreeNode = {};
  1169. $scope.onFilterCallback = function(branch) {
  1170. $scope.selectedItems[0] = {};
  1171. // $scope.selectedTreeNode = branch;
  1172. // $scope.refreshListData('expand-right', filterData);
  1173. };
  1174. // $scope.my_data = [];
  1175. $scope.tree_data = [];
  1176. $scope.my_tree = tree = {};
  1177. function convertListToTree(data, treeMap) {
  1178. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  1179. var root = null; //Initially set our loop to null
  1180. var parentNode = null;
  1181. //loop over data
  1182. for (var i = 0; i < data.length; i++) {
  1183. var datum = data[i];
  1184. //each node will have children, so let's give it a "children" poperty
  1185. datum.children = [];
  1186. //add an entry for this node to the map so that any future children can
  1187. //lookup the parent
  1188. idToNodeMap[datum.id] = datum;
  1189. //Does this node have a parent?
  1190. if (typeof datum.parent === "undefined" || datum.parent == null) {
  1191. //Doesn't look like it, so this node is the root of the tree
  1192. root = datum;
  1193. treeMap[datum.id] = root;
  1194. } else {
  1195. //This node has a parent, so let's look it up using the id
  1196. parentNode = idToNodeMap[datum.parent];
  1197. //We don't need this property, so let's delete it.
  1198. delete datum.parent;
  1199. //Let's add the current node as a child of the parent node.
  1200. parentNode.children.push(datum);
  1201. }
  1202. }
  1203. return root;
  1204. }
  1205. function convertParentToChildList(data) {
  1206. var treeMap = {};
  1207. var list = [];
  1208. convertListToTree(data, treeMap);
  1209. angular.forEach(treeMap, function(item) {
  1210. list.push(item);
  1211. });
  1212. return list;
  1213. }
  1214. // api_solution.addNotFile({ status:status,renewUserId:loginUser.id,publishRange:0,reject:reason}).then(function(response){
  1215. // var myData = Restangular.stripRestangular(response);
  1216. // console.log('myData='+JSON.stringify(myData));
  1217. // })
  1218. var uploader = $scope.uploader = new FileUploader({
  1219. url: api_solution.upload().getRequestedUrl(),
  1220. alias: "file",
  1221. removeAfterUpload: true,
  1222. queueLimit: 10
  1223. // headers : {
  1224. // }
  1225. });
  1226. // console.log('uploader='+JSON.stringify(uploader));
  1227. // var uploader_1 = $scope.uploader = new FileUploader({
  1228. // url:api_solution.addNotFile().getRequestedUrl(),
  1229. // alias:"file",
  1230. // removeAfterUpload:true,
  1231. // queueLimit:1
  1232. // });
  1233. // console.log('$scope.uploader.queue='+JSON.stringify(uploader.queue.file.name));
  1234. $scope.removeKnowledgeType = function() {
  1235. var b = $scope.my_tree.get_selected_branch();
  1236. if (b != null) {
  1237. SweetAlert.swal({
  1238. title: "确认删除?",
  1239. text: "删除数据后,将不能恢复该数据!",
  1240. type: "warning",
  1241. cancelButtonText: "取消",
  1242. showCancelButton: true,
  1243. confirmButtonColor: "#DD6B55",
  1244. confirmButtonText: "确认删除!"
  1245. }, function(isConfirm) {
  1246. if (isConfirm) {
  1247. api_solution.removeSolutionType(b.id).then(function(response) {
  1248. if (response.status == 204) {
  1249. $scope.try_async_load();
  1250. SweetAlert.swal({
  1251. title: "删除成功!",
  1252. confirmButtonColor: "#007AFF"
  1253. });
  1254. } else {
  1255. SweetAlert.swal({
  1256. title: "删除失败!",
  1257. text: response.data,
  1258. confirmButtonColor: "#007AFF"
  1259. });
  1260. }
  1261. });
  1262. }
  1263. });
  1264. } else {
  1265. SweetAlert.swal({
  1266. title: "删除数据错误",
  1267. text: "无法删除,请选中一个知识库类型!",
  1268. type: "warning"
  1269. });
  1270. }
  1271. }
  1272. $scope.editKnowledgeType = function(flag, size) {
  1273. var modalInstance = $modal.open({
  1274. templateUrl: 'assets/views/knowledge/tpl/newknowledgetype.html',
  1275. controller: function($scope, $modalInstance, selectNode, parentNode, isCreate, Alert) {
  1276. $scope.editNode = {};
  1277. if (angular.isDefined(selectNode)) {
  1278. $scope.editNode.id = selectNode.id;
  1279. $scope.editNode.typeName = selectNode.label;
  1280. }
  1281. // console.log('parentNode='+JSON.stringify(parentNode));
  1282. // if(parentNode==null){
  1283. // alert("请选择要添加类别的父类")
  1284. // }
  1285. if (angular.isDefined(parentNode) && (parentNode != null)) {
  1286. $scope.editNode.pid = parentNode.id;
  1287. $scope.parentName = parentNode.label;
  1288. $scope.ok = function() {
  1289. var data = {};
  1290. if (isCreate) {
  1291. data = {
  1292. flag: isCreate,
  1293. typeName: $scope.editNode.typeName,
  1294. pid: $scope.editNode.pid
  1295. }
  1296. } else {
  1297. data = {
  1298. flag: isCreate,
  1299. id: $scope.editNode.id,
  1300. typeName: $scope.editNode.typeName,
  1301. pid: $scope.editNode.pid
  1302. }
  1303. }
  1304. $modalInstance.close(data);
  1305. };
  1306. } else {
  1307. Alert.swal({
  1308. title: "操作错误",
  1309. text: "请选择要添加类别的父类!",
  1310. type: "warning"
  1311. })
  1312. return undefined;
  1313. }
  1314. $scope.ok = function() {
  1315. $modalInstance.close($scope.entity);
  1316. };
  1317. $scope.cancel = function() {
  1318. $modalInstance.dismiss('cancel');
  1319. };
  1320. },
  1321. size: size,
  1322. resolve: {
  1323. selectNode: function() {
  1324. if (!flag) {
  1325. return $scope.my_tree.get_selected_branch();
  1326. } else {
  1327. return undefined;
  1328. }
  1329. },
  1330. parentNode: function() {
  1331. if (flag) {
  1332. return $scope.my_tree.get_selected_branch();
  1333. } else {
  1334. var b = $scope.my_tree.get_selected_branch();
  1335. if (b != null) {
  1336. return $scope.my_tree.get_parent_branch(b);
  1337. }
  1338. return undefined;
  1339. }
  1340. },
  1341. isCreate: function() {
  1342. return flag;
  1343. },
  1344. Alert: function() {
  1345. return SweetAlert;
  1346. }
  1347. }
  1348. });
  1349. modalInstance.result.then(function(selectedItem) {
  1350. if (selectedItem) {
  1351. if (selectedItem.flag) {
  1352. api_solution.addSolutionType({ "pid": selectedItem.pid, "typeName": selectedItem.typeName }).then(function(response) {
  1353. var myData = Restangular.stripRestangular(response);
  1354. var data = myData.data;
  1355. if (myData.status == 201) {
  1356. $scope.try_async_load();
  1357. SweetAlert.swal({
  1358. title: "操作成功",
  1359. text: "操作成功!",
  1360. type: "success"
  1361. });
  1362. }
  1363. })
  1364. } else {
  1365. api_solution.updateSolutionType({ "id": selectedItem.id, "pid": selectedItem.pid, "typeName": selectedItem.typeName }).then(function(response) {
  1366. var myData = Restangular.stripRestangular(response);
  1367. var data = myData.data;
  1368. if (myData.status == 201) {
  1369. $scope.try_async_load();
  1370. SweetAlert.swal({
  1371. title: "操作成功",
  1372. text: "操作成功!",
  1373. type: "success"
  1374. });
  1375. }
  1376. })
  1377. }
  1378. }
  1379. });
  1380. }
  1381. // var filterData = {
  1382. // key: 'null',
  1383. // status: 0,
  1384. // pageIndex: 0,
  1385. // pageSum: mun,
  1386. // //treeIds:'[]',
  1387. // userId: loginUser.id
  1388. // }
  1389. // if ($stateParams.fromstate && $stateParams.fromstate != "") {
  1390. // $scope.allfilterData = JSON.parse($stateParams.fromstate);
  1391. // } else {
  1392. // $scope.allfilterData = {
  1393. // key: 'null',
  1394. // status: 0,
  1395. // pageIndex: 0,
  1396. // pageSum: mun,
  1397. // userId: loginUser.id
  1398. // }
  1399. // }
  1400. $scope.allfilterData = {
  1401. key: 'null',
  1402. status: 0,
  1403. pageIndex: 0,
  1404. pageSum: mun,
  1405. userId: loginUser.id
  1406. }
  1407. $scope.statuses = [
  1408. { status: 1, label: '待审核' },
  1409. { status: 2, label: '已发布' },
  1410. { status: 3, label: '已驳回' },
  1411. { status: 4, label: '已停用' },
  1412. { status: 5, label: '已驳回' },
  1413. { status: 6, label: '已拒绝' }
  1414. ];
  1415. // $scope.$watch('searchSolutionInput', function(oldvalue, newvalue) {
  1416. // // console.log(' oldvalue='+JSON.stringify( oldvalue));
  1417. // // console.log(' newvalue='+JSON.stringify( newvalue));
  1418. // // if(oldvalue==newvalue) return;
  1419. // if (angular.isUndefined(oldvalue) || oldvalue == '') {
  1420. // filterData.key = 'null';
  1421. // } else {
  1422. // filterData.key = oldvalue;
  1423. // }
  1424. // });
  1425. $scope.filterSolutionStatus = function(filterStatus) {
  1426. // filterData = $scope.allfilterData;
  1427. $scope.searchstate = filterStatus;
  1428. // filterData.status = filterStatus;
  1429. // var fildata = {};
  1430. // if (sessionStorage.searchKnowledge) {
  1431. // filterData = JSON.parse(sessionStorage.getItem("searchKnowledge"));
  1432. // $scope.gridOptions.paginationCurrentPage = 1;
  1433. // filterData.pageIndex = 0;
  1434. // } else {
  1435. // filterData = defaultFilterData;
  1436. // }
  1437. // var tempData = angular.copy(filterData);
  1438. // tempData.status = filterStatus;
  1439. // $scope.allfilterData = tempData;
  1440. // $stateParams.fromstate = JSON.stringify($scope.allfilterData);
  1441. // sessionStorage['searchknowledge'] = JSON.stringify(tempData);
  1442. $scope.jry_todata.solution.status.id=filterStatus;
  1443. $scope.refreshListData('expand-right', $scope.jry_todata);
  1444. }
  1445. $scope.myKeyup = function(e) {
  1446. var keyCode = window.event ? e.keyCode : e.which;
  1447. if (keyCode == 13) {
  1448. $scope.searchSolution();
  1449. }
  1450. };
  1451. // $scope.searchstate = 0;
  1452. $scope.searchSolution = function() {
  1453. console.log($scope.jry_knowipt);
  1454. $scope.jry_todata.solution.keywords=$scope.jry_knowipt;
  1455. $scope.jry_todata.solution.solutionType.id=$scope.solutionTypeId;
  1456. // if (sessionStorage['searchKnowledge']) {
  1457. // filterData = JSON.parse(sessionStorage.getItem("searchKnowledge"));
  1458. // }
  1459. // if (item.type) {
  1460. // // filterData['treeIds'] = "";
  1461. // filterData['treeIds'] = item.type.id;
  1462. // } else {
  1463. // delete filterData.treeIds;
  1464. // }
  1465. // if (item.searchSolutionInput) {
  1466. // // angular.extend(filterData['key'], item.searchSolutionInput)
  1467. // filterData['key'] = item.searchSolutionInput;
  1468. // } else {
  1469. // filterData['key'] = null;
  1470. // }
  1471. // sessionStorage['searchKnowledgetype'] = JSON.stringify(item);
  1472. $scope.refreshListData('expand-right', $scope.jry_todata);
  1473. }
  1474. // window.onbeforeunload = function(event) {
  1475. // $state.go('app.knowledge.manager', {})
  1476. // alert("文本")
  1477. // // $scope.refreshListData('expand-right', filterData);
  1478. // }
  1479. $scope.reload = function(item) {
  1480. // var reshfildata = {};
  1481. // if (item) { reshfildata = JSON.parse(item) }
  1482. if (sessionStorage['searchKnowledge']) {
  1483. $scope.allfilterData = JSON.parse(sessionStorage.getItem("searchKnowledge"));
  1484. // if (JSON.parse(sessionStorage.getItem("searchKnowledge")).treeIds) {
  1485. // $scope.knowledge = {
  1486. // "type": JSON.parse(sessionStorage.getItem("searchKnowledge")).treeIds
  1487. // };
  1488. // }
  1489. // if () {
  1490. // }
  1491. // $scope.knowledge = angular.extend($scope.knowledge, { 'type': JSON.parse(sessionStorage.getItem("searchKnowledge")).treeIds });
  1492. if (JSON.parse(sessionStorage.getItem("searchKnowledge")).key) {
  1493. $scope.knowledge = angular.extend($scope.knowledge, { 'searchSolutionInput': JSON.parse(sessionStorage.getItem("searchKnowledge")).key });
  1494. }
  1495. }
  1496. $scope.refreshListData('expand-right',$scope.jry_todata);
  1497. }
  1498. $scope.reloaddata = function() {
  1499. sessionStorage['searchKnowledgetype'] = JSON.stringify({});
  1500. // $scope.jry_todata={
  1501. // "idx":$scope.fenye,
  1502. // "sum":10,
  1503. // "solution":{
  1504. // "keywords":"",
  1505. // "solutionType":{"id":''},
  1506. // "status":{"id":""}
  1507. // }
  1508. // }
  1509. $scope.jry_todata.solution.solutionType.id="";
  1510. $scope.jry_todata.solution.keywords="";
  1511. $scope.jry_knowipt="";
  1512. $scope.knowledge = {};
  1513. $scope.try_async_load();
  1514. $scope.allfilterData.treeIds = 0;
  1515. $scope.reload(JSON.stringify(fildate));
  1516. }
  1517. // $scope.refreshListData('expand-right', $scope.allfilterData);
  1518. $scope.reload()
  1519. //树形图
  1520. var apple_selected, tree, treedata_avm, treedata_geography;
  1521. $scope.my_tree_handler = function(branch) {
  1522. //var _ref;
  1523. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  1524. api_cmdb.query({ 'sign': classify }).then(function(data) {
  1525. var myData = Restangular.stripRestangular(data);
  1526. // console.log(myData.data.node);
  1527. if (myData.data && myData.status == 200) {
  1528. var ret = myData.data;
  1529. redrawSvg(myData);
  1530. }
  1531. });
  1532. };
  1533. $scope.my_data = [];
  1534. function convertListToTree(data, treeMap) {
  1535. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  1536. var root = null; //Initially set our loop to null
  1537. var parentNode = null;
  1538. //loop over data
  1539. for (var i = 0; i < data.length; i++) {
  1540. var datum = data[i];
  1541. //each node will have children, so let's give it a "children" poperty
  1542. datum.children = [];
  1543. //add an entry for this node to the map so that any future children can
  1544. //lookup the parent
  1545. idToNodeMap[datum.id] = datum;
  1546. //Does this node have a parent?
  1547. if (typeof datum.parent === "undefined" || datum.parent == null) {
  1548. //Doesn't look like it, so this node is the root of the tree
  1549. root = datum;
  1550. treeMap[datum.id] = root;
  1551. } else {
  1552. //This node has a parent, so let's look it up using the id
  1553. parentNode = idToNodeMap[datum.parent.id];
  1554. //We don't need this property, so let's delete it.
  1555. delete datum.parent;
  1556. //Let's add the current node as a child of the parent node.
  1557. parentNode.children.push(datum);
  1558. }
  1559. }
  1560. return root;
  1561. }
  1562. function convertParentToChildList(data) {
  1563. var treeMap = {};
  1564. var list = [];
  1565. convertListToTree(data, treeMap);
  1566. angular.forEach(treeMap, function(item) {
  1567. list.push(item);
  1568. });
  1569. return list;
  1570. }
  1571. $scope.my_tree = tree = {};
  1572. $scope.try_async_load = function() {
  1573. $scope.my_data = [];
  1574. $scope.select_treedata = [];
  1575. $scope.doing_async = true;
  1576. api_zsk.jry_get_list({"idx":0,"sum":1000},"solutionType").then(function(result) {
  1577. //console.log(result['list']);
  1578. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  1579. $scope.doing_async = false;
  1580. // tree.expand_all();
  1581. //console.log(treelist);
  1582. });
  1583. };
  1584. $scope.select_treedata = [];
  1585. $scope.propTypeOptions = [];
  1586. $scope.try_async_load();
  1587. $scope.onFilterremove = function(item) {
  1588. console.log(item)
  1589. }
  1590. // 资产分类
  1591. $scope.onFilterCallback = function(item) {
  1592. console.log($scope.cifilter_classic);
  1593. console.log(item.id);
  1594. // $scope.jry_todata.solution.solutionType.id=item.id;
  1595. $scope.solutionTypeId=item.id;
  1596. // if (angular.isDefined(item.children) && item.children.length >= 1) {
  1597. // //not valid
  1598. // } else {
  1599. // var tempclassify = item.prefix.toLowerCase() + item.sign;
  1600. // $scope.gridApi.grid.options.paginationCurrentPage = 1;
  1601. // $scope.cifilter_classic = tempclassify;
  1602. // var memoryfilterData = {
  1603. // "sign": tempclassify,
  1604. // "idx": 0,
  1605. // "sum": $scope.gridOptions.paginationPageSize
  1606. // }
  1607. // angular.extend($scope.memoryfilterData, memoryfilterData)
  1608. // // $scope.memoryfilterData=memoryfilterData;
  1609. // $scope.refreshData('expand-right', $scope.memoryfilterData);
  1610. // // 专有属性
  1611. // api_configure_form.renderTabForm(tempclassify).then(function(data){
  1612. // var myData = Restangular.stripRestangular(data);
  1613. // $scope.propTypeOptions = myData[2].form.fields;
  1614. // // console.log($scope.propTypeOptions)
  1615. // });
  1616. // }
  1617. }
  1618. }]);
  1619. 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) {
  1620. var loginUser = $rootScope.user;
  1621. $scope.clses = [{
  1622. id: 6,
  1623. cls: 'danger'
  1624. }, {
  1625. id: 2,
  1626. cls: 'warning'
  1627. }, {
  1628. id: 3,
  1629. cls: 'success'
  1630. },
  1631. {
  1632. id: 4,
  1633. cls: 'primary'
  1634. }, {
  1635. id: 5,
  1636. cls: 'info'
  1637. }, {
  1638. id: 1,
  1639. cls: 'danger'
  1640. }
  1641. ];
  1642. $scope.showlist = true;
  1643. $scope.myKeyup = function(e, searchInput) {
  1644. var keyCode = window.event ? e.keyCode : e.which;
  1645. if (keyCode == 13) {
  1646. $scope.searchSolution(searchInput);
  1647. }
  1648. };
  1649. $scope.searchSolution = function(searchKey, page) {
  1650. console.log(page)
  1651. if (searchKey == "") {
  1652. if (angular.isDefined(page)) {
  1653. if (page == 0) {
  1654. page = 1;
  1655. } else if (page == $scope.pages + 1) {
  1656. page = $scope.pages;
  1657. }
  1658. } else {
  1659. tempPage = page = 0;
  1660. $scope.solutionBBS = [];
  1661. }
  1662. // api_solution.queryBBSSolutions(tempPage, 7, 'createtime', loginUser.id, searchKey).then(function(response) {
  1663. api_solution.fetchDataList("solution", { 'idx': 0, 'sum': 7, 'solution': { 'searchType': 2, 'keywords': searchKey, createUserId: loginUser.id } }).then(function(response) {
  1664. // api_solution.fetchDataList("solution", { 'idx': 0, 'sum': 7, 'solution': { 'searchType': 2, 'keywords': searchKey, createUser: {id:loginUser.id} } }).then(function(response) {
  1665. var myData = Restangular.stripRestangular(response);
  1666. var status = myData.status;
  1667. if (status == "500") {
  1668. $scope.solutionBBS = [];
  1669. } else if (status == "200" && myData.list) {
  1670. sereshdata(response, searchKey);
  1671. }
  1672. });
  1673. } else if (searchKey != "" && searchKey.length > 1) {
  1674. // if (angular.isDefined(page)) {
  1675. // if (page == 0) {
  1676. // page = 1;
  1677. // } else if (page == $scope.pages + 1) {
  1678. // page = $scope.pages;
  1679. // }
  1680. // tempPage = page - 1;
  1681. // } else {
  1682. // tempPage = page = 0;
  1683. // $scope.solutionBBS = [];
  1684. // }
  1685. // if(page==0){
  1686. // page=1;
  1687. // }else if(page==$scope.pages+1){
  1688. // page=$scope.pages;
  1689. // }
  1690. api_solution.fetchDataList("solution", { 'idx': 0, 'sum': 7, 'solution': { 'searchType': 2, 'keywords': searchKey, createUserId: loginUser.id } }).then(function(response) {
  1691. // api_solution.fetchDataList("solution", { 'idx': 0, 'sum': 7, 'solution': { 'searchType': 2, 'keywords': searchKey, createUser: {id:loginUser.id} } }).then(function(response) {
  1692. var myData = Restangular.stripRestangular(response);
  1693. $scope.solutionBBS = [];
  1694. $scope.currentPage = 1;
  1695. $scope.pages = 0;
  1696. $scope.num = response.totalNum;
  1697. sereshdata(response, searchKey);
  1698. // var status = myData.status;
  1699. // if (status == "500") {
  1700. // $scope.solutionBBS = [];
  1701. // } else if (status == "200" && myData.list) {
  1702. // var data = myData.list;
  1703. // var count = myData.totalNum;
  1704. // $scope.pages = parseInt(count / 7) + 1;
  1705. // if (page == 0) {
  1706. // $scope.currentPage = page + 1;
  1707. // } else {
  1708. // $scope.currentPage = page;
  1709. // }
  1710. // if (data.length > 0) {
  1711. // $scope.solutionBBS = [];
  1712. // for (var i = 0; i < data.length; i++) {
  1713. // data[i].creationTime = getLocalTime(data[i].createtime);
  1714. // data[i].releasetime = getLocalTime(data[i].releasetime);
  1715. // if (data[i].solutionReviewDTO.reviewTime == null) {
  1716. // data[i].solutionReviewDTO.reviewTime = "暂无回复";
  1717. // } else {
  1718. // data[i].solutionReviewDTO.reviewTime = getLocalTime(data[i].solutionReviewDTO.reviewTime);
  1719. // }
  1720. // if (data[i].solutionReviewDTO.userName == null) {
  1721. // data[i].solutionReviewDTO.userName = "暂无回复人";
  1722. // }
  1723. // // if (i == 0) {
  1724. // // data[i].index = 1;
  1725. // // } else if (i == 1) {
  1726. // // data[i].index = 2;
  1727. // // } else if (i == 2) {
  1728. // // data[i].index = 3;
  1729. // // } else {
  1730. // // data[i].index = 4;
  1731. // // }
  1732. // $scope.solutionBBS.push(data[i]);
  1733. // // reshdata($scope.solutionBBS);
  1734. // }
  1735. // }
  1736. // }
  1737. });
  1738. }
  1739. }
  1740. // $scope.$watch('searchInput',function(newvalue, oldvalue){
  1741. // if(newvalue == oldvalue) return;
  1742. // $scope.searchSolution(newvalue);
  1743. // });
  1744. //BBS列表切换
  1745. $scope.changeShowList = function(val) {
  1746. $scope.showlist = !$scope.showlist;
  1747. }
  1748. $scope.solutionBBS = [];
  1749. $scope.hotRankings = [];
  1750. $scope.scoreRankings = [];
  1751. $scope.solutionScores = [];
  1752. $scope.currentPage = 1;
  1753. $scope.pages = 0;
  1754. $scope.num = 0;
  1755. function sereshdata(item, key) {
  1756. $scope.tableParams = new ngTableParams({
  1757. page: 1, // show first page
  1758. count: 7, // count per page
  1759. data: item.list
  1760. }, {
  1761. total: item.totalNum, // length of data
  1762. getData: function($defer, params) {
  1763. api_solution.fetchDataList("solution", { 'idx': params.page() - 1, 'sum': 7, 'solution': { 'searchType': 2, 'keywords': key, createUserId: loginUser.id } }).then(function(response) {
  1764. // api_solution.fetchDataList("solution", { 'idx': params.page() - 1, 'sum': 7, 'solution': { 'searchType': 2, 'keywords': key, createUser: {id:loginUser.id} } }).then(function(response) {
  1765. var data = response.list;
  1766. for (var i = 0; i < data.length; i++) {
  1767. data[i].creationTime = getLocalTime(data[i].createtime);
  1768. data[i].releasetime = getLocalTime(data[i].releasetime);
  1769. if (data[i].solutionReviewDTO.reviewTime == null) {
  1770. data[i].solutionReviewDTO.reviewTime = "暂无回复";
  1771. } else {
  1772. data[i].solutionReviewDTO.reviewTime = getLocalTime(data[i].solutionReviewDTO.reviewTime);
  1773. }
  1774. if (data[i].solutionReviewDTO.userName == null) {
  1775. data[i].solutionReviewDTO.userName = "暂无回复人";
  1776. }
  1777. $scope.solutionBBS.push(data[i]);
  1778. }
  1779. $defer.resolve(data.slice((0) * params.count(), params.page() * params.count()));
  1780. })
  1781. }
  1782. });
  1783. }
  1784. // function reshdata(item, key) {
  1785. // $scope.tableParams = new ngTableParams({
  1786. // page: 1, // show first page
  1787. // count: 3 // count per page
  1788. // }, {
  1789. // total: item.totalNum, // length of data
  1790. // getData: function($defer, params) {
  1791. // // api_solution.fetchBBSSolutions(params.page() - 1, 7, "createtime", loginUser.id).then(function(response) {
  1792. // var orderedData = params.sorting() ? $filter('orderBy')(item.list, params.orderBy()) : item.list;
  1793. // $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1794. // }
  1795. // });
  1796. // }
  1797. // api_solution.fetchBBSSolutions(0, 7, "createtime", loginUser.id).then(function(response) {
  1798. api_solution.fetchDataList("solution", { 'idx': 0, 'sum': 7, 'solution': { 'searchType': 2, createUserId: loginUser.id } }).then(function(response) {
  1799. // api_solution.fetchDataList("solution", { 'idx': 0, 'sum': 7, 'solution': { 'searchType': 2, createUser: {id:loginUser.id} } }).then(function(response) {
  1800. if (response.status == 200) {
  1801. $scope.solutionBBS = [];
  1802. var data = response.list;
  1803. $scope.num = response.totalNum;
  1804. // for (var i = 0; i < data.length; i++) {
  1805. // data[i].creationTime = getLocalTime(data[i].createtime);
  1806. // data[i].releasetime = getLocalTime(data[i].releasetime);
  1807. // if (data[i].solutionReviewDTO.reviewTime == null) {
  1808. // data[i].solutionReviewDTO.reviewTime = "暂无回复";
  1809. // } else {
  1810. // data[i].solutionReviewDTO.reviewTime = getLocalTime(data[i].solutionReviewDTO.reviewTime);
  1811. // }
  1812. // if (data[i].solutionReviewDTO.userName == null) {
  1813. // data[i].solutionReviewDTO.userName = "暂无回复人";
  1814. // }
  1815. // $scope.solutionBBS.push(data[i]);
  1816. // }
  1817. sereshdata(response);
  1818. // $scope.tableParams = new ngTableParams({
  1819. // page: 1, // show first page
  1820. // count: 7 // count per page
  1821. // }, {
  1822. // total: response.totalNum, // length of data
  1823. // getData: function($defer, params) {
  1824. // api_solution.fetchBBSSolutions(params.page() - 1, 7, "createtime", loginUser.id).then(function(data) {
  1825. // var myData = data.list;
  1826. // $defer.resolve(myData.slice((0) * params.count(), params.page() * params.count()));
  1827. // })
  1828. // }
  1829. // });
  1830. }
  1831. })
  1832. api_solution.fetchBBSSolutions(0, 5, "scores", loginUser.id).then(function(response) {
  1833. $scope.solutionBBS1 = [];
  1834. var myData = Restangular.stripRestangular(response);
  1835. var data = myData.list;
  1836. for (var i = 0; i < data.length; i++) {
  1837. data[i].creationTime = getLocalTime(data[i].creationTime);
  1838. data[i].lastReplyTime = getLocalTime(data[i].lastReplyTime);
  1839. if (i == 0) {
  1840. data[i].index = 1;
  1841. } else if (i == 1) {
  1842. data[i].index = 2;
  1843. } else if (i == 2) {
  1844. data[i].index = 3;
  1845. } else {
  1846. data[i].index = 4;
  1847. }
  1848. $scope.solutionScores.push(data[i]);
  1849. }
  1850. });
  1851. $scope.todayHits = 0;
  1852. $scope.lastHits = 0;
  1853. api_solution.fetchDataList('solutionDayBrowser', { 'idx': 0, 'sum': 10 }).then(function(response) {
  1854. if (response.status == 200 && response.list) {
  1855. if (response.list[0].todayBrowser) {
  1856. $scope.todayHits = response.list[0].todayBrowser;
  1857. }
  1858. if (response.list[0].beforeDayBrowser) {
  1859. $scope.lastHits = response.list[0].beforeDayBrowser;
  1860. }
  1861. }
  1862. })
  1863. api_solution.hotRanking(1).then(function(response) {
  1864. var myData = Restangular.stripRestangular(response);
  1865. var data = myData.list;
  1866. console.log(data);
  1867. $scope.hotRankings = [];
  1868. $scope.hotArray = [];
  1869. for (var i = 0; i < data.length; i++) {
  1870. data[i].approvetime = getLocalTime(data[i].solutionDTO.approvetime);
  1871. if (i == 0) {
  1872. data[i].index = 1;
  1873. } else if (i == 1) {
  1874. data[i].index = 2;
  1875. } else if (i == 2) {
  1876. data[i].index = 3;
  1877. } else {
  1878. data[i].index = 4;
  1879. }
  1880. $scope.hotRankings.push(data[i]);
  1881. $scope.hotArray.push(data[i].totalBrowse);
  1882. }
  1883. if ($scope.hotArray.length > 0) {
  1884. $scope.tophot = $scope.hotArray.join(',');
  1885. }
  1886. //$scope
  1887. //$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];
  1888. //热点排行榜
  1889. // $("#stats-sparklines-2").pixelSparkline($scope.hotArray, {
  1890. // type: 'bar',
  1891. // height: '36px',
  1892. // width: '100%',
  1893. // barSpacing: 2,
  1894. // zeroAxis: false,
  1895. // barColor: '#ffffff'
  1896. // });
  1897. });
  1898. api_solution.hotRanking(2).then(function(response) {
  1899. var myData = Restangular.stripRestangular(response);
  1900. var data = myData.list;
  1901. $scope.scoreRankings = [];
  1902. $scope.scoreArray = [];
  1903. for (var i = 0; i < data.length; i++) {
  1904. data[i].approvetime = getLocalTime(data[i].solutionDTO.approvetime);
  1905. if (i == 0) {
  1906. data[i].index = 1;
  1907. } else if (i == 1) {
  1908. data[i].index = 2;
  1909. } else if (i == 2) {
  1910. data[i].index = 3;
  1911. } else {
  1912. data[i].index = 4;
  1913. }
  1914. $scope.scoreRankings.push(data[i]);
  1915. $scope.scoreArray.push(data[i].totalScore);
  1916. }
  1917. if ($scope.scoreArray.length > 0) {
  1918. $scope.topscore = $scope.scoreArray.join(',');
  1919. }
  1920. //$scope.scoreArray=[275,490,397,487,339,403,402,312,300];
  1921. //评分排行榜
  1922. // $("#stats-sparklines-3").pixelSparkline($scope.scoreArray, {
  1923. // type: 'line',
  1924. // width: '100%',
  1925. // height: '45px',
  1926. // fillColor: '',
  1927. // lineColor: '#fff',
  1928. // lineWidth: 2,
  1929. // spotColor: '#ffffff',
  1930. // minSpotColor: '#ffffff',
  1931. // maxSpotColor: '#ffffff',
  1932. // highlightSpotColor: '#ffffff',
  1933. // highlightLineColor: '#ffffff',
  1934. // spotRadius: 4,
  1935. // highlightLineColor: '#ffffff'
  1936. // });
  1937. });
  1938. var getLocalTime = function(time) {
  1939. return moment(time).format('YYYY-MM-DD HH:mm:ss');
  1940. // console("time="+time)
  1941. }
  1942. $scope.commentshowSolution = function(solution) {
  1943. var modalInstance = $modal.open({
  1944. templateUrl: 'assets/views/knowledge/tpl/commentknowledge.html',
  1945. controller: function($scope, $http, $modalInstance, APIService, uploader, currentUser, Alert, MomentFormat, loginUser) {
  1946. $scope.isManage = false;
  1947. angular.forEach(loginUser.role, function(item) {
  1948. if (item.rolecode == "solution") {
  1949. $scope.isManage = true;
  1950. }
  1951. })
  1952. $scope.examineKnowledge = function(item) {
  1953. APIService.updModel("solutionReview", { "solutionReview": { "status": 2, "id": item.id } }).then(function(response) {
  1954. if (response && response.status == "200") {
  1955. SweetAlert.swal({
  1956. title: "审核通过!",
  1957. text: "知识库评论审核成功!",
  1958. type: "success"
  1959. }, function() {
  1960. loadData();
  1961. });
  1962. } else {
  1963. SweetAlert.swal({
  1964. title: "审核失败",
  1965. text: "知识库评论审核失败!",
  1966. type: "error"
  1967. });
  1968. }
  1969. })
  1970. }
  1971. $scope.reviewKnowledge = function(item) {
  1972. APIService.updModel("updSolutionReviewByIds", { "type": 2, "status": 2, "ids": solution.id }).then(function(response) {
  1973. if (response && response.status == "200") {
  1974. SweetAlert.swal({
  1975. title: "审核通过!",
  1976. text: "知识库评论审核成功!",
  1977. type: "success"
  1978. }, function() {
  1979. loadData();
  1980. });
  1981. } else {
  1982. SweetAlert.swal({
  1983. title: "审核失败",
  1984. text: "知识库评论审核失败!",
  1985. type: "error"
  1986. });
  1987. }
  1988. })
  1989. }
  1990. $scope.removeKnowledge = function(item) {
  1991. APIService.updModel("solutionReview", { "solutionReview": { "status": 3, "id": item.id } }).then(function(response) {
  1992. if (response && response.status == "200") {
  1993. SweetAlert.swal({
  1994. title: "删除成功!",
  1995. text: "知识库评论删除成功!",
  1996. type: "success"
  1997. }, function() {
  1998. loadData();
  1999. });
  2000. } else {
  2001. SweetAlert.swal({
  2002. title: "删除失败",
  2003. text: "知识库评论删除失败!",
  2004. type: "error"
  2005. });
  2006. }
  2007. })
  2008. }
  2009. var loadData = function() {
  2010. $scope.visions = [];
  2011. $scope.entity = {};
  2012. $scope.showCommentScore = true;
  2013. $scope.comments = [];
  2014. // APIService.findSolutionReviewById(loginUser.id, solution.id, 0, 1000).then(function(response) {
  2015. APIService.fetchDataList('solutionReview', { 'idx': 0, 'sum': 1000, 'solutionReview': { 'solutionId': solution.id, 'userId': loginUser.id } }).then(function(response) {
  2016. if (response.status != "500") {
  2017. var data = response.list;
  2018. if (angular.isDefined(response.result)) { $scope.showCommentScore = false; }
  2019. for (var i = 0; i < data.length; i++) {
  2020. var object = {};
  2021. object.id = data[i].id;
  2022. object.name = data[i].userName;
  2023. object.status = data[i].status;
  2024. if (data[i].reviewScore > 0) {
  2025. object.score = data[i].reviewScore;
  2026. }
  2027. // object.content=data[i].review;
  2028. var ss = data[i].review;
  2029. var s1 = "";
  2030. if (ss != null) {
  2031. var index = ss.indexOf("<p>");
  2032. var indexs = ss.indexOf("</p>");
  2033. s1 = ss.substring(index + 3, indexs);
  2034. }
  2035. object.content = s1;
  2036. // object.score=data[i].reviewScore;
  2037. object.time = moment(data[i].reviewTime).format('YYYY-MM-DD HH:mm:ss');
  2038. // console.log('object.time='+JSON.stringify(object));
  2039. $scope.comments.push(object);
  2040. }
  2041. }
  2042. });
  2043. APIService.findSolutionById(solution.id).then(function(response) {
  2044. var datas = response.data;
  2045. $scope.entity = {
  2046. "id": datas.id,
  2047. "title": datas.title,
  2048. "keys": datas.keywords,
  2049. "type": datas.typeId,
  2050. "range": datas.solutionRange,
  2051. "number": datas.solutionNumber,
  2052. "content": datas.content,
  2053. "createrUserId": datas.createUserId,
  2054. "createTime": datas.createtime,
  2055. "status": datas.status,
  2056. "hits": datas.hits,
  2057. "relateId": datas.relateId,
  2058. "vision": datas.vision,
  2059. "vision2": "V" + datas.vision,
  2060. // "fileContent":datas.fileContent,
  2061. "replies": datas.replies,
  2062. "scores": datas.scores,
  2063. "hits": datas.hits,
  2064. "fileName": datas.fileName,
  2065. "typeName": datas.typeDTO.typeName
  2066. };
  2067. console.log(datas)
  2068. console.log($scope.entity);
  2069. });
  2070. }
  2071. loadData();
  2072. $scope.options = {
  2073. language: 'zh-cn',
  2074. allowedContent: true,
  2075. entities: false
  2076. };
  2077. $scope.uploader = uploader;
  2078. $scope.getdown = function(filename) {
  2079. $http({
  2080. url: APIService.getSolutionDowpath(solution.id).getRequestedUrl(),
  2081. method: 'GET',
  2082. headers: {
  2083. //'Content-type' : 'application/xls',
  2084. 'Accept': '*/*'
  2085. },
  2086. responseType: 'arraybuffer'
  2087. }).success(function(data, status, headers, config) {
  2088. var file = new Blob([data], {
  2089. type: 'application/octet-stream'
  2090. });
  2091. //trick to download store a file having its URL
  2092. var fileURL = URL.createObjectURL(file);
  2093. var a = document.createElement('a');
  2094. a.href = fileURL;
  2095. a.target = '_blank';
  2096. a.download = filename;
  2097. document.body.appendChild(a);
  2098. a.click();
  2099. }).error(function(data, status, headers, config) {
  2100. console.log(data);
  2101. });
  2102. }
  2103. $scope.ranges = [{
  2104. "id": 1,
  2105. "name": "全局"
  2106. }, {
  2107. "id": 3,
  2108. "name": "组"
  2109. }];
  2110. // $scope.ok = function() {
  2111. // $modalInstance.close($scope.entity);
  2112. // };
  2113. $scope.cancel = function() {
  2114. // api_solution.findSolutions($scope.entity.id).then(function(response){
  2115. // var data6=response.data[0];
  2116. // for(var j=0;j<=$scope.solutionBBS.length;j++){
  2117. // if($scope.solutionBBS.length>0&&$scope.solutionBBS[j].id==$scope.entity.id){
  2118. // $scope.solutionBBS[j].replies=data6.replies;
  2119. // $scope.solutionBBS[j].hits=data6.hits;
  2120. // $scope.solutionBBS[j].scores=data6.scores;
  2121. // break;
  2122. // }
  2123. // }
  2124. // });
  2125. $modalInstance.close($scope.entity.id);
  2126. };
  2127. $scope.saveComment = function(reviewcontent, score) {
  2128. $scope.entity['reviewcontent'] = reviewcontent;
  2129. $scope.entity['score'] = score;
  2130. $modalInstance.close($scope.entity);
  2131. }
  2132. },
  2133. size: 'lg',
  2134. resolve: {
  2135. APIService: function() {
  2136. return api_solution;
  2137. },
  2138. uploader: function() {
  2139. return $scope.uploader;
  2140. },
  2141. currentUser: function() {
  2142. return loginUser.id;
  2143. },
  2144. Alert: function() {
  2145. return SweetAlert;
  2146. },
  2147. MomentFormat: function() {
  2148. return moment;
  2149. },
  2150. loginUser: function() {
  2151. return loginUser;
  2152. }
  2153. }
  2154. });
  2155. modalInstance.result.then(function(selectedItem) {
  2156. if (selectedItem.title) {
  2157. var solutionId = selectedItem.id;
  2158. var reviewContent = selectedItem.reviewcontent;
  2159. // if(solutionId==null){
  2160. var reviewScore;
  2161. if (selectedItem.score) { reviewScore = selectedItem.score.toFixed(1) }
  2162. var data = {
  2163. id: null,
  2164. solutionId: solutionId,
  2165. userId: loginUser.id,
  2166. review: reviewContent,
  2167. reviewScore: reviewScore,
  2168. reviewTime: new Date()
  2169. };
  2170. api_solution.addSolutionReview(data).then(function(response) {
  2171. var status = response.status;
  2172. console.log(response)
  2173. console.log('$scope.apClient=' + JSON.stringify(status));
  2174. if (status == "200") {
  2175. SweetAlert.swal({
  2176. title: "评论知识库!",
  2177. text: "评论知识库成功!",
  2178. type: "success"
  2179. }, function() {
  2180. api_solution.findSolutions(selectedItem.id).then(function(response) {
  2181. var data6 = response.data[0];
  2182. for (var j = 0; j <= $scope.solutionBBS.length; j++) {
  2183. if ($scope.solutionBBS.length > 0 && $scope.solutionBBS[j].id == selectedItem.id) {
  2184. $scope.solutionBBS[j].replies = data6.replies;
  2185. $scope.solutionBBS[j].hits = data6.hits;
  2186. $scope.solutionBBS[j].scores = data6.scores;
  2187. break;
  2188. }
  2189. }
  2190. });
  2191. });
  2192. } else {
  2193. SweetAlert.swal({
  2194. title: "评论知识库!",
  2195. text: "评论知识库失败!",
  2196. type: "error"
  2197. });
  2198. }
  2199. });
  2200. }
  2201. });
  2202. }
  2203. //TODO
  2204. $('#attach-check').on('change', function() {
  2205. $('#attach').toggleClass('hidden');
  2206. });
  2207. $('#attachcheck1').on('change', function() {
  2208. $('#attachdiv1').toggleClass('hidden');
  2209. });
  2210. $('#attachcheck2').on('change', function() {
  2211. $('#attachdiv2').toggleClass('hidden');
  2212. });
  2213. }]);
  2214. app.filter('index', function() {
  2215. return function(array) {
  2216. return (array || []).map(function(item, index) {
  2217. item.order = index + 1;
  2218. return item;
  2219. });
  2220. };
  2221. });
  2222. app.controller('GridOperatorCtrl', ["$rootScope",'$http', '$scope', function($rootScope,$http, $scope, $event) {
  2223. // if ($scope.item.actions != "" && $scope.item.actions != null) { //1:查看,2:操作(改);3:审核;4.过期;发布更新
  2224. // if ($scope.item.actions.indexOf("1") >= 0) { //查看权限
  2225. // $scope.item.detailPower = true;
  2226. // } else {
  2227. // $scope.item.detailPower = false;
  2228. // }
  2229. // if ($scope.item.status == 4) {
  2230. // $scope.item.commentPower = true;
  2231. // } else {
  2232. // $scope.item.commentPower = false;
  2233. // }
  2234. // if ($scope.item.actions.indexOf("2") >= 0) { //操作(改)
  2235. // if ($scope.item.status == 1 || $scope.item.status == 5 || $scope.item.status == 3 || $scope.item.status == 4) {
  2236. // $scope.item.updatePower = true;
  2237. // }
  2238. // } else {
  2239. // $scope.item.updatePower = false;
  2240. // }
  2241. // if ($scope.item.actions.indexOf("3") >= 0) { //审核
  2242. // if ($scope.item.status == 1) {
  2243. // $scope.item.reviewPower = true;
  2244. // }
  2245. // } else {
  2246. // $scope.item.reviewPower = false;
  2247. // }
  2248. // if ($scope.item.actions.indexOf("4") >= 0) { //过期与发布
  2249. // if ($scope.item.status == 2) {
  2250. // $scope.item.updatePower = true;
  2251. // $scope.item.outTimePower = true;
  2252. // }
  2253. // if ($scope.item.status == 3) { //已发布的才能评论
  2254. // $scope.item.publishnotPower = true;
  2255. // } else {
  2256. // $scope.item.publishnotPower = false;
  2257. // }
  2258. // } else {
  2259. // $scope.item.outTimePower = false;
  2260. // }
  2261. // }
  2262. // if ($scope.item.status == 3) { //已发布的才能评论
  2263. // // $scope.item.publishnotPower = true;
  2264. // $scope.item.commontPower = true;
  2265. // } else {
  2266. // $scope.item.commontPower = false;
  2267. // // $scope.item.publishnotPower = false;
  2268. // }
  2269. // // console.log($scope.item.status + " " + $scope.item.commontPower);
  2270. $scope.edit = function() {
  2271. $scope.colobject.grid.appScope.editSolution($scope.item);
  2272. // console.log($scope.colobject);
  2273. //$scope.doEdit($scope.item.id);
  2274. }
  2275. $scope.leve=function(){
  2276. $scope.colobject.grid.appScope.leve($scope.item);
  2277. }
  2278. // $scope.comment = function() {
  2279. // $scope.colobject.grid.appScope.commentSolution($scope.item.id);
  2280. // //$scope.doComment($scope.item.id);
  2281. // }
  2282. $scope.approval = function() {
  2283. $scope.colobject.grid.appScope.jry_shenhe($scope.item);
  2284. //$scope.doApproval($scope.item.id,$scope.item.outTimePower);
  2285. }
  2286. $scope.publish = function() {
  2287. $scope.colobject.grid.appScope.jry_lishi($scope.item);
  2288. //$scope.doApproval($scope.item.id,$scope.item.outTimePower);
  2289. }
  2290. $scope.publishnot = function() {
  2291. $scope.colobject.grid.appScope.jry_close($scope.item);
  2292. //$scope.doApproval($scope.item.id,$scope.item.outTimePower);
  2293. }
  2294. // $scope.detail = function() {
  2295. // $scope.colobject.grid.appScope.detailSolution($scope.item.id);
  2296. // // console.log($scope.colobject);
  2297. // }
  2298. var jry_loginUser=$rootScope.user;
  2299. $scope.ZZKGLY=false;
  2300. for(var i=0;i<jry_loginUser.role.length;i++){
  2301. // console.log(i);
  2302. if(jry_loginUser.role[i].role=="知识库管理员"&&jry_loginUser.role[i].rolecode=="solution"){
  2303. $scope.ZZKGLY=true;
  2304. }
  2305. }
  2306. //编辑权限判断
  2307. $scope.jry_bj=function(){
  2308. if($scope.item.status.name=="待审核"&&$scope.item.createUser.id==jry_loginUser.id){
  2309. return true
  2310. }else if($scope.item.status.name=="已驳回"&&$scope.item.createUser.id==jry_loginUser.id){
  2311. return true
  2312. }else if($scope.item.status.name=="已驳回"&&$scope.ZZKGLY){
  2313. return true
  2314. }else{
  2315. return false
  2316. }
  2317. }
  2318. // 升级权限判断
  2319. $scope.jry_sj=function(){
  2320. if($scope.item.status.name=="已发布"&&$scope.item.createUser.id==jry_loginUser.id){
  2321. return true
  2322. }else{
  2323. return false
  2324. }
  2325. }
  2326. // 审核权限判断
  2327. $scope.jry_sh=function(){
  2328. if($scope.item.status.name=="待审核"&&$scope.ZZKGLY){
  2329. return true
  2330. }else{
  2331. return false
  2332. }
  2333. }
  2334. // 历史记录权限判断
  2335. $scope.jry_lsjl=function(){
  2336. return true
  2337. }
  2338. // 停用权限判断
  2339. $scope.jry_ty=function(){
  2340. if($scope.item.status.name=="已发布"&&$scope.ZZKGLY){
  2341. return true
  2342. }else{
  2343. return false
  2344. }
  2345. }
  2346. }]);
  2347. app.directive('gridoperator', function() {
  2348. return {
  2349. restrict: 'E',
  2350. scope: {
  2351. item: '=',
  2352. colobject: '='
  2353. // doEdit: '&',
  2354. // doComment: '&',
  2355. // doApproval: '&'
  2356. },
  2357. controller: 'GridOperatorCtrl',
  2358. template: '<div class="links cl-effect-1 ui-grid-cell-contents pull-left">' +
  2359. // // '<a ng-click="edit()" ng-show="{{item.updatePower}}" tooltip="编辑" tooltip-placement="right"><i class="fa fa-pencil-square-o forestgreen"></i></a>' +
  2360. // '<a ng-click="edit()" ng-show="{{item.updatePower}}" class="bianjifont" >编辑</a>' +
  2361. // // '<a ng-click="comment()" ng-show="{{item.commontPower}}" tooltip="评论" tooltip-placement="right"><i class="fa fa-send gold"></i></a>' +
  2362. // '<a ng-click="comment()" ng-show="{{item.commontPower}}" class="printfont" >评论</a>' +
  2363. // // '<a ng-click="approval()" ng-show="{{item.reviewPower}}" tooltip="审核" tooltip-placement="right"><i class="fa fa-ellipsis-v orangered"></i></a>' +
  2364. // '<a ng-click="approval()" ng-show="{{item.reviewPower}}" class="fontcolor-five" >审核</a>' +
  2365. // // '<a ng-click="publish()" ng-show="{{item.outTimePower}}" tooltip="发布" tooltip-placement="right"><i class="ti-clipboard steelblue"></i></a>' +
  2366. // '<a ng-click="publish()" ng-show="{{item.outTimePower}}" class="handlefont" >发布</a>' +
  2367. // // '<a ng-click="publishnot()" ng-show="{{item.publishnotPower}}" tooltip="撤销" tooltip-placement="right"><i class=" ti-brush-alt royalblue"></i></a>' +
  2368. // '<a ng-click="publishnot()" ng-show="{{item.publishnotPower}}" class="fontcolor-seven" >撤销</a>' +
  2369. // '<a ng-click="edit()" ng-show="{{item.updatePower}}" tooltip="编辑" tooltip-placement="right"><i class="fa fa-pencil-square-o forestgreen"></i></a>' +
  2370. // '<a ng-click="edit()" class="bianjifont" >编辑</a>' +
  2371. // // '<a ng-click="comment()" ng-show="{{item.commontPower}}" tooltip="评论" tooltip-placement="right"><i class="fa fa-send gold"></i></a>' +
  2372. // '<a ng-click="comment()" class="printfont" >评论</a>' +
  2373. // // '<a ng-click="approval()" ng-show="{{item.reviewPower}}" tooltip="审核" tooltip-placement="right"><i class="fa fa-ellipsis-v orangered"></i></a>' +
  2374. // '<a ng-click="approval()" class="fontcolor-five" >审核</a>' +
  2375. // // '<a ng-click="publish()" ng-show="{{item.outTimePower}}" tooltip="发布" tooltip-placement="right"><i class="ti-clipboard steelblue"></i></a>' +
  2376. // '<a ng-click="publish()" class="handlefont" >发布</a>' +
  2377. // // '<a ng-click="publishnot()" ng-show="{{item.publishnotPower}}" tooltip="撤销" tooltip-placement="right"><i class=" ti-brush-alt royalblue"></i></a>' +
  2378. // '<a ng-click="publishnot()" class="fontcolor-seven" >撤销</a>' +
  2379. '<a ng-click="edit()" class="bianjifont" ng-show="jry_bj()">编辑</a>' +
  2380. // '<a ng-click="comment()" ng-show="{{item.commontPower}}" tooltip="评论" tooltip-placement="right"><i class="fa fa-send gold"></i></a>' +
  2381. // '<a ng-click="comment()" class="printfont" >评论</a>' +
  2382. '<a ng-click="leve()" class="printfont" ng-show="jry_sj()">升级</a>' +
  2383. // '<a ng-click="approval()" ng-show="{{item.reviewPower}}" tooltip="审核" tooltip-placement="right"><i class="fa fa-ellipsis-v orangered"></i></a>' +
  2384. '<a ng-click="approval()" class="fontcolor-five" ng-show="jry_sh()">审核</a>' +
  2385. // '<a ng-click="publish()" ng-show="{{item.outTimePower}}" tooltip="发布" tooltip-placement="right"><i class="ti-clipboard steelblue"></i></a>' +
  2386. // '<a ng-click="publish()" class="handlefont" >发布</a>' +
  2387. '<a ng-click="publish()" class="handlefont" ng-show="jry_lsjl()">历史记录</a>' +
  2388. // '<a ng-click="publishnot()" ng-show="{{item.publishnotPower}}" tooltip="撤销" tooltip-placement="right"><i class=" ti-brush-alt royalblue"></i></a>' +
  2389. '<a ng-click="publishnot()" class="fontcolor-seven" ng-show="jry_ty()">停用</a>' +
  2390. '</div>'
  2391. };
  2392. });