用户管理 调整

szh-new
张同海 3 months ago
parent 7b78bce919
commit 7e34e5058f

@ -102,6 +102,10 @@ export const formSchema: FormSchema[] = [
componentProps: ({ formModel }) => { componentProps: ({ formModel }) => {
return { return {
options: columnViewData, options: columnViewData,
showSearch: true,
filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
},
onChange: async (e: ChangeEvent, a) => { onChange: async (e: ChangeEvent, a) => {
console.log(e, a) console.log(e, a)
@ -188,6 +192,10 @@ export const formSchema: FormSchema[] = [
componentProps: ({ formModel }) => { componentProps: ({ formModel }) => {
return { return {
options: ClientPermissionData, options: ClientPermissionData,
showSearch: true,
filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
},
// xxxx props // xxxx props
onChange: (e) => { onChange: (e) => {
console.log(e) console.log(e)

@ -0,0 +1,139 @@
<template>
<BasicModal
v-bind="$attrs"
title="用户权限配置"
width="80%"
@register="registerModal"
@ok="handleSubmit"
>
<a-row :gutter="16">
<a-col :span="4">
<BasicTree
:tree-data="treeData"
:fieldNames="fieldNames"
:expandedKeys="expandedKeys"
:selectedKeys="selectedKeys"
@select="onselect"
/>
</a-col>
<a-col :span="10">
<dataruleIndex
ref="RefdataruleIndex"
:permissionId="permissionId"
@Create="Create"
@ChangeSelect="ChangeSelect"
/>
</a-col>
<a-col :span="10">
<dataruleInfo
ref="RefdataruleInfo"
:permissionId="permissionId"
:InfoId="InfoId"
@success="success"
/>
</a-col>
</a-row>
<template #footer>
<PopConfirmButton
title="确定放弃编辑?"
ok-text="确定"
cancel-text="取消"
@confirm="closeModal"
>取消</PopConfirmButton
>
<a-button
type="primary"
pre-icon="ant-design:save-outlined"
:loading="loading"
ghost
style="margin-right: 0.8rem"
@click="handleSubmit(false)"
>仅保存</a-button
>
<a-button type="primary" :loading="loading" @click="handleSubmit(true)"></a-button>
</template>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, computed, unref } from 'vue'
import { BasicModal, useModalInner } from '/@/components/Modal'
import { BasicTree, TreeItem } from '/@/components/Tree'
import dataruleIndex from './dataruleIndex.vue'
import dataruleInfo from './dataruleInfo.vue'
import { PopConfirmButton } from '/@/components/Button'
// import { queryTreeListForRole, queryRolePermission, saveRolePermission } from '../role.api';
import { GetClientUserPermissions } from './api'
// const emit = defineEmits(['register']);
//
const treeData = ref<TreeItem[]>([])
//
const loading = ref(false)
const selectedKeys = ref<any>([])
const expandedKeys = ref<any>([])
const fieldNames = ref({ children: 'children', title: 'name', key: 'id' })
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await reset()
setModalProps({ confirmLoading: false, loading: true })
//
const res = await GetClientUserPermissions()
treeData.value = res.data
permissionId.value = res.data[0].children[0].id
selectedKeys.value[0] = res.data[0].children[0].id
expandedKeys.value[0] = res.data[0].id
setModalProps({ loading: false })
})
/**
* 点击选中
*/
const permissionId = ref()
async function onselect(checkedKeys, e) {
let type = true
treeData.value.forEach((item) => {
if (item.id == checkedKeys[0]) {
type = false
}
})
if (type) {
permissionId.value = checkedKeys[0]
}
}
const RefdataruleIndex = ref()
const RefdataruleInfo = ref()
//
function Create() {
RefdataruleIndex.value.clearSelectedRowKeys()
RefdataruleInfo.value.resetFields()
RefdataruleInfo.value.setFieldsValue({ permissionId: permissionId.value })
}
//
function success() {
RefdataruleIndex.value.reload()
}
const InfoId = ref('')
//
function ChangeSelect(data) {
console.log(data[0])
InfoId.value = data[0]
}
/**
* 数据重置
*/
function reset() {
treeData.value = []
}
/**
* 提交
*/
async function handleSubmit(exit) {
RefdataruleInfo.value.handleSave()
}
</script>
<style lang="less" scoped>
/** 固定操作按钮 */
.jeecg-basic-tree {
position: absolute;
width: 618px;
}
</style>

@ -3,7 +3,12 @@ import { DataResult, PageRequest } from '/@/api/model/baseModel'
enum Api { enum Api {
list = '/mainApi/ClientBank/GetClientBankList', list = '/mainApi/ClientBank/GetClientBankList',
edit = '/mainApi/ClientBank/EditClientBank', edit = '/mainApi/ClientBank/EditClientBank',
info = '/mainApi/ClientBank/GetClientBankInfo' info = '/mainApi/ClientBank/GetClientBankInfo',
GetClientUserPermissions = '/mainApi/User/GetClientUserPermissions',
GetDataRuleListByPermission = '/mainApi/User/GetDataRuleListByPermission'
} }
// 客户银行信息 列表 (Auth) // 客户银行信息 列表 (Auth)
export function GetClientBankList(data) { export function GetClientBankList(data) {
@ -33,3 +38,20 @@ export function GetClientBankInfo(params) {
} }
// 查询客户端 用户拥有的菜单权限 (Auth)
export function GetClientUserPermissions() {
return request<DataResult>({
url: Api.GetClientUserPermissions,
method: 'get',
})
}
// 根据权限模块获取数据范围列表 (Auth)
export function GetDataRuleListByPermission(params) {
return request<DataResult>({
url: Api.GetDataRuleListByPermission,
method: 'get',
params
})
}

@ -1,4 +1,5 @@
import { ref } from 'vue' import { h, ref } from 'vue'
import ConditionFilter from '../datarule/Condition/index.vue'
import { BasicColumn, FormSchema } from '/@/components/Table' import { BasicColumn, FormSchema } from '/@/components/Table'
import { import {
getRoleList, getRoleList,
@ -7,6 +8,8 @@ import {
GetFeeCurrencySelectList, GetFeeCurrencySelectList,
getCountryList, getCountryList,
} from '/@/api/common' } from '/@/api/common'
import { GetTablesByClient } from '/@/views/baseinfo/clientflowtemplate/api'
import { getTables, getColumns, getClientPermissionList } from '/@/api/system/role'
import { Tag } from 'ant-design-vue' import { Tag } from 'ant-design-vue'
import { useOptionsStore } from '/@/store/modules/options' import { useOptionsStore } from '/@/store/modules/options'
import { checkPermissions } from '/@/hooks/Permissions/index' import { checkPermissions } from '/@/hooks/Permissions/index'
@ -18,6 +21,30 @@ const orgIds = ref([])
getOrgList().then((res) => { getOrgList().then((res) => {
orgIds.value = res.data orgIds.value = res.data
}) })
const columnViewData = []
const res: API.DataResult = await GetTablesByClient()
if (res.succeeded) {
res.data.forEach((item) => {
columnViewData.push({
label: item.description,
value: item.name,
})
})
}
const ClientPermissionData = []
let ClientPermissionList = []
const res2: API.DataResult = await getClientPermissionList()
if (res2.succeeded) {
console.log(res2)
ClientPermissionList = res2.data
res2.data.forEach((item) => {
ClientPermissionData.push({
label: item.permissionName,
value: item.id,
})
})
}
const fields = ref<Field[]>([])
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
title: '用户编码', title: '用户编码',
@ -353,7 +380,7 @@ export const formSchema: FormSchema[] = [
valueField: 'id', valueField: 'id',
filterOption: (input: string, option: any) => { filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
} },
} }
}, },
}, },
@ -361,7 +388,7 @@ export const formSchema: FormSchema[] = [
field: 'userNumber', field: 'userNumber',
component: 'Input', component: 'Input',
label: '', label: '',
show: false show: false,
}, },
{ {
field: 'divider-selects', field: 'divider-selects',
@ -369,8 +396,8 @@ export const formSchema: FormSchema[] = [
label: '附属信息', label: '附属信息',
componentProps: {}, componentProps: {},
colProps: { colProps: {
span: 24 span: 24,
} },
}, },
{ {
field: 'orgIds', field: 'orgIds',
@ -407,7 +434,7 @@ export const formSchema: FormSchema[] = [
field: 'defaultOrgName', field: 'defaultOrgName',
label: '', label: '',
component: 'Input', component: 'Input',
show: false show: false,
}, },
{ {
field: 'defaultOrgId', field: 'defaultOrgId',
@ -451,7 +478,7 @@ export const formSchema: FormSchema[] = [
field: 'deptName', field: 'deptName',
label: '', label: '',
component: 'Input', component: 'Input',
show: false show: false,
}, },
{ {
field: 'deptId', field: 'deptId',
@ -474,7 +501,7 @@ export const formSchema: FormSchema[] = [
if (!e && !obj) { if (!e && !obj) {
formModel.deptName = null formModel.deptName = null
} }
} },
} }
}, },
dynamicDisabled: ({ values }) => { dynamicDisabled: ({ values }) => {
@ -491,8 +518,8 @@ export const formSchema: FormSchema[] = [
componentProps: { componentProps: {
mode: 'multiple', mode: 'multiple',
api: getRoleList, api: getRoleList,
resultField: 'data' resultField: 'data',
} },
}, },
{ {
field: 'signatureUrl', field: 'signatureUrl',
@ -502,7 +529,7 @@ export const formSchema: FormSchema[] = [
show: ({ values }) => { show: ({ values }) => {
return !!values.id return !!values.id
}, },
colProps: { span: 24 } colProps: { span: 24 },
}, },
] ]
@ -623,3 +650,206 @@ export const BankFormSchema: FormSchema[] = [
colProps: { span: 24 }, colProps: { span: 24 },
}, },
] ]
export const infoformSchema: FormSchema[] = [
{
field: 'divider-selects',
component: 'Divider',
label: '基本信息',
colProps: { span: 24 },
},
{
label: '',
field: 'id',
component: 'Input',
defaultValue: '',
show: false,
},
{
field: 'columnView',
label: '中文视图名',
component: 'Select',
required: true,
colProps: { span: 12 },
componentProps: ({ formModel }) => {
return {
options: columnViewData,
showSearch: true,
filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
},
onChange: async (e: ChangeEvent, a) => {
console.log(e, a)
const res: API.DataResult = await getColumns({ tableViewName: e })
fields.value = []
if (res.succeeded) {
console.log(res)
const Arr = [
{
dbColumnName: '{loginRole}',
columnDescription: '当前登录用户的角色',
},
{
dbColumnName: '{loginUser}',
columnDescription: '当前登录的用户',
},
{
dbColumnName: '{loginOrg}',
columnDescription: '机构',
},
]
res.data = [...res.data, ...Arr]
res.data.forEach((item) => {
// if (item.name == tableViewName) {
fields.value.push({
id: item.dbColumnName,
title: item.columnDescription,
name: 'Select',
value: null,
props: {
disabled: false,
multiple: false,
// placeholder: '请选择请假事由',
options: [],
},
style: {
width: '100%',
},
})
// }
})
if (a) {
formModel.field1 = {
groups: [],
conditions: [],
}
}
console.log(fields.value, 'fields.value')
}
},
}
},
},
{
label: '权限实体',
field: 'permissionEntity',
component: 'Input',
defaultValue: '',
show: false,
},
{
label: '',
field: 'Space1',
component: 'Space',
defaultValue: '',
colProps: {
span: 12,
},
},
{
field: 'permissionId',
label: '资源标识',
component: 'Select',
colProps: { span: 12 },
required: true,
show: false,
componentProps: ({ formModel }) => {
return {
options: ClientPermissionData,
showSearch: true,
filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
},
// xxxx props
onChange: (e) => {
console.log(e)
ClientPermissionList.forEach((item) => {
if (item.id == e) {
console.log(item)
formModel.permissionEntity = item.permissionEntity
}
})
},
}
},
},
{
field: 'status',
label: '是否启用',
component: 'RadioButtonGroup',
defaultValue: 0,
colProps: { span: 12 },
componentProps: {
options: [
{ label: '是', value: 0 },
{ label: '否', value: 1 },
],
},
},
{
field: 'orderNo',
label: '排序号',
component: 'InputNumber',
defaultValue: 0,
colProps: { span: 12 },
},
{
field: 'description',
label: '权限描述',
required: true,
component: 'InputTextArea',
colProps: { span: 12 },
componentProps: {
rows: 4,
},
},
{
field: 'note',
label: '备注',
component: 'InputTextArea',
colProps: { span: 12 },
componentProps: {
rows: 4,
},
},
{
field: 'divider-selects',
component: 'Divider',
label: '权限规则',
colProps: { span: 24 },
ifShow: ({ values }) => {
return !!values.columnView
},
},
{
field: 'field1',
component: 'Input',
colProps: {
span: 24,
},
defaultValue: {
groups: [],
conditions: [],
},
ifShow: ({ values }) => {
return !!values.columnView
},
// 通过函数渲染一个 Input
render: ({ model, field }) => {
return h(ConditionFilter, {
modelValue: model[field],
filterFields: fields.value,
// onChange: (e: ChangeEvent) => {
// console.log(e);
// model[field] = e.target.value;
// },
})
},
// componentProps: {
// onChange: (e: ChangeEvent) => {
// console.log('change', e);
// },
// },
},
]

