From 0b269c539f53fda21dd786deb26e45882edeadd4 Mon Sep 17 00:00:00 2001
From: kongdeqiang <123456>
Date: 星期一, 23 三月 2026 11:39:18 +0800
Subject: [PATCH] fix: 更新系统
---
src/views/data/Excel.vue | 77 +++++++++++++++++++++++++++++++++++++-
1 files changed, 74 insertions(+), 3 deletions(-)
diff --git a/src/views/data/Excel.vue b/src/views/data/Excel.vue
index d56d5fe..93cd808 100644
--- a/src/views/data/Excel.vue
+++ b/src/views/data/Excel.vue
@@ -21,8 +21,21 @@
</template>
<el-form :inline="true" :model="searchForm" class="search-form">
- <el-form-item label="鍗曚綅鍚嶇О">
- <el-input v-model="searchForm.unitName" placeholder="璇疯緭鍏ュ崟浣嶅悕绉�" clearable />
+ <el-form-item label="鍗曚綅">
+ <el-select
+ v-model="searchForm.unitCode"
+ placeholder="璇烽�夋嫨鍗曚綅"
+ clearable
+ filterable
+ style="width: 250px"
+ >
+ <el-option
+ v-for="dept in flatDepartmentList"
+ :key="dept.deptCode"
+ :label="`${dept.deptCode} - ${dept.deptName}`"
+ :value="dept.deptCode"
+ />
+ </el-select>
</el-form-item>
<el-form-item label="浜ゆ槗娴佹按鍙�">
<el-input v-model="searchForm.transactionNo" placeholder="璇疯緭鍏ヤ氦鏄撴祦姘村彿" clearable />
@@ -195,8 +208,9 @@
</template>
<script setup>
-import { ref, reactive, onMounted } from 'vue'
+import {ref, reactive, onMounted, computed} from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
+import { getDepartmentTree } from '@/api/department'
import { Plus, Edit, Delete, Search, Refresh, Upload, Download } from '@element-plus/icons-vue'
import { getExcelPage, createExcel, updateExcel, deleteExcel, importExcel, downloadTemplate } from '@/api/excel'
@@ -206,9 +220,11 @@
const dialogTitle = ref('')
const formRef = ref(null)
const uploadRef = ref(null)
+const departmentList = ref([])
const searchForm = reactive({
unitName: '',
+ unitCode: '',
transactionNo: '',
accountingPeriod: ''
})
@@ -243,6 +259,60 @@
const rules = {
unitName: [{ required: true, message: '璇疯緭鍏ュ崟浣嶅悕绉�', trigger: 'blur' }],
transactionNo: [{ required: true, message: '璇疯緭鍏ヤ氦鏄撴祦姘村彿', trigger: 'blur' }]
+}
+
+const flatDepartmentList = computed(() => {
+ const flatten = (list) => {
+ let result = []
+ list.forEach(item => {
+ result.push(item)
+ if (item.children && item.children.length > 0) {
+ result = result.concat(flatten(item.children))
+ }
+ })
+ return result
+ }
+ return flatten(departmentList.value)
+})
+
+const fetchDepartmentList = async () => {
+ try {
+ const res = await getDepartmentTree()
+ departmentList.value = buildTree(res.data)
+ } catch (error) {
+ console.error('鑾峰彇閮ㄩ棬鍒楄〃澶辫触:', error)
+ }
+}
+
+const buildTree = (list) => {
+ const map = {}
+ const roots = []
+
+ list.forEach(item => {
+ map[item.deptCode] = { ...item, children: [] }
+ })
+
+ list.forEach(item => {
+ const parent = map[item.parentCode]
+ if (parent) {
+ parent.children.push(map[item.deptCode])
+ } else {
+ roots.push(map[item.deptCode])
+ }
+ })
+
+ const cleanEmptyChildren = (nodes) => {
+ nodes.forEach(node => {
+ if (node.children && node.children.length === 0) {
+ delete node.children
+ } else {
+ cleanEmptyChildren(node.children)
+ }
+ })
+ }
+
+ cleanEmptyChildren(roots)
+ return roots
}
const formatAmount = (amount) => {
@@ -409,6 +479,7 @@
}
onMounted(() => {
+ fetchDepartmentList()
fetchData()
})
</script>
--
Gitblit v1.9.1