This commit is contained in:
zlwu committed 2026-06-07 00:40:01 +08:00
1 parent f9676f8759
commit 725774ef0c
155 files changed
+50675 -5242

No files matched your search

@@ -0,0 +1,223 @@
<script setup lang="ts">
import { computed } from 'vue'
import { Check, Close, Clock } from '@element-plus/icons-vue'
interface ApprovalNode {
id: number
nodeName: string
nodeOrder: number
approvalStatus: string
approvalOpinion?: string | null
approverName: string
approvalTime?: string | null
}
const props = withDefaults(
defineProps<{
nodes: ApprovalNode[]
loading?: boolean
}>(),
{
loading: false
}
)
const statusConfig: Record<string, { color: string; text: string; icon: any; circleClass: string }> = {
approved: { color: 'var(--success)', text: '已通过', icon: Check, circleClass: 'is-approved' },
rejected: { color: 'var(--danger)', text: '已驳回', icon: Close, circleClass: 'is-rejected' },
pending: { color: 'var(--primary)', text: '待处理', icon: Clock, circleClass: 'is-pending' }
}
function getConfig(status: string) {
return (
statusConfig[status] || {
color: 'var(--text-muted)',
text: '未知',
icon: null,
circleClass: 'is-pending'
}
)
}
const sortedNodes = computed(() =>
[...props.nodes].sort((a, b) => a.nodeOrder - b.nodeOrder)
)
function connectorClass(index: number) {
const node = sortedNodes.value[index]
return node?.approvalStatus === 'approved' ? 'is-done' : ''
}
</script>
<template>
<div class="approval-flow-view">
<el-skeleton v-if="loading" :rows="2" animated />
<template v-else>
<p v-if="sortedNodes.length === 0" class="approval-empty">暂无审批记录</p>
<div v-else class="approval-flow-scroll">
<div class="approval-flow-track">
<template v-for="(node, index) in sortedNodes" :key="node.id">
<div class="approval-flow-step">
<div
class="approval-flow-circle"
:class="getConfig(node.approvalStatus).circleClass"
>
<el-icon v-if="getConfig(node.approvalStatus).icon" class="approval-status-icon">
<component :is="getConfig(node.approvalStatus).icon" />
</el-icon>
</div>
<div class="approval-flow-label">{{ node.nodeName }}</div>
<div
class="approval-flow-status"
:style="{ color: getConfig(node.approvalStatus).color }"
>
{{ getConfig(node.approvalStatus).text }}
</div>
<div class="approval-flow-meta">
<span v-if="node.approverName">审批人:{{ node.approverName }}</span>
<span v-if="node.approvalTime">{{ node.approvalTime }}</span>
</div>
<div v-if="node.approvalOpinion" class="approval-flow-opinion">
{{ node.approvalOpinion }}
</div>
</div>
<div
v-if="index < sortedNodes.length - 1"
class="approval-flow-connector"
:class="connectorClass(index)"
/>
</template>
</div>
</div>
</template>
</div>
</template>
<style scoped>
.approval-flow-view {
padding: 4px 0;
}
.approval-empty {
margin: 0;
text-align: center;
color: var(--text-muted);
font-size: 13px;
padding: 24px 0;
}
.approval-flow-scroll {
overflow-x: auto;
padding: 8px 4px 12px;
}
.approval-flow-track {
display: flex;
align-items: flex-start;
justify-content: flex-start;
gap: 0;
min-width: min-content;
padding: 4px 8px;
}
.approval-flow-step {
display: flex;
flex-direction: column;
align-items: center;
gap: 6px;
width: 132px;
flex: 0 0 auto;
text-align: center;
}
.approval-flow-circle {
width: 36px;
height: 36px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
border: 2px solid #e2e8f0;
background: #f8fafc;
color: #94a3b8;
}
.approval-flow-circle.is-approved {
border-color: var(--success, #10b981);
background: linear-gradient(135deg, #10b981, #059669);
color: #fff;
box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}
.approval-flow-circle.is-rejected {
border-color: var(--danger, #ef4444);
background: #fef2f2;
color: var(--danger, #ef4444);
}
.approval-flow-circle.is-pending {
border-color: var(--primary, #10b981);
background: #fff;
color: var(--primary, #10b981);
}
.approval-status-icon {
width: 16px;
height: 16px;
}
.approval-flow-label {
font-size: 13px;
font-weight: 600;
color: var(--text);
line-height: 1.3;
}
.approval-flow-status {
font-size: 12px;
font-weight: 600;
}
.approval-flow-meta {
display: flex;
flex-direction: column;
gap: 2px;
font-size: 11px;
color: var(--text-muted);
line-height: 1.35;
word-break: break-all;
}
.approval-flow-opinion {
font-size: 11px;
color: var(--text-muted);
line-height: 1.35;
max-width: 120px;
word-break: break-all;
}
.approval-flow-connector {
width: 56px;
height: 2px;
background: #e2e8f0;
margin-top: 18px;
flex-shrink: 0;
position: relative;
}
.approval-flow-connector.is-done {
background: linear-gradient(90deg, #10b981, #34d399);
}
.approval-flow-connector.is-done::after {
content: '';
position: absolute;
right: -3px;
top: -3px;
width: 8px;
height: 8px;
border-top: 2px solid #10b981;
border-right: 2px solid #10b981;
transform: rotate(45deg);
}
</style>
@@ -0,0 +1,202 @@
<script setup lang="ts">
import { computed } from 'vue'
import { Check, Close, Clock } from '@element-plus/icons-vue'
interface ApprovalHistoryItem {
id: number | string
nodeName: string
nodeOrder: number
approvalStatus: string
approvalOpinion?: string | null
approverName: string
approvalTime?: string | null
}
const props = withDefaults(
defineProps<{
items: ApprovalHistoryItem[]
loading?: boolean
}>(),
{
loading: false
}
)
const statusConfig: Record<string, { color: string; text: string; icon: any; circleClass: string }> = {
approved: { color: 'var(--success)', text: '已通过', icon: Check, circleClass: 'is-approved' },
rejected: { color: 'var(--danger)', text: '已驳回', icon: Close, circleClass: 'is-rejected' },
pending: { color: 'var(--primary)', text: '待处理', icon: Clock, circleClass: 'is-pending' }
}
function getConfig(status: string) {
return (
statusConfig[status] || {
color: 'var(--text-muted)',
text: '未知',
icon: null,
circleClass: 'is-pending'
}
)
}
const sortedItems = computed(() =>
[...props.items].sort((a, b) => {
const ta = a.approvalTime ? new Date(a.approvalTime).getTime() : 0
const tb = b.approvalTime ? new Date(b.approvalTime).getTime() : 0
if (ta !== tb) return ta - tb
return a.nodeOrder - b.nodeOrder
})
)
</script>
<template>
<div class="approval-history-view">
<el-skeleton v-if="loading" :rows="2" animated />
<template v-else>
<p v-if="sortedItems.length === 0" class="approval-empty">暂无审批历史</p>
<div v-else class="approval-history-scroll">
<div class="approval-history-track">
<template v-for="(item, index) in sortedItems" :key="item.id">
<div class="approval-history-step">
<div
class="approval-history-circle"
:class="getConfig(item.approvalStatus).circleClass"
>
<el-icon v-if="getConfig(item.approvalStatus).icon" class="approval-status-icon">
<component :is="getConfig(item.approvalStatus).icon" />
</el-icon>
</div>
<div class="approval-history-label">{{ item.nodeName }}</div>
<div
class="approval-history-status"
:style="{ color: getConfig(item.approvalStatus).color }"
>
{{ getConfig(item.approvalStatus).text }}
</div>
<div class="approval-history-meta">
<span v-if="item.approverName">审批人:{{ item.approverName }}</span>
<span v-if="item.approvalTime">{{ item.approvalTime }}</span>
</div>
<div v-if="item.approvalOpinion" class="approval-history-opinion">
{{ item.approvalOpinion }}
</div>
</div>
<div v-if="index < sortedItems.length - 1" class="approval-history-connector" />
</template>
</div>
</div>
</template>
</div>
</template>
<style scoped>
.approval-history-view {
padding: 4px 0;
}
.approval-empty {
margin: 0;
text-align: center;
color: var(--text-muted);
font-size: 13px;
padding: 24px 0;
}
.approval-history-scroll {
overflow-x: auto;
padding: 8px 4px 12px;
}
.approval-history-track {
display: flex;
align-items: flex-start;
justify-content: flex-start;
gap: 0;
min-width: min-content;
padding: 4px 8px;
}
.approval-history-step {
display: flex;
flex-direction: column;
align-items: center;
gap: 6px;
width: 132px;
flex: 0 0 auto;
text-align: center;
}
.approval-history-circle {
width: 36px;
height: 36px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
border: 2px solid #e2e8f0;
background: #f8fafc;
color: #94a3b8;
}
.approval-history-circle.is-approved {
border-color: var(--success, #10b981);
background: linear-gradient(135deg, #10b981, #059669);
color: #fff;
box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}
.approval-history-circle.is-rejected {
border-color: var(--danger, #ef4444);
background: #fef2f2;
color: var(--danger, #ef4444);
}
.approval-history-circle.is-pending {
border-color: var(--primary, #10b981);
background: #fff;
color: var(--primary, #10b981);
}
.approval-status-icon {
width: 16px;
height: 16px;
}
.approval-history-label {
font-size: 13px;
font-weight: 600;
color: var(--text);
line-height: 1.3;
}
.approval-history-status {
font-size: 12px;
font-weight: 600;
}
.approval-history-meta {
display: flex;
flex-direction: column;
gap: 2px;
font-size: 11px;
color: var(--text-muted);
line-height: 1.35;
word-break: break-all;
}
.approval-history-opinion {
font-size: 11px;
color: var(--text-muted);
line-height: 1.35;
max-width: 120px;
word-break: break-all;
}
.approval-history-connector {
width: 40px;
height: 2px;
background: #cbd5e1;
margin-top: 18px;
flex-shrink: 0;
}
</style>
@@ -0,0 +1,29 @@
<script setup lang="ts">
import type { Component } from 'vue'
defineProps<{
type?: '' | 'primary' | 'success' | 'warning' | 'info' | 'danger'
loading?: boolean
link?: boolean
plain?: boolean
icon?: Component
}>()
const emit = defineEmits<{
click: [event: MouseEvent]
}>()
</script>
<template>
<el-button
class="bx-btn"
:type="type"
:loading="loading"
:link="link"
:plain="plain"
@click="emit('click', $event)"
>
<el-icon v-if="icon" class="ic"><component :is="icon" /></el-icon>
<slot />
</el-button>
</template>
@@ -0,0 +1,124 @@
<script setup lang="ts">
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
const props = withDefaults(defineProps<{
text?: string | number | null
lines?: number
expandText?: string
collapseText?: string
}>(), {
text: '',
lines: 3,
expandText: '展开',
collapseText: '收起',
})
const expanded = ref(false)
const overflow = ref(false)
const contentRef = ref<HTMLElement>()
let resizeObserver: ResizeObserver | null = null
const displayText = computed(() => {
const value = props.text
if (value === null || value === undefined || String(value).trim() === '') {
return '-'
}
return String(value)
})
const clampStyle = computed(() => {
if (expanded.value) {
return {}
}
return {
WebkitLineClamp: String(props.lines),
}
})
const checkOverflow = async () => {
await nextTick()
const el = contentRef.value
if (!el) {
overflow.value = false
return
}
overflow.value = el.scrollHeight - el.clientHeight > 1
}
watch(() => props.text, () => {
expanded.value = false
checkOverflow()
})
watch(() => props.lines, () => {
expanded.value = false
checkOverflow()
})
onMounted(() => {
checkOverflow()
if (typeof ResizeObserver !== 'undefined' && contentRef.value) {
resizeObserver = new ResizeObserver(() => {
checkOverflow()
})
resizeObserver.observe(contentRef.value)
}
})
onBeforeUnmount(() => {
if (resizeObserver) {
resizeObserver.disconnect()
resizeObserver = null
}
})
</script>
<template>
<div class="clamp-wrap">
<div ref="contentRef" class="clamp-content" :class="{ expanded }" :style="clampStyle">
{{ displayText }}
</div>
<button
v-if="overflow"
type="button"
class="clamp-toggle"
@click="expanded = !expanded"
>
{{ expanded ? collapseText : expandText }}
</button>
</div>
</template>
<style scoped>
.clamp-wrap {
min-width: 0;
}
.clamp-content {
min-width: 0;
line-height: 1.5;
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
word-break: break-word;
}
.clamp-content.expanded {
display: block;
}
.clamp-toggle {
margin-top: 4px;
border: none;
background: transparent;
padding: 0;
color: var(--primary-dark);
font-size: 12px;
line-height: 1.2;
cursor: pointer;
}
.clamp-toggle:hover {
color: var(--primary);
}
</style>
@@ -0,0 +1,20 @@
<script setup lang="ts">
const props = withDefaults(defineProps<{
title: string
data?: any[]
emptyText?: string
embedded?: boolean
}>(), {
data: () => [],
emptyText: '暂无数据',
embedded: false,
})
</script>
<template>
<div :class="{ 'dlg-view-section': !embedded }">
<h4 v-if="!embedded" class="dlg-view-section-title">{{ title }}</h4>
<slot v-if="data.length" />
<el-empty v-else :description="emptyText" :image-size="56" />
</div>
</template>
@@ -0,0 +1,17 @@
<script setup lang="ts">
const visible = defineModel<boolean>({ required: true })
defineProps<{
title: string
width?: string
}>()
</script>
<template>
<el-dialog v-model="visible" :title="title" :width="width" class="bx-dialog" align-center>
<slot />
<template v-if="$slots.footer" #footer>
<slot name="footer" />
</template>
</el-dialog>
</template>
@@ -0,0 +1,32 @@
<script setup lang="ts">
const modelValue = defineModel<string | number | undefined>()
withDefaults(
defineProps<{
placeholder?: string
clearable?: boolean
type?: 'text' | 'textarea' | 'password'
rows?: number
disabled?: boolean
}>(),
{
placeholder: '',
clearable: true,
type: 'text',
rows: 3,
disabled: false
}
)
</script>
<template>
<el-input
v-model="modelValue"
class="bx-input"
:placeholder="placeholder"
:clearable="clearable"
:type="type"
:rows="rows"
:disabled="disabled"
/>
</template>
@@ -0,0 +1,26 @@
<script setup lang="ts">
import type { Component } from 'vue'
defineProps<{
primary?: boolean
loading?: boolean
icon?: Component
}>()
const emit = defineEmits<{
click: [event: MouseEvent]
}>()
</script>
<template>
<el-button
class="bx-op-btn"
:class="{ primary }"
:loading="loading"
@click="emit('click', $event)"
>
<el-icon v-if="icon" class="ic-sm"><component :is="icon" /></el-icon>
<slot />
</el-button>
</template>
@@ -0,0 +1,26 @@
<script setup lang="ts">
type Model = string | number | null | undefined
const modelValue = defineModel<Model>()
withDefaults(
defineProps<{
placeholder?: string
clearable?: boolean
}>(),
{
placeholder: '',
clearable: true
}
)
function handleClear() {
modelValue.value = undefined
}
</script>
<template>
<el-select v-model="modelValue" class="bx-select" :placeholder="placeholder" :clearable="clearable" @clear="handleClear">
<slot />
</el-select>
</template>
@@ -0,0 +1,40 @@
<script setup lang="ts">
import { ref } from 'vue'
defineProps<{
data: any[]
showSummary?: boolean
summaryMethod?: (...args: any[]) => any
height?: string | number
maxHeight?: string | number
}>()
const emit = defineEmits<{
selectionChange: [rows: any[]]
}>()
const elTableRef = ref<any>()
function toggleRowExpansion(row: any, expanded?: boolean) {
elTableRef.value?.toggleRowExpansion(row, expanded)
}
defineExpose({
toggleRowExpansion,
})
</script>
<template>
<el-table
ref="elTableRef"
class="bx-table"
:data="data"
:show-summary="showSummary"
:summary-method="summaryMethod"
:height="height"
:max-height="maxHeight"
@selection-change="(rows) => emit('selectionChange', rows)"
>
<slot />
</el-table>
</template>
@@ -0,0 +1,16 @@
<script setup lang="ts">
withDefaults(
defineProps<{
tone?: 'pending' | 'processing' | 'done' | 'warning' | 'error' | 'info'
}>(),
{
tone: 'info'
}
)
</script>
<template>
<span class="bx-tag" :class="`bx-tag--${tone}`">
<slot />
</span>
</template>
@@ -0,0 +1,99 @@
<template>
<div v-if="files.length" class="attachment-upload">
<div class="attachment-list">
<div
v-for="file in files"
:key="String(file.id)"
class="attachment-item"
>
<div
class="attachment-preview"
@click="canBxPreview(file) ? handlePreview(file) : undefined"
>
<template v-if="isBxImageFile(file) && file.previewUrl">
<img :src="file.previewUrl" :alt="file.fileName" />
</template>
<template v-else-if="isBxVideoFile(file)">
<div class="attachment-preview__icon attachment-preview__icon--video">
<el-icon :size="28"><VideoPlay /></el-icon>
</div>
</template>
<template v-else>
<div class="attachment-preview__icon attachment-preview__icon--doc">
<el-icon :size="28"><Document /></el-icon>
</div>
</template>
</div>
<div class="attachment-footer">
<span class="attachment-name" :title="file.fileName">{{ file.fileName }}</span>
<div class="attachment-actions">
<el-icon class="action-btn" title="下载" @click="handleDownload(file)">
<Download />
</el-icon>
</div>
</div>
</div>
</div>
<el-dialog
v-model="previewVisible"
title="附件预览"
width="800px"
align-center
destroy-on-close
append-to-body
>
<img
v-if="previewMode === 'image' && previewUrl"
:src="previewUrl"
:alt="previewFileName"
class="bx-attachment-preview-media"
/>
<video
v-else-if="previewMode === 'video' && previewUrl"
:src="previewUrl"
controls
class="bx-attachment-preview-media"
/>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { VideoPlay, Document, Download } from '@element-plus/icons-vue'
import {
type BxAttachmentItem,
isBxImageFile,
isBxVideoFile,
canBxPreview,
downloadBxAttachment,
previewBxAttachment
} from '@/utils/bx/attachment'
defineProps<{
files: BxAttachmentItem[]
}>()
const previewVisible = ref(false)
const previewUrl = ref('')
const previewFileName = ref('')
const previewMode = ref<'image' | 'video'>('image')
function handleDownload(file: BxAttachmentItem) {
downloadBxAttachment(file)
}
async function handlePreview(file: BxAttachmentItem) {
const result = await previewBxAttachment(file)
if (!result) return
previewMode.value = result.type
previewUrl.value = result.url
previewFileName.value = result.fileName
previewVisible.value = true
}
</script>
<style scoped lang="scss">
@use '@/styles/bx/attachment.scss';
</style>
@@ -0,0 +1,242 @@
<template>
<div class="attachment-upload">
<div class="attachment-list">
<el-upload
ref="uploadRef"
:auto-upload="false"
:show-file-list="false"
:multiple="true"
:disabled="disabled || globalUploading"
accept="image/*,video/*,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.zip,.rar"
@change="handleAttachmentChange"
>
<div class="upload-card">
<el-icon :size="28" color="#10b981"><Plus /></el-icon>
<span class="upload-card-text">上传附件</span>
</div>
</el-upload>
<div
v-for="(file, index) in files"
:key="String(file.id)"
class="attachment-item"
:class="{ 'is-uploading': file._uploading }"
>
<div
class="attachment-preview"
@click="canBxPreview(file) ? handlePreview(file) : undefined"
>
<template v-if="isBxImageFile(file) && (file.previewUrl || file._uploading)">
<img v-if="file.previewUrl" :src="file.previewUrl" :alt="file.fileName" />
<el-icon v-else :size="24" color="#94a3b8"><Loading /></el-icon>
</template>
<template v-else-if="isBxImageFile(file) && !file.previewUrl">
<el-icon :size="24" color="#94a3b8"><Loading /></el-icon>
</template>
<template v-else-if="isBxVideoFile(file)">
<div class="attachment-preview__icon attachment-preview__icon--video">
<el-icon :size="28"><VideoPlay /></el-icon>
</div>
</template>
<template v-else>
<div class="attachment-preview__icon attachment-preview__icon--doc">
<el-icon :size="28"><Document /></el-icon>
</div>
</template>
</div>
<div class="attachment-footer">
<span class="attachment-name" :title="file.fileName">{{ file.fileName }}</span>
<div class="attachment-actions">
<el-icon class="action-btn" title="下载" @click="handleDownload(file)">
<Download />
</el-icon>
<el-icon
class="action-btn action-btn--danger"
title="删除"
@click="removeAttachment(index)"
>
<Delete />
</el-icon>
</div>
</div>
</div>
</div>
<span v-if="showHint" class="upload-hint">{{ hint }}</span>
<el-dialog
v-model="previewVisible"
title="附件预览"
width="800px"
align-center
destroy-on-close
append-to-body
>
<img
v-if="previewMode === 'image' && previewUrl"
:src="previewUrl"
:alt="previewFileName"
class="bx-attachment-preview-media"
/>
<video
v-else-if="previewMode === 'video' && previewUrl"
:src="previewUrl"
controls
class="bx-attachment-preview-media"
/>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { computed, nextTick, ref } from 'vue'
import {
Plus,
Loading,
VideoPlay,
Document,
Download,
Delete
} from '@element-plus/icons-vue'
import type { UploadFile, UploadInstance } from 'element-plus'
import { ElMessage, ElMessageBox } from 'element-plus'
import { attachmentApi, type BxId } from '@/api/bx'
import {
type BxAttachmentItem,
isBxImageFile,
isBxVideoFile,
canBxPreview,
downloadBxAttachment,
previewBxAttachment
} from '@/utils/bx/attachment'
const props = withDefaults(
defineProps<{
modelValue: BxAttachmentItem[]
bizType: string
bizId?: BxId
hint?: string
showHint?: boolean
disabled?: boolean
maxSizeMb?: number
}>(),
{
bizId: 0,
hint: '支持图片、视频、PDF、Word、Excel等文件,单文件不超过 20MB',
showHint: true,
disabled: false,
maxSizeMb: 20
}
)
const emit = defineEmits<{
'update:modelValue': [value: BxAttachmentItem[]]
}>()
const uploadRef = ref<UploadInstance>()
const globalUploading = ref(false)
const previewVisible = ref(false)
const previewUrl = ref('')
const previewFileName = ref('')
const previewMode = ref<'image' | 'video'>('image')
const files = computed({
get: () => props.modelValue,
set: (value) => emit('update:modelValue', value)
})
function syncFiles(next: BxAttachmentItem[]) {
emit('update:modelValue', next)
}
async function handleAttachmentChange(uploadFile: UploadFile) {
const rawFile = uploadFile.raw
if (!rawFile) return
const maxBytes = props.maxSizeMb * 1024 * 1024
if (rawFile.size > maxBytes) {
ElMessage.error(`单文件不能超过 ${props.maxSizeMb}MB`)
uploadRef.value?.clearFiles()
return
}
const item: BxAttachmentItem = {
id: `upload-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
fileName: rawFile.name,
fileType: rawFile.type,
fileSize: rawFile.size,
previewUrl: '',
_uploading: true
}
syncFiles([...files.value, item])
globalUploading.value = true
try {
const res: any = await attachmentApi.upload(rawFile, props.bizType, props.bizId ?? 0)
item.id = res.data.id
item.fileName = res.data.fileName || item.fileName
item.fileType = res.data.fileType || item.fileType
item.fileSize = res.data.fileSize ?? item.fileSize
item._uploading = false
if (isBxImageFile(item)) {
try {
const previewRes: any = await attachmentApi.preview(item.id)
item.previewUrl = previewRes.data?.url || ''
} catch {
/* preview optional */
}
}
syncFiles([...files.value])
} catch (error: any) {
syncFiles(files.value.filter((entry) => entry.id !== item.id))
ElMessage.error(error?.message || '上传失败')
} finally {
globalUploading.value = files.value.some((entry) => entry._uploading)
await nextTick()
uploadRef.value?.clearFiles()
}
}
async function removeAttachment(index: number) {
const file = files.value[index]
if (!file || file._uploading) return
try {
await ElMessageBox.confirm('确定删除该附件?', '提示', { type: 'warning' })
if (typeof file.id === 'number' || /^\d+$/.test(String(file.id))) {
await attachmentApi.delete(file.id)
}
const next = [...files.value]
next.splice(index, 1)
syncFiles(next)
ElMessage.success('已删除')
} catch {
/* cancelled */
}
}
function handleDownload(file: BxAttachmentItem) {
if (file._uploading) return
downloadBxAttachment(file)
}
async function handlePreview(file: BxAttachmentItem) {
const result = await previewBxAttachment(file)
if (!result) return
previewMode.value = result.type
previewUrl.value = result.url
previewFileName.value = result.fileName
previewVisible.value = true
}
function hasUploading() {
return files.value.some((item) => item._uploading)
}
function getFileIds() {
return files.value.filter((item) => !item._uploading).map((item) => item.id)
}
defineExpose({ hasUploading, getFileIds })
</script>
<style scoped lang="scss">
@use '@/styles/bx/attachment.scss';
</style>
@@ -0,0 +1,23 @@
<script setup lang="ts">
import {
workflowNodeLabel,
workflowNodeTone,
shouldShowWorkflowNodeTag,
} from '@/utils/bx/format'
import BaseTag from './BaseTag.vue'
defineProps<{
currentNode?: unknown
status?: unknown
}>()
</script>
<template>
<BaseTag
v-if="shouldShowWorkflowNodeTag(currentNode, status)"
:tone="workflowNodeTone(currentNode, status)"
>
{{ workflowNodeLabel(currentNode, status) }}
</BaseTag>
<span v-else class="node-current-empty">-</span>
</template>
@@ -0,0 +1,12 @@
<script setup lang="ts">
defineProps<{
title: string
}>()
</script>
<template>
<div class="panel">
<div class="panel-top">{{ title }}</div>
<slot />
</div>
</template>
@@ -0,0 +1,51 @@
<script setup lang="ts">
import { Refresh, Search } from '@element-plus/icons-vue'
withDefaults(
defineProps<{
/** 是否与「展开更多条件」联动(收起/展开文案);无更多筛选项时可不传 */
showMore?: boolean
/** 为 true 时才显示「展开更多条件 / 收起更多条件」按钮 */
hasExpandableFilters?: boolean
loading?: boolean
}>(),
{
showMore: false,
hasExpandableFilters: false,
}
)
const emit = defineEmits<{
toggleMore: []
reset: []
search: []
}>()
</script>
<template>
<div class="filter-block">
<div class="filter-main">
<slot />
</div>
<div class="filter-actions">
<el-button
v-if="hasExpandableFilters"
link
class="btn-link"
@click="emit('toggleMore')"
>
{{ showMore ? '收起更多条件' : '展开更多条件' }}
</el-button>
<div class="filter-actions-end">
<el-button class="filter-reset" :loading="loading" @click="emit('reset')">
<el-icon class="ic"><Refresh /></el-icon>
重置
</el-button>
<el-button class="filter-search" type="primary" plain :loading="loading" @click="emit('search')">
<el-icon class="ic"><Search /></el-icon>
查询
</el-button>
</div>
</div>
</div>
</template>
@@ -0,0 +1,103 @@
<script setup lang="ts">
import { computed } from 'vue'
import DataTablePanel from './DataTablePanel.vue'
import FilterBlock from './FilterBlock.vue'
import ListToolbar from './ListToolbar.vue'
import BaseTable from '../base/BaseTable.vue'
const props = withDefaults(
defineProps<{
panelTitle: string
showMore?: boolean
/** 为 true 时显示「展开更多条件」;筛选项全部在主区域时不要传或传 false */
hasExpandableFilters?: boolean
selectedCount: number
rows: any[]
rangeText: string
total: number
currentPage: number
pageSize: number
pageSizes?: number[]
showSummary?: boolean
summaryMethod?: (...args: any[]) => any
tableMaxHeight?: string | number
loading?: boolean
/** 追加到 .table-scroll 的类名(如合计行样式) */
tableScrollClass?: string
}>(),
{
pageSizes: () => [10, 20, 30],
showSummary: false,
showMore: false,
hasExpandableFilters: false,
}
)
const emit = defineEmits<{
toggleMore: []
reset: []
search: []
'update:currentPage': [value: number]
'update:pageSize': [value: number]
sizeChange: []
selectionChange: [rows: any[]]
}>()
const currentPageModel = computed({
get: () => props.currentPage,
set: (value: number) => emit('update:currentPage', value)
})
const pageSizeModel = computed({
get: () => props.pageSize,
set: (value: number) => emit('update:pageSize', value)
})
</script>
<template>
<DataTablePanel :title="panelTitle">
<FilterBlock
:show-more="showMore"
:has-expandable-filters="hasExpandableFilters"
:loading="loading"
@toggle-more="emit('toggleMore')"
@reset="emit('reset')"
@search="emit('search')"
>
<slot name="filters" />
</FilterBlock>
<ListToolbar :selected-count="selectedCount">
<slot name="toolbar" />
</ListToolbar>
<div class="table-scroll" :class="tableScrollClass">
<BaseTable
:data="rows"
:show-summary="showSummary"
:summary-method="summaryMethod"
:max-height="tableMaxHeight"
@selection-change="(rows: any[]) => emit('selectionChange', rows)"
>
<slot name="table-columns" />
</BaseTable>
</div>
<div class="list-pager">
<span class="list-range">{{ rangeText }}</span>
<div class="list-pager-right">
<el-pagination
v-model:current-page="currentPageModel"
v-model:page-size="pageSizeModel"
:total="total"
layout="sizes, prev, pager, next"
:page-sizes="pageSizes"
prev-text="上一页"
next-text="下一页"
@size-change="emit('sizeChange')"
/>
<span class="pager-size-suffix">条</span>
</div>
</div>
</DataTablePanel>
</template>
@@ -0,0 +1,18 @@
<script setup lang="ts">
defineProps<{
selectedCount: number
}>()
</script>
<template>
<div class="list-toolbar">
<div class="list-toolbar-row">
<span class="list-toolbar-selected">
已选 <span class="sel-num">{{ selectedCount }}</span> 条
</span>
<div class="list-toolbar-actions">
<slot />
</div>
</div>
</div>
</template>
@@ -287,7 +287,7 @@
const isCollapsed = isDualMenu.value && !menuOpen.value
return {
transform: isCollapsed ? 'translateY(-50px)' : 'translateY(0)',
height: isCollapsed ? 'calc(100% + 50px)' : 'calc(100% - 72px)',
height: isCollapsed ? 'calc(100% + 50px)' : 'calc(100% - 56px)',
transition: 'transform 0.3s ease'
}
})
@@ -169,8 +169,8 @@
align-items: center;
justify-content: center;
width: 100%;
height: 72px;
padding: 10px 12px 8px;
height: 56px;
padding: 0 12px;
overflow: hidden;
line-height: normal;
cursor: pointer;
@@ -179,10 +179,10 @@
.header-brand {
display: flex;
flex-direction: column;
flex-direction: row;
align-items: center;
justify-content: center;
gap: 4px;
gap: 8px;
width: 100%;
min-width: 0;
}
@@ -196,19 +196,21 @@
position: static;
box-sizing: border-box;
display: block;
width: 100%;
flex: 0 1 auto;
width: auto;
min-width: 0;
margin: 0;
font-size: 12px;
font-size: 14px;
font-weight: 600;
line-height: 1.3;
color: #111827 !important;
text-align: center;
text-align: left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
&.is-dual-menu-name {
margin: auto;
margin: 0 auto;
}
}
@@ -107,12 +107,16 @@ $popup-menu-radius: 6px;
// 菜单折叠样式
.menu-left-close {
.header {
.header-brand {
justify-content: center;
}
.header-brand-title {
display: none;
}
.logo {
margin: 0 auto;
margin: 0;
}
}
}