@page
@model xxtsoft.Web.Entry.Pages.sysadmins.kh.kh_outModel
@{
Layout = "_LayoutAdmin";
ViewData["Title"] = "考评计算";
}
<div class="layui-fluid">
<blockquote class="layui-elem-quote">
1、按部门导出考核评定表
</blockquote>
</div>
<div class="layui-fluid paneltop20">
<div class="layui-card layui-padding-3">
<form id="form1" name="form1" class="layui-form" method="post" onsubmit="disableButton(this)">
<div class="layui-form-item">
<div class="layui-input-block">
<button type="submit" class="layui-btn layui-btn-lg layui-bg-red" asp-page-handler="Submit">导出考核表Word</button>
</div>
</div>
</form>
</div>
</div>
<script>
layui.config({
base: '/layui/' // 静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(function () {
var $ = layui.jquery;
var form = layui.form;
var layer = layui.layer;
});
function disableButton(form) {
const button = form.querySelector('button[type="submit"]');
button.disabled = true;
button.classList.add('layui-btn-disabled');
button.textContent = '导出中,成功会有弹出框示提示...'; // 可选:更改按钮文本
}
</script>using Aspose.Words;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Data;
using System.Security.Claims;
using System.Text;
using xxtsoft.Common;
namespace xxtsoft.Web.Entry.Pages.sysadmins.kh
{
//登录判断
[Authorize]
public class kh_outModel : PageModel
{
public string loginxm = "";//登录用户名
public string loginRole = "";//登录角色
public string loginSid = "";//登录id
private readonly SqlSugar.ISqlSugarClient _db;
public kh_outModel(SqlSugar.ISqlSugarClient db)
{
this._db = db;
}
public void OnGet()
{
#region 登录信息
loginxm = User.Identity.Name;
loginRole = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Role)?.Value;
loginSid = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid)?.Value;
#endregion
}
public IActionResult OnPost()
{
StringBuilder sb = new StringBuilder();
DataTable dt = _db.Ado.GetDataTable("select * from pub_member where groupid<>3 and xld<>1 order by id asc");
if (dt.Rows.Count > 0)
{
var cs = CommHelper.GuanLian("kh_cs", "1", "cs");
foreach (DataRow dr in dt.Rows)
{
string teaid = dr["id"].ToString();
string bmzz = dr["bmzz"].ToString();
sb.AppendLine("<style>");
sb.AppendLine(".tbl {");
sb.AppendLine(" border-collapse: collapse;");
sb.AppendLine(" border-spacing: 0px; ");
sb.AppendLine("}");
sb.AppendLine(" .tbl td { ");
sb.AppendLine(" border:1px solid #000;");
sb.AppendLine(" padding:5px;");
sb.AppendLine(" font:\"Verdana\" , \"微软雅黑\" , \"宋体\" ,\"Helvetica\" , \"sans-serif\";");
sb.AppendLine(" }");
sb.AppendLine(" ");
sb.AppendLine("</style>");
sb.Append("<br><h2><center>浙江建设职业技术学院<br />");
if (bmzz.ToLower() == "true")
{
sb.Append("" + DateTime.Now.Year + "年第" + cs + "次中层干部日常考核登记表</center></h2>");
}
else
{
sb.Append("" + DateTime.Now.Year + "年第" + cs + "次其他管理教辅人员日常考核登记表</center></h2>");
}
DataTable dt1 = _db.Ado.GetDataTable("select * from kh_djb where teaid=" + teaid);
string fggz = "";
string mb = "";
string xjd = "";
string gzjy = "";
if (dt1.Rows.Count > 0)
{
fggz = dt1.Rows[0]["fj"].ToString();
mb = dt1.Rows[0]["mb"].ToString();
xjd = dt1.Rows[0]["xjd"].ToString();
gzjy = dt1.Rows[0]["gzjy"].ToString();
}
dt1.Dispose();
sb.AppendLine(" <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"650\" align=\"center\">");
sb.AppendLine(" <tr><td width=\"35%\" height=\"35\"><b>姓 名:</b> " + dr["truename"] + "</td>");
sb.AppendLine(" <td> <b>部门及职务:</b> " + dr["bm"] + " " + FunHelper.CutString(dr["zw"].ToString(), 20) + "</td></tr>");
sb.AppendLine(" <tr><td colspan=\"2\" height=\"35\"> <b>从事或分管工作: </b> " + fggz + "</td></tr>");
sb.AppendLine("</table>");
sb.AppendLine("");
sb.AppendLine(" <table width=\"650\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" class=\"tbl\">");
sb.AppendLine(" <tr>");
sb.AppendLine(" <td width=\"110\" align=\"center\"><p align=\"center\">");
sb.AppendLine(" 本阶段目标<br>");
sb.AppendLine(" 完成情况 </p> </td>");
sb.AppendLine(" <td width=\"540\" height=\"140\" valign=\"top\" style=\"font-size:15px;line-height:24px;\"> <p align=\"left\">条目式列举工作业绩、亮点、年度重点工作推进情况: <br />" + FunHelper.CutString(mb, 280).Replace("\n", "<br>") + "</td>");
sb.AppendLine(" </tr>");
sb.AppendLine(" <tr>");
sb.AppendLine(" <td align=\"center\"><p align=\"center\">");
sb.AppendLine(" 下阶段工作计划</p> </td>");
sb.AppendLine(" <td height=\"120\" valign=\"top\" style=\"font-size:15px;line-height:24px;\">" + FunHelper.CutString(xjd, 280).Replace("\n", "<br>") + "</td>");
sb.AppendLine(" </tr>");
sb.AppendLine(" <tr>");
sb.AppendLine(" <td width=\"110\" align=\"center\"><p align=\"center\">需要学校解决的工作困难以及对学校工作的意见建议 </p></td>");
sb.AppendLine(" <td height=\"120\" valign=\"top\" style=\"font-size:15px;line-height:24px;\">" + FunHelper.CutString(gzjy, 280).Replace("\n", "<br>") + "</td>");
sb.AppendLine(" </tr>");
sb.AppendLine(" <tr>");
sb.AppendLine(" <td align=\"center\"><p align=\"center\">阶段考核等次评定意见 </p></td>");
sb.AppendLine(" <td height=\"80\">");
#region 评价
StringBuilder sb2 = new StringBuilder();
dt1 = _db.Ado.GetDataTable("select * from kh_pjb where teaid=" + teaid + " and pj='好'");
if (dt1.Rows.Count > 0)
{
sb2.Append("【好】");
foreach (DataRow dr1 in dt1.Rows)
{
sb2.Append(CommHelper.GuanLian("pub_member", dr1["pjrid"].ToString(), "truename") + " ");
}
}
dt1.Dispose();
dt1 = _db.Ado.GetDataTable("select * from kh_pjb where teaid=" + teaid + " and pj='较好'");
if (dt1.Rows.Count > 0)
{
sb2.Append("【较好】");
foreach (DataRow dr1 in dt1.Rows)
{
sb2.Append(CommHelper.GuanLian("pub_member", dr1["pjrid"].ToString(), "truename") + " ");
}
}
dt1.Dispose();
dt1 = _db.Ado.GetDataTable("select * from kh_pjb where teaid=" + teaid + " and pj='一般'");
if (dt1.Rows.Count > 0)
{
sb2.Append("【一般】");
foreach (DataRow dr1 in dt1.Rows)
{
sb2.Append(CommHelper.GuanLian("pub_member", dr1["pjrid"].ToString(), "truename") + " ");
}
}
dt1.Dispose();
dt1 = _db.Ado.GetDataTable("select * from kh_pjb where teaid=" + teaid + " and pj='较差'");
if (dt1.Rows.Count > 0)
{
sb2.Append("【较差】");
foreach (DataRow dr1 in dt1.Rows)
{
sb2.Append(CommHelper.GuanLian("pub_member", dr1["pjrid"].ToString(), "truename") + " ");
}
}
dt1.Dispose();
#endregion
sb.AppendLine(" <p>" + sb2.ToString() + "</p>");
sb.AppendLine(" <p align=\"right\">");
sb.AppendLine(" 签名(盖章): 年 月 日 </p></td>");
sb.AppendLine(" </tr>");
sb.AppendLine(" <tr>");
sb.AppendLine(" <td align=\"center\"><p align=\"center\">本人 <br />");
sb.AppendLine(" 意见 </p></td>");
sb.AppendLine(" <td height=\"50\">");
sb.AppendLine(" <p align=\"left\"> </p>");
sb.AppendLine(" <p align=\"right\">签名: 年 月 日 </p></td>");
sb.AppendLine(" </tr>");
sb.AppendLine(" <tr>");
sb.AppendLine(" <td align=\"center\"><p align=\"center\">备注 </p></td>");
sb.AppendLine(" <td height=\"50\"><p> </p>");
sb.AppendLine(" <p> </p></td>");
sb.AppendLine(" </tr>");
sb.AppendLine("</table>");
//string bmzz = dr["bmzz"].ToString();
//if (bmzz.ToLower() == "true")
//{
// sb.AppendLine("<h2>");
// sb.AppendLine(" <center>1111浙江建设职业技术学院<br /><u> " + DateTime.Now.Year.ToString() + " </u>年第<u> " + cs + " </u>次中层干部日常考核登记表</center>");
// sb.AppendLine("</h2>");
// sb.AppendLine("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"600\" align=\"center\">");
// sb.AppendLine(" <tr>");
// sb.AppendLine(" <td height=\"35\"><b>姓名:</b>" + dr["truename"].ToString() + "</td>");
// sb.AppendLine(" <td> <b>部门及职务:</b>" + dr["bm"].ToString() + " " + dr["zw"].ToString() + "</td>");
// sb.AppendLine(" </tr>");
// sb.AppendLine(" <tr>");
// sb.AppendLine(" <td colspan=\"2\" height=\"35\"> <b>从事或分管工作: </b>" + dr["zccsfg"].ToString() + "</td>");
// sb.AppendLine(" </tr>");
// sb.AppendLine("</table>");
//}
//else
//{
// sb.AppendLine("<h2>");
// sb.AppendLine(" <center>111浙江建设职业技术学院<br /><u> " + DateTime.Now.Year.ToString() + " </u>年第<u> " + cs + " </u>次其他管理教辅人员日常考核登记表</center>");
// sb.AppendLine("</h2>");
// sb.AppendLine("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"600\" align=\"center\">");
// sb.AppendLine(" <tr>");
// sb.AppendLine(" <td height=\"35\"><b>姓名:</b>" + dr["truename"].ToString() + "</td>");
// sb.AppendLine(" <td> <b>部门及岗位:</b>" + dr["bm"].ToString() + " " + dr["zw"].ToString() + "</td>");
// sb.AppendLine(" </tr>");
// sb.AppendLine("</table>");
//}
//sb.AppendLine("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\" width=\"650\" align=\"center\">");
//sb.AppendLine(" <tr>");
//sb.AppendLine(" <td width=\"96\">");
//sb.AppendLine(" <p align=\"center\">");
//sb.AppendLine(" 阶段 <br />");
//sb.AppendLine(" 目标 <br />");
//sb.AppendLine(" 完成 <br />");
//sb.AppendLine(" 情况 </p>");
//sb.AppendLine(" </td>");
//sb.AppendLine(" <td width=\"509\" valign=\"top\" style=\"line-height:25px;padding-left:5px;\">");
//sb.AppendLine(" <p align=\"left\">条目式列举工作业绩、亮点、年度重点工作推进情况: <br />");
//sb.AppendLine(" <p>" + CommHelper.GuanLian("kh_djb", dr["khid"].ToString(), "mb").Replace("\n", "<br>") + "</p>");
//sb.AppendLine(" </td>");
//sb.AppendLine(" </tr>");
//sb.AppendLine(" <tr>");
//sb.AppendLine(" <td width=\"96\">");
//sb.AppendLine(" <p align=\"center\">需要 <br />学校 <br />解决 <br />的工 <br />作困 <br />难以 <br />及对 <br />学校 <br />工作 <br />的意 <br />见建 <br />议 </p>");
//sb.AppendLine(" </td>");
//sb.AppendLine(" <td width=\"509\" valign=\"top\">");
//sb.AppendLine(" <p>" + CommHelper.GuanLian("kh_djb", dr["khid"].ToString(), "gzjy").Replace("\n", "<br>") + "</p>");
//sb.AppendLine(" </td>");
//sb.AppendLine(" </tr>");
//sb.AppendLine(" <tr>");
//sb.AppendLine(" <td width=\"96\">");
//sb.AppendLine(" <p align=\"center\">阶段 <br />");
//sb.AppendLine(" 考核 <br />");
//sb.AppendLine(" 等次 <br />");
//sb.AppendLine(" 评定 <br />");
//sb.AppendLine(" 意见 </p>");
//sb.AppendLine(" </td>");
//sb.AppendLine(" <td width=\"509\">");
//sb.AppendLine(" <p> "+ dr["pj"].ToString() + "</p>");
//sb.AppendLine(" <p align=\"right\">");
//DateTime dd =DateTime.Parse(dr["cdt"].ToString());
//sb.AppendLine(" 签名(盖章):" + CommHelper.GuanLian("pub_member", dr["pjrid"].ToString(), "truename") + " "+dd.Year.ToString()+" 年 "+dd.Month+" 月 "+dd.Day+" 日 </p>");
//sb.AppendLine(" </td>");
//sb.AppendLine(" </tr>");
//sb.AppendLine(" <tr>");
//sb.AppendLine(" <td width=\"96\">");
//sb.AppendLine(" <p align=\"center\">本人 <br />");
//sb.AppendLine(" 意见 </p>");
//sb.AppendLine(" </td>");
//sb.AppendLine(" <td width=\"509\">");
//sb.AppendLine(" <p align=\"left\"> </p>");
//sb.AppendLine(" <p align=\"right\">签名: 年 月 日 </p>");
//sb.AppendLine(" </td>");
//sb.AppendLine(" </tr>");
//sb.AppendLine(" <tr>");
//sb.AppendLine(" <td width=\"96\">");
//sb.AppendLine(" <p align=\"center\">备注 </p>");
//sb.AppendLine(" </td>");
//sb.AppendLine(" <td width=\"509\">");
//sb.AppendLine(" <p> " + dr["bz"].ToString() + "</p>");
//sb.AppendLine(" </td>");
//sb.AppendLine(" </tr>");
//sb.AppendLine("</table>");
sb.AppendLine("<div style=\"page-break-before:always\"> </div>");
}
}
// 2. 使用 Aspose.Words 生成 Word 文档
var document = new Document();
var builder = new DocumentBuilder(document);
builder.InsertHtml(sb.ToString());
// 3. 导出为 Word 文档并返回到客户端
using (var stream = new MemoryStream())
{
document.Save(stream, SaveFormat.Docx);
return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "评定表" + DateTime.Now.ToString("MMdd") + ".docx");
}
}
}
}