Browse Source

fit: 导入警员

main
wxc 1 year ago
parent
commit
42b92c1cae
  1. 16
      src/utils/feedback.ts
  2. 53
      src/views/system/Police.vue

16
src/utils/feedback.ts

@ -19,15 +19,25 @@ export class Feedback {
}
// 错误消息
msgError(msg: string) {
ElMessage.error(msg)
ElMessage.error({
message: msg,
type: 'error',
duration: 5000
})
}
// 成功消息
msgSuccess(msg: string) {
ElMessage.success(msg)
ElMessage.success({
message: msg,
type: 'success'
})
}
// 警告消息
msgWarning(msg: string) {
ElMessage.warning(msg)
ElMessage.warning({
message: msg,
type: 'warning'
})
}
// 弹出提示
alert(msg: string) {

53
src/views/system/Police.vue

@ -78,7 +78,7 @@
</el-row>
</el-form>
<div class="mb-25 flex between">
<div>
<div class="flex gap">
<el-button
type="primary"
@click="handleAdd"
@ -89,6 +89,37 @@
</template>
新增警员</el-button
>
<el-upload
:multiple="false"
:show-file-list="false"
:action="`${BASE_PATH}/police/import`"
:headers="{ Authorization: getToken() }"
:before-upload="beforeUpload"
@success="handleSuccess"
@error="handleError"
accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
v-perms="['police:import']"
>
<el-button
type="primary"
>
<template #icon>
<icon name="el-icon-Upload" />
</template>
导入警员</el-button
>
</el-upload>
<a
class="link"
:href="`${BASE_PATH}/templates/数字督察警员权限导入模板.xlsx`"
target="__blank"
style="padding: 8px"
v-perms="['police:import']"
>数字督察警员权限导入模板</a
>
</div>
<div>
<el-button type="primary" @click="getList">
@ -445,6 +476,8 @@
</el-dialog>
</template>
<script setup>
import { BASE_PATH } from "@/api/request";
import { getToken } from "@/utils/token";
import { UserFilled } from "@element-plus/icons-vue";
import {
listPolice,
@ -584,6 +617,24 @@ async function handleDel(row) {
feedback.msgSuccess("操作成功");
getList();
}
import { ElLoading } from "element-plus";
let importLoading;
function beforeUpload() {
importLoading = ElLoading.service({
lock: true,
text: "数据导入中",
background: "rgba(0, 0, 0, 0.7)",
});
}
function handleSuccess(result) {
importLoading.close();
getList()
}
function handleError(result) {
importLoading.close();
feedback.msgError(result.msg || "上传失败!");
}
</script>
<style lang="scss" scoped>
</style>
Loading…
Cancel
Save