接口
This commit is contained in:
@@ -33,8 +33,8 @@ export const loginOut = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户权限信息
|
// 获取用户权限信息
|
||||||
export const getInfo = () => {
|
export const getInfo = (data) => {
|
||||||
return request.get({ url: '/system/auth/get-permission-info' })
|
return request.get({ url: '/system/auth/get-permission-info', data })
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取登录验证码
|
//获取登录验证码
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const getSimpleDeptList = async (): Promise<DeptVO[]> => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 查询部门列表
|
// 查询部门列表
|
||||||
export const getDeptPage = async (params: PageParam) => {
|
export const getDeptPage = async (params) => {
|
||||||
return await request.get({ url: '/system/dept/list', params })
|
return await request.get({ url: '/system/dept/list', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export const getRolePage = async (params: PageParam) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 查询角色(精简)列表
|
// 查询角色(精简)列表
|
||||||
export const getSimpleRoleList = async (): Promise<RoleVO[]> => {
|
export const getSimpleRoleList = async () => {
|
||||||
return await request.get({ url: '/system/role/list-all-simple' })
|
return await request.get({ url: '/system/role/list-all-simple' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-select v-model="roleId" filterable @change="handleChangeRole" style="width: 150px">
|
<el-select v-model="roleId" filterable @change="handleChangeRole" style="width: 150px">
|
||||||
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
|
<el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="RoleSelect">
|
<script setup name="RoleSelect">
|
||||||
const options = ref([
|
import { useUserStore } from '@/store/modules/user'
|
||||||
{ value: 1, label: '超级管理员' },
|
import { getInfo } from '@/api/login/index'
|
||||||
{ value: 2, label: '销售' }
|
|
||||||
])
|
const userStore = useUserStore()
|
||||||
|
|
||||||
|
const options = computed(() => {
|
||||||
|
return userStore.getRoles
|
||||||
|
})
|
||||||
const roleId = ref(1)
|
const roleId = ref(1)
|
||||||
|
|
||||||
function handleChangeRole() {
|
function handleChangeRole(val) {
|
||||||
console.log('修改角色')
|
getInfo({ params: { roleId: val } })
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -436,5 +436,6 @@ export default {
|
|||||||
btn_zoom_in: '放大',
|
btn_zoom_in: '放大',
|
||||||
btn_zoom_out: '缩小',
|
btn_zoom_out: '缩小',
|
||||||
preview: '预览'
|
preview: '预览'
|
||||||
}
|
},
|
||||||
|
'OAuth 2.0': 'OAuth 2.0' // 避免菜单名是 OAuth 2.0 时,一直 warn 报错
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,15 @@ const remainingRouter: AppRouteRecordRaw[] = [
|
|||||||
noTagsView: true
|
noTagsView: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: Layout,
|
||||||
|
redirect: '/Home/index',
|
||||||
|
meta: {
|
||||||
|
title: '首页',
|
||||||
|
hidden: true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/user',
|
path: '/user',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
|
|||||||
@@ -43,8 +43,8 @@
|
|||||||
<el-col :span="12" :offset="0">
|
<el-col :span="12" :offset="0">
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-radio-group v-model="formData.status">
|
<el-radio-group v-model="formData.status">
|
||||||
<el-radio :label="1"> 启用 </el-radio>
|
<el-radio :label="0"> 启用 </el-radio>
|
||||||
<el-radio :label="0"> 禁用 </el-radio>
|
<el-radio :label="1"> 禁用 </el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
<el-table-column prop="leader" label="负责人" width="120" />
|
<el-table-column prop="leader" label="负责人" width="120" />
|
||||||
<el-table-column prop="sort" label="排序" width="200" />
|
<el-table-column prop="sort" label="排序" width="200" />
|
||||||
<el-table-column prop="status" label="状态" width="100" />
|
<el-table-column prop="status" label="状态" width="100" />
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180" />
|
<el-table-column label="创建时间" prop="createTime" width="180" :formatter="dateFormatter" />
|
||||||
<el-table-column label="操作" align="center" class-name="fixed-width" width="160">
|
<el-table-column label="操作" class-name="fixed-width" width="160">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button link type="primary" @click="openForm('update', scope.row.id)"> 修改 </el-button>
|
<el-button link type="primary" @click="openForm('update', scope.row.id)"> 修改 </el-button>
|
||||||
<el-button link type="danger" @click="handleDelete(scope.row.id)"> 删除 </el-button>
|
<el-button link type="danger" @click="handleDelete(scope.row.id)"> 删除 </el-button>
|
||||||
@@ -36,18 +36,16 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts" name="SystemDept">
|
<script setup lang="ts" name="SystemDept">
|
||||||
import { handleTree } from '@/utils/tree'
|
import { handleTree } from '@/utils/tree'
|
||||||
// import * as DeptApi from '@/api/system/dept'
|
import * as DeptApi from '@/api/system/dept'
|
||||||
import DeptForm from './DeptForm.vue'
|
import DeptForm from './DeptForm.vue'
|
||||||
// import * as UserApi from '@/api/system/user'
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
|
|
||||||
const loading = ref(true) // 列表的加载中
|
const loading = ref(true) // 列表的加载中
|
||||||
const list = ref() // 列表的数据
|
const list = ref() // 列表的数据
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
name: undefined,
|
name: undefined
|
||||||
pageNo: 1,
|
|
||||||
pageSize: 20
|
|
||||||
})
|
})
|
||||||
const queryFormRef = ref() // 搜索的表单
|
const queryFormRef = ref() // 搜索的表单
|
||||||
|
|
||||||
@@ -55,11 +53,7 @@ const queryFormRef = ref() // 搜索的表单
|
|||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
// const data = await DeptApi.getDeptPage(queryParams)
|
const data = await DeptApi.getDeptPage(queryParams)
|
||||||
const data = [
|
|
||||||
{ name: '职能部', id: 10001, leader: '张三', status: 1 },
|
|
||||||
{ name: '财务部', id: 10002, leader: '李四', parentId: 10001, status: 1 }
|
|
||||||
]
|
|
||||||
list.value = handleTree(data)
|
list.value = handleTree(data)
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
@@ -68,13 +62,11 @@ const getList = async () => {
|
|||||||
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
const handleQuery = () => {
|
const handleQuery = () => {
|
||||||
queryParams.pageNo = 1
|
|
||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
const resetQuery = () => {
|
const resetQuery = () => {
|
||||||
queryParams.pageNo = 1
|
|
||||||
queryFormRef.value.resetFields()
|
queryFormRef.value.resetFields()
|
||||||
handleQuery()
|
handleQuery()
|
||||||
}
|
}
|
||||||
@@ -88,11 +80,10 @@ const openForm = (type: string, id?: number) => {
|
|||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
console.log(id)
|
|
||||||
// 删除的二次确认
|
// 删除的二次确认
|
||||||
await message.delConfirm()
|
await message.delConfirm()
|
||||||
// 发起删除
|
// 发起删除
|
||||||
// await DeptApi.deleteDept(id)
|
await DeptApi.deleteDept(id)
|
||||||
message.success(t('common.delSuccess'))
|
message.success(t('common.delSuccess'))
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await getList()
|
await getList()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<script lang="ts" name="SystemUserDeptTree" setup>
|
<script lang="ts" name="SystemUserDeptTree" setup>
|
||||||
import { ElTree } from 'element-plus'
|
import { ElTree } from 'element-plus'
|
||||||
// import * as DeptApi from '@/api/system/dept'
|
import * as DeptApi from '@/api/system/dept'
|
||||||
import { defaultProps, handleTree } from '@/utils/tree'
|
import { defaultProps, handleTree } from '@/utils/tree'
|
||||||
|
|
||||||
const deptName = ref('')
|
const deptName = ref('')
|
||||||
@@ -32,59 +32,7 @@ const treeRef = ref<InstanceType<typeof ElTree>>()
|
|||||||
|
|
||||||
/** 获得部门树 */
|
/** 获得部门树 */
|
||||||
const getTree = async () => {
|
const getTree = async () => {
|
||||||
// const res = await DeptApi.getSimpleDeptList()
|
const res = await DeptApi.getSimpleDeptList()
|
||||||
const res = [
|
|
||||||
{
|
|
||||||
id: 100,
|
|
||||||
name: '芋道源码',
|
|
||||||
parentId: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 101,
|
|
||||||
name: '深圳总公司',
|
|
||||||
parentId: 100
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 103,
|
|
||||||
name: '研发部门',
|
|
||||||
parentId: 101
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 108,
|
|
||||||
name: '市场部门',
|
|
||||||
parentId: 102
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 102,
|
|
||||||
name: '长沙分公司',
|
|
||||||
parentId: 100
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 104,
|
|
||||||
name: '市场部门',
|
|
||||||
parentId: 101
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 109,
|
|
||||||
name: '财务部门',
|
|
||||||
parentId: 102
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 105,
|
|
||||||
name: '测试部门',
|
|
||||||
parentId: 101
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 106,
|
|
||||||
name: '财务部门',
|
|
||||||
parentId: 101
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 107,
|
|
||||||
name: '运维部门',
|
|
||||||
parentId: 101
|
|
||||||
}
|
|
||||||
]
|
|
||||||
deptList.value = []
|
deptList.value = []
|
||||||
deptList.value.push(...handleTree(res))
|
deptList.value.push(...handleTree(res))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,10 +93,10 @@
|
|||||||
</template>
|
</template>
|
||||||
<script lang="ts" name="SystemUserForm" setup>
|
<script lang="ts" name="SystemUserForm" setup>
|
||||||
import { CommonStatusEnum } from '@/utils/constants'
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
import { defaultProps } from '@/utils/tree'
|
import { defaultProps, handleTree } from '@/utils/tree'
|
||||||
// import * as PostApi from '@/api/system/post'
|
import * as RoleApi from '@/api/system/role'
|
||||||
// import * as DeptApi from '@/api/system/dept'
|
import * as DeptApi from '@/api/system/dept'
|
||||||
// import * as UserApi from '@/api/system/user'
|
import * as UserApi from '@/api/system/user'
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
@@ -114,7 +114,6 @@ const formData = ref({
|
|||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
sex: 1,
|
sex: 1,
|
||||||
postIds: [],
|
|
||||||
remark: '',
|
remark: '',
|
||||||
status: CommonStatusEnum.ENABLE,
|
status: CommonStatusEnum.ENABLE,
|
||||||
roleIds: []
|
roleIds: []
|
||||||
@@ -140,7 +139,6 @@ const formRules = {
|
|||||||
}
|
}
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
const deptList = ref<Tree[]>([]) // 树形结构
|
const deptList = ref<Tree[]>([]) // 树形结构
|
||||||
const postList = ref([]) // 岗位列表
|
|
||||||
const roleOptions = ref([])
|
const roleOptions = ref([])
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
@@ -153,31 +151,15 @@ const open = async (type: string, id?: number) => {
|
|||||||
if (id) {
|
if (id) {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
// formData.value = await UserApi.getUser(id)
|
formData.value = await UserApi.getUser(id)
|
||||||
formData.value = {
|
|
||||||
nickname: '',
|
|
||||||
deptId: '',
|
|
||||||
mobile: '',
|
|
||||||
email: '',
|
|
||||||
id: undefined,
|
|
||||||
username: '',
|
|
||||||
password: '',
|
|
||||||
sex: 1,
|
|
||||||
postIds: [],
|
|
||||||
remark: '',
|
|
||||||
status: CommonStatusEnum.ENABLE,
|
|
||||||
roleIds: []
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 加载部门树
|
// 加载部门树
|
||||||
// deptList.value = handleTree(await DeptApi.getSimpleDeptList())
|
deptList.value = handleTree(await DeptApi.getSimpleDeptList())
|
||||||
deptList.value = []
|
|
||||||
// 加载岗位列表
|
// 加载岗位列表
|
||||||
// postList.value = await PostApi.getSimplePostList()
|
roleOptions.value = await RoleApi.getSimpleRoleList()
|
||||||
postList.value = []
|
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
@@ -191,12 +173,12 @@ const submitForm = async () => {
|
|||||||
// 提交请求
|
// 提交请求
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
// const data = formData.value as unknown as UserApi.UserVO
|
const data = formData.value as unknown as UserApi.UserVO
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
// await UserApi.createUser(data)
|
await UserApi.createUser(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
} else {
|
} else {
|
||||||
// await UserApi.updateUser(data)
|
await UserApi.updateUser(data)
|
||||||
message.success(t('common.updateSuccess'))
|
message.success(t('common.updateSuccess'))
|
||||||
}
|
}
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
@@ -217,8 +199,7 @@ const resetForm = () => {
|
|||||||
id: undefined,
|
id: undefined,
|
||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
sex: undefined,
|
sex: 1,
|
||||||
postIds: [],
|
|
||||||
remark: '',
|
remark: '',
|
||||||
status: CommonStatusEnum.ENABLE,
|
status: CommonStatusEnum.ENABLE,
|
||||||
roleIds: []
|
roleIds: []
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
<el-table-column label="用户编号" key="id" prop="id" />
|
<el-table-column label="用户编号" key="id" prop="id" />
|
||||||
<el-table-column label="用户名称" prop="username" />
|
<el-table-column label="用户名称" prop="username" />
|
||||||
<el-table-column label="用户昵称" prop="nickname" />
|
<el-table-column label="用户昵称" prop="nickname" />
|
||||||
<el-table-column label="部门" key="deptName" prop="dept.name" />
|
<el-table-column label="部门" key="deptName" prop="deptName" />
|
||||||
<el-table-column label="手机号码" prop="mobile" width="120" />
|
<el-table-column label="手机号码" prop="mobile" width="120" />
|
||||||
<el-table-column label="状态" key="status">
|
<el-table-column label="状态" key="status">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
@@ -47,7 +47,12 @@
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="创建时间" prop="createTime" width="180" />
|
<el-table-column
|
||||||
|
label="创建时间"
|
||||||
|
prop="createTime"
|
||||||
|
width="180"
|
||||||
|
:formatter="dateFormatter"
|
||||||
|
/>
|
||||||
<el-table-column label="操作" width="260">
|
<el-table-column label="操作" width="260">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button type="primary" link @click="openForm('update', scope.row.id)">
|
<el-button type="primary" link @click="openForm('update', scope.row.id)">
|
||||||
@@ -72,6 +77,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts" name="SystemUser">
|
<script setup lang="ts" name="SystemUser">
|
||||||
import { CommonStatusEnum } from '@/utils/constants'
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
import * as UserApi from '@/api/system/user'
|
import * as UserApi from '@/api/system/user'
|
||||||
import UserForm from './UserForm.vue'
|
import UserForm from './UserForm.vue'
|
||||||
import DeptTree from './DeptTree.vue'
|
import DeptTree from './DeptTree.vue'
|
||||||
@@ -94,11 +100,7 @@ const queryFormRef = ref() // 搜索的表单
|
|||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
// const data = await UserApi.getUserPage(queryParams)
|
const data = await UserApi.getUserPage(queryParams)
|
||||||
const data = {
|
|
||||||
list: [{ username: '测试', status: 0 }],
|
|
||||||
total: 0
|
|
||||||
}
|
|
||||||
list.value = data.list
|
list.value = data.list
|
||||||
total.value = data.total
|
total.value = data.total
|
||||||
} finally {
|
} finally {
|
||||||
@@ -137,7 +139,7 @@ const handleStatusChange = async (row: UserApi.UserVO) => {
|
|||||||
const text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用'
|
const text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用'
|
||||||
await message.confirm('确认要"' + text + '""' + row.username + '"用户吗?')
|
await message.confirm('确认要"' + text + '""' + row.username + '"用户吗?')
|
||||||
// 发起修改状态
|
// 发起修改状态
|
||||||
// await UserApi.updateUserStatus(row.id, row.status)
|
await UserApi.updateUserStatus(row.id, row.status)
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await getList()
|
await getList()
|
||||||
} catch {
|
} catch {
|
||||||
@@ -150,12 +152,10 @@ const handleStatusChange = async (row: UserApi.UserVO) => {
|
|||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
console.log(id)
|
|
||||||
|
|
||||||
// 删除的二次确认
|
// 删除的二次确认
|
||||||
await message.delConfirm()
|
await message.delConfirm()
|
||||||
// 发起删除
|
// 发起删除
|
||||||
// await UserApi.deleteUser(id)
|
await UserApi.deleteUser(id)
|
||||||
message.success(t('common.delSuccess'))
|
message.success(t('common.delSuccess'))
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await getList()
|
await getList()
|
||||||
@@ -172,7 +172,7 @@ const handleResetPwd = async (row: UserApi.UserVO) => {
|
|||||||
)
|
)
|
||||||
const password = result.value
|
const password = result.value
|
||||||
// 发起重置
|
// 发起重置
|
||||||
// await UserApi.resetUserPwd(row.id, password)
|
await UserApi.resetUserPwd(row.id, password)
|
||||||
message.success('修改成功,新密码是:' + password)
|
message.success('修改成功,新密码是:' + password)
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user