@ -0,0 +1,82 @@
<template>
<div>
<BasicTable @register="registerTable" rowKey="id" :maxHeight="400">
<template #tableTitle>
<span class="title">数据权限列表</span>
<a-button type="link" @click="handleCreate">
<span class="iconfont icon-new_document"></span>
新增
</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'roleName'">
<span style="color: #0d84ff" @click="handleEdit(record)">{{ record.roleName }}</span>
</template>
</template>
</BasicTable>
</div>
</template>
<script lang="ts" setup>
import { BasicTable, useTable, TableAction } from '/@/components/Table'
import { columns } from '/@/views/system/datarule/columns.tsx'
import { watch } from 'vue'
import { GetDataRuleListByPermission } from './api'
const props = defineProps({
permissionId: { type: String },
})
// Emits
const emit = defineEmits(['Create', 'ChangeSelect'])
watch(
() => props.permissionId,
(Nval) => {
reload()
},
)
const [registerTable, { reload, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
title: '',
api: async () => {
const res = await GetDataRuleListByPermission({ permissionId: props.permissionId })
return new Promise((resolve) => {
if (res.data.length) {
setSelectedRowKeys([res.data[0].id])
}
resolve({ data: [...res.data] })
})
},
columns,
isTreeTable: false,
pagination: false,
striped: true,
useSearchForm: false,
showTableSetting: false,
bordered: true,
showIndexColumn: true,
canResize: true,
immediate: false,
clickToRowSelect: true,
rowSelection: {
type: 'radio',
onChange: (selectedRowKeys: string[]) => {
emit('ChangeSelect', selectedRowKeys)
},
},
})
function handleCreate() {
console.log('新增')
emit('Create')
}
defineExpose({
reload,
clearSelectedRowKeys,
})
</script>
<style lang="less" scoped>
.title {
font-size: 12px;
font-weight: 700;
letter-spacing: 1px;
line-height: 15.84px;
color: rgba(51, 56, 61, 1);
text-align: left;
}
</style>

