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