| | |
| | | <script> |
| | | import routers from "../../../router"; |
| | | import MenuItem from "./MenuItem.vue"; |
| | | import { mapState } from "vuex"; |
| | | |
| | | // 递归过滤菜单 |
| | | function filterMenusByPrivilege(menus, flatMenus) { |
| | | return menus |
| | | .filter(menu => { |
| | | // 没有 privilege 字段的菜单默认显示,有 privilege 字段的要判断权限 |
| | | if (menu.meta && menu.meta.privilege) { |
| | | return flatMenus.includes(menu.meta.privilege); |
| | | } |
| | | return true; |
| | | }) |
| | | .map(menu => { |
| | | // 递归处理 children |
| | | if (menu.children && menu.children.length > 0) { |
| | | return { |
| | | ...menu, |
| | | children: filterMenusByPrivilege(menu.children, flatMenus) |
| | | }; |
| | | } |
| | | return menu; |
| | | }) |
| | | .filter(menu => { |
| | | // 过滤掉 children 为空的父级菜单 |
| | | if (menu.children && menu.children.length === 0) { |
| | | return false; |
| | | } |
| | | return true; |
| | | }); |
| | | } |
| | | export default { |
| | | components: { |
| | | MenuItem, |
| | | }, |
| | | computed: { |
| | | ...mapState(["flatMenus"]), |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | mounted() { |
| | | // 获取所有定义的一级菜单和多级菜单 |
| | | // 过滤掉登录路由和重定向路由,只获取主布局下的路由 |
| | | this.routersList = routers.options.routes.filter(route => |
| | | const allMenus = routers.options.routes.filter(route => |
| | | route.path !== '/login' && |
| | | route.path !== '/' && |
| | | !route.meta?.hide |
| | | ); |
| | | // 权限过滤 |
| | | this.routersList = filterMenusByPrivilege(allMenus, this.flatMenus); |
| | | }, |
| | | }; |
| | | </script> |
| | |
| | | <el-button size="small" icon="el-icon-upload2">点击上传</el-button> |
| | | </el-upload> |
| | | <div v-else> |
| | | <div v-for="file in item.data.fileList" :key="file.uid" class="file-list-item"> |
| | | {{ file.name }} |
| | | <div v-for="file in item.data.fileList" :key="file.uid" class="file-list-item" > |
| | | <span style="color: #409EFF; cursor: pointer;" @click="downloadFileByUrl(file.url, file.name)">{{ file.name }}</span> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | import addTableData from "./addTableData.vue"; |
| | | import apiConfig from '../../utils/baseurl' |
| | | import { getFullUrl } from '@/utils/utils' |
| | | import { downloadFileByUrl } from '@/utils/utils' |
| | | |
| | | export default { |
| | | name: "DynamicComponent", |
| | |
| | | break; |
| | | case 'fileUpload': |
| | | componentData = { fileList: component.data }; |
| | | console.log('component.data component.data',component.data) |
| | | break; |
| | | case 'imageUpload': |
| | | componentData = { imageList: component.data.map(item=>{ |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | getFullUrl, |
| | | downloadFileByUrl, |
| | | getUserDisplayText(fieldName, rowData) { |
| | | // 检查是否有对应的userInfo数据 |
| | | const userInfoKey = `${fieldName}_userInfo`; |
| | |
| | | break; |
| | | case 'fileUpload': |
| | | componentData = component.data.fileList.map(file => { |
| | | console.log('fileUpload fileUpload fileUpload',file) |
| | | if (file.url && file.url.startsWith(prefix)) { |
| | | return { ...file, url: file.url.substring(prefix.length) }; |
| | | } |
| | |
| | | const updatedComponents = JSON.parse(JSON.stringify(this.components)); |
| | | this.$emit('update:dataSource', updatedComponents); |
| | | }, |
| | | getFullUrl, |
| | | }, |
| | | computed: { |
| | | }, |
| | |
| | | if (!url) return ''; |
| | | if (/^https?:\/\//.test(url)) return url; |
| | | return apiConfig.showImgUrl + url; |
| | | } |
| | | |
| | | /** |
| | | * 通用文件下载方法 |
| | | * @param {string} url 文件的下载地址(支持相对和绝对路径) |
| | | * @param {string} name 下载保存的文件名(可选) |
| | | */ |
| | | export function downloadFileByUrl(url, name) { |
| | | console.log('22222222222222222222',url) |
| | | if (!url) return; |
| | | // 处理相对路径 |
| | | const fullUrl = getFullUrl(url); |
| | | console.log('fullUrl fullUrl',fullUrl) |
| | | const a = document.createElement('a'); |
| | | a.href = fullUrl; |
| | | if (name) { |
| | | a.download = name; |
| | | } else { |
| | | a.download = ''; |
| | | } |
| | | a.style.display = 'none'; |
| | | document.body.appendChild(a); |
| | | a.click(); |
| | | document.body.removeChild(a); |
| | | } |
| | | |
| | | /** |
| | | * 在新标签页打开文件(预览或下载) |
| | | * @param {string} url 文件地址(支持相对和绝对路径) |
| | | */ |
| | | export function openFileInNewTab(url) { |
| | | if (!url) return; |
| | | const fullUrl = getFullUrl(url); |
| | | window.open(fullUrl, '_blank'); |
| | | } |
| | |
| | | confirmSign: signatureImage, // 签字图片 |
| | | signTime: new Date().toISOString(), // 签字时间 |
| | | testMethodConfirmSheetTerms: this.testItems.map(item => ({ |
| | | id: item.id, // 保留原有ID(编辑时使用) |
| | | id: this.formData.id?item.id:'', // 保留原有ID(编辑时使用) |
| | | termCode: item.termCode, |
| | | termName: item.termName, |
| | | termType: item.termType, |
| | |
| | | ? "更新成功" |
| | | : "保存成功"; |
| | | this.$message.success(successMsg); |
| | | |
| | | this.$router.back(); |
| | | this.$store.commit( |
| | | "SET_TAGLIST", |
| | | this.tagList.filter((item) => item.path !== this.$route.path) |
| | |
| | | <el-form-item prop="feasibilityReportFiles" style="margin-top: -18px"> |
| | | <el-upload |
| | | disabled |
| | | :file-list="form.feasibilityReportFiles" |
| | | :file-list="fileList" |
| | | /> |
| | | </el-form-item> |
| | | |
| | |
| | | uid: file.id, |
| | | }; |
| | | }); |
| | | this.form.feasibilityReportFiles =data.feasibilityReportFiles; |
| | | this.form.feasibilityReportFiles =data.feasibilityReportFiles |
| | | } else { |
| | | this.fileList = []; |
| | | this.form.feasibilityReportFiles = []; |