@ -0,0 +1,102 @@
<template>
<BasicForm @register="registerForm"> </BasicForm>
</template>
<script lang="ts" setup>
import { ref, unref, watch } from 'vue'
import { BasicForm, useForm } from '/@/components/Form/index'
import { infoformSchema } from './columns.tsx'
import { editDataRule, getDataRuleInfo } from '/@/api/system/datarule'
import { useMessage } from '/@/hooks/web/useMessage'
const props = defineProps({
permissionId: { type: String },
InfoId: { type: String },
})
watch(
() => props.permissionId,
(Nval) => {
setFieldsValue({
permissionId: Nval,
})
},
)
watch(
() => props.InfoId,
(Nval) => {
rowId.value = Nval
GetData()
},
)
// Emits
const emit = defineEmits(['success', 'register'])
const isUpdate = ref(true)
const loading = ref(false)
const rowId = ref<any>('')
const { createMessage } = useMessage()
const [registerForm, { resetFields, setFieldsValue, validate, updateSchema, getFieldsValue }] =
useForm({
labelWidth: 110,
schemas: infoformSchema,
showActionButtonGroup: false,
})
async function GetData() {
const res = await getDataRuleInfo({ id: unref(rowId) })
if (res.succeeded) {
setFieldsValue({
...res.data,
field1: JSON.parse(res.data.dataRules),
})
}
}
async function handleSave(exit) {
try {
const values = await validate()
values.dataRules = JSON.stringify(values.field1)
loading.value = true
const res = await editDataRule({
columnView: values.columnView,
dataRules: values.dataRules,
description: values.description,
id: values.id,
note: values.note,
orderNo: values.orderNo,
permissionEntity: values.permissionEntity,
permissionId: values.permissionId,
status: values.status,
})
if (res.succeeded) {
createMessage.success(res.message)
emit('success')
//
if (!exit) {
if (unref(isUpdate)) {
await refresh()
} else {
rowId.value = res.data
isUpdate.value = true
await refresh()
}
}
loading.value = false
} else {
createMessage.error(res.message)
loading.value = false
}
} finally {
loading.value = false
}
}
async function refresh() {
const res = await getDataRuleInfo({ id: unref(rowId) })
if (res.succeeded) {
await setFieldsValue({
...res.data,
})
}
}
defineExpose({
resetFields,
setFieldsValue,
handleSave,
})
</script>

