租户模块相关

master
ZR20090193-陈敬勇 10 months ago
parent 21c9b78c05
commit a5804a4355

@ -0,0 +1,75 @@
<template>
<BasicForm @register="registerForm">
<!-- <template #auditStatusSlot="{ model, field }">-->
<!-- <canvas id="canvas" width="200" height="200"></canvas>-->
<!-- </template>-->
</BasicForm>
</template>
<script lang="ts" setup>
import { defineComponent, onMounted, ref, unref, watch } from 'vue'
import { BasicForm, useForm } from '/@/components/Form/index'
import { formSchema } from './columns'
import { getTenantAuditInfo } from './api'
import { useMessage } from '/@/hooks/web/useMessage'
import { propTypes } from '/@/utils/propTypes'
const { notification, createConfirm } = useMessage()
// Emits
const emit = defineEmits(['next', 'register'])
//
const props = defineProps({
applyId: propTypes.string,
})
watch(
() => props.applyId,
() => {
initData()
},
{ deep: true },
)
async function initData() {
const res: API.DataResult = await getTenantAuditInfo({ id: props.applyId })
if (res.succeeded) {
await setFieldsValue(res.data)
}
}
// onMounted(async () => {
// console.log(props.applyId)
// const res: API.DataResult = await getTenantAuditInfo({ id: props.applyId })
// if (res.succeeded) {
// await setFieldsValue(res.data)
// }
// })
const [registerForm, { resetFields, setFieldsValue, validate, updateSchema }] = useForm({
labelWidth: 100,
schemas: formSchema,
// showActionButtonGroup: false,
resetButtonOptions: {
text: '驳回',
color: 'error',
disabled: true,
onClick: customSubmitFunc,
},
showResetButton: true,
submitButtonOptions: {
text: '下一步',
},
submitFunc: customSubmitFunc,
})
const closeClientModal = (data: any) => {
console.log('接收值', data)
// const records = data.filter((x) => checkedKeys.value.includes(x.gid))
setFieldsValue({
clientIds: data.clientIds.toString(),
clientName: data.clientName,
})
}
async function customSubmitFunc() {
try {
const values = await validate()
emit('next', values)
} catch (error) {}
}
</script>
<style scoped lang="less"></style>

@ -0,0 +1,35 @@
<template> <BasicForm @register="registerForm" /> </template>
<script lang="ts" setup>
import { defineComponent, ref } from 'vue'
import { BasicForm, useForm } from '/@/components/Form/index'
import { dbFormSchema } from './columns'
import { useMessage } from '/@/hooks/web/useMessage'
const { notification, createConfirm, createMessage } = useMessage()
// Emits
const emit = defineEmits(['next', 'prev'])
const isUpdate = ref(true)
const loading = ref(false)
const rowId = ref('')
const [registerForm, { resetFields, setFieldsValue, validate, updateSchema }] = useForm({
labelWidth: 100,
schemas: dbFormSchema,
resetButtonOptions: {
text: '上一步',
onClick: handlePrev,
},
showResetButton: true,
submitButtonOptions: {
text: '下一步',
},
submitFunc: handleNext,
})
async function handlePrev() {
emit('prev')
}
async function handleNext() {
emit('next')
}
</script>
<style scoped lang="less"></style>

@ -0,0 +1,98 @@
<template>
<div class="m-4 mr-0 overflow-hidden bg-white">
<BasicTree
ref="treeRef"
title="所拥有的的权限"
:treeData="treeData"
:checkable="true"
:checkedKeys="checkedKeys"
:selectedKeys="selectedKeys"
defaultExpandAll
@check="onCheck"
/>
</div>
<BasicForm @register="registerForm" />
</template>
<script lang="ts" setup>
import { defineComponent, onMounted, ref, unref } from 'vue'
import { BasicForm, useForm } from '/@/components/Form/index'
import { permissionFormSchema } from './columns'
import { getTenantAuditInfo, auditInfo } from './api'
import { useMessage } from '/@/hooks/web/useMessage'
import { BasicTree, TreeItem } from '/@/components/Tree'
import { getClientPermissionTreeList } from './api'
//
const treeData = ref<TreeItem[]>([])
//
const allTreeKeys = ref([])
//
const checkedKeys = ref([])
const defaultCheckedKeys = ref([])
//
const selectedKeys = ref([])
const roleId = ref('')
//
const treeRef = ref(null)
const loading = ref(false)
const { notification, createConfirm, createMessage } = useMessage()
// Emits
const emit = defineEmits(['next', 'prev', 'permission'])
const [registerForm, { resetFields, setFieldsValue, validate, updateSchema }] = useForm({
labelWidth: 100,
schemas: permissionFormSchema,
resetButtonOptions: {
text: '上一步',
onClick: handlePrev,
},
showResetButton: true,
submitButtonOptions: {
text: '下一步',
},
submitFunc: handleNext,
})
async function handlePrev() {
emit('prev')
}
async function fetch() {
reset()
//
const res = await getClientPermissionTreeList()
treeData.value = res.data
// allTreeKeys.value = res.data.ids
// treeData.value = data
}
async function handleNext() {
console.log('permission', checkedKeys.value)
//
// emit('permission', checkedKeys.value)
emit('next')
}
/**
* 数据重置
*/
function reset() {
treeData.value = []
allTreeKeys.value = []
checkedKeys.value = []
defaultCheckedKeys.value = []
selectedKeys.value = []
// roleId.value = ''
}
/**
* 点击选中
*/
function onCheck(o) {
checkedKeys.value = o.checked ? o.checked : o
}
onMounted(() => {
fetch()
})
</script>
<style scoped lang="less"></style>

