Vue3 重构:REVIEW 岗位
parent
320cffee19
commit
c424ee76e4
|
@ -10,49 +10,37 @@ export interface PostVO {
|
|||
createTime?: Date
|
||||
}
|
||||
|
||||
export interface PostPageReqVO extends PageParam {
|
||||
code?: string
|
||||
name?: string
|
||||
status?: number
|
||||
}
|
||||
|
||||
export interface PostExportReqVO {
|
||||
code?: string
|
||||
name?: string
|
||||
status?: number
|
||||
}
|
||||
|
||||
// 查询岗位列表
|
||||
export const getPostPageApi = async (params: PostPageReqVO) => {
|
||||
export const getPostPage = async (params: PageParam) => {
|
||||
return await request.get({ url: '/system/post/page', params })
|
||||
}
|
||||
|
||||
// 获取岗位精简信息列表
|
||||
export const listSimplePostsApi = async () => {
|
||||
export const getSimplePostList = async () => {
|
||||
return await request.get({ url: '/system/post/list-all-simple' })
|
||||
}
|
||||
|
||||
// 查询岗位详情
|
||||
export const getPostApi = async (id: number) => {
|
||||
export const getPost = async (id: number) => {
|
||||
return await request.get({ url: '/system/post/get?id=' + id })
|
||||
}
|
||||
|
||||
// 新增岗位
|
||||
export const createPostApi = async (data: PostVO) => {
|
||||
export const createPost = async (data: PostVO) => {
|
||||
return await request.post({ url: '/system/post/create', data })
|
||||
}
|
||||
|
||||
// 修改岗位
|
||||
export const updatePostApi = async (data: PostVO) => {
|
||||
export const updatePost = async (data: PostVO) => {
|
||||
return await request.put({ url: '/system/post/update', data })
|
||||
}
|
||||
|
||||
// 删除岗位
|
||||
export const deletePostApi = async (id: number) => {
|
||||
export const deletePost = async (id: number) => {
|
||||
return await request.delete({ url: '/system/post/delete?id=' + id })
|
||||
}
|
||||
|
||||
// 导出岗位
|
||||
export const exportPostApi = async (params: PostExportReqVO) => {
|
||||
export const exportPost = async (params) => {
|
||||
return await request.download({ url: '/system/post/export', params })
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ import { FormInstance } from 'element-plus'
|
|||
// 业务相关的 import
|
||||
import * as TaskAssignRuleApi from '@/api/bpm/taskAssignRule'
|
||||
import { listSimpleRolesApi } from '@/api/system/role'
|
||||
import { listSimplePostsApi } from '@/api/system/post'
|
||||
import { getSimplePostList } from '@/api/system/post'
|
||||
import { getSimpleUserList } from '@/api/system/user'
|
||||
import { listSimpleUserGroup } from '@/api/bpm/userGroup'
|
||||
import { listSimpleDeptApi } from '@/api/system/dept'
|
||||
|
@ -336,7 +336,7 @@ onMounted(() => {
|
|||
})
|
||||
// 获得岗位列表
|
||||
postOptions.value = []
|
||||
listSimplePostsApi().then((data) => {
|
||||
getSimplePostList().then((data) => {
|
||||
postOptions.value.push(...data)
|
||||
})
|
||||
// 获得用户列表
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
</template>
|
||||
<script setup lang="ts">
|
||||
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
|
||||
import { CommonStatusEnum } from '@/utils/constants'
|
||||
import * as PostApi from '@/api/system/post'
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
|
@ -50,7 +51,8 @@ const formData = ref({
|
|||
id: undefined,
|
||||
name: '',
|
||||
code: '',
|
||||
status: undefined,
|
||||
sort: undefined,
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
remark: ''
|
||||
})
|
||||
const formRules = reactive({
|
||||
|
@ -71,7 +73,7 @@ const openModal = async (type: string, id?: number) => {
|
|||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await PostApi.getPostApi(id)
|
||||
formData.value = await PostApi.getPost(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
|
@ -91,10 +93,10 @@ const submitForm = async () => {
|
|||
try {
|
||||
const data = formData.value as unknown as PostApi.PostVO
|
||||
if (formType.value === 'create') {
|
||||
await PostApi.createPostApi(data)
|
||||
await PostApi.createPost(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await PostApi.updatePostApi(data)
|
||||
await PostApi.updatePost(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
modelVisible.value = false
|
||||
|
@ -109,10 +111,10 @@ const submitForm = async () => {
|
|||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
title: '',
|
||||
type: undefined,
|
||||
content: '',
|
||||
status: undefined,
|
||||
name: '',
|
||||
code: '',
|
||||
sort: undefined,
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
remark: ''
|
||||
}
|
||||
formRef.value?.resetFields()
|
|
@ -1,7 +1,13 @@
|
|||
<template>
|
||||
<content-wrap>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="岗位名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
|
@ -21,10 +27,10 @@
|
|||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
|
||||
<el-option
|
||||
v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||
:key="parseInt(dict.value)"
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="parseInt(dict.value)"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
@ -49,15 +55,16 @@
|
|||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" align="center">
|
||||
<el-table-column label="岗位编号" align="center" prop="id" />
|
||||
<el-table-column label="岗位名称" align="center" prop="name" />
|
||||
<el-table-column label="岗位编码" align="center" prop="code" />
|
||||
<el-table-column label="岗位顺序" align="center" prop="sort" />
|
||||
<el-table-column label="岗位备注" align="center" prop="remark" />
|
||||
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
||||
|
@ -98,18 +105,17 @@
|
|||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</content-wrap>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<post-form ref="modalRef" @success="getList" />
|
||||
<PostForm ref="formRef" @success="getList" />
|
||||
</template>
|
||||
<script setup lang="tsx">
|
||||
import * as PostApi from '@/api/system/post'
|
||||
import PostForm from './form.vue'
|
||||
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import { DictTag } from '@/components/DictTag'
|
||||
import * as PostApi from '@/api/system/post'
|
||||
import PostForm from './PostForm.vue'
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
@ -118,20 +124,20 @@ const loading = ref(true) // 列表的加载中
|
|||
const total = ref(0) // 列表的总页数
|
||||
const list = ref([]) // 列表的数据
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
code: '',
|
||||
name: '',
|
||||
status: undefined,
|
||||
pageNo: 1,
|
||||
pageSize: 100
|
||||
status: undefined
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
/** 查询岗位列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await PostApi.getPostPageApi(queryParams)
|
||||
|
||||
const data = await PostApi.getPostPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
|
@ -139,21 +145,6 @@ const getList = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await PostApi.exportPostApi(queryParams)
|
||||
download.excel(data, '岗位列表.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
|
@ -167,9 +158,9 @@ const resetQuery = () => {
|
|||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const modalRef = ref()
|
||||
const formRef = ref()
|
||||
const openModal = (type: string, id?: number) => {
|
||||
modalRef.value.openModal(type, id)
|
||||
formRef.value.openModal(type, id)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
|
@ -178,13 +169,28 @@ const handleDelete = async (id: number) => {
|
|||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await PostApi.deletePostApi(id)
|
||||
await PostApi.deletePost(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await PostApi.exportPost(queryParams)
|
||||
download.excel(data, '岗位列表.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
|
|
|
@ -273,7 +273,7 @@ import { rules, allSchemas } from './user.data'
|
|||
import * as UserApi from '@/api/system/user'
|
||||
import { listSimpleDeptApi } from '@/api/system/dept'
|
||||
import { listSimpleRolesApi } from '@/api/system/role'
|
||||
import { listSimplePostsApi, PostVO } from '@/api/system/post'
|
||||
import { getSimplePostList, PostVO } from '@/api/system/post'
|
||||
import {
|
||||
aassignUserRoleApi,
|
||||
listUserRolesApi,
|
||||
|
@ -329,7 +329,7 @@ const postOptions = ref<PostVO[]>([]) //岗位列表
|
|||
|
||||
// 获取岗位列表
|
||||
const getPostOptions = async () => {
|
||||
const res = await listSimplePostsApi()
|
||||
const res = await getSimplePostList()
|
||||
postOptions.value.push(...res)
|
||||
}
|
||||
const dataFormater = (val) => {
|
||||
|
|
Loading…
Reference in New Issue