@ -24,6 +24,11 @@
tooltip: '编辑', tooltip: '编辑',
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
}, },
{
icon: 'ant-design:trademark-circle-outlined',
tooltip: '授权',
onClick: handlePermission.bind(null, record),
},
{ {
icon: 'ant-design:delete-outlined', icon: 'ant-design:delete-outlined',
tooltip: '删除', tooltip: '删除',
@ -32,15 +37,16 @@
title: '是否要删除此条数据?', title: '是否要删除此条数据?',
okText: '是', okText: '是',
cancelText: '否', cancelText: '否',
confirm: handleDelete.bind(null, record) confirm: handleDelete.bind(null, record),
} },
} },
]" ]"
/> />
</template> </template>
</template> </template>
</BasicTable> </BasicTable>
<UserModal @register="registerModal" @success="handleSuccess" /> <UserModal @register="registerModal" @success="handleSuccess" />
<UserPermissionModal @register="registerPermissionModal" @success="handleSuccess" />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -50,10 +56,12 @@
import { formatParams } from '/@/hooks/web/common' import { formatParams } from '/@/hooks/web/common'
import { useModal } from '/@/components/Modal' import { useModal } from '/@/components/Modal'
import UserModal from './UserModal.vue' import UserModal from './UserModal.vue'
import UserPermissionModal from './UserPermissionModal.vue'
import { columns, searchFormSchema } from './columns' import { columns, searchFormSchema } from './columns'
const [registerModal, { openModal }] = useModal() const [registerModal, { openModal }] = useModal()
import { useMessage } from '/@/hooks/web/useMessage' import { useMessage } from '/@/hooks/web/useMessage'
const { createMessage } = useMessage() const { createMessage } = useMessage()
const [registerPermissionModal, { openModal: openPermissionModal }] = useModal()
const [registerTable, { reload, getForm, getPaginationRef }] = useTable({ const [registerTable, { reload, getForm, getPaginationRef }] = useTable({
api: async (p) => { api: async (p) => {
const res: API.DataResult = await getUserList(p) const res: API.DataResult = await getUserList(p)
@ -77,9 +85,10 @@
showTableSetting: true, showTableSetting: true,
bordered: true, bordered: true,
showIndexColumn: true, showIndexColumn: true,
canResize: false, canResize: true,
resizeHeightOffset: 35,
actionColumn: { actionColumn: {
width: 80, width: 120,
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
fixed: 'right', fixed: 'right',
@ -99,6 +108,12 @@
isUpdate: true, isUpdate: true,
}) })
} }
function handlePermission(record: Recordable) {
openPermissionModal(true, {
record,
isUpdate: true,
})
}
// //
async function handleDelete(record) { async function handleDelete(record) {
const res = await BatchDelUser({ const res = await BatchDelUser({
@ -119,5 +134,4 @@
reload() reload()
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss"></style>
</style>

Loading…
Cancel
Save