From 6c4bd2467bb6651c6edcf8a9741dcd4e9b1aa6d3 Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Fri, 30 Jan 2026 14:42:36 +0800
Subject: [PATCH] feat:权限按钮
---
applications/task-work-order/src/views/orderView/organizational/agenciesManagement/index.vue | 92 +++++++++++++++++++++++++++++----------------
1 files changed, 59 insertions(+), 33 deletions(-)
diff --git a/applications/task-work-order/src/views/orderView/organizational/agenciesManagement/index.vue b/applications/task-work-order/src/views/orderView/organizational/agenciesManagement/index.vue
index 457e203..ba5a2c2 100644
--- a/applications/task-work-order/src/views/orderView/organizational/agenciesManagement/index.vue
+++ b/applications/task-work-order/src/views/orderView/organizational/agenciesManagement/index.vue
@@ -48,7 +48,7 @@
<div class="gd-table-toolbar">
<el-button :icon="Plus" color="#4C34FF" type="primary" @click="openForm('add')">新增机构</el-button>
<el-button :icon="Upload" @click="handleImport">导入机构</el-button>
- <el-button :icon="Download" @click="handleExport">导出机构</el-button>
+ <el-button :icon="Download" :loading="exportLoading" :disabled="exportLoading" @click="handleExport">导出机构</el-button>
</div>
<div class="gd-table-container" v-loading="loading">
@@ -56,7 +56,7 @@
<el-table class="gd-table" :data="list">
<el-table-column label="序号" width="80">
<template v-slot="{ $index }">
- {{ ((searchParams.current - 1) * searchParams.size + $index + 1).toString().padStart(2, '0') }}
+ {{ $index + 1 }}
</template>
</el-table-column>
<el-table-column prop="deptCode" show-overflow-tooltip label="机构编码" />
@@ -68,7 +68,7 @@
{{ getDictLabel(row.status, dictObj.institutionStatus) }}
</template>
</el-table-column>
- <el-table-column label="操作" class-name="operation-btns" width="310">
+ <el-table-column label="操作" class-name="operation-btns" width="200">
<template v-slot="{ row }">
<el-link type="primary" @click="openForm('view', row)">查看</el-link>
<el-link type="primary" @click="openForm('edit', row)">编辑</el-link>
@@ -105,17 +105,26 @@
@close="handleImportClose"
>
<el-form class="gd-dialog-form" ref="importFormRef" :model="importParams" :rules="importRules" label-width="140px">
+ <el-form-item label="导出模板">
+ <el-button
+ color="#F2F3F5"
+ type="primary"
+ @click="handleExportTemplate"
+ >
+ 点击导出
+ </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 size="small" type="primary">点击上传</el-button>
+ <el-button type="primary">点击上传</el-button>
</el-upload>
</el-form-item>
</el-form>
<template #footer>
<el-button color="#F2F3F5" @click="isShowImportView = false">取消</el-button>
<el-button
- class=""
+
color="#4C34FF"
:loading="importSubmitting"
:disabled="importSubmitting"
@@ -138,6 +147,7 @@
agenciesRemoveApi,
agenciesImportApi,
agenciesExportApi,
+ agenciesExportTemplateApi,
regionLazyTreeApi,
agenciesSubmitApi
} from './agenciesApi'
@@ -183,6 +193,12 @@
file: [{ required: true, message: '请上传文件', trigger: ['change'] }],
})
+// 导出加载状态
+const exportLoading = ref(false)
+
+// 模板导出加载状态
+const templateExportLoading = ref(false)
+
provide('regionOptions', regionOptions)
provide('dictObj', dictObj)
@@ -197,8 +213,9 @@
async function loadRegionNode(node, resolve) {
try {
- const parentCode = node.data?.id || '360800000000'
- const res = await regionLazyTreeApi({ parentCode })
+ // 初始化加载时传递 code 参数,加载子节点时传递 parentCode 参数
+ const params = node.data?.id ? { parentCode: node.data.id } : { code: '360800000000' }
+ const res = await regionLazyTreeApi(params)
const nodes = res?.data?.data || []
// 处理返回的节点数据
@@ -216,27 +233,6 @@
resolve([])
}
}
-
-// 获取初始区域数据(根节点)
-async function getRegionList() {
- try {
- // 懒加载模式下,只需要初始化根节点
- const res = await regionLazyTreeApi({ parentCode: '360800000000' })
- const nodes = res?.data?.data || []
-
- // 处理根节点数据
- regionOptions.value = nodes.map(item => {
- return {
- id: item.id || item.value,
- name: item.name || item.title || item.label,
- hasChildren: item.hasChildren || false
- }
- })
- } catch (error) {
- console.error('获取区域数据失败:', error)
- }
-}
-
// 获取列表
async function getList() {
loading.value = true
@@ -319,8 +315,32 @@
}
}
+// 导出模板
+async function handleExportTemplate() {
+ templateExportLoading.value = true
+ try {
+ const res = await agenciesExportTemplateApi()
+ const blob = new Blob([res.data])
+ const url = URL.createObjectURL(blob)
+ const a = document.createElement('a')
+ a.href = url
+ a.download = `机构导入模板.xlsx`
+ document.body.appendChild(a)
+ a.click()
+ document.body.removeChild(a)
+ URL.revokeObjectURL(url)
+ } catch (error) {
+ console.error('导出模板失败:', error)
+ } finally {
+ templateExportLoading.value = false
+ }
+}
+
// 上传文件前处理
function onImportFileBefore(file) {
+ // 提示请先导出模板
+ // ElMessage.warning('请先导出模板并按模板格式填写数据')
+
// 检查文件类型
const allowedTypes = ['.xlsx', '.xls']
const fileExtension = file.name.substring(file.name.lastIndexOf('.')).toLowerCase()
@@ -368,23 +388,29 @@
}
// 导出机构
-function handleExport() {
- agenciesExportApi(searchParams.value).then(res => {
+async function handleExport() {
+ exportLoading.value = true
+ try {
+ const res = await agenciesExportApi(searchParams.value)
const blob = new Blob([res.data])
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
- a.download = `机构列表${new Date().getTime()}.xlsx`
+ // `机构列表${new Date().getTime()}.xlsx`
+ a.download = `机构列表.xlsx`
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
URL.revokeObjectURL(url)
- })
+ } catch (error) {
+ console.error('导出失败:', error)
+ } finally {
+ exportLoading.value = false
+ }
}
onMounted(() => {
getDictList()
- getRegionList()
getList()
})
</script>
--
Gitblit v1.9.3