From 1a8e5e88a4ba53037d76ea52b409e27106033e6b Mon Sep 17 00:00:00 2001 From: GGJ <357021191@qq.com> Date: Wed, 18 Sep 2024 15:52:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=84=E6=96=99=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/supervision-boot/database/index.ts | 21 + src/api/system-boot/file.ts | 21 +- src/utils/request.ts | 2 + src/views/pqs/database/algorithm/index.vue | 63 ++- .../pqs/database/case/components/annex.vue | 69 +++ .../pqs/database/case/components/drawer.vue | 61 ++- .../pqs/database/case/components/form.vue | 42 -- src/views/pqs/database/case/index.vue | 92 +++- src/views/pqs/database/standard/index.vue | 39 +- src/views/pqs/database/stencil/index.vue | 31 +- src/views/system/bpm/task/todo/index.vue | 477 +++++++++--------- 11 files changed, 588 insertions(+), 330 deletions(-) create mode 100644 src/views/pqs/database/case/components/annex.vue diff --git a/src/api/supervision-boot/database/index.ts b/src/api/supervision-boot/database/index.ts index 7caebb75..d9270d52 100644 --- a/src/api/supervision-boot/database/index.ts +++ b/src/api/supervision-boot/database/index.ts @@ -58,6 +58,27 @@ export const libcaseBeleteyById = (data: any) => { params: data }) } +/** + * 新增标准案例 + */ +export const addStandardCase = (data: any) => { + return createAxios({ + url: '/supervision-boot/libcase/addStandardCase', + method: 'POST', + params: data + }) +} +/** + * 新增标准案例 + */ +export const queryStandardCase = () => { + return createAxios({ + url: '/supervision-boot/libcase/queryStandardCase', + method: 'POST', + + }) +} + /** * 案例库修改 */ diff --git a/src/api/system-boot/file.ts b/src/api/system-boot/file.ts index d78613a7..fc0627ba 100644 --- a/src/api/system-boot/file.ts +++ b/src/api/system-boot/file.ts @@ -1,9 +1,7 @@ import createAxios from '@/utils/request' - const SYSTEM_PREFIX = '/system-boot' - /** * 上传文件 * @param file @@ -22,7 +20,6 @@ export const uploadFile = (file: any, path: string) => { }) } - /** * 删除文件 */ @@ -36,16 +33,17 @@ export const deleteFile = (filePath: string) => { }) } - /** * 下载文件 */ -export const downloadFile = (filePath: string) => { - let form = new FormData() - form.append('filePath', filePath) +export const downloadFile = (filePath: any) => { + // let form = new FormData() + // form.append('filePath', filePath) return createAxios({ url: SYSTEM_PREFIX + '/file/download', - method: 'GET' + method: 'GET', + params: filePath, + responseType: 'blob' }) } @@ -61,14 +59,13 @@ export const getFileUrl = (filePath: string) => { }) } - /** * 根据获取文件的一个短期url及文件名 */ export const getFileNameAndFilePath = (query: any) => { return createAxios({ - url:SYSTEM_PREFIX + '/file/getFileVO', + url: SYSTEM_PREFIX + '/file/getFileVO', method: 'GET', - params:query + params: query }) -} \ No newline at end of file +} diff --git a/src/utils/request.ts b/src/utils/request.ts index a2ad59bf..f8845075 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -64,6 +64,7 @@ function createAxios>( if ( !( config.url == '/system-boot/file/upload' || + config.url == '/harmonic-boot/grid/getAssessOverview' || config.url == '/system-boot/file/getFileVO' || config.url == '/harmonic-boot/gridDiagram/getGridDiagramAreaData' @@ -108,6 +109,7 @@ function createAxios>( Array.isArray(response.data) || response.data.size || response.config.url == '/harmonic-boot/exportmodel/exportModelJB' || + response.config.url == '/system-boot/file/download' || response.config.url == '/harmonic-boot/powerStatistics/exportExcelListTemplate' || response.config.url == '/harmonic-boot/powerStatistics/exportExcelRangTemplate' // || diff --git a/src/views/pqs/database/algorithm/index.vue b/src/views/pqs/database/algorithm/index.vue index 9d910163..aa9e17ba 100644 --- a/src/views/pqs/database/algorithm/index.vue +++ b/src/views/pqs/database/algorithm/index.vue @@ -29,6 +29,7 @@ > 新增 + 删除 @@ -64,11 +65,11 @@ @@ -79,6 +80,24 @@ + + + + + + diff --git a/src/views/pqs/database/case/components/drawer.vue b/src/views/pqs/database/case/components/drawer.vue index 652e5580..b0463dda 100644 --- a/src/views/pqs/database/case/components/drawer.vue +++ b/src/views/pqs/database/case/components/drawer.vue @@ -2,34 +2,75 @@
- - - + + + +
+ + + + +
diff --git a/src/views/pqs/database/case/components/form.vue b/src/views/pqs/database/case/components/form.vue index 92e9bf88..d1b35694 100644 --- a/src/views/pqs/database/case/components/form.vue +++ b/src/views/pqs/database/case/components/form.vue @@ -58,11 +58,6 @@ 上传 - - - 上传 - -
@@ -91,7 +86,6 @@ const dialogVisible = ref(false) const title = ref('') const formRef = ref() const fileList: any = ref([]) -const caseList: any = ref([]) // 注意不要和表单ref的命名冲突 const form = reactive({ type: '', @@ -119,7 +113,6 @@ const open = (text: string, data?: anyObj) => { dialogVisible.value = true if (data) { fileList.value = [] - caseList.value = [] // 表单赋值 for (let key in form) { form[key] = data[key] @@ -135,15 +128,6 @@ const open = (text: string, data?: anyObj) => { }) }) } - - if (data.caseUrl.length > 0) { - getFileNameAndFilePath({ filePath: data.caseUrl }).then(res => { - caseList.value.push({ - name: res.data.fileName, - url: res.data.name - }) - }) - } } else { // 在此处恢复默认表单 for (let key in form) { @@ -180,32 +164,6 @@ const submit = () => { form.url = '' } - if (caseList.value.length > 0) { - const promises = caseList.value.map(async item => { - if (caseList.value[0].raw) { - return new Promise((resolve, reject) => { - uploadFile(item.raw, '/supervision/') - .then((res: any) => { - resolve(res.data.name) - }) - .catch(reject) - }) - } else { - return item.url - } - }) - - try { - const fileNames = await Promise.all(promises) - form.caseUrl = fileNames.join(',') + '' - } catch (error) { - console.error('上传文件出错', error) - return - } - } else { - form.caseUrl = '' - } - setTimeout(() => { if (title.value === '新增案例') { libcaseAdd(form).then(res => { diff --git a/src/views/pqs/database/case/index.vue b/src/views/pqs/database/case/index.vue index e9ca4c30..4d6b85cd 100644 --- a/src/views/pqs/database/case/index.vue +++ b/src/views/pqs/database/case/index.vue @@ -4,6 +4,14 @@
@@ -14,7 +22,9 @@ - + + +
diff --git a/src/views/pqs/database/standard/index.vue b/src/views/pqs/database/standard/index.vue index 63c89416..4eb076dd 100644 --- a/src/views/pqs/database/standard/index.vue +++ b/src/views/pqs/database/standard/index.vue @@ -17,6 +17,7 @@ 新增 修改 删除 + 下载 { const dom = document.getElementById('navigation-splitpanes') if (dom) { @@ -82,7 +83,9 @@ onMounted(() => { const handleNodeClick = (data: any, node: any) => { dotList.value = data url.value = '' + flag.value = false if (data?.url != null && data?.url != '') { + flag.value = true getFileNameAndFilePath({ filePath: data.url }).then(res => { url.value = res.data.url }) @@ -110,6 +113,38 @@ const addUser = () => { const editUser = () => { addTreeRef.value.open('修改', dotList.value) } +// 下载 +const download = () => { + let url = dotList.value.url + let urls = url + let name = url.match(/\/([^/]+)\.(\w+)$/)[1] + downloadFile({ filePath: url }).then((res: any) => { + let blob = new Blob([res], { + type: urls.includes('.pdf') + ? 'application/pdf' + : urls.includes('.docx') + ? 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' + : urls.includes('.xls') + ? 'application/vnd.ms-excel' + : urls.includes('.xlsx') + ? 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + : urls.includes('.png') + ? 'image/png' + : urls.includes('.jpeg') + ? 'image/jpeg' + : urls.includes('.jpg') + ? 'image/jpg' + : '' + }) + const url = window.URL.createObjectURL(blob) + const link = document.createElement('a') + link.href = url + link.download = name + document.body.appendChild(link) + link.click() + link.remove() + }) +}