From 4d891b432639c471eb223a73c653605f168ee985 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 22 Dec 2020 11:28:44 +0800 Subject: [PATCH 1/5] support menu meta object value --- .../LINGYUN/Platform/Datas/ValueType.cs | 4 +- .../LINGYUN/Platform/Datas/DataItem.cs | 3 + .../Platform/Datas/DataItemMappingOptions.cs | 12 ++- .../PlatformEfCoreQueryableExtensions.cs | 10 ++ .../Platform/Menus/EfCoreMenuRepository.cs | 5 + vueJs/src/api/data-dictionary.ts | 3 +- vueJs/src/components/InputObject/index.vue | 102 ++++++++++++++++++ .../CreateOrUpdateDataItemDialog.vue | 6 ++ .../components/DataDictionaryTree.vue | 12 +-- .../components/DataItemTable.vue | 2 + .../components/CreateOrUpdateMenuDialog.vue | 20 +++- .../menus/components/MenuMetaInput.vue | 19 +++- 12 files changed, 182 insertions(+), 16 deletions(-) create mode 100644 vueJs/src/components/InputObject/index.vue diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Datas/ValueType.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Datas/ValueType.cs index f2d878d35..39703c081 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Datas/ValueType.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Datas/ValueType.cs @@ -7,7 +7,7 @@ Boolean = 2, Date = 3, DateTime = 4, - Array = 5 - + Array = 5, + Object = 6 } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataItem.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataItem.cs index 7730c8656..0ec149f99 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataItem.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataItem.cs @@ -78,6 +78,9 @@ namespace LINGYUN.Platform.Datas case ValueType.Numeic: DefaultValue = "0"; break; + case ValueType.Object: + DefaultValue = "{}"; + break; default: case ValueType.String: DefaultValue = ""; diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataItemMappingOptions.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataItemMappingOptions.cs index 64749afe3..c7d80cbee 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataItemMappingOptions.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataItemMappingOptions.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json.Linq; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using Volo.Abp; @@ -90,6 +91,15 @@ namespace LINGYUN.Platform.Datas } return value.ToString(); }); + SetMapping(ValueType.Object, value => + { + if (value == null) + { + return "{}"; + } + + return JsonConvert.SerializeObject(value); + }); } public void SetMapping(ValueType valueType, Func func) diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEfCoreQueryableExtensions.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEfCoreQueryableExtensions.cs index 46d257581..53a44e2e8 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEfCoreQueryableExtensions.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEfCoreQueryableExtensions.cs @@ -19,6 +19,16 @@ namespace LINGYUN.Platform.EntityFrameworkCore return queryable; } + public static IQueryable IncludeDetails(this IQueryable queryable, bool include = true) + { + if (!include) + { + return queryable; + } + + return queryable; + } + public static IQueryable IncludeDetails(this IQueryable queryable, bool include = true) { if (!include) diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreMenuRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreMenuRepository.cs index f934545e5..50186cbb2 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreMenuRepository.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreMenuRepository.cs @@ -234,5 +234,10 @@ namespace LINGYUN.Platform.Menus DbContext.Set().RemoveRange(membersQuery); } + + public override IQueryable WithDetails() + { + return GetQueryable().IncludeDetails(); + } } } diff --git a/vueJs/src/api/data-dictionary.ts b/vueJs/src/api/data-dictionary.ts index de6fb6b2a..45134ce7f 100644 --- a/vueJs/src/api/data-dictionary.ts +++ b/vueJs/src/api/data-dictionary.ts @@ -59,7 +59,8 @@ export enum ValueType { Boolean = 2, Date = 3, DateTime = 4, - Array = 5 + Array = 5, + Object = 6 } export class DataItem { diff --git a/vueJs/src/components/InputObject/index.vue b/vueJs/src/components/InputObject/index.vue new file mode 100644 index 000000000..e458fcecb --- /dev/null +++ b/vueJs/src/components/InputObject/index.vue @@ -0,0 +1,102 @@ + + + diff --git a/vueJs/src/views/admin/data-dictionary/components/CreateOrUpdateDataItemDialog.vue b/vueJs/src/views/admin/data-dictionary/components/CreateOrUpdateDataItemDialog.vue index 0044e7622..eaffcbde8 100644 --- a/vueJs/src/views/admin/data-dictionary/components/CreateOrUpdateDataItemDialog.vue +++ b/vueJs/src/views/admin/data-dictionary/components/CreateOrUpdateDataItemDialog.vue @@ -26,6 +26,7 @@ > + {{ $t('AppPlatform.Data:AddNew') }} @@ -99,7 +99,7 @@ export default class DataDictionaryTree extends Vue { icon: 'el-icon-edit', disabled: !checkPermission(['Platform.DataDictionary.Update']), onClick: () => { - this.handleEditData(data) + this.handleEditData(data.id) } }, { @@ -107,7 +107,7 @@ export default class DataDictionaryTree extends Vue { icon: 'ivu-icon ivu-icon-md-add', disabled: !checkPermission(['Platform.DataDictionary.Create']), onClick: () => { - this.handleEditData() + this.handleEditData('') } }, { @@ -152,11 +152,11 @@ export default class DataDictionaryTree extends Vue { } } - private handleEditData(data?: Data) { + private handleEditData(dataId: string) { this.editDataTitle = this.l('AppPlatform.Data:AddNew') this.isEditData = false - if (data) { - this.editDataId = data.id + if (dataId) { + this.editDataId = dataId this.isEditData = true this.editDataTitle = this.l('AppPlatform.Data:Edit') } else { diff --git a/vueJs/src/views/admin/data-dictionary/components/DataItemTable.vue b/vueJs/src/views/admin/data-dictionary/components/DataItemTable.vue index 591da5647..f08298083 100644 --- a/vueJs/src/views/admin/data-dictionary/components/DataItemTable.vue +++ b/vueJs/src/views/admin/data-dictionary/components/DataItemTable.vue @@ -141,6 +141,8 @@ import CreateOrUpdateDataItemDialog from './CreateOrUpdateDataItemDialog.vue' return 'DateTime' case ValueType.Array: return 'Array' + case ValueType.Object: + return 'Object' default: case ValueType.String: return 'String' diff --git a/vueJs/src/views/container/menus/components/CreateOrUpdateMenuDialog.vue b/vueJs/src/views/container/menus/components/CreateOrUpdateMenuDialog.vue index 3aa84600b..c21fa4580 100644 --- a/vueJs/src/views/container/menus/components/CreateOrUpdateMenuDialog.vue +++ b/vueJs/src/views/container/menus/components/CreateOrUpdateMenuDialog.vue @@ -126,7 +126,7 @@ :label="$t(('AppPlatform.DisplayName:Meta'))" > - {{ dataItem.displayName }} + >{{ dataItem.displayName }} --> { + return pre.valueType < next.valueType ? -1 : 0 + }) + return items + } + private activedTab = 'basic' private menu = new Menu() private bindData = new Data() @@ -282,6 +289,9 @@ export default class CreateOrUpdateMenuDialog extends Vue { private onLayoutChanged() { const layout = this.layouts.find(x => x.id === this.layoutId) if (layout) { + if (!this.isEdit) { + this.menu.meta = {} + } if (!this.parentId) { // 对于根菜单,自动设置组件路径为布局路径 this.menu.component = layout.path diff --git a/vueJs/src/views/container/menus/components/MenuMetaInput.vue b/vueJs/src/views/container/menus/components/MenuMetaInput.vue index e11f31720..bf79918c0 100644 --- a/vueJs/src/views/container/menus/components/MenuMetaInput.vue +++ b/vueJs/src/views/container/menus/components/MenuMetaInput.vue @@ -32,6 +32,11 @@ :value="inputArrayValue(value)" @input="onInputMetaChanged" /> + @@ -40,12 +45,14 @@ import { Component, Vue, Prop } from 'vue-property-decorator' import { DataItem } from '@/api/data-dictionary' import { isBoolean } from 'lodash' import ElInputTag from '@/components/InputTag/index.vue' +import InputObject from '@/components/InputObject/index.vue' import { isArray } from '@/utils/validate' @Component({ name: 'MenuMetaInput', components: { - ElInputTag + ElInputTag, + InputObject } }) export default class MenuMetaInput extends Vue { @@ -87,6 +94,16 @@ export default class MenuMetaInput extends Vue { this.value = String(value).split(',') } + get inputObjectValue() { + if (typeof this.value === 'object') { + return this.value + } + if (typeof this.value === 'string') { + return JSON.parse(this.value) + } + return JSON.parse(String(this.value)) + } + onInputMetaChanged(value: any) { this.$emit('input', value) } From 59e183f6f016417fead7fbea60538a02ffc68123 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 22 Dec 2020 11:59:34 +0800 Subject: [PATCH 2/5] switch roles should clear the menu checkbox --- .../src/views/admin/roles/components/ManageRoleMenuDialog.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vueJs/src/views/admin/roles/components/ManageRoleMenuDialog.vue b/vueJs/src/views/admin/roles/components/ManageRoleMenuDialog.vue index 9a24276a1..8845ae388 100644 --- a/vueJs/src/views/admin/roles/components/ManageRoleMenuDialog.vue +++ b/vueJs/src/views/admin/roles/components/ManageRoleMenuDialog.vue @@ -150,6 +150,10 @@ export default class ManageRoleMenuDialog extends Vue { } private onFormClosed() { + this.$nextTick(() => { + const tree = this.$refs.roleMenuTree as Tree + tree.setCheckedKeys([]) + }) this.$emit('closed') } } From a86db56d455b812fa42583d66e795067b0bcfe01 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 22 Dec 2020 14:42:23 +0800 Subject: [PATCH 3/5] add user menu manage view --- .../LINGYUN.ApiGateway.Host/event-bus-cap.db | Bin 40960 -> 40960 bytes .../AppPlatformHttpApiHostModule.cs | 4 +- .../LINGYUN.Platform.HttpApi.Host.csproj | 2 +- vueJs/src/api/menu.ts | 24 ++- .../src/layout/components/TagsView/index.vue | 11 +- .../roles/components/ManageRoleMenuDialog.vue | 13 +- .../users/components/ManageUserMenuDialog.vue | 172 ++++++++++++++++++ vueJs/src/views/admin/users/index.vue | 43 +++-- .../components/CreateOrUpdateMenuDialog.vue | 21 +-- 9 files changed, 243 insertions(+), 47 deletions(-) create mode 100644 vueJs/src/views/admin/users/components/ManageUserMenuDialog.vue diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/event-bus-cap.db b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/event-bus-cap.db index dc066d37fec461d90669698c4d938b7f2fe9c2fb..56ad120b11479f64606ccca2b7eb1dcd39cd2fca 100644 GIT binary patch delta 228 zcmZoTz|?SnX@WGP`9v9KM)QpcOZYjMxHA}dw{T}{<`IbD7Hjcj;$ahPWHxMz=5ThF z7n-Zs6ZuqOa$|I>poyW8nW>?vftjhfiHW79g~{Z^ym}5JBLzbfD?`J{fmO2nXi6r> zcSVRA=^7b@fR$L8nCTgqn;ILK8&Ccy=s5X-1cx3>J6O)b!ot$b+{nPlK-Unc%@|^` vm5I5Yfq|K&shRoa)v}RH98CPr8Th~OKi|xwaGRf-hnbBL>deib^!W+^iSj#% delta 218 zcmZoTz|?SnX@WGP=|mZ4M$?T6OZYh$dABg|ZsC;K%p(xPEyBRSGJ{R9k=d{&_glLNEl1k8;MkrfzCPV5R3 zHPSUS3<0aLGBDCJGBGeSH!_{v81JbE(+d%|FtD&RH!?6X&@}{VF@hKik}@+fv9K^T n+`L*gl8J+n{|f{E7yetDc@%E*b2Bh7NP->rbHnCO`g{cdEw?v- diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs index f4a0d45ff..658dddbef 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs @@ -46,7 +46,7 @@ using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.TenantManagement.EntityFrameworkCore; using Volo.Abp.Threading; using Volo.Abp.VirtualFileSystem; -using Volo.Abp.Http.Client.IdentityModel; +using Volo.Abp.Http.Client.IdentityModel.Web; namespace LINGYUN.Platform { @@ -57,7 +57,7 @@ namespace LINGYUN.Platform typeof(PlatformHttpApiModule), typeof(PlatformEntityFrameworkCoreModule), typeof(AbpIdentityHttpApiClientModule), - typeof(AbpHttpClientIdentityModelModule), + typeof(AbpHttpClientIdentityModelWebModule), typeof(AbpAspNetCoreMultiTenancyModule), typeof(AbpFeatureManagementEntityFrameworkCoreModule), typeof(AbpAuditLoggingEntityFrameworkCoreModule), diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj index 936db6c7f..b67f3cc3e 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj @@ -41,7 +41,7 @@ - + diff --git a/vueJs/src/api/menu.ts b/vueJs/src/api/menu.ts index dd29a114a..3ef8ecb01 100644 --- a/vueJs/src/api/menu.ts +++ b/vueJs/src/api/menu.ts @@ -29,8 +29,13 @@ export default class MenuService { return ApiService.Get>(_url, serviceUrl) } - public static getRoleMenuList(payload: GetRoleMenu) { - const _url = sourceUrl + '/by-role?' + urlStringify(payload) + public static getRoleMenuList(role: string, platformType: PlatformType) { + const _url = sourceUrl + `/by-role/${role}/${platformType}` + return ApiService.Get>(_url, serviceUrl) + } + + public static getUserMenuList(userId: string, platformType: PlatformType) { + const _url = sourceUrl + `/by-user/${userId}/${platformType}` return ApiService.Get>(_url, serviceUrl) } @@ -52,6 +57,11 @@ export default class MenuService { const _url = sourceUrl + '/by-role' return ApiService.Put(_url, payload,serviceUrl) } + + public static setUserMenu(payload: UserMenu) { + const _url = sourceUrl + '/by-user' + return ApiService.Put(_url, payload,serviceUrl) + } } export class MenuCreateOrUpdate { @@ -84,11 +94,6 @@ export class GetAllMenu implements ISortedResultRequest { platformType?: PlatformType } -export class GetRoleMenu { - role!: string - platformType!: PlatformType -} - export class GetMenuByPaged extends PagedAndSortedResultRequestDto { filter = '' reverse = false @@ -111,3 +116,8 @@ export class RoleMenu { roleName!: string menuIds = new Array() } + +export class UserMenu { + userId!: string + menuIds = new Array() +} diff --git a/vueJs/src/layout/components/TagsView/index.vue b/vueJs/src/layout/components/TagsView/index.vue index 8786ffd43..f57557c5b 100644 --- a/vueJs/src/layout/components/TagsView/index.vue +++ b/vueJs/src/layout/components/TagsView/index.vue @@ -18,7 +18,7 @@ @click.middle.native="!isAffix(tag)?closeSelectedTag(tag):''" @contextmenu.prevent.native="openMenu(tag, $event)" > - {{ $t('route.' + tag.meta.title) }} + {{ routeTitle(tag) }} { + if (route.meta.displayName) { + return route.meta.displayName + } + return this.$t('route.' + route.meta.title) + } + } + @Watch('$route') private onRouteChange() { this.addTags() diff --git a/vueJs/src/views/admin/roles/components/ManageRoleMenuDialog.vue b/vueJs/src/views/admin/roles/components/ManageRoleMenuDialog.vue index 8845ae388..dacff57a5 100644 --- a/vueJs/src/views/admin/roles/components/ManageRoleMenuDialog.vue +++ b/vueJs/src/views/admin/roles/components/ManageRoleMenuDialog.vue @@ -2,6 +2,7 @@ import { Component, Vue, Prop, Watch } from 'vue-property-decorator' -import MenuService, { Menu, GetAllMenu, GetRoleMenu, RoleMenu } from '@/api/menu' +import MenuService, { Menu, GetAllMenu, RoleMenu } from '@/api/menu' import { generateTree } from '@/utils' -import { PlatformTypes } from '@/api/layout' +import { PlatformType, PlatformTypes } from '@/api/layout' import { Tree } from 'element-ui' @Component({ @@ -90,7 +91,6 @@ export default class ManageRoleMenuDialog extends Vue { private menus = new Array() private roleMenuIds = new Array() private getMenuQuery = new GetAllMenu() - private getRoleMenuQuery = new GetRoleMenu() private platformTypes = PlatformTypes private confirmButtonBusy = false private menuProps = { @@ -110,9 +110,9 @@ export default class ManageRoleMenuDialog extends Vue { this.handleGetRoleMenus() } - private onPlatformTypeChanged(value: any) { - this.getRoleMenuQuery.platformType = value + private onPlatformTypeChanged() { this.handleGetMenus() + this.handleGetRoleMenus() } private handleGetMenus() { @@ -125,9 +125,8 @@ export default class ManageRoleMenuDialog extends Vue { private handleGetRoleMenus() { if (this.showDialog && this.roleName) { - this.getRoleMenuQuery.role = this.roleName MenuService - .getRoleMenuList(this.getRoleMenuQuery) + .getRoleMenuList(this.roleName, this.getMenuQuery.platformType || PlatformType.None) .then(res => { this.roleMenuIds = res.items.map(item => item.id) }) diff --git a/vueJs/src/views/admin/users/components/ManageUserMenuDialog.vue b/vueJs/src/views/admin/users/components/ManageUserMenuDialog.vue new file mode 100644 index 000000000..d49a7aec4 --- /dev/null +++ b/vueJs/src/views/admin/users/components/ManageUserMenuDialog.vue @@ -0,0 +1,172 @@ + + + + + diff --git a/vueJs/src/views/admin/users/index.vue b/vueJs/src/views/admin/users/index.vue index dfa768fb7..263ab8610 100644 --- a/vueJs/src/views/admin/users/index.vue +++ b/vueJs/src/views/admin/users/index.vue @@ -116,10 +116,19 @@