@@ -1,6 +1,7 @@ | |||
using Learun.Application.Base.SystemModule; | |||
using Learun.Application.TwoDevelopment.PersonnelManagement; | |||
using Learun.Util; | |||
using Newtonsoft.Json; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Data; | |||
@@ -186,11 +187,14 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers | |||
/// </summary> | |||
/// <param name="keyValue">主键</param> | |||
/// <returns></returns> | |||
[HttpGet] | |||
[HttpPost] | |||
[AjaxOnly] | |||
public ActionResult DeleteForm(string userNo, string year, string month) | |||
public ActionResult DeleteForm() | |||
{ | |||
gz_AmountsIBLL.DeleteEntity(userNo, Convert.ToInt32(year), Convert.ToInt32(month)); | |||
var userNo = Request.Params["userNo"].ToString().Split(','); | |||
var year = Request.Params["year"].ToString().Split(',').Select(x=>int.Parse(x)).ToArray(); | |||
var month = Request.Params["month"].ToString().Split(',').Select(x => int.Parse(x)).ToArray(); | |||
gz_AmountsIBLL.DeleteEntity(userNo, year, month); | |||
return Success("删除成功!"); | |||
} | |||
/// <summary> | |||
@@ -254,5 +258,76 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers | |||
} | |||
#endregion | |||
#region 导出 | |||
[HttpPost, ValidateInput(false)] | |||
public ActionResult ExportCol(string queryJson) | |||
{ | |||
var paginationobj = new Pagination { page = 1, rows = 10000, sidx = string.Empty, sord = "DESC" }; | |||
var data = gz_AmountsIBLL.GetPageListCol(paginationobj, queryJson, out decimal totalSend).ToList(); | |||
var result = new List<Dictionary<string, string>>(); | |||
if(data.Any()) | |||
{ | |||
foreach (var item in data) | |||
{ | |||
var dic = new Dictionary<string, string>(); | |||
dic.Add("DeptCode", item.DeptCode); | |||
dic.Add("DeptName", item.DeptName); | |||
dic.Add("PersonTypeCode", item.PersonTypeCode); | |||
dic.Add("PersonType", item.PersonType); | |||
dic.Add("UserNo", item.UserNo); | |||
dic.Add("RealName", item.RealName); | |||
dic.Add("SendDate", item.SendDate); | |||
dic.Add("SendCount", item.SendCount); | |||
dic.Add("Year", item.Year.ToString()); | |||
dic.Add("Month", item.Month.ToString()); | |||
dic.Add("TotalPay", item.TotalPay); | |||
dic.Add("TotalDeduction", item.TotalDeduction); | |||
dic.Add("TotalSend", item.TotalSend); | |||
dic.Add("Remark", item.Remark); | |||
result.Add(dic); | |||
} | |||
var str = JsonConvert.SerializeObject(result); | |||
var dt = str.ToTable(); | |||
//设置导出格式 | |||
ExcelConfig excelconfig = new ExcelConfig(); | |||
excelconfig.Title = " 工资数据列表"; | |||
excelconfig.TitleFont = "微软雅黑"; | |||
excelconfig.TitlePoint = 20; | |||
excelconfig.FileName = " 工资数据导出.xls"; | |||
excelconfig.IsAllSizeColumn = true; | |||
//每一列的设置,没有设置的列信息,系统将按datatable中的列名导出 | |||
excelconfig.ColumnEntity = new List<ColumnModel>(); | |||
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "DeptCode", ExcelColumn = "部门代码" }); | |||
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "DeptName", ExcelColumn = "部门名称" }); | |||
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "PersonTypeCode", ExcelColumn = "职员类型代码" }); | |||
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "PersonType", ExcelColumn = "职员类型" }); | |||
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "UserNo", ExcelColumn = "职员代码" }); | |||
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "RealName", ExcelColumn = "职员姓名" }); | |||
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "SendDate", ExcelColumn = "发放时间" }); | |||
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "SendCount", ExcelColumn = "发放次数" }); | |||
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "Year", ExcelColumn = "发放年份" }); | |||
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "Month", ExcelColumn = "发放月份" }); | |||
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "TotalPay", ExcelColumn = "应发合计" }); | |||
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "TotalDeduction", ExcelColumn = "扣款合计" }); | |||
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "TotalSend", ExcelColumn = "实发合计" }); | |||
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "Remark", ExcelColumn = "备注" }); | |||
//调用导出方法 | |||
ExcelHelper.ExcelDownload(dt, excelconfig); | |||
return Success("导出成功!"); | |||
} | |||
else | |||
{ | |||
return Success("无可导出数据!"); | |||
} | |||
} | |||
#endregion | |||
} | |||
} |
@@ -41,6 +41,7 @@ | |||
<a class="btn btn-default" v-on:click="detailShow"><i class="el-icon-edit-outline" style="margin-right:4px"></i>查看</a> | |||
<a class="btn btn-default" v-on:click="del"><i class="el-icon-delete" style="margin-right:4px"></i>删除</a> | |||
<a class="btn btn-default" id="lr_import"><i class="el-icon-download" style="margin-right:4px"></i>导入</a> | |||
<a class="btn btn-default" id="lr_export"><i class="el-icon-arrow-up" style="margin-right:4px"></i>导出</a> | |||
</el-col> | |||
</el-row> | |||
<div style="height:calc(100% - 80px)"> | |||
@@ -134,11 +135,11 @@ | |||
{ prop: 'SendCount', label: '发放次数' }, | |||
{ prop: 'Year', label: '发放年份' }, | |||
{ prop: 'Month', label: '发放月份' }, | |||
{ prop: 'TotalDeduction', label: '扣款合计' }, | |||
{ prop: 'TotalPay', label: '应发合计' }, | |||
{ prop: 'TotalDeduction', label: '扣款合计' }, | |||
{ prop: 'TotalSend', label: '实发合计' }, | |||
{ prop: 'Remark', label: '备注' }, | |||
{ prop: 'Reviewer', label: '审核人' } | |||
//{ prop: 'Reviewer', label: '审核人' } | |||
], | |||
// 导入 | |||
dialogVisible: false, | |||
@@ -178,7 +179,7 @@ | |||
$.ajax({ | |||
type: method, | |||
data, | |||
contentType: false, | |||
//contentType: false, | |||
processData: false, | |||
dataType: "json", | |||
async: false, | |||
@@ -241,25 +242,31 @@ | |||
}, | |||
// 删除 | |||
del() { | |||
if (this.multipleSelection.length != 1) { | |||
this.$message.warning('请选择一条数据进行删除!') | |||
return | |||
} | |||
//let ids = this.multipleSelection.map(e => e.id).toString() | |||
//if (!ids) { | |||
// this.$message.warning('请选择需要删除的数据!') | |||
//if (this.multipleSelection.length != 1) { | |||
// this.$message.warning('请选择一条数据进行删除!') | |||
// return | |||
//} | |||
let ids = this.multipleSelection.map(e => e.UserNo).toString() | |||
let years = this.multipleSelection.map(e => e.Year).toString() | |||
let months = this.multipleSelection.map(e => e.Month).toString() | |||
if (!ids) { | |||
this.$message.warning('请选择需要删除的数据!') | |||
return | |||
} | |||
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', { | |||
confirmButtonText: '确定', | |||
cancelButtonText: '取消', | |||
type: 'warning' | |||
}).then(async () => { | |||
let res = await this.NetRequest('/PersonnelManagement/Gz_Amounts/DeleteForm', $.param({ userNo: this.multipleSelection[0].UserNo, year: this.multipleSelection[0].Year, month: this.multipleSelection[0].Month }), 'get') | |||
let res = await this.NetRequest('/PersonnelManagement/Gz_Amounts/DeleteForm', $.param({ userNo: ids, year: years, month: months })) | |||
if (res) { | |||
this.$message.success('删除成功!') | |||
} | |||
}) | |||
}, | |||
//导出 | |||
export() { | |||
}, | |||
// 导入回调 | |||
importCallback() { | |||
@@ -85,6 +85,16 @@ var bootstrap = function ($, learun) { | |||
} | |||
}); | |||
}); | |||
$("#lr_export").on("click", function () { | |||
var p = {}; | |||
learun.download({ | |||
method: "POST", | |||
url: top.$.rootUrl + '/PersonnelManagement/Gz_Amounts/ExportCol', | |||
param: { | |||
queryJson: JSON.stringify(p) | |||
} | |||
}); | |||
}); | |||
}, | |||
initGird: function () { | |||
$('#gridtable').lrAuthorizeJfGrid({ | |||
@@ -285,6 +285,25 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||
} | |||
} | |||
} | |||
public void DeleteEntity(string[] userNo, int[] year, int[] month) | |||
{ | |||
try | |||
{ | |||
gz_AmountsService.DeleteEntity(userNo, year, month); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowBusinessException(ex); | |||
} | |||
} | |||
} | |||
#endregion | |||
} | |||
@@ -47,6 +47,8 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||
void DeleteEntity(string keyValue); | |||
void DeleteEntity(string userNo, int year, int month); | |||
void DeleteEntity(string[] userNo, int[] year, int[] month); | |||
/// <summary> | |||
/// 保存实体数据(新增、修改) | |||
/// </summary> | |||
@@ -180,6 +180,40 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||
} | |||
} | |||
} | |||
public void DeleteEntity(string[] userNo, int[] year, int[] month) | |||
{ | |||
try | |||
{ | |||
this.BaseRepository("CollegeMIS").BeginTrans(); | |||
if(userNo.Any()) | |||
{ | |||
for (int i = 0; i < userNo.Length; i++) | |||
{ | |||
var u = userNo[i]; | |||
var y = year[i]; | |||
var m = month[i]; | |||
this.BaseRepository("CollegeMIS").Delete<Gz_AmountsEntity>(t => t.UserNo == u && t.Year == y && t.Month == m); | |||
} | |||
this.BaseRepository("CollegeMIS").Commit(); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
this.BaseRepository("CollegeMIS").Rollback(); | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowServiceException(ex); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 保存实体数据(新增、修改) | |||
/// <param name="keyValue">主键</param> | |||
@@ -262,6 +296,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||
foreach (var item in cols) | |||
{ | |||
var val = dr[item].ToString().Trim(); | |||
var cvb = decimal.TryParse(val, out var amount); | |||
if (!val.IsEmpty()) | |||
{ | |||
var itemEntity = itemList.FirstOrDefault(x => x.Name == item); | |||
@@ -274,13 +309,16 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||
dbm.UserNo = u; | |||
dbm.ItemId = itemEntity.Id; | |||
dbm.OriVal = val; | |||
if (decimal.TryParse(val, out var amount)) | |||
if (cvb) | |||
{ | |||
dbm.Amount = amount; | |||
} | |||
if (!hlist.Any(x => x.Year == dbm.Year && x.Month == dbm.Month && x.UserNo == dbm.UserNo && x.ItemId == dbm.ItemId)) | |||
{ | |||
addEntity.Add(dbm); | |||
if ((cvb && amount > 0) || !cvb) | |||
{ | |||
addEntity.Add(dbm); | |||
} | |||
} | |||
} | |||
else | |||
@@ -470,7 +508,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||
year = yearStart; | |||
month = monthStart; | |||
return GetAmountsCols(new Pagination { rows=30,page=1}, yearStart, monthStart, yearEnd, monthEnd, userNo, string.Empty, string.Empty, out var total); | |||
return GetAmountsCols(new Pagination { rows = 30, page = 1 }, yearStart, monthStart, yearEnd, monthEnd, userNo, string.Empty, string.Empty, out var total); | |||
} | |||
catch (Exception ex) | |||
@@ -567,17 +605,17 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||
var rs = ls.Skip(skip).Take(pagination.rows).ToList(); | |||
if(rs.Any()) | |||
if (rs.Any()) | |||
{ | |||
var usrNos = rs.Select(x => x.UserNo).ToArray(); | |||
var user = this.BaseRepository("CollegeMIS").FindList<EmpInfoEntity>(x => usrNos.Contains(x.EmpNo)).ToList(); | |||
var user = this.BaseRepository("CollegeMIS").FindList<EmpInfoEntity>(x => usrNos.Contains(x.EmpNo)).ToList(); | |||
var deptId = user.Select(x => x.F_DepartmentId).ToArray(); | |||
var depts = this.BaseRepository().FindList<DepartmentEntity>(x => deptId.Contains(x.F_DepartmentId)).ToList(); | |||
var emps = user.Join(depts, a => a.F_DepartmentId, b => b.F_DepartmentId, (a, b) => new { a.EmpNo, a.F_DepartmentId, b.F_FullName }).ToList(); | |||
foreach (var item in rs) | |||
{ | |||
var emp = emps.FirstOrDefault(x => x.EmpNo == item.UserNo); | |||
if(emp!=null) | |||
if (emp != null) | |||
{ | |||
item.DeptCode = emp.F_DepartmentId; | |||
item.DeptName = emp.F_FullName; | |||