$(document).ready(function() { $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent"); $(".workmenu>ul>li.demandIcon").addClass("nowLi"); var id = $.cookie('orgId'); if(id == "" || id == null || id == "null"){ location.href = "cmp-settled-log.html"; } resMgr(id); demandList(true,10, 1); /*查询企业认证状态*/ function companyAuthentState() { $.ajax({ url: '/ajax/org/authStatus', type: "GET", timeout: 10000, dataType: "json", data: { "id": id }, beforeSend: function() {}, success: function(data, textState) { if(data.success) { console.log(data); if(data.data == 3) { $("#companyDemandList").show(); } else { $("#identityState").show(); } } }, error: function(XMLHttpRequest, textStats, errorThrown) { $.MsgBox.Alert('提示', '服务器请求失败') } }) } companyAuthentState(); function st6This(osr) { var tim = osr.substring(0, 4) + osr.substring(5, 7) + osr.substring(8, 10) ; return tim; } var seleTime = '

请设置需求的有效期:

'+ '
'+ ''+ ''+ ''+ ''+ '
'+ ''+ '
' $("#cmpneedList").on("click",".delayThis",function(){//延期 var dataId=$(this).parents("li").find(".urlHref").attr("data-id"); $(".blackcover2").fadeIn(); var btnOk='' $(".mb_btnOk").remove(); $("#promotGt").prepend(btnOk); $(".modelContain").show(); $("body").addClass("modelOpen"); $(".mb-listR").remove(); $("#promotTh").append(seleTime);//时间选择器 var a = new Date(); var c = a.getFullYear() + "-" + (Number(a.getMonth()) + 1) + "-" + (Number(a.getDate()) + 1); $(".mb-listR .form_datetime").datetimepicker({ language: 'ch', format: 'yyyy-mm-dd', weekStart: 0, todayBtn: false, autoclose: 1, todayHighlight: 1, startView: 2, minView: 2, forceParse: 0, startDate: getNowFormatDate(), oflag: 1, startDate: c, }); $(".mb-listR .form_datetime").val(getNowFormatDate(1)); $(".mb_btnOkset").on("click", function() { var delayTime=$(".mb-listR .form_datetime .fColor").val(); $.ajax({ "url": "/ajax/demand/defer", "type": "POST", "async": true, "data":{ "id":dataId, "day":st6This(delayTime) }, "success": function(data) { if(data.success && data.data) { $(".blackcover2").fadeOut(); $(".modelContain").hide(); $("body").removeClass("modelOpen"); demandList(true,10,1); } } }); }) }) $("#cmpneedList").on("click",".overThis",function(){//完成 var dataId=$(this).parents("li").find(".urlHref").attr("data-id"); $.MsgBox.Confirm("提示", "确认该需求已解决?",function(){ $.ajax({ "url": "/ajax/demand/over", "type": "POST", "async": true, "data":{ "id":dataId, }, "success": function(data) { if(data.success && data.data) { console.log(data); $(".madiaEdit").remove(); demandList(true,10,1); } } }); }); }) $("#cmpneedList").on("click",".closeThis",function(){//关闭 var dataId=$(this).parents("li").find(".urlHref").attr("data-id"); $.MsgBox.Confirm("提示", "确认要关闭该需求?",function(){ $.ajax({ "url": "/ajax/demand/close", "type": "POST", "async": true, "data":{ "id":dataId }, "success": function(data) { if(data.success && data.data) { $(".madiaEdit").remove(); demandList(true,10, 1); } } }); }); }) $("#cmpneedList").on("click",".updateThis",function(){//修改 var dataId=$(this).parents("li").find(".urlHref").attr("data-id"); window.open("needIssue.html?demandId="+dataId) }) $(".issueSpan").click(function(e){ UnauthorizedUser() e.preventDefault(); }) function UnauthorizedUser() { $.ajax({ url: "/ajax/professor/qaOrgAuth", type: "GET", timeout: 10000, dataType: "json", async:"true", data: { "orgId": $.cookie("orgId"), "orgAuth": 1 }, success: function(data, textState) { if(data.success) { if(data.data.length==0) { $.MsgBox.Confirm("提示", "请至少认证1位员工
选择认证员工作为联系人,代表企业与对方沟通。", function(){ location.href="cmp-staffList.html"; }); $("#mb_btn_no").val("稍后再说"); $("#mb_btn_ok").val("去认证"); }else if(data.data.length>0){ window.open("cmp-demandPublish.html") } } }, error: function(XMLHttpRequest, textStats, errorThrown) { $.MsgBox.Alert('提示', '服务器请求失败') } }) } /*需求列表*/ function demandList(isbind, pageSize, pageNo) { $.ajax({ url: "/ajax/demand/pq/org", type: "GET", timeout: 10000, dataType: "json", traditional: true, data: { "state":[0,1,2,3], 'oname':$.cookie('orgName'), "pageNo": pageNo, "pageSize": pageSize }, "beforeSend": function() { $("#cmpneedList").append(''); }, success: function(data, textState) { if(data.success) { console.log(data); $("#cmpneedList").html(""); var $info = data.data.data; if($info.length > 0){ for(var i = 0; i < $info.length; i++) { var liStr=$("
  • ").appendTo("#cmpneedList"); demandHtml($info[i],liStr); userFun($info[i].creator,liStr); } if($info.length != 0) { if(isbind == true) { $(".tcdPageCode").createPage({ pageCount: Math.ceil(data.data.total / pageSize), current: data.data.data.pageNo, backFn: function(p) { $("#cmpneedList").html(""); demandList(false,10, p); document.body.scrollTop = document.documentElement.scrollTop = 0; } }); } } }else{ $("#cmpneedList").parent().find(".nodatabox").removeClass("displayNone") } } $(".loading").remove(); }, error: function() { } }) } function demandHtml($data,liStr) { var sowU=""; if($data.pageViews!=0){ sowU='
  • 浏览量 '+$data.pageViews+'
  • ' } var statusU=""; var dateGap = delayDay($data.invalidDay); if($data.state==1 && dateGap=="1"){ statusU='
  • 即将于 '+TimeTr($data.invalidDay)+' 过期
  • ' } if($data.state==0){ statusU='
  • 已于 '+TimeTr($data.invalidDay)+' 过期
  • ' }else if($data.state==2){ statusU='
  • 已于 '+TimeTr($data.modifyTime)+' 完成
  • ' }else if($data.state==3){ statusU='
  • 已于 '+TimeTr($data.modifyTime)+' 关闭
  • ' } var closStr='',pdRight=""; if($data.state==1 && dateGap=="0"){ pdRight="padding-right:80px"; closStr += '' }else if($data.state==0 || ($data.state==1 && dateGap=="1")){ pdRight="padding-right:260px"; closStr += '' } var strCon=''; strCon+='' strCon+='

    '+ $data.title +'

    ' strCon+='' strCon+='
    '+closStr $(strCon).appendTo(liStr); } function userFun(id,$listItem) { $.ajax({ "url": "/ajax/professor/editBaseInfo/" + id, "type": "get", "async": true, "data":{ "id":id }, "success": function(data) { if(data.success && data.data) { $listItem.find(".creator").text('联系人 ' +data.data.name); } }, "error": function() { $.MsgBox.Alert('提示', '链接服务器超时') } }); } function delayDay(startTime){ var dateToday = new Date(); var dateInvalid = new Date(); dateInvalid.setFullYear(parseInt(startTime.substring(0, 4))); dateInvalid.setMonth(parseInt(startTime.substring(4, 6)) - 1); dateInvalid.setDate(parseInt(startTime.substring(6, 8))); var dateGap = Math.abs(dateToday.getTime() - dateInvalid.getTime()); var ifDelay="0"; if(dateGap < 604800000){ ifDelay="1"; } return ifDelay; } })