Skip to content

Commit

Permalink
整理代码
Browse files Browse the repository at this point in the history
  • Loading branch information
renyh committed Oct 19, 2022
1 parent 358c884 commit c05caf9
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 23 deletions.
3 changes: 3 additions & 0 deletions dp2weixin.service/SearchBiblioResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class BiblioDetailResult : ApiResult
{
public string biblioPath { get; set; }

// 书目记录时间戳
public string Timestamp { get; set; }

public List<BiblioItem> itemList { get; set; }

//public string biblioName { get; set; }
Expand Down
38 changes: 23 additions & 15 deletions dp2weixin.service/dp2WeiXinService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7700,6 +7700,7 @@ public BiblioDetailResult GetBiblioDetail(LoginInfo loginInfo,
string strBiblioInfo = "";
string imgHtml = "";// 封面图像
string biblioInfo = "";
string timestamp = "";
if (format == "summary")
{
nRet = this.GetSummaryAndImgHtml(lib,
Expand Down Expand Up @@ -7732,6 +7733,7 @@ public BiblioDetailResult GetBiblioDetail(LoginInfo loginInfo,
showCover,
out strBiblioInfo,
out imgHtml,
out timestamp,
out strError);
if (nRet == -1 || nRet == 0)
{
Expand Down Expand Up @@ -7777,13 +7779,11 @@ public BiblioDetailResult GetBiblioDetail(LoginInfo loginInfo,
result.errorInfo = strError;
return result;
}
// 有好书推荐的权限
if (nHasRights == 1)
{
workerUserName = activeUser.userName;
}

if (workerUserName != "")
{
string returnUrl = "/Biblio/Index";
if (from == "detail")
returnUrl = "/Biblio/Detail?biblioPath=" + HttpUtility.UrlEncode(biblioPath);
Expand All @@ -7795,22 +7795,23 @@ public BiblioDetailResult GetBiblioDetail(LoginInfo loginInfo,
// + "&returnUrl=" + HttpUtility.UrlEncode(returnUrl);
recommendBtn = "<button class='mui-btn mui-btn-default' "
+ " onclick=\"gotoUrl('" + recommPath + "')\">好书推荐</button>";
}

//

// todo 修改书目跳转的url
// 工作人员都出现编辑书目和删除书目的按钮
{
// 修改书目跳转的url
string biblioEditUrl = "/Biblio/BiblioEdit?biblioPath=" + HttpUtility.UrlEncode(biblioPath);
recommendBtn += "&nbsp;&nbsp;<button class='mui-btn mui-btn-default' "
+ " onclick=\"gotoUrl('"+ biblioEditUrl+"')\">修改书目</button>";

+ " onclick=\"gotoUrl('" + biblioEditUrl + "')\">修改书目</button>";

// todo 删除书目
// 删除书目
string deletefun = "deleteBiblio('" + biblioPath + "','" + timestamp + "')";
recommendBtn += "&nbsp;&nbsp;<button class='mui-btn mui-btn-default' "
+ " onclick=\"alert('尚未实现')\">删除书目</button>";

+ " onclick=\"" + deletefun + "\">删除书目</button>";
}

if (string.IsNullOrEmpty(recommendBtn) ==false)
recommendBtn = "<div class='btnRow'>" + recommendBtn + "</div>";
}
}

// 书目信息上方为 table+好书推荐按钮
Expand Down Expand Up @@ -7878,11 +7879,13 @@ private int GetTableAndImgHtml(LibEntity lib,
bool showCover,
out string table,
out string coverImgHtml,
out string timestamp, //2022/10/17增加时间戳
out string strError)
{
strError = "";
table = "";
coverImgHtml = "";
timestamp = "";

List<string> dataList = null;
int nRet = this.GetBiblioInfo(lib,
Expand All @@ -7895,6 +7898,7 @@ private int GetTableAndImgHtml(LibEntity lib,
return nRet;

string xml = dataList[0];
timestamp = dataList[1];//2022/10/17取出时间戳
XmlDocument dom = new XmlDocument();
try
{
Expand Down Expand Up @@ -8640,6 +8644,7 @@ public int SetBiblio(string loginUserName,
int nRet = 0;
outputBiblioPath = "";
outputTimestamp = "";
string style = ""; //删除记录时,传whenChildEmpty

// 调dp2接口时,使用的dp2帐户
LoginInfo loginInfo = GetLoginInfo(loginUserName, loginUserType);// new LoginInfo(loginUserName, false);
Expand Down Expand Up @@ -8705,7 +8710,8 @@ 1010 ǂachi
}
else if (biblio.Action == C_Action_delete)
{
// todo
// 书目没有下级记录时,才可以删除。
style = "whenChildEmpty";
}
else
{
Expand Down Expand Up @@ -8741,6 +8747,7 @@ public class Record
// 本接口目前仅支持处理一条记录
Entity entity = new Entity();
entity.Action = biblio.Action;
entity.Style = style;

//新记录
Record newRecord = new Record();
Expand Down Expand Up @@ -8773,10 +8780,11 @@ public class Record
entities);
try
{
string connName = C_ConnPrefix_Myself + libId; //"<myself>:";
// 连接
MessageConnection connection = this._channels.GetConnectionTaskAsync(
this._dp2MServerUrl,
"").Result;
connName).Result; //注意这里connName传的标记表示使用本图书馆的weixin_xxx帐户,这样在配置权限时,把setbiblio权限配置在weixin_xxx。
//发起请求
SetInfoResult result = connection.SetInfoTaskAsync(
lib.capoUserName,
Expand All @@ -8785,7 +8793,7 @@ public class Record
cancel_token).Result;
if (result.Value == -1)
{
strError = "图书馆 " + lib.libName + " 的保存书目出错:" + result.ErrorInfo;
strError = "为图书馆'" + lib.libName + "'设置书目出错:" + result.ErrorInfo;
return -1;
}

Expand Down
76 changes: 75 additions & 1 deletion dp2weixinP2P/Scripts/weixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ function getDetail(libId, recPath, obj, from,biblioName) {
itemTables += "<tr>"
+ "<td class='label' colspan='2'>"
//+ "<button class='mui-btn' onclick='gotoEditItem(\"" + recPath + "\",\"" + biblioName + "\")'>编辑</button>"
+ "<button class='mui-btn' onclick='deleteItem(\"" + worker + "\",\"" + libId + "\",\"" + recPath + "\",\"" + record.recPath + "\",\"" + tempBarcode + "\")'>删除</button>"
+ "<button class='mui-btn' onclick='deleteItem(\"" + worker + "\",\"" + libId + "\",\"" + recPath + "\",\"" + record.recPath + "\",\"" + tempBarcode + "\")'>删除册</button>"
+"</td > "
+ "</tr>";
}
Expand Down Expand Up @@ -414,6 +414,80 @@ function getDetail(libId, recPath, obj, from,biblioName) {
//return "";
}

//删除书目
function deleteBiblio(biblioPath, biblioTimestamp) {

var gnl = confirm("您确认要删除书目[" + biblioPath + "]吗?");
if (gnl == false) {
return false;
}

//alert("1");
// 图书馆
var libId = getLibId();//$("#selLib").val();
if (libId == "" || libId == null) {
alert("您尚未选择图书馆。");
return;
}

var weixinId = $("#weixinId").text();
if (weixinId == null || weixinId == "") {
alert("weixinId参数为空");
return;
}

// 时间戳不能为空
if (biblioTimestamp == null || biblioTimestamp == "") {
alert("删除书目时timestamp参数不能为空");
return;
}

// biblio path不能为空
if (biblioPath == null || biblioPath == "") {
alert("书目路径不能为空");
return;
}

// 登录帐户和类型
var loginUserName = getLoginUserName();
var loginUserType = getLoginUserType();

// web api
var url = "/api2/BiblioApi/SetBiblio?loginUserName=" + encodeURIComponent(loginUserName)
+ "&loginUserType=" + loginUserType
+ "&weixinId=" + weixinId
+ "&libId=" + libId

//alert(url);
sendAjaxRequest(url, "POST",
function (result) {
// 关闭等待层
hideMaskLayer();


if (result.errorCode == -1) {
alert(result.errorInfo);
return;
}

alert("删除书目成功。");

},
function (xhq, textStatus, errorThrown) {
// 关闭等待层
hideMaskLayer();
alert(errorThrown);
},
{
BiblioPath: biblioPath,
Action: "delete",
Fields: "",
Timestamp: biblioTimestamp
}
);

}

//预约
function reservation(obj, barcode, style) {
//alert("走到reservation()");
Expand Down
4 changes: 2 additions & 2 deletions dp2weixinP2P/Views/Biblio/Detail.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function loadJs(sid, jsurl, callback) {
var biblioName = $("#_biblioName").text();
if (biblioName != null && biblioName != "") {
expand("d1", 1);
expand("d1", 0); //2022/10/17 修改:当新增册的情况也让书目展开,与从册编辑界面查看详情进入保持一致的状态。
}
}
});
Expand Down Expand Up @@ -450,7 +450,7 @@ else
<input id='batchNo' type="text" class="mui-input mui-input-clear" value="" placeholder="请输入 批次号">
</div>
<div class="mui-content-padded">
<button id='btn' class="mui-btn mui-btn-block mui-btn-primary" onclick="saveItem()">保存</button>
<button id='btn' class="mui-btn mui-btn-block mui-btn-primary" onclick="saveItem()">新增册</button>
</div>
</div>
}
Expand Down
10 changes: 8 additions & 2 deletions dp2weixinP2P/Views/Biblio/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,14 @@ function loadJs(sid, jsurl, callback) {
</table>
</div>
<div style="padding:10px">
(简单检索默认以"前方一致"匹配)&nbsp;<a id="searchType" href="javascript:void(0)" onclick="changeType()">高级检索</a>
&nbsp;<a id="" href="javascript:void(0)" onclick="gotoBiblioEdit()">新增书目</a>
(简单检索默认以"前方一致"匹配)&nbsp;<a id="searchType" href="javascript:void(0)" onclick="changeType()">高级检索</a>

<!--如果是馆员帐户,才出现新增书目-->
@if (ViewBag.Worker != null && ViewBag.Worker != "")
{
@Html.Raw("&nbsp;<a id='' href='javascript: void(0)' onclick='gotoBiblioEdit()'>新增书目</a>");
}


</div>
<div id="divResult">
Expand Down
2 changes: 1 addition & 1 deletion dp2weixinP2P/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<script src='@Url.Content("~/Scripts/jquery-3.5.1.js?a=2")'></script>
<script src='@Url.Content("~/Scripts/jquery-ui-1.12.1.js?a=2")'></script>
<script src="@Url.Content("~/Scripts/knockout-2.2.0.js?a=2")"></script>
<script src="@Url.Content("~/Scripts/weixin.js?test=1")"></script>
<script src="@Url.Content("~/Scripts/weixin.js?test=3")"></script>
<script src="@Url.Content("~/Scripts/layer.js?a=2")"></script>

<link href="@Url.Content("~/Content/layer.css?a=2")" rel="stylesheet">
Expand Down
2 changes: 1 addition & 1 deletion dp2weixinP2P/Views/Shared/_LayoutEmpty.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<script src='@Url.Content("~/Scripts/jquery-3.5.1.js?a=5")'></script>
<script src='@Url.Content("~/Scripts/jquery-ui-1.12.1.js?a=5")'></script>
<script src="@Url.Content("~/Scripts/knockout-2.2.0.js?a=5")"></script>
<script src="@Url.Content("~/Scripts/weixin.js?a=1")"></script>
<script src="@Url.Content("~/Scripts/weixin.js?a=3")"></script>
<script src="@Url.Content("~/Scripts/jweixin-1.0.0.js?a=5")"></script>
<script src="@Url.Content("~/Scripts/layer.js?a=5")"></script>

Expand Down
2 changes: 1 addition & 1 deletion dp2weixinP2P/Views/Shared/_LayoutManager.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<script src='@Url.Content("~/Scripts/jquery-ui-1.12.1.js?a=1")'></script>
<script src="@Url.Content("~/Scripts/knockout-2.2.0.js")"></script>
<script src="@Url.Content("~/Scripts/weixin.js?test=1")"></script>
<script src="@Url.Content("~/Scripts/weixin.js?test=3")"></script>
<script src="@Url.Content("~/Scripts/jweixin-1.0.0.js")"></script>

@RenderSection("style", required: false)
Expand Down

0 comments on commit c05caf9

Please sign in to comment.