@ -0,0 +1,147 @@
<template>
<BasicModal
v-bind="$attrs"
@register="registerModal"
:useWrapper="true"
:title="getTitle"
width="80%"
@ok="handleSave"
>
<div class="step-form-form">
<a-steps :current="current">
<a-step title="企业用户基本信息" />
<a-step title="权限模块" />
<a-step title="配置数据库信息" />
<a-step title="完成" />
</a-steps>
</div>
<div class="mt-5">
<BaseInfoStep
@next="handleStep1Next"
v-show="current === 0"
v-if="state.initSetp1"
:applyId="applyId"
/>
<PermissionSetStep
@prev="handleStepPrev"
@next="handleStep2Next"
v-show="current === 1"
v-if="state.initSetp2"
/>
<DbSetStep
@prev="handleStepPrev"
@next="handleStep3Next"
v-show="current === 2"
v-if="state.initSetp3"
/>
<DbSetStep
v-show="current === 3"
@prev="handleStepPrev"
@finish="finish"
v-if="state.initSetp4"
/>
</div>
<!--右下角按钮-->
<template #footer>
<a-button
@click="closeModal"
preIcon="ant-design:close-outlined"
type="warning"
:loading="loading"
ghost
style="margin-right: 0.8rem"
>取消
</a-button>
</template>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, computed, unref, h, reactive } from 'vue'
import { BasicModal, useModalInner } from '/@/components/Modal'
import { useMessage } from '/@/hooks/web/useMessage'
import PermissionSetStep from './PermissionSetStep.vue'
import DbSetStep from './DbSetStep.vue'
import BaseInfoStep from './BaseInfoStep.vue'
const { notification, createConfirm, createMessage } = useMessage()
// Emits
const emit = defineEmits(['success', 'register'])
const isUpdate = ref(true)
const loading = ref(false)
// const rowId = ref('')
const current = ref(0)
const applyId = ref('')
const state = reactive({
initSetp1: true,
initSetp2: false,
initSetp3: false,
initSetp4: false,
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
setModalProps({ confirmLoading: false, loading: true })
isUpdate.value = !!data?.isUpdate
if (unref(isUpdate)) {
applyId.value = data.record.id
console.log(applyId.value)
}
setModalProps({ loading: false })
})
function handleStep1Next(step1Values: any) {
console.log(step1Values)
current.value++
state.initSetp1 = false
state.initSetp2 = true
state.initSetp3 = false
state.initSetp4 = false
}
function handleStepPrev() {
current.value--
if (current.value == 0) {
state.initSetp1 = true
state.initSetp2 = false
state.initSetp3 = false
state.initSetp4 = false
} else if (current.value == 1) {
state.initSetp1 = false
state.initSetp2 = true
state.initSetp3 = false
state.initSetp4 = false
} else if (current.value == 2) {
state.initSetp1 = false
state.initSetp2 = false
state.initSetp3 = true
state.initSetp4 = false
} else if (current.value == 3) {
state.initSetp1 = false
state.initSetp2 = false
state.initSetp3 = false
state.initSetp4 = true
}
}
function handleStep2Next(step2Values: any) {
current.value++
state.initSetp1 = false
state.initSetp2 = false
state.initSetp3 = true
state.initSetp4 = false
console.log(step2Values)
}
function handleStep3Next(step3Values: any) {
current.value++
state.initSetp1 = false
state.initSetp2 = false
state.initSetp3 = false
state.initSetp4 = true
console.log(step3Values)
}
function finish() {
current.value = 0
state.initSetp1 = false
state.initSetp2 = false
state.initSetp3 = false
state.initSetp4 = false
}
const getTitle = computed(() => (!unref(isUpdate) ? '' : '企业用户审批'))
</script>

@ -4,7 +4,7 @@
@register="registerModal"
:useWrapper="true"
:title="getTitle"
width="50%"
width="80%"
@ok="handleSave"
>
<BasicForm @register="registerForm">

