knowledgeCtrl.js 119 KB

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