# 附件拖拽上传 Implementation Plan > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. **Goal:** 在方案 1 范围内(类型 A/B/C 附件上传)为所有上传区增加拖拽落文件能力,保留现有点击上传行为。 **Architecture:** 新增 `useAttachmentDropZone` composable 封装 dragenter/dragleave/dragover/drop;各页面在 `.attachment-upload`(或 C 类 `.paper-att-list`)独立挂载,drop 后复用现有 `handleAttachmentChange` / `handlePaperAttachmentChange`。类型 B 仅改 `ProtocolFinanceConfirmFields` 一处并回归 6 个消费页。全局 `.is-dragover` 样式放 `app.scss`。 **Tech Stack:** Vue 3 · Element Plus `el-upload` · TypeScript · SCSS · `fetchUploadAttachment` **设计文档:** `docs/superpowers/specs/2026-07-01-attachment-drag-upload-design.md` --- ## 文件结构 | 路径 | 职责 | |------|------| | `web-admin/src/composables/useAttachmentDropZone.ts` | **新建** — drop zone 事件与 `isDragover` 状态 | | `web-admin/src/assets/styles/core/app.scss` | **修改** — `.attachment-upload.is-dragover`、`.paper-att-list.is-dragover` | | `web-admin/src/components/business/protocol-finance-confirm-fields/index.vue` | **修改** — 类型 B 共享上传 | | `web-admin/src/components/business/outbound-material-form-sections/index.vue` | **修改** — 类型 C 行内上传 | | 22 个类型 A `.vue` 文件 | **修改** — 各页独立挂载 composable | | `openspec/changes/zkxw-engineering-standards/specs/ui-conventions/spec.md` | **修改** — 补充拖拽 SHALL | --- ## Task 0: 基础设施 **Files:** - Create: `web-admin/src/composables/useAttachmentDropZone.ts` - Modify: `web-admin/src/assets/styles/core/app.scss` - Modify: `openspec/changes/zkxw-engineering-standards/specs/ui-conventions/spec.md` - [ ] **Step 1: 创建 composable** ```ts // web-admin/src/composables/useAttachmentDropZone.ts import { ref, type Ref } from 'vue' export type AttachmentDropZoneOptions = { /** 收到有效文件列表时回调(已过滤空项) */ onFiles: (files: File[]) => void | Promise /** 为 true 时不响应拖拽 */ disabled?: Ref | (() => boolean) } export function useAttachmentDropZone(options: AttachmentDropZoneOptions) { const isDragover = ref(false) let dragDepth = 0 function isDisabled() { const d = options.disabled if (!d) return false return typeof d === 'function' ? d() : d.value } function onDragEnter(e: DragEvent) { if (isDisabled()) return e.preventDefault() dragDepth += 1 isDragover.value = true } function onDragLeave(e: DragEvent) { if (isDisabled()) return e.preventDefault() dragDepth = Math.max(0, dragDepth - 1) if (dragDepth === 0) isDragover.value = false } function onDragOver(e: DragEvent) { if (isDisabled()) return e.preventDefault() if (e.dataTransfer) e.dataTransfer.dropEffect = 'copy' } function onDrop(e: DragEvent) { if (isDisabled()) return e.preventDefault() dragDepth = 0 isDragover.value = false const list = e.dataTransfer?.files if (!list?.length) return const files = Array.from(list).filter((f) => f.size >= 0) if (files.length) void options.onFiles(files) } const dropZoneHandlers = { onDragenter: onDragEnter, onDragleave: onDragLeave, onDragover: onDragOver, onDrop: onDrop } return { isDragover, dropZoneHandlers } } ``` - [ ] **Step 2: 全局 dragover 样式(app.scss 附件相关区末尾追加)** ```scss .attachment-upload.is-dragover { border: 1px dashed var(--primary, #10b981); border-radius: 8px; background: var(--primary-bg, #ecfdf5); box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.15); } .paper-att-list.is-dragover { border: 1px dashed var(--primary, #10b981); border-radius: 8px; background: var(--primary-bg, #ecfdf5); } ``` - [ ] **Step 3: OpenSpec 补充** 在 `ui-conventions/spec.md`「附件上传卡片化布局」的 `el-upload` 配置表后增加: - Drop zone SHALL 为 `.attachment-upload` 根容器(表格行内纸质材料为 `.paper-att-list`) - SHALL 支持拖拽与点击两种方式;`.upload-hint` 含「支持拖拽或点击上传」 - dragover 时使用 `.is-dragover` 修饰类(Fresh Mint 虚线边框 + 浅绿底) - [ ] **Step 4: 手工冒烟** 本地 `pnpm dev`,临时在任意页挂载 composable 验证 drop 能触发 `onFiles`(可在 Step 1 完成前跳过,于 Task 1 一并验)。 --- ## Task 1: 试点 — ProtocolFormDialog(A1) **Files:** - Modify: `web-admin/src/views/cell-storage/protocol/ProtocolFormDialog.vue` - [ ] **Step 1: 协议附件区挂载 composable** 在 `