| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483 |
- <template>
- <el-dialog
- v-model="dialogVisible"
- :title="readonly ? `任务详情 — ${taskName}` : `任务执行 — ${taskName}`"
- width="96vw"
- class="dialog-form-layout execution-dialog"
- align-center
- destroy-on-close
- :close-on-click-modal="false"
- @close="handleClose"
- >
- <!-- 顶部:任务基本信息一行展示 -->
- <div v-if="editor.taskDetail.value" class="execution-header">
- <div class="execution-header-row">
- <span class="execution-header-item">任务号:<b>{{ editor.taskDetail.value.taskNo }}</b></span>
- <span class="execution-header-item">工单号:{{ editor.taskDetail.value.workOrderNo || '—' }}</span>
- <span class="execution-header-item">任务名称:{{ editor.taskDetail.value.taskName || '—' }}</span>
- <el-tag :type="editor.taskStatusTag(editor.taskDetail.value.taskStatus).type">
- {{ editor.taskStatusTag(editor.taskDetail.value.taskStatus).label }}
- </el-tag>
- <div v-if="!readonly" class="execution-header-actions">
- <el-button
- v-if="editor.taskDetail.value.taskStatus === 'dpz'"
- class="btn-main"
- type="primary"
- size="small"
- @click="editor.handleStartTask"
- >
- <el-icon><VideoPlay /></el-icon>开始执行
- </el-button>
- <el-button
- v-if="editor.taskDetail.value.taskStatus === 'jxz'"
- class="btn-main"
- type="success"
- size="small"
- @click="editor.handleCompleteTask"
- >
- <el-icon><Check /></el-icon>完成任务
- </el-button>
- </div>
- </div>
- <div v-if="editor.taskDetail.value.remark" class="execution-header-remark">{{ editor.taskDetail.value.remark }}</div>
- </div>
- <!-- 主体:可折叠工艺库 + 步骤列表 + 详情面板 -->
- <div class="execution-main">
- <!-- 可折叠工艺库侧栏(只读时隐藏) -->
- <template v-if="!readonly">
- <transition name="slide-lib">
- <div v-show="editor.processLibraryExpanded.value" class="execution-lib-panel">
- <div class="execution-lib-header">
- <h3>工艺库</h3>
- <el-input v-model="editor.processSearchKeyword.value" placeholder="搜索工序" clearable size="small" class="route-config-search" />
- </div>
- <el-collapse v-model="editor.expandedCategories.value" class="route-config-collapse">
- <el-collapse-item v-for="cat in editor.filteredProcessLibrary.value" :key="cat.categoryId" :name="cat.categoryId">
- <template #title>
- <span class="route-config-cat-bar"></span>
- <span>{{ cat.categoryName }}</span>
- </template>
- <div v-for="(proc, procIndex) in cat.processes" :key="proc.id" class="route-config-process-card" draggable="true" @dragstart="editor.onDragStart($event, proc)">
- <div class="route-config-process-info">
- <div class="route-config-process-name">
- <span class="route-config-process-seq">{{ procIndex + 1 }}</span>{{ proc.processName }}
- </div>
- <div class="route-config-process-code">{{ proc.processCode }}</div>
- </div>
- <el-icon class="route-config-process-drag"><Rank /></el-icon>
- </div>
- <el-empty v-if="!cat.processes.length" description="该分类暂无工序" :image-size="32" />
- </el-collapse-item>
- </el-collapse>
- <el-empty v-if="!editor.filteredProcessLibrary.value.length" description="暂无工艺数据" :image-size="48" />
- </div>
- </transition>
- <!-- 工艺库折叠把手 -->
- <div class="execution-lib-toggle" @click="editor.processLibraryExpanded.value = !editor.processLibraryExpanded.value">
- <span>{{ editor.processLibraryExpanded.value ? '‹' : '›' }}</span>
- <span class="execution-lib-toggle-text">工艺库</span>
- </div>
- </template>
- <!-- 步骤列表 -->
- <div class="execution-step-list" v-loading="editor.stepListLoading.value" @dragover.prevent @drop="editor.onDropToCenter">
- <div class="execution-step-list-header">
- <h3>工序步骤</h3>
- <span class="execution-progress-badge">{{ editor.completedStepCount.value }}/{{ editor.stepList.value.length }}</span>
- </div>
- <div class="execution-step-list-body">
- <!-- 虚拟步骤:任务输入 -->
- <div
- class="virtual-step-card"
- :class="{ 'is-active': editor.selectedVirtualStep.value === 'input' }"
- @click="editor.selectVirtualStep('input')"
- >
- <div class="virtual-step-icon virtual-step-icon--input">📥</div>
- <div class="virtual-step-info">
- <div class="virtual-step-name">任务输入</div>
- </div>
- <el-tag v-if="editor.virtualInputStatus.value === 'filled'" type="success" size="small">已填写 {{ editor.taskInputs.value.length }} 项</el-tag>
- <el-tag v-else type="danger" size="small">未填写</el-tag>
- </div>
- <!-- 虚拟步骤:任务输出 -->
- <div
- class="virtual-step-card"
- :class="{ 'is-active': editor.selectedVirtualStep.value === 'output' }"
- @click="editor.selectVirtualStep('output')"
- >
- <div class="virtual-step-icon virtual-step-icon--output">📤</div>
- <div class="virtual-step-info">
- <div class="virtual-step-name">任务输出</div>
- </div>
- <el-tag v-if="editor.virtualOutputStatus.value === 'filled'" type="success" size="small">已填写 {{ editor.taskOutputs.value.length }} 项</el-tag>
- <el-tag v-else type="danger" size="small">未填写</el-tag>
- </div>
- <!-- 分割线 -->
- <div class="step-divider"><span>工艺步骤</span></div>
- <!-- 真实步骤列表 -->
- <draggable v-model="editor.stepList.value" :handle="readonly ? undefined : '.route-config-step-handle'" :animation="200" @end="editor.onStepDragEnd">
- <div
- v-for="(element, index) in editor.stepList.value"
- :key="element.id"
- class="route-config-step-card"
- :class="{
- 'is-active': editor.selectedStepId.value === element.id,
- 'is-done': element.stepStatus === 'ywc'
- }"
- @click="editor.selectStep(element)"
- >
- <div v-if="!readonly" class="route-config-step-handle"><el-icon><Rank /></el-icon></div>
- <div class="route-config-step-order" :class="stepSeqClass(element.stepStatus)">{{ element.stepStatus === 'ywc' ? '✓' : index + 1 }}</div>
- <div class="route-config-step-info">
- <div class="route-config-step-name">{{ element.processName || '未命名步骤' }}</div>
- <div class="route-config-step-desc">{{ element.description || '' }}</div>
- </div>
- <el-tag v-if="element.stepStatus" :type="editor.stepStatusTag(element.stepStatus).type" size="small" style="margin-right:4px">{{ editor.stepStatusTag(element.stepStatus).label }}</el-tag>
- <template v-if="!readonly">
- <el-button link type="primary" size="small" title="复制步骤" @click.stop="editor.handleCopyStep(element)">
- <el-icon><CopyDocument /></el-icon>
- </el-button>
- <el-button link type="danger" size="small" @click.stop="editor.handleDeleteStep(element)">
- <el-icon><Delete /></el-icon>
- </el-button>
- </template>
- </div>
- </draggable>
- <div v-if="!editor.stepList.value.length" class="execution-step-list-empty">
- <el-icon :size="32" color="#a7f3d0"><Plus /></el-icon>
- <p>从左侧拖拽工序到此处,添加任务步骤</p>
- </div>
- </div>
- </div>
- <!-- 右侧详情面板 -->
- <div class="execution-detail-panel">
- <!-- 任务输入详情 -->
- <template v-if="editor.selectedVirtualStep.value === 'input'">
- <div class="execution-detail-header">
- <h3>📥 任务输入</h3>
- <div v-if="!readonly" class="execution-detail-actions">
- <el-button class="btn-main" type="primary" size="small" @click="editor.addTaskInputRow"><el-icon><Plus /></el-icon>添加输入</el-button>
- <el-button class="btn-main" type="primary" size="small" :loading="editor.inputSaving.value" @click="editor.saveTaskInputs"><el-icon><Check /></el-icon>保存</el-button>
- </div>
- </div>
- <div class="execution-detail-body">
- <el-table :data="editor.taskInputs.value" stripe class="inner-table">
- <el-table-column type="index" label="序号" width="56" align="center" :index="(i: number) => i + 1" />
- <el-table-column label="输入类型" min-width="120" align="center">
- <template #default="{ row }">
- <span v-if="readonly">{{ row.inputType === 'sample' ? '样本' : row.inputType === 'cell_product' ? '细胞产品' : row.inputType }}</span>
- <el-select v-else v-model="row.inputType" placeholder="选择类型" class="inner-cell-select" @change="() => { row.inputId = ''; row.inputCode = ''; row.inputName = '' }">
- <el-option label="样本" value="sample" />
- <el-option label="细胞产品" value="cell_product" />
- </el-select>
- </template>
- </el-table-column>
- <el-table-column label="输入编码" min-width="150" align="center">
- <template #default="{ row }">
- <template v-if="row.inputType === 'cell_product'">
- <el-select
- v-if="!readonly"
- v-model="row.inputId"
- placeholder="选择细胞产品"
- filterable
- class="inner-cell-select"
- :loading="editor.cellProductOptionsLoading.value"
- @change="(val: string) => editor.onCellProductInputSelect(row, val)"
- >
- <el-option v-for="opt in editor.cellProductOptions.value" :key="opt.id" :label="opt.label" :value="opt.id" />
- </el-select>
- <span v-else>{{ row.inputCode || '—' }}</span>
- </template>
- <template v-else>
- <span>{{ row.inputCode || '—' }}</span>
- </template>
- </template>
- </el-table-column>
- <el-table-column label="输入名称" min-width="150" align="center">
- <template #default="{ row }">
- <span v-if="readonly">{{ row.inputName || '—' }}</span>
- <el-input v-else v-model="row.inputName" placeholder="输入名称" class="inner-cell-input" />
- </template>
- </el-table-column>
- <el-table-column label="备注" min-width="120" align="center">
- <template #default="{ row }">
- <span v-if="readonly">{{ row.remark || '—' }}</span>
- <el-input v-else v-model="row.remark" placeholder="备注" class="inner-cell-input" />
- </template>
- </el-table-column>
- <el-table-column v-if="!readonly" label="操作" width="80" align="center">
- <template #default="{ $index }">
- <el-button link type="danger" size="small" @click="editor.removeTaskInputRow($index)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <el-empty v-if="!editor.taskInputs.value.length" description="暂无输入项" :image-size="48" />
- </div>
- </template>
- <!-- 任务输出详情 -->
- <template v-else-if="editor.selectedVirtualStep.value === 'output'">
- <div class="execution-detail-header">
- <h3>📤 任务输出</h3>
- <div v-if="!readonly" class="execution-detail-actions">
- <el-button class="btn-main" type="primary" size="small" @click="editor.addTaskOutputRow"><el-icon><Plus /></el-icon>添加输出</el-button>
- <el-button class="btn-main" type="primary" size="small" :loading="editor.outputSaving.value" @click="editor.saveTaskOutputs"><el-icon><Check /></el-icon>保存</el-button>
- </div>
- </div>
- <div class="execution-detail-body">
- <el-table :data="editor.taskOutputs.value" stripe class="inner-table">
- <el-table-column type="index" label="序号" width="56" align="center" :index="(i: number) => i + 1" />
- <el-table-column label="输出名称" min-width="140" align="center">
- <template #default="{ row }">
- <span v-if="readonly">{{ row.outputName || '—' }}</span>
- <el-input v-else v-model="row.outputName" placeholder="输出名称" class="inner-cell-input" />
- </template>
- </el-table-column>
- <el-table-column label="输出条码" min-width="140" align="center">
- <template #default="{ row }">
- <span v-if="readonly">{{ row.outputBarcode || '—' }}</span>
- <el-input v-else v-model="row.outputBarcode" placeholder="扫码或输入" class="inner-cell-input" />
- </template>
- </el-table-column>
- <el-table-column label="数量" min-width="100" align="center">
- <template #default="{ row }">
- <span v-if="readonly">{{ row.quantity ?? '—' }}</span>
- <el-input-number v-else v-model="row.quantity" :min="0" :precision="2" controls-position="right" style="width: 100%" />
- </template>
- </el-table-column>
- <el-table-column label="单位" min-width="80" align="center">
- <template #default="{ row }">
- <span v-if="readonly">{{ row.unit || '—' }}</span>
- <el-input v-else v-model="row.unit" placeholder="单位" class="inner-cell-input" />
- </template>
- </el-table-column>
- <el-table-column label="备注" min-width="120" align="center">
- <template #default="{ row }">
- <span v-if="readonly">{{ row.remark || '—' }}</span>
- <el-input v-else v-model="row.remark" placeholder="备注" class="inner-cell-input" />
- </template>
- </el-table-column>
- <el-table-column v-if="!readonly" label="操作" width="80" align="center">
- <template #default="{ $index }">
- <el-button link type="danger" size="small" @click="editor.removeTaskOutputRow($index)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <el-empty v-if="!editor.taskOutputs.value.length" description="暂无输出项" :image-size="48" />
- </div>
- </template>
- <!-- 步骤详情 -->
- <template v-else>
- <StepDetailPanel :editor="editor" :readonly="readonly" />
- </template>
- </div>
- </div>
- </el-dialog>
- </template>
- <script setup lang="ts">
- import { Rank, Plus, Check, VideoPlay, CopyDocument, Delete } from '@element-plus/icons-vue'
- import { VueDraggable as draggable } from 'vue-draggable-plus'
- import { useTaskStepEditor } from './useTaskStepEditor'
- import StepDetailPanel from './StepDetailPanel.vue'
- const props = defineProps<{
- visible: boolean
- taskId: string
- taskName: string
- readonly?: boolean
- }>()
- const emit = defineEmits<{
- (e: 'update:visible', val: boolean): void
- (e: 'success'): void
- }>()
- const dialogVisible = computed({
- get: () => props.visible,
- set: (val) => emit('update:visible', val)
- })
- const editor = useTaskStepEditor()
- function handleClose() {
- dialogVisible.value = false
- emit('success')
- }
- function stepSeqClass(status: string) {
- if (status === 'ywc') return 'seq-done'
- if (status === 'jxz') return 'seq-running'
- return 'seq-pending'
- }
- watch(() => props.visible, async (val) => {
- if (val && props.taskId) {
- await editor.initEditor(props.taskId, { mode: 'execution' })
- }
- })
- </script>
- <style scoped lang="scss">
- @use '../../../styles/route-config' as *;
- .execution-dialog {
- :deep(.el-dialog) {
- margin: 2vh auto !important;
- }
- :deep(.el-dialog__body) {
- max-height: calc(96vh - 54px);
- overflow-y: auto;
- padding: 10px 14px;
- }
- }
- /* 顶部信息 */
- .execution-header {
- padding: 6px 16px;
- background: #f0fdf4;
- border-radius: 6px;
- margin-bottom: 8px;
- border: 1px solid #d1fae5;
- }
- .execution-header-row {
- display: flex; align-items: center; gap: 16px;
- font-size: 13px; color: #475569;
- b { color: #1e293b; }
- }
- .execution-header-item { white-space: nowrap; }
- .execution-header-actions { display: flex; gap: 8px; margin-left: auto; }
- .execution-header-remark { margin-top: 4px; font-size: 12px; color: #64748b; }
- /* 主体三区域 */
- .execution-main {
- display: flex; gap: 0;
- height: calc(96vh - 110px);
- min-height: 400px;
- }
- /* 工艺库折叠侧栏 */
- .execution-lib-panel {
- width: 260px; flex-shrink: 0;
- display: flex; flex-direction: column;
- border: 1px solid #e5e7eb; border-radius: 8px;
- overflow: hidden;
- }
- .execution-lib-header {
- padding: 10px 12px; border-bottom: 1px solid #e5e7eb; flex-shrink: 0;
- h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: #1f2937; }
- }
- .slide-lib-enter-active, .slide-lib-leave-active {
- transition: width 0.2s ease, opacity 0.2s ease;
- overflow: hidden;
- }
- .slide-lib-enter-from, .slide-lib-leave-to {
- width: 0 !important; opacity: 0;
- }
- /* 工艺库折叠把手 */
- .execution-lib-toggle {
- width: 24px; flex-shrink: 0;
- display: flex; flex-direction: column;
- align-items: center; justify-content: center;
- gap: 4px; cursor: pointer;
- background: #f9fafb; border-left: 1px solid #e5e7eb; border-right: 1px solid #e5e7eb;
- transition: background 0.15s;
- font-size: 14px; color: #9ca3af;
- &:hover { background: #ecfdf5; color: #10b981; }
- }
- .execution-lib-toggle-text {
- writing-mode: vertical-lr; font-size: 11px; letter-spacing: 2px;
- }
- /* 步骤列表 */
- .execution-step-list {
- width: 340px; flex-shrink: 0;
- display: flex; flex-direction: column;
- border: 1px solid #e5e7eb; border-radius: 8px;
- overflow: hidden; margin: 0 8px;
- }
- .execution-step-list-header {
- padding: 10px 14px; border-bottom: 1px solid #e5e7eb;
- display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
- h3 { margin: 0; font-size: 14px; font-weight: 600; color: #1f2937; }
- }
- .execution-progress-badge {
- font-size: 12px; color: #6b7280; background: #f3f4f6;
- padding: 2px 10px; border-radius: 10px;
- }
- .execution-step-list-body {
- flex: 1; overflow-y: auto; padding: 8px;
- }
- .execution-step-list-empty {
- display: flex; flex-direction: column;
- align-items: center; justify-content: center;
- padding: 40px 0; color: #9ca3af;
- p { margin-top: 8px; font-size: 13px; }
- }
- /* 虚拟步骤卡片 */
- .virtual-step-card {
- display: flex; align-items: center; gap: 10px;
- padding: 10px 12px; margin-bottom: 4px;
- border-radius: 8px; cursor: pointer;
- border: 2px solid #bfdbfe; background: #eff6ff;
- transition: all 0.15s;
- &:hover { border-color: #93c5fd; background: #dbeafe; }
- &.is-active { border-color: #3b82f6; background: #dbeafe; box-shadow: 0 0 0 1px #3b82f6; }
- }
- .virtual-step-icon {
- width: 28px; height: 28px; border-radius: 6px;
- display: flex; align-items: center; justify-content: center;
- font-size: 14px; flex-shrink: 0;
- &--input { background: #dbeafe; }
- &--output { background: #fef3c7; }
- }
- .virtual-step-info { flex: 1; min-width: 0; }
- .virtual-step-name { font-size: 13px; font-weight: 500; color: #1e293b; }
- /* 分割线 */
- .step-divider {
- display: flex; align-items: center; gap: 8px;
- margin: 8px 0; padding: 0 4px;
- color: #9ca3af; font-size: 11px;
- &::before, &::after { content: ''; flex: 1; height: 1px; background: #e5e7eb; }
- }
- /* 步骤序号状态 */
- .seq-done { background: #d1fae5 !important; color: #059669 !important; }
- .seq-running { background: #10b981 !important; color: #fff !important; }
- .seq-pending { background: #f3f4f6 !important; color: #6b7280 !important; }
- .route-config-step-card.is-done { opacity: 0.6; }
- /* 右侧详情面板 */
- .execution-detail-panel {
- flex: 1; min-width: 0;
- display: flex; flex-direction: column;
- border: 1px solid #e5e7eb; border-radius: 8px;
- overflow: hidden;
- }
- .execution-detail-header {
- padding: 10px 16px; border-bottom: 1px solid #e5e7eb;
- display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
- h3 { margin: 0; font-size: 14px; font-weight: 600; color: #1e293b; }
- }
- .execution-detail-actions { display: flex; gap: 8px; }
- .execution-detail-body {
- flex: 1; overflow-y: auto; padding: 16px;
- }
- .section-bar {
- display: inline-block; width: 3px; height: 14px;
- background: #10b981; border-radius: 2px; margin-right: 8px;
- }
- </style>
|