#region AddChargeItem [AllRights] //use in edit page public IActionResult AddChargeJob(string id) { var vm = Wtm.CreateVM<tbl_ma_dbn_jobListVM>(); vm.SearcherMode = ListVMSearchModeEnum.Custom1; ViewBag.tbl_ma_dbn_mstrID = id; vm.Searcher.outstanding_bill = true; return PartialView(vm); } /// <summary> /// Add Charge Job by select the payterms /// </summary> /// <param name="IDs">tbl_ma_payterm ID</param> /// <param name="tbl_ma_dbn_mstrID"></param> /// <returns></returns> [AllRights] [HttpPost] public IActionResult AddChargeJob(string[] IDs, Guid tbl_ma_dbn_mstrID) { var vm = Wtm.CreateVM<tbl_ma_dbn_jobVM>(); vm.tbl_ma_dbn_mstrID = tbl_ma_dbn_mstrID; vm.IDs = IDs; vm.DoAdd(); if (!ModelState.IsValid) { return BadRequest("Payterm Error"); } else { return Ok(); } } #endregion
//use in edit page
#region
[AllRights]
[HttpPost]
//use in edit page
public IActionResult DeleteChargeJob(string[] ids)
{
foreach (var id in ids)
{
var vm = Wtm.CreateVM<tbl_ma_dbn_jobVM>(id);
vm.DoDelete();
}
return Ok();
}
#endregion
## View
@model PIS.ViewModel.MA.tbl_ma_dbn_jobVMs.tbl_ma_dbn_jobListVM @inject IStringLocalizer<Program> Localizer; <wt:form method="post"> <wt:searchpanel vm="@Model" reset-btn="false" grid-id="jobList"> <wt:row items-per-row="ItemsPerRowEnum.Two"> <wt:textbox field="Searcher.job_no" label-text="Job No." required="true" search-url="/MA/tbl_ma_job_hdr/GetJob" change-func="search" /> </wt:row> </wt:searchpanel> <wt:grid vm="@Model" url="/MA/tbl_ma_dbn_job/Search" height="300" id="jobList" auto-search ="false"/> <wt:row align="AlignEnum.Right"> <wt:submitbutton click="onSubmit();" /> <wt:closebutton /> </wt:row> </wt:form> <script> function search() { $("#[email protected]").trigger('click'); pis.render(); } </script> <script> var table = layui.table; function onSubmit() { var checkStatus = table.checkStatus("jobList"); var ids = []; var amt = 0; $(checkStatus.data).each(function (i, o) { ids.push(o.ID); amt = o.pay_term_amt; }); if (ids.length < 1) { layer.msg("Please select one job"); return false; } if (ids.length > 1) { layer.msg("Please only select one job"); return false; } $.ajax({ type: "post", url: "/MA/tbl_ma_dbn_mstr/AddChargeJob", data: { IDs: ids, tbl_ma_dbn_mstrID: '@ViewBag.tbl_ma_dbn_mstrID', }, success: function (result) { layer.closeAll('page'); layui.table.reload('[email protected]_ma_dbn_mstrID'); //刷新表格 $("#tbl_ma_dbn_mstrVM_Entity_mai_amt_1").val(amt); $("#tbl_ma_dbn_mstrVM_Entity_mai_amt_1").change(); }, error: function (req, status, error) { console.log(status + " - " + error); } }); } </script>
标签:tables,ma,form,dbn,layui,vm,ids,tbl,var From: https://www.cnblogs.com/axblog/p/17482536.html