- 根据本次实际进入删除审批的记录数返回删除结果 - 未提交、新增已拒绝直接删除时提示“删除成功” - 已生效记录进入删除审批时提示“已经提交删除审批” - 批量混合删除时提示部分记录已提交删除审批
160 lines
6.3 KiB
C#
160 lines
6.3 KiB
C#
using YLErp.Modules.ClientModule;
|
|
|
|
|
|
namespace YLErp.Web.Controllers
|
|
{
|
|
public class clientblackController : BaseController
|
|
{
|
|
public static List<SelectListItem> GetClientBlackStates()
|
|
{
|
|
return new List<SelectListItem>
|
|
{
|
|
new() { Text = client_black.未提交, Value = client_black.未提交 },
|
|
new() { Text = client_black.新增审批中, Value = client_black.新增审批中 },
|
|
new() { Text = client_black.新增已拒绝, Value = client_black.新增已拒绝 },
|
|
new() { Text = client_black.已加入, Value = client_black.已加入 },
|
|
new() { Text = client_black.删除审批中, Value = client_black.删除审批中 },
|
|
new() { Text = client_black.删除已拒绝, Value = client_black.删除已拒绝 }
|
|
};
|
|
}
|
|
|
|
[MyAuthorize("客户管理-黑名单客户")]
|
|
public ActionResult clientblacklist()
|
|
{
|
|
return View();
|
|
}
|
|
[HttpPost]
|
|
public JsonResult clientblacklistQuery(ClientBlackReq req)
|
|
{
|
|
var sList = new ClientBlackService(CurUser).SearchList(req);
|
|
return Json(sList);
|
|
}
|
|
|
|
public ActionResult clientblackAdd(int id = 0)
|
|
{
|
|
var clientBlack = DataCacheProvider.GetClientBlackDataSource().GetData(id) ?? new client_black();
|
|
return View(clientBlack);
|
|
}
|
|
public JsonResult ClientBlackAddJson(client_black client, bool checkStatus)
|
|
{
|
|
if (string.IsNullOrEmpty(client.Name))
|
|
{
|
|
return JsonError("客户名称不能为空");
|
|
}
|
|
new ClientBlackService(CurUser).AddClientBlack(new[] { client }, checkStatus);
|
|
return JsonSuccess("", client);
|
|
}
|
|
/// <summary>
|
|
/// 导入黑名单
|
|
/// </summary>
|
|
public ActionResult UploadSettlementBill(IFormFile file, bool checkStatus)
|
|
{
|
|
try
|
|
{
|
|
if (file == null || string.IsNullOrWhiteSpace(file.FileName))
|
|
{
|
|
return JsonError("未获取上传文件");
|
|
}
|
|
var fileExtension = Path.GetExtension(file.FileName);
|
|
using var inputStream = file.OpenReadStream();
|
|
new ClientBlackService(CurUser).ImportxlsxClientBlack(inputStream, checkStatus);
|
|
return JsonSuccess("导入成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogFactory.GetLogger("导入黑名单").Error("导入黑名单出错", ex);
|
|
return JsonError(ex.Messages());
|
|
}
|
|
}
|
|
public ActionResult DeleteClientBlack(string ids)
|
|
{
|
|
try
|
|
{
|
|
var datalist = ids.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
|
|
var service = new ClientBlackService(CurUser);
|
|
var submitRemovalApprovalCount = service.DeleteClientBlack(datalist);
|
|
var message = submitRemovalApprovalCount == 0
|
|
? "删除成功"
|
|
: submitRemovalApprovalCount == datalist.Count
|
|
? "已经提交删除审批!"
|
|
: "删除成功,部分记录已提交删除审批!";
|
|
return JsonSuccess(message);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return JsonError(ex.GetBaseException().Message);
|
|
}
|
|
}
|
|
|
|
[MyAuthorize("客户管理-黑名单审批")]
|
|
public ActionResult clientblackApproval()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpPost, MyAuthorize("客户管理-黑名单审批")]
|
|
public JsonResult clientblackApprovalQuery(ClientBlackReq req)
|
|
{
|
|
return Json(new ClientBlackService(CurUser).ClientBlackApprovalQuery(req));
|
|
}
|
|
|
|
[HttpPost, MyAuthorize("客户管理-黑名单客户提交审批")]
|
|
public JsonResult clientblackSubmit(string ids)
|
|
{
|
|
var idList = ids.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
|
|
new ClientBlackService(CurUser).SubmitApprovalClientBlack(idList);
|
|
return JsonSuccess("提交审批成功");
|
|
}
|
|
|
|
[HttpPost, MyAuthorize("客户管理-黑名单客户撤回提交审批")]
|
|
public JsonResult clientblackWithdraw(string ids)
|
|
{
|
|
var idList = ids.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
|
|
new ClientBlackService(CurUser).WithdrawApprovalClientBlack(idList, out var withdrawCount, out var msg);
|
|
if (withdrawCount == 0)
|
|
{
|
|
return JsonError(string.IsNullOrWhiteSpace(msg)
|
|
? "所选记录当前状态无法撤回审批"
|
|
: $"以下记录已进入后续节点无法撤回:{msg}");
|
|
}
|
|
return JsonSuccess("撤回审批成功" + (string.IsNullOrWhiteSpace(msg) ? "" : $",以下记录已进入后续节点无法撤回:{msg}"));
|
|
}
|
|
|
|
[HttpPost, MyAuthorize("客户管理-黑名单审批")]
|
|
public JsonResult Auditclientblack(ClientBlackAuditReq req)
|
|
{
|
|
new ClientBlackService(CurUser).AuditClientBlack(req);
|
|
return JsonSuccess("审批成功");
|
|
}
|
|
|
|
[MyAuthorize("客户管理-黑名单审批")]
|
|
public ActionResult clientblackView(string enid)
|
|
{
|
|
var id = DataProtectHelper.DecryptInt(enid);
|
|
var item = clientDB.client_black.FirstOrDefault(x => x.id == id);
|
|
return View(item);
|
|
}
|
|
|
|
[MyAuthorize("客户管理-黑名单客户")]
|
|
public ActionResult clientblackLogList(int id)
|
|
{
|
|
var logs = clientDB.client_blacklog.Where(x => x.ClientBlackId == id)
|
|
.OrderByDescending(x => x.id)
|
|
.ToList();
|
|
return View(logs);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 黑名单导出
|
|
/// </summary>
|
|
[HttpPost]
|
|
public object ExportClientBlack(ClientBlackReq req)
|
|
{
|
|
var bytes = new ClientBlackService(CurUser).ExportClientBlack(req);
|
|
|
|
return File(bytes, xlsxMimeType, $"黑名单导出-{DateTime.Now:yyyy-MM-dd}.xlsx");
|
|
}
|
|
}
|
|
}
|