feat: 邀请函邮件发送 + 首次设密/密码为空 + 姓名单一可信源
邀请发送 (菜单暂隐藏, 待确认参数见 发送邀请-待确认参数.md): - 后端: BizInvite / BizInviteRecipient + Controller/Service/Mapper/XML - 邮件: InviteMailSender (spring-boot-starter-mail SMTP) + application*.yml 邮件配置 - 上传进度: UploadProgressRegistry + UploadProgressController - 前端: InviteList / InviteNew / InviteDetail / InviteView + api/business/invite.js - 原型: proto/html/components/invite-detail / new-invitation / send-invitation 登录/账号: - 首次设密: /getInfo 返回 isPasswordEmpty, SysProfileController 密码为空时跳过旧密码校验, ForcePasswordDialog 强制弹窗 - 姓名单一可信源 resolveDisplayName: doctor→biz_expert.name, sponsor/executor→biz_person.name, 其余回退 nick_name - OA compliance 门禁改为按手机号查 ecology 视图 (不再限定 manager/leader) 其它: - OSS zip 在线查看 (列清单+取单文件, 公开只读) + SecurityConfig permitAll - doctor 项目详情 ProjectDetail.vue - 数据库/测试/设计文档 (md) 入库
This commit is contained in:
@@ -10,41 +10,80 @@
|
||||
/>
|
||||
-->
|
||||
<template>
|
||||
<div class="ht-file-upload" :class="{ 'has-file': modelValue, 'is-block': block, readonly, uploading }" @click="handleClick">
|
||||
<div v-if="uploading" class="ht-file-progress">
|
||||
<span class="progress-label">上传中</span>
|
||||
<el-progress :percentage="progress" :stroke-width="6" class="progress-bar" />
|
||||
</div>
|
||||
<div v-else-if="!modelValue && !readonly" class="ht-file-placeholder">
|
||||
<span class="placeholder-text">{{ placeholder }}</span>
|
||||
<span class="placeholder-hint" v-if="hint">{{ hint }}</span>
|
||||
</div>
|
||||
<div v-else-if="!modelValue && readonly" class="ht-file-placeholder readonly-empty">
|
||||
<span class="placeholder-text">未上传</span>
|
||||
</div>
|
||||
<div v-else-if="modelValue" class="ht-file-info">
|
||||
<el-icon class="file-icon" :size="22"><svg viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm-1 7V3.5L18.5 9H13z"/>
|
||||
</svg></el-icon>
|
||||
<div class="file-meta">
|
||||
<a class="file-name" :href="openHref" target="_blank" @click.stop>{{ fileName }}</a>
|
||||
<span class="file-type">{{ ext.toUpperCase() }} · {{ fileSizeText }}</span>
|
||||
<div class="ht-file-upload" :class="{ 'has-file': hasValue, 'is-block': block, readonly, uploading, multiple }" @click="handleClick">
|
||||
<!-- 多文件模式: 上传多个文件, modelValue 存 JSON 数组字符串 (单文件时退化为单 URL 字符串) -->
|
||||
<template v-if="multiple">
|
||||
<div v-if="uploading" class="ht-file-progress">
|
||||
<span class="progress-label">上传中</span>
|
||||
<el-progress :percentage="progress" :stroke-width="6" class="progress-bar" />
|
||||
</div>
|
||||
<el-link :underline="false" v-if="!readonly" type="danger" class="remove-btn" @click.stop="onRemove">移除</el-link>
|
||||
<!-- 右侧预览框 (图片用 el-image, 其他用 icon + 点击新窗口打开) -->
|
||||
<div v-if="showPreview" class="preview-box">
|
||||
<el-image v-if="isImage" :src="modelValue" :preview-src-list="[modelValue]" :initial-index="0" fit="cover" class="preview-img" />
|
||||
<a v-else :href="openHref" target="_blank" class="preview-file" @click.stop>
|
||||
<el-icon :size="28"><Document /></el-icon>
|
||||
<span class="preview-text">{{ getFileType(modelValue) }}</span>
|
||||
</a>
|
||||
<template v-else>
|
||||
<div v-if="!modelList.length && !readonly" class="ht-file-placeholder" @click.stop="handleClick">
|
||||
<span class="placeholder-text">{{ placeholder }}</span>
|
||||
<span class="placeholder-hint" v-if="hint">{{ hint }}</span>
|
||||
</div>
|
||||
<div v-if="!modelList.length && readonly" class="ht-file-placeholder readonly-empty">
|
||||
<span class="placeholder-text">未上传</span>
|
||||
</div>
|
||||
<div v-for="(u, i) in modelList" :key="u" class="ht-file-info multi-item" @click.stop>
|
||||
<el-icon class="file-icon" :size="22"><svg viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm-1 7V3.5L18.5 9H13z"/>
|
||||
</svg></el-icon>
|
||||
<div class="file-meta">
|
||||
<span class="file-name">{{ fileNameOf(u) }}</span>
|
||||
<span class="file-type">{{ typeOf(u) }}</span>
|
||||
</div>
|
||||
<div class="file-actions">
|
||||
<el-link :underline="false" v-if="!readonly" type="danger" class="remove-btn" @click.stop="onRemoveAt(i)">移除</el-link>
|
||||
<a class="download-btn" :href="u" target="_blank" rel="noopener" @click.stop>下载</a>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!readonly && modelList.length" class="ht-file-add" @click.stop="handleClick">
|
||||
<el-icon :size="16"><Plus /></el-icon> 继续添加
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
<!-- 单文件模式 (原逻辑) -->
|
||||
<template v-else>
|
||||
<div v-if="uploading" class="ht-file-progress">
|
||||
<span class="progress-label">上传中</span>
|
||||
<el-progress :percentage="progress" :stroke-width="6" class="progress-bar" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="!modelValue && !readonly" class="ht-file-placeholder">
|
||||
<span class="placeholder-text">{{ placeholder }}</span>
|
||||
<span class="placeholder-hint" v-if="hint">{{ hint }}</span>
|
||||
</div>
|
||||
<div v-else-if="!modelValue && readonly" class="ht-file-placeholder readonly-empty">
|
||||
<span class="placeholder-text">未上传</span>
|
||||
</div>
|
||||
<div v-else-if="modelValue" class="ht-file-info">
|
||||
<el-icon class="file-icon" :size="22"><svg viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm-1 7V3.5L18.5 9H13z"/>
|
||||
</svg></el-icon>
|
||||
<div class="file-meta">
|
||||
<a class="file-name" :href="openHref" @click.stop.prevent="handleOpen">{{ fileName }}</a>
|
||||
<span class="file-type">{{ ext.toUpperCase() }} · {{ fileSizeText }}</span>
|
||||
</div>
|
||||
<div class="file-actions">
|
||||
<el-link :underline="false" v-if="!readonly" type="danger" class="remove-btn" @click.stop="onRemove">移除</el-link>
|
||||
<a class="download-btn" :href="modelValue" target="_blank" rel="noopener" @click.stop>下载</a>
|
||||
</div>
|
||||
<!-- 右侧预览框 (图片用 el-image, 其他用 icon + 点击新窗口打开) -->
|
||||
<div v-if="showPreview" class="preview-box">
|
||||
<el-image v-if="isImage" :src="modelValue" :preview-src-list="[modelValue]" :initial-index="0" fit="cover" class="preview-img" />
|
||||
<a v-else :href="openHref" class="preview-file" @click.stop.prevent="handleOpen">
|
||||
<el-icon :size="28"><Document /></el-icon>
|
||||
<span class="preview-text">{{ getFileType(modelValue) }}</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<input
|
||||
type="file"
|
||||
ref="fileInput"
|
||||
:accept="accept"
|
||||
:multiple="multiple"
|
||||
style="display:none"
|
||||
@change="onFileChange"
|
||||
/>
|
||||
@@ -53,7 +92,7 @@
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Document } from '@element-plus/icons-vue'
|
||||
import { Document, Plus } from '@element-plus/icons-vue'
|
||||
import { uploadToOss } from '@/utils/oss'
|
||||
|
||||
const props = defineProps({
|
||||
@@ -63,36 +102,59 @@ const props = defineProps({
|
||||
placeholder: { type: String, default: '点击上传文件' },
|
||||
hint: { type: String, default: '' },
|
||||
accept: { type: String, default: '.pdf,.png,.jpg,.jpeg' },
|
||||
maxSize: { type: Number, default: 10 }, // MB
|
||||
maxSize: { type: Number, default: 200 }, // MB
|
||||
block: { type: Boolean, default: false },
|
||||
readonly: { type: Boolean, default: false },
|
||||
showPreview: { type: Boolean, default: true } // 右侧预览框 (图片/PDF/其他)
|
||||
showPreview: { type: Boolean, default: true }, // 右侧预览框 (图片/PDF/其他)
|
||||
multiple: { type: Boolean, default: false } // 多文件模式: 一次选多个文件, modelValue 存 JSON 数组字符串
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'update:name'])
|
||||
const emit = defineEmits(['update:modelValue', 'update:name', 'preview'])
|
||||
|
||||
const fileInput = ref(null)
|
||||
const uploading = ref(false)
|
||||
const progress = ref(0)
|
||||
|
||||
const fileName = computed(() => {
|
||||
// 优先用调用方回传的原文件名 (v-model:name); 没有则从 OSS key 还原原名
|
||||
if (props.name) return props.name
|
||||
if (!props.modelValue) return ''
|
||||
// 取 URL 最后一段, 去 query 参数; 上传时已对路径做了 encodeURIComponent, 这里先还原
|
||||
const url = props.modelValue.split('?')[0]
|
||||
let last = url.substring(url.lastIndexOf('/') + 1)
|
||||
/** 从 OSS URL 还原原文件名 (前端 key 格式 原名_时间戳_随机串.扩展名 → 原名.扩展名; 旧 key 原样返回末段) */
|
||||
function nameOfUrl(url) {
|
||||
if (!url) return ''
|
||||
const u = url.split('?')[0]
|
||||
let last = u.substring(u.lastIndexOf('/') + 1)
|
||||
try { last = decodeURIComponent(last) } catch (e) { /* 已解码/旧 key, 原样用 */ }
|
||||
// 新 key 格式: 原名_时间戳_随机串.扩展名 → 还原 原名.扩展名; 旧 key (无原名) 原样返回
|
||||
const m = last.match(/^(.+)_\d{13}_[a-z0-9]{6}(\.[^.]+)?$/)
|
||||
if (m) return m[1] + (m[2] || '')
|
||||
return last
|
||||
}
|
||||
const fileName = computed(() => {
|
||||
// 优先用调用方回传的原文件名 (v-model:name); 没有则从 OSS key 还原原名
|
||||
if (props.name) return props.name
|
||||
return nameOfUrl(props.modelValue)
|
||||
})
|
||||
const ext = computed(() => {
|
||||
const n = fileName.value
|
||||
const i = n.lastIndexOf('.')
|
||||
return i >= 0 ? n.substring(i + 1) : ''
|
||||
})
|
||||
|
||||
// ===== 多文件模式 =====
|
||||
/** 解析 modelValue 为 URL 列表 (兼容单 URL 字符串 / JSON 数组字符串 / 数组) */
|
||||
const modelList = computed(() => {
|
||||
if (!props.modelValue) return []
|
||||
if (Array.isArray(props.modelValue)) return props.modelValue
|
||||
try {
|
||||
const arr = JSON.parse(props.modelValue)
|
||||
return Array.isArray(arr) ? arr : [props.modelValue]
|
||||
} catch (e) {
|
||||
return [props.modelValue]
|
||||
}
|
||||
})
|
||||
const hasValue = computed(() => props.multiple ? modelList.value.length > 0 : !!props.modelValue)
|
||||
function fileNameOf(url) { return nameOfUrl(url) }
|
||||
function typeOf(url) {
|
||||
const n = nameOfUrl(url)
|
||||
const i = n.lastIndexOf('.')
|
||||
return (i >= 0 ? n.substring(i + 1) : '').toUpperCase()
|
||||
}
|
||||
const fileSizeText = computed(() => '已上传')
|
||||
|
||||
// 图片扩展名 (用于 el-image 预览)
|
||||
@@ -102,6 +164,10 @@ const isImage = computed(() => {
|
||||
})
|
||||
// PDF: 点击不下载, 走 /common/oss/proxy 后端代理重写 Content-Disposition 为 inline, 新窗口内嵌预览
|
||||
const isPdf = computed(() => ext.value.toLowerCase() === 'pdf')
|
||||
// Office/文本 (可页内预览的扩展名): 点击 emit preview, 由父组件弹 Preview 对话框; 老 .doc/.ppt 仍走下载
|
||||
const isOffice = computed(() => ['docx', 'xlsx', 'xls', 'pptx', 'txt'].includes(ext.value.toLowerCase()))
|
||||
// zip: 点击 emit preview (父组件 Preview 服务端解压列目录), 不直接下载
|
||||
const isZip = computed(() => ext.value.toLowerCase() === 'zip')
|
||||
// OSS 代理预览 (与 Preview.vue / PublicityDetail 同技术): bucket 默认 attachment, 直接打开会强制下载
|
||||
function proxyUrl(url) {
|
||||
if (!url) return url
|
||||
@@ -112,6 +178,14 @@ function proxyUrl(url) {
|
||||
}
|
||||
// 文件名/预览框点击目标: PDF → 代理预览(新窗口), 其余 → 原 URL (图片 el-image 预览, 其他下载)
|
||||
const openHref = computed(() => isPdf.value ? proxyUrl(props.modelValue) : props.modelValue)
|
||||
// 点击文件名/预览框: Office/文本 → emit preview 弹对话框; 其余 → 新窗口打开 openHref
|
||||
function handleOpen() {
|
||||
if (isOffice.value || isZip.value) {
|
||||
emit('preview', props.modelValue)
|
||||
return
|
||||
}
|
||||
window.open(openHref.value, '_blank', 'noopener')
|
||||
}
|
||||
// 文件类型标签 (PDF / DOC / XLS / ZIP 等)
|
||||
const typeLabelMap = {
|
||||
pdf: 'PDF', doc: 'DOC', docx: 'DOCX',
|
||||
@@ -130,11 +204,8 @@ function handleClick() {
|
||||
fileInput.value?.click()
|
||||
}
|
||||
|
||||
async function onFileChange(e) {
|
||||
const file = e.target.files?.[0]
|
||||
e.target.value = ''
|
||||
if (!file) return
|
||||
// 类型校验 (按 accept 列表)
|
||||
/** 类型/大小校验, 不通过返回 false (内部已 toast) */
|
||||
function validateFile(file) {
|
||||
const allowed = props.accept.split(',').map(s => s.trim().toLowerCase()).filter(Boolean)
|
||||
if (allowed.length) {
|
||||
const lower = file.name.toLowerCase()
|
||||
@@ -143,11 +214,45 @@ async function onFileChange(e) {
|
||||
if (rule.endsWith('/*')) return file.type.startsWith(rule.slice(0, -1))
|
||||
return file.type === rule
|
||||
})
|
||||
if (!ok) return ElMessage.warning('文件类型不符, 允许: ' + props.accept)
|
||||
if (!ok) { ElMessage.warning('文件类型不符, 允许: ' + props.accept); return false }
|
||||
}
|
||||
if (file.size / 1024 / 1024 > props.maxSize) {
|
||||
return ElMessage.warning(`文件大小不能超过 ${props.maxSize}MB`)
|
||||
ElMessage.warning(`文件大小不能超过 ${props.maxSize}MB`)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async function onFileChange(e) {
|
||||
const files = Array.from(e.target.files || [])
|
||||
e.target.value = ''
|
||||
if (!files.length) return
|
||||
// 多文件模式: 逐个上传, 追加进 modelValue 列表
|
||||
if (props.multiple) {
|
||||
const list = [...modelList.value]
|
||||
let added = 0
|
||||
for (const file of files) {
|
||||
if (!validateFile(file)) continue
|
||||
uploading.value = true
|
||||
progress.value = 0
|
||||
try {
|
||||
const url = await uploadToOss(file, props.dir, (p) => { progress.value = p })
|
||||
list.push(url)
|
||||
added++
|
||||
} catch (err) {
|
||||
ElMessage.error(err.message || '上传失败')
|
||||
}
|
||||
}
|
||||
uploading.value = false
|
||||
if (added) {
|
||||
emit('update:modelValue', list.length === 1 ? list[0] : JSON.stringify(list))
|
||||
ElMessage.success(`已上传 ${added} 个文件`)
|
||||
}
|
||||
return
|
||||
}
|
||||
// 单文件模式 (原逻辑)
|
||||
const file = files[0]
|
||||
if (!validateFile(file)) return
|
||||
uploading.value = true
|
||||
progress.value = 0
|
||||
try {
|
||||
@@ -166,6 +271,17 @@ function onRemove() {
|
||||
emit('update:modelValue', '')
|
||||
emit('update:name', '')
|
||||
}
|
||||
|
||||
/** 多文件模式: 移除第 i 个文件 */
|
||||
function onRemoveAt(i) {
|
||||
const list = [...modelList.value]
|
||||
list.splice(i, 1)
|
||||
if (!list.length) {
|
||||
emit('update:modelValue', '')
|
||||
} else {
|
||||
emit('update:modelValue', list.length === 1 ? list[0] : JSON.stringify(list))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -187,6 +303,17 @@ function onRemove() {
|
||||
.ht-file-upload.readonly { cursor: default; }
|
||||
.ht-file-upload.uploading { cursor: default; }
|
||||
|
||||
/* 多文件模式: 纵向堆叠列表 */
|
||||
.ht-file-upload.multiple { flex-direction: column; align-items: stretch; gap: 8px; }
|
||||
.ht-file-upload.multiple .ht-file-info.multi-item { padding-bottom: 6px; border-bottom: 1px dashed #f0f0f0; }
|
||||
.ht-file-upload.multiple .ht-file-info.multi-item:last-of-type { border-bottom: none; }
|
||||
.ht-file-add {
|
||||
display: flex; align-items: center; justify-content: center; gap: 4px;
|
||||
border: 1px dashed #d9d9d9; border-radius: 4px; padding: 8px;
|
||||
color: var(--brand-primary); font-size: 13px; cursor: pointer;
|
||||
}
|
||||
.ht-file-add:hover { border-color: var(--brand-primary); }
|
||||
|
||||
/* 上传进度条 */
|
||||
.ht-file-progress {
|
||||
flex: 1;
|
||||
@@ -220,6 +347,9 @@ function onRemove() {
|
||||
.file-name:hover { color: var(--brand-primary); text-decoration: underline; }
|
||||
.file-type { font-size: 12px; color: #909399; }
|
||||
.remove-btn { flex-shrink: 0; }
|
||||
.file-actions { display: flex; flex-direction: row; align-items: center; gap: 12px; flex-shrink: 0; }
|
||||
.download-btn { color: var(--brand-primary); text-decoration: none; }
|
||||
.download-btn:hover { text-decoration: underline; }
|
||||
|
||||
/* 右侧预览框 (方形, 64x64) */
|
||||
.preview-box {
|
||||
|
||||
Reference in New Issue
Block a user