@ -5,6 +5,8 @@ enum Api {
list = '/mainApi/TenantApply/GetTenantApplyList',
getTenantAuditInfo = '/mainApi/TenantApply/GetTenantAuditInfo',
auditInfo = '/mainApi/TenantApply/AuditTenantApply',
getClientPermissionTreeList = '/mainApi/Common/GetClientPermissionTreeList',
}
export function getTenantApplyList(data: PageRequest) {
return request<DataResult>({
@ -29,3 +31,9 @@ export function auditInfo(data: any) {
data,
})
}
export function getClientPermissionTreeList() {
return request<DataResult>({
url: Api.getClientPermissionTreeList,
method: 'get',
})
}

@ -89,17 +89,7 @@ export const formSchema: FormSchema[] = [
label: '公司名称',
component: 'Input',
required: true,
colProps: { span: 16 },
componentProps: {
disabled: true,
},
},
{
field: 'shortname',
label: '公司简称',
component: 'Input',
required: true,
colProps: { span: 8 },
colProps: { span: 12 },
componentProps: {
disabled: true,
},
@ -149,12 +139,12 @@ export const formSchema: FormSchema[] = [
},
},
{
field: 'loginname',
field: 'adminUserCode',
label: '管理员账号',
component: 'Input',
colProps: { span: 12 },
dynamicDisabled: ({ values }) => {
return !!values.gid
return !!values.id
},
},
{
@ -239,4 +229,90 @@ export const formSchema: FormSchema[] = [
],
},
},
{
field: 'divider-selects',
component: 'Divider',
label: '审批步骤',
colProps: { span: 24 },
},
]
export const permissionFormSchema: FormSchema[] = [
{
field: 'divider-selects',
component: 'Divider',
label: '审批步骤',
colProps: { span: 24 },
},
{
label: '',
field: 'id',
component: 'Input',
defaultValue: '',
show: false,
},
]
export const dbFormSchema: FormSchema[] = [
{
field: 'divider-selects',
component: 'Divider',
label: '数据库配置',
colProps: { span: 24 },
},
{
label: '',
field: 'id',
component: 'Input',
defaultValue: '',
show: false,
},
{
field: 'host',
label: '数据库IP',
component: 'Input',
required: true,
colProps: { span: 24 },
},
{
field: 'dbType',
component: 'RadioButtonGroup',
label: '数据库类型',
required: true,
componentProps: {
options: [
{ label: 'MsSQL', value: 1 },
{ label: 'MySQL', value: 0 },
],
},
defaultValue: 1,
colProps: {
span: 12,
},
},
{
field: 'connAccount',
label: '数据库账号',
component: 'Input',
required: true,
colProps: { span: 24 },
},
{
field: 'connPassword',
label: '数据库密码',
component: 'Input',
required: true,
colProps: { span: 24 },
},
{
field: 'connAccount',
label: '数据库账号',
component: 'Input',
required: true,
colProps: { span: 24 },
},
{
field: 'divider-selects',
component: 'Divider',
label: '审批步骤',
colProps: { span: 24 },
},
]

@ -21,7 +21,7 @@
</template>
</template>
</BasicTable>
<TenantModal @register="registerModal" @success="handleSuccess" />
<TenantAuditStepModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" setup>
@ -29,7 +29,7 @@
import {BasicTable, useTable, TableAction, SorterResult} from '/@/components/Table'
import { getTenantApplyList } from './api'
import { useModal } from '/@/components/Modal'
import TenantModal from './TenantModal.vue'
import TenantAuditStepModal from './TenantAuditStepModal.vue'
import { columns, searchFormSchema } from './columns'
let filterInfo: Partial<Recordable<string[]>> = []
let sortInfo: SorterResult = {}

@ -220,14 +220,6 @@ export const formSchema: FormSchema[] = [
label: '客户端',
value: 1,
},
{
label: '市平台',
value: 2,
},
{
label: '省平台',
value: 3,
},
],
},
itemProps: {

@ -21,4 +21,10 @@ public enum UserTypeEnum
/// </summary>
[Description("普通用户")]
Nomal = 2,
/// <summary>
/// 租户申请
/// </summary>
[Description("租户申请")]
ApplyUser = 3,
}

