提交 | 用户 | 时间
|
314507
|
1 |
<template> |
H |
2 |
<ContentWrap> |
|
3 |
<!-- 搜索工作栏 --> |
|
4 |
<el-form |
|
5 |
class="-mb-15px" |
|
6 |
:model="queryParams" |
|
7 |
ref="queryFormRef" |
|
8 |
:inline="true" |
|
9 |
label-width="68px" |
|
10 |
> |
|
11 |
<el-form-item label="岗位名称" prop="name"> |
|
12 |
<el-input |
|
13 |
v-model="queryParams.name" |
|
14 |
placeholder="请输入岗位名称" |
|
15 |
clearable |
|
16 |
@keyup.enter="handleQuery" |
|
17 |
/> |
|
18 |
</el-form-item> |
|
19 |
<el-form-item label="岗位编码" prop="code"> |
|
20 |
<el-input |
|
21 |
v-model="queryParams.code" |
|
22 |
placeholder="请输入岗位编码" |
|
23 |
clearable |
|
24 |
@keyup.enter="handleQuery" |
|
25 |
/> |
|
26 |
</el-form-item> |
|
27 |
<el-form-item label="状态" prop="status"> |
|
28 |
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable> |
|
29 |
<el-option |
|
30 |
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" |
|
31 |
:key="dict.value" |
|
32 |
:label="dict.label" |
|
33 |
:value="dict.value" |
|
34 |
/> |
|
35 |
</el-select> |
|
36 |
</el-form-item> |
|
37 |
<el-form-item> |
|
38 |
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
|
39 |
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
|
40 |
<el-button |
|
41 |
type="primary" |
|
42 |
plain |
|
43 |
@click="openForm('create')" |
|
44 |
v-hasPermi="['system:post:create']" |
|
45 |
> |
|
46 |
<Icon icon="ep:plus" class="mr-5px" /> 新增 |
|
47 |
</el-button> |
|
48 |
<el-button |
|
49 |
type="success" |
|
50 |
plain |
|
51 |
@click="handleExport" |
|
52 |
:loading="exportLoading" |
|
53 |
v-hasPermi="['system:post:export']" |
|
54 |
> |
|
55 |
<Icon icon="ep:download" class="mr-5px" /> 导出 |
|
56 |
</el-button> |
|
57 |
</el-form-item> |
|
58 |
</el-form> |
|
59 |
</ContentWrap> |
|
60 |
|
|
61 |
<!-- 列表 --> |
|
62 |
<ContentWrap> |
|
63 |
<el-table v-loading="loading" :data="list"> |
|
64 |
<el-table-column label="岗位编号" align="center" prop="id" /> |
|
65 |
<el-table-column label="岗位名称" align="center" prop="name" /> |
|
66 |
<el-table-column label="岗位编码" align="center" prop="code" /> |
|
67 |
<el-table-column label="岗位顺序" align="center" prop="sort" /> |
|
68 |
<el-table-column label="岗位备注" align="center" prop="remark" /> |
|
69 |
<el-table-column label="状态" align="center" prop="status"> |
|
70 |
<template #default="scope"> |
|
71 |
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> |
|
72 |
</template> |
|
73 |
</el-table-column> |
|
74 |
<el-table-column |
|
75 |
label="创建时间" |
|
76 |
align="center" |
|
77 |
prop="createTime" |
|
78 |
width="180" |
|
79 |
:formatter="dateFormatter" |
|
80 |
/> |
|
81 |
<el-table-column label="操作" align="center"> |
|
82 |
<template #default="scope"> |
|
83 |
<el-button |
|
84 |
link |
|
85 |
type="primary" |
|
86 |
@click="openForm('update', scope.row.id)" |
|
87 |
v-hasPermi="['system:post:update']" |
|
88 |
> |
|
89 |
编辑 |
|
90 |
</el-button> |
|
91 |
<el-button |
|
92 |
link |
|
93 |
type="danger" |
|
94 |
@click="handleDelete(scope.row.id)" |
|
95 |
v-hasPermi="['system:post:delete']" |
|
96 |
> |
|
97 |
删除 |
|
98 |
</el-button> |
|
99 |
</template> |
|
100 |
</el-table-column> |
|
101 |
</el-table> |
|
102 |
<!-- 分页 --> |
|
103 |
<Pagination |
|
104 |
:total="total" |
|
105 |
v-model:page="queryParams.pageNo" |
|
106 |
v-model:limit="queryParams.pageSize" |
|
107 |
@pagination="getList" |
|
108 |
/> |
|
109 |
</ContentWrap> |
|
110 |
|
|
111 |
<!-- 表单弹窗:添加/修改 --> |
|
112 |
<PostForm ref="formRef" @success="getList" /> |
|
113 |
</template> |
|
114 |
<script lang="ts" setup> |
|
115 |
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
|
116 |
import { dateFormatter } from '@/utils/formatTime' |
|
117 |
import download from '@/utils/download' |
|
118 |
import * as PostApi from '@/api/system/post' |
|
119 |
import PostForm from './PostForm.vue' |
|
120 |
|
|
121 |
defineOptions({ name: 'SystemPost' }) |
|
122 |
|
|
123 |
const message = useMessage() // 消息弹窗 |
|
124 |
const { t } = useI18n() // 国际化 |
|
125 |
|
|
126 |
const loading = ref(true) // 列表的加载中 |
|
127 |
const total = ref(0) // 列表的总页数 |
|
128 |
const list = ref([]) // 列表的数据 |
|
129 |
const queryParams = reactive({ |
|
130 |
pageNo: 1, |
|
131 |
pageSize: 10, |
|
132 |
code: '', |
|
133 |
name: '', |
|
134 |
status: undefined |
|
135 |
}) |
|
136 |
const queryFormRef = ref() // 搜索的表单 |
|
137 |
const exportLoading = ref(false) // 导出的加载中 |
|
138 |
|
|
139 |
/** 查询岗位列表 */ |
|
140 |
const getList = async () => { |
|
141 |
loading.value = true |
|
142 |
try { |
|
143 |
const data = await PostApi.getPostPage(queryParams) |
|
144 |
list.value = data.list |
|
145 |
total.value = data.total |
|
146 |
} finally { |
|
147 |
loading.value = false |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
/** 搜索按钮操作 */ |
|
152 |
const handleQuery = () => { |
|
153 |
queryParams.pageNo = 1 |
|
154 |
getList() |
|
155 |
} |
|
156 |
|
|
157 |
/** 重置按钮操作 */ |
|
158 |
const resetQuery = () => { |
|
159 |
queryFormRef.value.resetFields() |
|
160 |
handleQuery() |
|
161 |
} |
|
162 |
|
|
163 |
/** 添加/修改操作 */ |
|
164 |
const formRef = ref() |
|
165 |
const openForm = (type: string, id?: number) => { |
|
166 |
formRef.value.open(type, id) |
|
167 |
} |
|
168 |
|
|
169 |
/** 删除按钮操作 */ |
|
170 |
const handleDelete = async (id: number) => { |
|
171 |
try { |
|
172 |
// 删除的二次确认 |
|
173 |
await message.delConfirm() |
|
174 |
// 发起删除 |
|
175 |
await PostApi.deletePost(id) |
|
176 |
message.success(t('common.delSuccess')) |
|
177 |
// 刷新列表 |
|
178 |
await getList() |
|
179 |
} catch {} |
|
180 |
} |
|
181 |
|
|
182 |
/** 导出按钮操作 */ |
|
183 |
const handleExport = async () => { |
|
184 |
try { |
|
185 |
// 导出的二次确认 |
|
186 |
await message.exportConfirm() |
|
187 |
// 发起导出 |
|
188 |
exportLoading.value = true |
|
189 |
const data = await PostApi.exportPost(queryParams) |
|
190 |
download.excel(data, '岗位列表.xls') |
|
191 |
} catch { |
|
192 |
} finally { |
|
193 |
exportLoading.value = false |
|
194 |
} |
|
195 |
} |
|
196 |
|
|
197 |
/** 初始化 **/ |
|
198 |
onMounted(() => { |
|
199 |
getList() |
|
200 |
}) |
|
201 |
</script> |