Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
bigDataSystem
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张伯涛
bigDataSystem
Commits
1a4b9d69
Commit
1a4b9d69
authored
Nov 04, 2024
by
罗林杰
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
f1f03401
e5e17d59
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
834 additions
and
1 deletion
+834
-1
index.vue
src/views/notifications/noticeManage/index.vue
+198
-1
noti.data.ts
src/views/notifications/noticeManage/noti.data.ts
+173
-0
notiDrawer.vue
src/views/notifications/noticeManage/notiDrawer.vue
+126
-0
notiModal.data.ts
src/views/notifications/noticeManage/notiModal.data.ts
+92
-0
notiModal.vue
src/views/notifications/noticeManage/notiModal.vue
+245
-0
No files found.
src/views/notifications/noticeManage/index.vue
View file @
1a4b9d69
<
template
>
<
template
>
<div>
通知中心
</div>
<div>
<tabs
v-model:value=
"activeKey"
@
change=
"handleTabChange"
>
<Tabs
.
TabPane
key=
"1"
tab=
"Tab 1"
>
<BasicTable
@
register=
"registerTable"
>
<!--
<template
#
toolbar
>
<a-button
type=
"primary"
@
click=
"handleCreate"
>
新增角色
</a-button>
<a-button
type=
"primary"
@
click=
"handleExport"
>
导出
</a-button>
</
template
>
-->
<
template
#
bodyCell=
"{ column, record }"
>
<template
v-if=
"column.key === 'action'"
>
<TableAction
:actions=
"[
{
// icon: 'clarity:note-edit-line',
label: '编辑',
onClick: handleEdit.bind(null, record),
},
{
// icon: 'clarity:note-edit-line',
label: '数据权限',
onClick: dataPermiss.bind(null, record),
},
{
// icon: 'ant-design:delete-outlined',
label: '删除',
color: 'error',
popConfirm: {
title: '是否确认删除',
placement: 'left',
confirm: handleDelete.bind(null, record),
},
},
]"
/>
</
template
>
</template>
</BasicTable>
</Tabs
.TabPane
>
<Tabs
.
TabPane
key=
"2"
tab=
"Tab 2"
>
<BasicTable
@
register=
"registerTable"
>
<
template
#
toolbar
>
<a-button
type=
"primary"
@
click=
"handleCreate"
>
新增角色
</a-button>
<a-button
type=
"primary"
@
click=
"handleExport"
>
导出
</a-button>
</
template
>
<
template
#
bodyCell=
"{ column, record }"
>
<template
v-if=
"column.key === 'action'"
>
<TableAction
:actions=
"[
{
// icon: 'clarity:note-edit-line',
label: '编22222222222辑',
onClick: handleEdit.bind(null, record),
},
{
// icon: 'clarity:note-edit-line',
label: '数据222222222222222权限',
onClick: dataPermiss.bind(null, record),
},
{
// icon: 'ant-design:delete-outlined',
label: '删2222222222222222除',
color: 'error',
popConfirm: {
title: '是否确认删除',
placement: 'left',
confirm: handleDelete.bind(null, record),
},
},
]"
/>
</
template
>
</template>
</BasicTable>
</Tabs
.TabPane
>
</tabs>
<NotiDrawer
@
register=
"registerDrawer"
@
success=
"handleSuccess"
/>
<NotiModal
@
register=
"registerModal"
@
success=
"handleSuccess"
/>
</div>
</template>
</template>
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
BasicTable
,
useTable
,
TableAction
}
from
'@/components/Table'
;
import
{
getRoleListByPage
,
deleteById
,
exportRoleList
}
from
'@/api/system/role/role'
;
import
{
downloadByData
}
from
'@/utils/file/download'
;
import
{
useDrawer
}
from
'@/components/Drawer'
;
import
NotiDrawer
from
'./notiDrawer.vue'
;
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
import
{
columns
,
searchFormSchema
}
from
'./noti.data'
;
import
{
reactive
,
unref
,
onDeactivated
,
onMounted
,
ref
}
from
'vue'
;
import
{
useRoute
,
onBeforeRouteLeave
}
from
'vue-router'
;
import
{
useFilterStore
}
from
'@/store/modules/filterData'
;
import
{
useUserStore
}
from
'@/store/modules/user'
;
import
NotiModal
from
'./notiModal.vue'
;
import
{
useModal
}
from
'@/components/Modal'
;
import
{
getMenuListByPage
}
from
'@/api/system/menu/menu'
;
import
{
Tabs
}
from
'ant-design-vue'
;
defineOptions
({
name
:
'RoleManagement'
});
const
filterStore
=
useFilterStore
();
const
route
=
useRoute
();
const
{
createMessage
}
=
useMessage
();
const
[
registerDrawer
,
{
openDrawer
}]
=
useDrawer
();
const
[
registerModal
,
{
openModal
}]
=
useModal
();
const
[
registerTable
,
{
reload
,
getForm
}]
=
useTable
({
title
:
'通知列表'
,
api
:
getRoleListByPage
,
columns
,
formConfig
:
{
labelWidth
:
120
,
schemas
:
searchFormSchema
,
},
useSearchForm
:
true
,
showTableSetting
:
true
,
bordered
:
true
,
showIndexColumn
:
false
,
actionColumn
:
{
width
:
200
,
title
:
'操作'
,
dataIndex
:
'action'
,
// slots: { customRender: 'action' },
fixed
:
undefined
,
},
});
/***新增角色按钮*/
function
handleCreate
()
{
openDrawer
(
true
,
{
isUpdate
:
false
,
});
}
/** 导出按钮*/
async
function
handleExport
()
{
console
.
log
(
'导出----'
);
const
params
=
Object
.
assign
({},
getForm
().
getFieldsValue
());
const
data
=
await
exportRoleList
(
params
);
downloadByData
(
data
,
'角色列表'
+
'.xlsx'
);
}
/**编辑按钮*/
function
handleEdit
(
record
:
Recordable
)
{
openDrawer
(
true
,
{
record
,
isUpdate
:
true
,
});
}
/**数据权限按钮*/
function
dataPermiss
(
record
:
Recordable
)
{
openModal
(
true
,
{
isPermiss
:
true
,
record
,
});
}
/**删除按钮*/
async
function
handleDelete
(
record
:
Recordable
)
{
await
deleteById
(
record
.
businessId
);
createMessage
.
success
(
'删除成功!'
);
await
reload
();
}
function
handleSuccess
()
{
reload
();
}
/**进入页面的初始化方法*/
onMounted
(()
=>
{
const
path
=
route
.
path
;
if
(
filterStore
.
getSearchParams
[
path
])
{
if
(
JSON
.
parse
(
filterStore
.
getSearchParams
[
path
]
!==
{}))
{
const
params
=
JSON
.
parse
(
filterStore
.
getSearchParams
[
path
]);
getForm
().
setFieldsValue
({
page
:
params
.
page
,
pageSize
:
params
.
pageSize
,
roleName
:
params
.
roleName
,
roleKey
:
params
.
roleKey
,
flag
:
params
.
flag
,
});
}
}
});
/**离开路由前调用的钩子函数*/
onBeforeRouteLeave
((
to
,
from
,
next
)
=>
{
const
params
=
Object
.
assign
({},
getForm
().
getFieldsValue
());
filterStore
.
setSearchParams
({
path
:
from
.
path
,
param
:
{
...
params
,
},
});
next
();
// 允许导航
});
//标签页切换
const
activeKey
=
ref
(
'1'
);
const
handleTabChange
=
(
key
)
=>
{
console
.
log
(
'Active tab:'
,
key
);
activeKey
.
value
=
key
;
};
</
script
>
</
script
>
src/views/notifications/noticeManage/noti.data.ts
0 → 100644
View file @
1a4b9d69
import
{
BasicColumn
,
FormSchema
}
from
'@/components/Table'
;
import
{
h
,
Ref
}
from
'vue'
;
import
{
Switch
}
from
'ant-design-vue'
;
import
{
setRoleStatus
}
from
'@/api/system/role/role'
;
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
type
CheckedType
=
boolean
|
string
|
number
;
export
const
columns
:
BasicColumn
[]
=
[
{
title
:
'选择'
,
dataIndex
:
'select'
,
width
:
60
,
},
{
title
:
'通知时间'
,
dataIndex
:
'createDate'
,
width
:
200
,
},
{
title
:
'通知规则'
,
dataIndex
:
'alarmRule'
,
width
:
180
,
},
{
title
:
'紧急程度'
,
dataIndex
:
'alarmLevel'
,
width
:
100
,
},
{
title
:
'资源类型'
,
dataIndex
:
'resourceType'
,
width
:
100
,
},
{
title
:
'触发方式'
,
dataIndex
:
'triggerType'
,
width
:
100
,
},
];
export
const
searchFormSchema
:
FormSchema
[]
=
[
{
field
:
'roleName'
,
label
:
''
,
component
:
'Input'
,
componentProps
:
{
placeholder
:
'请输入关键字'
,
},
colProps
:
{
span
:
4
},
},
{
field
:
'alarmRule1'
,
label
:
''
,
component
:
'Select'
,
componentProps
:
{
options
:
[{
label
:
'全部通知规则'
,
value
:
'1'
}],
placeholder
:
'请选择通知规则范围'
,
defaultValue
:
'1'
,
},
colProps
:
{
span
:
4
},
},
{
field
:
'alarmRule'
,
label
:
''
,
component
:
'Select'
,
componentProps
:
{
options
:
[
{
label
:
'元数据变更'
,
value
:
'1'
},
{
label
:
'元数据处理'
,
value
:
'2'
},
],
placeholder
:
'请选择通知规则'
,
},
colProps
:
{
span
:
4
},
},
{
field
:
'resourceType'
,
label
:
''
,
component
:
'Select'
,
componentProps
:
{
options
:
[
{
label
:
'资源类型1'
,
value
:
'1'
},
{
label
:
'资源类型2'
,
value
:
'2'
},
],
placeholder
:
'请选择资源类型'
,
},
colProps
:
{
span
:
4
},
},
{
field
:
'alarmLevel'
,
label
:
''
,
component
:
'Select'
,
componentProps
:
{
options
:
[
{
label
:
'元数据变更'
,
value
:
'1'
},
{
label
:
'元数据处理'
,
value
:
'2'
},
],
placeholder
:
'请选择紧急程度'
,
},
colProps
:
{
span
:
8
},
},
];
export
const
formSchema
:
FormSchema
[]
=
[
{
field
:
'roleName'
,
label
:
'角色名称'
,
component
:
'Input'
,
rules
:
[
{
required
:
true
,
message
:
'请输入角色名称'
,
},
],
},
{
field
:
'roleKey'
,
label
:
'权限字符'
,
component
:
'Input'
,
rules
:
[
{
required
:
true
,
message
:
'请输入权限字符'
,
},
],
},
{
field
:
'roleSort'
,
label
:
'角色排序'
,
component
:
'InputNumber'
,
rules
:
[
{
required
:
true
,
message
:
'请输入角色排序'
,
pattern
:
/^
\d
+$/
,
//需要将返回的数字变成字符串再校验
},
],
componentProps
:
{
min
:
0
,
// 最小值
max
:
9999
,
// 最大值(根据需要调整)
step
:
1
,
// 每次增减的步长
placeholder
:
'请输入角色排序'
,
// 占位符
style
:
{
width
:
'100%'
},
// 样式(可选)
},
},
{
field
:
'flag'
,
label
:
'状态'
,
component
:
'RadioButtonGroup'
,
defaultValue
:
'0'
,
componentProps
:
{
options
:
[
{
label
:
'启用'
,
value
:
'1'
},
{
label
:
'停用'
,
value
:
'0'
},
],
},
},
{
label
:
'备注'
,
field
:
'remarks'
,
component
:
'InputTextArea'
,
},
{
label
:
' '
,
field
:
'menuIds'
,
slot
:
'menu'
,
rules
:
[
{
required
:
true
,
message
:
'请选择菜单权限'
,
},
],
},
];
src/views/notifications/noticeManage/notiDrawer.vue
0 → 100644
View file @
1a4b9d69
<
template
>
<BasicDrawer
v-bind=
"$attrs"
@
register=
"registerDrawer"
showFooter
:title=
"getTitle"
width=
"500px"
@
ok=
"handleSubmit"
>
<BasicForm
@
register=
"registerForm"
>
<template
#
menu=
"
{ model, field }">
<BasicTree
v-model:value=
"model[field]"
:treeData=
"treeData"
:fieldNames=
"
{ title: 'label', key: 'id' }"
checkable
toolbar
title="菜单分配"
/>
</
template
>
</BasicForm>
</BasicDrawer>
</template>
<
script
lang=
"ts"
setup
>
import
{
ref
,
computed
,
unref
}
from
'vue'
;
import
{
BasicForm
,
useForm
}
from
'@/components/Form'
;
import
{
formSchema
}
from
'./noti.data'
;
import
{
BasicDrawer
,
useDrawerInner
}
from
'@/components/Drawer'
;
import
{
BasicTree
,
TreeItem
}
from
'@/components/Tree'
;
import
{
roleDetailApi
,
roleUpdataApi
,
addRoleApi
}
from
'@/api/system/role/role'
;
import
{
getMenuSelect
,
getRoleMenuSelected
}
from
'@/api/system/menu/menu'
;
import
{
encryptTwo
}
from
'@/utils/jsencrypt'
;
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
const
emit
=
defineEmits
([
'success'
,
'register'
]);
const
{
createMessage
}
=
useMessage
();
const
isUpdate
=
ref
(
true
);
const
roleId
=
ref
(
''
);
const
treeData
=
ref
<
TreeItem
[]
>
([]);
const
[
registerForm
,
{
resetFields
,
setFieldsValue
,
validate
}]
=
useForm
({
labelWidth
:
90
,
baseColProps
:
{
span
:
24
},
schemas
:
formSchema
,
showActionButtonGroup
:
false
,
});
const
[
registerDrawer
,
{
setDrawerProps
,
closeDrawer
}]
=
useDrawerInner
(
async
(
data
)
=>
{
resetFields
();
setDrawerProps
({
confirmLoading
:
false
});
// 需要在setFieldsValue之前先填充treeData,否则Tree组件可能会报key not exist警告
if
(
unref
(
treeData
).
length
===
0
)
{
const
treeRes
=
await
getMenuSelect
();
treeData
.
value
=
treeRes
.
data
as
any
as
TreeItem
[];
}
//获取角色已选择的菜单
const
params
=
{
businessId
:
data
.
record
.
businessId
,
};
const
selectedTree
=
await
getRoleMenuSelected
(
params
);
// 过滤掉值小于10的项,并将选中的节点ID从数字数组转换为字符串数组
const
selectedKeys
=
selectedTree
.
data
.
checkedKeys
.
filter
((
key
)
=>
key
>=
100
)
// 过滤掉值小于10的项
.
map
((
key
)
=>
key
.
toString
());
// 将数字转换为字符串
//获取角色信息
isUpdate
.
value
=
!!
data
?.
isUpdate
;
if
(
unref
(
isUpdate
))
{
// 获取行数据的id
roleId
.
value
=
data
.
record
.
businessId
;
// 通过id获取角色详情信息
roleDetailApi
(
roleId
.
value
).
then
((
res
)
=>
{
const
form
=
res
.
data
;
form
.
menuIds
=
selectedKeys
;
// 塞值
setFieldsValue
({
...
form
,
});
});
}
});
const
getTitle
=
computed
(()
=>
(
!
unref
(
isUpdate
)
?
'新增角色'
:
'编辑角色'
));
async
function
handleSubmit
()
{
try
{
const
formData
=
await
validate
();
setDrawerProps
({
confirmLoading
:
true
});
// 编辑
if
(
unref
(
isUpdate
))
{
formData
.
businessId
=
roleId
.
value
;
roleUpdataApi
(
formData
).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
createMessage
.
success
(
'编辑成功'
);
closeDrawer
();
emit
(
'success'
,
{
isUpdate
:
unref
(
isUpdate
),
values
:
{
...
formData
,
id
:
roleId
.
value
},
});
}
});
}
else
{
//新增
const
paramsAdd
=
{
businessId
:
formData
.
businessId
,
menuIds
:
formData
.
menuIds
,
remarks
:
formData
.
remarks
,
roleKey
:
formData
.
roleKey
,
roleName
:
formData
.
roleName
,
roleSort
:
formData
.
roleSort
,
roleStatus
:
formData
.
roleStatus
,
};
addRoleApi
(
paramsAdd
).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
createMessage
.
success
(
'新增成功'
);
closeDrawer
();
emit
(
'success'
,
{
isUpdate
:
unref
(
isUpdate
),
values
:
{
...
formData
,
id
:
roleId
.
value
},
});
}
});
}
}
finally
{
setDrawerProps
({
confirmLoading
:
false
});
}
}
</
script
>
src/views/notifications/noticeManage/notiModal.data.ts
0 → 100644
View file @
1a4b9d69
import
{
BasicColumn
,
FormSchema
}
from
'@/components/Table'
;
import
{
h
}
from
'vue'
;
import
{
Switch
}
from
'ant-design-vue'
;
import
{
getAllRoleList
,
setRoleStatus
}
from
'@/api/system/role/role'
;
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
import
Icon
from
"@/components/Icon/Icon.vue"
;
import
{
setMenuStatus
}
from
"@/api/system/menu/menu"
;
type
CheckedType
=
boolean
|
string
|
number
;
export
const
columns
:
BasicColumn
[]
=
[
{
title
:
'菜单名称'
,
dataIndex
:
'menuName'
,
width
:
50
,
align
:
'left'
,
colProps
:
{
span
:
8
},
},
];
export
const
ModelFormSchema
:
FormSchema
[]
=
[
{
field
:
'roleName'
,
label
:
'角色名称'
,
component
:
'Input'
,
rules
:
[
{
required
:
true
,
message
:
'请输入角色名称'
,
},
],
componentProps
:
{
disabled
:
true
,
},
},
{
field
:
'menuName'
,
label
:
'菜单名称'
,
component
:
'Input'
,
rules
:
[
{
required
:
true
,
message
:
'请输入菜单名称'
,
},
],
componentProps
:
{
placeholder
:
'未选择菜单名称'
,
disabled
:
true
,
},
},
{
field
:
'dataScope'
,
label
:
'权限范围'
,
component
:
'Select'
,
rules
:
[
{
required
:
true
,
message
:
'请选择权限范围'
,
},
],
componentProps
:
{
options
:
[
{
value
:
'1'
,
label
:
'全部数据权限'
},
{
value
:
'2'
,
label
:
'自定数据权限'
},
{
value
:
'3'
,
label
:
'本部门数据权限'
},
{
value
:
'4'
,
label
:
'本部门及以下数据权限'
},
{
value
:
'5'
,
label
:
'仅本人数据权限'
}
],
},
},
{
label
:
'数据权限'
,
field
:
'menuIds'
,
slot
:
'menu'
,
ifShow
:
false
},
];
src/views/notifications/noticeManage/notiModal.vue
0 → 100644
View file @
1a4b9d69
<
template
>
<BasicModal
v-bind=
"$attrs"
width=
"45%"
height=
"500"
@
register=
"registerModal"
:title=
"getTitle"
@
ok=
"handleSubmit"
>
<div
class=
"modal-content"
>
<div
class=
"table-container"
>
<BasicTable
@
register=
"registerTable"
>
<template
#
bodyCell=
"
{ column, record }">
<template
v-if=
"column.key === 'action'"
>
<TableAction
:actions=
"[
{
label: '编辑',
onClick: handleEdit.bind(null, record),
},
]"
/>
</
template
>
</template>
</BasicTable>
</div>
<div
class=
"form-container"
>
<BasicForm
@
register=
"registerForm"
>
<
template
#
menu=
"{ model, field }"
>
<BasicTree
v-model:value=
"model[field]"
:treeData=
"treeDataList"
:fieldNames=
"
{ title: 'label', key: 'id' }"
checkable
toolbar
/>
</
template
>
</BasicForm>
</div>
</div>
</BasicModal>
</template>
<
script
setup
lang=
"ts"
>
import
{
BasicTable
,
useTable
,
TableAction
}
from
'@/components/Table'
;
import
{
useModalInner
}
from
'@/components/Modal'
;
import
BasicModal
from
'@/components/Modal/src/BasicModal.vue'
;
import
{
ref
,
unref
}
from
'vue'
;
import
{
Table
}
from
'ant-design-vue'
;
import
{
ModelFormSchema
,
columns
}
from
'@/views/notifications/noticeManage/notiModal.data'
;
import
{
addDataScopeApi
,
getRoleDeptTreeSelect
,
roleDetailApi
}
from
'@/api/system/role/role'
;
import
{
BasicForm
,
useForm
}
from
'@/components/Form'
;
import
{
getMenuListByPage
,
getMenuSelect
,
getRoleMenuSelectedMC
}
from
'@/api/system/menu/menu'
;
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
import
{
BasicTree
,
TreeItem
}
from
'@/components/Tree'
;
defineOptions
({
name
:
'RoleModal'
});
const
loadingRef
=
ref
(
false
);
// 列表
const
dataSource
=
ref
([]);
const
treeData
=
ref
();
const
roleId
=
ref
();
const
isPermiss
=
ref
(
true
);
const
getTitle
=
ref
(
'数据权限信息'
);
const
{
createMessage
}
=
useMessage
();
const
emit
=
defineEmits
([
'success'
,
'register'
]);
const
formData
=
ref
({});
const
treeDataList
=
ref
<
TreeItem
[]
>
([]);
const
[
registerTable
,
{
reload
,
getForm
}]
=
useTable
({
api
:
async
(
params
)
=>
{
const
param
=
{
businessId
:
roleId
.
value
,
};
const
response
=
await
getRoleMenuSelectedMC
(
param
);
//进行处理数据
const
transformedData
=
transformData
(
response
.
data
);
// 定义一个函数transformData来做你需要的数据转换
return
{
...
response
,
data
:
transformedData
};
},
columns
,
useSearchForm
:
false
,
showTableSetting
:
false
,
bordered
:
true
,
isTreeTable
:
true
,
pagination
:
false
,
showIndexColumn
:
false
,
actionColumn
:
{
width
:
50
,
title
:
'操作'
,
dataIndex
:
'action'
,
fixed
:
undefined
,
},
});
const
[
registerModal
,
{
closeModal
,
setModalProps
}]
=
useModalInner
(
async
(
data
)
=>
{
isPermiss
.
value
=
data
.
record
.
isPermiss
;
roleId
.
value
=
data
.
record
.
businessId
;
roleDetailApi
(
roleId
.
value
).
then
((
res
)
=>
{
formData
.
value
=
res
.
data
;
const
form
=
{
roleName
:
res
.
data
.
roleName
,
};
setFieldsValue
({
...
form
,
});
});
if
(
unref
(
treeDataList
).
length
===
0
)
{
const
treeRes
=
await
getMenuSelect
();
treeDataList
.
value
=
treeRes
.
data
as
any
as
TreeItem
[];
}
//控制
updateSchema
({
field
:
'dataScope'
,
componentProps
:
{
onChange
:
(
value
:
any
,
option
:
any
,
form
:
any
)
=>
{
//调用接口 返回的参数赋值给dictValue
if
(
value
===
'2'
)
{
updateSchema
({
field
:
'menuIds'
,
ifShow
:
true
,
rules
:
[
{
required
:
true
,
message
:
'请选择数据权限'
,
},
],
});
}
else
{
updateSchema
({
field
:
'menuIds'
,
ifShow
:
false
,
rules
:
[
{
required
:
false
,
},
],
});
}
},
},
});
reload
();
});
//初始化表单
const
[
registerForm
,
{
setFieldsValue
,
updateSchema
,
resetFields
,
validate
,
getFieldsValue
}]
=
useForm
({
labelWidth
:
100
,
schemas
:
ModelFormSchema
,
showActionButtonGroup
:
false
,
});
/**编辑按钮*/
function
handleEdit
(
record
:
Recordable
)
{
formData
.
value
.
menuId
=
record
.
businessId
;
formData
.
value
.
menuName
=
record
.
menuName
;
const
form
=
{
menuName
:
record
.
menuName
,
};
setFieldsValue
({
...
form
,
});
const
params
=
{
menuId
:
formData
.
value
.
menuId
,
roleId
:
formData
.
value
.
businessId
,
};
getRoleDeptTreeSelect
(
params
).
then
((
res
)
=>
{
formData
.
value
.
deptCheckStrictly
=
res
.
data
.
deptCheckStrictly
;
});
}
/**改变列表结构 列表->树*/
function
transformData
(
data
)
{
treeData
.
value
=
handleTree
(
data
,
'businessId'
,
undefined
,
undefined
,
undefined
);
return
treeData
.
value
;
}
/**结构转换方法*/
function
handleTree
(
data
,
id
,
parentId
,
children
,
rootId
)
{
id
=
id
||
'id'
;
parentId
=
parentId
||
'parentId'
;
children
=
children
||
'children'
;
rootId
=
rootId
||
Math
.
min
.
apply
(
Math
,
data
.
map
((
item
)
=>
{
return
item
[
parentId
];
}),
)
||
0
;
// 对源数据深度克隆
const
cloneData
=
JSON
.
parse
(
JSON
.
stringify
(
data
));
// 循环所有项
const
treeData
=
cloneData
.
filter
((
father
)
=>
{
const
branchArr
=
cloneData
.
filter
((
child
)
=>
{
// 返回每一项的子级数组
return
father
[
id
]
===
child
[
parentId
];
});
branchArr
.
length
>
0
?
(
father
.
children
=
branchArr
)
:
''
;
// 返回第一层
return
father
[
parentId
]
===
rootId
;
});
return
treeData
!==
''
?
treeData
:
data
;
}
/**确认按钮*/
async
function
handleSubmit
()
{
try
{
const
values
=
await
validate
();
console
.
log
(
'values:'
,
values
);
setModalProps
({
confirmLoading
:
true
});
formData
.
value
.
code
=
values
.
dataScope
;
formData
.
value
.
menuIds
=
values
.
menuIds
;
formData
.
value
.
deptIdList
=
''
;
formData
.
value
.
roleId
=
''
;
addDataScopeApi
(
formData
.
value
).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
createMessage
.
success
(
'新增成功'
);
closeModal
();
emit
(
'success'
,
{
isUpdate
:
unref
(
isPermiss
),
values
:
{
...
values
}
});
}
});
reload
();
}
finally
{
setModalProps
({
confirmLoading
:
false
});
}
}
</
script
>
<
style
scoped
lang=
"less"
>
.modal-content {
display: flex;
height: 100%; // 可以根据需要调整高度
.table-container,
.form-container {
flex: 1; // 每个容器占据一半的空间
overflow: auto; // 如果内容超出容器高度,则显示滚动条
}
.table-container {
border-right: 1px solid #e9ecef; // 可选:在表格和表单之间添加分隔线
}
}
</
style
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment