applications/task-work-order/src/views/orderView/organizational/agenciesManagement/agenciesApi.js
@@ -57,10 +57,11 @@ } // 导出模板 export const agenciesExportTemplateApi = () => { export const agenciesExportTemplateApi = params => { return request({ url: `/blade-system/dept/export-template`, method: 'get', params, responseType: 'blob', }) } applications/task-work-order/src/views/orderView/organizational/agenciesManagement/index.vue
@@ -53,7 +53,8 @@ <div class="gd-table-container" v-loading="loading"> <div class="gd-table-content gd-table-content-bg"> <el-table class="gd-table" :data="list"> <el-table class="gd-table" :data="list" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="46" /> <el-table-column label="序号" width="80"> <template v-slot="{ $index }"> {{ $index + 1 }} @@ -98,8 +99,8 @@ class="gd-dialog" append-to-body v-model="isShowImportView" title="导入机构" :width="pxToRem(600)" title="机构导入" :width="pxToRem(500)" :close-on-click-modal="false" :destroy-on-close="true" @close="handleImportClose" @@ -115,10 +116,13 @@ </el-button> </el-form-item> <el-form-item label="上传文件" prop="file"> {{ importFileName }} <el-upload class="avatar-uploader" action="" :show-file-list="false" :before-upload="onImportFileBefore"> <el-button type="primary">点击上传</el-button> </el-upload> <div class="upload-tip"> {{ importFileName }} </div> </el-form-item> </el-form> <template #footer> @@ -171,6 +175,7 @@ const dialogVisible = ref(false) const regionOptions = ref([]) // 区域选项 const dictObj = ref({}) // 字典对象 const selectedFiles = ref([]) // 勾选的文件列表 // 树形选择器配置 const treeSelectProps = { @@ -178,8 +183,6 @@ label: 'name', children: 'children' } // 导入机构相关 const isShowImportView = ref(false) const importFileName = ref('') @@ -321,6 +324,11 @@ } } // 勾选值设置 function handleSelectionChange(rows) { selectedFiles.value = rows } // 导出模板 async function handleExportTemplate() { templateExportLoading.value = true @@ -344,9 +352,6 @@ // 上传文件前处理 function onImportFileBefore(file) { // 提示请先导出模板 // ElMessage.warning('请先导出模板并按模板格式填写数据') // 检查文件类型 const allowedTypes = ['.xlsx', '.xls'] const fileExtension = file.name.substring(file.name.lastIndexOf('.')).toLowerCase() @@ -354,21 +359,11 @@ ElMessage.error('请上传Excel文件(.xlsx 或 .xls)') return false } let data = new FormData() data.append('file', file) agenciesImportApi(data, { isCovered: importParams.value.isCovered }).then(res => { if (res.data.code === 200) { ElMessage.success('导入成功') // 保存文件名 importFileName.value = file.name importParams.value.file = file isShowImportView.value = false getList() } else { ElMessage.error(res.msg || '导入失败') } }) // 保存文件名和文件对象 importFileName.value = file.name importParams.value.file = file ElMessage.success('上传成功') return false // 阻止组件的默认上传行为 } @@ -384,8 +379,19 @@ ElMessage.error('请先上传文件') return } // 触发上传操作 await onImportFileBefore(importParams.value.file) // 构建表单数据并调用导入接口 let data = new FormData() data.append('file', importParams.value.file) const res = await agenciesImportApi(data, { isCovered: importParams.value.isCovered }) if (res.data.code === 200) { ElMessage.success('导入成功') isShowImportView.value = false getList() } else { ElMessage.error(res.msg || '导入失败') } } finally { importSubmitting.value = false } @@ -395,15 +401,26 @@ // 导出机构 async function handleExport() { // 检查是否有选中的数据 if (selectedFiles.value.length === 0) { ElMessage.warning('请选择要导出的机构') return } exportLoading.value = true try { const res = await agenciesExportApi(searchParams.value) const params = {} params.deptIds = selectedFiles.value.map(i => i.id) // 调用导出API const res = await agenciesExportApi(params) const blob = new Blob([res.data]) const url = URL.createObjectURL(blob) const a = document.createElement('a') a.href = url // `机构列表${new Date().getTime()}.xlsx` a.download = `机构列表.xlsx` // `机构列表${new Date().getTime()}.xlsx` const fileName = `机构列表.xlsx` a.download = fileName document.body.appendChild(a) a.click() document.body.removeChild(a) @@ -422,4 +439,7 @@ </script> <style scoped lang="scss"> .upload-tip { margin-left: 5px; } </style> applications/task-work-order/src/views/orderView/organizational/zoningManagement/index.vue
@@ -45,7 +45,8 @@ <div class="gd-table-container" v-loading="loading"> <div class="gd-table-content gd-table-content-bg"> <el-table class="gd-table" :data="list"> <el-table class="gd-table" :data="list" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="46" /> <el-table-column label="序号" width="80"> <template v-slot="{ $index }"> {{ $index + 1 }} @@ -95,16 +96,14 @@ class="gd-dialog" append-to-body v-model="isShowImportView" title="导入区划" :width="pxToRem(600)" title="区划导入" :width="pxToRem(500)" :close-on-click-modal="false" :destroy-on-close="true" @close="handleImportClose" > <el-form class="gd-dialog-form" ref="importFormRef" :model="importParams" :rules="importRules" label-width="140px"> <el-form-item label="导出模板"> <!-- :loading="templateExportLoading" :disabled="templateExportLoading" --> <el-button type="primary" color="#F2F3F5" @@ -114,10 +113,12 @@ </el-button> </el-form-item> <el-form-item label="上传文件" prop="file"> {{ importFileName }} <el-upload class="avatar-uploader" action="" :show-file-list="false" :before-upload="onImportFileBefore"> <el-button type="primary">点击上传</el-button> </el-upload> <div class="upload-tip"> {{ importFileName }} </div> </el-form-item> </el-form> <template #footer> @@ -169,6 +170,7 @@ const dialogVisible = ref(false) const regionOptions = ref([]) // 区域选项 const dictObj = ref({}) // 字典对象 const selectedFiles = ref([]) // 勾选的文件列表 // 导入区划相关 const isShowImportView = ref(false) @@ -281,6 +283,11 @@ } } // 勾选值设置 function handleSelectionChange(rows) { selectedFiles.value = rows } // 导出模板 async function handleExportTemplate() { templateExportLoading.value = true @@ -304,9 +311,6 @@ // 上传文件前处理 function onImportFileBefore(file) { // 提示请先导出模板 // ElMessage.warning('请先导出模板并按模板格式填写数据') // 检查文件类型 const allowedTypes = ['.xlsx', '.xls'] const fileExtension = file.name.substring(file.name.lastIndexOf('.')).toLowerCase() @@ -314,21 +318,11 @@ ElMessage.error('请上传Excel文件(.xlsx 或 .xls)') return false } let data = new FormData() data.append('file', file) zoningImportApi(data, { isCovered: importParams.value.isCovered }).then(res => { if (res.data.code === 200) { ElMessage.success('导入成功') // 保存文件名 importFileName.value = file.name importParams.value.file = file isShowImportView.value = false getList() } else { ElMessage.error(res.msg || '导入失败') } }) // 保存文件名和文件对象 importFileName.value = file.name importParams.value.file = file ElMessage.success('上传成功') return false // 阻止组件的默认上传行为 } @@ -344,8 +338,18 @@ ElMessage.error('请先上传文件') return } // 触发上传操作 await onImportFileBefore(importParams.value.file) // 构建表单数据并调用导入接口 let data = new FormData() data.append('file', importParams.value.file) const res = await zoningImportApi(data, { isCovered: importParams.value.isCovered }) if (res.data.code === 200) { ElMessage.success('导入成功') isShowImportView.value = false getList() } else { ElMessage.error(res.msg || '导入失败') } } finally { importSubmitting.value = false } @@ -355,14 +359,25 @@ // 导出区划 async function handleExport() { // 检查是否有选中的数据 if (selectedFiles.value.length === 0) { ElMessage.warning('请选择要导出的区划') return } exportLoading.value = true try { const res = await zoningExportApi(searchParams.value) const params = {} params.regionIds = selectedFiles.value.map(i => i.id) // 调用导出API const res = await zoningExportApi(params) const blob = new Blob([res.data]) const url = URL.createObjectURL(blob) const a = document.createElement('a') a.href = url a.download = `区划列表.xlsx` const fileName = `区划列表.xlsx` a.download = fileName document.body.appendChild(a) a.click() document.body.removeChild(a) @@ -381,4 +396,7 @@ </script> <style scoped lang="scss"> .upload-tip { margin-left: 5px; } </style> applications/task-work-order/src/views/orderView/organizational/zoningManagement/zoningApi.js
@@ -57,10 +57,11 @@ } // 导出模板 export const zoningExportTemplateApi = () => { export const zoningExportTemplateApi = params => { return request({ url: `/blade-system/region/export-template`, method: 'get', params, responseType: 'blob', }) }