97 lines
3.3 KiB
C#
97 lines
3.3 KiB
C#
using YLErp.Modules.QuoteFileModule;
|
|
|
|
namespace YLErp.Web.Controllers
|
|
{
|
|
public class QuoteFileController : BaseController
|
|
{
|
|
private readonly IWebHostEnvironment _hostEnviroment;
|
|
public QuoteFileController(IWebHostEnvironment hostEnviroment)
|
|
{
|
|
_hostEnviroment = hostEnviroment ?? throw new ArgumentNullException(nameof(hostEnviroment));
|
|
}
|
|
[MyAuthorize("报价管理-报价文件管理")]
|
|
public ActionResult List()
|
|
{
|
|
return View();
|
|
}
|
|
/// <summary>
|
|
/// 报价文件管理查询
|
|
/// </summary>
|
|
/// <param name="req"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public JsonResult Query(QouteFileQueryRequest req)
|
|
{
|
|
var result = new QuoteFileService(CurUser, _hostEnviroment.WebRootPath).SearchList(req);
|
|
return Json(result);
|
|
}
|
|
/// <summary>
|
|
/// 上传报价文件管理
|
|
/// </summary>
|
|
/// <param name="req"></param>
|
|
/// <returns></returns>
|
|
public JsonResult AddQuoteFile(QuoteFileUpRequest req)
|
|
{
|
|
if (Request.Form.Files.Count == 0)
|
|
{
|
|
return JsonError("上传文件不存在");
|
|
}
|
|
|
|
var file = Request.Form.Files[0];
|
|
|
|
if (!System.IO.Path.GetExtension(file.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return JsonError("请上传Excel(.xlsx)格式文件");
|
|
}
|
|
using var stream = file.OpenReadStream();
|
|
new QuoteFileService(CurUser, _hostEnviroment.WebRootPath).AddQuoteFile(req, stream, file.FileName, out var TotalNum, out var SuccessNum);
|
|
return Json(new
|
|
{
|
|
success = true,
|
|
totalNum = TotalNum,
|
|
successNum = SuccessNum,
|
|
});
|
|
}
|
|
/// <summary>
|
|
/// 上传覆盖报价文件管理
|
|
/// </summary>
|
|
/// <param name="req"></param>
|
|
/// <returns></returns>
|
|
public JsonResult UploadQuoteFile(string enid)
|
|
{
|
|
var quoteFileId= DecryptInt(enid);
|
|
if (Request.Form.Files.Count == 0)
|
|
{
|
|
return JsonError("上传文件不存在");
|
|
}
|
|
|
|
var file = Request.Form.Files[0];
|
|
|
|
if (!System.IO.Path.GetExtension(file.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return JsonError("请上传Excel(.xlsx)格式文件");
|
|
}
|
|
using var stream = file.OpenReadStream();
|
|
new QuoteFileService(CurUser, _hostEnviroment.WebRootPath).UploadQuoteFile(quoteFileId, stream, file.FileName, out var TotalNum, out var SuccessNum);
|
|
|
|
return Json(new
|
|
{
|
|
success = true,
|
|
totalNum = TotalNum,
|
|
successNum = SuccessNum,
|
|
});
|
|
}
|
|
/// <summary>
|
|
/// 删除报价文件
|
|
/// </summary>
|
|
/// <param name="quoteFileId"></param>
|
|
/// <returns></returns>
|
|
public JsonResult DelteQuoteFile(string enid)
|
|
{
|
|
var quoteFileId = DecryptInt(enid);
|
|
new QuoteFileService(CurUser, _hostEnviroment.WebRootPath).DelteQuoteFile(quoteFileId);
|
|
return JsonSuccess("删除成功");
|
|
}
|
|
}
|
|
}
|