提交
This commit is contained in:
1 parent
8248e5ef15
commit
b9b4cc2673
57 files changed
+42800
-30473
No files matched your search
@@ -1,89 +1,81 @@
|
||||
<!-- OA 审批详情 · 实例讨论评论(≠ 审批意见) -->
|
||||
<!-- OA 审批详情 · 评论输入(列表已并入审批进度时间线) -->
|
||||
<template>
|
||||
<section class="oa-comment-panel">
|
||||
<h3 class="oa-comment-panel__title">
|
||||
<el-icon class="oa-comment-panel__title-icon"><ChatDotRound /></el-icon>
|
||||
评论
|
||||
</h3>
|
||||
|
||||
<div v-if="!comments.length" class="oa-comment-panel__empty">暂无评论</div>
|
||||
<ul v-else class="oa-comment-panel__list">
|
||||
<li v-for="c in comments" :key="c.id" class="oa-comment-panel__item">
|
||||
<template v-if="c.status === 'revoked'">
|
||||
<span class="oa-comment-panel__revoked">
|
||||
{{ c.createByName || c.createBy }} 撤回了一条评论
|
||||
<span v-if="c.revokedTime" class="oa-comment-panel__time">{{ c.revokedTime }}</span>
|
||||
</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="oa-comment-panel__meta">
|
||||
<strong>{{ c.createByName || c.createBy }}</strong>
|
||||
<span class="oa-comment-panel__time">{{ c.createTime }}</span>
|
||||
<el-button
|
||||
v-if="c.canRevoke"
|
||||
link
|
||||
type="danger"
|
||||
:loading="revokingId === c.id"
|
||||
@click="onRevoke(c)"
|
||||
>
|
||||
<el-icon><RefreshLeft /></el-icon>
|
||||
撤回
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="oa-comment-panel__content">{{ c.content }}</div>
|
||||
<div v-if="c.attachmentRefs?.length" class="oa-comment-panel__refs">
|
||||
<el-tag
|
||||
v-for="(f, idx) in c.attachmentRefs"
|
||||
:key="`${c.id}-${idx}-${f.url}`"
|
||||
class="oa-comment-panel__ref"
|
||||
size="small"
|
||||
effect="plain"
|
||||
@click="openUrl(f.url)"
|
||||
>
|
||||
{{ f.fileName || f.url }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div v-if="instanceStatus === 'running'" class="oa-comment-panel__composer">
|
||||
<el-input
|
||||
v-model="draft"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
maxlength="1024"
|
||||
show-word-limit
|
||||
placeholder="填写评论"
|
||||
/>
|
||||
<div v-if="picked.length" class="oa-comment-panel__picked">
|
||||
<section v-if="instanceStatus === 'running'" class="oa-comment-panel">
|
||||
<div class="oa-comment-panel__composer">
|
||||
<div class="oa-comment-panel__editor">
|
||||
<el-input
|
||||
ref="inputRef"
|
||||
v-model="draft"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
maxlength="1024"
|
||||
show-word-limit
|
||||
placeholder="填写评论,输入 @ 可提到人员"
|
||||
@focus="onDraftFocus"
|
||||
@input="onDraftInput"
|
||||
@keydown="onDraftKeydown"
|
||||
/>
|
||||
<div v-if="atOpen" class="oa-comment-at" v-loading="atLoading">
|
||||
<button
|
||||
v-for="(u, idx) in atOptions"
|
||||
:key="u.id"
|
||||
type="button"
|
||||
class="oa-comment-at__item"
|
||||
:class="{ 'is-active': idx === atActive }"
|
||||
@mousedown.prevent="pickAtUser(u)"
|
||||
>
|
||||
<span class="oa-comment-at__name">{{ u.name }}</span>
|
||||
</button>
|
||||
<div v-if="!atLoading && !atOptions.length" class="oa-comment-at__empty">未找到人员</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="mentionUsers.length" class="oa-comment-panel__picked">
|
||||
<el-tag
|
||||
v-for="(f, idx) in picked"
|
||||
:key="`${f.url}-${idx}`"
|
||||
v-for="u in mentionUsers"
|
||||
:key="u.id"
|
||||
closable
|
||||
size="small"
|
||||
effect="plain"
|
||||
@close="picked.splice(idx, 1)"
|
||||
@close="removeMention(u.id)"
|
||||
>
|
||||
{{ f.fileName || f.url }}
|
||||
@{{ u.name }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<div v-if="picked.length" class="oa-comment-panel__files">
|
||||
<OaCommentFileCards :files="picked" removable @remove="removePicked" />
|
||||
</div>
|
||||
<div class="oa-comment-panel__actions">
|
||||
<el-button class="btn-ghost" @click="openMention">
|
||||
<el-icon><User /></el-icon>
|
||||
@人员
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" @click="openAttach">
|
||||
<el-icon><Paperclip /></el-icon>
|
||||
引用附件
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :loading="uploading" @click="pickUpload">
|
||||
<el-icon><Upload /></el-icon>
|
||||
上传附件
|
||||
</el-button>
|
||||
<el-button type="primary" class="btn-main" :loading="sending" @click="onSend">
|
||||
<el-icon><Promotion /></el-icon>
|
||||
发送
|
||||
</el-button>
|
||||
</div>
|
||||
<input
|
||||
ref="fileInputRef"
|
||||
class="oa-comment-file-input"
|
||||
type="file"
|
||||
multiple
|
||||
:accept="OA_UPLOAD_ACCEPT"
|
||||
@change="onUploadFiles"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
v-model="attachVisible"
|
||||
title="引用表单附件"
|
||||
width="560px"
|
||||
width="640px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
append-to-body
|
||||
@@ -95,21 +87,43 @@
|
||||
<div v-if="!attachLoading && !attachGroups.length" class="oa-comment-attach__empty">
|
||||
暂无可引用附件
|
||||
</div>
|
||||
<el-checkbox-group v-else v-model="selectedUrls" class="oa-comment-attach__groups">
|
||||
<div v-else class="oa-comment-attach__groups">
|
||||
<div v-for="g in attachGroups" :key="g.fieldKey" class="oa-comment-attach__group">
|
||||
<div class="oa-comment-attach__label">{{ g.fieldLabel || g.fieldKey }}</div>
|
||||
<div class="oa-comment-attach__files">
|
||||
<el-checkbox
|
||||
<button
|
||||
v-for="f in g.files"
|
||||
:key="f.url"
|
||||
:value="f.url"
|
||||
class="oa-comment-attach__file"
|
||||
type="button"
|
||||
class="oa-comment-attach__card"
|
||||
:class="{ 'is-selected': isSelected(f.url) }"
|
||||
:title="f.fileName || f.url"
|
||||
@click="toggleUrl(f.url)"
|
||||
>
|
||||
{{ f.fileName || f.url }}
|
||||
</el-checkbox>
|
||||
<div class="oa-comment-attach__thumb">
|
||||
<img
|
||||
v-if="isImageRef(f)"
|
||||
:src="thumbSrc(f.url)"
|
||||
:alt="f.fileName || '附件'"
|
||||
/>
|
||||
<div
|
||||
v-else-if="isVideoRef(f)"
|
||||
class="oa-comment-attach__icon oa-comment-attach__icon--video"
|
||||
>
|
||||
<el-icon :size="16"><VideoPlay /></el-icon>
|
||||
</div>
|
||||
<div v-else class="oa-comment-attach__icon oa-comment-attach__icon--doc">
|
||||
<el-icon :size="16"><Document /></el-icon>
|
||||
</div>
|
||||
<span v-if="isSelected(f.url)" class="oa-comment-attach__check">
|
||||
<el-icon :size="12"><Check /></el-icon>
|
||||
</span>
|
||||
</div>
|
||||
<div class="oa-comment-attach__name">{{ f.fileName || f.url }}</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</el-checkbox-group>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="attachVisible = false">
|
||||
@@ -127,46 +141,98 @@
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
v-model="mentionVisible"
|
||||
title="提到人员"
|
||||
width="480px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
append-to-body
|
||||
modal-class="protocol-dialog-mask"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-select
|
||||
v-model="mentionDraftIds"
|
||||
multiple
|
||||
filterable
|
||||
:loading="userLoading"
|
||||
placeholder="搜索姓名"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="u in dialogUserOptions"
|
||||
:key="u.id"
|
||||
:label="u.name"
|
||||
:value="u.id"
|
||||
/>
|
||||
</el-select>
|
||||
<template #footer>
|
||||
<el-button @click="mentionVisible = false">
|
||||
<el-icon><Close /></el-icon>
|
||||
取消
|
||||
</el-button>
|
||||
<el-button type="primary" @click="confirmMention">
|
||||
<el-icon><Check /></el-icon>
|
||||
确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
ChatDotRound,
|
||||
Check,
|
||||
Close,
|
||||
Paperclip,
|
||||
Promotion,
|
||||
RefreshLeft
|
||||
} from '@element-plus/icons-vue'
|
||||
import { Check, Close, Document, Paperclip, Promotion, Upload, User, VideoPlay } from '@element-plus/icons-vue'
|
||||
import { fetchUserOptions } from '@/api/admin'
|
||||
import { fetchUploadAttachment } from '@/api/business'
|
||||
import {
|
||||
fetchCreateOaComment,
|
||||
fetchOaFormAttachments,
|
||||
fetchRevokeOaComment,
|
||||
type OaCommentAttachmentRef,
|
||||
type OaInstanceComment
|
||||
type OaCommentAttachmentRef
|
||||
} from '@/api/oaApproval'
|
||||
import OaCommentFileCards from '@/components/oa-approval/OaCommentFileCards.vue'
|
||||
import { attachmentFullUrl } from '@/composables/useAttachmentActions'
|
||||
import { isOaUploadImageFile, isOaUploadVideoFile } from '@/utils/oa-upload-file-type'
|
||||
|
||||
defineOptions({ name: 'OaCommentPanel' })
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
instanceId: string
|
||||
instanceStatus: string
|
||||
comments?: OaInstanceComment[]
|
||||
}>(),
|
||||
{
|
||||
comments: () => []
|
||||
}
|
||||
)
|
||||
type MentionUser = { id: string; name: string }
|
||||
|
||||
const props = defineProps<{
|
||||
instanceId: string
|
||||
instanceStatus: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{ refresh: [] }>()
|
||||
|
||||
const inputRef = ref<any>(null)
|
||||
const draft = ref('')
|
||||
const picked = ref<OaCommentAttachmentRef[]>([])
|
||||
const sending = ref(false)
|
||||
const revokingId = ref('')
|
||||
const uploading = ref(false)
|
||||
const fileInputRef = ref<HTMLInputElement | null>(null)
|
||||
const OA_UPLOAD_ACCEPT = 'image/*,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.zip,.rar'
|
||||
const mentionUsers = ref<MentionUser[]>([])
|
||||
const mentionVisible = ref(false)
|
||||
const mentionDraftIds = ref<string[]>([])
|
||||
const userLoading = ref(false)
|
||||
|
||||
/** 租户内启用用户缓存:@ 与弹窗共用,本地过滤,避免每次请求 */
|
||||
const allMentionUsers = ref<MentionUser[]>([])
|
||||
let userCachePromise: Promise<void> | null = null
|
||||
|
||||
const dialogUserOptions = computed(() => {
|
||||
const map = new Map(allMentionUsers.value.map((u) => [u.id, u]))
|
||||
for (const u of mentionUsers.value) map.set(u.id, u)
|
||||
return [...map.values()]
|
||||
})
|
||||
|
||||
const atOpen = ref(false)
|
||||
const atQuery = ref('')
|
||||
const atStart = ref(-1)
|
||||
const atActive = ref(0)
|
||||
const atOptions = ref<MentionUser[]>([])
|
||||
const atLoading = ref(false)
|
||||
|
||||
const attachVisible = ref(false)
|
||||
const attachLoading = ref(false)
|
||||
@@ -175,15 +241,238 @@
|
||||
>([])
|
||||
const selectedUrls = ref<string[]>([])
|
||||
|
||||
function openUrl(url: string) {
|
||||
const full = attachmentFullUrl(url) || url
|
||||
if (full) window.open(full, '_blank')
|
||||
function getTextareaEl(): HTMLTextAreaElement | null {
|
||||
const inst = inputRef.value
|
||||
if (!inst) return null
|
||||
if (inst.textarea instanceof HTMLTextAreaElement) return inst.textarea
|
||||
const el = inst.$el as HTMLElement | undefined
|
||||
return (el?.querySelector?.('textarea') as HTMLTextAreaElement | null) || null
|
||||
}
|
||||
|
||||
async function ensureUserCache() {
|
||||
if (allMentionUsers.value.length) return
|
||||
if (userCachePromise) return userCachePromise
|
||||
userCachePromise = (async () => {
|
||||
try {
|
||||
const res = await fetchUserOptions()
|
||||
const list = Array.isArray(res) ? res : []
|
||||
const next: MentionUser[] = []
|
||||
const seen = new Set<string>()
|
||||
for (const u of list) {
|
||||
const id = String(u?.value || '').trim()
|
||||
if (!id || seen.has(id)) continue
|
||||
seen.add(id)
|
||||
const name = String(u?.label || id).trim() || id
|
||||
next.push({ id, name })
|
||||
}
|
||||
allMentionUsers.value = next
|
||||
} catch {
|
||||
allMentionUsers.value = []
|
||||
} finally {
|
||||
userCachePromise = null
|
||||
}
|
||||
})()
|
||||
return userCachePromise
|
||||
}
|
||||
|
||||
function filterMentionUsers(keyword: string, excludeIds?: Set<string>): MentionUser[] {
|
||||
const q = (keyword || '').trim().toLowerCase()
|
||||
const out: MentionUser[] = []
|
||||
for (const u of allMentionUsers.value) {
|
||||
if (excludeIds?.has(u.id)) continue
|
||||
if (q && !u.name.toLowerCase().includes(q) && !u.id.toLowerCase().includes(q)) {
|
||||
continue
|
||||
}
|
||||
out.push(u)
|
||||
if (out.length >= 30) break
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
function closeAtSuggest() {
|
||||
atOpen.value = false
|
||||
atQuery.value = ''
|
||||
atStart.value = -1
|
||||
atActive.value = 0
|
||||
atOptions.value = []
|
||||
}
|
||||
|
||||
async function applyAtSuggest(query: string) {
|
||||
const needFetch = !allMentionUsers.value.length
|
||||
if (needFetch) atLoading.value = true
|
||||
try {
|
||||
await ensureUserCache()
|
||||
if (!atOpen.value) return
|
||||
const pickedIds = new Set(mentionUsers.value.map((u) => u.id))
|
||||
atOptions.value = filterMentionUsers(query, pickedIds)
|
||||
if (atActive.value >= atOptions.value.length) {
|
||||
atActive.value = Math.max(0, atOptions.value.length - 1)
|
||||
}
|
||||
} finally {
|
||||
atLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function detectAtSuggest() {
|
||||
const ta = getTextareaEl()
|
||||
if (!ta) {
|
||||
closeAtSuggest()
|
||||
return
|
||||
}
|
||||
const pos = ta.selectionStart ?? 0
|
||||
const before = draft.value.slice(0, pos)
|
||||
const matched = before.match(/(?:^|[\s\n])(@([^\s@]*))$/)
|
||||
if (!matched) {
|
||||
closeAtSuggest()
|
||||
return
|
||||
}
|
||||
const token = matched[1] || ''
|
||||
const query = matched[2] || ''
|
||||
atStart.value = before.length - token.length
|
||||
atQuery.value = query
|
||||
atOpen.value = true
|
||||
atActive.value = 0
|
||||
// 有缓存则同步过滤;无缓存才拉一次
|
||||
if (allMentionUsers.value.length) {
|
||||
const pickedIds = new Set(mentionUsers.value.map((u) => u.id))
|
||||
atOptions.value = filterMentionUsers(query, pickedIds)
|
||||
} else {
|
||||
void applyAtSuggest(query)
|
||||
}
|
||||
}
|
||||
|
||||
function onDraftInput() {
|
||||
nextTick(() => detectAtSuggest())
|
||||
}
|
||||
|
||||
function onDraftFocus() {
|
||||
void ensureUserCache()
|
||||
}
|
||||
|
||||
function onDraftKeydown(e: KeyboardEvent) {
|
||||
if (!atOpen.value) return
|
||||
if (e.key === 'ArrowDown') {
|
||||
e.preventDefault()
|
||||
if (!atOptions.value.length) return
|
||||
atActive.value = (atActive.value + 1) % atOptions.value.length
|
||||
return
|
||||
}
|
||||
if (e.key === 'ArrowUp') {
|
||||
e.preventDefault()
|
||||
if (!atOptions.value.length) return
|
||||
atActive.value = (atActive.value - 1 + atOptions.value.length) % atOptions.value.length
|
||||
return
|
||||
}
|
||||
if (e.key === 'Enter' || e.key === 'Tab') {
|
||||
const u = atOptions.value[atActive.value]
|
||||
if (!u) return
|
||||
e.preventDefault()
|
||||
pickAtUser(u)
|
||||
return
|
||||
}
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault()
|
||||
closeAtSuggest()
|
||||
}
|
||||
}
|
||||
|
||||
function addMentionUser(u: MentionUser) {
|
||||
if (mentionUsers.value.some((x) => x.id === u.id)) return true
|
||||
if (mentionUsers.value.length >= 20) {
|
||||
ElMessage.warning('一次最多@20人')
|
||||
return false
|
||||
}
|
||||
mentionUsers.value.push(u)
|
||||
return true
|
||||
}
|
||||
|
||||
function pickAtUser(u: MentionUser) {
|
||||
if (!addMentionUser(u)) return
|
||||
const start = atStart.value
|
||||
if (start < 0) {
|
||||
closeAtSuggest()
|
||||
return
|
||||
}
|
||||
const ta = getTextareaEl()
|
||||
const end = ta?.selectionStart ?? draft.value.length
|
||||
const insert = `@${u.name} `
|
||||
draft.value = `${draft.value.slice(0, start)}${insert}${draft.value.slice(end)}`
|
||||
closeAtSuggest()
|
||||
nextTick(() => {
|
||||
const el = getTextareaEl()
|
||||
if (!el) return
|
||||
const pos = start + insert.length
|
||||
el.focus()
|
||||
el.setSelectionRange(pos, pos)
|
||||
})
|
||||
}
|
||||
|
||||
function fileLike(f: OaCommentAttachmentRef) {
|
||||
return { url: f.url, name: f.fileName }
|
||||
}
|
||||
|
||||
function isImageRef(f: OaCommentAttachmentRef) {
|
||||
return isOaUploadImageFile(fileLike(f))
|
||||
}
|
||||
|
||||
function isVideoRef(f: OaCommentAttachmentRef) {
|
||||
return isOaUploadVideoFile(fileLike(f))
|
||||
}
|
||||
|
||||
function thumbSrc(url: string) {
|
||||
return attachmentFullUrl(url) || url
|
||||
}
|
||||
|
||||
function isSelected(url: string) {
|
||||
return selectedUrls.value.includes(url)
|
||||
}
|
||||
|
||||
function toggleUrl(url: string) {
|
||||
const u = String(url || '').trim()
|
||||
if (!u) return
|
||||
const idx = selectedUrls.value.indexOf(u)
|
||||
if (idx >= 0) selectedUrls.value.splice(idx, 1)
|
||||
else selectedUrls.value.push(u)
|
||||
}
|
||||
|
||||
function removeMention(id: string) {
|
||||
mentionUsers.value = mentionUsers.value.filter((u) => u.id !== id)
|
||||
}
|
||||
|
||||
async function openMention() {
|
||||
closeAtSuggest()
|
||||
mentionDraftIds.value = mentionUsers.value.map((u) => u.id)
|
||||
mentionVisible.value = true
|
||||
userLoading.value = !allMentionUsers.value.length
|
||||
try {
|
||||
await ensureUserCache()
|
||||
} finally {
|
||||
userLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function confirmMention() {
|
||||
const map = new Map(allMentionUsers.value.map((u) => [u.id, u.name]))
|
||||
for (const u of mentionUsers.value) map.set(u.id, u.name)
|
||||
const next = mentionDraftIds.value
|
||||
.map((id) => ({ id, name: map.get(id) || id }))
|
||||
.slice(0, 20)
|
||||
mentionUsers.value = next
|
||||
for (const u of next) {
|
||||
const token = `@${u.name}`
|
||||
if (!draft.value.includes(token)) {
|
||||
draft.value = `${draft.value.trimEnd()}${draft.value.trim() ? ' ' : ''}${token} `
|
||||
}
|
||||
}
|
||||
mentionVisible.value = false
|
||||
}
|
||||
|
||||
async function openAttach() {
|
||||
attachVisible.value = true
|
||||
attachLoading.value = true
|
||||
selectedUrls.value = picked.value.map((f) => f.url)
|
||||
selectedUrls.value = picked.value
|
||||
.filter((f) => f.source !== 'upload')
|
||||
.map((f) => f.url)
|
||||
try {
|
||||
const res = await fetchOaFormAttachments(props.instanceId)
|
||||
const items = res?.items || []
|
||||
@@ -206,29 +495,76 @@
|
||||
if (f?.url) map.set(f.url, f)
|
||||
}
|
||||
}
|
||||
const next: OaCommentAttachmentRef[] = []
|
||||
const cited: OaCommentAttachmentRef[] = []
|
||||
for (const url of selectedUrls.value) {
|
||||
const found = map.get(url) || picked.value.find((p) => p.url === url)
|
||||
if (found) next.push({ ...found })
|
||||
const found = map.get(url) || picked.value.find((p) => p.url === url && p.source !== 'upload')
|
||||
if (found) cited.push({ ...found, source: 'form' })
|
||||
}
|
||||
picked.value = next
|
||||
const uploads = picked.value.filter((f) => f.source === 'upload')
|
||||
picked.value = [...cited, ...uploads]
|
||||
attachVisible.value = false
|
||||
}
|
||||
|
||||
function removePicked(index: number) {
|
||||
picked.value.splice(index, 1)
|
||||
}
|
||||
|
||||
function pickUpload() {
|
||||
fileInputRef.value?.click()
|
||||
}
|
||||
|
||||
async function onUploadFiles(ev: Event) {
|
||||
const input = ev.target as HTMLInputElement
|
||||
const files = Array.from(input.files || [])
|
||||
input.value = ''
|
||||
if (!files.length) return
|
||||
uploading.value = true
|
||||
try {
|
||||
for (const file of files) {
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
fd.append('folder', 'oa-approval')
|
||||
const res: any = await fetchUploadAttachment(fd)
|
||||
const url = String(res?.fileUrl || res?.data?.fileUrl || '').trim()
|
||||
if (!url) {
|
||||
ElMessage.error(`${file.name || '文件'} 上传失败`)
|
||||
continue
|
||||
}
|
||||
if (picked.value.some((p) => p.url === url)) continue
|
||||
picked.value.push({
|
||||
source: 'upload',
|
||||
fieldKey: '',
|
||||
fieldLabel: '',
|
||||
url,
|
||||
fileName: String(res?.fileName || res?.data?.fileName || file.name || '').trim() || file.name
|
||||
})
|
||||
}
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '上传失败')
|
||||
} finally {
|
||||
uploading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function onSend() {
|
||||
const content = draft.value.trim()
|
||||
if (!content) {
|
||||
ElMessage.warning('请填写评论')
|
||||
if (!content && !mentionUsers.value.length && !picked.value.length) {
|
||||
ElMessage.warning('请填写评论、@人员或添加附件')
|
||||
return
|
||||
}
|
||||
sending.value = true
|
||||
try {
|
||||
await fetchCreateOaComment(props.instanceId, {
|
||||
content,
|
||||
attachmentRefs: picked.value.length ? [...picked.value] : undefined
|
||||
attachmentRefs: picked.value.length ? [...picked.value] : undefined,
|
||||
mentionUserIds: mentionUsers.value.length
|
||||
? mentionUsers.value.map((u) => u.id)
|
||||
: undefined
|
||||
})
|
||||
draft.value = ''
|
||||
picked.value = []
|
||||
mentionUsers.value = []
|
||||
closeAtSuggest()
|
||||
ElMessage.success('已发送')
|
||||
emit('refresh')
|
||||
} catch (e: any) {
|
||||
@@ -238,101 +574,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function onRevoke(c: OaInstanceComment) {
|
||||
try {
|
||||
await ElMessageBox.confirm('确定撤回该评论吗?', '提示', { type: 'warning' })
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
revokingId.value = c.id
|
||||
try {
|
||||
await fetchRevokeOaComment(props.instanceId, c.id)
|
||||
ElMessage.success('已撤回')
|
||||
emit('refresh')
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '撤回失败')
|
||||
} finally {
|
||||
revokingId.value = ''
|
||||
}
|
||||
}
|
||||
onMounted(() => {
|
||||
void ensureUserCache()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.oa-comment-panel {
|
||||
max-width: 960px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.oa-comment-panel__title {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
margin: 16px 0 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--mint-text, #0f172a);
|
||||
.oa-comment-file-input {
|
||||
position: absolute;
|
||||
width: 0;
|
||||
height: 0;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.oa-comment-panel__title-icon {
|
||||
color: var(--primary, #10b981);
|
||||
font-size: 16px;
|
||||
.oa-comment-panel__files {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.oa-comment-panel__empty {
|
||||
padding: 8px 0 12px;
|
||||
color: var(--mint-text-muted, #94a3b8);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.oa-comment-panel__list {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.oa-comment-panel__item {
|
||||
padding: 10px 0;
|
||||
border-bottom: 1px solid var(--mint-border, #e2e8f0);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.oa-comment-panel__revoked {
|
||||
color: var(--mint-text-muted, #94a3b8);
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.oa-comment-panel__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
margin-bottom: 6px;
|
||||
|
||||
strong {
|
||||
color: var(--mint-text-strong, #0f172a);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.oa-comment-panel__time {
|
||||
margin-left: 4px;
|
||||
color: var(--mint-text-muted, #94a3b8);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.oa-comment-panel__content {
|
||||
color: var(--mint-text, #334155);
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.oa-comment-panel__refs,
|
||||
.oa-comment-panel__picked {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
@@ -340,29 +604,65 @@
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.oa-comment-panel__ref {
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
color: var(--primary-dark, #059669);
|
||||
border-color: #a7f3d0;
|
||||
background: var(--primary-bg, #ecfdf5);
|
||||
}
|
||||
.oa-comment-panel__composer {
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.oa-comment-panel__composer {
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid var(--mint-border, #e2e8f0);
|
||||
.oa-comment-panel__editor {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.oa-comment-panel__actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
justify-content: flex-end;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.oa-comment-at {
|
||||
position: absolute;
|
||||
top: calc(100% - 28px);
|
||||
left: 0;
|
||||
z-index: 20;
|
||||
width: min(320px, 100%);
|
||||
max-height: 220px;
|
||||
overflow: auto;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
|
||||
}
|
||||
|
||||
.oa-comment-at__item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
min-height: 36px;
|
||||
padding: 6px 12px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
border: none;
|
||||
|
||||
&:hover,
|
||||
&.is-active {
|
||||
background: var(--primary-bg, #ecfdf5);
|
||||
}
|
||||
}
|
||||
|
||||
.oa-comment-at__name {
|
||||
color: var(--mint-text-strong, #0f172a);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.oa-comment-at__empty {
|
||||
padding: 12px;
|
||||
color: var(--mint-text-muted, #94a3b8);
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.oa-comment-attach {
|
||||
min-height: 80px;
|
||||
}
|
||||
@@ -376,26 +676,110 @@
|
||||
|
||||
.oa-comment-attach__groups {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
gap: 16px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.oa-comment-attach__label {
|
||||
margin-bottom: 6px;
|
||||
margin-bottom: 8px;
|
||||
color: var(--mint-text-strong, #0f172a);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.oa-comment-attach__files {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.oa-comment-attach__file {
|
||||
margin-right: 0;
|
||||
height: auto;
|
||||
white-space: normal;
|
||||
align-items: flex-start;
|
||||
.oa-comment-attach__card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 88px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
transition:
|
||||
border-color 0.15s,
|
||||
box-shadow 0.15s;
|
||||
|
||||
&:hover {
|
||||
border-color: #a7f3d0;
|
||||
box-shadow: 0 2px 8px rgba(16, 185, 129, 0.12);
|
||||
}
|
||||
|
||||
&.is-selected {
|
||||
border-color: var(--primary, #10b981);
|
||||
box-shadow: 0 0 0 1px var(--primary, #10b981);
|
||||
}
|
||||
}
|
||||
|
||||
.oa-comment-attach__thumb {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 64px;
|
||||
overflow: hidden;
|
||||
background: #f8fafc;
|
||||
|
||||
img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
.oa-comment-attach__icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 8px;
|
||||
|
||||
&--video {
|
||||
color: #7c3aed;
|
||||
background: #ede9fe;
|
||||
}
|
||||
|
||||
&--doc {
|
||||
color: #0284c7;
|
||||
background: #e0f2fe;
|
||||
}
|
||||
}
|
||||
|
||||
.oa-comment-attach__check {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 4px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
color: #fff;
|
||||
background: var(--primary, #10b981);
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.18);
|
||||
}
|
||||
|
||||
.oa-comment-attach__name {
|
||||
display: -webkit-box;
|
||||
margin: 0;
|
||||
padding: 4px 6px;
|
||||
overflow: hidden;
|
||||
color: var(--mint-text, #334155);
|
||||
font-size: 11px;
|
||||
line-height: 1.3;
|
||||
word-break: break-all;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user