From c1ae3394f9a888cef504bf3a7cd8397b78a24238 Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Fri, 7 Jun 2024 17:30:25 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=A2=E6=A0=A1=E6=8B=9B=E5=BD=95=E4=B8=93?= =?UTF-8?q?=E4=B8=9A-=E5=8A=A0=E5=85=A5=E5=86=85=E9=83=A8=E5=BD=95?= =?UTF-8?q?=E5=8F=96=E6=96=B9=E5=BC=8F=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yx/yxSchoolMajor/YxSchoolMajorList.vue | 74 ++++++++++++++++--- 1 file changed, 64 insertions(+), 10 deletions(-) diff --git a/src/views/yx/yxSchoolMajor/YxSchoolMajorList.vue b/src/views/yx/yxSchoolMajor/YxSchoolMajorList.vue index 6b46134..6315bbd 100644 --- a/src/views/yx/yxSchoolMajor/YxSchoolMajorList.vue +++ b/src/views/yx/yxSchoolMajor/YxSchoolMajorList.vue @@ -52,11 +52,9 @@ - 查询 - - 重置 - + 查询 + 导出 + 重置 @@ -94,7 +92,7 @@ import {defHttp} from '/@/utils/http/axios'; import {JVxeColumn, JVxeTypes} from '/@/components/jeecg/JVxeTable/types'; import {useMessage} from '/@/hooks/web/useMessage'; import { useListPage } from '/@/hooks/system/useListPage'; - +import {XLSX_FILE_SUFFIX, XLSX_MIME_TYPE} from "@/hooks/system/useMethods"; const labelCol = reactive({ xs: {span: 24}, sm: {span: 7}, @@ -200,23 +198,35 @@ const columns = ref([ type: JVxeTypes.input, }, { - title: '录取方式缩写(文x专y)', + title: '录取方式缩写(用于筛选条件)', key: 'rulesEnrollProbabilitySx', width: 150, type: JVxeTypes.input, }, { - title: '录取方式(文*x+专*y)', + title: '对外录取方式', key: 'rulesEnrollProbability', width: 150, type: JVxeTypes.input, }, { - title: '录取概率计算规则运算符', + title: '对外录取方式运算符', key: 'probabilityOperator', width: 150, type: JVxeTypes.input, }, + { + title: '内部录取方式', + key: 'privateRulesEnrollProbability', + width: 150, + type: JVxeTypes.input, + }, + { + title: '内部录取方式运算符', + key: 'privateProbabilityOperator', + width: 150, + type: JVxeTypes.input, + }, { title: '批次', key: 'batch', @@ -312,6 +322,7 @@ enum Api { // 模拟保存整个表格的数据 saveAll = '/yx/yxSchoolMajor/saveBatch', deleteBatch = '/yx/yxSchoolMajor/deleteBatch', + exportXls = '/yx/yxSchoolMajor/exportXls', } loadData(); @@ -452,7 +463,7 @@ function handleEditClosed(event) { } } -// 当分页参数变化时触发的事件 + // 当分页参数变化时触发的事件 function handlePageChange(event) { // 重新赋值 pagination.current = event.current; @@ -465,6 +476,49 @@ function handlePageChange(event) { function handleSelectRowChange(event) { selectedRows.value = event.selectedRows; } + +/** + * 导出xls + * @param name + * @param url + */ +async function exportXls(isXlsx = false) { + let name = '' + let selections = '' + if (selectedRows.value) { + selectedRows.value.forEach(i=>{ + selections+=i.id+"," + }) + console.log(selectedRows.value) + } + const data = await defHttp.get({ url: Api.exportXls, params: {selections:selections}, responseType: 'blob', timeout: 60000 }, { isTransformResponse: false }); + if (!data) { + createMessage.warning('文件下载失败'); + return; + } + if (!name || typeof name != 'string') { + name = '导出文件'; + } + let blobOptions = { type: 'application/vnd.ms-excel' }; + let fileSuffix = '.xls'; + if (isXlsx === true) { + blobOptions['type'] = XLSX_MIME_TYPE; + fileSuffix = XLSX_FILE_SUFFIX; + } + if (typeof window.navigator.msSaveBlob !== 'undefined') { + window.navigator.msSaveBlob(new Blob([data], blobOptions), name + fileSuffix); + } else { + let url = window.URL.createObjectURL(new Blob([data], blobOptions)); + let link = document.createElement('a'); + link.style.display = 'none'; + link.href = url; + link.setAttribute('download', name + fileSuffix); + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); //下载完成移除元素 + window.URL.revokeObjectURL(url); //释放掉blob对象 + } +}