From 43e57aa5422b1033372e6efb1da5e0103e1c9fc8 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Wed, 15 May 2024 14:56:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Services/CommonServices.cs | 90 ++++++++++++++----- .../Ghre/Ghre_ExamPaperServices.cs | 6 +- 2 files changed, 71 insertions(+), 25 deletions(-) diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index 909f01f5..ff5b4c90 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -275,34 +275,76 @@ public partial class CommonServices : BaseServices>, ICommon result.JM_PageControlT1.Toolbar = DbAccess.QueryList(sql); #region 特殊处理 - if (param.menuName == "F_QuestionBank") + var toolbar = new Toolbar(); + var index = -1; + switch (param.menuName) { - var toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault(); - if (toolbar != null) { toolbar.fnKey = "TBD1YN"; } - toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "UpdateYN").FirstOrDefault(); - if (toolbar != null) { toolbar.fnKey = "TBD2YN"; } - } - else if (param.menuName == "F_ExamPaperDraft") - { - var toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault(); - if (toolbar != null) { toolbar.fnKey = "TBD1YN"; } - toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "UpdateYN").FirstOrDefault(); - if (toolbar != null) { toolbar.fnKey = "TBD2YN"; } - toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "DetailYN").FirstOrDefault(); - if (toolbar != null) { toolbar.fnKey = "TBD3YN"; } + case "F_QuestionBank": + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault(); + if (toolbar != null) { toolbar.fnKey = "TBD1YN"; } + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "UpdateYN").FirstOrDefault(); + if (toolbar != null) { toolbar.fnKey = "TBD2YN"; } + break; + case "F_ExamPaperDraft": + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault(); + if (toolbar != null) { toolbar.fnKey = "TBD1YN"; } + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "UpdateYN").FirstOrDefault(); + if (toolbar != null) { toolbar.fnKey = "TBD2YN"; } + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "DetailYN").FirstOrDefault(); + if (toolbar != null) { toolbar.fnKey = "TBD3YN"; } + + index = result.JM_PageControlT1.Toolbar.FindIndex(x => x.fnKey == "TBD1YN"); + result.JM_PageControlT1.Toolbar.Insert(index + 1, new Toolbar() + { + display = true, + fnKey = "TBD4YN", + fnTitle = "发布", + fnType = "table", + icon = "ghr-publish", + position = "left" + }); + + break; + case "F_ExamPaperReleased": + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "DetailYN").FirstOrDefault(); + if (toolbar != null) { toolbar.fnKey = "TBD3YN"; } - var index = result.JM_PageControlT1.Toolbar.FindIndex(x => x.fnKey == "TBD1YN"); - result.JM_PageControlT1.Toolbar.Insert(index + 1, new Toolbar() - { - display = true, - fnKey = "TBD4YN", - fnTitle = "已发布", - fnType = "table", - icon = "ghr-publish", - position = "left" - }); + result.JM_PageControlT1.Toolbar.Insert(0, new Toolbar() + { + display = true, + fnKey = "TBD4YN", + fnTitle = "取消发布", + fnType = "table", + icon = "ghr-publish", + position = "left" + }); + result.JM_PageControlT1.Toolbar.Insert(1, new Toolbar() + { + display = true, + fnKey = "TBD5YN", + fnTitle = "停用", + fnType = "table", + icon = "ghr-publish", + position = "left" + }); + + break; + case "F_ExamPaperDisabled": + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "DetailYN").FirstOrDefault(); + if (toolbar != null) { toolbar.fnKey = "TBD3YN"; } + result.JM_PageControlT1.Toolbar.Insert(0, new Toolbar() + { + display = true, + fnKey = "TBD4YN", + fnTitle = "启用", + fnType = "table", + icon = "ghr-publish", + position = "left" + }); + break; } + #endregion #endregion diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs index 579ad288..1617fa15 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs @@ -673,6 +673,8 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';"); public async Task UpdateStatus(long[] ids, string status) { + if (status != "Released" && status != "Disabled" && status != "Draft") + throw new Exception("无效的状态"); HttpRequest request = UserContext.Context.Request; var api = request.Path.ObjToString().TrimEnd('/').ToLower(); @@ -689,7 +691,7 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';"); BasePoco ent = entity; ent.UpdateIP = ip; ent.UpdateProg = api; - if ((status == "Released" && entity.Status == "Draft") || status == "Disabled" && entity.Status == "Released") + if (status == "Released" || status == "Disabled" || status == "Draft") { entity.Status = status; entities.Add(entity); @@ -699,6 +701,8 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';"); var result = await BaseDal.Update(entities); if (status == "Released") return ServiceResult.OprateSuccess("发布成功!"); + else if (status == "Draft") + return ServiceResult.OprateSuccess("取消发布成功!"); else return ServiceResult.OprateSuccess("停用成功!");