Commit 1b3cdc13 by ningjihai

用户

parent 4efb6a0b
<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.realname = ''
queryForm.value.username = ''
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.realname" clearable placeholder="请输入姓名"></el-input>
</el-form-item>
<el-form-item label="用户名:">
<el-input v-model="queryForm.username" 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 @@
title="编辑用户"
:model-value="visible"
@update:model-value="$emit('update:visible', $event)"
width="600px"
width="900px"
:close-on-click-modal="false"
append-to-body
destroy-on-close
:align-center="true"
:fullscreen="false"
@close="handleClose"
class="user-edit-dialog"
class="custom-dialog"
>
<div class="dialog-content" style="padding: 20px; padding-bottom: 80px;height: 700px;overflow-y: auto;">
<el-form
......@@ -137,12 +137,12 @@
</div>
</div>
<template #footer>
<div class="dialog-footer">
<div class="footer-buttons">
<el-button @click="handleClose">取 消</el-button>
<el-button type="primary" @click="handleSubmit">确 定</el-button>
</div>
</div>
<!-- <div class="dialog-footer">
<div class="footer-buttons"> -->
<el-button type="danger" @click="handleClose">取 消</el-button>
<el-button type="primary" color="rgba(33, 103, 217, 1)" @click="handleSubmit">确 定</el-button>
<!-- </div>
</div> -->
</template>
</el-dialog>
</template>
......
<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="userList"
stripe
height="100%"
style="width: 100%"
>
<el-table-column
type="index"
label="序号"
width="80"
align="center"
fixed
/>
<!-- 发现任务名称列(左侧浮动) -->
<el-table-column
prop="realname"
label="姓名"
min-width="180"
>
<template #default="{ row }">
<span>{{ row.realname }}</span>
</template>
</el-table-column>
<el-table-column
prop="username"
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.pageno"
v-model:limit="queryParams.pagesize"
@pagination="getList"
/>
</div>
<!-- 编辑弹窗 -->
<user-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, Edit } from '@element-plus/icons-vue'
import UserEdit from './edit.vue'
import { query, remove } from '@/api/safetyManagement/userConfig.js'
// 定义组件名称
defineOptions({
name: 'UserConfig'
})
const data = reactive({
queryParams: {
pageno: 1,
pagesize: 10,
name: '',
username: '',
remark: ''
}
})
// 表格数据
const { queryParams } = toRefs(data)
// 响应式数据
const searchForm = reactive({
name: '',
username: '',
remark: ''
})
const userList = ref([])
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,
// pageno: currentPage.value,
// pagesize: pageSize.value
// }
try {
const res = await query(queryParams.value)
if (res.code === 'POP_00014') {
userList.value = res.data.list || []
total.value = res.data.total || 0
} else {
const modal = instance?.appContext.config.globalProperties.$modal
modal && modal.msgError ? modal.msgError(res.msg || '查询失败') : alert(res.msg || '查询失败')
}
} catch (e) {
const modal = instance?.appContext.config.globalProperties.$modal
modal && modal.msgError ? modal.msgError('查询异常') : alert('查询异常')
}
}
// 处理搜索
const handleSearch = () => {
currentPage.value = 1
getList()
}
function onReset(formQuery) {
queryParams.value.pageno = 1
queryParams.value.pagesize = 10
formQuery.resetFields()
handleSearch()
}
// 添加用户
const handleAdd = () => {
editData.value = null
editVisible.value = true
}
// 分页变化
const handlePageChange = (page) => {
currentPage.value = page
getList()
}
// 删除用户
const handleDelete = async (row) => {
ElMessageBox.confirm('确认删除该用户吗?', '提示', {
type: 'warning'
}).then( async () => {
// 调用删除接口
console.log('删除用户', row)
await remove({id: row.id})
getList()
}).catch(() => {})
}
// 编辑用户
const handleEdit = async (row) => {
editData.value = { id: row.id }
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 4px rgba(0, 0, 0, 0.1);
overflow: hidden;
position: relative;
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);
}
&.admin-card {
border-left: 4px solid #f39c12;
}
.card-header {
padding: 15px 20px;
display: flex;
align-items: center;
justify-content: space-between;
background: linear-gradient(to right, #3498db, #73b4f8);
color: white;
&.admin-header {
background: linear-gradient(to right, #f39c12, #f8c471);
}
.header-info {
flex: 1;
.name {
font-size: 18px;
font-weight: bold;
margin-bottom: 5px;
}
.username {
font-size: 14px;
opacity: 0.9;
}
}
.user-avatar {
margin-left: 15px;
}
}
.card-content {
padding: 15px 20px;
.info-row {
display: flex;
margin-bottom: 10px;
&:last-child {
margin-bottom: 0;
}
.info-label {
color: #666;
font-size: 14px;
width: 80px;
flex-shrink: 0;
}
.info-value {
color: #333;
font-size: 14px;
flex: 1;
}
}
}
.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;
transition: all 0.3s;
.operation-buttons {
display: flex;
gap: 30px;
.operation-btn {
display: flex;
flex-direction: column;
align-items: center;
color: white;
cursor: pointer;
.el-icon {
// font-size: 24px;
margin-bottom: 8px;
}
// span {
// font-size: 14px;
// }
&:hover {
color: #409EFF;
transform: scale(1.1);
}
}
}
}
&:hover {
.hover-mask {
display: flex;
}
}
}
}
.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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论