18 changed files with 720 additions and 64 deletions
@ -0,0 +1,65 @@ |
|||
using Coldairarrow.Business.HuiYan; |
|||
using Coldairarrow.Entity.HuiYan; |
|||
using Coldairarrow.Util; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Coldairarrow.Api.Controllers.HuiYan |
|||
{ |
|||
[Route("/HuiYan/[controller]/[action]")]
|
|||
public class albbitemlabelsController : BaseApiController |
|||
{ |
|||
#region DI
|
|||
|
|||
public albbitemlabelsController(IalbbitemlabelsBusiness albbitemlabelsBus) |
|||
{ |
|||
_albbitemlabelsBus = albbitemlabelsBus; |
|||
} |
|||
|
|||
IalbbitemlabelsBusiness _albbitemlabelsBus { get; } |
|||
|
|||
#endregion
|
|||
|
|||
#region 获取
|
|||
|
|||
[HttpPost] |
|||
public async Task<PageResult<albbitemlabels>> GetDataList(PageInput<ConditionDTO> input) |
|||
{ |
|||
return await _albbitemlabelsBus.GetDataListAsync(input); |
|||
} |
|||
|
|||
[HttpPost] |
|||
public async Task<albbitemlabels> GetTheData(IdInputDTO input) |
|||
{ |
|||
return await _albbitemlabelsBus.GetTheDataAsync(input.id); |
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
#region 提交
|
|||
|
|||
[HttpPost] |
|||
public async Task SaveData(albbitemlabels data) |
|||
{ |
|||
if (data.Id.IsNullOrEmpty()) |
|||
{ |
|||
InitEntity(data); |
|||
|
|||
await _albbitemlabelsBus.AddDataAsync(data); |
|||
} |
|||
else |
|||
{ |
|||
await _albbitemlabelsBus.UpdateDataAsync(data); |
|||
} |
|||
} |
|||
|
|||
[HttpPost] |
|||
public async Task DeleteData(List<string> ids) |
|||
{ |
|||
await _albbitemlabelsBus.DeleteDataAsync(ids); |
|||
} |
|||
|
|||
#endregion
|
|||
} |
|||
} |
@ -0,0 +1,65 @@ |
|||
using Coldairarrow.Entity.HuiYan; |
|||
using Coldairarrow.Util; |
|||
using EFCore.Sharding; |
|||
using LinqKit; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Coldairarrow.Business.HuiYan |
|||
{ |
|||
public class albbitemlabelsBusiness : BaseBusiness<albbitemlabels>, IalbbitemlabelsBusiness, ITransientDependency |
|||
{ |
|||
public albbitemlabelsBusiness(IDbAccessor db) |
|||
: base(db) |
|||
{ |
|||
} |
|||
|
|||
#region 外部接口
|
|||
|
|||
public async Task<PageResult<albbitemlabels>> GetDataListAsync(PageInput<ConditionDTO> input) |
|||
{ |
|||
var q = GetIQueryable(); |
|||
var where = LinqHelper.True<albbitemlabels>(); |
|||
var search = input.Search; |
|||
|
|||
//筛选
|
|||
if (!search.Condition.IsNullOrEmpty() && !search.Keyword.IsNullOrEmpty()) |
|||
{ |
|||
var newWhere = DynamicExpressionParser.ParseLambda<albbitemlabels, bool>( |
|||
ParsingConfig.Default, false, $@"{search.Condition}.Contains(@0)", search.Keyword); |
|||
where = where.And(newWhere); |
|||
} |
|||
|
|||
return await q.Where(where).GetPageResultAsync(input); |
|||
} |
|||
|
|||
public async Task<albbitemlabels> GetTheDataAsync(string id) |
|||
{ |
|||
return await GetEntityAsync(id); |
|||
} |
|||
|
|||
public async Task AddDataAsync(albbitemlabels data) |
|||
{ |
|||
await InsertAsync(data); |
|||
} |
|||
|
|||
public async Task UpdateDataAsync(albbitemlabels data) |
|||
{ |
|||
await UpdateAsync(data); |
|||
} |
|||
|
|||
public async Task DeleteDataAsync(List<string> ids) |
|||
{ |
|||
await DeleteAsync(ids); |
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
#region 私有成员
|
|||
|
|||
#endregion
|
|||
} |
|||
} |
@ -0,0 +1,41 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.ComponentModel.DataAnnotations.Schema; |
|||
|
|||
namespace Coldairarrow.Entity.HuiYan |
|||
{ |
|||
/// <summary>
|
|||
/// albbitemlabels
|
|||
/// </summary>
|
|||
[Table("albbitemlabels")] |
|||
public class albbitemlabels |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 主键
|
|||
/// </summary>
|
|||
[Key, Column(Order = 1)] |
|||
public String Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
public DateTime CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建人Id
|
|||
/// </summary>
|
|||
public String CreatorId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 否已删除
|
|||
/// </summary>
|
|||
public Boolean Deleted { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 店铺ID
|
|||
/// </summary>
|
|||
public String ShopId { get; set; } |
|||
|
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
using Coldairarrow.Entity.HuiYan; |
|||
using Coldairarrow.Util; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Coldairarrow.Business.HuiYan |
|||
{ |
|||
public interface IalbbitemlabelsBusiness |
|||
{ |
|||
Task<PageResult<albbitemlabels>> GetDataListAsync(PageInput<ConditionDTO> input); |
|||
Task<albbitemlabels> GetTheDataAsync(string id); |
|||
Task AddDataAsync(albbitemlabels data); |
|||
Task UpdateDataAsync(albbitemlabels data); |
|||
Task DeleteDataAsync(List<string> ids); |
|||
} |
|||
} |
@ -0,0 +1,80 @@ |
|||
<template> |
|||
<a-modal |
|||
:title="title" |
|||
width="40%" |
|||
:visible="visible" |
|||
:confirmLoading="loading" |
|||
@ok="handleSubmit" |
|||
@cancel="()=>{this.visible=false}" |
|||
> |
|||
<a-spin :spinning="loading"> |
|||
<a-form-model ref="form" :model="entity" :rules="rules" v-bind="layout"> |
|||
<a-form-model-item label="商品ID" prop="ItemId"> |
|||
<a-input v-model="entity.ItemId" autocomplete="off" /> |
|||
</a-form-model-item> |
|||
</a-form-model> |
|||
</a-spin> |
|||
</a-modal> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
props: { |
|||
parentObj: Object |
|||
}, |
|||
data() { |
|||
return { |
|||
layout: { |
|||
labelCol: { span: 5 }, |
|||
wrapperCol: { span: 18 } |
|||
}, |
|||
visible: false, |
|||
loading: false, |
|||
entity: {}, |
|||
rules: {}, |
|||
title: '' |
|||
} |
|||
}, |
|||
methods: { |
|||
init() { |
|||
this.visible = true |
|||
this.entity = {} |
|||
this.$nextTick(() => { |
|||
this.$refs['form'].clearValidate() |
|||
}) |
|||
}, |
|||
openForm(id, title) { |
|||
this.init() |
|||
|
|||
if (id) { |
|||
this.loading = true |
|||
this.$http.post('/HuiYan/albbitemlabels/GetTheData', { id: id }).then(resJson => { |
|||
this.loading = false |
|||
|
|||
this.entity = resJson.Data |
|||
}) |
|||
} |
|||
}, |
|||
handleSubmit() { |
|||
this.$refs['form'].validate(valid => { |
|||
if (!valid) { |
|||
return |
|||
} |
|||
this.loading = true |
|||
this.$http.post('/HuiYan/albbitemlabels/SaveData', this.entity).then(resJson => { |
|||
this.loading = false |
|||
|
|||
if (resJson.Success) { |
|||
this.$message.success('操作成功!') |
|||
this.visible = false |
|||
|
|||
this.parentObj.getDataList() |
|||
} else { |
|||
this.$message.error(resJson.Msg) |
|||
} |
|||
}) |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,157 @@ |
|||
<template> |
|||
<a-card :bordered="false"> |
|||
<div class="table-operator"> |
|||
<a-button type="primary" icon="plus" @click="hanldleAdd()">新建</a-button> |
|||
<a-button |
|||
type="primary" |
|||
icon="minus" |
|||
@click="handleDelete(selectedRowKeys)" |
|||
:disabled="!hasSelected()" |
|||
:loading="loading" |
|||
>删除</a-button> |
|||
<a-button type="primary" icon="redo" @click="getDataList()">刷新</a-button> |
|||
</div> |
|||
|
|||
<div class="table-page-search-wrapper"> |
|||
<a-form layout="inline"> |
|||
<a-row :gutter="10"> |
|||
<a-col :md="4" :sm="24"> |
|||
<a-form-item label="查询类别"> |
|||
<a-select allowClear v-model="queryParam.condition"> |
|||
<a-select-option key="ItemId">商品ID</a-select-option> |
|||
</a-select> |
|||
</a-form-item> |
|||
</a-col> |
|||
<a-col :md="4" :sm="24"> |
|||
<a-form-item> |
|||
<a-input v-model="queryParam.keyword" placeholder="关键字" /> |
|||
</a-form-item> |
|||
</a-col> |
|||
<a-col :md="6" :sm="24"> |
|||
<a-button type="primary" @click="() => {this.pagination.current = 1; this.getDataList()}">查询</a-button> |
|||
<a-button style="margin-left: 8px" @click="() => (queryParam = {})">重置</a-button> |
|||
</a-col> |
|||
</a-row> |
|||
</a-form> |
|||
</div> |
|||
|
|||
<a-table |
|||
ref="table" |
|||
:columns="columns" |
|||
:rowKey="row => row.Id" |
|||
:dataSource="data" |
|||
:pagination="pagination" |
|||
:loading="loading" |
|||
@change="handleTableChange" |
|||
:rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" |
|||
:bordered="true" |
|||
size="small" |
|||
> |
|||
<span slot="action" slot-scope="text, record"> |
|||
<template> |
|||
<a @click="handleEdit(record.Id)">编辑</a> |
|||
<a-divider type="vertical" /> |
|||
<a @click="handleDelete([record.Id])">删除</a> |
|||
</template> |
|||
</span> |
|||
</a-table> |
|||
|
|||
<edit-form ref="editForm" :parentObj="this"></edit-form> |
|||
</a-card> |
|||
</template> |
|||
|
|||
<script> |
|||
import EditForm from './EditForm' |
|||
|
|||
const columns = [ |
|||
{ title: '商品ID', dataIndex: 'ItemId', width: '10%' }, |
|||
{ title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' } } |
|||
] |
|||
|
|||
export default { |
|||
components: { |
|||
EditForm |
|||
}, |
|||
mounted() { |
|||
this.getDataList() |
|||
}, |
|||
data() { |
|||
return { |
|||
data: [], |
|||
pagination: { |
|||
current: 1, |
|||
pageSize: 10, |
|||
showTotal: (total, range) => `总数:${total} 当前:${range[0]}-${range[1]}` |
|||
}, |
|||
filters: {}, |
|||
sorter: { field: 'Id', order: 'asc' }, |
|||
loading: false, |
|||
columns, |
|||
queryParam: {}, |
|||
selectedRowKeys: [] |
|||
} |
|||
}, |
|||
methods: { |
|||
handleTableChange(pagination, filters, sorter) { |
|||
this.pagination = { ...pagination } |
|||
this.filters = { ...filters } |
|||
this.sorter = { ...sorter } |
|||
this.getDataList() |
|||
}, |
|||
getDataList() { |
|||
this.selectedRowKeys = [] |
|||
|
|||
this.loading = true |
|||
this.$http |
|||
.post('/HuiYan/albbitemlabels/GetDataList', { |
|||
PageIndex: this.pagination.current, |
|||
PageRows: this.pagination.pageSize, |
|||
SortField: this.sorter.field || 'Id', |
|||
SortType: this.sorter.order, |
|||
Search: this.queryParam, |
|||
...this.filters |
|||
}) |
|||
.then(resJson => { |
|||
this.loading = false |
|||
this.data = resJson.Data |
|||
const pagination = { ...this.pagination } |
|||
pagination.total = resJson.Total |
|||
this.pagination = pagination |
|||
}) |
|||
}, |
|||
onSelectChange(selectedRowKeys) { |
|||
this.selectedRowKeys = selectedRowKeys |
|||
}, |
|||
hasSelected() { |
|||
return this.selectedRowKeys.length > 0 |
|||
}, |
|||
hanldleAdd() { |
|||
this.$refs.editForm.openForm() |
|||
}, |
|||
handleEdit(id) { |
|||
this.$refs.editForm.openForm(id) |
|||
}, |
|||
handleDelete(ids) { |
|||
var thisObj = this |
|||
this.$confirm({ |
|||
title: '确认删除吗?', |
|||
onOk() { |
|||
return new Promise((resolve, reject) => { |
|||
thisObj.$http.post('/HuiYan/albbitemlabels/DeleteData', ids).then(resJson => { |
|||
resolve() |
|||
|
|||
if (resJson.Success) { |
|||
thisObj.$message.success('操作成功!') |
|||
|
|||
thisObj.getDataList() |
|||
} else { |
|||
thisObj.$message.error(resJson.Msg) |
|||
} |
|||
}) |
|||
}) |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
Loading…
Reference in new issue