在Sharepoint中默认创建的调查列表系统只允许答复一次,再次答复将报错误信息,这对最终用户而言是非常不友好的体验,当然你也可以在调查设置中的常规设置中设置允许多次答复,这样就会有错误提示信息,但有时实际业务场景只允许最终用户答复一次,不允许再次答复,因此非常有必要改进系统的重复答复错误提示信息,本文给出一种在调查列表中自定义的不允许再次答复提示的处理方法,通过Sharepoint列表Web服务和自定义的调查列表页面实现。如果允许多次答复可以按下图设置:

如果不允许多次答复的,系统默认的报错信息如下图:

通过自定义的报错提示如下图:

核心的JS代码如下:
$(document).ready(function() {
var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>
<soapenv:Body>
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
<listName>食堂管理</listName>
<viewFields>
<ViewFields>
<FieldRef Name='ID' />
</ViewFields>
</viewFields>
<query>
<Query>
<Where>
<Eq>
<FieldRef Name='Author' />
<Value Type='Integer'>
<UserID Type='Integer' />
</Value>
</Eq>
</Where>
</Query>
</query>
<queryOptions>
<QueryOptions>
<RowLimit>1</RowLimit>
</QueryOptions>
</queryOptions>
</GetListItems>
</soapenv:Body>
</soapenv:Envelope>";
$.ajax({
url: "http://portal.contoso.uat/jx/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
async: false,
complete: processResult,
contentType: "text/xml; charset="utf-8""
});
});
function OpenDg() {
$( "#dialog-message" ).dialog({
modal: true,
buttons: {
确定: function() {
$( this ).dialog( "close" );
}
}
});
};
function processResult(xData, status) {
if(xData.responseText.indexOf("<z:row") <0)
{
$("#stgl").attr("href","/JX/Lists/Survey6/NewForm.aspx?Source=http://portal.contoso.uat/jx/SitePages/Home.html");
return true;
}
else
{
$("#stgl").click(function(){
$('#dialog-message').empty();
$('#dialog-message').append("<p>对不起,您已填过<b>食堂管理</b>调查,不允许再次答复此调查!</p>");
OpenDg();
return false;
});
}
}
|
本博客为软件人生原创,欢迎转载,转载请标明出处:http://www.cnblogs.com/nbpowerboy/p/3655773.html 。演绎或用于商业目的,但是必须保留本文的署名软件人生(包含链接)。如您有任何疑问或者授权方面的协商,请给我留言。 |