salary
qsh 6 months ago
parent 3050b9a2fe
commit 33be215c0a
  1. 4
      src/api/login/index.ts
  2. 2
      src/api/system/dept/index.ts
  3. 2
      src/api/system/role/index.ts
  4. 18
      src/layout/components/RoleSelect/index.vue
  5. 3
      src/locales/zh-CN.ts
  6. 10
      src/router/modules/remaining.ts
  7. 4
      src/views/Basic/Dept/DeptForm.vue
  8. 23
      src/views/Basic/Dept/index.vue
  9. 56
      src/views/Basic/User/DeptTree.vue
  10. 41
      src/views/Basic/User/UserForm.vue
  11. 24
      src/views/Basic/User/index.vue

@ -33,8 +33,8 @@ export const loginOut = () => {
}
// 获取用户权限信息
export const getInfo = () => {
return request.get({ url: '/system/auth/get-permission-info' })
export const getInfo = (data) => {
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 })
}

@ -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' })
}

@ -1,18 +1,22 @@
<template>
<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>
</template>
<script setup name="RoleSelect">
const options = ref([
{ value: 1, label: '超级管理员' },
{ value: 2, label: '销售' }
])
import { useUserStore } from '@/store/modules/user'
import { getInfo } from '@/api/login/index'
const userStore = useUserStore()
const options = computed(() => {
return userStore.getRoles
})
const roleId = ref(1)
function handleChangeRole() {
console.log('修改角色')
function handleChangeRole(val) {
getInfo({ params: { roleId: val } })
}
</script>

@ -436,5 +436,6 @@ export default {
btn_zoom_in: '放大',
btn_zoom_out: '缩小',
preview: '预览'
}
},
'OAuth 2.0': 'OAuth 2.0' // 避免菜单名是 OAuth 2.0 时,一直 warn 报错
}