@ -7,7 +7,7 @@ namespace DS.WMS.Core.System.Entity;
/// 权限信息
/// </summary>
[SqlSugar.SugarTable("sys_permission")]
public class SysPermission : BaseTenantModel<long>
public class SysPermission : BaseModel<long>
{
/// <summary>
///上级权限ID

@ -0,0 +1,129 @@
using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.System.Entity;
/// <summary>
/// 权限信息-租户
/// </summary>
[SqlSugar.SugarTable("sys_permission_tenant")]
public class SysPermissionTenant : BaseTenantModel<long>
{
/// <summary>
///权限ID
/// </summary>
public long PermissionId { get; set; }
/// <summary>
///上级权限ID
/// </summary>
public long ParentId { get; set; }
/// <summary>
/// 权限名称
/// </summary>
public string PermissionName { get; set; }
/// <summary>
///权限唯一码
/// </summary>
public string PermissionCode { get; set; }
/// <summary>
/// 菜单名称
/// </summary>
public string Title { get; set; }
/// <summary>
/// 权限图标
/// </summary>
[SqlSugar.SugarColumn(IsNullable = true)]
public string Icon { get; set; }
/// <summary>
/// 路径
/// </summary>
[SqlSugar.SugarColumn(IsNullable = true)]
public string Url { get; set; }
/// <summary>
/// 跳转
/// </summary>
[SqlSugar.SugarColumn(IsNullable = true)]
public string Redirect { get; set; }
/// <summary>
/// 组件
/// </summary>
[SqlSugar.SugarColumn(IsNullable = true)]
public string Component { get; set; }
/// <summary>
/// 组件
/// </summary>
public string ComponentName { get; set; }
/// <summary>
/// 权限类型
/// 1:一级菜单; 2:子菜单:3:按钮权限
/// </summary>
public int MenuType { get; set; }
/// <summary>
///0: 公共; 1:客户端; 2:市平台:3:省平台
/// </summary>
public int PermissionType { get; set; }
/// <summary>
/// 外链菜单打开方式 0/内部打开 1/外部打开
/// </summary>
public int OpenType { get; set; }
/// <summary>
/// 排序码
/// </summary>
public int SortCode { get; set; }
/// <summary>
/// 是否公众权限
/// </summary>
public bool IsPublic { get; set; } = false;
/// <summary>
/// 是否缓存该页面
/// </summary>
public bool KeepAlive { get; set; } = true;
/// <summary>
/// 是否隐藏路由
/// </summary>
public bool IsHidden { get; set; } = false;
/// <summary>
/// 是否隐藏tab
/// </summary>
public bool IsHideTab { get; set; } = false;
/// <summary>
/// 聚合子路由
/// </summary>
public bool IsAlwaysShow { get; set; } = false;
/// <summary>
/// 是否路由菜单
/// </summary>
public bool IsRoute { get; set; } = true;
#region 拓展字段
[SugarColumn(IsIgnore = true)]
public virtual List<SysPermission> children { get; set; }
#endregion 拓展字段
/// <summary>
///权限实体
/// </summary>
public string PermissionEntity { get; set; }
}

@ -26,6 +26,25 @@ public interface ICommonService
/// <returns></returns>
DataResult<List<RouteItem>> GetUserPermissionByToken();
/// <summary>
/// 客户登录
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
DataResult<string> ClientUserLogin(UserLoginModel model);
/// <summary>
/// 获取用户信息-客户
/// </summary>
/// <returns></returns>
DataResult<CurrentUserViewModel> GetClientUserInfo();
/// <summary>
/// 查询客户用户拥有的菜单权限
/// </summary>
/// <returns></returns>
DataResult<List<RouteItem>> GetClientUserPermissionByToken();
/// <summary>
/// 获取服务器信息
/// </summary>
@ -60,4 +79,11 @@ public interface ICommonService
DataResult<List<EntityFieldProperty>> GetDataRuleEntityFields(string permissionId);
public ISugarQueryable<T> GetDataRuleFilter<T>();
/// <summary>
/// 获取权限树列表-客户端
/// </summary>
/// <returns></returns>
public DataResult<List<PermissionTreeList>> GetClientPermissionTreeList();
}

