Skip to content

Commit c424ee7

Browse files
committed
Vue3 重构:REVIEW 岗位
1 parent 320cffe commit c424ee7

File tree

5 files changed

+63
-67
lines changed

5 files changed

+63
-67
lines changed

src/api/system/post/index.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,37 @@ export interface PostVO {
1010
createTime?: Date
1111
}
1212

13-
export interface PostPageReqVO extends PageParam {
14-
code?: string
15-
name?: string
16-
status?: number
17-
}
18-
19-
export interface PostExportReqVO {
20-
code?: string
21-
name?: string
22-
status?: number
23-
}
24-
2513
// 查询岗位列表
26-
export const getPostPageApi = async (params: PostPageReqVO) => {
14+
export const getPostPage = async (params: PageParam) => {
2715
return await request.get({ url: '/system/post/page', params })
2816
}
2917

3018
// 获取岗位精简信息列表
31-
export const listSimplePostsApi = async () => {
19+
export const getSimplePostList = async () => {
3220
return await request.get({ url: '/system/post/list-all-simple' })
3321
}
3422

3523
// 查询岗位详情
36-
export const getPostApi = async (id: number) => {
24+
export const getPost = async (id: number) => {
3725
return await request.get({ url: '/system/post/get?id=' + id })
3826
}
3927

4028
// 新增岗位
41-
export const createPostApi = async (data: PostVO) => {
29+
export const createPost = async (data: PostVO) => {
4230
return await request.post({ url: '/system/post/create', data })
4331
}
4432

4533
// 修改岗位
46-
export const updatePostApi = async (data: PostVO) => {
34+
export const updatePost = async (data: PostVO) => {
4735
return await request.put({ url: '/system/post/update', data })
4836
}
4937

5038
// 删除岗位
51-
export const deletePostApi = async (id: number) => {
39+
export const deletePost = async (id: number) => {
5240
return await request.delete({ url: '/system/post/delete?id=' + id })
5341
}
5442

5543
// 导出岗位
56-
export const exportPostApi = async (params: PostExportReqVO) => {
44+
export const exportPost = async (params) => {
5745
return await request.download({ url: '/system/post/export', params })
5846
}

src/views/bpm/taskAssignRule/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ import { FormInstance } from 'element-plus'
139139
// 业务相关的 import
140140
import * as TaskAssignRuleApi from '@/api/bpm/taskAssignRule'
141141
import { listSimpleRolesApi } from '@/api/system/role'
142-
import { listSimplePostsApi } from '@/api/system/post'
142+
import { getSimplePostList } from '@/api/system/post'
143143
import { getSimpleUserList } from '@/api/system/user'
144144
import { listSimpleUserGroup } from '@/api/bpm/userGroup'
145145
import { listSimpleDeptApi } from '@/api/system/dept'
@@ -336,7 +336,7 @@ onMounted(() => {
336336
})
337337
// 获得岗位列表
338338
postOptions.value = []
339-
listSimplePostsApi().then((data) => {
339+
getSimplePostList().then((data) => {
340340
postOptions.value.push(...data)
341341
})
342342
// 获得用户列表

src/views/system/post/form.vue renamed to src/views/system/post/PostForm.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
</template>
3838
<script setup lang="ts">
3939
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
40+
import { CommonStatusEnum } from '@/utils/constants'
4041
import * as PostApi from '@/api/system/post'
4142
4243
const { t } = useI18n() // 国际化
@@ -50,7 +51,8 @@ const formData = ref({
5051
id: undefined,
5152
name: '',
5253
code: '',
53-
status: undefined,
54+
sort: undefined,
55+
status: CommonStatusEnum.ENABLE,
5456
remark: ''
5557
})
5658
const formRules = reactive({
@@ -71,7 +73,7 @@ const openModal = async (type: string, id?: number) => {
7173
if (id) {
7274
formLoading.value = true
7375
try {
74-
formData.value = await PostApi.getPostApi(id)
76+
formData.value = await PostApi.getPost(id)
7577
} finally {
7678
formLoading.value = false
7779
}
@@ -91,10 +93,10 @@ const submitForm = async () => {
9193
try {
9294
const data = formData.value as unknown as PostApi.PostVO
9395
if (formType.value === 'create') {
94-
await PostApi.createPostApi(data)
96+
await PostApi.createPost(data)
9597
message.success(t('common.createSuccess'))
9698
} else {
97-
await PostApi.updatePostApi(data)
99+
await PostApi.updatePost(data)
98100
message.success(t('common.updateSuccess'))
99101
}
100102
modelVisible.value = false
@@ -109,10 +111,10 @@ const submitForm = async () => {
109111
const resetForm = () => {
110112
formData.value = {
111113
id: undefined,
112-
title: '',
113-
type: undefined,
114-
content: '',
115-
status: undefined,
114+
name: '',
115+
code: '',
116+
sort: undefined,
117+
status: CommonStatusEnum.ENABLE,
116118
remark: ''
117119
}
118120
formRef.value?.resetFields()

src/views/system/post/index.vue

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
<template>
2-
<content-wrap>
2+
<ContentWrap>
33
<!-- 搜索工作栏 -->
4-
<el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
4+
<el-form
5+
class="-mb-15px"
6+
:model="queryParams"
7+
ref="queryFormRef"
8+
:inline="true"
9+
label-width="68px"
10+
>
511
<el-form-item label="岗位名称" prop="name">
612
<el-input
713
v-model="queryParams.name"
@@ -21,10 +27,10 @@
2127
<el-form-item label="状态" prop="status">
2228
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
2329
<el-option
24-
v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)"
25-
:key="parseInt(dict.value)"
30+
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
31+
:key="dict.value"
2632
:label="dict.label"
27-
:value="parseInt(dict.value)"
33+
:value="dict.value"
2834
/>
2935
</el-select>
3036
</el-form-item>
@@ -49,15 +55,16 @@
4955
</el-button>
5056
</el-form-item>
5157
</el-form>
58+
</ContentWrap>
5259

53-
<!-- 列表 -->
60+
<!-- 列表 -->
61+
<ContentWrap>
5462
<el-table v-loading="loading" :data="list" align="center">
5563
<el-table-column label="岗位编号" align="center" prop="id" />
5664
<el-table-column label="岗位名称" align="center" prop="name" />
5765
<el-table-column label="岗位编码" align="center" prop="code" />
5866
<el-table-column label="岗位顺序" align="center" prop="sort" />
5967
<el-table-column label="岗位备注" align="center" prop="remark" />
60-
6168
<el-table-column label="状态" align="center" prop="status">
6269
<template #default="scope">
6370
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
@@ -98,18 +105,17 @@
98105
v-model:limit="queryParams.pageSize"
99106
@pagination="getList"
100107
/>
101-
</content-wrap>
108+
</ContentWrap>
102109

103110
<!-- 表单弹窗:添加/修改 -->
104-
<post-form ref="modalRef" @success="getList" />
111+
<PostForm ref="formRef" @success="getList" />
105112
</template>
106113
<script setup lang="tsx">
107-
import * as PostApi from '@/api/system/post'
108-
import PostForm from './form.vue'
109-
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
114+
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
110115
import { dateFormatter } from '@/utils/formatTime'
111116
import download from '@/utils/download'
112-
import { DictTag } from '@/components/DictTag'
117+
import * as PostApi from '@/api/system/post'
118+
import PostForm from './PostForm.vue'
113119
114120
const message = useMessage() // 消息弹窗
115121
const { t } = useI18n() // 国际化
@@ -118,42 +124,27 @@ const loading = ref(true) // 列表的加载中
118124
const total = ref(0) // 列表的总页数
119125
const list = ref([]) // 列表的数据
120126
const queryParams = reactive({
127+
pageNo: 1,
128+
pageSize: 10,
121129
code: '',
122130
name: '',
123-
status: undefined,
124-
pageNo: 1,
125-
pageSize: 100
131+
status: undefined
126132
})
127133
const queryFormRef = ref() // 搜索的表单
128134
const exportLoading = ref(false) // 导出的加载中
135+
129136
/** 查询岗位列表 */
130137
const getList = async () => {
131138
loading.value = true
132139
try {
133-
const data = await PostApi.getPostPageApi(queryParams)
134-
140+
const data = await PostApi.getPostPage(queryParams)
135141
list.value = data.list
136142
total.value = data.total
137143
} finally {
138144
loading.value = false
139145
}
140146
}
141147
142-
/** 导出按钮操作 */
143-
const handleExport = async () => {
144-
try {
145-
// 导出的二次确认
146-
await message.exportConfirm()
147-
// 发起导出
148-
exportLoading.value = true
149-
const data = await PostApi.exportPostApi(queryParams)
150-
download.excel(data, '岗位列表.xls')
151-
} catch {
152-
} finally {
153-
exportLoading.value = false
154-
}
155-
}
156-
157148
/** 搜索按钮操作 */
158149
const handleQuery = () => {
159150
queryParams.pageNo = 1
@@ -167,9 +158,9 @@ const resetQuery = () => {
167158
}
168159
169160
/** 添加/修改操作 */
170-
const modalRef = ref()
161+
const formRef = ref()
171162
const openModal = (type: string, id?: number) => {
172-
modalRef.value.openModal(type, id)
163+
formRef.value.openModal(type, id)
173164
}
174165
175166
/** 删除按钮操作 */
@@ -178,13 +169,28 @@ const handleDelete = async (id: number) => {
178169
// 删除的二次确认
179170
await message.delConfirm()
180171
// 发起删除
181-
await PostApi.deletePostApi(id)
172+
await PostApi.deletePost(id)
182173
message.success(t('common.delSuccess'))
183174
// 刷新列表
184175
await getList()
185176
} catch {}
186177
}
187178
179+
/** 导出按钮操作 */
180+
const handleExport = async () => {
181+
try {
182+
// 导出的二次确认
183+
await message.exportConfirm()
184+
// 发起导出
185+
exportLoading.value = true
186+
const data = await PostApi.exportPost(queryParams)
187+
download.excel(data, '岗位列表.xls')
188+
} catch {
189+
} finally {
190+
exportLoading.value = false
191+
}
192+
}
193+
188194
/** 初始化 **/
189195
onMounted(() => {
190196
getList()

src/views/system/user/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ import { rules, allSchemas } from './user.data'
273273
import * as UserApi from '@/api/system/user'
274274
import { listSimpleDeptApi } from '@/api/system/dept'
275275
import { listSimpleRolesApi } from '@/api/system/role'
276-
import { listSimplePostsApi, PostVO } from '@/api/system/post'
276+
import { getSimplePostList, PostVO } from '@/api/system/post'
277277
import {
278278
aassignUserRoleApi,
279279
listUserRolesApi,
@@ -329,7 +329,7 @@ const postOptions = ref<PostVO[]>([]) //岗位列表
329329
330330
// 获取岗位列表
331331
const getPostOptions = async () => {
332-
const res = await listSimplePostsApi()
332+
const res = await getSimplePostList()
333333
postOptions.value.push(...res)
334334
}
335335
const dataFormater = (val) => {

0 commit comments

Comments
 (0)