提交 | 用户 | 时间
|
fd2207
|
1 |
<template> |
懒 |
2 |
<div class="app-container"> |
|
3 |
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> |
|
4 |
<el-form-item label="岗位编码" prop="postCode"> |
|
5 |
<el-input |
|
6 |
v-model="queryParams.postCode" |
|
7 |
placeholder="请输入岗位编码" |
|
8 |
clearable |
|
9 |
@keyup.enter.native="handleQuery" |
|
10 |
/> |
|
11 |
</el-form-item> |
|
12 |
<el-form-item label="岗位名称" prop="postName"> |
|
13 |
<el-input |
|
14 |
v-model="queryParams.postName" |
|
15 |
placeholder="请输入岗位名称" |
|
16 |
clearable |
|
17 |
@keyup.enter.native="handleQuery" |
|
18 |
/> |
|
19 |
</el-form-item> |
|
20 |
<el-form-item label="状态" prop="status"> |
|
21 |
<el-select v-model="queryParams.status" placeholder="岗位状态" clearable> |
|
22 |
<el-option |
|
23 |
v-for="dict in dict.type.sys_normal_disable" |
|
24 |
:key="dict.value" |
|
25 |
:label="dict.label" |
|
26 |
:value="dict.value" |
|
27 |
/> |
|
28 |
</el-select> |
|
29 |
</el-form-item> |
|
30 |
<el-form-item> |
|
31 |
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> |
|
32 |
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> |
|
33 |
</el-form-item> |
|
34 |
</el-form> |
|
35 |
|
|
36 |
<el-row :gutter="10" class="mb8"> |
|
37 |
<el-col :span="1.5"> |
|
38 |
<el-button |
|
39 |
type="primary" |
|
40 |
plain |
|
41 |
icon="el-icon-plus" |
|
42 |
size="mini" |
|
43 |
@click="handleAdd" |
|
44 |
v-hasPermi="['system:post:add']" |
|
45 |
>新增</el-button> |
|
46 |
</el-col> |
|
47 |
<el-col :span="1.5"> |
|
48 |
<el-button |
|
49 |
type="success" |
|
50 |
plain |
|
51 |
icon="el-icon-edit" |
|
52 |
size="mini" |
|
53 |
:disabled="single" |
|
54 |
@click="handleUpdate" |
|
55 |
v-hasPermi="['system:post:edit']" |
|
56 |
>修改</el-button> |
|
57 |
</el-col> |
|
58 |
<el-col :span="1.5"> |
|
59 |
<el-button |
|
60 |
type="danger" |
|
61 |
plain |
|
62 |
icon="el-icon-delete" |
|
63 |
size="mini" |
|
64 |
:disabled="multiple" |
|
65 |
@click="handleDelete" |
|
66 |
v-hasPermi="['system:post:remove']" |
|
67 |
>删除</el-button> |
|
68 |
</el-col> |
|
69 |
<el-col :span="1.5"> |
|
70 |
<el-button |
|
71 |
type="warning" |
|
72 |
plain |
|
73 |
icon="el-icon-download" |
|
74 |
size="mini" |
|
75 |
@click="handleExport" |
|
76 |
v-hasPermi="['system:post:export']" |
|
77 |
>导出</el-button> |
|
78 |
</el-col> |
|
79 |
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
|
80 |
</el-row> |
|
81 |
|
|
82 |
<el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange"> |
|
83 |
<el-table-column type="selection" width="55" align="center" /> |
|
84 |
<el-table-column label="岗位编号" align="center" prop="postId" /> |
|
85 |
<el-table-column label="岗位编码" align="center" prop="postCode" /> |
|
86 |
<el-table-column label="岗位名称" align="center" prop="postName" /> |
|
87 |
<el-table-column label="岗位排序" align="center" prop="postSort" /> |
|
88 |
<el-table-column label="状态" align="center" prop="status"> |
|
89 |
<template slot-scope="scope"> |
|
90 |
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/> |
|
91 |
</template> |
|
92 |
</el-table-column> |
|
93 |
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
|
94 |
<template slot-scope="scope"> |
|
95 |
<span>{{ parseTime(scope.row.createTime) }}</span> |
|
96 |
</template> |
|
97 |
</el-table-column> |
|
98 |
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
|
99 |
<template slot-scope="scope"> |
|
100 |
<el-button |
|
101 |
size="mini" |
|
102 |
type="text" |
|
103 |
icon="el-icon-edit" |
|
104 |
@click="handleUpdate(scope.row)" |
|
105 |
v-hasPermi="['system:post:edit']" |
|
106 |
>修改</el-button> |
|
107 |
<el-button |
|
108 |
size="mini" |
|
109 |
type="text" |
|
110 |
icon="el-icon-delete" |
|
111 |
@click="handleDelete(scope.row)" |
|
112 |
v-hasPermi="['system:post:remove']" |
|
113 |
>删除</el-button> |
|
114 |
</template> |
|
115 |
</el-table-column> |
|
116 |
</el-table> |
|
117 |
|
|
118 |
<pagination |
|
119 |
v-show="total>0" |
|
120 |
:total="total" |
|
121 |
:page.sync="queryParams.pageNum" |
|
122 |
:limit.sync="queryParams.pageSize" |
|
123 |
@pagination="getList" |
|
124 |
/> |
|
125 |
|
|
126 |
<!-- 添加或修改岗位对话框 --> |
|
127 |
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> |
|
128 |
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
|
129 |
<el-form-item label="岗位名称" prop="postName"> |
|
130 |
<el-input v-model="form.postName" placeholder="请输入岗位名称" /> |
|
131 |
</el-form-item> |
|
132 |
<el-form-item label="岗位编码" prop="postCode"> |
|
133 |
<el-input v-model="form.postCode" placeholder="请输入编码名称" /> |
|
134 |
</el-form-item> |
|
135 |
<el-form-item label="岗位顺序" prop="postSort"> |
|
136 |
<el-input-number v-model="form.postSort" controls-position="right" :min="0" /> |
|
137 |
</el-form-item> |
|
138 |
<el-form-item label="岗位状态" prop="status"> |
|
139 |
<el-radio-group v-model="form.status"> |
|
140 |
<el-radio |
|
141 |
v-for="dict in dict.type.sys_normal_disable" |
|
142 |
:key="dict.value" |
|
143 |
:label="dict.value" |
|
144 |
>{{dict.label}}</el-radio> |
|
145 |
</el-radio-group> |
|
146 |
</el-form-item> |
|
147 |
<el-form-item label="备注" prop="remark"> |
|
148 |
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> |
|
149 |
</el-form-item> |
|
150 |
</el-form> |
|
151 |
<div slot="footer" class="dialog-footer"> |
|
152 |
<el-button type="primary" @click="submitForm">确 定</el-button> |
|
153 |
<el-button @click="cancel">取 消</el-button> |
|
154 |
</div> |
|
155 |
</el-dialog> |
|
156 |
</div> |
|
157 |
</template> |
|
158 |
|
|
159 |
<script> |
|
160 |
import { listPost, getPost, delPost, addPost, updatePost } from "@/api/system/post"; |
|
161 |
|
|
162 |
export default { |
|
163 |
name: "Post", |
|
164 |
dicts: ['sys_normal_disable'], |
|
165 |
data() { |
|
166 |
return { |
|
167 |
// 遮罩层 |
|
168 |
loading: true, |
|
169 |
// 选中数组 |
|
170 |
ids: [], |
|
171 |
// 非单个禁用 |
|
172 |
single: true, |
|
173 |
// 非多个禁用 |
|
174 |
multiple: true, |
|
175 |
// 显示搜索条件 |
|
176 |
showSearch: true, |
|
177 |
// 总条数 |
|
178 |
total: 0, |
|
179 |
// 岗位表格数据 |
|
180 |
postList: [], |
|
181 |
// 弹出层标题 |
|
182 |
title: "", |
|
183 |
// 是否显示弹出层 |
|
184 |
open: false, |
|
185 |
// 查询参数 |
|
186 |
queryParams: { |
|
187 |
pageNum: 1, |
|
188 |
pageSize: 10, |
|
189 |
postCode: undefined, |
|
190 |
postName: undefined, |
|
191 |
status: undefined |
|
192 |
}, |
|
193 |
// 表单参数 |
|
194 |
form: {}, |
|
195 |
// 表单校验 |
|
196 |
rules: { |
|
197 |
postName: [ |
|
198 |
{ required: true, message: "岗位名称不能为空", trigger: "blur" } |
|
199 |
], |
|
200 |
postCode: [ |
|
201 |
{ required: true, message: "岗位编码不能为空", trigger: "blur" } |
|
202 |
], |
|
203 |
postSort: [ |
|
204 |
{ required: true, message: "岗位顺序不能为空", trigger: "blur" } |
|
205 |
] |
|
206 |
} |
|
207 |
}; |
|
208 |
}, |
|
209 |
created() { |
|
210 |
this.getList(); |
|
211 |
}, |
|
212 |
methods: { |
|
213 |
/** 查询岗位列表 */ |
|
214 |
getList() { |
|
215 |
this.loading = true; |
|
216 |
listPost(this.queryParams).then(response => { |
|
217 |
this.postList = response.rows; |
|
218 |
this.total = response.total; |
|
219 |
this.loading = false; |
|
220 |
}); |
|
221 |
}, |
|
222 |
// 取消按钮 |
|
223 |
cancel() { |
|
224 |
this.open = false; |
|
225 |
this.reset(); |
|
226 |
}, |
|
227 |
// 表单重置 |
|
228 |
reset() { |
|
229 |
this.form = { |
|
230 |
postId: undefined, |
|
231 |
postCode: undefined, |
|
232 |
postName: undefined, |
|
233 |
postSort: 0, |
|
234 |
status: "0", |
|
235 |
remark: undefined |
|
236 |
}; |
|
237 |
this.resetForm("form"); |
|
238 |
}, |
|
239 |
/** 搜索按钮操作 */ |
|
240 |
handleQuery() { |
|
241 |
this.queryParams.pageNum = 1; |
|
242 |
this.getList(); |
|
243 |
}, |
|
244 |
/** 重置按钮操作 */ |
|
245 |
resetQuery() { |
|
246 |
this.resetForm("queryForm"); |
|
247 |
this.handleQuery(); |
|
248 |
}, |
|
249 |
// 多选框选中数据 |
|
250 |
handleSelectionChange(selection) { |
|
251 |
this.ids = selection.map(item => item.postId) |
|
252 |
this.single = selection.length!=1 |
|
253 |
this.multiple = !selection.length |
|
254 |
}, |
|
255 |
/** 新增按钮操作 */ |
|
256 |
handleAdd() { |
|
257 |
this.reset(); |
|
258 |
this.open = true; |
|
259 |
this.title = "添加岗位"; |
|
260 |
}, |
|
261 |
/** 修改按钮操作 */ |
|
262 |
handleUpdate(row) { |
|
263 |
this.reset(); |
|
264 |
const postId = row.postId || this.ids |
|
265 |
getPost(postId).then(response => { |
|
266 |
this.form = response.data; |
|
267 |
this.open = true; |
|
268 |
this.title = "修改岗位"; |
|
269 |
}); |
|
270 |
}, |
|
271 |
/** 提交按钮 */ |
|
272 |
submitForm: function() { |
|
273 |
this.$refs["form"].validate(valid => { |
|
274 |
if (valid) { |
|
275 |
if (this.form.postId != undefined) { |
|
276 |
updatePost(this.form).then(response => { |
|
277 |
this.$modal.msgSuccess("修改成功"); |
|
278 |
this.open = false; |
|
279 |
this.getList(); |
|
280 |
}); |
|
281 |
} else { |
|
282 |
addPost(this.form).then(response => { |
|
283 |
this.$modal.msgSuccess("新增成功"); |
|
284 |
this.open = false; |
|
285 |
this.getList(); |
|
286 |
}); |
|
287 |
} |
|
288 |
} |
|
289 |
}); |
|
290 |
}, |
|
291 |
/** 删除按钮操作 */ |
|
292 |
handleDelete(row) { |
|
293 |
const postIds = row.postId || this.ids; |
|
294 |
this.$modal.confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?').then(function() { |
|
295 |
return delPost(postIds); |
|
296 |
}).then(() => { |
|
297 |
this.getList(); |
|
298 |
this.$modal.msgSuccess("删除成功"); |
|
299 |
}).catch(() => {}); |
|
300 |
}, |
|
301 |
/** 导出按钮操作 */ |
|
302 |
handleExport() { |
|
303 |
this.download('system/post/export', { |
|
304 |
...this.queryParams |
|
305 |
}, `post_${new Date().getTime()}.xlsx`) |
|
306 |
} |
|
307 |
} |
|
308 |
}; |
|
309 |
</script> |