portal html css js resource

cmp-demandPublish.js 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. $(document).ready(function() {
  2. var demandId = GetQueryString("demandId");
  3. var a = new Date();
  4. var c = a.getFullYear() + "-" + (Number(a.getMonth()) + 1) + "-" + (Number(a.getDate()) + 1);
  5. $('.dateBtn').datetimepicker({
  6. language: 'ch',
  7. weekStart: 0,
  8. todayBtn: false,
  9. autoclose: 1,
  10. todayHighlight: 1,
  11. startView: 2,
  12. minView: 2,
  13. forceParse: 0,
  14. startDate: c
  15. });
  16. /*需求主题*/
  17. $("#demandTitle").bind({
  18. focus: function() {
  19. $(this).siblings().find("span").show();
  20. },
  21. blur: function() {
  22. $(this).siblings().find("span").hide();
  23. }
  24. })
  25. /*需求内容*/
  26. $("#remarkContent").bind({
  27. focus: function() {
  28. $(this).parent().siblings().find(".frmconmsg").show();
  29. },
  30. blur: function() {
  31. $(this).parent().siblings().find(".frmconmsg").hide();
  32. },
  33. input: function() {
  34. $(".msgconNum").find("em").text($(this).val().length);
  35. }
  36. })
  37. /*联系电话*/
  38. $("#phone").bind({
  39. focus: function() {
  40. $(this).siblings().find("span").show();
  41. },
  42. blur: function() {
  43. $(this).siblings().find("span").hide();
  44. }
  45. })
  46. DefaultContact()
  47. function DefaultContact() {
  48. $.ajax({
  49. url: "/ajax/org/linkman/queryAll",
  50. type: "GET",
  51. timeout: 10000,
  52. dataType: "json",
  53. async:"true",
  54. data: {
  55. "oid": $.cookie("orgId")
  56. },
  57. success: function(data, textState) {
  58. if(data.success) {
  59. var $data = data.data;
  60. if($data.length) {
  61. UnauthorizedUser($data[0].pid)
  62. }else {
  63. UnauthorizedUser('')
  64. }
  65. }
  66. },
  67. error: function(XMLHttpRequest, textStats, errorThrown) {
  68. $.MsgBox.Alert('提示', '服务器请求失败')
  69. }
  70. })
  71. }
  72. cmpFun()
  73. function cmpFun() {
  74. $.ajax({
  75. "url": "/ajax/org/queryByName",
  76. 'data': {
  77. name: $.cookie('orgName')
  78. },
  79. "type": "get",
  80. "async": true,
  81. "success": function(data) {
  82. if(data.success) {
  83. if(data.data != null) {
  84. $(".goSpan").show();
  85. if(data.data.forShort) {
  86. $("#Qname").text(data.data.forShort);
  87. }else{
  88. $("#Qname").text(data.data.name);
  89. }
  90. var img="/images/default-icon.jpg";
  91. if(data.data.hasOrgLogo==1){
  92. img="/images/org/" + data.data.id + ".jpg";
  93. }
  94. if(data.data.industry) {
  95. $("#industry").text(data.data.industry.replace(/,/g, " | "));
  96. }
  97. $("#companyImg").attr("src",img);
  98. $("#companyImg").parents(".cmpHead").attr("href","cmpInforShow.html?orgId="+data.data.id);
  99. $("#companyImg").parents(".cmpHead").attr("data-id",data.data.id);
  100. $("#Qname").attr("href","cmpInforShow.html?orgId="+data.data.id);
  101. if(data.data.authStatus==3){
  102. $("#QauthFlag").addClass("authicon-com-ok").attr("title","科袖认证企业")
  103. }
  104. if(data.data.contactNum) {
  105. $("#phone").val(data.data.contactNum)
  106. }
  107. } else {
  108. $("#companyImg").attr("src",'/images/default-icon.jpg');
  109. $("#Qname").text(par);
  110. $("#companyImg").parents(".cmpHead").removeAttr("href");
  111. $("#Qname").parents(".cmpHead").removeAttr("href");
  112. }
  113. }else {
  114. $("#companyImg").attr("src",'/images/default-icon.jpg');
  115. $("#Qname").text(par);
  116. $("#companyImg").parents(".cmpHead").removeAttr("href");
  117. $("#Qname").parents(".cmpHead").removeAttr("href");
  118. }
  119. },
  120. "error": function() {
  121. $.MsgBox.Alert('提示', '链接服务器超时')
  122. }
  123. });
  124. }
  125. function UnauthorizedUser(par) {
  126. $.ajax({
  127. url: "/ajax/professor/qaOrgAuth",
  128. type: "GET",
  129. timeout: 10000,
  130. dataType: "json",
  131. async:"false",
  132. data: {
  133. "orgId": $.cookie('orgId'),
  134. "orgAuth": 1
  135. },
  136. success: function(data, textState) {
  137. if(data.success) {
  138. console.log(data);
  139. unauthUser(data.data,par);
  140. if(data.data.length ==0) {
  141. $(".seRe").removeClass("displayNone")
  142. }
  143. }
  144. },
  145. error: function(XMLHttpRequest, textStats, errorThrown) {
  146. $.MsgBox.Alert('提示', '服务器请求失败')
  147. }
  148. })
  149. }
  150. function unauthUser($res,par) {
  151. var osting=""
  152. for(var i = 0; i < $res.length; i++) {
  153. var img;
  154. var oClass = autho($res[i].authType, $res[i].orgAuth, $res[i].authStatus);
  155. var oTitle="";
  156. if($res[i].title) {
  157. oTitle=$res[i].title;
  158. }else{
  159. if($res[i].office) {
  160. oTitle=$res[i].office;
  161. }
  162. }
  163. var cls='';
  164. if($res[i].id == par) {
  165. cls = 'selectAdd'
  166. }
  167. if($res[i].hasHeadImage) {
  168. img = "/images/head/" + $res[i].id + "_l.jpg";
  169. } else {
  170. img = "../images/default-photo.jpg"
  171. }
  172. var oSt = '<li class="flexCenter" style="cursor:pointer;" id="'+$res[i].id+'">'
  173. oSt += '<div class="madiaHead useHead" id="userimg" style="background-image: url('+img+');"></div>'
  174. oSt += '<div class = "madiaInfo">'
  175. oSt += '<p class = "ellipsisSty">'
  176. oSt += '<span class = "h1Font" id="name">'+$res[i].name+'</span><em class="authicon '+oClass.sty+'" title="'+oClass.title+'"></em >'
  177. oSt += '</p>'
  178. oSt += '<p class="h2Font ellipsisSty">'+oTitle+'</p>'
  179. oSt += '</div>'
  180. oSt += '<div class="selectNull '+cls+'" flag=1></div>'
  181. oSt += '</li>'
  182. osting+=oSt;
  183. }
  184. $("#expertli").html(osting);
  185. }
  186. function formatDate(date) {
  187. var y = date.getFullYear();
  188. var m = date.getMonth() + 1;
  189. m = m < 10 ? '0' + m : m;
  190. var d = date.getDate();
  191. d = d < 10 ? ('0' + d) : d;
  192. return y + '-' + m + '-' + d;
  193. };
  194. function test() {
  195. if($("#demandTitle").val().trim() == "") {
  196. $.MsgBox.Alert('提示', '请填写需求主题');
  197. return;
  198. } else if($("#demandTitle").val().length > 50) {
  199. $.MsgBox.Alert('提示', '需求主题不得超过50个字');
  200. return;
  201. }
  202. if($("#remarkContent").val().trim() == "") {
  203. $.MsgBox.Alert('提示', '请填写需求内容');
  204. return;
  205. } else if($("#remarkContent").val().length > 1000) {
  206. $.MsgBox.Alert('提示', '需求内容不得超过1000个字');
  207. return;
  208. }
  209. if($("#oprovince").text() == "请选择省/直辖市") {
  210. $.MsgBox.Alert('提示', '请选择省/直辖市');
  211. return;
  212. }
  213. if($("#ocity").text() == "请选择城市") {
  214. $.MsgBox.Alert('提示', '请选择城市');
  215. return;
  216. }
  217. if($("#createTime").val() == "") {
  218. $.MsgBox.Alert('提示', '请选择需求有效期');
  219. return;
  220. }
  221. if($("#phone").val().trim() == "") {
  222. $.MsgBox.Alert('提示', '请填写联系电话');
  223. return;
  224. } else if($("#phone").val().length > 50) {
  225. $.MsgBox.Alert('提示', '联系电话不得超过50个字');
  226. return;
  227. }
  228. var len=$("#expertli").find(".selectAdd");
  229. if(len.length==0) {
  230. $.MsgBox.Alert('提示', '请至少选择一个联系人。');
  231. return 0;
  232. }
  233. return 1;
  234. }
  235. /*时间转换成6位传给后台*/
  236. function st6(osr) {
  237. var tim = osr.substring(0, 4) + osr.substring(5, 7) + osr.substring(8, 10);
  238. return tim;
  239. }
  240. $(".posted").click(function() {
  241. if(test()) {
  242. $.MsgBox.Confirm("提示", "确认发布需求?", pDemand);
  243. }
  244. event.stopPropagation();
  245. });
  246. function pDemand() {
  247. $.ajax({
  248. "url": "/ajax/demand",
  249. "type": "POST",
  250. "data": {
  251. "title": $("#demandTitle").val(),
  252. "descp": $("#remarkContent").val(),
  253. "province": $("#oprovince").text(),
  254. "city": $("#ocity").text(),
  255. "cost": $("#spendCost").val(),
  256. "duration": $("#budget").val(),
  257. "invalidDay": st6($("#createTime").val()),
  258. "contactNum": $("#phone").val(),
  259. "creator": $("#expertli").find(".selectAdd").parents('li').attr('id'),
  260. 'orgName': $.cookie("orgName"),
  261. 'source': 'ekexiuWeb'
  262. },
  263. "contentType": "application/x-www-form-urlencoded",
  264. "traditional": true,
  265. "dataType": "json",
  266. "success": function(data) {
  267. if(data.success) {
  268. location.href = "cmp-needList.html";
  269. }
  270. },
  271. "error": function() {
  272. $.MsgBox.Alert('提示', '服务器连接超时');
  273. }
  274. });
  275. }
  276. /*选择用户*/
  277. $("#expertli").on("click","li",function(){
  278. var userL=$("#expertli").find(".selectAdd").length;
  279. console.log($(this).find('.selectNull').hasClass("selectAdd"))
  280. if($(this).find('.selectNull').hasClass("selectAdd")) {
  281. $(this).find('.selectNull').removeClass("selectAdd");
  282. return;
  283. }
  284. $("#linkman").text("");
  285. if(userL ==1) {
  286. $("#linkman").text("最多选择1位联系人");
  287. return;
  288. }
  289. $(this).find('.selectNull').addClass("selectAdd");
  290. });
  291. });