123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688 |
- $(function() {
- loginStatus();
- var articleId = GetQueryString("articleId");
- var experarray = [];
- var resourcesarray = [];
- var $data = {};
- var modifyTimeval;
- var settime = false;
-
- articleshow();
- relevantExperts();
- relevantResources();
-
-
- $("#newstitle").on({
- focus: function() {
- $(this).prev().find("span").text("30字以内");
- },
- blur: function() {
- $(this).prev().find("span").text("");
- },
- keyup: function() {
- if($(this).val().length > 30) {
- $(this).val($(this).val().substr(0, 30));
- }
- }
- })
-
- $("#KeyWord").on({
- focus: function() {
- $("#keyPrompt").text("最多可添加5个关键词,每个关键词10字以内");
- },
- blur: function() {
- $("#keyPrompt").text("");
- },
- keyup: function() {
- if($(this).val()==""){
- $(".frmadd").addClass("displayNone");
- $(".keydrop ul").html("");
- $(".keydrop").addClass("displayNone");
- }else{
- $(".frmadd").removeClass("displayNone");
- $(".keydrop").removeClass("displayNone");
- }
- if($(this).val().length > 10) {
- $(this).val($(this).val().substr(0, 10));
- }
- KeyWordList();
- }
- })
-
-
- $("#addkeyWord").on("click",function(){
- var keyWord =$("#KeyWord").val();
- keyWordlen(keyWord);
- $(".frmadd").addClass("displayNone");
- $(".keydrop ul").html("");
- $(".keydrop").addClass("displayNone");
- })
-
-
- $(".keydrop").on("click","p",function(){
- var keyWord =$(this).text();
- $(".frmadd").addClass("displayNone");
- keyWordlen(keyWord);
- $(".keydrop ul").html("");
- $(".keydrop").hide();
- })
-
-
- $("#keyWordlist").on("click",".closeThis",function(){
- $(this).parent().remove();
- var plength =$(".keyResult li p").length;
- if(plength < 5){
- $("#KeyWord").show();
- }
- $(".keydrop ul").html("");
- $(".keydrop").hide();
- })
-
- function captiureSubInd(subIndu) {
- var industrys = $("#" + subIndu + "");
- var industryAll = "";
- if(industrys.size() > 0) {
- for(var i = 0; i < industrys.size(); i++) {
- industryAll += industrys[i].innerText;
- industryAll += ',';
- };
- industryAll = industryAll.substring(0, industryAll.length - 1);
- }
- return industryAll;
- }
-
-
- function industryShow(data,industryList){
- if(data != undefined && data.length != 0 ){
- var subs = new Array();
- if(data.indexOf(',')){
- subs = data.split(',');
- }else{
- subs[0] = data;
- }
- if(subs.length>0){
- for (var i = 0; i < subs.length; i++)
- {
- $("#"+industryList+"").append('<li class="delkeylist"><p class="h2Font">'+ subs[i] +'</p><div class="closeThis"></div></li>');
- };
- }
- if(subs.length>4){
- $("#KeyWord").hide();
- }
- }
- }
- function keyWordlen(keyWord){
- $("#KeyWord").val("");
- var plength = $(".keyResult li p");
- for(var i=0;i<plength.length;i++){
- if(plength[i].innerText==keyWord){
- $("#keyPrompt").text("关键词已存在");
- return;
- }
- }
- if(plength.length > 3) {
- $("#KeyWord").hide();
- $("#keyWordlist").append("<li class='delkeylist'><p class='h2Font'>"+ keyWord +"</p><div class='closeThis'></div></li>");
- }else{
- $("#keyWordlist").append("<li class='delkeylist'><p class='h2Font'>"+ keyWord +"</p><div class='closeThis'></div></li>");
- }
- }
-
-
- $("#checkZj").on("focus",function(){
- $(this).prev().find("span").text("最多选择3位专家");
- })
- $("#checkZy").on("focus",function(){
- $(this).prev().find("span").text("最多选择3个资源");
- })
- $("#checkZj,#checkZy").on("blur",function(){
- $(this).prev().find("span").text("");
- })
-
- $("#checkZj").on("keyup", function() {
- var _this = this;
- checkZj(_this);
- })
- $("#checkZy").on("keyup", function() {
- var _this = this;
- checkZy(_this);
- })
-
- $("#expertlist").on("click","li",function(){
- var _this = this;
- expertlist(_this,"该专家已选择");
- });
- $("#resouselist").on("click","li",function(){
- var _this = this;
- expertlist(_this,"该资源已选择");
- });
-
-
- function expertlist(_this,title){
- var liId = $(_this).html();
- var plength = $(_this).parents(".otherBlock").find(".addexpert li");
- for(var i=0;i<plength.length;i++){
- if(plength[i].innerHTML==liId){
- $(_this).parents(".otherBlock").find(".aboutTit span").text(title);
- $(_this).parents(".otherBlock").find(".form-drop").addClass("displayNone");
- $(_this).parents(".otherBlock").find("input").val("");
- return;
- }
- }
- if(plength.length > 3) {
- $(_this).parents(".otherBlock").find("input").hide();
- $(_this).parents(".otherBlock").find(".addexpert").append($(_this).clone());
- $(_this).parents(".otherBlock").find("input").val("");
- $(_this).parents(".otherBlock").find(".form-drop").addClass("displayNone");
- }else{
- $(_this).parents(".otherBlock").find(".addexpert").append($(_this).clone());
- $(_this).parents(".otherBlock").find("input").val("");
- $(_this).parents(".otherBlock").find(".form-drop").addClass("displayNone");
- }
- }
-
-
- $(".addexpert").on("click",".deleteThis",function(){
- var plength = $(this).parent().parent().find("li").length;
- if(plength < 6){
- $(this).parents(".otherBlock").find("input").show();
- }
- $(this).parent().remove();
- })
-
- function checkZj(_this){
- $.ajax({
- "url": "/ajax/professor/qaByName",
- "type": "get",
- "data": {
- "name": $("#checkZj").val(),
- "total":3
- },
- "success": function(data) {
- console.log(data);
- if(data.success ) {
- if(data.data != ""){
- $(_this).next().removeClass("displayNone");
- var itemlist = '';
- $("#expertlist").html("");
- for(var i = 0; i < data.data.length; i++) {
- var itemlist = '<li id="usid" class="flexCenter">';
- itemlist += '<div class="madiaHead useHead" id="userimg"></div>';
- itemlist += '<div class="madiaInfo">';
- itemlist += '<p class="ellipsisSty"><span class="h1Font" id="name"></span><span class="h2Font" style="margin-left:10px;" id="title"></span></p>';
- itemlist += '<p class="h2Font ellipsisSty" id="orgName"></p>';
- itemlist += '</div><div class="deleteThis"></div></li>';
- $itemlist = $(itemlist);
- $("#expertlist").append($itemlist);
- var datalist = data.data[i];
- $itemlist.attr("data-id",datalist.id);
- $itemlist.find("#name").text(datalist.name);
- $itemlist.find("#title").text(datalist.title);
- $itemlist.find("#orgName").text(datalist.orgName);
- if(datalist.hasHeadImage==1) {
- $itemlist.find("#userimg").attr("style", "background-image: url(/images/head/" + datalist.id + "_l.jpg);");
- }
- }
- }else{
- $(_this).next().addClass("displayNone");
- }
- }else{
- $(_this).next().addClass("displayNone");
- }
- },
- "error": function() {
- $.MsgBox.Alert('提示', '链接服务器超时')
- }
- });
- }
-
- function checkZy(_this) {
- $.ajax({
- "url": "/ajax/resource/qaByName",
- "type": "get",
- "data": {
- "resourceName": $("#checkZy").val(),
- "rows": 3
- },
- "success": function(data) {
- console.log(data);
- if(data.success) {
- if(data.data != "") {
- $(_this).next().removeClass("displayNone");
- var itemlist = '';
- $("#resouselist").html("");
- for(var i = 0; i < data.data.length; i++) {
- var itemlist = '<li id="usid" class="flexCenter">';
- itemlist += '<div class="madiaHead resouseHead" id="userimg"></div>';
- itemlist += '<div class="madiaInfo">';
- itemlist += '<p class="h2Font ellipsisSty" id="resourceName"></p>';
- itemlist += '<p class="h1Font ellipsisSty" id="name"></p>';
- itemlist += '</div><div class="deleteThis"></div></li>';
- $itemlist = $(itemlist);
- $("#resouselist").append($itemlist);
- var datalist = data.data[i];
- $itemlist.attr("data-id", datalist.resourceId);
- $itemlist.find("#resourceName").text(datalist.resourceName);
- if(datalist.resourceType==1){
- $itemlist.find("#name").text(datalist.professor.name);
- }else{
- $itemlist.find("#name").text(datalist.organization.name);
- }
- if(datalist.images.length > 0) {
- $itemlist.find("#userimg").attr("style", "background-image: url(/data/resource/" + datalist.images[0].imageSrc + ");");
- }
- }
- } else {
- $(_this).next().addClass("displayNone");
- }
- } else {
- $(_this).next().addClass("displayNone");
- }
- },
- "error": function() {
- $.MsgBox.Alert('提示', '链接服务器超时')
- }
- });
- }
- function KeyWordList() {
- $.ajax({
- "url": "/ajax/dataDict/qaHotKey",
- "type": "get",
- "data": {
- "key": $("#KeyWord").val()
- },
- "success": function(data) {
- console.log(data);
- if(data.success) {
- if(data.data != "") {
- var itemlist = '';
- $("#keydropList").html("");
- $(".keydrop").removeClass("displayNone");
- for(var i = 0; i < data.data.length; i++) {
- var itemlist = '<li><p class="h2Font"></p></li>';
- $itemlist = $(itemlist);
- $("#keydropList").append($itemlist);
- $itemlist.find(".h2Font").text(data.data[i].caption);
- }
- } else {
- $(".keydrop").addClass("displayNone");
- }
- } else {
- $(".keydrop").addClass("displayNone");
- }
- },
- "error": function() {
- $.MsgBox.Alert('提示', '链接服务器超时')
- }
- });
- }
-
-
- function articleshow(){
- $.ajax({
- "url" : "/ajax/article/query",
- "type" : "GET" ,
- "dataType" : "json",
- "data" :{"articleId":articleId},
- "success" : function(data) {
- console.log(data)
- if (data.success){
- $("#keyWordlist").html("");
- $("#newstitle").val(data.data.articleTitle);
- if(data.data.articleImg){
- $("#uploader").attr("style", "background-image: url(/data/article/" + data.data.articleImg + ");");
- $(".upFront").hide();
- $(".upBackbtn").show();
- }
- ue.ready(function() {
- if(data.data.articleContent==undefined){
- var datadescp ="";
- }else{
- var datadescp = data.data.articleContent;
- }
- ue.setContent(datadescp);
- });
- industryShow(data.data.subject,"keyWordlist");
- modifyTimeval = data.data.modifyTime;
- }
- },
- "error":function(){
- $.MsgBox.Alert('提示','链接服务器超时')
- }
- });
- }
-
-
- function relevantExperts(){
- $.ajax({
- "url": "/ajax/article/ralatePro",
- "type": "get",
- "dataType" : "json",
- "data" :{"articleId":articleId},
- "success": function(data) {
- if(data.success && data.data) {
- for(var i = 0; i < data.data.length; i++) {
- var professorId = data.data[i].professorId;
- relevantExpertsList(professorId)
- }
-
- }
- },
- "error": function() {
- $.MsgBox.Alert('提示', '链接服务器超时')
- }
- });
- }
-
-
- function relevantExpertsList(professorId){
- $.ajax({
- "url" : "/ajax/professor/info/"+professorId,
- "type" : "GET" ,
- "dataType" : "json",
- "success" : function(data) {
- console.log(data);
- if (data.success && data.data){
- var itemlist = '';
- var itemlist = '<li id="usid">';
- itemlist += '<div class="madiaHead useHead" id="userimg"></div>';
- itemlist += '<div class="madiaInfo">';
- itemlist += '<p class="ellipsisSty"><span class="h1Font" id="name"></span><span class="h2Font" style="margin-left:10px;" id="title"></span></p>';
- itemlist += '<p class="h2Font ellipsisSty" id="orgName"></p>';
- itemlist += '</div><div class="deleteThis"></div></li>';
- $itemlist = $(itemlist);
- $("#expertli").append($itemlist);
- var datalist = data.data;
- $itemlist.attr("data-id",datalist.id);
- $itemlist.find("#name").text(datalist.name);
- $itemlist.find("#title").text(datalist.title);
- $itemlist.find("#orgName").text(datalist.orgName);
- if(datalist.hasHeadImage==1) {
- $itemlist.find("#userimg").attr("style", "background-image: url(/images/head/" + datalist.id + "_l.jpg);");
- }
- }
- },
- "error":function(){
- $.MsgBox.Alert('提示','链接服务器超时')
- }
- });
- }
-
-
- function relevantResources(){
- $.ajax({
- "url": "/ajax/article/ralateRes",
- "type": "get",
- "dataType" : "json",
- "data" :{"articleId":articleId},
- "success": function(data) {
- if(data.success && data.data) {
- for(var i = 0; i < data.data.length; i++) {
- var resourceId = data.data[i].resourceId;
- relevantResourcesList(resourceId)
- }
-
- }
- },
- "error": function() {
- $.MsgBox.Alert('提示', '链接服务器超时')
- }
- });
- }
-
-
- function relevantResourcesList(resourceId){
- $.ajax({
- "url" : "/ajax/resource/resourceInfo",
- "type" : "GET" ,
- "dataType" : "json",
- "data" :{"resourceId":resourceId},
- "success" : function(data) {
- console.log(data);
- if (data.success && data.data){
- var itemlist = '<li id="usid">';
- itemlist += '<div class="madiaHead resouseHead" id="userimg"></div>';
- itemlist += '<div class="madiaInfo">';
- itemlist += '<p class="h2Font ellipsisSty" id="resourceName"></p>';
- itemlist += '<p class="h1Font" id="name"></p>';
- itemlist += '</div><div class="deleteThis"></div></li>';
- $itemlist = $(itemlist);
- $("#resources").append($itemlist);
- var datalist = data.data;
- $itemlist.attr("data-id", datalist.resourceId);
- $itemlist.find("#resourceName").text(datalist.resourceName);
- $itemlist.find("#name").text(datalist.editProfessor.name);
- if(datalist.images.length > 0) {
- $itemlist.find("#userimg").attr("style", "background-image: url(/data/resource/" + datalist.images[0].imageSrc + ");");
- }
- }
- },
- "error":function(){
- $.MsgBox.Alert('提示','链接服务器超时')
- }
- });
- }
- var titleflase = false;
-
- function noTitleImg(){
-
- var newstitle = $("#newstitle").val();
-
- $(".imgtis").text("请上传封面图片");
- }else{
- $(".imgtis").text("");
- imgflase = true;
- }*/
- if(newstitle==""){
- $("#aboutTit span").text("请输入文章标题");
- }else{
- $("#aboutTit span").text("");
- titleflase = true;
- }
- }
-
-
- function expertli(){
- experarray=[];
- $("#expertli li").each(function(i){
- var liid = $(this).attr("data-id");
- experarray.push(liid);
- });
-
- return $.unique(experarray);
- }
-
-
- function resourcesli(){
- resourcesarray=[];
- $("#resources li").each(function(i){
- var liid = $(this).attr("data-id");
- resourcesarray.push(liid);
- });
- return $.unique(resourcesarray);
- }
-
-
- $("#release").on("click",function(){
- noTitleImg();
- if(titleflase){
- $.MsgBox.Confirm("提示","确认发布该文章?",newsAdd);
- }
- })
-
-
- $("#draft").on("click",function(){
- noTitleImg();
- if(titleflase){
- draftAdd(1);
- }
- })
-
-
- $("#preview").on("click",function(){
- noTitleImg();
- if(titleflase){
- draftAdd(2);
- }
- })
-
-
- $("#delete").on("click",function(){
- $.MsgBox.Confirm("提示","确认删除该文章?",newsDelet);
- })
-
-
- $("#setTimeIssue").on("click", function() {
- $(".form_datetime").val(timeGeshi(modifyTimeval));
- noTitleImg();
- if(titleflase) {
- $(".blackcover2").fadeIn();
- $(".modelContain").show();
- $("body").addClass("modelOpen");
- $(".mb_btnOk").on("click", function() {
- var modifyTimeval = $(".form_datetime").val();
- settime = true;
- setTimeIssue(st6(modifyTimeval),settime);
- })
- }
- })
-
-
- function getdata(publishTime,settime) {
- expertli();
- resourcesli();
- $data.articleId = articleId;
- $data.professorId = userid;
- $data.articleTitle = $("#newstitle").val();
- $data.subject = captiureSubInd("keyWordlist .delkeylist");
- $data.articleImg = $("#uploader").attr("data-id");
- $data.articleContent = ue.getContent();
- $data.professors = experarray;
- $data.resources = resourcesarray;
- if(settime) {
- $data.publishTime = publishTime;
- }
- console.log($data);
- }
-
-
-
- function newsAdd(){
- getdata();
- $.ajax({
- "url" : "/ajax/article/save",
- "type" : "post" ,
- "dataType" : "json",
- "data" :$data,
- "traditional": true,
- "success" : function(data) {
- console.log(data);
- if (data.success){
- articleId = data.data;
- $.MsgBox.Alert("提示","文章发表成功!",function articalList(){
- location.href = "articalList.html";
- });
- $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
- } else {
- $.MsgBox.Alert("提示","文章发表失败!");
- }
- },
- "error":function(){
- $.MsgBox.Alert('提示','链接服务器超时')
- }
- });
- }
-
- function setTimeIssue(publishTime,settime) {
- getdata(publishTime,settime);
- $.ajax({
- "url": "/ajax/article/timing",
- "type": "post",
- "dataType": "json",
- "data": $data,
- "traditional": true,
- "success": function(data) {
- console.log(data);
- if(data.success) {
- articleId = data.data;
- location.href = "articalList.html";
- } else {
- $.MsgBox.Alert("提示", "文章发表失败!");
- }
- },
- "error": function() {
- $.MsgBox.Alert('提示', '链接服务器超时')
- }
- });
- }
-
- function draftAdd(num){
- getdata();
- $.ajax({
- "url" : "/ajax/article/draft",
- "type" : "post" ,
- "dataType" : "json",
- "data" :$data,
- "traditional": true,
- "success" : function(data) {
- console.log(data);
- if(num==1){
- if (data.success){
- articleId = data.data;
- $.MsgBox.Alert("提示","文章已保存草稿。");
- $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
- articleshow();
- }
- }
- if(num==2){
- if (data.success){
- articleId = data.data;
- }
- window.open("articalPreview.html?articleId="+ articleId)
- }
- },
- "error":function(){
- $.MsgBox.Alert('提示','链接服务器超时')
- }
- });
- }
-
-
- function newsDelet() {
- $.ajax({
- "url" : "/ajax/article/deleteArticle",
- "type" : "POST",
- "dataType" : "json",
- "data": {
- "articleId": articleId
- },
- "success" : function($data) {
- if ($data.success) {
- location.href = "articalList.html";
- }
- },
- "error":function(){
- $.MsgBox.Alert('提示','链接服务器超时')
- }
- })
- }
-
- function st6(osr) {
- var tim = osr.substring(0, 4) + osr.substring(5, 7) + osr.substring(8, 10) + osr.substring(11, 13) + osr.substring(14, 16);
- return tim;
- }
-
- function timeGeshi(otm) {
- var otme = otm.substring(0, 4) + "-" + otm.substring(4, 6).replace(/\b(0+)/gi, "") + "-" + otm.substring(6, 8).replace(/\b(0+)/gi, "") + " " + otm.substring(8, 10)+ ":" + otm.substring(10, 12);
- return otme;
- }
- });
|