@ -50,7 +50,15 @@ const remainingRouter: AppRouteRecordRaw[] = [
noTagsView: true
}
},
{
path: '',
component: Layout,
redirect: '/Home/index',
meta: {
title: '首页',
hidden: true
}
},
{
path: '/user',
component: Layout,

@ -43,8 +43,8 @@
<el-col :span="12" :offset="0">
<el-form-item label="状态" prop="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-form-item>
</el-col>

@ -22,8 +22,8 @@
<el-table-column prop="leader" label="负责人" width="120" />
<el-table-column prop="sort" label="排序" width="200" />
<el-table-column prop="status" label="状态" width="100" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180" />
<el-table-column label="操作" align="center" class-name="fixed-width" width="160">
<el-table-column label="创建时间" prop="createTime" width="180" :formatter="dateFormatter" />
<el-table-column label="操作" class-name="fixed-width" width="160">
<template #default="scope">
<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>
@ -36,18 +36,16 @@
</template>
<script setup lang="ts" name="SystemDept">
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 * as UserApi from '@/api/system/user'
import { dateFormatter } from '@/utils/formatTime'
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref() //
const queryParams = reactive({
name: undefined,
pageNo: 1,
pageSize: 20
name: undefined
})
const queryFormRef = ref() //
@ -55,11 +53,7 @@ const queryFormRef = ref() // 搜索的表单
const getList = async () => {
loading.value = true
try {
// const data = await DeptApi.getDeptPage(queryParams)
const data = [
{ name: '职能部', id: 10001, leader: '张三', status: 1 },
{ name: '财务部', id: 10002, leader: '李四', parentId: 10001, status: 1 }
]
const data = await DeptApi.getDeptPage(queryParams)
list.value = handleTree(data)
} finally {
loading.value = false
@ -68,13 +62,11 @@ const getList = async () => {
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryParams.pageNo = 1
queryFormRef.value.resetFields()
handleQuery()
}
@ -88,11 +80,10 @@ const openForm = (type: string, id?: number) => {
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
console.log(id)
//
await message.delConfirm()
//
// await DeptApi.deleteDept(id)
await DeptApi.deleteDept(id)
message.success(t('common.delSuccess'))
//
await getList()

@ -23,7 +23,7 @@
<script lang="ts" name="SystemUserDeptTree" setup>
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'
const deptName = ref('')
@ -32,59 +32,7 @@ const treeRef = ref<InstanceType<typeof ElTree>>()
/** 获得部门树 */
const getTree = async () => {
// 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
}
]
const res = await DeptApi.getSimpleDeptList()
deptList.value = []
deptList.value.push(...handleTree(res))
}

@ -93,10 +93,10 @@
</template>
<script lang="ts" name="SystemUserForm" setup>
import { CommonStatusEnum } from '@/utils/constants'
import { defaultProps } from '@/utils/tree'
// import * as PostApi from '@/api/system/post'
// import * as DeptApi from '@/api/system/dept'
// import * as UserApi from '@/api/system/user'
import { defaultProps, handleTree } from '@/utils/tree'
import * as RoleApi from '@/api/system/role'
import * as DeptApi from '@/api/system/dept'
import * as UserApi from '@/api/system/user'
const { t } = useI18n() //
const message = useMessage() //
@ -114,7 +114,6 @@ const formData = ref({
username: '',
password: '',
sex: 1,
postIds: [],
remark: '',
status: CommonStatusEnum.ENABLE,
roleIds: []
@ -140,7 +139,6 @@ const formRules = {
}
const formRef = ref() // Ref
const deptList = ref<Tree[]>([]) //
const postList = ref([]) //
const roleOptions = ref([])
/** 打开弹窗 */
@ -153,31 +151,15 @@ const open = async (type: string, id?: number) => {
if (id) {
formLoading.value = true
try {
// formData.value = await UserApi.getUser(id)
formData.value = {
nickname: '',
deptId: '',
mobile: '',
email: '',
id: undefined,
username: '',
password: '',
sex: 1,
postIds: [],
remark: '',
status: CommonStatusEnum.ENABLE,
roleIds: []
}
formData.value = await UserApi.getUser(id)
} finally {
formLoading.value = false
}
}
//
// deptList.value = handleTree(await DeptApi.getSimpleDeptList())
deptList.value = []
deptList.value = handleTree(await DeptApi.getSimpleDeptList())
//
// postList.value = await PostApi.getSimplePostList()
postList.value = []
roleOptions.value = await RoleApi.getSimpleRoleList()
}
defineExpose({ open }) // open
@ -191,12 +173,12 @@ const submitForm = async () => {
//
formLoading.value = true
try {
// const data = formData.value as unknown as UserApi.UserVO
const data = formData.value as unknown as UserApi.UserVO
if (formType.value === 'create') {
// await UserApi.createUser(data)
await UserApi.createUser(data)
message.success(t('common.createSuccess'))
} else {
// await UserApi.updateUser(data)
await UserApi.updateUser(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
@ -217,8 +199,7 @@ const resetForm = () => {
id: undefined,
username: '',
password: '',
sex: undefined,
postIds: [],
sex: 1,
remark: '',
status: CommonStatusEnum.ENABLE,
roleIds: []

@ -35,7 +35,7 @@
<el-table-column label="用户编号" key="id" prop="id" />
<el-table-column label="用户名称" prop="username" />
<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="状态" key="status">
<template #default="scope">
@ -47,7 +47,12 @@
/>
</template>
</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">
<template #default="scope">
<el-button type="primary" link @click="openForm('update', scope.row.id)">
@ -72,6 +77,7 @@
</template>
<script setup lang="ts" name="SystemUser">
import { CommonStatusEnum } from '@/utils/constants'
import { dateFormatter } from '@/utils/formatTime'
import * as UserApi from '@/api/system/user'
import UserForm from './UserForm.vue'
import DeptTree from './DeptTree.vue'
@ -94,11 +100,7 @@ const queryFormRef = ref() // 搜索的表单
const getList = async () => {
loading.value = true
try {
// const data = await UserApi.getUserPage(queryParams)
const data = {
list: [{ username: '测试', status: 0 }],
total: 0
}
const data = await UserApi.getUserPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
@ -137,7 +139,7 @@ const handleStatusChange = async (row: UserApi.UserVO) => {
const text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用'
await message.confirm('确认要"' + text + '""' + row.username + '"用户吗?')
//
// await UserApi.updateUserStatus(row.id, row.status)
await UserApi.updateUserStatus(row.id, row.status)
//
await getList()
} catch {
@ -150,12 +152,10 @@ const handleStatusChange = async (row: UserApi.UserVO) => {
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
console.log(id)
//
await message.delConfirm()
//
// await UserApi.deleteUser(id)
await UserApi.deleteUser(id)
message.success(t('common.delSuccess'))
//
await getList()
@ -172,7 +172,7 @@ const handleResetPwd = async (row: UserApi.UserVO) => {
)
const password = result.value
//
// await UserApi.resetUserPwd(row.id, password)
await UserApi.resetUserPwd(row.id, password)
message.success('修改成功,新密码是:' + password)
} catch {}
}

Loading…
Cancel
Save