mirror of https://github.com/EasyAbp/EShop.git
42 changed files with 560 additions and 60 deletions
@ -0,0 +1,19 @@ |
|||||
|
@page |
||||
|
@using Microsoft.AspNetCore.Mvc.Localization |
||||
|
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal; |
||||
|
@using EasyAbp.EShop.Plugins.Coupons.Localization |
||||
|
@inject IHtmlLocalizer<CouponsResource> L |
||||
|
@model EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplateScope.CreateModalModel |
||||
|
@{ |
||||
|
Layout = null; |
||||
|
} |
||||
|
<abp-dynamic-form abp-model="ViewModel" data-ajaxForm="true" asp-page="CreateModal"> |
||||
|
<abp-modal> |
||||
|
<abp-modal-header title="@L["CreateCouponTemplate"].Value"></abp-modal-header> |
||||
|
<abp-modal-body> |
||||
|
<abp-input asp-for="CouponTemplateId" /> |
||||
|
<abp-form-content/> |
||||
|
</abp-modal-body> |
||||
|
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer> |
||||
|
</abp-modal> |
||||
|
</abp-dynamic-form> |
||||
@ -0,0 +1,44 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using EasyAbp.EShop.Plugins.Coupons.CouponTemplates; |
||||
|
using EasyAbp.EShop.Plugins.Coupons.CouponTemplates.Dtos; |
||||
|
using EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplate.ViewModels; |
||||
|
using EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplateScope.ViewModels; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplateScope |
||||
|
{ |
||||
|
public class CreateModalModel : CouponsPageModel |
||||
|
{ |
||||
|
[HiddenInput] |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public Guid CouponTemplateId { get; set; } |
||||
|
|
||||
|
[BindProperty] |
||||
|
public CreateEditCouponTemplateScopeViewModel ViewModel { get; set; } |
||||
|
|
||||
|
private readonly ICouponTemplateAppService _service; |
||||
|
|
||||
|
public CreateModalModel(ICouponTemplateAppService service) |
||||
|
{ |
||||
|
_service = service; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IActionResult> OnPostAsync() |
||||
|
{ |
||||
|
var dto = await _service.GetAsync(CouponTemplateId); |
||||
|
|
||||
|
var updateDto = |
||||
|
ObjectMapper.Map<CouponTemplateDto, CreateUpdateCouponTemplateDto>(dto); |
||||
|
|
||||
|
var createScopeDto = |
||||
|
ObjectMapper.Map<CreateEditCouponTemplateScopeViewModel, CreateUpdateCouponTemplateScopeDto>(ViewModel); |
||||
|
|
||||
|
updateDto.Scopes.Add(createScopeDto); |
||||
|
|
||||
|
await _service.UpdateAsync(CouponTemplateId, updateDto); |
||||
|
|
||||
|
return NoContent(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
@page |
||||
|
@using EasyAbp.EShop.Plugins.Coupons.Localization |
||||
|
@using Microsoft.AspNetCore.Mvc.Localization |
||||
|
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal; |
||||
|
@inject IHtmlLocalizer<CouponsResource> L |
||||
|
@model EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplateScope.EditModalModel |
||||
|
@{ |
||||
|
Layout = null; |
||||
|
} |
||||
|
<abp-dynamic-form abp-model="ViewModel" data-ajaxForm="true" asp-page="EditModal"> |
||||
|
<abp-modal> |
||||
|
<abp-modal-header title="@L["EditCouponTemplateScope"].Value"></abp-modal-header> |
||||
|
<abp-modal-body> |
||||
|
<abp-input asp-for="CouponTemplateId" /> |
||||
|
<abp-input asp-for="CouponTemplateScopeId" /> |
||||
|
<abp-form-content /> |
||||
|
</abp-modal-body> |
||||
|
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer> |
||||
|
</abp-modal> |
||||
|
</abp-dynamic-form> |
||||
@ -0,0 +1,59 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using EasyAbp.EShop.Plugins.Coupons.CouponTemplates; |
||||
|
using EasyAbp.EShop.Plugins.Coupons.CouponTemplates.Dtos; |
||||
|
using EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplate.ViewModels; |
||||
|
using EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplateScope.ViewModels; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplateScope |
||||
|
{ |
||||
|
public class EditModalModel : CouponsPageModel |
||||
|
{ |
||||
|
[HiddenInput] |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public Guid CouponTemplateId { get; set; } |
||||
|
|
||||
|
[HiddenInput] |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public Guid CouponTemplateScopeId { get; set; } |
||||
|
|
||||
|
[BindProperty] |
||||
|
public CreateEditCouponTemplateScopeViewModel ViewModel { get; set; } |
||||
|
|
||||
|
private readonly ICouponTemplateAppService _service; |
||||
|
|
||||
|
public EditModalModel(ICouponTemplateAppService service) |
||||
|
{ |
||||
|
_service = service; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task OnGetAsync() |
||||
|
{ |
||||
|
var dto = await _service.GetAsync(CouponTemplateId); |
||||
|
|
||||
|
ViewModel = |
||||
|
ObjectMapper.Map<CouponTemplateScopeDto, CreateEditCouponTemplateScopeViewModel>( |
||||
|
dto.Scopes.First(x => x.Id == CouponTemplateScopeId)); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IActionResult> OnPostAsync() |
||||
|
{ |
||||
|
var dto = await _service.GetAsync(CouponTemplateId); |
||||
|
|
||||
|
dto.Scopes.RemoveAll(x => x.Id == CouponTemplateScopeId); |
||||
|
|
||||
|
var updateDto = |
||||
|
ObjectMapper.Map<CouponTemplateDto, CreateUpdateCouponTemplateDto>(dto); |
||||
|
|
||||
|
updateDto.Scopes.Add(ObjectMapper |
||||
|
.Map<CreateEditCouponTemplateScopeViewModel, CreateUpdateCouponTemplateScopeDto>(ViewModel)); |
||||
|
|
||||
|
await _service.UpdateAsync(CouponTemplateId, updateDto); |
||||
|
|
||||
|
return NoContent(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,62 @@ |
|||||
|
@page |
||||
|
@using EasyAbp.EShop.Plugins.Coupons.Permissions |
||||
|
@using Microsoft.AspNetCore.Authorization |
||||
|
@using Microsoft.AspNetCore.Mvc.Localization |
||||
|
@using Volo.Abp.AspNetCore.Mvc.UI.Layout |
||||
|
@using EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplateScope |
||||
|
@using EasyAbp.EShop.Plugins.Coupons.Localization |
||||
|
@using EasyAbp.EShop.Plugins.Coupons.Web.Menus |
||||
|
@model IndexModel |
||||
|
@inject IPageLayout PageLayout |
||||
|
@inject IHtmlLocalizer<CouponsResource> L |
||||
|
@inject IAuthorizationService Authorization |
||||
|
@{ |
||||
|
PageLayout.Content.Title = L["CouponTemplateScope"].Value; |
||||
|
PageLayout.Content.BreadCrumb.Add(L["Menu:CouponTemplate"].Value); |
||||
|
PageLayout.Content.MenuItemName = CouponsMenus.CouponTemplate; |
||||
|
} |
||||
|
|
||||
|
@section scripts |
||||
|
{ |
||||
|
<abp-script src="/Pages/EShop/Plugins/Coupons/CouponTemplates/CouponTemplateScope/index.js" /> |
||||
|
} |
||||
|
@section styles |
||||
|
{ |
||||
|
<abp-style src="/Pages/EShop/Plugins/Coupons/CouponTemplates/CouponTemplateScope/index.css"/> |
||||
|
} |
||||
|
|
||||
|
<script> |
||||
|
let couponTemplateId = '@Model.CouponTemplateId'; |
||||
|
</script> |
||||
|
|
||||
|
<abp-card> |
||||
|
<abp-card-header> |
||||
|
<abp-row> |
||||
|
<abp-column size-md="_6"> |
||||
|
<abp-card-title>@L["CouponTemplateScope"]</abp-card-title> |
||||
|
</abp-column> |
||||
|
<abp-column size-md="_6" class="text-right"> |
||||
|
@if (await Authorization.IsGrantedAsync(CouponsPermissions.CouponTemplate.Update)) |
||||
|
{ |
||||
|
<abp-button id="NewCouponTemplateScopeButton" |
||||
|
text="@L["CreateCouponTemplateScope"].Value" |
||||
|
icon="plus" |
||||
|
button-type="Primary" /> |
||||
|
} |
||||
|
</abp-column> |
||||
|
</abp-row> |
||||
|
</abp-card-header> |
||||
|
<abp-card-body> |
||||
|
<abp-table striped-rows="true" id="CouponTemplateScopeTable" class="nowrap"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th>@L["Actions"]</th> |
||||
|
<th>@L["CouponTemplateScopeStoreId"]</th> |
||||
|
<th>@L["CouponTemplateScopeProductGroupName"]</th> |
||||
|
<th>@L["CouponTemplateScopeProductId"]</th> |
||||
|
<th>@L["CouponTemplateScopeProductSkuId"]</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
</abp-table> |
||||
|
</abp-card-body> |
||||
|
</abp-card> |
||||
@ -0,0 +1,17 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplateScope |
||||
|
{ |
||||
|
public class IndexModel : CouponsPageModel |
||||
|
{ |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public Guid CouponTemplateId { get; set; } |
||||
|
|
||||
|
public virtual async Task OnGetAsync() |
||||
|
{ |
||||
|
await Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using EasyAbp.EShop.Plugins.Coupons.CouponTemplates; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Plugins.Coupons.Web.Pages.EShop.Plugins.Coupons.CouponTemplates.CouponTemplateScope.ViewModels |
||||
|
{ |
||||
|
public class CreateEditCouponTemplateScopeViewModel |
||||
|
{ |
||||
|
[Display(Name = "CouponTemplateScopeStoreId")] |
||||
|
public Guid StoreId { get; set; } |
||||
|
|
||||
|
[Display(Name = "CouponTemplateScopeProductGroupName")] |
||||
|
public string ProductGroupName { get; set; } |
||||
|
|
||||
|
[Display(Name = "CouponTemplateScopeProductId")] |
||||
|
public Guid? ProductId { get; set; } |
||||
|
|
||||
|
[Display(Name = "CouponTemplateScopeProductSkuId")] |
||||
|
public Guid? ProductSkuId { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,85 @@ |
|||||
|
$(function () { |
||||
|
|
||||
|
var l = abp.localization.getResource('EasyAbpEShopPluginsCoupons'); |
||||
|
|
||||
|
var service = easyAbp.eShop.plugins.coupons.couponTemplates.couponTemplate; |
||||
|
var createModal = new abp.ModalManager(abp.appPath + 'EShop/Plugins/Coupons/CouponTemplates/CouponTemplateScope/CreateModal'); |
||||
|
var editModal = new abp.ModalManager(abp.appPath + 'EShop/Plugins/Coupons/CouponTemplates/CouponTemplateScope/EditModal'); |
||||
|
|
||||
|
var dataTable = $('#CouponTemplateScopeTable').DataTable(abp.libs.datatables.normalizeConfiguration({ |
||||
|
processing: true, |
||||
|
serverSide: true, |
||||
|
paging: true, |
||||
|
searching: false, |
||||
|
autoWidth: false, |
||||
|
scrollCollapse: true, |
||||
|
order: [[0, "asc"]], |
||||
|
ajax: function (requestData, callback, settings) { |
||||
|
if (callback) { |
||||
|
service.get(couponTemplateId).then(function (result) { |
||||
|
callback({ |
||||
|
recordsTotal: result.scopes.length, |
||||
|
recordsFiltered: result.scopes.length, |
||||
|
data: result.scopes |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
}, |
||||
|
columnDefs: [ |
||||
|
{ |
||||
|
rowAction: { |
||||
|
items: |
||||
|
[ |
||||
|
{ |
||||
|
text: l('Edit'), |
||||
|
visible: abp.auth.isGranted('EasyAbp.EShop.Plugins.Coupons.CouponTemplate.Update'), |
||||
|
action: function (data) { |
||||
|
editModal.open({ couponTemplateId: couponTemplateId, couponTemplateScopeId: data.record.id }); |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
text: l('Delete'), |
||||
|
visible: abp.auth.isGranted('EasyAbp.EShop.Plugins.Coupons.CouponTemplate.Update'), |
||||
|
confirmMessage: function (data) { |
||||
|
return l('CouponTemplateScopeDeletionConfirmationMessage', data.record.id); |
||||
|
}, |
||||
|
action: function (data) { |
||||
|
service.get(couponTemplateId).then(function (result) { |
||||
|
var updateDto = result; |
||||
|
for (var i in updateDto.scopes) { |
||||
|
if (updateDto.scopes[i].id === data.record.id) { |
||||
|
updateDto.scopes.splice(i, 1); |
||||
|
service.update(couponTemplateId, updateDto) |
||||
|
.then(function () { |
||||
|
abp.notify.info(l('SuccessfullyDeleted')); |
||||
|
dataTable.ajax.reload(); |
||||
|
}); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
{ data: "storeId" }, |
||||
|
{ data: "productGroupName" }, |
||||
|
{ data: "productId" }, |
||||
|
{ data: "productSkuId" }, |
||||
|
] |
||||
|
})); |
||||
|
|
||||
|
createModal.onResult(function () { |
||||
|
dataTable.ajax.reload(); |
||||
|
}); |
||||
|
|
||||
|
editModal.onResult(function () { |
||||
|
dataTable.ajax.reload(); |
||||
|
}); |
||||
|
|
||||
|
$('#NewCouponTemplateScopeButton').click(function (e) { |
||||
|
e.preventDefault(); |
||||
|
createModal.open({ couponTemplateId: couponTemplateId }); |
||||
|
}); |
||||
|
}); |
||||
Loading…
Reference in new issue