committed by
GitHub
24 changed files with 879 additions and 24 deletions
@ -0,0 +1,49 @@ |
|||||
|
using LINGYUN.Abp.FileManagement.Localization; |
||||
|
using Volo.Abp.Features; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Validation.StringValues; |
||||
|
|
||||
|
namespace LINGYUN.Abp.FileManagement.Features |
||||
|
{ |
||||
|
public class AbpFileManagementFeatureDefinitionProvider : FeatureDefinitionProvider |
||||
|
{ |
||||
|
public override void Define(IFeatureDefinitionContext context) |
||||
|
{ |
||||
|
var featureGroup = context.AddGroup( |
||||
|
name: AbpFileManagementFeatureNames.GroupName, |
||||
|
displayName: L("Features:FileManagement")); |
||||
|
|
||||
|
var fileSystemFeature = featureGroup.AddFeature( |
||||
|
name: AbpFileManagementFeatureNames.FileSystem.Default, |
||||
|
displayName: L("Features:DisplayName:FileSystem"), |
||||
|
description: L("Features:Description:FileSystem")); |
||||
|
|
||||
|
fileSystemFeature.CreateChild( |
||||
|
name: AbpFileManagementFeatureNames.FileSystem.DownloadFile, |
||||
|
defaultValue: false.ToString(), |
||||
|
displayName: L("Features:DisplayName:DownloadFile"), |
||||
|
description: L("Features:Description:DownloadFile"), |
||||
|
valueType: new ToggleStringValueType(new BooleanValueValidator())); |
||||
|
|
||||
|
fileSystemFeature.CreateChild( |
||||
|
name: AbpFileManagementFeatureNames.FileSystem.UploadFile, |
||||
|
defaultValue: true.ToString(), |
||||
|
displayName: L("Features:DisplayName:UploadFile"), |
||||
|
description: L("Features:Description:UploadFile"), |
||||
|
valueType: new ToggleStringValueType(new BooleanValueValidator())); |
||||
|
|
||||
|
// TODO: 此功能需要控制器协同,暂时不实现
|
||||
|
fileSystemFeature.CreateChild( |
||||
|
name: AbpFileManagementFeatureNames.FileSystem.MaxUploadFileCount, |
||||
|
defaultValue: 1.ToString(), |
||||
|
displayName: L("Features:DisplayName:MaxUploadFileCount"), |
||||
|
description: L("Features:Description:MaxUploadFileCount"), |
||||
|
valueType: new ToggleStringValueType(new NumericValueValidator(1, 10))); |
||||
|
} |
||||
|
|
||||
|
protected ILocalizableString L(string name) |
||||
|
{ |
||||
|
return LocalizableString.Create<AbpFileManagementResource>(name); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
namespace LINGYUN.Abp.FileManagement.Features |
||||
|
{ |
||||
|
public class AbpFileManagementFeatureNames |
||||
|
{ |
||||
|
public const string GroupName = "Abp.FileManagement"; |
||||
|
public class FileSystem |
||||
|
{ |
||||
|
public const string Default = GroupName + ".FileSystem"; |
||||
|
/// <summary>
|
||||
|
/// 下载文件功能
|
||||
|
/// </summary>
|
||||
|
public const string DownloadFile = Default + ".DownloadFile"; |
||||
|
/// <summary>
|
||||
|
/// 上传文件功能
|
||||
|
/// </summary>
|
||||
|
public const string UploadFile = Default + ".UploadFile"; |
||||
|
/// <summary>
|
||||
|
/// 最大上传文件
|
||||
|
/// </summary>
|
||||
|
public const string MaxUploadFileCount = Default + ".MaxUploadFileCount"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,206 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using LINGYUN.BackendAdmin.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LINGYUN.BackendAdmin.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(BackendAdminHostMigrationsDbContext))] |
||||
|
[Migration("20200910080638_Add-abp-feature-module")] |
||||
|
partial class Addabpfeaturemodule |
||||
|
{ |
||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
||||
|
.HasAnnotation("ProductVersion", "3.1.7") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("varchar(128) CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(128); |
||||
|
|
||||
|
b.Property<string>("ProviderKey") |
||||
|
.HasColumnType("varchar(64) CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(64); |
||||
|
|
||||
|
b.Property<string>("ProviderName") |
||||
|
.HasColumnType("varchar(64) CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(64); |
||||
|
|
||||
|
b.Property<string>("Value") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("varchar(128) CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(128); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name", "ProviderName", "ProviderKey"); |
||||
|
|
||||
|
b.ToTable("AbpFeatureValues"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("varchar(128) CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(128); |
||||
|
|
||||
|
b.Property<string>("ProviderKey") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("varchar(64) CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(64); |
||||
|
|
||||
|
b.Property<string>("ProviderName") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("varchar(64) CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(64); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnName("TenantId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name", "ProviderName", "ProviderKey"); |
||||
|
|
||||
|
b.ToTable("AbpPermissionGrants"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("varchar(128) CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(128); |
||||
|
|
||||
|
b.Property<string>("ProviderKey") |
||||
|
.HasColumnType("varchar(64) CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(64); |
||||
|
|
||||
|
b.Property<string>("ProviderName") |
||||
|
.HasColumnType("varchar(64) CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(64); |
||||
|
|
||||
|
b.Property<string>("Value") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("longtext CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(2048); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name", "ProviderName", "ProviderKey"); |
||||
|
|
||||
|
b.ToTable("AbpSettings"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.TenantManagement.Tenant", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasColumnName("ConcurrencyStamp") |
||||
|
.HasColumnType("varchar(40) CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(40); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnName("CreationTime") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnName("CreatorId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnName("DeleterId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnName("DeletionTime") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnName("ExtraProperties") |
||||
|
.HasColumnType("longtext CHARACTER SET utf8mb4"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnName("IsDeleted") |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnName("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnName("LastModifierId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("varchar(64) CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(64); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name"); |
||||
|
|
||||
|
b.ToTable("AbpTenants"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.TenantManagement.TenantConnectionString", b => |
||||
|
{ |
||||
|
b.Property<Guid>("TenantId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.HasColumnType("varchar(64) CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(64); |
||||
|
|
||||
|
b.Property<string>("Value") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("varchar(1024) CHARACTER SET utf8mb4") |
||||
|
.HasMaxLength(1024); |
||||
|
|
||||
|
b.HasKey("TenantId", "Name"); |
||||
|
|
||||
|
b.ToTable("AbpTenantConnectionStrings"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.TenantManagement.TenantConnectionString", b => |
||||
|
{ |
||||
|
b.HasOne("Volo.Abp.TenantManagement.Tenant", null) |
||||
|
.WithMany("ConnectionStrings") |
||||
|
.HasForeignKey("TenantId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
namespace LINGYUN.BackendAdmin.Migrations |
||||
|
{ |
||||
|
public partial class Addabpfeaturemodule : Migration |
||||
|
{ |
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpFeatureValues", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(nullable: false), |
||||
|
Name = table.Column<string>(maxLength: 128, nullable: false), |
||||
|
Value = table.Column<string>(maxLength: 128, nullable: false), |
||||
|
ProviderName = table.Column<string>(maxLength: 64, nullable: true), |
||||
|
ProviderKey = table.Column<string>(maxLength: 64, nullable: true) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); |
||||
|
}); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", |
||||
|
table: "AbpFeatureValues", |
||||
|
columns: new[] { "Name", "ProviderName", "ProviderKey" }); |
||||
|
} |
||||
|
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpFeatureValues"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Binary file not shown.
@ -0,0 +1,56 @@ |
|||||
|
import ApiService from './serviceBase' |
||||
|
|
||||
|
const serviceUrl = process.env.VUE_APP_BASE_API |
||||
|
|
||||
|
export default class FeatureManagementService { |
||||
|
public static getFeatures(providerName: string, providerKey: string) { |
||||
|
let _url = '/api/feature-management/features?' |
||||
|
_url += 'providerName=' + providerName |
||||
|
_url += '&providerKey=' + providerKey |
||||
|
return ApiService.Get<Features>(_url, serviceUrl) |
||||
|
} |
||||
|
|
||||
|
public static updateFeatures(providerName: string, providerKey: string, features: Features) { |
||||
|
let _url = '/api/feature-management/features?' |
||||
|
_url += 'providerName=' + providerName |
||||
|
_url += '&providerKey=' + providerKey |
||||
|
return ApiService.Put<void>(_url, features, serviceUrl) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export class Provider { |
||||
|
providerName!: string |
||||
|
providerKey!: string |
||||
|
} |
||||
|
|
||||
|
export class ValueType { |
||||
|
name!: string |
||||
|
properties!: any |
||||
|
validator!: any |
||||
|
} |
||||
|
|
||||
|
export class Feature { |
||||
|
name!: string |
||||
|
displayName?: string |
||||
|
value!: string |
||||
|
description?: string |
||||
|
valueType?: ValueType |
||||
|
depth?: number |
||||
|
parentName?: string |
||||
|
|
||||
|
constructor( |
||||
|
name: string, |
||||
|
value: any |
||||
|
) { |
||||
|
this.name = name |
||||
|
this.value = value |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export class Features { |
||||
|
features!: Feature[] |
||||
|
|
||||
|
constructor() { |
||||
|
this.features = new Array<Feature>() |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,317 @@ |
|||||
|
<template> |
||||
|
<div class="app-container"> |
||||
|
<el-form |
||||
|
ref="frmFeature" |
||||
|
:model="features" |
||||
|
label-width="100px" |
||||
|
> |
||||
|
<el-tabs v-model="selectTab"> |
||||
|
<el-tab-pane |
||||
|
v-for="(feature, fi) in features.features" |
||||
|
:key="feature.name" |
||||
|
:label="feature.displayName" |
||||
|
:name="feature.name" |
||||
|
> |
||||
|
<el-form-item |
||||
|
v-for="(featureChildren, fci) in feature.children" |
||||
|
:key="featureChildren.name" |
||||
|
:label="featureChildren.displayName" |
||||
|
:prop="'features.' + fi + '.children.' + fci + '.value'" |
||||
|
:rules="featureChildren.valueType.validator | inputRuleFilter(localizer)" |
||||
|
> |
||||
|
<div |
||||
|
v-if="featureChildren.valueType.name === 'ToggleStringValueType'" |
||||
|
> |
||||
|
<el-switch |
||||
|
v-if="featureChildren.valueType.validator.name === 'BOOLEAN'" |
||||
|
v-model="featureChildren.value" |
||||
|
/> |
||||
|
<el-input |
||||
|
v-else-if="featureChildren.valueType.validator.name === 'NUMERIC'" |
||||
|
v-model.number="featureChildren.value" |
||||
|
type="number" |
||||
|
/> |
||||
|
<el-input |
||||
|
v-else-if="featureChildren.valueType.validator.name === 'STRING'" |
||||
|
v-model="featureChildren.value" |
||||
|
type="text" |
||||
|
/> |
||||
|
</div> |
||||
|
<div |
||||
|
v-else-if="featureChildren.valueType.name === 'SELECTION'" |
||||
|
> |
||||
|
<el-select |
||||
|
v-model="featureChildren.value" |
||||
|
> |
||||
|
<el-option |
||||
|
v-for="valueItem in featureChildren.valueType.itemSource.items" |
||||
|
:key="valueItem.value" |
||||
|
:label="valueItem.displayText" |
||||
|
:value="valueItem.value" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</div> |
||||
|
</el-form-item> |
||||
|
</el-tab-pane> |
||||
|
</el-tabs> |
||||
|
<el-button |
||||
|
type="primary" |
||||
|
class="confirm" |
||||
|
@click="onSave" |
||||
|
> |
||||
|
{{ $t('AbpFeatureManagement.Submit') }} |
||||
|
</el-button> |
||||
|
<el-button |
||||
|
class="cancel" |
||||
|
@click="onClosed" |
||||
|
> |
||||
|
{{ $t('AbpFeatureManagement.Cancel') }} |
||||
|
</el-button> |
||||
|
</el-form> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts"> |
||||
|
import { Component, Prop, Vue, Watch } from 'vue-property-decorator' |
||||
|
import FeatureManagementService, { ValueType, Feature, Features } from '@/api/feature-management' |
||||
|
|
||||
|
/** |
||||
|
* 适用于动态表单的功能节点列表 |
||||
|
*/ |
||||
|
class FeatureItems { |
||||
|
features = new Array<FeatureItem>() |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 适用于动态表单的功能节点 |
||||
|
*/ |
||||
|
class FeatureItem { |
||||
|
/** 功能名称 */ |
||||
|
name!: string |
||||
|
/** 显示名称 */ |
||||
|
displayName?: string |
||||
|
/** 当前值 */ |
||||
|
value!: any |
||||
|
/** 说明 */ |
||||
|
description?: string |
||||
|
/** 值类型 */ |
||||
|
valueType?: ValueType |
||||
|
/** 深度 */ |
||||
|
depth?: number |
||||
|
/** 子节点 */ |
||||
|
children!: FeatureItem[] |
||||
|
|
||||
|
/** 构造器 */ |
||||
|
constructor( |
||||
|
name: string, |
||||
|
value: any, |
||||
|
displayName?: string, |
||||
|
description?: string, |
||||
|
valueType?: ValueType, |
||||
|
depth?: number |
||||
|
) { |
||||
|
this.name = name |
||||
|
this.depth = depth |
||||
|
this.valueType = valueType |
||||
|
this.displayName = displayName |
||||
|
this.description = description |
||||
|
this.children = new Array<FeatureItem>() |
||||
|
if (value !== null) { |
||||
|
this.value = value.toLowerCase() === 'true' ? true // boolean类型 |
||||
|
: !isNaN(Number(value)) ? Number(value) // number类型 |
||||
|
: value |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 创建子节点 |
||||
|
* @feature 子节点 |
||||
|
*/ |
||||
|
public appendChildren(feature: FeatureItem) { |
||||
|
this.children.push(feature) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取子节点 |
||||
|
* @name 节点名称 |
||||
|
*/ |
||||
|
public getChildren(name: string) { |
||||
|
const childrenIndex = this.children.findIndex(feature => feature.name === name) |
||||
|
if (childrenIndex >= 0) { |
||||
|
return this.children[childrenIndex] |
||||
|
} |
||||
|
return undefined |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Component({ |
||||
|
name: 'FeatureManagement', |
||||
|
filters: { |
||||
|
/** |
||||
|
* 动态处理功能表单验证 |
||||
|
* @validator 后端传递的验证规则 |
||||
|
* @localizer 本地化method |
||||
|
*/ |
||||
|
inputRuleFilter(validator: any, localizer: any) { |
||||
|
const featureRules: {[key: string]: any}[] = new Array<{[key: string]: any}>() |
||||
|
if (validator.name === 'NUMERIC') { |
||||
|
const ruleRang: {[key: string]: any} = {} |
||||
|
ruleRang.pattern = RegExp('^(' + validator.minValue + '|[1-9]d?|' + validator.maxValue + ')$') |
||||
|
// ruleRang.pattern = /^(1|[1-9]\d?|10)$/ |
||||
|
// ruleRang.min = validator.minValue |
||||
|
// ruleRang.max = validator.maxValue |
||||
|
ruleRang.trigger = 'blur' |
||||
|
ruleRang.message = localizer('AbpFeatureManagement.ThisFieldMustBeBetween{0}And{1}', { 0: validator.minValue, 1: validator.maxValue }) |
||||
|
featureRules.push(ruleRang) |
||||
|
} else if (validator.name === 'STRING') { |
||||
|
if (validator.allowNull && validator.allowNull.toLowerCase() === 'true') { |
||||
|
const ruleRequired: {[key: string]: any} = {} |
||||
|
ruleRequired.required = true |
||||
|
ruleRequired.trigger = 'blur' |
||||
|
ruleRequired.messahe = localizer('AbpFeatureManagement.ThisFieldIsRequired') |
||||
|
featureRules.push(ruleRequired) |
||||
|
} |
||||
|
const ruleString: {[key: string]: any} = {} |
||||
|
ruleString.min = validator.minLength |
||||
|
ruleString.max = validator.maxLength |
||||
|
ruleString.trigger = 'blur' |
||||
|
ruleString.message = localizer('AbpFeatureManagement.ThisFieldMustBeBetween{0}And{1}', { 0: validator.minValue, 1: validator.maxValue }) |
||||
|
featureRules.push(ruleString) |
||||
|
} |
||||
|
return featureRules |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
/** |
||||
|
* 本地化method |
||||
|
*/ |
||||
|
localizer(name: string, values?: any[]) { |
||||
|
return this.$t(name, values) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
export default class extends Vue { |
||||
|
/** |
||||
|
* 功能提供者名称 |
||||
|
*/ |
||||
|
@Prop({ default: '' }) |
||||
|
private providerName!: string |
||||
|
|
||||
|
/** |
||||
|
* 功能提供者标识 |
||||
|
*/ |
||||
|
@Prop({ default: '' }) |
||||
|
private providerKey!: string |
||||
|
|
||||
|
/** |
||||
|
* 默认选择tab选项卡 |
||||
|
* 如果不定义的话,动态组合的表单需要手动点击一次才会显示? |
||||
|
*/ |
||||
|
private selectTab = '' |
||||
|
/** |
||||
|
* 用于拼接动态表单的功能数据,需要把abp返回的数据做一次调整 |
||||
|
*/ |
||||
|
private features = new FeatureItems() |
||||
|
|
||||
|
@Watch('providerKey', { immediate: true }) |
||||
|
onProviderKeyChanged() { |
||||
|
if (this.providerKey) { |
||||
|
this.handleGetFeatures() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 重置表单数据 |
||||
|
*/ |
||||
|
public resetFeature() { |
||||
|
this.features = new FeatureItems() |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取功能列表 |
||||
|
*/ |
||||
|
private handleGetFeatures() { |
||||
|
FeatureManagementService.getFeatures(this.providerName, this.providerKey).then(res => { |
||||
|
this.features = new FeatureItems() |
||||
|
res.features.forEach(feature => { |
||||
|
const featureTrue = new FeatureItem( |
||||
|
feature.name, |
||||
|
feature.value, |
||||
|
feature.displayName, |
||||
|
feature.description, |
||||
|
feature.valueType, |
||||
|
feature.depth |
||||
|
) |
||||
|
if (feature.parentName) { |
||||
|
const children = this.features.features.find(f => f.name === feature.parentName) |
||||
|
if (children) { |
||||
|
children.appendChildren(featureTrue) |
||||
|
} else { |
||||
|
this.features.features.push(featureTrue) |
||||
|
} |
||||
|
} else { |
||||
|
this.features.features.push(featureTrue) |
||||
|
} |
||||
|
}) |
||||
|
// 需要手动选择一下? |
||||
|
if (this.features.features.length > 0) { |
||||
|
this.selectTab = this.features.features[0].name |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 保存变更 |
||||
|
*/ |
||||
|
private onSave() { |
||||
|
if (this.features.features.length > 0) { |
||||
|
const frmFeature = this.$refs.frmFeature as any |
||||
|
frmFeature.validate((valid: boolean) => { |
||||
|
if (valid) { |
||||
|
const updateFeatures = new Features() |
||||
|
this.features.features.forEach(feature => { |
||||
|
this.getChangedFeatures(feature, updateFeatures) |
||||
|
}) |
||||
|
FeatureManagementService |
||||
|
.updateFeatures(this.providerName, this.providerKey, updateFeatures) |
||||
|
.then(() => { |
||||
|
this.$message.success(this.$t('global.successful').toString()) |
||||
|
this.onClosed() |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 递归获取abp的功能接口格式数据 |
||||
|
*/ |
||||
|
private getChangedFeatures(feature: FeatureItem, features: Features) { |
||||
|
const updateFeature = new Feature(feature.name, feature.value) |
||||
|
features.features.push(updateFeature) |
||||
|
feature.children.forEach(children => { |
||||
|
this.getChangedFeatures(children, features) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 关闭模态窗口 |
||||
|
*/ |
||||
|
private onClosed() { |
||||
|
this.$emit('closed') |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.confirm { |
||||
|
width: 120px; |
||||
|
position: absolute; |
||||
|
right: 180px; |
||||
|
} |
||||
|
.cancel { |
||||
|
width: 120px; |
||||
|
position: absolute; |
||||
|
right: 40px; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,41 @@ |
|||||
|
<template> |
||||
|
<el-dialog |
||||
|
:visible="showDialog" |
||||
|
title="管理功能" |
||||
|
width="800px" |
||||
|
:show-close="false" |
||||
|
@closed="onFormClosed" |
||||
|
> |
||||
|
<feature-management |
||||
|
ref="featureManagement" |
||||
|
provider-name="T" |
||||
|
:provider-key="tenantId" |
||||
|
@closed="onFormClosed" |
||||
|
/> |
||||
|
</el-dialog> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts"> |
||||
|
import { Component, Prop, Vue } from 'vue-property-decorator' |
||||
|
import FeatureManagement from '../../components/FeatureManagement.vue' |
||||
|
|
||||
|
@Component({ |
||||
|
name: 'TenantFeatureEditForm', |
||||
|
components: { |
||||
|
FeatureManagement |
||||
|
} |
||||
|
}) |
||||
|
export default class extends Vue { |
||||
|
@Prop({ default: '' }) |
||||
|
private tenantId!: string |
||||
|
|
||||
|
@Prop({ default: false }) |
||||
|
private showDialog!: boolean |
||||
|
|
||||
|
private onFormClosed() { |
||||
|
this.$emit('closed') |
||||
|
const featureManagement = this.$refs.featureManagement as FeatureManagement |
||||
|
featureManagement.resetFeature() |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
Loading…
Reference in new issue