using System; using EC.App.AutoWeight.MonthPlan; using learun.util; using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; namespace EC.Web.Areas.AutoWeight.Controllers { /// /// 汽车衡 /// Copyright (c) 2019-present 汽车衡 /// 创建人:lxc /// 日 期: 2020-11-10 21:49:48 /// 描 述: 月计划 aw_MonthPlan /// [Area("AutoWeight")] public class MonthPlanController : MvcControllerBase { private readonly MonthPlanIBll _bll; public MonthPlanController(MonthPlanIBll bll) { _bll = bll; } #region 视图功能 /// /// 视图 /// /// [HttpGet] public IActionResult Index() { return View(); } /// /// 视图 /// /// [HttpGet] public IActionResult Form() { return View(); } #endregion 视图功能 #region 获取数据 /// /// 获取表单数据 /// /// 主键 /// [HttpGet] [AjaxOnly] public async Task GetForm(string keyValue) { var monthPlanEntity = await _bll.GetEntity(keyValue); var jsonData = new { aw_MonthPlan = monthPlanEntity }; return Success(jsonData); } /// /// 获取主表aw_MonthPlan的所有列表数据 /// /// 查询参数,json字串 /// [HttpGet] [AjaxOnly] public async Task GetList(string queryJson) { var list = await _bll.GetList(queryJson); return Success(list); } /// /// 获取主表aw_MonthPlan的分页列表数据 /// /// 分页参数 /// 查询参数,json字串 /// [HttpGet] [AjaxOnly] public async Task GetPageList(string pagination, string queryJson) { var pageObj = pagination.ToObject(); var queryParam = queryJson.ToJObject(); if (queryParam["CompanyId"].IsEmpty()) queryParam["CompanyId"] = CurrentUser().Result.F_CompanyId; var list = await _bll.GetPageList(pageObj, queryParam); var jsonData = new { rows = list, pageObj.total, pageObj.page, pageObj.records }; return Success(jsonData); } /// /// 获取树形数据 /// /// [HttpGet] [AjaxOnly] public async Task GetTree(string companyId, string supplierId) { if (companyId == null) throw new ArgumentNullException(nameof(companyId)); var data = await _bll.GetTree(companyId, supplierId); return this.Success(data); } #endregion 获取数据 #region 提交数据 /// /// 删除表单数据 /// /// /// [HttpPost] [AjaxOnly] public async Task DeleteForm(string keyValue) { await _bll.Delete(keyValue); return SuccessInfo("删除成功!"); } /// /// 新增,更新 /// /// 主键值 /// aw_MonthPlan实体数据 /// [HttpPost] [AjaxOnly] public async Task SaveForm(string keyValue, MonthPlanEntity entity) { var res = await _bll.SaveEntity(keyValue, entity); return Success("保存成功!", res); } [HttpPost] [AjaxOnly] public async Task ReCountWeight(string keyValue) { if (keyValue == null) throw new ArgumentNullException(nameof(keyValue)); await _bll.ReCountWeight(keyValue); return SuccessInfo("更新成功!"); } #endregion 提交数据 } }