-
-
-
需求
-
-
- {{ tag.name }}
-
-
-
-
-
-
-
工程
-
-
- {{ tag.name }}
-
-
-
-
-
-
-
产品
-
-
- {{ tag.name }}
-
-
-
-
-
-
-
营销
-
-
- {{ tag.name }}
-
-
-
-
-
-
@@ -191,14 +182,29 @@ export default {
background: #fff;
min-height: 100%;
box-sizing: border-box;
+ display: flex;
+ flex-direction: column;
+}
+
+.search-container {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ margin-bottom: 16px;
+
+ .search-input {
+ flex: 1;
+ }
+}
+
+.tags-container {
+ flex: 1;
+ overflow-y: auto;
+ padding-right: 4px;
}
.filter-section {
- margin-bottom: 24px;
-
- &:last-of-type {
- margin-bottom: 32px;
- }
+ margin-bottom: 20px;
}
.section-title {
@@ -213,108 +219,94 @@ export default {
display: flex;
flex-wrap: wrap;
gap: 8px;
- margin-bottom: 8px;
+}
- .tag-button {
- height: 32px;
- padding: 0 16px;
- border-radius: 16px;
- border: 1px solid #dcdfe6;
- background: #f5f7fa;
- color: #606266;
- font-size: 14px;
- transition: all 0.3s;
+.tag-button {
+ min-width: 80px;
+ height: 32px;
+ line-height: 32px;
+ border-radius: 16px;
+ border: 1px solid #dcdfe6;
+ background: #f5f7fa;
+ color: #606266;
+ font-size: 14px;
+ text-align: center;
+ padding: 0 16px;
+ cursor: pointer;
+ transition: all 0.3s;
+ user-select: none;
- &:hover {
- border-color: #409eff;
- color: #409eff;
- }
-
- &.active {
- background: #409eff;
- border-color: #409eff;
- color: #fff;
- }
+ &:hover {
+ border-color: #409eff;
+ color: #409eff;
}
+
+ &.active {
+ background: #409eff;
+ border-color: #409eff;
+ color: #fff;
+ }
+}
+
+.load-status {
+ text-align: center;
+ color: #909399;
+ font-size: 12px;
+ padding: 12px 0 4px;
}
.action-buttons {
display: flex;
justify-content: center;
gap: 16px;
- margin-top: 24px;
- padding-top: 20px;
+ margin-top: 16px;
+ padding-top: 16px;
border-top: 1px solid #e4e7ed;
- .query-button {
+ .query-button,
+ .reset-button {
height: 36px;
padding: 0 24px;
border-radius: 18px;
- background: #409eff;
- border-color: #409eff;
- color: #fff;
- font-size: 14px;
- font-weight: 500;
display: flex;
align-items: center;
gap: 6px;
+ }
+
+ .query-button {
+ background: #409eff;
+ border-color: #409eff;
+ color: #fff;
&:hover {
background: #66b1ff;
border-color: #66b1ff;
}
-
- i {
- font-size: 14px;
- }
}
.reset-button {
- height: 36px;
- padding: 0 24px;
- border-radius: 18px;
background: #f5f7fa;
border-color: #dcdfe6;
color: #606266;
- font-size: 14px;
- display: flex;
- align-items: center;
- gap: 6px;
&:hover {
background: #ecf5ff;
border-color: #c6e2ff;
color: #409eff;
}
-
- i {
- font-size: 14px;
- }
}
}
-// 响应式设计
@media (max-width: 768px) {
.tag-filter-container {
padding: 16px;
}
- .tag-buttons {
- .tag-button {
- height: 28px;
- padding: 0 12px;
- font-size: 12px;
- }
- }
-
- .action-buttons {
- flex-direction: column;
- align-items: center;
-
- .query-button,
- .reset-button {
- width: 120px;
- }
+ .tag-button {
+ min-width: 70px;
+ height: 28px;
+ line-height: 28px;
+ font-size: 12px;
}
}
diff --git a/src/views/publicService/docCenter/components/tableCom/upload.vue b/src/views/publicService/docCenter/components/tableCom/upload.vue
index fad91f1..5a70e59 100644
--- a/src/views/publicService/docCenter/components/tableCom/upload.vue
+++ b/src/views/publicService/docCenter/components/tableCom/upload.vue
@@ -41,7 +41,6 @@
action="#"
:auto-upload="false"
:file-list="fileList"
- :before-upload="handleBeforeUpload"
:on-change="handleFileChange"
:on-remove="handleRemove"
:on-exceed="handleExceed"
@@ -87,61 +86,45 @@ export default {
TagSelector,
},
props: {
- visible: {
- type: Boolean,
- default: false,
- },
selectedNode: {
type: Object,
- default: {},
+ default: () => ({}),
},
},
data() {
return {
- dialogVisible: false,
duplicateHandle: '1', // 重复处理方式:1-跳过,2-覆盖
- selectedTag: '', // 选中的文件标签ID(兼容旧代码)
selectedTags: [], // 选中的标签对象数组
+ selectedTagIds: [], // 选中的标签ID数组
+ selectedTagLabels: [], // 选中的标签名称数组
selectedTypeIds: [], // 选中的去重后的 typeId 数组
tagSelectorVisible: false, // 标签选择弹框显示状态
fileList: [], // 文件列表
uploading: false, // 上传状态
}
},
- watch: {
- visible: {
- handler(val) {
- this.dialogVisible = val
- },
- immediate: true,
- },
- },
computed: {
// 选中的标签显示文本
selectedTagText() {
- if (this.selectedTags.length === 0) {
+ if (this.selectedTagLabels.length === 0) {
return ''
}
- return this.selectedTags.map((tag) => tag.labelName).join(',')
+ return this.selectedTagLabels.join(',')
},
},
methods: {
- // 关闭对话框
- handleClose() {
- this.dialogVisible = false
- this.$emit('update:visible', false)
- this.resetForm()
- },
-
// 重置表单
resetForm() {
this.duplicateHandle = '1'
- this.selectedTag = ''
this.selectedTags = []
+ this.selectedTagIds = []
+ this.selectedTagLabels = []
this.selectedTypeIds = []
this.fileList = []
this.uploading = false
- this.$refs.upload && this.$refs.upload.clearFiles()
+ this.$nextTick(() => {
+ this.$refs.upload && this.$refs.upload.clearFiles()
+ })
},
// 打开标签选择弹框
@@ -153,38 +136,56 @@ export default {
handleTagConfirm(result) {
// result 格式: { tags: [], typeIds: [] }
this.selectedTags = result?.tags || []
+ this.selectedTagIds =
+ result?.tagIds ||
+ this.selectedTags.map((tag) => String(tag.id ?? ''))
+ this.selectedTagLabels =
+ result?.tagLabels ||
+ this.selectedTags.map((tag) => tag.labelName || '')
this.selectedTypeIds = result?.typeIds || []
- // 兼容旧代码,取第一个标签的ID
- if (this.selectedTags.length > 0) {
- this.selectedTag = this.selectedTags[0].id
- } else {
- this.selectedTag = ''
- }
},
- // 上传前校验
- handleBeforeUpload(file) {
- // 检查文件格式
- // const allowedTypes = ['rar', 'zip']
- // const fileExtension = file.name.split('.').pop().toLowerCase()
+ // 校验文件合法性
+ validateFile(file, options = {}) {
+ const { showMessage = true } = options
+ const rawFile = file?.raw || file
+ if (!rawFile) {
+ if (showMessage) {
+ this.$modal.msgError('文件信息异常,请重新选择文件!')
+ }
+ return false
+ }
- // if (!allowedTypes.includes(fileExtension)) {
- // this.$modal.msgError('只支持上传rar/zip格式文件!')
- // return false
- // }
+ const fileName = rawFile.name || file.name || ''
+ const fileSize = rawFile.size || file.size || 0
+
+ // 检查文件格式
+ const allowedTypes = ['rar', 'zip']
+ const fileExtension = fileName.split('.').pop().toLowerCase()
+
+ if (!allowedTypes.includes(fileExtension)) {
+ if (showMessage) {
+ this.$modal.msgError('只支持上传rar/zip格式文件!')
+ }
+ return false
+ }
// 检查文件大小 (500kb = 0.5MB)
const maxSize = 0.5
- const isLtMaxSize = file.size / 1024 / 1024 < maxSize
+ const isLtMaxSize = fileSize / 1024 / 1024 < maxSize
if (!isLtMaxSize) {
- this.$modal.msgError(`文件大小不能超过 ${maxSize}MB!`)
+ if (showMessage) {
+ this.$modal.msgError(`文件大小不能超过 ${maxSize}MB!`)
+ }
return false
}
// 检查文件名是否包含特殊字符
- if (file.name.includes(',')) {
- this.$modal.msgError('文件名不能包含英文逗号!')
+ if (fileName.includes(',')) {
+ if (showMessage) {
+ this.$modal.msgError('文件名不能包含英文逗号!')
+ }
return false
}
@@ -193,6 +194,10 @@ export default {
// 文件变化
handleFileChange(file, fileList) {
+ // if (!this.validateFile(file, { showMessage: true })) {
+ // this.fileList = fileList.filter((item) => item.uid !== file.uid)
+ // return
+ // }
this.fileList = fileList
},
@@ -215,14 +220,21 @@ export default {
async handleConfirm() {
if (this.fileList.length === 0) {
this.$modal.msgWarning('请选择要上传的文件!')
- return
+ throw new Error('表单验证失败')
}
if (this.selectedTags.length === 0) {
this.$modal.msgWarning('请选择文件标签!')
- return
+ throw new Error('表单验证失败')
}
+ // const hasInvalidFile = this.fileList.some(
+ // (item) => !this.validateFile(item, { showMessage: true }),
+ // )
+ // if (hasInvalidFile) {
+ // throw new Error('表单验证失败')
+ // }
+
this.uploading = true
try {
@@ -233,9 +245,12 @@ export default {
folderId: this.selectedNode?.id,
type: this.selectedNode?.type,
repeatType: this.duplicateHandle,
- parentId: this.selectedNode?.parentId,
- labels: this.selectedTags.map((tag) => tag.id).join(','),
- typeIds: this.selectedTypeIds.join(','), // 去重后的 typeId 数组,用逗号连接
+ parentId: this.selectedNode?.id,
+ parentIds: this.selectedNode?.parentIds,
+ labelIds: this.selectedTagIds.join(','), // 标签ID
+ labels: this.selectedTagLabels.join(','), // 标签名称
+ level: this.selectedNode?.level * 1 + 1,
+ // typeIds: this.selectedTypeIds.join(','), // 去重后的 typeId 数组,用逗号连接
}
// 添加文件
@@ -250,7 +265,24 @@ export default {
// 调用上传接口
const response = await uploadFileTagAPI(formData)
- console.log(response, '上传结果')
+ this.$modal.msgSuccess('文件上传成功!')
+
+ const payload = {
+ success: true,
+ response,
+ tagIds: [...this.selectedTagIds],
+ tagLabels: [...this.selectedTagLabels],
+ tags: this.selectedTags.map((tag) => ({
+ id: String(tag.id ?? ''),
+ labelName: tag.labelName,
+ typeId: tag.typeId,
+ typeName: tag.typeName,
+ })),
+ }
+
+ this.$emit('confirm', payload)
+ this.resetForm()
+ return payload
} catch (error) {
this.$modal.msgError('文件上传失败,请重试!')
throw error