diff --git a/.env b/.env index dc10f1a..c77e1d9 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ VITE_BASE_API = '/remoteServer/admin-api/' VITE_BASE_API_SYSTEM = '/remoteServer/admin-api/system/' VITE_SHOW_ONLINE_DEVICE = true -VITE_BASE_URL = 'http://43.140.245.32:48089' \ No newline at end of file +VITE_BASE_URL = 'http://192.168.1.63:48089' \ No newline at end of file diff --git a/global.types/components.d.ts b/global.types/components.d.ts index 137173c..4813ee4 100644 --- a/global.types/components.d.ts +++ b/global.types/components.d.ts @@ -18,6 +18,8 @@ declare module 'vue' { EdfsWrap: typeof import('./../src/components/Edfs-wrap.vue')['default'] ElAside: typeof import('element-plus/es')['ElAside'] ElButton: typeof import('element-plus/es')['ElButton'] + ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] + ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup'] ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider'] ElContainer: typeof import('element-plus/es')['ElContainer'] ElDialog: typeof import('element-plus/es')['ElDialog'] diff --git a/src/api/module/device/category.ts b/src/api/module/device/category.ts index 53d51ca..45ce8b2 100644 --- a/src/api/module/device/category.ts +++ b/src/api/module/device/category.ts @@ -17,7 +17,7 @@ export const createDeviceType = (params: IDeviceCategoryOV & IDeviceBase) => { }) } -export const uploadDeviceTypeFile = (params: { file: File, projectName: string, fileName: string }, abort: AbortController) => { +export const uploadDeviceTypeFile = (params: { file: File, projectName: string, fileName: string, pointName: string }, abort: AbortController) => { return globalServer({ url: '/project/point/import-file', method: 'post', @@ -26,4 +26,15 @@ export const uploadDeviceTypeFile = (params: { file: File, projectName: string, headers: { 'Content-Type': 'multipart/form-data' }, timeout: 0, }) -} \ No newline at end of file +} + + + +export const downloadDeviceTypeFile = (params: { projectName: string, pointName: string }) => { + return globalServer({ + url: '/project/point/download-excel', + method: 'get', + params, + responseType: 'blob', + }) +} diff --git a/src/api/module/engineering/index.ts b/src/api/module/engineering/index.ts index 8cd8a6e..05d6ec8 100644 --- a/src/api/module/engineering/index.ts +++ b/src/api/module/engineering/index.ts @@ -19,3 +19,20 @@ export const getEngineeringList = ( params, }) } + + +export const deleteEngineering = (params: { name: string }) => { + return globalServer({ + url: 'project/delete', + method: 'delete', + params, + }) +} + +export const deleteEngineeringBatch = (names: string[]) => { + return globalServer({ + url: 'project/delete-list', + method: 'delete', + params: names.join(','), + }) +} diff --git a/src/views/engineering/config/components/StepDeviceCategory.vue b/src/views/engineering/config/components/StepDeviceCategory.vue index cb5053e..be19cd8 100644 --- a/src/views/engineering/config/components/StepDeviceCategory.vue +++ b/src/views/engineering/config/components/StepDeviceCategory.vue @@ -65,17 +65,24 @@
- 点表文件 + 点表文件: - + {{ fileName || '-' }} +
+ 下载 +
@@ -101,7 +108,7 @@ :show-file-list="false" :disabled="uploadingStates[fileName]" :on-change=" - (file: any) => handleFileChange(file, fileName as string) + (file: any) => handleFileChange(file, fileName as string, categoryName) " > import { ref, reactive, computed, watch } from 'vue' import { useRoute } from 'vue-router' -import { UploadFilled, Plus } from '@element-plus/icons-vue' +import { UploadFilled, Plus, Download } from '@element-plus/icons-vue' import type { IDeviceCategoryList, IDeviceCategoryOV } from '@/api/module/device/index.d' import type { FormInstance, FormRules, UploadFile } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus' -import { createDeviceType, uploadDeviceTypeFile } from '@/api/module/device/category' +import { + createDeviceType, + uploadDeviceTypeFile, + downloadDeviceTypeFile, +} from '@/api/module/device/category' import { ChannelEnum } from '@/api/module/channel/index' import type { IChannelOV } from '@/api/module/channel/index.d' import { validateName } from '@/utils/validate' @@ -278,7 +289,11 @@ const setUploadRef = (el: any, key: string) => { } } -const handleFileChange = async (file: UploadFile, fileName: string) => { +const handleFileChange = async ( + file: UploadFile, + fileName: string, + categoryName: string, +) => { if (!file.raw) return const controller = new AbortController() uploadControllers[fileName] = controller @@ -290,6 +305,7 @@ const handleFileChange = async (file: UploadFile, fileName: string) => { file: file.raw, projectName: projectName.value, fileName: fileName, + pointName: categoryName, }, controller, ) @@ -331,6 +347,30 @@ const cancelAllUploads = () => { }) } +async function handleDownload(pointName: string) { + try { + const res = await fetch( + `/remoteServer/admin-api/project/point/download-excel?projectName=${projectName.value}&pointName=${pointName}`, + ) + debugger + // 检查响应是否成功 + if (!res.ok) { + throw new Error('Network response was not ok') + } + const blob = await res.blob() + const link = document.createElement('a') + link.style.display = 'none' + link.href = URL.createObjectURL(blob) + link.download = `${pointName}.xlsx` + document.body.appendChild(link) + link.click() + document.body.removeChild(link) + URL.revokeObjectURL(link.href) + } catch (error) { + ElMessage.error('下载出现错误') + } +} + // Check before leaving step const checkBeforeLeave = async (): Promise => { if (!hasUploadingFiles()) { diff --git a/src/views/engineering/index.vue b/src/views/engineering/index.vue index 9f9e4ba..6828d50 100644 --- a/src/views/engineering/index.vue +++ b/src/views/engineering/index.vue @@ -1,7 +1,22 @@