$(document).ready(function () {
$(".onlogin .headnavbtn li.mywork").addClass("navcurrent");
$(".workmenu>ul>li:contains('成果')").addClass("nowLi");
loginStatus(); //判断个人是否登录
valUser();
var userid = $.cookie("userid");
var resourceId;
/*资源列表查询*/
function getRecourceMe(n, isbind, num) {
var resourceNameVa = $("#patentName").val();
var $info = {};
$info.pageSize = 10;
if (resourceNameVa != "") {
$info.key = resourceNameVa;
}
$info.pageNo = n;
$info.status = ['1', '2'];
$info.id = userid
$.ajax({ //获取全部非专数据
// /ajax/resResult/pq/creator
"url": "/ajax/resResult/pq/researcher",
"type": "GET",
"success": function (data) {
console.log(data)
if (data.success) {
$("#patentList").html("");
if (num == 1) {
if (data.data.data.length == 0) {
$("#noresource").removeClass("displayNone");
$(".noContip").text("您还未发布任何非专利成果");
return;
} else {
$("#noresource").addClass("displayNone");
}
} else {
if (data.data.data.length == 0) {
$("#noresource").removeClass("displayNone");
$(".noContip").text("没有符合该搜索条件的内容");
return;
} else {
$("#noresource").addClass("displayNone");
}
}
resourceHtml(data.data.data);
if (isbind == true) {
$(".tcdPageCode").createPage({
pageCount: Math.ceil(data.data.total / data.data.pageSize),
current: data.data.pageNo,
backFn: function (p) {
getRecourceMe(p, false);
}
});
}
}
},
"data": $info,
dataType: "json",
traditional: true,
'error': function () {
$.MsgBox.Alert('提示', '服务器连接超时!');
}
});
}
getRecourceMe(1, true, 1);
function resourceHtml($data) {
console.log($data)
for (var i = 0; i < $data.length; i++) {
var oTime, pageview = "",
draftLable = "",
oHtml, oLi = '',
gl = ''
mg = '';
if ($data[i].pic)
var imgSrc = "/data/researchResult" + $data[i].pic.split(",")[0];
if ($data[i].status == '2') {
$('.deteleThis3').css('display', 'none')
oTime = "修改于 " + TimeTr($data[i].modifyTime);
draftLable = '草稿';
oHtml = "unPatentIssue.html";
oLi = "class='draftList'"
mg = '
' + oTime + '' + draftLable + ''
} else if ($data[i].status == '1') {
oHtml = "unPatentShow.html"
gl = '取消关联'
}
var oStr = '' +
'' +
'' +
'' +
'
' + $data[i].name + '
' +
'
' +
'
' +
'
' +
'' +
'' +
''
var $oStr = $(oStr);
$("#patentList").append($oStr);
if ($data[i].status == '1') {
proList($data[i].id, $oStr, $data[i].orgId,$data[i].subject,$data[i].department || '')
console.log($data[i])
}
$oStr.find(".editThis").attr("data-state", $data[i].status);
}
}
function proList(par, $pa, p3,subject,department) {
$.ajax({
"url": "/ajax/resResult/researcher",
"type": "GET",
"data": {
id: par
},
"success": function (data) {
if (data.success) {
var $da = data.data
if ($da.length) {
var arr = [];
var dom = [];
for (var i = 0; i < $da.length; i++) {
arr.push($da[i].name)
dom.push($da[i].id)
}
$pa.find('.hu2').append('研究者:' + arr.join(',') + '')
$pa.find('.hu2').append('应用领域:' + subject + '')
$pa.find('.hu2>li').css({'float':'none' , 'margin-bottom':'0px'})
$('.itemListBolck .itemListCon .madiaInfo').css('padding-top','0px')
orgname(p3, $pa)
console.log(p3)
if (p3){
}
$.ajax({
'url': '/ajax/resResult/selectbyidandPid',
'type': 'get',
'data': {
pid: userid,
id: par
},
'success': function (res) {
var $info = res.data
for (var i = 0; i < $info.length; i++) {
if ($info[i].name == '######' || $info[i].status == 0) {
$pa.find('.deteleThis3').css('display', 'none')
} else {
$pa.find('.deteleThis2').css('display', 'none')
$pa.find('.editThis').css('display', 'none')
}
}
}
})
}
}
},
"data": {
"id": par
},
dataType: "json",
'error': function () {
$.MsgBox.Alert('提示', '服务器连接超时!');
}
});
}
function orgname(par, $pa) {
$.ajax({
"url": "ajax/org/" + par,
"type": "GET",
"success": function (data) {
console.log(data)
if (data.success) {
$pa.find('.hu1').append('所属机构:' + data.data.name+ '')
}
},
"data": {
"id": par
},
dataType: "json",
'error': function () {
$.MsgBox.Alert('提示', '服务器连接超时!');
}
});
}
/*点击修改跳转修改页面*/
$("#patentList").on("click", ".editThis", function () {
location.href = "unPatentIssue.html?id=" + $(this).attr("data-id") + "&flag=" + $(this).attr("data-state");
})
/*点击删除跳转修改页面*/
$("#patentList").on("click", ".deteleThis2", function () {
resourceId = $(this).attr("data-id");
$.MsgBox.Confirm("提示", "确认删除该成果?", deleResource);
})
//点击取消关联
$("#patentList").on("click", ".deteleThis3", function () {
resourceId = $(this).attr("data-id");
$.MsgBox.Confirm("提示", "确认取消该成果?", cancel);
})
//取消关联函数
function cancel() {
$.ajax({
'url': '/ajax/resResult/deleteContact',
'type': 'post',
'data': {
id: resourceId,
uid: userid
},
'success': function (res) {
console.log(res)
getRecourceMe(1, true);
}
})
}
/*删除函数*/
function deleResource() {
$.ajax({
"url": "/ajax/resResult/delete",
"type": "POST",
"success": function (data) {
if (data.success) {
getRecourceMe(1, true);
}
},
"data": {
"id": resourceId
},
"beforeSend": function () {},
"contentType": "application/x-www-form-urlencoded",
dataType: "json"
});
}
/*输入资源名称限制字数*/
$("#patentList").bind({
keyup: function () {
if ($(this).val().length > 30) {
$(this).val($(this).val().substr(0, 30));
}
}
});
/*点击搜索*/
$(".searchSpan").click(function () {
$(".tcdPageCode").remove();
$(".aboutRes").append('');
getRecourceMe(1, true);
})
})