diff --git a/src/api/card.js b/src/api/card.js index 3c45a80..49177ad 100644 --- a/src/api/card.js +++ b/src/api/card.js @@ -113,3 +113,15 @@ }) } +// 批量导入 +export function batchDelImport(fileobj) { + const param = new FormData() + param.append('file', fileobj) + return request({ + url: 'acsPermission/batchDelImport', + method: 'post', + headers: { 'Content-Type': 'multipart/form-data' }, + data: param + }) +} + diff --git a/src/api/card.js b/src/api/card.js index 3c45a80..49177ad 100644 --- a/src/api/card.js +++ b/src/api/card.js @@ -113,3 +113,15 @@ }) } +// 批量导入 +export function batchDelImport(fileobj) { + const param = new FormData() + param.append('file', fileobj) + return request({ + url: 'acsPermission/batchDelImport', + method: 'post', + headers: { 'Content-Type': 'multipart/form-data' }, + data: param + }) +} + diff --git a/src/views/accessPermission/listDoorPermission.vue b/src/views/accessPermission/listDoorPermission.vue index c9d22c9..22d3399 100644 --- a/src/views/accessPermission/listDoorPermission.vue +++ b/src/views/accessPermission/listDoorPermission.vue @@ -27,6 +27,18 @@ + 批量导入删除 + + + 批量导入 + 门禁授权 重置门禁授权 @@ -77,7 +90,7 @@ import { getDoorPermissionList } from '@/api/access' import { delAllPermission } from '@/api/access' import { getDoorGroupList } from '@/api/door' -import { batchAcsImport } from '@/api/card' +import { batchAcsImport, batchDelImport } from '@/api/card' import { getProject } from '@/utils/baseConfig' import { downloadFile } from '@/utils/downloadUtils' import AreaSelectTree from '@/components/AreaSelect/areaSelectTree' @@ -125,6 +138,7 @@ ], // 显示列 list: [], // 列表数据 fileList: [], + fileDeleteList: [], // 批量导入删除 groupList: [], multipleSelection: [], filename: 'batchAcsInfoTemp.xlsx', @@ -207,6 +221,50 @@ this.canEdit = true }) }, + // 批量导入删除 + uploadDeleteFile(param) { + this.$confirm( + '导入后将删除数据,是否继续?', + '确认操作', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + } + ).then(() => { + // 判断文件大小是否符合要求 + const _file = param.file + const isLt5M = _file.size / 1024 / 1024 < 5 + if (!isLt5M) { + this.$message.error('请上传5M以下的excel文件') + return false + } + // 全屏加载动画 + const loading = this.$loading({ + lock: true, + text: '导入中,请稍后...', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)' + }) + // 发起导入请求 + batchDelImport(_file).then(res => { + loading.close() // 关闭加载动画 + if (res.code === 200) { + // this.$message.success('导入成功') + this.$message.success(`${res.message}`) + this.fileDeleteList = [] + this.fetchData(false) + } + }).catch(() => { + this.fileDeleteList = [] + loading.close() + }) + this.fileDeleteList = [] + }).catch(() => { + this.fileDeleteList = [] + this.canEdit = true + }) + }, // 进入员工授权列表 doorStaffPermission() { this.$router.push({ path: '/listStaffPermission', query: { doorCodes: '', doorName: '', btnshow: true }}) diff --git a/src/api/card.js b/src/api/card.js index 3c45a80..49177ad 100644 --- a/src/api/card.js +++ b/src/api/card.js @@ -113,3 +113,15 @@ }) } +// 批量导入 +export function batchDelImport(fileobj) { + const param = new FormData() + param.append('file', fileobj) + return request({ + url: 'acsPermission/batchDelImport', + method: 'post', + headers: { 'Content-Type': 'multipart/form-data' }, + data: param + }) +} + diff --git a/src/views/accessPermission/listDoorPermission.vue b/src/views/accessPermission/listDoorPermission.vue index c9d22c9..22d3399 100644 --- a/src/views/accessPermission/listDoorPermission.vue +++ b/src/views/accessPermission/listDoorPermission.vue @@ -27,6 +27,18 @@ + 批量导入删除 + + + 批量导入 + 门禁授权 重置门禁授权 @@ -77,7 +90,7 @@ import { getDoorPermissionList } from '@/api/access' import { delAllPermission } from '@/api/access' import { getDoorGroupList } from '@/api/door' -import { batchAcsImport } from '@/api/card' +import { batchAcsImport, batchDelImport } from '@/api/card' import { getProject } from '@/utils/baseConfig' import { downloadFile } from '@/utils/downloadUtils' import AreaSelectTree from '@/components/AreaSelect/areaSelectTree' @@ -125,6 +138,7 @@ ], // 显示列 list: [], // 列表数据 fileList: [], + fileDeleteList: [], // 批量导入删除 groupList: [], multipleSelection: [], filename: 'batchAcsInfoTemp.xlsx', @@ -207,6 +221,50 @@ this.canEdit = true }) }, + // 批量导入删除 + uploadDeleteFile(param) { + this.$confirm( + '导入后将删除数据,是否继续?', + '确认操作', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + } + ).then(() => { + // 判断文件大小是否符合要求 + const _file = param.file + const isLt5M = _file.size / 1024 / 1024 < 5 + if (!isLt5M) { + this.$message.error('请上传5M以下的excel文件') + return false + } + // 全屏加载动画 + const loading = this.$loading({ + lock: true, + text: '导入中,请稍后...', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)' + }) + // 发起导入请求 + batchDelImport(_file).then(res => { + loading.close() // 关闭加载动画 + if (res.code === 200) { + // this.$message.success('导入成功') + this.$message.success(`${res.message}`) + this.fileDeleteList = [] + this.fetchData(false) + } + }).catch(() => { + this.fileDeleteList = [] + loading.close() + }) + this.fileDeleteList = [] + }).catch(() => { + this.fileDeleteList = [] + this.canEdit = true + }) + }, // 进入员工授权列表 doorStaffPermission() { this.$router.push({ path: '/listStaffPermission', query: { doorCodes: '', doorName: '', btnshow: true }}) diff --git a/src/views/accessPermission/listStaffPermission.vue b/src/views/accessPermission/listStaffPermission.vue index 90aeae7..9ed4c78 100644 --- a/src/views/accessPermission/listStaffPermission.vue +++ b/src/views/accessPermission/listStaffPermission.vue @@ -31,6 +31,12 @@ + + + + + + { - this.list = response.data.rows + this.list = response.data.rows.map(item => { + return { + ...item, + statusName: item.status === '1' ? '失败' : item.status === '0' ? '成功' : '未知' + } + }) this.total = parseInt(response.data.total) this.listLoading = false })