knowledgeCtrl.js 119 KB

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