@ -40,6 +40,8 @@ public class CommonService : ICommonService
_environment = _serviceProvider.GetRequiredService<IWebHostEnvironment>();
}
#region 后台登录
/// <summary>
/// 用户登录
/// </summary>
@ -74,7 +76,6 @@ public class CommonService : ICommonService
/// <summary>
///
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
public DataResult<CurrentUserViewModel> GetUserInfo()
{
@ -116,7 +117,8 @@ public class CommonService : ICommonService
//超级管理员
if (userInfo.UserType == 0)
{
list = db.Queryable<SysPermission>().Filter(null, true).Where(x => x.MenuType == 1 && x.IsHidden == false)
list = db.Queryable<SysPermission>().Filter(null, true).Where(x =>
x.MenuType == 1 && x.IsHidden == false && (x.PermissionType == -1 || x.PermissionType == 0))
.OrderBy(x => x.SortCode)
.Select(a => new RouteItem
{
@ -136,7 +138,8 @@ public class CommonService : ICommonService
foreach (var item in list)
{
var childs = db.Queryable<SysPermission>().Filter(null, true)
.Where(x => x.MenuType == 2 && x.ParentId == item.Id && x.IsHidden == false)
.Where(x => x.MenuType == 2 && x.ParentId == item.Id && x.IsHidden == false &&
(x.PermissionType == -1 || x.PermissionType == 0))
.OrderBy(x => x.SortCode)
.Select(a => new RouteItem
{
@ -161,7 +164,8 @@ public class CommonService : ICommonService
.Select(x => x.PermissionId).Distinct().ToList();
var perlist = db.Queryable<SysPermission>()
.Where(x => x.MenuType == 1 && x.IsHidden == false && permissions.Contains(x.Id))
.Where(x => x.MenuType == 1 && x.IsHidden == false && permissions.Contains(x.Id) &&
(x.PermissionType == -1 || x.PermissionType == 0))
.OrderBy(x => x.SortCode)
.Select(a => new RouteItem
{
@ -179,50 +183,189 @@ public class CommonService : ICommonService
})
.ToList();
// if (perlist.Count == 0)
// {
// //公共菜单权限
// var publicFirstMenu = db.Queryable<SysPermission>().Filter(null, true).Where(x =>
// x.MenuType == 1 && x.IsHidden == false && x.PermissionType == (int)PermissionType.Public)
// .OrderBy(x=>x.SortCode)
// .Select(a => new RouteItem
// {
// Id = a.Id,
// Path = a.Url,
// Name = a.PermissionName,
// Component = a.Component,
// Redirect = a.Redirect,
// SortCode = a.SortCode,
// Meta = new RouteMeta()
// {
// Title = a.Title,
// Icon = a.Icon,
// }
// })
// .ToList();
// list.AddRange(publicFirstMenu);
//
// // 权限身份菜单
// var identityFirstMenu = db.Queryable<SysPermission>().Filter(null, true).Where(x =>
// x.MenuType == 1 && x.IsHidden == false && x.PermissionType == userInfo.PermissionIdentity)
// .OrderBy(x=>x.SortCode)
// .Select(a => new RouteItem
// {
// Id = a.Id,
// Path = a.Url,
// Name = a.PermissionName,
// Component = a.Component,
// Redirect = a.Redirect,
// SortCode = a.SortCode,
// Meta = new RouteMeta()
// {
// Title = a.Title,
// Icon = a.Icon,
// }
// })
// .ToList();
// list.AddRange(identityFirstMenu);
// }
list.AddRange(perlist);
//去重
list.Distinct();
//排序
list = list.OrderBy(x => x.SortCode).ToList();
foreach (var item in list)
{
var childs = db.Queryable<SysPermission>().Where(x =>
x.MenuType == 2 && x.ParentId == item.Id && x.IsHidden == false && permissions.Contains(x.Id) &&
(x.PermissionType == -1 || x.PermissionType == 0))
.OrderBy(x => x.SortCode)
.Select(a => new RouteItem
{
Path = a.Url,
Name = a.PermissionName,
Component = a.Component,
Meta = new RouteMeta()
{
Title = a.Title,
Icon = a.Icon,
}
}).ToList();
//去重
childs.Distinct();
//排序
childs = childs.OrderBy(x => x.SortCode).ToList();
item.Children = childs;
}
}
// list = list.OrderBy(x => x.Id).ToList();
return DataResult<List<RouteItem>>.Success("获取数据成功!", list);
}
#endregion
#region 客户端登录
/// <summary>
/// 用户登录
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public DataResult<string> ClientUserLogin(UserLoginModel model)
{
var userInfo = db.Queryable<SysUser>().Filter(null, true)
.First(x => x.UserCode == model.UserName);
if (userInfo == null)
{
return DataResult<string>.Failed("账号不存在,请检查!");
}
if (userInfo.MD5Password != model.Password)
{
return DataResult<string>.Failed("密码错误!");
}
var tokenModel = new JwtHelper.JwtTokenModel
{
Uid = userInfo.Id.ToString(),
// CompanyId = userInfo.CompanyId,
// GID = userInfo.GID,
TenantId = userInfo.TenantId.ToString(),
};
var token = JwtHelper.Encrypt(tokenModel);
return DataResult<string>.Success(token);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public DataResult<CurrentUserViewModel> GetClientUserInfo()
{
var userId = long.Parse(user.UserId);
var tenantId = user.GetTenantId();
var data = db.Queryable<SysUser>().Filter(null, true).Where(x => x.Id == userId)
.Select(a => new CurrentUserViewModel
{
UserId = a.Id,
UserCode = a.UserCode,
UserName = a.NickName,
TenantId = tenantId,
UserType = a.UserType,
CompanyId = a.CompanyId,
ClientId = a.ClientId,
IsLimitClient = a.IsLimitClient
// CompanyId = a.CompanyId.ToString(), CompanyName = a.CustomerName
})
.Mapper(it =>
{
//只能写在Select后面
it.HomePath = "/analysis";
})
.First();
return DataResult<CurrentUserViewModel>.Success(data);
}
/// <summary>
/// 查询客户 用户拥有的菜单权限
/// </summary>
/// <returns></returns>
public DataResult<List<RouteItem>> GetClientUserPermissionByToken()
{
List<RouteItem> list = new List<RouteItem>();
var userId = long.Parse(user.UserId);
var userInfo = db.Queryable<SysUser>().Where(x => x.Id == userId).First();
//超级管理员
if (userInfo.UserType == 0)
{
list = db.Queryable<SysPermissionTenant>().Where(x =>
x.MenuType == 1 && x.IsHidden == false && (x.PermissionType == 1 || x.PermissionType == 0))
.OrderBy(x => x.SortCode)
.Select(a => new RouteItem
{
Id = a.PermissionId,
Path = a.Url,
Name = a.PermissionName,
Component = a.Component,
Redirect = a.Redirect,
Meta = new RouteMeta()
{
Title = a.Title,
Icon = a.Icon,
}
})
.ToList();
foreach (var item in list)
{
var childs = db.Queryable<SysPermissionTenant>().Filter(null, true)
.Where(x => x.MenuType == 2 && x.ParentId == item.Id && x.IsHidden == false &&
(x.PermissionType == 1 || x.PermissionType == 0))
.OrderBy(x => x.SortCode)
.Select(a => new RouteItem
{
Path = a.Url,
Name = a.PermissionName,
Component = a.Component,
Meta = new RouteMeta()
{
Title = a.Title,
Icon = a.Icon,
}
}).ToList();
item.Children = childs;
}
}
else if (userInfo.UserType == 3) //租户申请用户
{
var roleIds = db.Queryable<SysRoleUser>().Where(x => x.UserId == userId).Select(x => x.RoleId).ToList();
var permissions = db.Queryable<SysRolePermission>().Where(x => roleIds.Contains(x.RoleId))
.Select(x => x.PermissionId).Distinct().ToList();
var perlist = db.Queryable<SysPermission>()
.Where(x => x.MenuType == 1 && x.IsHidden == false && permissions.Contains(x.Id) &&
(x.PermissionType == 1 || x.PermissionType == 0))
.OrderBy(x => x.SortCode)
.Select(a => new RouteItem
{
Id = a.Id,
Path = a.Url,
Name = a.PermissionName,
Component = a.Component,
Redirect = a.Redirect,
SortCode = a.SortCode,
Meta = new RouteMeta()
{
Title = a.Title,
Icon = a.Icon,
}
})
.ToList();
list.AddRange(perlist);
//去重
@ -234,7 +377,67 @@ public class CommonService : ICommonService
foreach (var item in list)
{
var childs = db.Queryable<SysPermission>().Where(x =>
x.MenuType == 2 && x.ParentId == item.Id && x.IsHidden == false && permissions.Contains(x.Id))
x.MenuType == 2 && x.ParentId == item.Id && x.IsHidden == false && permissions.Contains(x.Id) &&
(x.PermissionType == 1 || x.PermissionType == 0))
.OrderBy(x => x.SortCode)
.Select(a => new RouteItem
{
Path = a.Url,
Name = a.PermissionName,
Component = a.Component,
Meta = new RouteMeta()
{
Title = a.Title,
Icon = a.Icon,
}
}).ToList();
//去重
childs.Distinct();
//排序
childs = childs.OrderBy(x => x.SortCode).ToList();
item.Children = childs;
}
}
else
{
var roleIds = db.Queryable<SysRoleUser>().Where(x => x.UserId == userId).Select(x => x.RoleId).ToList();
var permissions = db.Queryable<SysRolePermission>().Where(x => roleIds.Contains(x.RoleId))
.Select(x => x.PermissionId).Distinct().ToList();
var perlist = db.Queryable<SysPermissionTenant>()
.Where(x => x.MenuType == 1 && x.IsHidden == false && permissions.Contains(x.PermissionId) &&
(x.PermissionType == 1 || x.PermissionType == 0))
.OrderBy(x => x.SortCode)
.Select(a => new RouteItem
{
Id = a.PermissionId,
Path = a.Url,
Name = a.PermissionName,
Component = a.Component,
Redirect = a.Redirect,
SortCode = a.SortCode,
Meta = new RouteMeta()
{
Title = a.Title,
Icon = a.Icon,
}
})
.ToList();
list.AddRange(perlist);
//去重
list.Distinct();
//排序
list = list.OrderBy(x => x.SortCode).ToList();
foreach (var item in list)
{
var childs = db.Queryable<SysPermissionTenant>().Where(x =>
x.MenuType == 2 && x.ParentId == item.Id && x.IsHidden == false && permissions.Contains(x.Id) &&
(x.PermissionType == 1 || x.PermissionType == 0))
.OrderBy(x => x.SortCode)
.Select(a => new RouteItem
{
@ -247,44 +450,6 @@ public class CommonService : ICommonService
Icon = a.Icon,
}
}).ToList();
// if (childs.Count == 0)
// {
// var publicSecondMenu = db.Queryable<SysPermission>().Filter(null, true).Where(x =>
// x.MenuType == 2 && x.ParentId == item.Id && x.IsHidden == false && x.PermissionType == (int)PermissionType.Public)
// .OrderBy(x=>x.SortCode)
// .Select(a => new RouteItem
// {
// Path = a.Url,
// Name = a.PermissionName,
// Component = a.Component,
// Meta = new RouteMeta()
// {
// Title = a.Title,
// Icon = a.Icon,
// }
// }).ToList();
// childs.AddRange(publicSecondMenu);
//
// // 权限身份菜单
// var identityecondMenu = db.Queryable<SysPermission>().Filter(null, true).Where(x =>
// x.MenuType == 2 && x.ParentId == item.Id && x.IsHidden == false && x.PermissionType == userInfo.PermissionIdentity)
// .OrderBy(x=>x.SortCode)
// .Select(a => new RouteItem
// {
// Id = a.Id,
// Path = a.Url,
// Name = a.PermissionName,
// Component = a.Component,
// Redirect = a.Redirect,
// Meta = new RouteMeta()
// {
// Title = a.Title,
// Icon = a.Icon,
// }
// })
// .ToList();
// childs.AddRange(identityecondMenu);
// }
//去重
childs.Distinct();
@ -298,6 +463,47 @@ public class CommonService : ICommonService
return DataResult<List<RouteItem>>.Success("获取数据成功!", list);
}
#endregion
#region 客户端通用
/// <summary>
/// 获取权限树列表-客户端
/// </summary>
/// <returns></returns>
public DataResult<List<PermissionTreeList>> GetClientPermissionTreeList()
{
var list = db.Queryable<SysPermission>()
.Where(x => x.MenuType == 1 && x.IsHidden == false && (x.PermissionType == 1 || x.PermissionType == 0))
.OrderBy(x => x.SortCode)
.Select(a => new PermissionTreeList
{
Title = a.PermissionName,
Key = a.Id,
Icon = a.Icon
})
.ToList();
foreach (var item in list)
{
var childs = db.Queryable<SysPermission>().Where(x =>
x.MenuType == 2 && x.IsHidden == false && x.ParentId == item.Key && (x.PermissionType == 1 || x.PermissionType == 0))
.OrderBy(x => x.SortCode)
.Select(a => new PermissionTreeList
{
Title = a.PermissionName,
Key = a.Id,
Icon = a.Icon
}).ToList();
item.Children = childs;
}
return DataResult<List<PermissionTreeList>>.Success("获取数据成功!", list);
}
#endregion
#region 获取服务器信息
/// <summary>
@ -396,13 +602,10 @@ public class CommonService : ICommonService
return DataResult.Successed("密码修改成功!");
}
#endregion 修改密码
#region 租户注册
#region 租户注册
/// <summary>
/// 租户注册
@ -463,7 +666,7 @@ public class CommonService : ICommonService
//写入注册用户
var userEntity = new SysUser
{
{
UserCode = req.AdminUserCode,
UserName = req.Name,
Password = req.AdminUserPassword,
@ -472,19 +675,19 @@ public class CommonService : ICommonService
NickName = req.AdminUserCode,
Email = "",
Phone = req.Phone,
UserType = UserTypeEnum.Admin.ToEnumInt(), //管理员
Status = 0, //正常
UserType = UserTypeEnum.ApplyUser.ToEnumInt(), //管理员
Status = 0, //正常
TenantId = 1288018625843826688,
};
var adminUser = db.Insertable(userEntity).ExecuteReturnEntity();
};
var adminUser = db.Insertable(userEntity).ExecuteReturnEntity();
//写入用户角色 指定角色
var roleUser = new SysRoleUser
{
RoleId = 1744922920100171776,
UserId = adminUser.Id
UserId = adminUser.Id
};
db.Insertable(roleUser).ExecuteCommand();
db.Ado.CommitTran();
return DataResult.Successed("企业注册成功!请登录后完善相关资料并提交审核!");
}

@ -22,7 +22,7 @@ public class JwtSafeMiddleware
{
// Console.WriteLine(context.Request.Path);
var path = context.Request.Path.ToString();
if (path.Contains("swagger") || path.Contains("login")|| path.Contains("TenantRegister"))
if (path.Contains("swagger") || path.Contains("login")|| path.Contains("TenantRegister") || path.Contains("ClientUserLogin") )
{
//跳过swagger及login
}

@ -22,14 +22,14 @@
</member>
<member name="M:DS.WMS.MainApi.Controllers.CommonController.Login(DS.WMS.Core.System.Dtos.UserLoginModel)">
<summary>
用户登录
用户登录-管理端
</summary>
<param name="model"></param>
<returns></returns>
</member>
<member name="M:DS.WMS.MainApi.Controllers.CommonController.GetUserInfo">
<summary>
获取用户
获取用户-管理端
</summary>
<returns></returns>
</member>
@ -41,7 +41,26 @@
</member>
<member name="M:DS.WMS.MainApi.Controllers.CommonController.GetUserPermissionByToken">
<summary>
查询用户拥有的菜单权限
查询用户拥有的菜单权限-管理端
</summary>
<returns></returns>
</member>
<member name="M:DS.WMS.MainApi.Controllers.CommonController.ClientUserLogin(DS.WMS.Core.System.Dtos.UserLoginModel)">
<summary>
用户登录-客户端
</summary>
<param name="model"></param>
<returns></returns>
</member>
<member name="M:DS.WMS.MainApi.Controllers.CommonController.GetClientUserInfo">
<summary>
获取用户-客户端
</summary>
<returns></returns>
</member>
<member name="M:DS.WMS.MainApi.Controllers.CommonController.GetClientUserPermissionByToken">
<summary>
查询用户拥有的菜单权限-客户端
</summary>
<returns></returns>
</member>
@ -71,6 +90,12 @@
<param name="model"></param>
<returns></returns>
</member>
<member name="M:DS.WMS.MainApi.Controllers.CommonController.GetClientPermissionTreeList">
<summary>
获取权限树列表-客户端
</summary>
<returns></returns>
</member>
<member name="M:DS.WMS.MainApi.Controllers.CommonController.GetDataRuleEntityFields(System.String)">
<summary>
获取数据权限字段

@ -24,7 +24,7 @@ public class CommonController : ApiController
}
/// <summary>
/// 用户登录
/// 用户登录-管理端
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
@ -38,7 +38,7 @@ public class CommonController : ApiController
}
/// <summary>
/// 获取用户
/// 获取用户-管理端
/// </summary>
/// <returns></returns>
[HttpGet]
@ -61,7 +61,7 @@ public class CommonController : ApiController
}
/// <summary>
/// 查询用户拥有的菜单权限
/// 查询用户拥有的菜单权限-管理端
/// </summary>
/// <returns></returns>
[HttpGet]
@ -72,6 +72,44 @@ public class CommonController : ApiController
return res;
}
/// <summary>
/// 用户登录-客户端
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
[Route("ClientUserLogin")]
public DataResult<string> ClientUserLogin([FromBody] UserLoginModel model)
{
var res = _invokeService.ClientUserLogin(model);
return res;
}
/// <summary>
/// 获取用户-客户端
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("GetClientUserInfo")]
public DataResult<CurrentUserViewModel> GetClientUserInfo()
{
var res = _invokeService.GetClientUserInfo();
return res;
}
/// <summary>
/// 查询用户拥有的菜单权限-客户端
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("GetClientUserPermissionByToken")]
public DataResult<List<RouteItem>> GetClientUserPermissionByToken()
{
var res = _invokeService.GetClientUserPermissionByToken();
return res;
}
/// <summary>
/// 获取服务器信息
/// </summary>
@ -124,6 +162,18 @@ public class CommonController : ApiController
return res;
}
/// <summary>
/// 获取权限树列表-客户端
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("GetClientPermissionTreeList")]
public DataResult<List<PermissionTreeList>> GetClientPermissionTreeList()
{
var res = _invokeService.GetClientPermissionTreeList();
return res;
}
/// <summary>
/// 获取数据权限字段
/// </summary>

