Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
完成联系人的添加功能和查询功能绑定视图页面信息6
Browse files Browse the repository at this point in the history
  • Loading branch information
ltm0203 committed Mar 25, 2018
1 parent 73ab2f9 commit 8f8e6d9
Show file tree
Hide file tree
Showing 8 changed files with 999 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using System.ComponentModel.DataAnnotations;
using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using Abp.Domain.Entities.Auditing;
using MPACore.PhoneBook.PhoneBooks.Persons;

namespace MPACore.PhoneBook.PhoneBooks.Dtos
{

[AutoMapTo(typeof(Person))]
public class PersonEditDto
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected async Task UpdatePersonAsync(PersonEditDto input)
protected async Task CreatePersonAsync(PersonEditDto input)
{

_personRepository.Insert(input.MapTo<Person>());
await _personRepository.InsertAsync(input.MapTo<Person>());

}

Expand Down
9 changes: 9 additions & 0 deletions aspnet-core/src/MPACore.PhoneBook.Core/PhoneBookConsts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,14 @@ public class PhoneBookConsts
public const string ConnectionStringName = "Default";

public const bool MultiTenancyEnabled = false;



public const int MaxNameLength = 50;

public const int MaxEmailAddressLength = 80;
public const int MaxAddressLength = 200;


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ public class Person :FullAuditedEntity
/// 姓名
/// </summary>
[Required]
[MaxLength(50)]
[MaxLength(PhoneBookConsts.MaxNameLength)]
public string Name { get; set; }

/// <summary>
/// 邮箱
/// </summary>
[EmailAddress]
[MaxLength(80)]
[MaxLength(PhoneBookConsts.MaxEmailAddressLength)]
public string EmailAddress { get; set; }

/// <summary>
/// 地址信息
/// </summary>
[MaxLength(200)]
[MaxLength(PhoneBookConsts.MaxAddressLength)]
public string Address { get; set; }


Expand Down
825 changes: 825 additions & 0 deletions aspnet-core/src/MPACore.PhoneBook.Web.Mvc/App_Data/Logs/Logs.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ public PersonsController(IPersonAppService personAppService)
_personAppService = personAppService;
}


public async Task<IActionResult> Index(GetPersonInput input)
{
var dtos= await _personAppService.GetPagedPersonAsync(input);
var dtos= await _personAppService.GetPagedPersonAsync(input);

return View(dtos);

}
}
}
124 changes: 118 additions & 6 deletions aspnet-core/src/MPACore.PhoneBook.Web.Mvc/Views/Persons/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@using Abp.Application.Services.Dto
@using Abp.Authorization.Users
@using MPACore.PhoneBook
@using MPACore.PhoneBook.PhoneBooks.Dtos
@using MPACore.PhoneBook.Web.Startup
@model Abp.Application.Services.Dto.PagedResultDto<PersonListDto>
Expand All @@ -9,18 +10,17 @@
@section scripts
{
<environment names="Development">
<script src="~/view-resources/Views/Users/Index.js" asp-append-version="true"></script>
</environment>
<environment names="Staging,Production">
<script src="~/view-resources/Views/Users/Index.min.js" asp-append-version="true"></script>
<script src="~/view-resources/Views/Persons/Index.js" asp-append-version="true"></script>
</environment>


}
<div class="row clearfix">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="card">
<div class="header">
<h2>
联系人
联系人
</h2>
<ul class="header-dropdown m-r--5">
<li class="dropdown">
Expand All @@ -33,8 +33,120 @@
</li>
</ul>
</div>


<div class="body table-responsive">

<table class="table">

<thead>
<tr>
<th>@L("Name")</th>
<th>@L("EmailAddress")</th>
<th>@L("Address")</th>
<th>@L("CreationTime")</th>
<th>@L("Actions")</th>

</tr>

</thead>

<tbody>

@foreach (var person in Model.Items)
{
<tr>
<td>@person.Name</td>
<td>@person.EmailAddress</td>
<td>@person.Address</td>
<td>@person.CreationTime</td>

<td class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<i class="material-icons">menu</i>
</a>
<ul class="dropdown-menu pull-right">
<li><a href="#" class="waves-effect waves-block edit-person" data-user-id="@person.Id" data-toggle="modal" data-target="#PersonEditModal"><i class="material-icons">edit</i>@L("Edit")</a></li>
<li><a href="#" class="waves-effect waves-block delete-person" data-user-id="@person.Id" data-person-name="@person.Name"><i class="material-icons">delete_sweep</i>@L("Delete")</a></li>
</ul>
</td>
</tr>
}
</tbody>
</table>
<button type="button" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-right" data-toggle="modal" data-target="#PersonCreateModal">
<i class="material-icons">add</i>
</button>



</div>


</div>
</div>
</div>


<div class="modal fade" id="PersonCreateModal" tabindex="-1" role="dialog" aria-labelledby="PersonCreateModalLabel" data-backdrop="static">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
<span>@L("CreatePerson")</span>
</h4>
</div>
<div class="modal-body">
<form name="personCreateForm" role="form" novalidate class="form-validation">

<div class="tab-content">
<div role="tabpanel" class="tab-pane animated fadeIn active" id="create-user-details">

<div class="row clearfix" style="margin-top: 10px;">
<div class="col-sm-12">
<div class="form-group form-float">
<div class="form-line">
<input class="form-control" type="text" name="Name" required maxlength="@PhoneBookConsts.MaxNameLength" minlength="2">
<label class="form-label">@L("Name")</label>
</div>
</div>
</div>
</div>

<div class="row clearfix" style="margin-top: 10px;">
<div class="col-sm-12">
<div class="form-group form-float">
<div class="form-line">
<input class="form-control" type="text" name="EmailAddress" required maxlength="@PhoneBookConsts.MaxEmailAddressLength" minlength="2">
<label class="form-label">@L("EmailAddress")</label>
</div>
</div>
</div>
</div>

<div class="row clearfix" style="margin-top: 10px;">
<div class="col-sm-12">
<div class="form-group form-float">
<div class="form-line">
<input class="form-control" type="text" name="Address" maxlength="@PhoneBookConsts.MaxNameLength" >
<label class="form-label">@L("Address")</label>
</div>
</div>
</div>
</div>

</div>

</div>
<div class="modal-footer">
<button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button>
<button type="submit" class="btn btn-primary waves-effect">@L("Save")</button>
</div>
</form>
</div>
</div>
</div>
</div>




Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(function() {

$(function() {

var _personService = abp.services.app.person;

var _$modal = $("#PersonCreateModal");
var _$form = _$modal.find('form');


//添加联系人功能

_$form.find('button[type="submit"]').click(function(e) {
e.preventDefault();
if (!_$form.valid()) {
return;
}
var personEditDto = _$form.serializeFormToObject();//序列化表单为对象

abp.ui.setBusy(_$modal);
//约定大于配置
_personService.createOrUpdatePerson({personEditDto}).done(function() {
_$modal.modal('hide');
location.reload();
}).always(function() {
abp.ui.clearBusy(_$modal);
});

});


});


})();

0 comments on commit 8f8e6d9

Please sign in to comment.