123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638 |
- app.controller('knowledgeManagerCtrl', ["$rootScope", "$scope", "i18nService", "$state", "$timeout", "$interval", "SweetAlert", "$modal", "FileUploader", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_user_data", "api_solution", "api_bpm_domain", function($rootScope, $scope, i18nService, $state, $timeout, $interval, SweetAlert, $modal, FileUploader, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data, api_solution, api_bpm_domain) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- var loginUser = $rootScope.user;
- // console.log(' loginUser='+JSON.stringify( loginUser));
- //for test
- // loginUser = {
- // id:2,
- // name:'李进'
- // };
- //console.log(loginUser);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalPagination = true;
- $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;
- };
- $scope.transferTime = function(time) {
- return moment(time).format('YYYY-MM-DD ');
- }
- $scope.transferStatus = function(status) {
- var statusLabel = "不合法的状态";
- if (status == 1) {
- statusLabel = "待审核";
- } else if (status == 2) {
- statusLabel = "已批准";
- } else if (status == 3) {
- statusLabel = "已发布";
- } else if (status == 4) {
- statusLabel = "已取消";
- } else if (status == 5) {
- statusLabel = "已驳回";
- } else if (status == 6) {
- statusLabel = "已拒绝";
- }
- return statusLabel;
- }
-
- // $scope.myDD={
- // 'solutionNumber':'编号',
- // 'typeName':'类别',
- // 'title':'标题',
- // 'keywords':'关键字',
- // 'status':'状态',
- // 'createUserName':'创建人',
- // 'createtime':'创建日期',
- // '操作':'操作'
- // }
- $scope.gridOptions.columnDefs = [
- { name: 'solutionNumber', displayName: '编号', width: 100 },
- { name: 'typeName', displayName: '类别', width: 100 },
- { name: 'title', displayName: '标题', width: 100 },
- { name: 'keywords', displayName: '关键字', width: 100 },
- { name: 'status', displayName: '状态', cellTemplate: '<div class="ui-grid-cell-contents">{{grid.appScope.transferStatus(row.entity.status)}}</div>', width: 80 },
- { name: 'createUserName', displayName: '创建人', width: 60 },
- { name: 'createtime', cellTemplate: '<div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.createtime)}}</div>', displayName: '创建日期', width: 100 },
- { name: '操作', cellTemplate: '<gridoperator item="row.entity" colobject="col">' }
- ];
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- var filtersData = $scope.allfilterData;
- // console.log(filtersData)
- filterData.pageIndex = newPage - 1;
- var data = { pageIndex: newPage - 1 };
- var dataFilter = angular.extend(data, filterData);
- dataFilter.status = filtersData.status;
- // console.log(dataFilter)
- $scope.refreshListData('expand-right', dataFilter);
- });
- gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- $scope.selected.item = data.entity;
- });
-
- };
- this.selectRowFunction = function(data) {};
- $scope.refreshListData = function(style, filterData) {
- $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- if (angular.isDefined($scope.searchTypes)) {
- filterData['searchType'] = $scope.searchTypes;
- }
- $scope.myData = [];
- api_solution.findSolutionByKeys(filterData).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- // console.log("myData="+JSON.stringify(myData));
- $scope.gridOptions.totalItems = myData.totalNum;
- if (angular.isArray(myData.list)) {
- $scope.myData = myData.list;
- } else {
- SweetAlert.swal({
- title: "数据为空",
- text: myData.list,
- type: "warning"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- }, function() {
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- }
- $scope.createKnowledge = function() {
- var data = { model: { knowledge: { createUserId: loginUser.id, status: 1 } } };
- $state.go('app.knowledge.create', { formKey: 'knowledge_create', service: 'api_solution', 'model': JSON.stringify(data) })
- }
- $scope.detailSolution = function(id) {
- 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);
- }
- $state.go('app.knowledge.detail', { formKey: 'knowledge_detail', service: 'api_solution', 'model': JSON.stringify(data) })
- })
- }
- $scope.editSolution = function(id) {
- 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);
- }
- $state.go('app.knowledge.editor', { formKey: 'knowledge_editor', service: 'api_solution', 'model': JSON.stringify(data) })
- })
-
- }
- $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) {
- $scope.uploader = uploader;
- var loadData = function() {
- $scope.visions = [];
- $scope.entity = {};
- $scope.solutionDowpath = APIService.getSolutionDowpath().getRequestedUrl();
- APIService.findSolutionById(id).then(function(response) {
- var data = response.data;
-
- console.log(data);
- $scope.entity = {
- "id": data.id,
- "title": data.title,
- "keys": data.keywords,
- "type": 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,
- "vision2": "V" + data.vision,
- "fileContent": data.fileContent,
- "replies": data.replies,
- "scores": data.scores,
- "hits": data.hits,
- "fileName": data.fileName,
- "typeName": data.typeDTO.typeName
- };
- $scope.file = data.fileName;
- $scope.nowEntity = data;
- $scope.couldReview = true;
- $scope.showOutTime = true;
- if ($scope.nowEntity.status != 1) { //状态只有是 待审核状态 才能进行审核
- $scope.couldReview = false;
- }
- if (($scope.nowEntity.status == 2) && outtime) { //表示状态为已通过
- $scope.showOutTime = false;
- }
- $scope.showCommentScore = true;
- $scope.comments = [];
- APIService.findSolutionReviewById(loginUser.id, data.id, 0, 1000).then(function(response) {
- if (response.status != "500") {
- var data = response.list;
- // console.log("data="+data);
- 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.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 = MomentFormat(data[i].reviewTime).format('YYYY-MM-DD ');
- // console.log("object="+object );
- $scope.comments.push(object);
- }
- }
- });
- });
- }
- loadData();
- $scope.options = {
- language: 'zh-cn',
- allowedContent: true,
- entities: false
- };
- $scope.uploader = uploader;
- $scope.onReady = function() {
- // ...
- };
- $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.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- $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;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- console.log('selectedItem=' + JSON.stringify(selectedItem));
- // console.log('reviewContent='+JSON.stringify(reviewContent));
- // console.log('score='+JSON.stringify(score));
- if (selectedItem) {
- 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") {
- // var data=response.data;
- // $scope.reviewcontent="";
- // $scope.score=0;
- SweetAlert.swal({
- title: "评论知识库!",
- text: "评论知识库成功!",
- type: "success"
- }, function() {
- $scope.reload();
- });
- } else {
- SweetAlert.swal({
- title: "评论知识库!",
- text: "评论知识库失败!",
- type: "error"
- });
- }
- });
- }
- });
- }
- $scope.approvalSolution = function(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;
- $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
- };
- $scope.nowEntity = data;
- $scope.couldReview = true;
- $scope.showOutTime = true;
- $scope.fabu = false;
- $scope.shenhe = false;
- $scope.fabulabel = false;
- $scope.chexiao = false;
- $scope.shouquan = 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 = {};
- }
- }
- 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 == 2) && outTimePower) { //表示状态为已通过
- $scope.showOutTime = false;
- }
- });
- }
- $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 = "发布";
- }
- $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_data = convertParentToChildList(result['list']);
- var nata = [];
- for (var i = 0; i < $scope.my_data.length; i++) {
- nata.push({
- 'groupname': $scope.my_data[i].groupName,
- 'id': $scope.my_data[i].id
- })
- $scope.group = nata;
- }
- })
- $scope.saveright = function(multipleDemo) {
- console.log(multipleDemo);
- $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.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;
- }
- }
- });
- 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: "warning"
- }, 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: "warning"
- }, 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_data = convertParentToChildList(result['list']);
- var nata = [];
- for (var i = 0; i < $scope.my_data.length; i++) {
- nata.push({
- 'groupname': $scope.my_data[i].groupName,
- 'id': $scope.my_data[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.my_tree_handler = function(branch) {
- filterData.treeIds = branch.id;
- $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;
- }
- var uploader = $scope.uploader = new FileUploader({
- url: api_solution.upload().getRequestedUrl(),
- alias: "file",
- removeAfterUpload: true,
- queueLimit: 10
- // headers : {
- // }
- });
- $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;
- }
- 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"
- });
- }
- })
- }
- }
- });
- }
- $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) {
- if (response.status == 200) {
- var data = response.data;
- // 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";
- objects.push(object);
- }
- $scope.my_data = convertParentToChildList(objects);
- $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 = {};
- $scope.allfilterData = {
- key: 'null',
- status: 0,
- pageIndex: 0,
- pageSum: 10,
- //treeIds:'[]',
- userId: loginUser.id
- }
- var filterData = {
- key: 'null',
- status: 0,
- pageIndex: 0,
- pageSum: 10,
- //treeIds:'[]',
- 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.people = [
- { name: 'Adam', email: 'adam@email.com', age: 12, country: 'United States' },
- { name: 'Amalie', email: 'amalie@email.com', age: 12, country: 'Argentina' },
- { name: 'Estefanía', email: 'estefania@email.com', age: 21, country: 'Argentina' },
- { name: 'Adrian', email: 'adrian@email.com', age: 21, country: 'Ecuador' },
- { name: 'Wladimir', email: 'wladimir@email.com', age: 30, country: 'Ecuador' },
- { name: 'Samantha', email: 'samantha@email.com', age: 30, country: 'United States' },
- { name: 'Nicole', email: 'nicole@email.com', age: 43, country: 'Colombia' },
- { name: 'Natasha', email: 'natasha@email.com', age: 54, country: 'Ecuador' },
- { name: 'Michael', email: 'michael@email.com', age: 15, country: 'Colombia' },
- { name: 'Nicolás', email: 'nicolas@email.com', age: 43, country: 'Colombia' }
- ];
-
- $scope.searchSolution = function() {
- $scope.refreshListData('expand-right', filterData);
- }
- $scope.reload = function() {
- if ($rootScope.searchknowledge) { filterData = $rootScope.searchknowledge; }
- $scope.refreshListData('expand-right', filterData);
- }
- $scope.reload();
- }]);
- app.controller('knowledgeForumCtrl', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "moment", "Restangular", "api_solution", function($rootScope, $scope, $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.searchSolution = function(searchKey, page) {
- console.log(page)
- $scope.getKnowledgeList();
- if (searchKey == "") {
- ng - u
- 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) {
- var myData = Restangular.stripRestangular(response);
- var status = myData.status;
- if (status == "500") {
- $scope.solutionBBS = [];
- } else if (status == "200" && myData.list) {
- var data = myData.data[0];
- var count = myData.data[1];
- $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].creationtime);
- 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]);
- }
- }
- }
- });
- } 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.queryBBSSolutions(tempPage, 7, 'createtime', loginUser.id, searchKey).then(function(response) {
- var myData = Restangular.stripRestangular(response);
- 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]);
- }
- }
- }
- });
- }
- }
- //BBS列表切换
- $scope.changeShowList = function(val) {
- $scope.showlist = !$scope.showlist;
- }
- $scope.solutionBBS = [];
- $scope.hotRankings = [];
- $scope.scoreRankings = [];
- $scope.solutionScores = [];
- $scope.currentPage = 1;
- $scope.pages = 0;
- api_solution.fetchBBSSolutions(0, 7, "createtime", loginUser.id).then(function(response) {
- if (response.status == 200 && response.list) {
- $scope.solutionBBS = [];
- var myData = Restangular.stripRestangular(response);
- var data = myData.list;
- var count = myData.totalNum;
- if (count <= 7) {
- $scope.pages = 1;
- }
- 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]);
- }
- console.log($scope.solutionBBS)
- }
- });
- $scope.fetchByPage = function(page) {
- api_solution.fetchBBSSolutions(0, 7, "createtime", loginUser.id).then(function(response) {
- var sumdata = Restangular.stripRestangular(response);
- var sum = sumdata.list;
- if (angular.isDefined($scope.searchInput) && $scope.searchInput != "" && $scope.searchInput.length > 1) {
- $scope.searchSolution($scope.searchInput, page);
- } else {
- if (page == 0) {
- page = 1;
- } else if (page == $scope.pages + 1) {
- page = $scope.pages;
- } else if (sum / 7 == 1) {
- $scope.pages = 1;
- page = 1;
- }
- api_solution.fetchBBSSolutions(page - 1, 7, "createtime", loginUser.id).then(function(response) {
- if (response.status == 200 && response.list) {
- $scope.solutionBBS = [];
- var myData = Restangular.stripRestangular(response);
- var data = myData.list;
- var count = myData.totalNum;
- if (count / 7 == parseInt(count / 7)) {
- // if(count/7==1){
- // page=1;
- // $scope.pages=parseInt(count/7);
- // }else{
- $scope.pages = parseInt(count / 7);
- // }
- } else {
- $scope.pages = parseInt(count / 7) + 1;
- }
- $scope.currentPage = page;
- 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]);
- }
- }
- });
- }
- })
- }
- 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) {
- var loadData = function() {
- $scope.visions = [];
- $scope.entity = {};
- $scope.showCommentScore = true;
- $scope.comments = [];
- APIService.findSolutionReviewById(loginUser.id, solution.id, 0, 1000).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;
- 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;
- }
- }
- });
- 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"
- });
- }
- });
- }
- });
- }
- $('#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', ['$http', '$scope', function($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.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;
- }
- } else {
- $scope.item.outTimePower = false;
- }
- }
- if ($scope.item.status == 3) { //已发布的才能评论
- $scope.item.publishnotPower = true;
- $scope.item.commontPower = true;
- } else {
- $scope.item.commontPower = false;
- $scope.item.publishnotPower = false;
- }
- // console.log($scope.item.status + " " + $scope.item.commontPower);
- $scope.edit = function() {
- $scope.colobject.grid.appScope.editSolution($scope.item.id);
- // console.log($scope.colobject);
- //$scope.doEdit($scope.item.id);
- }
- $scope.comment = function() {
- $scope.colobject.grid.appScope.commentSolution($scope.item.id);
- //$scope.doComment($scope.item.id);
- }
- $scope.approval = function() {
- $scope.colobject.grid.appScope.approvalSolution($scope.item.id, $scope.item.outTimePower);
- //$scope.doApproval($scope.item.id,$scope.item.outTimePower);
- }
- $scope.publish = function() {
- $scope.colobject.grid.appScope.approvalSolution($scope.item.id, $scope.item.outTimePower);
- //$scope.doApproval($scope.item.id,$scope.item.outTimePower);
- }
- $scope.publishnot = function() {
- $scope.colobject.grid.appScope.approvalSolution($scope.item.id, $scope.item.outTimePower);
- //$scope.doApproval($scope.item.id,$scope.item.outTimePower);
- }
- $scope.detail = function() {
- $scope.colobject.grid.appScope.detailSolution($scope.item.id);
- // console.log($scope.colobject);
- }
- }]);
- app.directive('gridoperator', function() {
- return {
- restrict: 'E',
- scope: {
- item: '=',
- colobject: '='
- // doEdit: '&',
- // doComment: '&',
- // doApproval: '&'
- },
- controller: 'GridOperatorCtrl',
- template: '<div class="links cl-effect-1">' +
- '<a ng-click="detail()" ng-show="{{item.detailPower}}" tooltip="查看" tooltip-placement="left"><i class="ti-eye"></i></a>' +
- '<a ng-click="edit()" ng-show="{{item.updatePower}}" tooltip="编辑" tooltip-placement="left"><i class="fa fa-pencil"></i></a>' +
- '<a ng-click="comment()" ng-show="{{item.commontPower}}" tooltip="评论" tooltip-placement="left"><i class="fa fa-send"></i></a>' +
- '<a ng-click="approval()" ng-show="{{item.reviewPower}}" tooltip="审核" tooltip-placement="left"><i class="fa fa-ellipsis-v"></i></a>' +
- '<a ng-click="publish()" ng-show="{{item.outTimePower}}" tooltip="发布" tooltip-placement="left"><i class="ti-clipboard"></i></a>' +
- '<a ng-click="publishnot()" ng-show="{{item.publishnotPower}}" tooltip="撤销" tooltip-placement="left"><i class=" ti-brush-alt"></i></a>' +
- '</div>'
- };
- });
|