| | |
| | | /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="机构编码" prop="bindCode"> |
| | | <el-form-item label="机构编码" prop="deptCode"> |
| | | <el-input |
| | | class="gd-input gray" |
| | | v-model="searchParams.bindCode" |
| | | v-model="searchParams.deptCode" |
| | | placeholder="请输入" |
| | | clearable |
| | | @clear="handleSearch" |
| | |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="所属区划" prop="areaCode"> |
| | | <el-select |
| | | <el-tree-select |
| | | class="gd-select gray" |
| | | popper-class="gd-select-popper" |
| | | popper-class="gd-tree-select-popper" |
| | | v-model="searchParams.areaCode" |
| | | node-key="id" |
| | | :props="treeSelectProps" |
| | | placeholder="请选择" |
| | | clearable |
| | | filterable |
| | | @change="handleSearch" |
| | | > |
| | | <el-option v-for="item in regionOptions" :key="item.value" :label="item.title" :value="item.value" /> |
| | | </el-select> |
| | | :check-strictly="true" |
| | | lazy |
| | | :load="loadRegionNode" |
| | | :render-after-expand="false" |
| | | /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item class="gd-search-actions"> |
| | |
| | | {{ ((searchParams.current - 1) * searchParams.size + $index + 1).toString().padStart(2, '0') }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="bindCode" show-overflow-tooltip label="机构编码" /> |
| | | <el-table-column prop="deptCode" show-overflow-tooltip label="机构编码" /> |
| | | <el-table-column prop="deptName" show-overflow-tooltip label="机构名称" /> |
| | | <el-table-column prop="areaName" show-overflow-tooltip label="所属区划" /> |
| | | <el-table-column prop="remark" show-overflow-tooltip label="机构描述" /> |
| | |
| | | @close="handleImportClose" |
| | | > |
| | | <el-form class="gd-dialog-form" ref="importFormRef" :model="importParams" :rules="importRules" label-width="140px"> |
| | | |
| | | <el-form-item label="上传文件" prop="file"> |
| | | {{ importFileName }} |
| | | <el-upload class="avatar-uploader" action="" :show-file-list="false" :before-upload="onImportFileBefore"> |
| | |
| | | // 初始化查询参数 |
| | | const initSearchParams = () => ({ |
| | | deptName: '', // 机构名称 |
| | | bindCode: '', // 机构编码 |
| | | deptCode: '', // 机构编码 |
| | | areaCode: '', // 所属区划 |
| | | current: 1, // 当前页 |
| | | size: 10, // 每页大小 |
| | |
| | | const dialogVisible = ref(false) |
| | | const regionOptions = ref([]) // 区域选项 |
| | | const dictObj = ref({}) // 字典对象 |
| | | |
| | | // 树形选择器配置 |
| | | const treeSelectProps = { |
| | | value: 'id', |
| | | label: 'name', |
| | | children: 'children' |
| | | } |
| | | |
| | | |
| | | // 导入机构相关 |
| | | const isShowImportView = ref(false) |
| | |
| | | }) |
| | | } |
| | | |
| | | // 获取区域列表 |
| | | function getRegionList() { |
| | | regionLazyTreeApi({parentCode: '360800000000'}).then(res => { |
| | | console.log('区域列表', res.data.data); |
| | | |
| | | regionOptions.value = res.data.data || [] |
| | | }) |
| | | // 懒加载获取区域节点数据 |
| | | async function loadRegionNode(node, resolve) { |
| | | |
| | | try { |
| | | const parentCode = node.data?.id || '360800000000' |
| | | const res = await regionLazyTreeApi({ parentCode }) |
| | | const nodes = res?.data?.data || [] |
| | | |
| | | // 处理返回的节点数据 |
| | | const processedNodes = nodes.map(item => { |
| | | return { |
| | | id: item.id || item.value, |
| | | name: item.name || item.title || item.label, |
| | | hasChildren: item.hasChildren || false |
| | | } |
| | | }) |
| | | |
| | | resolve(processedNodes) |
| | | } catch (error) { |
| | | console.error('获取区域数据失败:', error) |
| | | 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) |
| | | } |
| | | } |
| | | |
| | | // 获取列表 |
| | |
| | | |
| | | // 上传文件前处理 |
| | | function onImportFileBefore(file) { |
| | | // 执行文件上传 |
| | | // 检查文件类型 |
| | | const allowedTypes = ['.xlsx', '.xls'] |
| | | const fileExtension = file.name.substring(file.name.lastIndexOf('.')).toLowerCase() |
| | | if (!allowedTypes.includes(fileExtension)) { |
| | | ElMessage.error('请上传Excel文件(.xlsx 或 .xls)') |
| | | return false |
| | | } |
| | | let data = new FormData() |
| | | data.append('file', file) |
| | | |
| | |
| | | if (valid) { |
| | | importSubmitting.value = true |
| | | try { |
| | | // 这里实际上传文件的逻辑已经在onImportFileBefore中处理了 |
| | | // 这里可以添加额外的验证或逻辑 |
| | | if (!importParams.value.file) { |
| | | ElMessage.error('请先上传文件') |
| | | return |
| | | } |
| | | // 触发上传操作 |
| | | await onImportFileBefore(importParams.value.file) |
| | | } finally { |
| | | importSubmitting.value = false |
| | | } |