feat: 新增标签模块
This commit is contained in:
@@ -31,5 +31,10 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
|||||||
/// 是否禁止评论创建功能
|
/// 是否禁止评论创建功能
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsDisableCreateComment { get; set; }
|
public bool IsDisableCreateComment { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标签
|
||||||
|
/// </summary>
|
||||||
|
public HashSet<Guid>? DiscussLables { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Label输入创建对象
|
/// Label输入创建对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MyTypeCreateInputVo
|
public class DiscussLableCreateInputVo
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string? Color { get; set; }
|
public string? Color { get; set; }
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Volo.Abp.Application.Dtos;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
||||||
|
{
|
||||||
|
public class DiscussLableGetListInputVo : PagedAndSortedResultRequestDto
|
||||||
|
{
|
||||||
|
public string? Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,11 +2,10 @@ using Volo.Abp.Application.Dtos;
|
|||||||
|
|
||||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
||||||
{
|
{
|
||||||
public class MyTypeGetListOutputDto : EntityDto<Guid>
|
public class DiscussLableGetListOutputDto : EntityDto<Guid>
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string? Color { get; set; }
|
public string? Color { get; set; }
|
||||||
public string? BackgroundColor { get; set; }
|
public string? BackgroundColor { get; set; }
|
||||||
public Guid UserId { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ using Volo.Abp.Application.Dtos;
|
|||||||
|
|
||||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
||||||
{
|
{
|
||||||
public class MyTypeOutputDto : EntityDto<Guid>
|
public class DiscussLableOutputDto : EntityDto<Guid>
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string? Color { get; set; }
|
public string? Color { get; set; }
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
||||||
{
|
{
|
||||||
public class MyTypeUpdateInputVo
|
public class DiscussLableUpdateInputVo
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string? Color { get; set; }
|
public string? Color { get; set; }
|
||||||
public string? BackgroundColor { get; set; }
|
public string? BackgroundColor { get; set; }
|
||||||
public Guid UserId { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
using Volo.Abp.Application.Dtos;
|
|
||||||
|
|
||||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
|
||||||
{
|
|
||||||
public class MyTypeGetListInputVo : PagedAndSortedResultRequestDto
|
|
||||||
{
|
|
||||||
public string? Name { get; set; }
|
|
||||||
public string? Color { get; set; }
|
|
||||||
public string? BackgroundColor { get; set; }
|
|
||||||
public Guid? UserId { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.IServices
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Label服务抽象
|
/// Label服务抽象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IMyTypeService : IYiCrudAppService<MyTypeOutputDto, MyTypeGetListOutputDto, Guid, MyTypeGetListInputVo, MyTypeCreateInputVo, MyTypeUpdateInputVo>
|
public interface IDiscussLableService : IYiCrudAppService<DiscussLableOutputDto, DiscussLableGetListOutputDto, Guid, DiscussLableGetListInputVo, DiscussLableCreateInputVo, DiscussLableUpdateInputVo>
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,6 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
|||||||
private IDiscussService _discussService { get; set; }
|
private IDiscussService _discussService { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取改主题下的评论,结构为二维列表,该查询无分页
|
/// 获取改主题下的评论,结构为二维列表,该查询无分页
|
||||||
/// Todo: 可放入领域层
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="discussId"></param>
|
/// <param name="discussId"></param>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
@@ -64,15 +63,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
|||||||
List<Guid> userIds = entities.Where(x => x.CreatorId != null).Select(x => x.CreatorId ?? Guid.Empty).ToList();
|
List<Guid> userIds = entities.Where(x => x.CreatorId != null).Select(x => x.CreatorId ?? Guid.Empty).ToList();
|
||||||
var bbsUserInfoDic = (await _bbsUserManager.GetBbsUserInfoAsync(userIds)).ToDictionary(x => x.Id);
|
var bbsUserInfoDic = (await _bbsUserManager.GetBbsUserInfoAsync(userIds)).ToDictionary(x => x.Id);
|
||||||
|
|
||||||
|
//------数据查询完成------,以下只是dto的简单组装
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------数据查询完成------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//从根目录开始组装
|
//从根目录开始组装
|
||||||
//结果初始值,第一层等于全部根节点
|
//结果初始值,第一层等于全部根节点
|
||||||
@@ -117,11 +108,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
|||||||
rootOutoutDto?.ForEach(x =>
|
rootOutoutDto?.ForEach(x =>
|
||||||
{
|
{
|
||||||
x.Children = x.Children.OrderByDescending(x => x.CreationTime).ToList();
|
x.Children = x.Children.OrderByDescending(x => x.CreationTime).ToList();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return new PagedResultDto<CommentGetListOutputDto>(entities.Count(), rootOutoutDto);
|
return new PagedResultDto<CommentGetListOutputDto>(entities.Count(), rootOutoutDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SqlSugar;
|
||||||
|
using Volo.Abp.Application.Dtos;
|
||||||
|
using Volo.Abp.Data;
|
||||||
|
using Yi.Framework.Bbs.Application.Contracts.Dtos.MyType;
|
||||||
|
using Yi.Framework.Bbs.Application.Contracts.IServices;
|
||||||
|
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
||||||
|
using Yi.Framework.Ddd.Application;
|
||||||
|
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// DiscussLable服务实现
|
||||||
|
/// </summary>
|
||||||
|
public class DiscussLableService : YiCrudAppService<DiscussLableAggregateRoot, DiscussLableOutputDto,
|
||||||
|
DiscussLableGetListOutputDto, Guid, DiscussLableGetListInputVo, DiscussLableCreateInputVo,
|
||||||
|
DiscussLableUpdateInputVo>,
|
||||||
|
IDiscussLableService
|
||||||
|
{
|
||||||
|
private ISqlSugarRepository<DiscussLableAggregateRoot, Guid> _repository;
|
||||||
|
|
||||||
|
public DiscussLableService(ISqlSugarRepository<DiscussLableAggregateRoot, Guid> repository) : base(repository)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("discuss-lable/all")]
|
||||||
|
public async Task<ListResultDto<DiscussLableGetListOutputDto>> GetAllListAsync(DiscussLableGetListInputVo input)
|
||||||
|
{
|
||||||
|
var order = input.Sorting ?? nameof(DiscussLableAggregateRoot.Name);
|
||||||
|
var output = await _repository._DbQueryable
|
||||||
|
.WhereIF(input.Name is not null, x => x.Name.Contains(input.Name))
|
||||||
|
.OrderBy(order)
|
||||||
|
.Select(x => new DiscussLableGetListOutputDto(), true)
|
||||||
|
.ToListAsync();
|
||||||
|
return new ListResultDto<DiscussLableGetListOutputDto>(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<PagedResultDto<DiscussLableGetListOutputDto>> GetListAsync(
|
||||||
|
DiscussLableGetListInputVo input)
|
||||||
|
{
|
||||||
|
RefAsync<int> total = 0;
|
||||||
|
var order = input.Sorting ?? nameof(DiscussLableAggregateRoot.Name);
|
||||||
|
var output = await _repository._DbQueryable
|
||||||
|
.WhereIF(input.Name is not null, x => x.Name.Contains(input.Name))
|
||||||
|
.OrderBy(order)
|
||||||
|
.Select(x => new DiscussLableGetListOutputDto(), true)
|
||||||
|
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||||
|
return new PagedResultDto<DiscussLableGetListOutputDto>(total, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
using Volo.Abp.Application.Dtos;
|
|
||||||
using Volo.Abp.Data;
|
|
||||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.MyType;
|
|
||||||
using Yi.Framework.Bbs.Application.Contracts.IServices;
|
|
||||||
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
|
||||||
using Yi.Framework.Ddd.Application;
|
|
||||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
|
||||||
|
|
||||||
namespace Yi.Framework.Bbs.Application.Services.Forum
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Label服务实现
|
|
||||||
/// </summary>
|
|
||||||
public class MyTypeService : YiCrudAppService<MyTypeEntity, MyTypeOutputDto, MyTypeGetListOutputDto, Guid, MyTypeGetListInputVo, MyTypeCreateInputVo, MyTypeUpdateInputVo>,
|
|
||||||
IMyTypeService
|
|
||||||
{
|
|
||||||
private ISqlSugarRepository<MyTypeEntity, Guid> _repository;
|
|
||||||
public MyTypeService(ISqlSugarRepository<MyTypeEntity, Guid> repository, IDataFilter dataFilter) : base(repository)
|
|
||||||
{
|
|
||||||
_repository = repository;
|
|
||||||
_dataFilter = dataFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IDataFilter _dataFilter { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取当前用户的主题类型
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public Task<PagedResultDto<MyTypeGetListOutputDto>> GetListCurrentAsync(MyTypeGetListInputVo input)
|
|
||||||
{
|
|
||||||
//过滤器需要更换
|
|
||||||
//_dataFilter.Enable<MyTypeEntity>(x => x.UserId == CurrentUser.Id);
|
|
||||||
|
|
||||||
//_dataFilter.AddFilter<MyTypeEntity>(x => x.UserId == CurrentUser.Id);
|
|
||||||
return base.GetListAsync(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 创建
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public override async Task<MyTypeOutputDto> CreateAsync(MyTypeCreateInputVo input)
|
|
||||||
{
|
|
||||||
var entity = await MapToEntityAsync(input);
|
|
||||||
entity.UserId = CurrentUser.Id ?? Guid.Empty;
|
|
||||||
entity.IsDeleted = false;
|
|
||||||
var outputEntity = await _repository.InsertReturnEntityAsync(entity);
|
|
||||||
return await MapToGetOutputDtoAsync(outputEntity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -67,6 +67,9 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
|
|||||||
[SugarColumn(IsJson = true)]//使用json处理
|
[SugarColumn(IsJson = true)]//使用json处理
|
||||||
public List<Guid>? PermissionUserIds { get; set; }
|
public List<Guid>? PermissionUserIds { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(IsJson = true)]//使用json处理
|
||||||
|
public HashSet<Guid>? DiscussLables{ get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否禁止评论创建功能
|
/// 是否禁止评论创建功能
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -4,17 +4,13 @@ using Volo.Abp.Domain.Entities;
|
|||||||
|
|
||||||
namespace Yi.Framework.Bbs.Domain.Entities.Forum
|
namespace Yi.Framework.Bbs.Domain.Entities.Forum
|
||||||
{
|
{
|
||||||
[SugarTable("MyType")]
|
[SugarTable("DiscussLable")]
|
||||||
public class MyTypeEntity : Entity<Guid>, ISoftDelete
|
public class DiscussLableAggregateRoot : AggregateRoot<Guid>, ISoftDelete
|
||||||
{
|
{
|
||||||
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
|
||||||
public override Guid Id { get; protected set; }
|
|
||||||
public bool IsDeleted { get; set; }
|
public bool IsDeleted { get; set; }
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string? Color { get; set; }
|
public string? Color { get; set; }
|
||||||
public string? BackgroundColor { get; set; }
|
public string? BackgroundColor { get; set; }
|
||||||
|
|
||||||
public Guid UserId { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
using SqlSugar;
|
|
||||||
using Volo.Abp.Domain.Entities;
|
|
||||||
|
|
||||||
namespace Yi.Framework.Bbs.Domain.Entities.Forum
|
|
||||||
{
|
|
||||||
[SugarTable("DiscussMyType")]
|
|
||||||
public class DiscussMyTypeEntity : Entity<Guid>
|
|
||||||
{
|
|
||||||
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
|
||||||
public override Guid Id { get; protected set; }
|
|
||||||
|
|
||||||
public Guid DiscussId { get; set; }
|
|
||||||
|
|
||||||
public Guid MyTypeId { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
9
Yi.Bbs.Vue3/src/apis/discussLableApi.js
Normal file
9
Yi.Bbs.Vue3/src/apis/discussLableApi.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import request from "@/config/axios/service";
|
||||||
|
|
||||||
|
export function getAllList(data) {
|
||||||
|
return request({
|
||||||
|
url: "/discuss-lable/all",
|
||||||
|
method: "get",
|
||||||
|
params: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -2,25 +2,29 @@
|
|||||||
<div style="width: 1300px">
|
<div style="width: 1300px">
|
||||||
<div class="body-div">
|
<div class="body-div">
|
||||||
<el-form
|
<el-form
|
||||||
label-width="120px"
|
label-width="120px"
|
||||||
:model="editForm"
|
:model="editForm"
|
||||||
label-position="left"
|
label-position="left"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
ref="ruleFormRef"
|
ref="ruleFormRef"
|
||||||
>
|
>
|
||||||
<el-form-item label="类型:">
|
<el-form-item label="类型:">
|
||||||
<el-radio-group v-model="radio">
|
<el-radio-group v-model="radio">
|
||||||
<el-radio-button label="discuss" :disabled="artType !== 'discuss'"
|
<el-radio-button label="discuss" :disabled="artType !== 'discuss'"
|
||||||
>主题</el-radio-button
|
>主题
|
||||||
|
</el-radio-button
|
||||||
>
|
>
|
||||||
<el-radio-button label="article" :disabled="artType !== 'article'"
|
<el-radio-button label="article" :disabled="artType !== 'article'"
|
||||||
>文章</el-radio-button
|
>文章
|
||||||
|
</el-radio-button
|
||||||
>
|
>
|
||||||
<el-radio-button label="plate" :disabled="artType !== 'plate'"
|
<el-radio-button label="plate" :disabled="artType !== 'plate'"
|
||||||
>板块</el-radio-button
|
>板块
|
||||||
|
</el-radio-button
|
||||||
>
|
>
|
||||||
<el-radio-button label="orther" :disabled="artType !== 'orther'"
|
<el-radio-button label="orther" :disabled="artType !== 'orther'"
|
||||||
>其他</el-radio-button
|
>其他
|
||||||
|
</el-radio-button
|
||||||
>
|
>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -33,30 +37,30 @@
|
|||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="可见用户:"
|
label="可见用户:"
|
||||||
v-if="radio == 'discuss' && perRadio == 'User'"
|
v-if="radio == 'discuss' && perRadio == 'User'"
|
||||||
>
|
>
|
||||||
<UserSelectInfo v-model="editForm.permissionUserIds" />
|
<UserSelectInfo v-model="editForm.permissionUserIds"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item
|
<el-form-item
|
||||||
v-if="radio == 'article'"
|
v-if="radio == 'article'"
|
||||||
label="子文章名称:"
|
label="子文章名称:"
|
||||||
prop="name"
|
prop="name"
|
||||||
>
|
>
|
||||||
<el-input placeholder="请输入" v-model="editForm.name" />
|
<el-input placeholder="请输入" v-model="editForm.name"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-else label="标题:" prop="title">
|
<el-form-item v-else label="标题:" prop="title">
|
||||||
<el-input placeholder="请输入" v-model="editForm.title" />
|
<el-input placeholder="请输入" v-model="editForm.title"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="描述:" prop="introduction">
|
<el-form-item label="描述:" prop="introduction">
|
||||||
<el-input placeholder="请输入" v-model="editForm.introduction" />
|
<el-input placeholder="请输入" v-model="editForm.introduction"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="内容:" prop="content">
|
<el-form-item label="内容:" prop="content">
|
||||||
<MavonEdit
|
<MavonEdit
|
||||||
height="30rem"
|
height="30rem"
|
||||||
v-model="editForm.content"
|
v-model="editForm.content"
|
||||||
:codeStyle="codeStyle"
|
:codeStyle="codeStyle"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="封面:" v-if="radio == 'discuss'">
|
<el-form-item label="封面:" v-if="radio == 'discuss'">
|
||||||
@@ -67,61 +71,84 @@
|
|||||||
style="width: 178px; height: 178px"
|
style="width: 178px; height: 178px"
|
||||||
class="avatar"
|
class="avatar"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 主题封面选择 -->
|
<!-- 主题封面选择 -->
|
||||||
<el-upload
|
<el-upload
|
||||||
class="avatar-uploader"
|
class="avatar-uploader"
|
||||||
:action="fileUploadUrl"
|
:action="fileUploadUrl"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
:on-success="onSuccess"
|
:on-success="onSuccess"
|
||||||
>
|
>
|
||||||
<el-icon class="avatar-uploader-icon"><Plus /></el-icon>
|
<el-icon class="avatar-uploader-icon">
|
||||||
|
<Plus/>
|
||||||
|
</el-icon>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="标签:" prop="types">
|
<el-form-item label="分类标签:" prop="discussLable" v-if="radio == 'discuss'">
|
||||||
<el-input placeholder="请输入" v-model="editForm.types" />
|
<el-select
|
||||||
|
value-key="id"
|
||||||
|
v-model="selectLabelList"
|
||||||
|
multiple
|
||||||
|
filterable
|
||||||
|
remote
|
||||||
|
reserve-keyword
|
||||||
|
placeholder="请选择合适的文章标签"
|
||||||
|
:remote-method="remoteMethod"
|
||||||
|
:loading="labelLoading"
|
||||||
|
style="width: 435px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in labelListData"
|
||||||
|
:key="item.value.id"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button
|
<el-button
|
||||||
@click="submit(ruleFormRef)"
|
@click="submit(ruleFormRef)"
|
||||||
class="submit-btn"
|
class="submit-btn"
|
||||||
type="primary"
|
type="primary"
|
||||||
>提交</el-button
|
>提交
|
||||||
></el-form-item
|
</el-button
|
||||||
|
>
|
||||||
|
</el-form-item
|
||||||
>
|
>
|
||||||
</el-form>
|
</el-form>
|
||||||
<div class="import-content" v-show="radio == 'article'">
|
<div class="import-content" v-show="radio == 'article'">
|
||||||
<div class="text">上传类型:</div>
|
<div class="text">上传类型:</div>
|
||||||
<el-select
|
<el-select
|
||||||
v-model="currentType"
|
v-model="currentType"
|
||||||
placeholder="请选择"
|
placeholder="请选择"
|
||||||
style="width: 120px"
|
style="width: 120px"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in typeOptions"
|
v-for="item in typeOptions"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
:label="item.label"
|
:label="item.label"
|
||||||
:value="item.value"
|
:value="item.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
:icon="Download"
|
:icon="Download"
|
||||||
:loading="importLoading"
|
:loading="importLoading"
|
||||||
@click="handleImport"
|
@click="handleImport"
|
||||||
class="import-btn"
|
class="import-btn"
|
||||||
>导入文章</el-button
|
>导入文章
|
||||||
|
</el-button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 文件弹框 -->
|
<!-- 文件弹框 -->
|
||||||
<div>
|
<div>
|
||||||
<input
|
<input
|
||||||
v-show="false"
|
v-show="false"
|
||||||
ref="fileRef"
|
ref="fileRef"
|
||||||
type="file"
|
type="file"
|
||||||
multiple
|
multiple
|
||||||
@change="getFile"
|
@change="getFile"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -130,8 +157,8 @@
|
|||||||
import MavonEdit from "@/components/MavonEdit.vue";
|
import MavonEdit from "@/components/MavonEdit.vue";
|
||||||
import UserSelectInfo from "@/components/UserSelectInfo.vue";
|
import UserSelectInfo from "@/components/UserSelectInfo.vue";
|
||||||
import {ref, reactive, onMounted, computed} from "vue";
|
import {ref, reactive, onMounted, computed} from "vue";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import {useRoute, useRouter} from "vue-router";
|
||||||
import { Plus, Download } from "@element-plus/icons-vue";
|
import {Plus, Download} from "@element-plus/icons-vue";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
add as discussAdd,
|
add as discussAdd,
|
||||||
@@ -139,6 +166,10 @@ import {
|
|||||||
get as discussGet,
|
get as discussGet,
|
||||||
} from "@/apis/discussApi.js";
|
} from "@/apis/discussApi.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
getAllList as getLableAllList
|
||||||
|
} from "@/apis/discussLableApi"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
add as articleAdd,
|
add as articleAdd,
|
||||||
update as articleUpdate,
|
update as articleUpdate,
|
||||||
@@ -161,13 +192,30 @@ const fileUploadUrl = `${import.meta.env.VITE_APP_BASEAPI}/file`;
|
|||||||
//封面的url
|
//封面的url
|
||||||
const dialogImageUrl = ref("");
|
const dialogImageUrl = ref("");
|
||||||
|
|
||||||
|
//远程文章标签
|
||||||
|
const labelListData = ref([]);
|
||||||
|
const labelLoading = ref(false);
|
||||||
|
const selectLabelList = ref([]);
|
||||||
|
//远程下拉框查询文章标签
|
||||||
|
const remoteMethod = async (query) => {
|
||||||
|
labelLoading.value = true
|
||||||
|
const {data} = await getLableAllList({name:query});
|
||||||
|
labelLoading.value = false
|
||||||
|
labelListData.value = data.items.map((item) => {
|
||||||
|
return {
|
||||||
|
value: item,
|
||||||
|
label: item.name
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
//文件上传成功后
|
//文件上传成功后
|
||||||
const onSuccess = (response) => {
|
const onSuccess = (response) => {
|
||||||
dialogImageUrl.value = response[0].id;
|
dialogImageUrl.value = response[0].id;
|
||||||
};
|
};
|
||||||
|
|
||||||
//封面url
|
//封面url
|
||||||
const getUrl=computed(()=>{
|
const getUrl = computed(() => {
|
||||||
return `${import.meta.env.VITE_APP_BASEAPI}/file/${dialogImageUrl.value}`;
|
return `${import.meta.env.VITE_APP_BASEAPI}/file/${dialogImageUrl.value}`;
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -175,11 +223,11 @@ const getUrl=computed(()=>{
|
|||||||
//整个页面上的表单
|
//整个页面上的表单
|
||||||
const editForm = reactive({
|
const editForm = reactive({
|
||||||
title: "",
|
title: "",
|
||||||
types: "",
|
|
||||||
introduction: "",
|
introduction: "",
|
||||||
content: "",
|
content: "",
|
||||||
name: "",
|
name: "",
|
||||||
permissionUserIds: [],
|
permissionUserIds: [],
|
||||||
|
discussLables:[]
|
||||||
});
|
});
|
||||||
|
|
||||||
//组装主题内容: 需要更新主题信息
|
//组装主题内容: 需要更新主题信息
|
||||||
@@ -192,13 +240,13 @@ const article = {};
|
|||||||
const ruleFormRef = ref(null);
|
const ruleFormRef = ref(null);
|
||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
title: [
|
title: [
|
||||||
{ required: true, message: "请输入标题", trigger: "blur" },
|
{required: true, message: "请输入标题", trigger: "blur"},
|
||||||
{ min: 3, max: 40, message: "长度 3 到 20", trigger: "blur" },
|
{min: 3, max: 40, message: "长度 3 到 20", trigger: "blur"},
|
||||||
],
|
],
|
||||||
name: [{ required: true, message: "请输入子文章名称", trigger: "blur" }],
|
name: [{required: true, message: "请输入子文章名称", trigger: "blur"}],
|
||||||
content: [
|
content: [
|
||||||
{ required: true, message: "请输入内容", trigger: "blur" },
|
{required: true, message: "请输入内容", trigger: "blur"},
|
||||||
{ min: 10, message: "长度 大于 10", trigger: "blur" },
|
{min: 10, message: "长度 大于 10", trigger: "blur"},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
//提交按钮,需要区分操作类型
|
//提交按钮,需要区分操作类型
|
||||||
@@ -206,10 +254,11 @@ const submit = async (formEl) => {
|
|||||||
if (!formEl) return;
|
if (!formEl) return;
|
||||||
await formEl.validate(async (valid, fields) => {
|
await formEl.validate(async (valid, fields) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
discuss.discussLables=selectLabelList.value.map((item) =>item.id);
|
||||||
|
console.log(discuss,"discuss")
|
||||||
//dicuss主题处理
|
//dicuss主题处理
|
||||||
if (radio.value == "discuss") {
|
if (radio.value == "discuss") {
|
||||||
discuss.title = editForm.title;
|
discuss.title = editForm.title;
|
||||||
discuss.types = editForm.types;
|
|
||||||
discuss.introduction = editForm.introduction;
|
discuss.introduction = editForm.introduction;
|
||||||
discuss.content = editForm.content;
|
discuss.content = editForm.content;
|
||||||
discuss.plateId = discuss.plateId ?? route.query.plateId;
|
discuss.plateId = discuss.plateId ?? route.query.plateId;
|
||||||
@@ -225,7 +274,7 @@ const submit = async (formEl) => {
|
|||||||
message: `[${discuss.title}]主题创建成功!`,
|
message: `[${discuss.title}]主题创建成功!`,
|
||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
var routerPer = { path: `/article/${response.data.id}` };
|
var routerPer = {path: `/article/${response.data.id}`};
|
||||||
router.push(routerPer);
|
router.push(routerPer);
|
||||||
}
|
}
|
||||||
//主题更新
|
//主题更新
|
||||||
@@ -236,7 +285,7 @@ const submit = async (formEl) => {
|
|||||||
message: `[${discuss.title}]主题更新成功!`,
|
message: `[${discuss.title}]主题更新成功!`,
|
||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
var routerPer = { path: `/article/${route.query.discussId}` };
|
var routerPer = {path: `/article/${route.query.discussId}`};
|
||||||
router.push(routerPer);
|
router.push(routerPer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -301,7 +350,6 @@ const loadDiscuss = async () => {
|
|||||||
const res = response.data;
|
const res = response.data;
|
||||||
editForm.content = res.content;
|
editForm.content = res.content;
|
||||||
editForm.title = res.title;
|
editForm.title = res.title;
|
||||||
editForm.types = res.types;
|
|
||||||
editForm.introduction = res.introduction;
|
editForm.introduction = res.introduction;
|
||||||
discuss.plateId = res.plateId;
|
discuss.plateId = res.plateId;
|
||||||
dialogImageUrl.value = res.cover;
|
dialogImageUrl.value = res.cover;
|
||||||
@@ -342,19 +390,19 @@ const getFile = async (e) => {
|
|||||||
formData.append("file", e.target.files[i]);
|
formData.append("file", e.target.files[i]);
|
||||||
}
|
}
|
||||||
await importArticle(
|
await importArticle(
|
||||||
{
|
{
|
||||||
discussId: route.query.discussId,
|
discussId: route.query.discussId,
|
||||||
articleParentId: route.query.parentArticleId,
|
articleParentId: route.query.parentArticleId,
|
||||||
importType: currentType.value,
|
importType: currentType.value,
|
||||||
},
|
},
|
||||||
formData
|
formData
|
||||||
);
|
);
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: `导入成功!`,
|
message: `导入成功!`,
|
||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
importLoading.value = false;
|
importLoading.value = false;
|
||||||
const routerPer = { path: `/article/${route.query.discussId}` };
|
const routerPer = {path: `/article/${route.query.discussId}`};
|
||||||
router.push(routerPer);
|
router.push(routerPer);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error(error.message);
|
ElMessage.error(error.message);
|
||||||
@@ -373,16 +421,19 @@ const getFile = async (e) => {
|
|||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
margin: 1.5rem;
|
margin: 1.5rem;
|
||||||
padding: 1.5rem;
|
padding: 1.5rem;
|
||||||
|
|
||||||
.import-content {
|
.import-content {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 1.5rem;
|
top: 1.5rem;
|
||||||
right: 1.5rem;
|
right: 1.5rem;
|
||||||
|
|
||||||
.text {
|
.text {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.import-btn {
|
.import-btn {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
@@ -408,6 +459,7 @@ const getFile = async (e) => {
|
|||||||
height: 178px;
|
height: 178px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-upload {
|
.el-upload {
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user