123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- $(function() {
- $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
- loginStatus();
- var userid = $.cookie("userid");
- var name = $.cookie("userName");
- var flag;
-
- var resourceNamePass = true;
-
- var supportedServicesPass = true;
- function resourceName() {
- var code = $("#resourceName").val();
- if(code.length == 0 || code == " ") {
- $(".workmsg1").text("发布资源名称不能为空");
- resourceNamePass = false;
- } else {
- $(".workmsg1").text("");
- resourceNamePass = true;
- }
- }
- $("#resourceName").blur(function() {
- resourceName();
- });
-
- function supportedServices() {
- var code = $("#supportedServices").val();
- if(code.length == 0 || code == " ") {
- $(".workmsg3").text("可提供服务不能为空");
- supportedServicesPass = false;
- } else {
- $(".workmsg3").text("");
- supportedServicesPass = true;
- }
- }
- $("#supportedServices").blur(function() {
- supportedServices();
- });
- function industryShow(data, industryList, deleteIndustry) {
- 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("<div class='" + deleteIndustry + "'><em>" + subs[i] + "</em><span class='removeNu'><img src='images/move.png'></span></div>");
- };
- }
- }
- }
-
- function addDele() {
- $("#industryList").on("click", ".removeNu", function() {
- $(this).parent().remove();
- });
- $("#industryAdd").click(function() {
- var val = $("#industry").val();
- if(!val.trim()) {
- $(".workmsg5").text("请填写应用行业");
- return;
- } else {
- $(".workmsg5").text("");
- }
- var vallist1 = $("#industryList .deleteIndustry em");
- for(var i = 0; i < vallist1.length; i++) {
- if(vallist1[i].innerText == val) {
- $(".workmsg5").text("不能添加重复内容");
- return;
- }
- }
- $("#industryList").append("<div class='deleteIndustry'><em>" + val + "</em><span class='removeNu'><img src='images/move.png'></span></div>")
- $("#industry").val("");
- });
- $("#SubjectList").on("click", ".removeNu", function() {
- $(this).parent().remove();
- });
- $("#subjectAdd").click(function() {
- var va = $("#subject").val();
- if(!va.trim()) {
- $(".workmsg4").text("请填写学术领域");
- return;
- } else {
- $(".workmsg4").text("");
- }
- var vallist2 = $("#SubjectList .deleteSubject em");
- for(var i = 0; i < vallist2.length; i++) {
- if(vallist2[i].innerText == va) {
- $(".workmsg4").text("不能添加重复内容");
- return;
- }
- }
- $("#SubjectList").append("<div class='deleteSubject'><em>" + va + "</em><span class='removeNu'><img src='images/move.png'></span></div>")
- $("#subject").val("");
- });
- }
-
- $("#workmysrc").on("click", ".resoumag", function() {
-
- ResourceInfo();
- addDele();
- $(".limitBox").removeClass("limitBox");
- $(".limitwords").removeClass("limitwords");
- $(".limitwordbox").removeClass("limitwordbox");
- $(".respublisher").css("display", "none");
- $(".stateinfor span").text("资源发布中");
- var resourceID = $(this).attr("resourceId");
- function delet() {
- $.ajax({
- "url": "/ajax/resource/" + resourceID,
- "type": "DELETE",
- "success": function($data) {
- if($data.success) {
- $(".blackcover").remove();
- $("body").css("position", "");
- getDataResource();
- UE.delEditor('editor');
- } else {
- $.MsgBox.Alert('message', $data.msg);
- }
- }
- })
- }
- if(resourceID) {
- $("#deletedResource").on("click", function() {
- $("body").css("position", "");
- $.MsgBox.Confirm("消息", "执行删除后资源信息将无法恢复,确定继续吗?", delet)
- })
- $.ajax({
- "url": "/ajax/resource/" + resourceID,
- "type": "get",
- "async": false,
- "success": function(info) {
- if(info.success) {
-
- $("#resourceName").val(info.data.resourceName);
- $("#supportedServices").val(info.data.supportedServices);
- $("#hopePayMethod").val(info.data.hopePayMethod);
- $("#cooperationNotes").val(info.data.cooperationNotes);
- industryShow(info.data.subject, "SubjectList", "deleteSubject");
- industryShow(info.data.industry, "industryList", "deleteIndustry");
- ue.ready(function() {
- if(info.data.descp == undefined) {
- var datadescp = "";
- } else {
- var datadescp = info.data.descp;
- }
- ue.setContent(datadescp);
- });
- $("#professor").text(name);
- if(info.data.images.length) {
- var $liMages = $(
- '<div id="WU_FILE" class="file-item thumbnail ResImgBox" style="max-width:216px;width:216px;height: 216px;">' +
- '<img class="resImg headRadius resourceImg" style="display: inline;" src="/images/resource/' + resourceID + '.jpg">' +
- '</div>'
- )
- } else {
- var $liMages = $(
- '<div id="WU_FILE" class="file-item thumbnail ResImgBox" style="max-width:216px;width:216px;height: 216px;">' +
- '<img class="resImg headRadius resourceImg" style="display: inline;" src="/images/default-resource.jpg">' +
- '</div>'
- )
- }
- $("#fileList").append($liMages);
- $(".upbox").css({
- "marginTop": "0px"
- });
- $("#deletedResource").show();
- } else {
- $.MsgBox.Alert('message', "系统异常!");
- }
- },
- "error": function() {
- $.MsgBox.Alert('message', 'failed')
- }
- });
- }
- 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;
- }
- $("#inputb").on("click", function() {
- var $data = {};
- $data.resourceName = $("#resourceName").val();
- $data.supportedServices = $("#supportedServices").val();
- $data.professorId = userid;
- $data.hopePayMethod = $("#hopePayMethod").val();
- $data.cooperationNotes = $("#cooperationNotes").val();
- $data.subject = captiureSubInd("SubjectList .deleteSubject");
- $data.industry = captiureSubInd("industryList .deleteIndustry");
- $data.descp = ue.getContent();
- if(cacheImageKey) {
-
- $data.fn = cacheImageKey;
- }
- if(resourceID) {
- $data.resourceId = resourceID;
- }
-
- function getDataput() {
- $.ajax({
- "url": "ajax/resource/updateResource",
- "type": "post",
- "success": function(rdata) {
-
- if(rdata.success) {
- getDataResource();
- $(".blackcover").remove();
- UE.delEditor('editor');
- } else {
- $.MsgBox.Alert("消息", "资源发布失败");
- }
- },
- "data": $data,
- "beforeSend": function() { },
- "contentType": "application/x-www-form-urlencoded",
- dataType: "json"
- });
- }
-
- resourceName();
-
- supportedServices();
- if(resourceNamePass && supportedServicesPass) {
- if(resourceID) {
-
- $("body").css("position", "");
- $.MsgBox.Confirm("消息", "确定修改资源信息吗?", getDataput)
- $data.fn = cacheImageKey;
- } else {
- $.ajax({
- "url": "/ajax/resource",
- "type": "POST",
- "success": function(rdata) {
- if(rdata.success) {
- $(".blackcover").remove();
- $("body").css("position", "");
- getDataResource();
- $.MsgBox.Alert("消息", "资源发布成功");
- $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
- UE.delEditor('editor');
- } else {
- $.MsgBox.Alert("消息", "资源发布失败");
- }
- },
- "data": $data,
- "beforeSend": function() { },
- "contentType": "application/x-www-form-urlencoded",
- dataType: "json"
- });
- }
- }
- });
- });
- getDataResource();
- function getDataResource() {
- $.ajax({
- "url": "/ajax/resource/qapro",
- "type": "get",
- "async": true,
- "data": {
- "professorId": userid
- },
- "beforeSend": function() {
- $("#consd").append('<img src="../images/loading.gif" class="loading" />');
- },
- "success": function(data) {
- if(data.success) {
- var add = '';
- var k = 0;
- $("#consd").html("");
- var addbut = ' <div class="addworkbtn resoumag" ></div>';
- $("#consd").append(addbut);
- for(var i = 0; i < data.data.length; i++) {
- var add = '<div class="addworkbtn-list"> <div class="resoumag">'
- add += '<div class="ResImgBox" style="max-width:216px;width:216px;height: 216px;"><img class="resImg headRadius resourceImg" src="" /></div>'
- add += '<h2>' + data.data[i].resourceName + '</h2>'
- add += '<p>' + data.data[i].supportedServices + '</p>'
- add += '</div></div>';
- $add = $(add);
- $("#consd").append($add);
- if(data.data[i].subject == undefined) {
- $(".li1").eq(i).css({
- "display": "none"
- });
- }
- $add.find('.resoumag').attr("resourceId", data.data[i].resourceId);
-
- if(data.data[i].images.length) {
- $add.find(".resourceImg").attr("src", "/images/resource/" + data.data[i].resourceId + ".jpg");
- } else {
- $add.find(".resourceImg").attr("src", "/images/default-resource.jpg");
- }
- add = "";
- $(".loading").remove();
- }
- } else {
- $.MsgBox.Alert('message', "系统异常!");
- }
- },
- "error": function() {
- $.MsgBox.Alert('message', 'failed')
- }
- });
- }
- });
|