Commit 23f00fec by ningjihai

角色

parent 9474c36f
...@@ -184,17 +184,12 @@ const groupList = ref([ ...@@ -184,17 +184,12 @@ const groupList = ref([
} }
]) ])
const onReset = () => { function onReset(formQuery) {
queryParams.value = { console.log('onReset')
page: 1, formQuery.resetFields()
rows: 10,
groupname: '',
remark: '',
}
handleSearch() handleSearch()
} }
const editVisible = ref(false) const editVisible = ref(false)
const editData = ref(null) const editData = ref(null)
...@@ -211,7 +206,7 @@ const getList = async () => { ...@@ -211,7 +206,7 @@ const getList = async () => {
} }
const handleSearch = () => { const handleSearch = () => {
currentPage.value = 1
getList() getList()
} }
const handleAdd = () => { const handleAdd = () => {
......
<script setup lang="ts" name="QueryForm">
import { computed,ref,watch } from 'vue'
import type { FormInstance } from 'element-plus'
import PageWrapperSearch from '@/components/search/PageWrapperSearch.vue'
import {
Plus
} from '@element-plus/icons-vue'
import { color } from 'echarts'
// import { useDict } from '@/utils/dict'
// import { listDept } from '@/api/system/dept'// 部门
// const { approve_status, invoice_status} = useDict('approve_status', 'invoice_status')
const emit = defineEmits(['update:modelValue', 'query', 'reset','handleAdd'])
const invoice_status_filter = ref([])
const employeesList = ref([])
const props = defineProps<{
modelValue: any
}>()
const queryForm = computed({
get() {
return props.modelValue
},
set(val: any) {
console.log('query computed', val)
emit('update:modelValue', val)
}
})
// 搜索
function onSearch() {
emit('query')
}
// 重置
function onReset(formRef: FormInstance) {
queryForm.value.rolename = ''
queryForm.value.remark = ''
emit('reset', formRef)
}
function handleAdd() {
emit('handleAdd')
}
</script>
<template>
<!-- el-form -->
<page-wrapper-search
:model="queryForm"
:extraButtons="[
{
text: '新增',
icon: Plus,
color: 'rgba(0, 189, 207, 1)',
type: 'success',
class: 'btn-fff',
onClick: handleAdd
}
]"
@search="onSearch"
@reset="onReset">
<el-form-item label="角色名:">
<el-input v-model="queryForm.rolename" clearable placeholder="请输入角色名"></el-input>
</el-form-item>
<el-form-item label="备注:">
<el-input v-model="queryForm.remark" clearable placeholder="请输入备注"></el-input>
</el-form-item>
</page-wrapper-search>
<!-- <page-wrapper-search
:model="queryForm"
:extraButtons="[
{
text: '导出',
icon: Edit,
type: 'success',
onClick: handleExport
},
{
text: '打印',
type: 'warning',
onClick: handlePrint
}
]"
@search="onSearch"
@reset="onReset">
<el-form-item label="项目名称" prop="proName">
<el-input
v-model="queryForm.proName"
placeholder="请输入项目名称"
clearable
/>
</el-form-item>
<el-form-item label="备注" prop="note">
<el-input
v-model="queryForm.note"
placeholder="请输入备注"
clearable
/>
</el-form-item>
</page-wrapper-search> -->
</template>
<style scoped lang="scss">
:deep(.btn-fff){
span{
color: #fff;
}
}
</style>
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
title="编辑角色" title="编辑角色"
:model-value="visible" :model-value="visible"
@update:model-value="$emit('update:visible', $event)" @update:model-value="$emit('update:visible', $event)"
width="800px"
:close-on-click-modal="false" :close-on-click-modal="false"
append-to-body append-to-body
destroy-on-close destroy-on-close
:align-center="true" :align-center="true"
:fullscreen="false" :fullscreen="false"
@close="handleClose" @close="handleClose"
class="user-edit-dialog" class="custom-dialog"
width="900px"
> >
<div class="dialog-content" style="padding: 20px; padding-bottom: 80px;height: 700px;overflow-y: auto;"> <div class="dialog-content" style="padding: 20px; padding-bottom: 80px;height: 700px;overflow-y: auto;">
<el-form <el-form
...@@ -46,12 +46,8 @@ ...@@ -46,12 +46,8 @@
/> />
</div> </div>
<template #footer> <template #footer>
<div class="dialog-footer"> <el-button type="danger" @click="handleClose">取 消</el-button>
<div class="footer-buttons"> <el-button type="primary" color="rgba(33, 103, 217, 1)" @click="handleSubmit">确 定</el-button>
<el-button @click="handleClose">取 消</el-button>
<el-button type="primary" @click="handleSubmit">确 定</el-button>
</div>
</div>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
......
<template> <script setup lang="ts" name="projectManageIndex">
<div class="user-config"> import { ref } from 'vue'
<!-- 标题 --> import list from './list.vue'
<div class="title">
<el-icon><User /></el-icon>
角色
</div>
<!-- 搜索和操作区域 -->
<div class="search-area">
<el-form :inline="true" :model="searchForm" class="search-form">
<div class="left-area">
<el-form-item label="角色名:">
<el-input v-model="searchForm.rolename" clearable placeholder="请输入角色名"></el-input>
</el-form-item>
<el-form-item label="备注:">
<el-input v-model="searchForm.remark" clearable placeholder="请输入备注"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleSearch">搜索</el-button>
</el-form-item>
</div>
<div class="right-area">
<el-button type="primary" icon="Plus" @click="handleAdd">新增角色</el-button>
</div>
</el-form>
</div>
<!-- 列表 -->
<div class="user-list">
<div class="user-grid">
<div v-for="(user, index) in roleList" :key="index" class="user-card">
<div class="user-info">
<div class="avatar">
<el-avatar :size="50" icon="User"></el-avatar>
</div>
<div class="info">
<div class="roleName">角色名: {{ user.rolename }}</div>
<div class="remark">备注: {{ user.remark }}</div>
</div>
<!-- 遮罩层和操作按钮 -->
<div class="hover-mask">
<div class="operation-buttons">
<div class="operation-btn" @click="handleDelete(user)">
<el-icon><Delete /></el-icon>
<span>删除</span>
</div>
<div class="operation-btn" @click="handleEdit(user)">
<el-icon><MessageBox /></el-icon>
<span>权限设置</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 分页 -->
<div class="pagination">
<div class="pagination-info">
共有记录 {{ total }} 条,每页显示 {{ pageSize }} 条,共 {{ Math.max(1, Math.ceil(total / pageSize)) }}
</div>
<el-pagination
background
layout="prev, pager, next, jumper"
:total="total"
:current-page="currentPage"
:page-size="pageSize"
@current-change="handlePageChange">
</el-pagination>
</div>
<!-- 编辑弹窗 -->
<role-edit
v-model:visible="editVisible"
:form-data="editData"
@success="handleEditSuccess"
/>
</div>
</template>
<script setup>
import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
import { ElMessageBox } from 'element-plus'
import { User, Delete, MessageBox } from '@element-plus/icons-vue'
import RoleEdit from './edit.vue'
import { query as queryRole, del } from '@/api/safetyManagement/roleConfig.js'
// 定义组件名称
defineOptions({
name: 'RoleConfig'
})
// 响应式数据
const searchForm = reactive({
roleName: '',
remark: ''
})
const roleList = ref([
{
realname: 'admin',
roleName: 'admin',
remark: ''
}
])
const total = ref(1)
const currentPage = ref(1)
const pageSize = ref(8)
const editVisible = ref(false)
const editData = ref(null)
const instance = getCurrentInstance()
// 获取角色列表
const getList = async () => {
const params = {
...searchForm,
page: currentPage.value,
rows: pageSize.value
}
try {
// 实际项目中这里应该调用接口获取数据
const res = await queryRole(params)
console.log('角色列表接口返回数据:', res)
roleList.value = res.data.list || []
total.value = res.data.total
} catch (error) {
const modal = instance?.appContext.config.globalProperties.$modal
modal && modal.msgError ? modal.msgError('查询异常') : console.error('查询异常', error)
}
}
// 处理搜索
const handleSearch = () => {
currentPage.value = 1
getList()
}
// 添加角色 const widget = {
const handleAdd = () => { list: list
editData.value = null
editVisible.value = true
} }
// 分页变化 const page = ref('list')
const handlePageChange = (page) => { const params = ref({})
currentPage.value = page
getList()
}
// 删除角色
const handleDelete = (row) => {
ElMessageBox.confirm('确认删除该角色吗?', '提示', {
type: 'warning'
}).then(() => {
// 调用删除接口
console.log('删除角色', row)
// 这里应该调用删除接口
del({ id: row.id }).then(res => {
if (res.code === 'POP_00014') {
console.log('角色删除成功', res);
getList();
} else {
console.error('角色删除失败:', res.msg);
}
}).catch(error => {
console.error('角色删除异常:', error);
});
}).catch(() => {}) function onChangePage(val: string, param?: any) {
page.value = val
params.value = param ?? {}
} }
// 编辑角色
const handleEdit = (row) => {
editData.value = { ...row }
editVisible.value = true
}
// 编辑成功回调
const handleEditSuccess = () => {
editVisible.value = false
// 刷新列表数据
getList()
}
// 页面挂载时获取数据
onMounted(() => {
getList()
})
</script> </script>
<style lang="scss" scoped> <template>
.user-config { <component :is="widget[page]" v-bind="params" @page="onChangePage" />
padding: 20px; </template>
.title {
font-size: 18px;
color: #333;
margin-bottom: 20px;
display: flex;
align-items: center;
i {
color: #409EFF;
margin-right: 8px;
font-size: 20px;
}
}
.search-area {
background: #fff;
padding: 20px;
border-radius: 4px;
margin-bottom: 20px;
.search-form {
display: flex;
justify-content: space-between;
align-items: center;
.left-area {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.right-area {
margin-left: 20px;
}
}
.el-form-item {
margin-bottom: 0;
}
}
.user-list {
margin-bottom: 20px;
.user-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 20px;
}
.user-card {
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
overflow: hidden;
border-left: 4px solid #3498db;
transition: all 0.3s ease;
&:hover {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
transform: translateY(-2px);
}
}
.user-info {
display: flex;
align-items: center;
padding: 20px;
position: relative;
cursor: pointer;
height: 100%;
.avatar {
margin-right: 15px;
}
.info {
flex: 1;
.name {
font-size: 16px;
font-weight: bold;
margin-bottom: 8px;
color: #333;
}
.roleName, .remark {
color: #666;
font-size: 14px;
margin-bottom: 5px;
}
}
.hover-mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
display: none;
justify-content: center;
align-items: center;
.operation-buttons {
display: flex;
gap: 30px;
.operation-btn {
display: flex;
flex-direction: column;
align-items: center;
color: white;
cursor: pointer;
.el-icon {
margin-bottom: 8px;
}
&:hover {
color: #409EFF;
transform: scale(1.1);
}
}
}
}
&:hover {
.hover-mask {
display: flex;
}
}
}
.operation-time {
color: #666;
i {
margin-right: 5px;
}
}
}
.pagination {
background: #fff;
padding: 15px 20px;
border-radius: 4px;
display: flex;
justify-content: space-between;
align-items: center;
.pagination-info {
color: #666;
font-size: 14px;
}
}
}
</style>
<template>
<div class="app-container scroller">
<PageTitle>
<template #title>
角色
</template>
</PageTitle>
<div class="app-container__body">
<query-form
ref="QueryFormRef"
v-model="queryParams"
@query="handleSearch"
@reset="onReset"
@handleAdd="handleAdd"
/>
<div style="flex: 1;">
<el-table
:data="roleList"
stripe
height="100%"
style="width: 100%"
>
<el-table-column
type="index"
label="序号"
width="80"
align="center"
fixed
/>
<!-- 发现任务名称列(左侧浮动) -->
<el-table-column
prop="rolename"
label="角色名"
min-width="180"
>
</el-table-column>
<el-table-column
prop="remark"
label="备注"
min-width="180"
>
</el-table-column>
<el-table-column
prop="createtime"
label="创建时间"
min-width="180"
>
</el-table-column>
<el-table-column
label="操作"
width="320"
fixed="right"
align="center"
>
<template #default="{ row }">
<div class="operation-buttons">
<!-- 编辑按钮 -->
<el-button
link
type="primary"
size="small"
icon="edit"
@click="handleEdit(row)"
class="op-btn"
>
编辑
</el-button>
<el-button
link
type="primary"
size="small"
icon="delete"
@click="handleDelete(row)"
class="op-btn"
>
删除
</el-button>
</div>
</template>
</el-table-column>
</el-table>
</div>
<pagination
v-show="total > 0"
:total="total"
v-model:page="queryParams.page"
v-model:limit="queryParams.rows"
@pagination="getList"
/>
</div>
<!-- 列表 -->
<!-- <div class="user-list">
<div class="user-grid">
<div v-for="(user, index) in roleList" :key="index" class="user-card">
<div class="user-info">
<div class="avatar">
<el-avatar :size="50" icon="User"></el-avatar>
</div>
<div class="info">
<div class="roleName">角色名: {{ user.rolename }}</div>
<div class="remark">备注: {{ user.remark }}</div>
</div>
<div class="hover-mask">
<div class="operation-buttons">
<div class="operation-btn" @click="handleDelete(user)">
<el-icon><Delete /></el-icon>
<span>删除</span>
</div>
<div class="operation-btn" @click="handleEdit(user)">
<el-icon><MessageBox /></el-icon>
<span>权限设置</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div> -->
<!-- 分页 -->
<!-- 编辑弹窗 -->
<role-edit
v-model:visible="editVisible"
:form-data="editData"
@success="handleEditSuccess"
/>
</div>
</template>
<script setup>
import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
import QueryForm from './QueryForm.vue'
import { ElMessageBox } from 'element-plus'
import { User, Delete, MessageBox } from '@element-plus/icons-vue'
import RoleEdit from './edit.vue'
import { query as queryRole, del } from '@/api/safetyManagement/roleConfig.js'
// 定义组件名称
defineOptions({
name: 'RoleConfig'
})
const data = reactive({
queryParams: {
page: 1,
rows: 10,
rolename: '',
remark: '',
}
})
const total = ref(0)
// 表格数据
const { queryParams } = toRefs(data)
const roleList = ref([
])
const editVisible = ref(false)
const editData = ref(null)
const instance = getCurrentInstance()
// 获取角色列表
const getList = async () => {
try {
// 实际项目中这里应该调用接口获取数据
const res = await queryRole(queryParams.value)
console.log('角色列表接口返回数据:', res)
roleList.value = res.data.list || []
total.value = res.data.total
} catch (error) {
const modal = instance?.appContext.config.globalProperties.$modal
modal && modal.msgError ? modal.msgError('查询异常') : console.error('查询异常', error)
}
}
function onReset(formQuery) {
console.log('onReset')
formQuery.resetFields()
handleSearch()
}
// 处理搜索
const handleSearch = () => {
getList()
}
// 添加角色
const handleAdd = () => {
editData.value = null
editVisible.value = true
}
// 分页变化
const handlePageChange = (page) => {
currentPage.value = page
getList()
}
// 删除角色
const handleDelete = (row) => {
ElMessageBox.confirm('确认删除该角色吗?', '提示', {
type: 'warning'
}).then(() => {
// 调用删除接口
console.log('删除角色', row)
// 这里应该调用删除接口
del({ id: row.id }).then(res => {
if (res.code === 'POP_00014') {
console.log('角色删除成功', res);
getList();
} else {
console.error('角色删除失败:', res.msg);
}
}).catch(error => {
console.error('角色删除异常:', error);
});
}).catch(() => {})
}
// 编辑角色
const handleEdit = (row) => {
editData.value = { ...row }
editVisible.value = true
}
// 编辑成功回调
const handleEditSuccess = () => {
editVisible.value = false
// 刷新列表数据
getList()
}
// 页面挂载时获取数据
onMounted(() => {
getList()
})
</script>
<style lang="scss" scoped>
.user-config {
padding: 20px;
.title {
font-size: 18px;
color: #333;
margin-bottom: 20px;
display: flex;
align-items: center;
i {
color: #409EFF;
margin-right: 8px;
font-size: 20px;
}
}
.search-area {
background: #fff;
padding: 20px;
border-radius: 4px;
margin-bottom: 20px;
.search-form {
display: flex;
justify-content: space-between;
align-items: center;
.left-area {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.right-area {
margin-left: 20px;
}
}
.el-form-item {
margin-bottom: 0;
}
}
.user-list {
margin-bottom: 20px;
.user-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 20px;
}
.user-card {
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
overflow: hidden;
border-left: 4px solid #3498db;
transition: all 0.3s ease;
&:hover {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
transform: translateY(-2px);
}
}
.user-info {
display: flex;
align-items: center;
padding: 20px;
position: relative;
cursor: pointer;
height: 100%;
.avatar {
margin-right: 15px;
}
.info {
flex: 1;
.name {
font-size: 16px;
font-weight: bold;
margin-bottom: 8px;
color: #333;
}
.roleName, .remark {
color: #666;
font-size: 14px;
margin-bottom: 5px;
}
}
.hover-mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
display: none;
justify-content: center;
align-items: center;
.operation-buttons {
display: flex;
gap: 30px;
.operation-btn {
display: flex;
flex-direction: column;
align-items: center;
color: white;
cursor: pointer;
.el-icon {
margin-bottom: 8px;
}
&:hover {
color: #409EFF;
transform: scale(1.1);
}
}
}
}
&:hover {
.hover-mask {
display: flex;
}
}
}
.operation-time {
color: #666;
i {
margin-right: 5px;
}
}
}
.pagination {
background: #fff;
padding: 15px 20px;
border-radius: 4px;
display: flex;
justify-content: space-between;
align-items: center;
.pagination-info {
color: #666;
font-size: 14px;
}
}
}
</style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论