From 365794ab8bfc897a9c6d28c590f9e12caa9ce4ce Mon Sep 17 00:00:00 2001 From: bb_pan Date: Tue, 21 Jan 2025 18:12:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/deviceManagement/index.js | 31 ++ src/main.js | 3 +- src/utils/request.js | 29 ++ .../streamingConfiguration/index.vue | 4 +- .../videoDeviceMgmt/index.vue | 285 ++++++++++-------- 5 files changed, 217 insertions(+), 135 deletions(-) create mode 100644 src/api/deviceManagement/index.js diff --git a/src/api/deviceManagement/index.js b/src/api/deviceManagement/index.js new file mode 100644 index 00000000..49a36598 --- /dev/null +++ b/src/api/deviceManagement/index.js @@ -0,0 +1,31 @@ +import request from '@/utils/request'; + +// 获取视频设备列表 +export const getList = (params) => { + return request.get('/smart-site/video_equipment/list', { params }); +}; + +// 获取设备类型列表 +export const getTypeList = (data) => { + return request.post('/smart-site/video_equipment/getTypeList', data); +}; + +// 新增视频设备 +export const addVideoDevice = (data) => { + return request.post('/smart-site/video_equipment/add', data); +}; + +// 编辑视频设备 +export const editVideoDevice = (data) => { + return request.post('/smart-site/video_equipment/edit', data); +}; + +// 删除视频设备 +export const delVideoDevice = (id) => { + return request.post(`/smart-site/video_equipment/del/${id}`); +}; + +// 获取视频设备详情 +export const getVideoDeviceDetail = (id) => { + return request.get(`/smart-site/video_equipment/${id}`); +}; \ No newline at end of file diff --git a/src/main.js b/src/main.js index cc8e4833..329c2736 100644 --- a/src/main.js +++ b/src/main.js @@ -12,7 +12,7 @@ import store from './store' import router from './router' import directive from './directive' // directive import plugins from './plugins' // plugins -import { download } from '@/utils/request' +import { download, derive } from '@/utils/request' import './assets/icons' // icon import './permission' // permission control @@ -56,6 +56,7 @@ Vue.prototype.addDateRange = addDateRange Vue.prototype.selectDictLabel = selectDictLabel Vue.prototype.selectDictLabels = selectDictLabels Vue.prototype.download = download +Vue.prototype.derive = derive Vue.prototype.handleTree = handleTree Vue.prototype.indexContinuation = indexContinuation diff --git a/src/utils/request.js b/src/utils/request.js index 7d2be68e..cfa6377f 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -184,4 +184,33 @@ export function download(url, params, filename, config) { }) } +// 通用导出方法 +export function derive(url, params, filename, config) { + downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }) + return service.post(url, JSON.stringify(params), { + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + 'encryption': 'encryption' + }, + responseType: 'blob', + ...config + }).then(async (data) => { + const isBlob = blobValidate(data); + if (isBlob) { + const blob = new Blob([data]) + saveAs(blob, filename) + } else { + const resText = await data.text(); + const rspObj = JSON.parse(resText); + const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'] + Message.error(errMsg); + } + downloadLoadingInstance.close(); + }).catch((r) => { + console.error(r) + Message.error('下载文件出现错误,请联系管理员!') + downloadLoadingInstance.close(); + }) +} + export default service diff --git a/src/views/deviceManagement/streamingConfiguration/index.vue b/src/views/deviceManagement/streamingConfiguration/index.vue index d1d5955b..8a7b5823 100644 --- a/src/views/deviceManagement/streamingConfiguration/index.vue +++ b/src/views/deviceManagement/streamingConfiguration/index.vue @@ -136,8 +136,8 @@ - 取 消 - 确 定 + {{ isDetail ? '关 闭' : '取 消' }} + 确 定 diff --git a/src/views/deviceManagement/videoDeviceMgmt/index.vue b/src/views/deviceManagement/videoDeviceMgmt/index.vue index 51411d18..5aa33eda 100644 --- a/src/views/deviceManagement/videoDeviceMgmt/index.vue +++ b/src/views/deviceManagement/videoDeviceMgmt/index.vue @@ -10,8 +10,8 @@ @keyup.enter.native="handleQuery" /> - - + + @@ -48,13 +48,13 @@ -