123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688 |
- $(function() {
- var orgId = $.cookie('orgId');
- var oProfessor = [];
- var sevriceId = GetQueryString("sevriceId");
- var re, reEnd, ue = UE.getEditor('editor', {}),
- temp = [];
- if(orgId == "" || orgId == null || orgId == "null") {
- location.href = "cmp-settled-log.html";
- }
- if(sevriceId) {
- $("#deleteResource").removeClass("disableLi").addClass("deleteResource");
- getRecourceMe();
- }
- function ajaxRequist(url, obj, type, fn) {
- $.ajax({
- url: url,
- data: obj,
- dataType: 'json',
- type: type,
- traditional: true,
- success: function(data) {
- if(data.success) {
- fn(data)
- }
- },
- error: function(xhr, type, errorThrown) {
- $.MsgBox.Alert('提示', '服务器请求失败');
- }
- });
- }
- function getRecourceMe() {
- $.ajax({
- "url": "/ajax/ware/qo",
- "type": "GET",
- "success": function(data) {
- if(data.success) {
- $("#uploadDd").siblings().remove();
- $("#fileList").append("<dd></dd><dd></dd>");
- temp = [];
- resourceHtml(data.data);
- }
- },
- "data": {
- "id": sevriceId
- },
- dataType: "json",
- 'error': function() {
- $.MsgBox.Alert('提示', '服务器连接超时!');
- }
- });
- }
-
- function resourceHtml($da) {
- $("#resourceName").val($da.name);
- if($da.cnt) {
- $("#modelNumber").val($da.cnt);
- autoGrow.call($("#modelNumber")[0])
- }
- if($da.cooperation) {
- $("#remarkContent").val($da.cooperation);
- }
- if($da.keywords) {
- var oSub = $da.keywords.split(",");
- var oSt = "";
- for(var i = 0; i < oSub.length; i++) {
- oSt += '<li>' + oSub[i] + '<div class="closeThis"></div></li>'
- }
- $("#keyWordlist").html(oSt);
- if(oSub.length > 4) {
- $("#KeyWord").parent().addClass("displayNone");
- }
- } else {
- $("#keyWordlist").html("");
- }
- if($da.descp) {
- ue.ready(function() {
- ue.setContent($da.descp);
- });
- }
- if($da.images) {
- var arr = [];
- var oImg = $da.images.split(",");
- for(var i = 0; i < oImg.length; i++) {
- var oString = '<dd>' +
- '<div class="imgItem">' +
- '<img src="' + "/data/ware" + oImg[i] + '"/>' +
- '</div>' +
- '<div class="file-panel">' +
- '<span class="cancel" flag=1></span>' +
- '</div>' +
- '</dd>'
- arr[i] = oString;
- temp[i] = oImg[i];
- }
- $("#fileList dd").eq(2).remove();
- if(oImg.length == 1) {
- $("#fileList").prepend(arr[0]);
- } else if(oImg.length == 2) {
- $("#fileList dd").eq(1).remove();
- $("#fileList").prepend(arr[1]);
- $("#fileList").prepend(arr[0]);
- } else if(oImg.length == 3) {
- $("#fileList dd").eq(1).remove();
- $("#fileList").prepend(arr[2]);
- $("#fileList").prepend(arr[1]);
- $("#fileList").prepend(arr[0]);
- }
- }
- }
- var uploader = WebUploader.create({
- auto: true,
- fileNumLimit: 3,
- swf: '../js/webuploader/Uploader.swf',
- server: '/ajax/ware/upload',
- fileSingleSizeLimit: 2 * 1024 * 1024,
- pick: {
- id: "#filePicker",
- multiple: false
- },
- accept: {
- title: 'Images',
- extensions: 'jpg,jpeg,png',
- mimeTypes: 'image/jpg,image/png,image/jpeg'
- }
- });
-
- uploader.on('fileQueued', function(file) {
- var $len = $("#fileList").find("img").length;
- fileId = file.id;
- if($len == 0 || $len == 1) {
- var oRemove = $("#fileList").find("dd");
- oRemove.eq(oRemove.length - 1).remove();
- }
- var $li = $(
- '<dd>' +
- '<div class="imgItem" id="' + file.id + '">' +
- '<img />' +
- '</div>' +
-
- '</dd>'
- ),
- $btns = $('<div class="file-panel">' +
- '<span class="cancel"></span>' +
- '</div>').appendTo($li),
- $img = $li.find('img');
- var $list = $("#fileList");
- if($len == 1) {
- $list.find("dd").eq(0).after($li)
- } else if($len == 2) {
- $list.find("dd").eq(1).after($li)
- } else {
- $list.prepend($li);
- }
-
-
-
- uploader.makeThumb(file, function(error, src) {
- if(error) {
- $img.replaceWith('<span>不能预览</span>');
- return;
- }
- $img.attr('src', src);
- }, 1, 1);
- });
- uploader.onError = function(code) {
- $.MsgBox.Alert('提示', '请上传jpg、jpeg、png格式的图片,大小不超过2M')
- };
- uploader.on('uploadSuccess', function(file, data) {
- if(data.success) {
- temp.push(data.data[0].uri);
- uploader.removeFile(fileId);
- } else {
- $.MsgBox.Alert('提示', '只支持jpeg/jpg/png格式的图片');
- }
- });
-
- $("#fileList").on("click", ".cancel", function() {
- var flag = $(this).attr("flag");
- var oNum = $(this).parents("dd").index();
- temp.splice(oNum, 1);
- $(this).parent().parent().remove();
- var $len = $("#fileList").find("img").length;
- if($len != 2) {
- $("#fileList").append("<dd></dd>")
- }
- });
-
- $("#resourceName").bind({
- focus: function() {
- $("#resourceNamePrompt").show();
- },
- blur: function() {
- $("#resourceNamePrompt").hide();
- },
- keyup: function() {
- if($(this).val().length > 30) {
- $(this).val($(this).val().substr(0, 30));
- }
- }
- })
- hotKey(".oinput");
-
- $("#KeyWord").on({
- focus: function() {
- $("#keyPrompt").text("最多可添加5个关键词,每个关键词15字以内");
- },
- blur: function() {
- $("#keyPrompt").text("");
- }
- })
- $("#keyWordlist").on("click", ".closeThis", function() {
- $(this).parent().remove();
- var liNum = $("#keyWordlist").find("li").length;
- if(liNum < 5) {
- $("#keyWordlist").parents(".keyResult").siblings("div.col-w-12").show();
- }
- })
-
- $("#modelNumber").bind({
- focus: function() {
- $("#model").show();
- },
- blur: function() {
- $("#model").hide();
- },
- keyup: function() {
- if($(this).val().length > 250) {
- $(this).val($(this).val().substr(0, 250));
- }
- },
- input: function() {
- autoGrow.call(this);
- }
- });
- function autoGrow() {
- document.getElementById("tt").style.width = this.scrollWidth + "px";
- document.getElementById("tt").value = this.value;
- this.style.height = document.getElementById("tt").scrollHeight + "px";
- }
- $("#remarkContent").bind({
- focus: function() {
- $("#remark").show();
- },
- blur: function() {
- $("#remark").hide();
- }
- });
-
- limitObj("#remarkContent", 1000);
-
- $(".goFabu").click(function() {
- var oYes = term();
- if(oYes == 0) {
- return;
- }
- $.MsgBox.Confirm("提示", "确认发布该服务?", ajsPost);
- })
-
- $("#oPreview").click(function() {
- var oYes = term();
- if(oYes == 0) {
- return;
- }
- if(sevriceId) {
- ajsPost("/ajax/ware/draft/org/update", 1);
- } else {
- ajsPost("/ajax/ware/draft/org", 1);
- }
- })
-
- $("#oDraft").click(function() {
- var oYes = term();
- if(oYes == 0) {
- return;
- }
- if(sevriceId) {
- ajsPost("/ajax/ware/draft/org/update", 2);
- } else {
- ajsPost("/ajax/ware/draft/org", 2);
- }
- })
-
- $("#operateBlocko").on("click", ".deleteResource", function() {
- $.MsgBox.Confirm("提示", "确认删除该服务?", deleResource);
- })
-
- function deleResource() {
- $.ajax({
- "url": "/ajax/ware/delete",
- "type": "POST",
- "success": function(data) {
- if(data.success) {
- location.href = "cmp-serviceList.html"
- }
- },
- "data": {
- "id": sevriceId
- },
- "beforeSend": function() { },
- "contentType": "application/x-www-form-urlencoded",
- dataType: "json"
- });
- }
-
- function term() {
- var reName = $.trim($("#resourceName").val());
- var len=$("#expertli").find(".selectAdd");
- if(reName == "") {
- $.MsgBox.Alert('提示', '请输入服务名称。');
- return 0;
- }
- if(len.length==0) {
- $.MsgBox.Alert('提示', '请至少选择一个联系人。');
- return 0;
- }
- }
- function keyW() {
- var industrys = $("#keyWordlist li");
- var industryAll = "";
- if(industrys.size() > 0) {
- for(var i = 0; i < industrys.size(); i++) {
- industryAll += industrys[i].innerText.trim();
- industryAll += ',';
- };
- industryAll = industryAll.substring(0, industryAll.length - 1);
- }
- return industryAll;
- }
-
- function ajsPost(pa1, pa2) {
- var oUrl;
- if(sevriceId) {
- oUrl = "/ajax/ware/publish/org/update";
- } else {
- oUrl = "/ajax/ware/publish/org";
- }
- if(pa1) {
- oUrl = pa1
- }
- console.log(oProfessor)
-
- var $data = {
- owner: orgId,
- name: $("#resourceName").val(),
- cooperation: $("#remarkContent").val(),
- keywords: keyW(),
- cnt: $("#modelNumber").val(),
- descp: ue.getContent(),
- images: temp.join(","),
- resource: resourcesli(),
- professor: oProfessor
- };
- if(sevriceId) {
- $data.id = sevriceId;
- }
- ajaxRequist(oUrl, $data, "POST", function(data) {
- if(data.success) {
- if(pa2 == 1) {
- if(!sevriceId)
- sevriceId = data.data;
- $("#deleteResource").removeClass("disableLi").addClass("deleteResource");
- window.open("../sevricePreview.html?sevriceId=" + sevriceId);
- getRecourceMe();
-
- } else if(pa2 == 2) {
- $("#deleteResource").removeClass("disableLi").addClass("deleteResource");
- if(!sevriceId)
- sevriceId = data.data;
- $.MsgBox.Alert('提示', '服务已保存草稿。');
- $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
- getRecourceMe();
- } else {
- $.MsgBox.Alert('提示', '服务发布成功!');
- $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
- location.href = "cmp-serviceList.html"
- }
- } else {
- if(data.code == 90) {
- $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
- }
- }
- })
- }
- function UnauthorizedUser() {
- $.ajax({
- url: "/ajax/professor/qaOrgAuth",
- type: "GET",
- timeout: 10000,
- dataType: "json",
- async: "false",
- data: {
- "orgId": orgId,
- "orgAuth": 1
- },
- success: function(data, textState) {
- if(data.success) {
- unauthUser(data.data);
- }
- },
- error: function(XMLHttpRequest, textStats, errorThrown) {
- $.MsgBox.Alert('提示', '服务器请求失败')
- }
- })
- }
- UnauthorizedUser();
- function unauthUser($res) {
- if(sevriceId) {
- selUse();
- }
- var osting = ""
- for(var i = 0; i < $res.length; i++) {
- var img;
-
- var oClass = autho($res[i].authType, $res[i].orgAuth, $res[i].authStatus);
- var oTitle = "";
-
-
- }*/
- if($res[i].title) {
- oTitle = $res[i].title;
- } else {
- if($res[i].office) {
- oTitle = $res[i].office;
- }
- }
- if($res[i].hasHeadImage) {
- img = "/images/head/" + $res[i].id + "_l.jpg";
- } else {
- img = "../images/default-photo.jpg"
- }
- var oSt = '<li class="flexCenter" style="cursor:pointer;" id="' + $res[i].id + '">'
- oSt += '<div class="madiaHead useHead" id="userimg" style="background-image: url(' + img + ');"></div>'
- oSt += '<div class = "madiaInfo">'
- oSt += '<p class = "ellipsisSty">'
- oSt += '<span class = "h1Font" id="name">' + $res[i].name + '</span><em class="authicon ' + oClass.sty + '" title="' + oClass.title + '"></em >'
- oSt += '</p>'
- oSt += '<p class="h2Font ellipsisSty">' + oTitle + '</p>'
- oSt += '</div>'
- oSt += '<div class="selectNull " flag=1></div>'
- oSt += '</li>'
- osting += oSt;
- }
- $("#expertli").html(osting);
- }
-
- $("#expertli").on("click", "li", function() {
- var userL = $("#expertli").find(".selectAdd").length;
- var oSel = $(this).find(".selectAdd").length;
- var oId = $(this).attr("id");
- $("#linkman").text("");
- if(oSel == 0) {
- if(userL == 5) {
- $("#linkman").text("最多可选5个负责人");
- return;
- }
- $(this).find('[flag]').addClass("selectAdd");
- oProfessor.push(oId);
- } else {
- $(this).find('[flag]').removeClass("selectAdd");
- for(var i = 0; i < oProfessor.length; i++) {
- if(oId == oProfessor[i]) {
- oProfessor.splice(i, 1);
- }
- }
- }
- });
- function selUse() {
- $.ajax({
- url: "/ajax/ware/pro",
- type: "GET",
- timeout: 10000,
- dataType: "json",
- async: true,
- data: {
- "id": sevriceId,
- },
- success: function(data) {
- if(data.success) {
- var arr = [];
- var arr1 = [];
- var oLength = $("#expertli").find("li");
- for(var i = 0; i < data.data.length; i++) {
- arr1.push(data.data[i].professor);
- }
- for(var i = 0; i < oLength.length; i++) {
- arr.push(oLength.eq(i).attr("id"));
- }
- for(var i = 0; i < arr1.length; i++) {
- oProfessor.push(arr1[i]);
- oLength.eq(arr.indexOf(arr1[i])).find("[flag]").addClass("selectAdd")
- }
- }
- },
- error: function(XMLHttpRequest, textStats, errorThrown) {
- $.MsgBox.Alert('提示', '服务器请求失败')
- }
- })
- }
- $("#checkZy").on("keyup", function() {
- var ti = $(this).val();
- re = ti;
- if($(this).val() == "") {
- return;
- }
- var _this = this;
- setTimeout(function() {
- if(ti === re && ti !== reEnd) {
- checkZy(_this, ti);
- }
- }, 500)
- })
- $("#checkZy").on("focus", function() {
- $(this).prev().find("span").text("最多选择5个资源");
- })
- $("#checkZy").on("blur", function() {
- $(this).prev().find("span").text("");
- })
- function checkZy(_this, prd) {
- reEnd = prd;
- $.ajax({
- "url": "/ajax/resource/lq/publish/org",
- "type": "get",
- "data": {
- "orgid": orgId,
- "resourceName": $("#checkZy").val(),
- "rows": 5
- },
- "success": function(data) {
- if(data.success) {
- if(data.data != "") {
- if(reEnd == prd) {
- $(_this).next().removeClass("displayNone");
- $("#resouselist").html("");
- for(var i = 0; i < data.data.length; i++) {
- var itemlist = '<li id="usid" class="flexCenter" >' +
- '<p class="h1Font ellipsisSty-2 childElement" id="resourceName"></p>' +
- '<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);
- }
- }
- } else {
- $(_this).next().addClass("displayNone");
- var itemlist = '<div class="null-data">没有找到相关资源</div>'
- $("#resouselist").html(itemlist);
- }
- } else {
- $(_this).next().addClass("displayNone");
- }
- },
- "error": function() {
- $.MsgBox.Alert('提示', '链接服务器超时')
- }
- });
- }
- $("#resouselist").on("click", "li", function() {
- var _this = this;
- expertlist(_this, "该资源已选择");
- });
- function resourcesli() {
- var resourcesarray = [];
- $("#resources li").each(function(i) {
- var liid = $(this).attr("data-id");
- resourcesarray.push(liid);
- });
- return resourcesarray;
- }
-
- 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 >= 4) {
- $(_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");
- }
- }
- if(!sevriceId)
- DefaultContact()
- function DefaultContact() {
- $.ajax({
- url: "/ajax/org/linkman/queryAll",
- type: "GET",
- timeout: 10000,
- dataType: "json",
- async:"true",
- data: {
- "oid": orgId
- },
- success: function(data, textState) {
- if(data.success) {
- var $data = data.data;
- if($data.length) {
- oProfessor.push($data[0].pid);
- var oLength=$("#expertli").find("li");
- for(var i=0;i<oLength.length;i++) {
- var sid = oLength.eq(i).attr("id");
- if($data[0].pid ===sid) {
- oLength.eq(i).find("[flag]").addClass("selectAdd");
- break;
- }
- }
- oProfessor.push($data[0].pid);
- }
-
- }
- },
- error: function(XMLHttpRequest, textStats, errorThrown) {
- $.MsgBox.Alert('提示', '服务器请求失败')
- }
- })
- }
-
- $(".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();
- })
- if(sevriceId) {
- ajaxRequist("/ajax/ware/res", {
- "id": sevriceId
- }, "get", function(data) {
- var $data = data.data;
- if($data.length>=5) {
- $("#checkZy").hide();
- }
- for(var i = 0; i < $data.length; i++) {
- (function(i) {
- ajaxRequist("/ajax/resource/queryOne", {
- "resourceId": $data[i].resource
- }, "get", function(data) {
- var $data = data.data;
- var itemlist = '<li id="usid" class="flexCenter" >' +
- '<p class="h1Font ellipsisSty-2 childElement" id="resourceName"></p>' +
- '<div class="deleteThis"></div></li>'
- var datalist = data.data;
- var $itemlist=$(itemlist);
- $("#resources").append($itemlist);
- $itemlist.attr("data-id", datalist.resourceId);
- $itemlist.find("#resourceName").text(datalist.resourceName);
-
- })
- })(i)
- }
- })
- }
- })
|