@ -833,3 +833,52 @@
2024-01-11 16:38:23.9900 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-01-11 16:38:23.9900 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-01-11 16:38:24.0184 Info Configuration initialized.
2024-01-12 09:19:32.6470 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-01-12 09:19:32.6665 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-01-12 09:19:32.6775 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-01-12 09:19:32.6775 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.7.2287. Product version: 5.2.7+a1ef7cd83b5a6a172142a6850f0ced4e759a4b3b. GlobalAssemblyCache: False
2024-01-12 09:19:32.7066 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-01-12 09:19:32.7066 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-01-12 09:19:32.7296 Info Configuration initialized.
2024-01-12 10:45:51.9023 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-01-12 10:45:51.9446 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-01-12 10:45:51.9829 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-01-12 10:45:52.0405 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.7.2287. Product version: 5.2.7+a1ef7cd83b5a6a172142a6850f0ced4e759a4b3b. GlobalAssemblyCache: False
2024-01-12 10:45:52.1251 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-01-12 10:45:52.1790 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-01-12 10:45:52.2714 Info Configuration initialized.
2024-01-12 10:49:28.1112 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-01-12 10:49:28.1912 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-01-12 10:49:28.3204 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-01-12 10:49:28.3930 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.7.2287. Product version: 5.2.7+a1ef7cd83b5a6a172142a6850f0ced4e759a4b3b. GlobalAssemblyCache: False
2024-01-12 10:49:28.4624 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-01-12 10:49:28.5124 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-01-12 10:49:28.6148 Info Configuration initialized.
2024-01-12 11:26:34.8058 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-01-12 11:26:34.9598 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-01-12 11:26:34.9934 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-01-12 11:26:35.0738 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.7.2287. Product version: 5.2.7+a1ef7cd83b5a6a172142a6850f0ced4e759a4b3b. GlobalAssemblyCache: False
2024-01-12 11:26:35.1243 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-01-12 11:26:35.1522 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-01-12 11:26:35.2137 Info Configuration initialized.
2024-01-12 11:32:30.1398 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-01-12 11:32:30.1897 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-01-12 11:32:30.2525 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-01-12 11:32:30.3205 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.7.2287. Product version: 5.2.7+a1ef7cd83b5a6a172142a6850f0ced4e759a4b3b. GlobalAssemblyCache: False
2024-01-12 11:32:30.4000 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-01-12 11:32:30.4274 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-01-12 11:32:30.5826 Info Configuration initialized.
2024-01-12 12:00:25.7705 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-01-12 12:00:25.8147 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-01-12 12:00:25.8478 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-01-12 12:00:25.8885 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.7.2287. Product version: 5.2.7+a1ef7cd83b5a6a172142a6850f0ced4e759a4b3b. GlobalAssemblyCache: False
2024-01-12 12:00:25.9311 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-01-12 12:00:25.9516 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-01-12 12:00:26.0039 Info Configuration initialized.
2024-01-15 08:50:27.2072 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-01-15 08:50:27.2724 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-01-15 08:50:27.3312 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-01-15 08:50:27.4083 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.7.2287. Product version: 5.2.7+a1ef7cd83b5a6a172142a6850f0ced4e759a4b3b. GlobalAssemblyCache: False
2024-01-15 08:50:27.5191 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-01-15 08:50:27.5526 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-01-15 08:50:27.6339 Info Configuration initialized.

