用户管理 调整
parent
7b78bce919
commit
7e34e5058f
@ -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>
|
@ -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>
|
Loading…
Reference in New Issue