diff --git a/src/router/index.js b/src/router/index.js index bbfb0d0..37e31e4 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -303,6 +303,20 @@ export const dynamicRoutes = [ } ] }, + { + path: '/tool', + component: Layout, + hidden: true, + permissions: ['enterpriseLibrary:tool:list'], + children: [ + { + path: 'index', + component: () => import('@/views/enterpriseLibrary/tool/index'), + name: 'Tool', + meta: { title: '工器具库', activeMenu: '/enterpriseLibrary/tool', noCache: true } + } + ] + }, ] // 防止连续点击多次路由报错 diff --git a/src/views/common/UploadFile.vue b/src/views/common/UploadFile.vue index 095e2e1..603b87d 100644 --- a/src/views/common/UploadFile.vue +++ b/src/views/common/UploadFile.vue @@ -85,12 +85,14 @@ export default { previewFileType: '', isUploading: false, // 添加上传状态标识 defaultFileSize: 1024 * 1024 * 5, // 默认文件大小5MB 超过5MB算大文件上传 + fileValidationMap: new Map(), // 存储文件验证结果 } }, methods: { beforeUpload(file) { // 如果正在上传中,阻止新的上传 if (this.isUploading) { + this.fileValidationMap.set(file.uid, false); return false; } @@ -103,16 +105,23 @@ export default { // 验证文件大小 const isLtMaxSize = file.size / 1024 / 1024 < this.maxSizeMB; + + let isValid = true; + if (!isAllowedType || !isAllowedMimeType) { this.$message.error(`只能上传 ${this.uploadType} 格式的文件!`); - return false; + isValid = false; } if (!isLtMaxSize) { this.$message.error(`文件大小不能超过 ${this.maxFileTips}!`); - return false; + isValid = false; } + // 存储验证结果 + this.fileValidationMap.set(file.uid, isValid); + + // 返回 false 阻止自动上传,我们将手动控制上传流程 return false; }, // 文件状态改变 @@ -122,7 +131,20 @@ export default { return; } - // 不使用深拷贝,直接使用 fileList,但确保 files 是响应式的 + // 检查文件验证结果 + const isValid = this.fileValidationMap.get(file.uid); + if (isValid === false) { + // 验证失败,从文件列表中移除该文件 + const fileIndex = fileList.findIndex(item => item.uid === file.uid); + if (fileIndex !== -1) { + fileList.splice(fileIndex, 1); + } + this.fileValidationMap.delete(file.uid); + this.files = this.formatFileList(fileList); + return; + } + + // 验证通过,继续处理 this.files = this.formatFileList(fileList); // 生成预览 @@ -140,8 +162,7 @@ export default { } // 如果启用自动上传且文件验证通过,触发上传 - if (this.autoUpload && file.status === 'ready' && !this.isUploading) { - alert(this.fileUploadRule.fields_json); + if (this.autoUpload && file.status === 'ready' && !this.isUploading && isValid !== false) { if (this.fileUploadRule.fields_json) { // 文件需要ocr识别 this.uploadFile(file, '识别中'); @@ -150,6 +171,9 @@ export default { this.uploadFile(file, '上传中'); } } + + // 清理验证结果 + this.fileValidationMap.delete(file.uid); }, // 格式化文件列表,确保数据结构正确 @@ -336,7 +360,13 @@ export default { // 手动触发新文件的上传流程 const newFile = files[0]; - this.beforeUpload(newFile); // 先进行验证 + + // 先进行验证 + const isValid = this.beforeUpload(newFile); + + if (!isValid) { + return; + } // 创建新的文件对象,确保包含 percentage const newFileObj = { diff --git a/src/views/enterpriseLibrary/enterprise/components/EnterpriseKnowledge.vue b/src/views/enterpriseLibrary/enterprise/components/EnterpriseKnowledge.vue index 3b79d17..31e498e 100644 --- a/src/views/enterpriseLibrary/enterprise/components/EnterpriseKnowledge.vue +++ b/src/views/enterpriseLibrary/enterprise/components/EnterpriseKnowledge.vue @@ -76,7 +76,7 @@ export default { description: '工器具库主要用于登记工器具资料信息, 统一管理工器具清单等', icon: enterpriseKnowledgeIcon, path: '/enterpriseLibrary/enterprise/tools', - name: 'Tools' + name: 'Tool' }, { type: 'financial', diff --git a/src/views/enterpriseLibrary/technical/components/RightTable.vue b/src/views/enterpriseLibrary/technical/components/RightTable.vue index ac44025..6950360 100644 --- a/src/views/enterpriseLibrary/technical/components/RightTable.vue +++ b/src/views/enterpriseLibrary/technical/components/RightTable.vue @@ -1,5 +1,5 @@ - + diff --git a/src/views/enterpriseLibrary/technical/components/TypeForm.vue b/src/views/enterpriseLibrary/technical/components/TypeForm.vue index d169250..958006e 100644 --- a/src/views/enterpriseLibrary/technical/components/TypeForm.vue +++ b/src/views/enterpriseLibrary/technical/components/TypeForm.vue @@ -11,10 +11,9 @@ - - 确认 - 取消 + 取消 @@ -165,4 +164,42 @@ export default { display: flex; justify-content: space-between; } + +.confirm-btn { + width: 98px; + height: 36px; + background: #1F72EA; + box-shadow: 0px 4px 8px 0px rgba(51, 135, 255, 0.5); + border-radius: 4px 4px 4px 4px; + color: #fff; + border: none; + font-size: 14px; + transition: all 0.3s; + + &:hover { + background: #4A8BFF; + box-shadow: 0px 6px 12px 0px rgba(51, 135, 255, 0.6); + } +} + +.cancel-btn { + width: 98px; + height: 36px; + background: #E5E5E5; + box-shadow: 0px 4px 8px 0px rgba(76, 76, 76, 0.2); + border-radius: 4px 4px 4px 4px; + color: #333; + border: none; + font-size: 14px; + transition: all 0.3s; + + &:hover { + background: #d0d0d0; + box-shadow: 0px 6px 12px 0px rgba(76, 76, 76, 0.3); + } +} + +::v-deep .el-dialog__footer { + text-align: center; +} \ No newline at end of file diff --git a/src/views/enterpriseLibrary/technical/index.vue b/src/views/enterpriseLibrary/technical/index.vue index bffcb1d..fc725a7 100644 --- a/src/views/enterpriseLibrary/technical/index.vue +++ b/src/views/enterpriseLibrary/technical/index.vue @@ -1,5 +1,11 @@ + + + + 返回 + + @@ -18,7 +24,7 @@ @@ -70,6 +86,32 @@ export default { background: linear-gradient(180deg, #F1F6FF 20%, #E5EFFF 100%); } +.back-container { + display: flex; + justify-content: flex-end; + align-items: center; + margin-bottom: 30px; + padding: 0 20px; + + .back-btn { + width: 98px; + height: 36px; + background: #FFFFFF; + box-shadow: 0px 4px 8px 0px rgba(76, 76, 76, 0.2); + border-radius: 4px; + border: none; + color: #666; + font-size: 14px; + transition: all 0.3s ease; + + &:hover { + background: #f5f5f5; + color: #409EFF; + box-shadow: 0px 6px 12px 0px rgba(76, 76, 76, 0.3); + } + } +} + .layout-container { display: flex; height: 100%; diff --git a/src/views/enterpriseLibrary/tool/components/ToolForm.vue b/src/views/enterpriseLibrary/tool/components/ToolForm.vue new file mode 100644 index 0000000..6196681 --- /dev/null +++ b/src/views/enterpriseLibrary/tool/components/ToolForm.vue @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + 确认 + 取消 + + + + + \ No newline at end of file diff --git a/src/views/enterpriseLibrary/tool/config.js b/src/views/enterpriseLibrary/tool/config.js new file mode 100644 index 0000000..fc8426f --- /dev/null +++ b/src/views/enterpriseLibrary/tool/config.js @@ -0,0 +1,18 @@ +export const formLabel = [ + { + isShow: false, // 是否展示label + f_type: 'ipt', + f_label: '工器具名称', + f_model: 'userName', + f_max: 32, + f_width: '250px', + }, +] + +export const columnsList = [ + { t_props: 'userName', t_label: '名称' }, + { t_props: 'nickName', t_label: '规格型号' }, + { t_props: 'phonenumberDes', t_label: '单位' }, + { t_props: 'phonenumberDes', t_label: '技术参数' }, + { t_props: 'phonenumberDes', t_label: '主要作用' }, +] \ No newline at end of file diff --git a/src/views/enterpriseLibrary/tool/index.vue b/src/views/enterpriseLibrary/tool/index.vue new file mode 100644 index 0000000..8eab0bc --- /dev/null +++ b/src/views/enterpriseLibrary/tool/index.vue @@ -0,0 +1,212 @@ + + + + + + + 返回 + + + + + 数据列表 + + + 导入模板下载 + 导入模板下载 + 新增工器具 + + + {{ data.dept.deptName || '--' }} + + + + 查看 + + + 编辑 + + + 删除 + + + + + + + + + +