portal html css js resource

cmp-demandPublish.js 8.0KB

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