@ -16,12 +16,12 @@ const baseUploadUrl = globSetting.uploadUrl
const viewUploadUrl = globSetting.viewUrl
// eslint-disable-next-line @typescript-eslint/no-unused-vars
enum Api {
Login = '/mainApi/common/login',
GetUserInfo = '/mainApi/common/GetUserInfo',
Login = '/mainApi/common/ClientUserLogin',
GetUserInfo = '/mainApi/common/GetClientUserInfo',
getDictDrop = '/mainApi/Common/GetDictTypeDropDown',
getDictOptions = '/mainApi/Common/GetDictOptions',
getRoleList = '/mainApi/Common/GetRoleList',
GetMenuList = '/mainApi/Common/GetUserPermissionByToken',
GetMenuList = '/mainApi/Common/GetClientUserPermissionByToken',
GetPermCode = '/mainApi/Common/GetPermCode',
getUserTenants = '/mainApi/Common/GetUserTenants',
ChangeTenant = '/mainApi/Common/ChangeTenant',

@ -220,14 +220,6 @@ export const formSchema: FormSchema[] = [
label: '客户端',
value: 1,
},
{
label: '市平台',
value: 2,
},
{
label: '省平台',
value: 3,
},
],
},
itemProps: {

@ -182,4 +182,9 @@ export const fileSchema: FormSchema[] = [
fileType: UploadTypeEnum.image,
},
},
{
field: 'divider-selects',
component: 'Divider',
label: '审批',
},
]

Loading…
Cancel
Save