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对象 + } +}