diff --git a/pc/public.zip b/pc/public.zip new file mode 100644 index 0000000..028483f Binary files /dev/null and b/pc/public.zip differ diff --git a/pc/src/api/resource.js b/pc/src/api/resource.js new file mode 100644 index 0000000..12fb916 --- /dev/null +++ b/pc/src/api/resource.js @@ -0,0 +1,54 @@ +import request from '@/utils/request' + +/** + * 上传附件 + * @param {File} file 文件对象 + * @returns {Promise} 返回包含fileId和fileName的Promise + */ +export function uploadAttachment(file) { + const formData = new FormData() + formData.append('file', file) + return request({ + url: '/resource/attachment/uploadAttachment', + method: 'post', + data: formData, + headers: { + 'Content-Type': 'multipart/form-data' + } + }) +} + +/** + * 下载附件 + * @param {string} fileId 文件ID + * @returns {Promise} 返回文件流的Promise + */ +export function downloadAttachment(fileId) { + return request({ + url: `/resource/attachment/downloadAttachment?fileId=${fileId}`, + method: 'get', + responseType: 'blob' + }) +} + +/** + * 批量删除附件 + * @param {Array} fileIds 文件ID数组 + * @returns {Promise} 返回操作结果的Promise + */ +export function batchDeleteAttachment(fileIds) { + return request({ + url: '/resource/attachment/batchDeleteAttachment', + method: 'post', + data: fileIds + }) +} + +/** + * 删除单个附件 + * @param {string} fileId 文件ID + * @returns {Promise} 返回操作结果的Promise + */ +export function deleteAttachment(fileId) { + return batchDeleteAttachment([fileId]) +} \ No newline at end of file diff --git a/pc/src/main.js b/pc/src/main.js index 0794d55..58a436d 100644 --- a/pc/src/main.js +++ b/pc/src/main.js @@ -11,13 +11,36 @@ Vue.config.productionTip = false // 添加下载方法 Vue.prototype.download = function(res, fileName) { - // 创建blob链接 - const blob = new Blob([res]) - const link = document.createElement('a') - link.href = URL.createObjectURL(blob) - link.download = fileName - link.click() - URL.revokeObjectURL(link.href) + // 检查响应类型 + if (res.type && (res.type === 'application/vnd.ms-excel' || + res.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || + res.type.includes('excel') || + res.type === 'application/octet-stream')) { + // 如果已经是Blob类型且是Excel类型,直接使用 + const blob = res + const link = document.createElement('a') + link.href = URL.createObjectURL(blob) + link.download = fileName + link.click() + URL.revokeObjectURL(link.href) + } else { + // 如果不是Blob类型或无法确定类型,根据文件扩展名处理 + let blob + if (fileName.endsWith('.xlsx') || fileName.endsWith('.xls')) { + // Excel文件需要使用二进制格式 + blob = new Blob([res], { + type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + }) + } else { + // 其他类型使用默认处理 + blob = new Blob([res]) + } + const link = document.createElement('a') + link.href = URL.createObjectURL(blob) + link.download = fileName + link.click() + URL.revokeObjectURL(link.href) + } } new Vue({ diff --git a/pc/src/views/project/index.vue b/pc/src/views/project/index.vue index a5002dd..408e560 100644 --- a/pc/src/views/project/index.vue +++ b/pc/src/views/project/index.vue @@ -188,6 +188,17 @@ {{ detail.availableArea }}㎡ {{ detail.totalRooms }} {{ detail.availableRooms }} + + + {{ tag.tagName }} + + 暂无标签 + @@ -287,6 +298,25 @@ export default { } } }, + computed: { + // 项目标签列表,用于在详情页展示 + projectTagList() { + if (!this.detail.projectTags || !this.tagOptions || this.tagOptions.length === 0) { + return []; + } + + // 将逗号分隔的标签ID字符串转为数组 + const tagIds = typeof this.detail.projectTags === 'string' + ? this.detail.projectTags.split(',') + : this.detail.projectTags; + + // 根据ID查找标签对象 + return tagIds.map(tagId => { + const tag = this.tagOptions.find(t => t.id === tagId); + return tag || { id: tagId, tagName: `标签${tagId}` }; + }); + } + }, created() { this.getList() this.getTagOptions() @@ -314,14 +344,18 @@ export default { }, /** 获取标签选项 */ getTagOptions() { - getTagByType({ tagType: '项目标签',tagName: '项目标签' }).then(res => { - this.tagOptions = res.data - }).catch(() => { - this.tagOptions = [ - { id: '1', tagName: '标签1' }, - { id: '2', tagName: '标签2' } - ] - }) + return new Promise((resolve) => { + getTagByType({ tagType: '项目标签',tagName: '项目标签' }).then(res => { + this.tagOptions = res.data || []; + resolve(this.tagOptions); + }).catch(() => { + this.tagOptions = [ + { id: '1', tagName: '标签1' }, + { id: '2', tagName: '标签2' } + ]; + resolve(this.tagOptions); + }); + }); }, /** 搜索按钮操作 */ handleQuery() { @@ -366,7 +400,12 @@ export default { }) }, /** 详情按钮操作 */ - handleDetail(row) { + async handleDetail(row) { + // 确保标签选项已加载 + if (this.tagOptions.length === 0) { + await this.getTagOptions(); + } + getProjectDetail(row.id).then(res => { // 处理项目详情数据,确保标签显示友好 const detailData = { ...res.data }; diff --git a/pc/src/views/project/room/components/DetailView.vue b/pc/src/views/project/room/components/DetailView.vue index a5ee1f6..c294a46 100644 --- a/pc/src/views/project/room/components/DetailView.vue +++ b/pc/src/views/project/room/components/DetailView.vue @@ -55,11 +55,11 @@ -
+
房源图片
- - + +
@@ -75,11 +75,11 @@ {{ workstationCountRange }} -
+
户型图
- - + +
@@ -89,12 +89,18 @@
+ + + + 预览图片 +