mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-20 08:26:37 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93180faa23 | ||
|
|
816858f231 | ||
|
|
fa1d68848f | ||
|
|
bce955a1e1 | ||
|
|
82f70e0ac9 | ||
|
|
fc9b78cfef | ||
|
|
72400a48da | ||
|
|
537b39b3c4 | ||
|
|
47e6e48729 | ||
|
|
d252229777 |
@@ -22,7 +22,8 @@ Yi框架-一套与SqlSugar一样爽的.Net6低代码开源框架。
|
|||||||
适合.Net6学习、Sqlsugar学习 、项目二次开发。
|
适合.Net6学习、Sqlsugar学习 、项目二次开发。
|
||||||
集大成者,终究轮子
|
集大成者,终究轮子
|
||||||
|
|
||||||
Yi框架最新版本标签:`v1.1.3`,具体版本可以查看标签迭代
|
|
||||||
|
Yi框架最新版本标签:`v1.1.6`,具体版本可以查看标签迭代
|
||||||
|
|
||||||
(项目与Sqlsugar同步更新,但这作者老杰哥代码天天爆肝到凌晨两点,我们也尽量会跟上他的脚步。更新频繁,所以可watching持续关注。)
|
(项目与Sqlsugar同步更新,但这作者老杰哥代码天天爆肝到凌晨两点,我们也尽量会跟上他的脚步。更新频繁,所以可watching持续关注。)
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -32,7 +32,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Permission($"{nameof(T)}:get:list")]
|
[Permission($"{nameof(T)}:get")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public virtual async Task<Result> GetById(long id)
|
public virtual async Task<Result> GetById(long id)
|
||||||
{
|
{
|
||||||
@@ -43,7 +43,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
/// 列表查询
|
/// 列表查询
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Permission($"{nameof(T)}:get:list")]
|
[Permission($"{nameof(T)}:get")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public virtual async Task<Result> GetList(QueryCondition queryCondition)
|
public virtual async Task<Result> GetList(QueryCondition queryCondition)
|
||||||
{
|
{
|
||||||
@@ -55,7 +55,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="queryCondition"></param>
|
/// <param name="queryCondition"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Permission($"{nameof(T)}:get:list")]
|
[Permission($"{nameof(T)}:get")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public virtual async Task<Result> PageList(QueryPageCondition queryCondition)
|
public virtual async Task<Result> PageList(QueryPageCondition queryCondition)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,16 @@
|
|||||||
<None Remove="wwwrooot\**" />
|
<None Remove="wwwrooot\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="yi-sqlsugar-dev.db" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="yi-sqlsugar-dev.db">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Yi.Framework.DTOModel\Yi.Framework.DTOModel.csproj" />
|
<ProjectReference Include="..\Yi.Framework.DTOModel\Yi.Framework.DTOModel.csproj" />
|
||||||
<ProjectReference Include="..\Yi.Framework.Interface\Yi.Framework.Interface.csproj" />
|
<ProjectReference Include="..\Yi.Framework.Interface\Yi.Framework.Interface.csproj" />
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"StartUrl": "http://localohost:19001",
|
"StartUrl": "http://*:19001",
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"StartUrl": "http://localohost:19001",
|
"StartUrl": "http://*:19001",
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
|
|||||||
Binary file not shown.
@@ -42,7 +42,7 @@ namespace Yi.Framework.Core
|
|||||||
|
|
||||||
foreach (var m in menus)
|
foreach (var m in menus)
|
||||||
{
|
{
|
||||||
claims.Add(new Claim("permission", m.PermissionCode));
|
claims.Add(new Claim("permission", m.PermissionCode.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRefresh)
|
if (isRefresh)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace Yi.Framework.Model.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
///</summary>
|
///</summary>
|
||||||
[SugarColumn(ColumnName= "PermissionCode")]
|
[SugarColumn(ColumnName="PermissionCode" )]
|
||||||
public string PermissionCode { get; set; }
|
public string PermissionCode { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -69,5 +69,15 @@ namespace Yi.Framework.Model.Models
|
|||||||
///</summary>
|
///</summary>
|
||||||
[SugarColumn(ColumnName="TenantId" )]
|
[SugarColumn(ColumnName="TenantId" )]
|
||||||
public long? TenantId { get; set; }
|
public long? TenantId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
///</summary>
|
||||||
|
[SugarColumn(ColumnName="MenuIcon" )]
|
||||||
|
public string MenuIcon { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
///</summary>
|
||||||
|
[SugarColumn(ColumnName="Router" )]
|
||||||
|
public string Router { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,5 +54,10 @@ namespace Yi.Framework.Model.Models
|
|||||||
///</summary>
|
///</summary>
|
||||||
[SugarColumn(ColumnName="ModifyUser" )]
|
[SugarColumn(ColumnName="ModifyUser" )]
|
||||||
public long? ModifyUser { get; set; }
|
public long? ModifyUser { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
///</summary>
|
||||||
|
[SugarColumn(ColumnName="RoleCode" )]
|
||||||
|
public string RoleCode { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="NEST" Version="7.16.0" />
|
<PackageReference Include="NEST" Version="7.16.0" />
|
||||||
<PackageReference Include="SqlSugarCore" Version="5.0.7.5" />
|
<PackageReference Include="SqlSugarCore" Version="5.0.7.8" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ namespace Yi.Framework.Repository
|
|||||||
public Task<List<T>> GetListAsync(QueryCondition pars);
|
public Task<List<T>> GetListAsync(QueryCondition pars);
|
||||||
public Task<bool> DeleteByLogicAsync(List<long> ids);
|
public Task<bool> DeleteByLogicAsync(List<long> ids);
|
||||||
public Task<bool> UpdateIgnoreNullAsync(T entity);
|
public Task<bool> UpdateIgnoreNullAsync(T entity);
|
||||||
public Task<List<S>> UseSqlAsync<S>(string sql);
|
public Task<List<S>> UseSqlAsync<S>(string sql, object parameters = null);
|
||||||
public Task<bool> UseSqlAsync(string sql);
|
public Task<bool> UseSqlAsync(string sql, object parameters = null);
|
||||||
ISugarQueryable<T> QueryConditionHandler(QueryCondition pars);
|
ISugarQueryable<T> QueryConditionHandler(QueryCondition pars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,24 +42,21 @@ namespace Yi.Framework.Repository
|
|||||||
/// <typeparam name="S"></typeparam>
|
/// <typeparam name="S"></typeparam>
|
||||||
/// <param name="sql"></param>
|
/// <param name="sql"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<List<S>> UseSqlAsync<S>(string sql)
|
public async Task<List<S>> UseSqlAsync<S>(string sql, object parameters = null)
|
||||||
{
|
{
|
||||||
return await _Db.Ado.SqlQueryAsync<S>(sql);
|
return await _Db.Ado.SqlQueryAsync<S>(sql, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 执行增删改sql返回状态
|
/// 执行增删改sql返回状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sql"></param>
|
/// <param name="sql"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<bool> UseSqlAsync(string sql)
|
public async Task<bool> UseSqlAsync(string sql, object parameters)
|
||||||
{
|
{
|
||||||
return await _Db.Ado.ExecuteCommandAsync(sql)>0;
|
return await _Db.Ado.ExecuteCommandAsync(sql, parameters) >0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加返回实体
|
/// 添加返回实体
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Yi.Framework.Common.Helper;
|
using Yi.Framework.Common.Helper;
|
||||||
@@ -112,7 +113,7 @@ namespace Yi.Framework.Service
|
|||||||
//首先获取到该用户全部信息,导航到角色、菜单,(菜单需要去重,完全交给Set来处理即可)
|
//首先获取到该用户全部信息,导航到角色、菜单,(菜单需要去重,完全交给Set来处理即可)
|
||||||
|
|
||||||
//得到用户
|
//得到用户
|
||||||
var user = await _repository._Db.Queryable<UserEntity>().Includes(u => u.Roles, r => r.Menus).InSingleAsync(userId);
|
var user = await _repository._Db.Queryable<UserEntity>().Includes(u => u.Roles.Where(r=>r.IsDeleted==false).ToList(), r => r.Menus.Where(m=>m.IsDeleted==false).ToList()).InSingleAsync(userId);
|
||||||
|
|
||||||
//得到角色集合
|
//得到角色集合
|
||||||
var roleList = user.Roles;
|
var roleList = user.Roles;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
|||||||
var apiXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//控制器层注释
|
var apiXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//控制器层注释
|
||||||
//var entityXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//实体注释
|
//var entityXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//实体注释
|
||||||
//c.IncludeXmlComments(apiXmlPath, true);//true表示显示控制器注释
|
//c.IncludeXmlComments(apiXmlPath, true);//true表示显示控制器注释
|
||||||
c.IncludeXmlComments(apiXmlPath,true);
|
c.IncludeXmlComments(apiXmlPath, true);
|
||||||
|
|
||||||
//添加控制器注释
|
//添加控制器注释
|
||||||
//c.DocumentFilter<SwaggerDocTag>();
|
//c.DocumentFilter<SwaggerDocTag>();
|
||||||
@@ -42,25 +42,40 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
|||||||
//添加header验证信息
|
//添加header验证信息
|
||||||
//c.OperationFilter<SwaggerHeader>();
|
//c.OperationFilter<SwaggerHeader>();
|
||||||
//var security = new Dictionary<string, IEnumerable<string>> { { "Bearer", new string[] { } }, };
|
//var security = new Dictionary<string, IEnumerable<string>> { { "Bearer", new string[] { } }, };
|
||||||
|
c.AddSecurityDefinition("JwtBearer", new OpenApiSecurityScheme()
|
||||||
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
|
|
||||||
{
|
{
|
||||||
Description = "文本框里输入从服务器获取的Token。格式为:Bearer + 空格+token",//JWT授权(数据将在请求头中进行传输) 参数结构: \"Authorization: Bearer {token}\"
|
Description = "直接输入Token即可",
|
||||||
Name = "Authorization",////jwt默认的参数名称
|
Name = "Authorization",
|
||||||
In = ParameterLocation.Header,////jwt默认存放Authorization信息的位置(请求头中)
|
In = ParameterLocation.Header,
|
||||||
Type = SecuritySchemeType.ApiKey,
|
Type = SecuritySchemeType.Http,
|
||||||
|
Scheme = "bearer"
|
||||||
});
|
});
|
||||||
c.AddSecurityRequirement(new OpenApiSecurityRequirement
|
var scheme = new OpenApiSecurityScheme()
|
||||||
{
|
{
|
||||||
{ new OpenApiSecurityScheme
|
Reference = new OpenApiReference() { Type = ReferenceType.SecurityScheme, Id = "JwtBearer" }
|
||||||
{
|
};
|
||||||
Reference = new OpenApiReference()
|
c.AddSecurityRequirement(new OpenApiSecurityRequirement()
|
||||||
{
|
{
|
||||||
Id = "Bearer",
|
[scheme] = new string[0]
|
||||||
Type = ReferenceType.SecurityScheme
|
|
||||||
}
|
|
||||||
}, Array.Empty<string>() }
|
|
||||||
});
|
});
|
||||||
|
//c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
|
||||||
|
//{
|
||||||
|
// Description = "文本框里输入从服务器获取的Token。格式为:Bearer + 空格+token",//JWT授权(数据将在请求头中进行传输) 参数结构: \"Authorization: Bearer {token}\"
|
||||||
|
// Name = "Authorization",////jwt默认的参数名称
|
||||||
|
// In = ParameterLocation.Header,////jwt默认存放Authorization信息的位置(请求头中)
|
||||||
|
// Type = SecuritySchemeType.ApiKey,
|
||||||
|
//});
|
||||||
|
//c.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||||
|
//{
|
||||||
|
// { new OpenApiSecurityScheme
|
||||||
|
// {
|
||||||
|
// Reference = new OpenApiReference()
|
||||||
|
// {
|
||||||
|
// Id = "Bearer",
|
||||||
|
// Type = ReferenceType.SecurityScheme
|
||||||
|
// }
|
||||||
|
// }, Array.Empty<string>() }
|
||||||
|
//});
|
||||||
|
|
||||||
//c.AddServer(new OpenApiServer()
|
//c.AddServer(new OpenApiServer()
|
||||||
//{
|
//{
|
||||||
|
|||||||
@@ -19,4 +19,12 @@ export default {
|
|||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
GiveUserSetRole(UserIds,RoleIds)
|
||||||
|
{
|
||||||
|
return myaxios({
|
||||||
|
url: `/User/GiveUserSetRole`,
|
||||||
|
method: 'put',
|
||||||
|
data:{UserIds,RoleIds}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<v-avatar :size="size" >
|
<v-avatar :size="size" >
|
||||||
<!-- <img src="https://z3.ax1x.com/2021/05/09/gJadhD.jpg" /> -->
|
<!-- <img src="https://z3.ax1x.com/2021/05/09/gJadhD.jpg" /> -->
|
||||||
<img
|
<img
|
||||||
:src="baseurl +'/image/'+$store.state.user.user.icon"
|
:src="baseurl +'/image/'+$store.state.user.user.user.icon"
|
||||||
/>
|
/>
|
||||||
</v-avatar>
|
</v-avatar>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ export default {
|
|||||||
watch:{
|
watch:{
|
||||||
select:{//深度监听,可监听到对象、数组的变化
|
select:{//深度监听,可监听到对象、数组的变化
|
||||||
handler(val, oldVal){
|
handler(val, oldVal){
|
||||||
|
console.log(oldVal)
|
||||||
|
console.log(val)
|
||||||
this.$emit("select",val);
|
this.$emit("select",val);
|
||||||
},
|
},
|
||||||
deep:true
|
deep:true
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
></v-text-field>
|
></v-text-field>
|
||||||
|
|
||||||
<v-btn
|
<v-btn
|
||||||
v-if="axiosUrls.add != null"
|
v-if="btnEnable.add==true"
|
||||||
color="primary"
|
color="primary"
|
||||||
dark
|
dark
|
||||||
class="mb-2 mx-2"
|
class="mb-2 mx-2"
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
<!-- 添加提示框 -->
|
<!-- 添加提示框 -->
|
||||||
<v-dialog
|
<v-dialog
|
||||||
v-if="axiosUrls.add != null"
|
v-if="btnEnable.add ==true"
|
||||||
v-model="dialog"
|
v-model="dialog"
|
||||||
max-width="500px"
|
max-width="500px"
|
||||||
>
|
>
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
<v-btn
|
<v-btn
|
||||||
v-if="axiosUrls.del != null"
|
v-if="btnEnable.del == true"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
class="mb-2"
|
class="mb-2"
|
||||||
@click="deleteItem(null)"
|
@click="deleteItem(null)"
|
||||||
@@ -87,14 +87,14 @@
|
|||||||
<slot name="action" :item="item"></slot>
|
<slot name="action" :item="item"></slot>
|
||||||
|
|
||||||
<v-icon
|
<v-icon
|
||||||
v-if="axiosUrls.update != null"
|
v-if="btnEnable.update ==true"
|
||||||
small
|
small
|
||||||
class="mr-2"
|
class="mr-2"
|
||||||
@click="editItem(item)"
|
@click="editItem(item)"
|
||||||
>
|
>
|
||||||
mdi-pencil
|
mdi-pencil
|
||||||
</v-icon>
|
</v-icon>
|
||||||
<v-icon v-if="axiosUrls.del != null" small @click="deleteItem(item)">
|
<v-icon v-if="btnEnable.del ==true" small @click="deleteItem(item)">
|
||||||
mdi-delete
|
mdi-delete
|
||||||
</v-icon>
|
</v-icon>
|
||||||
</template>
|
</template>
|
||||||
@@ -119,6 +119,9 @@ export default {
|
|||||||
axiosUrls: {
|
axiosUrls: {
|
||||||
type: Object,
|
type: Object,
|
||||||
},
|
},
|
||||||
|
btnEnable: {
|
||||||
|
type: Object,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
page: 1,
|
page: 1,
|
||||||
@@ -166,7 +169,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
initialize() {
|
initialize() {
|
||||||
if(this.axiosUrls.get!=undefined && this.axiosUrls.get!=null )
|
if(this.btnEnable.get==true )
|
||||||
{
|
{
|
||||||
this.dataInit(this.axiosUrls.get)
|
this.dataInit(this.axiosUrls.get)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,10 +52,15 @@
|
|||||||
hoverable
|
hoverable
|
||||||
item-text="menuName"
|
item-text="menuName"
|
||||||
>
|
>
|
||||||
|
<template v-slot:prepend="{ item }">
|
||||||
|
<v-icon>
|
||||||
|
{{ item.menuIcon }}
|
||||||
|
</v-icon>
|
||||||
|
</template>
|
||||||
<template v-slot:append="{ item }">
|
<template v-slot:append="{ item }">
|
||||||
<v-btn v-show="item.menuType==1" class="mr-2">权限:{{ item.permissionCode }}</v-btn>
|
<app-btn v-show="item.menuType==1" class="mr-2" color="secondary"> 权限:{{ item.permissionCode }}</app-btn>
|
||||||
<!-- <v-btn class="mr-2">图标:{{ item.icon }}</v-btn> -->
|
<!-- <v-btn class="mr-2">图标:{{ item.icon }}</v-btn> -->
|
||||||
<!-- <v-btn class="mr-2">路由:{{ item.router }}</v-btn> -->
|
<app-btn v-show="item.menuType==0" class="mr-2" >路由:{{ item.router }}</app-btn>
|
||||||
<!-- <v-btn v-if="item.mould" class="mr-2">接口名:{{ item.mould.mould_name }}</v-btn>
|
<!-- <v-btn v-if="item.mould" class="mr-2">接口名:{{ item.mould.mould_name }}</v-btn>
|
||||||
<v-btn v-if="item.mould" class="mr-2" color="secondary">接口地址:{{ item.mould.url }}</v-btn> -->
|
<v-btn v-if="item.mould" class="mr-2" color="secondary">接口地址:{{ item.mould.url }}</v-btn> -->
|
||||||
<!-- <ccCombobox
|
<!-- <ccCombobox
|
||||||
@@ -101,9 +106,10 @@ export default {
|
|||||||
editedItem: {},
|
editedItem: {},
|
||||||
editedIndex: -1,
|
editedIndex: -1,
|
||||||
defaultItem: {
|
defaultItem: {
|
||||||
// icon: "mdi-start",
|
menuIcon: "mdi-view-dashboard",
|
||||||
permissionCode: "test",
|
permissionCode: "",
|
||||||
menuName: "管理",
|
menuName: "",
|
||||||
|
router:"",
|
||||||
parentId: 0,
|
parentId: 0,
|
||||||
MenuType:0
|
MenuType:0
|
||||||
},
|
},
|
||||||
@@ -121,21 +127,16 @@ export default {
|
|||||||
this.$refs.tree.updateAll(true);
|
this.$refs.tree.updateAll(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
// setMould(item) {
|
|
||||||
// menuApi.SetMouldByMenu(item.id, this.mouldSelect[0].id).then((resp) => {
|
|
||||||
// this.$dialog.notify.info(resp.msg, {
|
|
||||||
// position: "top-right",
|
|
||||||
// timeout: 5000,
|
|
||||||
// });
|
|
||||||
// this.init();
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
|
|
||||||
getSelect(data) {
|
getSelect(data) {
|
||||||
this.mouldSelect = data;
|
this.mouldSelect = data;
|
||||||
},
|
},
|
||||||
async deleteItem(item) {
|
async deleteItem(item) {
|
||||||
this.editedIndex = 1;
|
if(item!=null)
|
||||||
|
{
|
||||||
|
this.editedIndex = 1;
|
||||||
|
}
|
||||||
|
|
||||||
this.editedItem = Object.assign({}, item);
|
this.editedItem = Object.assign({}, item);
|
||||||
var p = await this.$dialog.warning({
|
var p = await this.$dialog.warning({
|
||||||
text: "你确定要删除此条记录吗??",
|
text: "你确定要删除此条记录吗??",
|
||||||
@@ -154,7 +155,7 @@ export default {
|
|||||||
if (this.editedIndex > -1) {
|
if (this.editedIndex > -1) {
|
||||||
Ids.push(this.editedItem.id);
|
Ids.push(this.editedItem.id);
|
||||||
} else {
|
} else {
|
||||||
this.selection.forEach(function (item) {
|
this.selection.forEach( (item) =>{
|
||||||
Ids.push(item.id);
|
Ids.push(item.id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -200,6 +201,7 @@ export default {
|
|||||||
selection: {
|
selection: {
|
||||||
//深度监听,可监听到对象、数组的变化
|
//深度监听,可监听到对象、数组的变化
|
||||||
handler(val, oldVal) {
|
handler(val, oldVal) {
|
||||||
|
|
||||||
this.$emit("selection", val);
|
this.$emit("selection", val);
|
||||||
},
|
},
|
||||||
deep: true,
|
deep: true,
|
||||||
|
|||||||
@@ -1,15 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-navigation-drawer
|
<v-navigation-drawer id="default-drawer" v-model="$store.state.home.drawer" :dark="dark" :right="$vuetify.rtl"
|
||||||
id="default-drawer"
|
:src="drawerImage ? image : ''" :mini-variant.sync="$store.state.home.mini" mini-variant-width="80" app width="260">
|
||||||
v-model="$store.state.home.drawer"
|
|
||||||
:dark="dark"
|
|
||||||
:right="$vuetify.rtl"
|
|
||||||
:src="drawerImage ? image : ''"
|
|
||||||
:mini-variant.sync="$store.state.home.mini"
|
|
||||||
mini-variant-width="80"
|
|
||||||
app
|
|
||||||
width="260"
|
|
||||||
>
|
|
||||||
<template v-if="drawerImage" #img="props">
|
<template v-if="drawerImage" #img="props">
|
||||||
<v-img :key="image" :gradient="gradient" v-bind="props" />
|
<v-img :key="image" :gradient="gradient" v-bind="props" />
|
||||||
</template>
|
</template>
|
||||||
@@ -24,13 +15,7 @@
|
|||||||
|
|
||||||
<template #append>
|
<template #append>
|
||||||
<div class="pa-4 text-center">
|
<div class="pa-4 text-center">
|
||||||
<app-btn
|
<app-btn class="text-none mb-4" color="white" href="https://vuetifyjs.com" small text>
|
||||||
class="text-none mb-4"
|
|
||||||
color="white"
|
|
||||||
href="https://vuetifyjs.com"
|
|
||||||
small
|
|
||||||
text
|
|
||||||
>
|
|
||||||
Documentation
|
Documentation
|
||||||
</app-btn>
|
</app-btn>
|
||||||
|
|
||||||
@@ -49,180 +34,19 @@
|
|||||||
<script>
|
<script>
|
||||||
// Utilities
|
// Utilities
|
||||||
// import { get, sync } from 'vuex-pathify'
|
// import { get, sync } from 'vuex-pathify'
|
||||||
import userApi from "@/api/userApi";
|
import store from "@/store/index.js";
|
||||||
|
import { toTree } from "@/util/menuHandle";
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
//这里动态获取菜单,暂时写死
|
const menus = store.state.user.user.menus.filter((m) => {
|
||||||
// userApi.GetMenuByHttpUser().then((resp) => {
|
return m.menuType == 0;
|
||||||
// this.items = resp.data.children;
|
});
|
||||||
// });
|
this.items = toTree(menus);
|
||||||
this.items =
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
icon: "mdi-view-dashboard",
|
|
||||||
router: "/",
|
|
||||||
menu_name: "首页",
|
|
||||||
roles: null,
|
|
||||||
mould: null,
|
|
||||||
is_top: 0,
|
|
||||||
sort: 0,
|
|
||||||
is_show: 1,
|
|
||||||
parentId: 1,
|
|
||||||
children: null,
|
|
||||||
id: 2,
|
|
||||||
is_delete: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: "mdi-account-box-multiple",
|
|
||||||
router: null,
|
|
||||||
menu_name: "用户角色管理",
|
|
||||||
roles: null,
|
|
||||||
mould: null,
|
|
||||||
is_top: 0,
|
|
||||||
sort: 0,
|
|
||||||
is_show: 1,
|
|
||||||
parentId: 1,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
icon: "mdi-account-box",
|
|
||||||
router: "/AdmUser/",
|
|
||||||
menu_name: "用户管理",
|
|
||||||
roles: null,
|
|
||||||
mould: null,
|
|
||||||
is_top: 0,
|
|
||||||
sort: 0,
|
|
||||||
is_show: 1,
|
|
||||||
parentId: 3,
|
|
||||||
children: null,
|
|
||||||
id: 4,
|
|
||||||
is_delete: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: "mdi-account-circle",
|
|
||||||
router: "/admrole/",
|
|
||||||
menu_name: "角色管理",
|
|
||||||
roles: null,
|
|
||||||
mould: null,
|
|
||||||
is_top: 0,
|
|
||||||
sort: 0,
|
|
||||||
is_show: 1,
|
|
||||||
parentId: 3,
|
|
||||||
children: null,
|
|
||||||
id: 9,
|
|
||||||
is_delete: 0,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
id: 3,
|
|
||||||
is_delete: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: "mdi-account-cash",
|
|
||||||
router: null,
|
|
||||||
menu_name: "角色接口管理",
|
|
||||||
roles: null,
|
|
||||||
mould: null,
|
|
||||||
is_top: 0,
|
|
||||||
sort: 0,
|
|
||||||
is_show: 1,
|
|
||||||
parentId: 1,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
icon: "mdi-clipboard-check-multiple",
|
|
||||||
router: "/AdmMenu/",
|
|
||||||
menu_name: "菜单管理",
|
|
||||||
roles: null,
|
|
||||||
mould: null,
|
|
||||||
is_top: 0,
|
|
||||||
sort: 0,
|
|
||||||
is_show: 1,
|
|
||||||
parentId: 14,
|
|
||||||
children: null,
|
|
||||||
id: 15,
|
|
||||||
is_delete: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: "mdi-circle-slice-8",
|
|
||||||
router: "/admMould/",
|
|
||||||
menu_name: "接口管理",
|
|
||||||
roles: null,
|
|
||||||
mould: null,
|
|
||||||
is_top: 0,
|
|
||||||
sort: 0,
|
|
||||||
is_show: 1,
|
|
||||||
parentId: 14,
|
|
||||||
children: null,
|
|
||||||
id: 20,
|
|
||||||
is_delete: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: "mdi-clipboard-account",
|
|
||||||
router: "/admRoleMenu/",
|
|
||||||
menu_name: "角色菜单分配管理",
|
|
||||||
roles: null,
|
|
||||||
mould: null,
|
|
||||||
is_top: 0,
|
|
||||||
sort: 0,
|
|
||||||
is_show: 1,
|
|
||||||
parentId: 14,
|
|
||||||
children: null,
|
|
||||||
id: 25,
|
|
||||||
is_delete: 0,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
id: 14,
|
|
||||||
is_delete: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: "mdi-clipboard-flow-outline",
|
|
||||||
router: null,
|
|
||||||
menu_name: "路由管理",
|
|
||||||
roles: null,
|
|
||||||
mould: null,
|
|
||||||
is_top: 0,
|
|
||||||
sort: 0,
|
|
||||||
is_show: 1,
|
|
||||||
parentId: 1,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
icon: "mdi-account-eye",
|
|
||||||
router: "/userinfo/",
|
|
||||||
menu_name: "用户信息",
|
|
||||||
roles: null,
|
|
||||||
mould: null,
|
|
||||||
is_top: 0,
|
|
||||||
sort: 0,
|
|
||||||
is_show: 1,
|
|
||||||
parentId: 26,
|
|
||||||
children: null,
|
|
||||||
id: 27,
|
|
||||||
is_delete: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: "mdi-account-eye",
|
|
||||||
router: "/pan",
|
|
||||||
menu_name: "云盘管理",
|
|
||||||
roles: null,
|
|
||||||
mould: null,
|
|
||||||
is_top: 0,
|
|
||||||
sort: 0,
|
|
||||||
is_show: 1,
|
|
||||||
parentId: 26,
|
|
||||||
children: null,
|
|
||||||
id: 28,
|
|
||||||
is_delete: 0,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
id: 26,
|
|
||||||
is_delete: 0,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
},
|
},
|
||||||
logout() {
|
logout() {
|
||||||
this.$store.dispatch("Logout");
|
this.$store.dispatch("Logout")
|
||||||
this.$router.push({ path: "/login" });
|
this.$router.push({ path: "/login/" });
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-list-group :group="group" :prepend-icon="item.icon" eager v-bind="$attrs">
|
<v-list-group :group="group" :prepend-icon="item.menuIcon" eager v-bind="$attrs">
|
||||||
<template v-slot:activator>
|
<template v-slot:activator>
|
||||||
<v-list-item-icon
|
<v-list-item-icon
|
||||||
v-if="!item.icon && !item.avatar"
|
v-if="!item.menuIcon && !item.avatar"
|
||||||
class="text-caption text-uppercase text-center my-2 align-self-center"
|
class="text-caption text-uppercase text-center my-2 align-self-center"
|
||||||
style="margin-top: 14px"
|
style="margin-top: 14px"
|
||||||
>
|
>
|
||||||
@@ -13,8 +13,8 @@
|
|||||||
<v-img :src="item.avatar" />
|
<v-img :src="item.avatar" />
|
||||||
</v-list-item-avatar>
|
</v-list-item-avatar>
|
||||||
|
|
||||||
<v-list-item-content v-if="item.menu_name">
|
<v-list-item-content v-if="item.menuName">
|
||||||
<v-list-item-title v-text="item.menu_name" />
|
<v-list-item-title v-text="item.menuName" />
|
||||||
</v-list-item-content>
|
</v-list-item-content>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ export default {
|
|||||||
return this.genGroup(this.item.children);
|
return this.genGroup(this.item.children);
|
||||||
},
|
},
|
||||||
title() {
|
title() {
|
||||||
const matches = this.item.menu_name.match(/\b(\w)/g);
|
const matches = this.item.menuName.match(/\b(\w)/g);
|
||||||
if (matches != null) {
|
if (matches != null) {
|
||||||
return matches.join("");
|
return matches.join("");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
v-on="$listeners"
|
v-on="$listeners"
|
||||||
>
|
>
|
||||||
<v-list-item-icon
|
<v-list-item-icon
|
||||||
v-if="!item.icon"
|
v-if="!item.menuIcon"
|
||||||
class="text-caption text-uppercase justify-center ml-1 my-2 align-self-center"
|
class="text-caption text-uppercase justify-center ml-1 my-2 align-self-center"
|
||||||
>
|
>
|
||||||
{{ title }}
|
{{ title }}
|
||||||
@@ -22,14 +22,14 @@
|
|||||||
</v-list-item-avatar>
|
</v-list-item-avatar>
|
||||||
|
|
||||||
<v-list-item-icon
|
<v-list-item-icon
|
||||||
v-if="item.icon"
|
v-if="item.menuIcon"
|
||||||
class="my-2 align-self-center"
|
class="my-2 align-self-center"
|
||||||
>
|
>
|
||||||
<v-icon v-text="item.icon" />
|
<v-icon v-text="item.menuIcon" />
|
||||||
</v-list-item-icon>
|
</v-list-item-icon>
|
||||||
|
|
||||||
<v-list-item-content v-if="item.menu_name">
|
<v-list-item-content v-if="item.menuName">
|
||||||
<v-list-item-title v-text="item.menu_name" />
|
<v-list-item-title v-text="item.menuName" />
|
||||||
</v-list-item-content>
|
</v-list-item-content>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</template>
|
</template>
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
title () {
|
title () {
|
||||||
const matches = this.item.menu_name.match(/\b(\w)/g)
|
const matches = this.item.menuName.match(/\b(\w)/g)
|
||||||
if(matches!=null)
|
if(matches!=null)
|
||||||
{
|
{
|
||||||
return matches.join('')
|
return matches.join('')
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import store from './store/index'
|
|||||||
|
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
|
|
||||||
|
// console.log(to)
|
||||||
|
// console.log(from)
|
||||||
|
// console.log(next)
|
||||||
const user = store.state.user.user; //获取是有user
|
const user = store.state.user.user; //获取是有user
|
||||||
if (!user) { //如果没有登入
|
if (!user) { //如果没有登入
|
||||||
if (to.path == '/login/' || to.path == '/register/' || to.path == '/reset_password/' || to.path == '/qq/') {
|
if (to.path == '/login/' || to.path == '/register/' || to.path == '/reset_password/' || to.path == '/qq/') {
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ const mutations = { //变化//载荷
|
|||||||
},
|
},
|
||||||
SET_USER(state, user) {
|
SET_USER(state, user) {
|
||||||
state.user = user
|
state.user = user
|
||||||
console.log(user)
|
|
||||||
setUser(user)
|
setUser(user)
|
||||||
},
|
},
|
||||||
SetGradient(state, gradient) {
|
SetGradient(state, gradient) {
|
||||||
@@ -87,19 +86,21 @@ const actions = { //动作
|
|||||||
|
|
||||||
|
|
||||||
accountApi.getUserAllInfo().then(resp2=>{
|
accountApi.getUserAllInfo().then(resp2=>{
|
||||||
commit('SET_USER', resp2.data.user)
|
commit('SET_USER', resp2.data)
|
||||||
|
|
||||||
var code=[];
|
var code=[];
|
||||||
resp2.data.menus.forEach(element => {
|
resp2.data.menus.forEach(element => {
|
||||||
code.push(element.permissionCode)
|
code.push(element.permissionCode)
|
||||||
});
|
});
|
||||||
commit('SET_PER', code)
|
commit('SET_PER', code)
|
||||||
|
|
||||||
resolv(resp)
|
resolv(resp)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resolv(resp)
|
||||||
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject(error)
|
reject(error)
|
||||||
})
|
})
|
||||||
|
|||||||
81
Yi.Vue2.x/src/util/btnHandle.js
Normal file
81
Yi.Vue2.x/src/util/btnHandle.js
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import store from '../store/index'
|
||||||
|
//匹配按钮,判断是否有按钮存在
|
||||||
|
|
||||||
|
function getBtn(par) {
|
||||||
|
var axiosEnable = {
|
||||||
|
get: false,
|
||||||
|
update: false,
|
||||||
|
del: false,
|
||||||
|
add: false,
|
||||||
|
};
|
||||||
|
const per = store.state.user.per;
|
||||||
|
switch (par) {
|
||||||
|
case "user":
|
||||||
|
per.forEach(p => {
|
||||||
|
if(p=="user:get")
|
||||||
|
{
|
||||||
|
axiosEnable.get=true;
|
||||||
|
}
|
||||||
|
else if(p=="user:update")
|
||||||
|
{
|
||||||
|
axiosEnable.update=true;
|
||||||
|
}
|
||||||
|
else if(p=="user:del")
|
||||||
|
{
|
||||||
|
axiosEnable.del=true;
|
||||||
|
}
|
||||||
|
else if(p=="user:add")
|
||||||
|
{
|
||||||
|
axiosEnable.add=true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "role":
|
||||||
|
per.forEach(p => {
|
||||||
|
if(p=="role:get")
|
||||||
|
{
|
||||||
|
axiosEnable.get=true;
|
||||||
|
}
|
||||||
|
else if(p=="role:update")
|
||||||
|
{
|
||||||
|
axiosEnable.update=true;
|
||||||
|
}
|
||||||
|
else if(p=="role:del")
|
||||||
|
{
|
||||||
|
axiosEnable.del=true;
|
||||||
|
}
|
||||||
|
else if(p=="role:add")
|
||||||
|
{
|
||||||
|
axiosEnable.add=true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
case "menu":
|
||||||
|
per.forEach(p => {
|
||||||
|
if(p=="menu:get")
|
||||||
|
{
|
||||||
|
axiosEnable.get=true;
|
||||||
|
}
|
||||||
|
else if(p=="menu:update")
|
||||||
|
{
|
||||||
|
axiosEnable.update=true;
|
||||||
|
}
|
||||||
|
else if(p=="menu:del")
|
||||||
|
{
|
||||||
|
axiosEnable.del=true;
|
||||||
|
}
|
||||||
|
else if(p=="menu:add")
|
||||||
|
{
|
||||||
|
axiosEnable.add=true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
default: console.log("未发现合法路由")
|
||||||
|
}
|
||||||
|
return axiosEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export {getBtn};
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
//匹配菜单,让code变成路由
|
|
||||||
const menuDic=
|
|
||||||
{
|
|
||||||
"user:get:list": "/admuser",
|
|
||||||
"role:get:list": "/admrole",
|
|
||||||
"menu:get:list":"/admmenu",
|
|
||||||
"rolemenu:set:list":"/admrolemenu"
|
|
||||||
}
|
|
||||||
//匹配按钮,判断是否有按钮存在
|
|
||||||
const btnDic=
|
|
||||||
{
|
|
||||||
"user:add":"",
|
|
||||||
"user:update":"",
|
|
||||||
"user:del":"",
|
|
||||||
}
|
|
||||||
export default {menuDic,btnDic};
|
|
||||||
//菜单可以区分使用code来进行匹配
|
|
||||||
//记得:关于*的使用,要单独判断
|
|
||||||
//比如,
|
|
||||||
|
|
||||||
//按钮是user:*或者*:*:*直接全部放行即可
|
|
||||||
|
|
||||||
//菜单就不一样了,如果是*:*:*
|
|
||||||
//有两种方案:
|
|
||||||
//1:直接使用一个默认的全部菜单(会和后端给的菜单冲突)
|
|
||||||
//2:前端直接无视,*:*:*相当于只管后端权限(如果后端没有配置菜单前端将没有菜单了)
|
|
||||||
|
|
||||||
|
|
||||||
//如果查询找到的是user:*,可以先把*全部替换成get:list再进行比对即可
|
|
||||||
@@ -1,29 +1,26 @@
|
|||||||
export function setTreeMenu(menuList) {
|
export function toTree(data) {
|
||||||
if (menuList != null && menuList.length > 0) {
|
// 删除 所有 children,以防止多次调用
|
||||||
|
data.forEach(function (item) {
|
||||||
|
delete item.children;
|
||||||
|
});
|
||||||
|
|
||||||
//结果
|
// 将数据存储为 以 id 为 KEY 的 map 索引数据列
|
||||||
var res;
|
var map = {};
|
||||||
//获取最小的parentId
|
data.forEach(function (item) {
|
||||||
var minParentId = 0;
|
map[item.id] = item;
|
||||||
//获取id=最小的parentId的菜单列表
|
});
|
||||||
var menuList1=menuList.filter((item)=>{item.parentId==minParentId}) ;
|
// console.log(map);
|
||||||
|
var val = [];
|
||||||
menuList1.forEach(element=>{
|
data.forEach(function (item) {
|
||||||
res.push(element)
|
// 以当前遍历项,的pid,去map对象中找到索引的id
|
||||||
var children=menuList.filter((item)=>{item.parentId==element.id}) ;
|
var parent = map[item.parentId];
|
||||||
if (children.length > 0) {
|
// 好绕啊,如果找到索引,那么说明此项不在顶级当中,那么需要把此项添加到,他对应的父级中
|
||||||
setTreeChildren(menuList, children,element)
|
if (parent) {
|
||||||
}
|
(parent.children || ( parent.children = [] )).push(item);
|
||||||
})
|
} else {
|
||||||
}
|
//如果没有在map中找到对应的索引ID,那么直接把 当前的item添加到 val结果集中,作为顶级
|
||||||
}
|
val.push(item);
|
||||||
|
|
||||||
function setTreeChildren(menuList, childrenList,model) {
|
|
||||||
childrenList.forEach(element => {
|
|
||||||
model.Childs.push(element);
|
|
||||||
var childrenList2=menuList.filter((item)=>{item.parentId==element.id}) ;
|
|
||||||
if (childrenList2.length > 0) {
|
|
||||||
setTreeChildren(menuList, childrenList2,element)
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
@@ -31,14 +31,14 @@ myaxios.interceptors.request.use(function(config) {
|
|||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
myaxios.interceptors.response.use(async function(response) {
|
myaxios.interceptors.response.use(async function(response) {
|
||||||
const resp = response.data
|
const resp = response.data
|
||||||
if (resp.code == undefined && resp.msg == undefined) {
|
if (resp.code == undefined && resp.message == undefined) {
|
||||||
vm.$dialog.notify.error("错误代码:无,原因:与服务器失去连接", {
|
vm.$dialog.notify.error("错误代码:无,原因:与服务器失去连接", {
|
||||||
position: "top-right",
|
position: "top-right",
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
});
|
});
|
||||||
} else if (resp.code == 401) {
|
} else if (resp.code == 401) {
|
||||||
const res = await vm.$dialog.error({
|
const res = await vm.$dialog.error({
|
||||||
text: `错误代码:${resp.code},原因:${resp.msg}<br>是否重新进行登录?`,
|
text: `错误代码:${resp.code},原因:${resp.message}<br>是否重新进行登录?`,
|
||||||
title: '错误',
|
title: '错误',
|
||||||
actions: {
|
actions: {
|
||||||
'false': '取消',
|
'false': '取消',
|
||||||
@@ -50,7 +50,7 @@ myaxios.interceptors.response.use(async function(response) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (resp.code !== 200) {
|
} else if (resp.code !== 200) {
|
||||||
vm.$dialog.notify.error(`错误代码:${resp.code},原因:${resp.msg}`, {
|
vm.$dialog.notify.error(`错误代码:${resp.code},原因:${resp.message}`, {
|
||||||
position: "top-right",
|
position: "top-right",
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
});
|
});
|
||||||
@@ -60,14 +60,14 @@ myaxios.interceptors.response.use(async function(response) {
|
|||||||
return resp;
|
return resp;
|
||||||
}, async function(error) {
|
}, async function(error) {
|
||||||
const resp = error.response.data
|
const resp = error.response.data
|
||||||
if (resp.code == undefined && resp.msg == undefined) {
|
if (resp.code == undefined && resp.message == undefined) {
|
||||||
vm.$dialog.notify.error("错误代码:无,原因:与服务器失去连接", {
|
vm.$dialog.notify.error("错误代码:无,原因:与服务器失去连接", {
|
||||||
position: "top-right",
|
position: "top-right",
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
});
|
});
|
||||||
} else if (resp.code == 401) {
|
} else if (resp.code == 401) {
|
||||||
const res = await vm.$dialog.error({
|
const res = await vm.$dialog.error({
|
||||||
text: `错误代码:${resp.code},原因:${resp.msg}<br>是否重新进行登录?`,
|
text: `错误代码:${resp.code},原因:${resp.message}<br>是否重新进行登录?`,
|
||||||
title: '错误',
|
title: '错误',
|
||||||
actions: {
|
actions: {
|
||||||
'false': '取消',
|
'false': '取消',
|
||||||
@@ -81,7 +81,7 @@ myaxios.interceptors.response.use(async function(response) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (resp.code !== 200) {
|
} else if (resp.code !== 200) {
|
||||||
vm.$dialog.notify.error(`错误代码:${resp.code},原因:${resp.msg}`, {
|
vm.$dialog.notify.error(`错误代码:${resp.code},原因:${resp.message}`, {
|
||||||
position: "top-right",
|
position: "top-right",
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,17 +7,20 @@
|
|||||||
:defaultItem="defaultItem"
|
:defaultItem="defaultItem"
|
||||||
:headers="headers"
|
:headers="headers"
|
||||||
:axiosUrls="axiosUrls"
|
:axiosUrls="axiosUrls"
|
||||||
|
:btnEnable="btnEnable"
|
||||||
>
|
>
|
||||||
</ccTable>
|
</ccTable>
|
||||||
</material-card>
|
</material-card>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import { getBtn } from "../util/btnHandle";
|
||||||
export default {
|
export default {
|
||||||
created() {
|
created() {
|
||||||
this.init();
|
this.init();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
|
this.btnEnable = getBtn("role")
|
||||||
this.axiosUrls = {
|
this.axiosUrls = {
|
||||||
get: "/role/GetList",
|
get: "/role/GetList",
|
||||||
update: "/role/Update",
|
update: "/role/Update",
|
||||||
@@ -30,8 +33,10 @@ export default {
|
|||||||
start: true,
|
start: true,
|
||||||
axiosUrls: {
|
axiosUrls: {
|
||||||
},
|
},
|
||||||
|
btnEnable:{},
|
||||||
headers: [
|
headers: [
|
||||||
{ text: "编号", align: "start", value: "id" },
|
// { text: "编号", align: "start", value: "id" },
|
||||||
|
{ text: "角色编号", value: "roleCode", sortable: false },
|
||||||
{ text: "角色名", value: "roleName", sortable: false },
|
{ text: "角色名", value: "roleName", sortable: false },
|
||||||
// { text: "云盘地址", value: "file_path", sortable: false },
|
// { text: "云盘地址", value: "file_path", sortable: false },
|
||||||
// { text: "简介", value: "introduce", sortable: false },
|
// { text: "简介", value: "introduce", sortable: false },
|
||||||
|
|||||||
@@ -48,7 +48,8 @@
|
|||||||
item-text="menuName"
|
item-text="menuName"
|
||||||
>
|
>
|
||||||
<template v-slot:append="{ item }">
|
<template v-slot:append="{ item }">
|
||||||
<v-btn>权限:{{ item.permissionCode }}</v-btn>
|
<app-btn v-if="item.menuType==0">路由:{{ item.router }}</app-btn>
|
||||||
|
<app-btn v-if="item.menuType==1" color="secondary">权限:{{ item.permissionCode }}</app-btn>
|
||||||
</template>
|
</template>
|
||||||
</v-treeview>
|
</v-treeview>
|
||||||
</v-card></v-col
|
</v-card></v-col
|
||||||
|
|||||||
@@ -3,22 +3,13 @@
|
|||||||
<template #title>
|
<template #title>
|
||||||
用户管理 — <small class="text-body-1">用户可拥有多个角色</small>
|
用户管理 — <small class="text-body-1">用户可拥有多个角色</small>
|
||||||
</template>
|
</template>
|
||||||
<ccCombobox
|
<ccCombobox headers="设置角色" :items="roleItems" @select="getSelect" itemText="roleName">
|
||||||
headers="设置角色"
|
|
||||||
:items="roleItems"
|
|
||||||
@select="getSelect"
|
|
||||||
itemText="role_name"
|
|
||||||
>
|
|
||||||
<template v-slot:save>
|
<template v-slot:save>
|
||||||
<v-btn @click="setRole" color="blue darken-1" text> 保存</v-btn>
|
<v-btn @click="setRole" color="blue darken-1" text> 保存</v-btn>
|
||||||
</template>
|
</template>
|
||||||
</ccCombobox>
|
</ccCombobox>
|
||||||
<ccTable
|
<ccTable :defaultItem="defaultItem" :headers="headers" :axiosUrls="axiosUrls" :btnEnable="btnEnable"
|
||||||
:defaultItem="defaultItem"
|
@selected="getTableSelect">
|
||||||
:headers="headers"
|
|
||||||
:axiosUrls="axiosUrls"
|
|
||||||
@selected="getTableSelect"
|
|
||||||
>
|
|
||||||
<template v-slot:action="{ item }">
|
<template v-slot:action="{ item }">
|
||||||
<v-icon small class="mr-2" @click="showItem(item)"> mdi-eye </v-icon>
|
<v-icon small class="mr-2" @click="showItem(item)"> mdi-eye </v-icon>
|
||||||
</template>
|
</template>
|
||||||
@@ -27,6 +18,8 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import userApi from "../api/userApi";
|
import userApi from "../api/userApi";
|
||||||
|
import roleApi from "../api/roleApi";
|
||||||
|
import { getBtn } from "../util/btnHandle";
|
||||||
export default {
|
export default {
|
||||||
created() {
|
created() {
|
||||||
this.init();
|
this.init();
|
||||||
@@ -59,9 +52,8 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
init() {
|
init() {
|
||||||
|
//这里可以遍历后台的菜单code,根据对应的菜单code来给axiosUrls的增删改查赋值即可
|
||||||
//这里可以遍历后台的菜单code,根据对应的菜单code来给axiosUrls的增删改查赋值即可
|
this.btnEnable = getBtn("user")
|
||||||
|
|
||||||
this.axiosUrls = {
|
this.axiosUrls = {
|
||||||
get: "/user/GetList",
|
get: "/user/GetList",
|
||||||
update: "/user/Update",
|
update: "/user/Update",
|
||||||
@@ -69,9 +61,9 @@ export default {
|
|||||||
add: "/user/Add",
|
add: "/user/Add",
|
||||||
};
|
};
|
||||||
|
|
||||||
// roleApi.getRole().then((resp) => {
|
roleApi.getList().then((resp) => {
|
||||||
// this.roleItems = resp.data;
|
this.roleItems = JSON.parse(JSON.stringify(resp.data));
|
||||||
// });
|
});
|
||||||
},
|
},
|
||||||
setRole() {
|
setRole() {
|
||||||
var userIds = [];
|
var userIds = [];
|
||||||
@@ -82,8 +74,8 @@ export default {
|
|||||||
this.select.forEach((item) => {
|
this.select.forEach((item) => {
|
||||||
roleIds.push(item.id);
|
roleIds.push(item.id);
|
||||||
});
|
});
|
||||||
userApi.SetRoleByUser(userIds, roleIds).then((resp) => {
|
userApi.GiveUserSetRole(userIds, roleIds).then((resp) => {
|
||||||
this.$dialog.notify.success(resp.msg, {
|
this.$dialog.notify.success(resp.message, {
|
||||||
position: "top-right",
|
position: "top-right",
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
});
|
});
|
||||||
@@ -98,6 +90,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
|
btnEnable: [],
|
||||||
TableSelect: [],
|
TableSelect: [],
|
||||||
select: [],
|
select: [],
|
||||||
roleItems: [],
|
roleItems: [],
|
||||||
|
|||||||
@@ -52,7 +52,16 @@
|
|||||||
<a href="javascript:void(0)" class="mt-1"> 忘记密码? </a>
|
<a href="javascript:void(0)" class="mt-1"> 忘记密码? </a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<v-btn block color="primary" @click="login" class="mt-6" :loading="loader" :disabled="btn_dis"> 登录 </v-btn>
|
<v-btn
|
||||||
|
block
|
||||||
|
color="primary"
|
||||||
|
@click="login"
|
||||||
|
class="mt-6"
|
||||||
|
:loading="loader"
|
||||||
|
:disabled="btn_dis"
|
||||||
|
>
|
||||||
|
登录
|
||||||
|
</v-btn>
|
||||||
</v-form>
|
</v-form>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
|
||||||
@@ -70,7 +79,7 @@
|
|||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
|
||||||
<!-- social links -->
|
<!-- social links -->
|
||||||
<v-card-actions class="d-flex justify-center ">
|
<v-card-actions class="d-flex justify-center">
|
||||||
<v-btn v-for="link in socialLink" :key="link.icon" icon class="ms-1">
|
<v-btn v-for="link in socialLink" :key="link.icon" icon class="ms-1">
|
||||||
<v-icon :color="$vuetify.theme.dark ? link.colorInDark : link.color">
|
<v-icon :color="$vuetify.theme.dark ? link.colorInDark : link.color">
|
||||||
{{ link.icon }}
|
{{ link.icon }}
|
||||||
@@ -81,11 +90,11 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
created(){
|
created() {
|
||||||
this.enterSearch();
|
this.enterSearch();
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
btn_dis:false,
|
btn_dis: false,
|
||||||
loader: null,
|
loader: null,
|
||||||
socialLink: [
|
socialLink: [
|
||||||
{
|
{
|
||||||
@@ -122,8 +131,7 @@ export default {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
enterSearch() {
|
enterSearch() {
|
||||||
|
|
||||||
document.onkeydown = (e) => {
|
document.onkeydown = (e) => {
|
||||||
//13表示回车键,baseURI是当前页面的地址,为了更严谨,也可以加别的,可以打印e看一下
|
//13表示回车键,baseURI是当前页面的地址,为了更严谨,也可以加别的,可以打印e看一下
|
||||||
if (e.keyCode === 13 && e.target.baseURI.match("/")) {
|
if (e.keyCode === 13 && e.target.baseURI.match("/")) {
|
||||||
@@ -133,20 +141,29 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
login() {
|
login() {
|
||||||
this.loader = true;
|
this.loader = true;
|
||||||
this.btn_dis=true;
|
this.btn_dis = true;
|
||||||
this.$store.dispatch("Login", this.form).then((resp) => {
|
this.$store
|
||||||
if (resp.status) {
|
.dispatch("Login", this.form)
|
||||||
this.$router.push("/");
|
.then((resp) => {
|
||||||
} else {
|
if (resp.status) {
|
||||||
this.loader=null;
|
|
||||||
this.btn_dis=false;
|
this.$router.push("/");
|
||||||
this.$dialog.notify.error(resp.msg, {
|
} else {
|
||||||
position: "top-right",
|
|
||||||
timeout: 5000,
|
this.loader = null;
|
||||||
});
|
this.btn_dis = false;
|
||||||
}
|
this.$dialog.notify.error(resp.message, {
|
||||||
});
|
position: "top-right",
|
||||||
|
timeout: 5000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
|
||||||
|
this.loader = false;
|
||||||
|
this.btn_dis = false;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user