| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- <!--
- 单张工单的时间线(票 12):**状态路径** + **动作轨迹**两段。
- 为什么两段都要有(而不是只画一条动作流水):
- · 动作流水回答「什么时候、谁、做了什么」——它是**发生过的事实**;
- · 状态路径回答「这张工单在码表里的什么位置」——同一时刻只有一张工单的整体位置。
- 只画流水,值班人员得自己数着状态读;只画路径,回退(待验收→处理中)就看不出来了。
- 两条本票验收原句的落地方式:
- · 「验收驳回显示为**回退动作**,不是独立终态」→ 回退在动作流水里是一行带 `回退` 标记的记录
- (`domain/workOrderTimeline.js` 按状态码比较判定),状态路径**只铺码表里的节点**,
- 驳回不会多出节点;
- · 「不展示延期状态」→ **票 20 已按后端枚举更正**:码表是 `WorkOrderStatusEnum` 的 0–7,
- 其中 **6 就是「延期中」**(处理旁路),是正式状态,不再是"不展示"的档位。
- 「已取消」(7) 与「延期中」(6) 都刻意画成**路径外**节点:主线是 0→5,
- 把它们接在主线上看起来就像多出来的一步。
- 只读:本组件没有任何写入口(spec 验收第 6 条),也不改工单状态。
- -->
- <template>
- <div class="wo-timeline" data-work-order-timeline :data-wo-code="track.code">
- <!-- ---------- 状态路径:码表节点一个不少,当前位置与走到过的最远处分开标 ---------- -->
- <ol class="wo-timeline__path" data-wo-path>
- <li
- v-for="(node, index) in nodes"
- :key="node.code"
- class="wo-timeline__node"
- :data-wo-path-node="node.code"
- :data-wo-path-name="node.name"
- :data-wo-path-state="node.current ? 'current' : node.reached ? 'reached' : 'pending'"
- :data-wo-path-off="node.offPath ? 'true' : 'false'"
- :data-wo-path-bypass="node.bypass ? 'true' : 'false'"
- :data-wo-path-tone="nodeTone(node)"
- :title="`${node.code} ${node.name}${node.bypass ? '(处理旁路)' : node.offPath ? '(路径外终态)' : ''}`"
- >
- <!-- 每一步都标出序号与名称,并用箭头指向下一步(维护者 2026-11-13)。 -->
- <span class="wo-timeline__chip">
- <b class="wo-timeline__index">{{ index + 1 }}</b>
- <span class="wo-timeline__node-name">{{ node.name }}</span>
- </span>
- <span v-if="index < nodes.length - 1" class="wo-timeline__arrow" aria-hidden="true">›</span>
- </li>
- </ol>
- <!-- ---------- 动作轨迹:每条记录一行,回退单独带标记 ---------- -->
- <ol v-if="track.steps.length" class="wo-timeline__steps" data-wo-steps>
- <li
- v-for="step in track.steps"
- :key="step.key"
- class="wo-timeline__step"
- :class="{ 'is-rollback': step.isRollback }"
- :data-wo-step="step.index"
- :data-wo-step-action="step.action"
- :data-wo-step-state="step.stateCode === null ? '' : step.stateCode"
- :data-wo-step-tone="stepTone(step)"
- >
- <div class="wo-timeline__step-head">
- <span class="wo-timeline__op">{{ step.operationName || step.stateName || placeholder }}</span>
- <time class="wo-timeline__time">{{ step.operatedAt || placeholder }}</time>
- </div>
- <div class="wo-timeline__step-meta">
- <span v-if="step.stateName && step.stateName !== step.operationName" class="wo-timeline__state">{{ step.stateName }}</span>
- <em v-if="step.isRollback" class="wo-timeline__rollback" data-wo-rollback>
- {{ step.actionLabel }} · 自{{ step.fromStateName }}
- </em>
- <span v-else-if="step.actionLabel" class="wo-timeline__action">{{ step.actionLabel }}</span>
- <span v-if="step.operatorName" class="wo-timeline__who">{{ step.operatorName }}</span>
- </div>
- <p v-if="step.operationDesc" class="wo-timeline__desc">{{ step.operationDesc }}</p>
- <!-- 维修过程上传的图片:缩略图,点开交共享图片组件看大图。 -->
- <div v-if="step.attachImages && step.attachImages.length" class="wo-timeline__shots" data-wo-step-images>
- <ImageGallery :items="shotItems(step)" />
- </div>
- </li>
- </ol>
- <!--
- 没有动作流水时:说清楚是哪一种"没有"。
- 轨迹分区没拿到(`pathOnly`)时**不说**「这张工单没有动作记录」——
- 那是把"没取到"说成"没有"(两者在工单面板里是分开的两句话,见 EquipmentDetailSections.vue)。
- -->
- <p v-else-if="!pathOnly" class="wo-timeline__empty" data-wo-steps-empty>这张工单没有动作记录</p>
- </div>
- </template>
- <script setup>
- import { computed } from 'vue'
- import { DETAIL_PLACEHOLDER } from '../domain/detailFlow.js'
- import { pathView, TIMELINE_ACTION } from '../domain/workOrderTimeline.js'
- import ImageGallery from './ImageGallery.vue'
- const props = defineProps({
- /** `domain/equipmentDetailView.js` 的 `timelineSource().tracks[workOrderCode]`。 */
- track: { type: Object, required: true },
- /**
- * 只画状态路径、不画动作流水(轨迹分区没取到时由调用方传 true)。
- * 它决定"没有流水"这一行**说不出**「这张工单没有动作记录」—— 见上面的注释。
- */
- pathOnly: { type: Boolean, default: false },
- })
- /** 维修过程图片:每张带自己的 caption(时间 · 动作 · 序号),点开由共享组件弹大图。 */
- function shotItems(step) {
- return (step.attachImages || []).map((path, shot) => ({
- url: path,
- alt: `${step.operationName || '处置'}第${shot + 1}张图片`,
- caption: [step.operatedAt, `${step.operationName || '处置'}第${shot + 1}张图片`].filter(Boolean).join(' · '),
- }))
- }
- const placeholder = DETAIL_PLACEHOLDER
- const nodes = computed(() => pathView(props.track))
- /** 动作轨迹节点色:推进蓝、起点绿、回退/旁路黄、取消红;灰度下仍靠箭头/文字读方向。 */
- function stepTone(step) {
- if (!step) return 'neutral'
- switch (step.action) {
- case TIMELINE_ACTION.START: return 'lv4'
- case TIMELINE_ACTION.FORWARD: return 'lv3'
- case TIMELINE_ACTION.ROLLBACK: return 'lv2'
- case TIMELINE_ACTION.CANCEL: return 'lv1'
- case TIMELINE_ACTION.BYPASS: return 'lv2'
- default: return 'neutral'
- }
- }
- /**
- * 进度节点语义色(维护者 2026-11-13:每一步用对应颜色语义)。
- * 已走过 reached → lv4 绿;当前 current → lv3 蓝;
- * 路径外终态(已取消)→ lv1 红;处理旁路(延期中)→ lv2 黄;未到 → neutral 灰。
- * 颜色只在 tokens.css 声明,这里只给色键。
- */
- function nodeTone(node) {
- if (node.current) {
- if (node.offPath) return 'lv1'
- if (node.bypass) return 'lv2'
- return 'lv3'
- }
- if (node.reached) return 'lv4'
- return 'neutral'
- }
- </script>
- <style scoped>
- .wo-timeline,
- .wo-timeline * {
- box-sizing: border-box;
- }
- .wo-timeline {
- display: grid;
- gap: calc(3 * var(--u, 1px));
- margin-top: calc(3 * var(--u, 1px));
- padding-left: calc(6 * var(--u, 1px));
- border-left: 1px solid rgba(1, 171, 234, 0.28);
- }
- /* 状态路径:横向铺开,节点等宽;窄栏里允许换行。 */
- .wo-timeline__path {
- display: flex;
- flex-wrap: wrap;
- gap: calc(4 * var(--u, 1px));
- margin: 0;
- padding: 0;
- list-style: none;
- }
- /* 节点=「序号 + 名称」胶囊,后面跟箭头;箭头在胶囊之外,所以不会被边框圈住。 */
- .wo-timeline__node {
- display: inline-flex;
- align-items: center;
- gap: calc(2 * var(--u, 1px));
- }
- .wo-timeline__chip {
- display: inline-flex;
- align-items: center;
- gap: calc(4 * var(--u, 1px));
- padding: 1px calc(6 * var(--u, 1px));
- border: 1px solid currentcolor;
- border-radius: calc(8 * var(--u, 1px));
- background: color-mix(in srgb, currentcolor 12%, transparent);
- font-size: var(--fs-caption, 10.5px);
- white-space: nowrap;
- opacity: .75;
- }
- .wo-timeline__index {
- flex: none;
- min-width: calc(12 * var(--u, 1px));
- border-radius: 50%;
- background: color-mix(in srgb, currentcolor 26%, transparent);
- font-weight: 700;
- text-align: center;
- }
- /* 箭头:指向下一步,颜色跟随「这一步」的语义色。 */
- .wo-timeline__arrow {
- flex: none;
- color: currentcolor;
- font-size: var(--fs-caption, 10.5px);
- opacity: .8;
- }
- /* 语义色:由 data-wo-path-tone 决定(色值只在 tokens.css 声明一份)。 */
- .wo-timeline__node[data-wo-path-tone='lv1'] { color: var(--lv1, #ff3b52); }
- .wo-timeline__node[data-wo-path-tone='lv2'] { color: var(--lv2, #ffb020); }
- .wo-timeline__node[data-wo-path-tone='lv3'] { color: var(--lv3, #01abea); }
- .wo-timeline__node[data-wo-path-tone='lv4'] { color: var(--lv4, #27d17a); }
- .wo-timeline__node[data-wo-path-tone='neutral'] { color: var(--neutral, #5680b0); }
- /* 走到过与当前态更实,未到态更淡:颜色之外再用不透明度区分。 */
- .wo-timeline__node[data-wo-path-state='reached'] .wo-timeline__chip,
- .wo-timeline__node[data-wo-path-state='current'] .wo-timeline__chip { opacity: 1; }
- .wo-timeline__node[data-wo-path-state='current'] .wo-timeline__chip {
- background: color-mix(in srgb, currentcolor 28%, transparent);
- box-shadow: inset 0 0 8px color-mix(in srgb, currentcolor 30%, transparent);
- }
- .wo-timeline__steps {
- position: relative;
- display: grid;
- gap: 0;
- margin: 0;
- padding: calc(4 * var(--u, 1px)) 0 calc(2 * var(--u, 1px)) calc(2 * var(--u, 1px));
- list-style: none;
- }
- /* 竖向时间轴:每个动作一颗语义色圆点,连线贯穿整条流;与预警处置记录同一视觉语言。 */
- .wo-timeline__steps::before {
- content: '';
- position: absolute;
- left: calc(4 * var(--u, 1px));
- top: calc(8 * var(--u, 1px));
- bottom: calc(8 * var(--u, 1px));
- width: 1px;
- background: linear-gradient(180deg, rgba(1, 171, 234, .55), rgba(1, 171, 234, .08));
- }
- .wo-timeline__step {
- position: relative;
- display: grid;
- gap: calc(2 * var(--u, 1px));
- padding: calc(4 * var(--u, 1px)) 0 calc(7 * var(--u, 1px)) calc(15 * var(--u, 1px));
- border-left: 0;
- background: transparent;
- color: var(--neutral, #5680b0);
- }
- .wo-timeline__step::before {
- content: '';
- position: absolute;
- left: 0;
- top: calc(8 * var(--u, 1px));
- width: calc(8 * var(--u, 1px));
- height: calc(8 * var(--u, 1px));
- border-radius: 50%;
- background: currentcolor;
- box-shadow: 0 0 0 calc(3 * var(--u, 1px)) color-mix(in srgb, currentcolor 18%, transparent);
- }
- .wo-timeline__step[data-wo-step-tone='lv1'] { color: var(--lv1, #ff3b52); }
- .wo-timeline__step[data-wo-step-tone='lv2'] { color: var(--lv2, #ffb020); }
- .wo-timeline__step[data-wo-step-tone='lv3'] { color: var(--lv3, #01abea); }
- .wo-timeline__step[data-wo-step-tone='lv4'] { color: var(--lv4, #27d17a); }
- .wo-timeline__step[data-wo-step-tone='neutral'] { color: var(--neutral, #5680b0); }
- /* 回退:底色与圆点同时变警示色,时刻能看出“往回走”。 */
- .wo-timeline__step.is-rollback {
- background: linear-gradient(90deg, rgba(255, 176, 32, 0.13), transparent 72%);
- border-radius: 0 6px 6px 0;
- }
- .wo-timeline__step-head {
- display: flex;
- align-items: baseline;
- justify-content: space-between;
- gap: var(--space-2, 8px);
- }
- .wo-timeline__step-meta {
- display: flex;
- flex-wrap: wrap;
- align-items: baseline;
- gap: calc(6 * var(--u, 1px));
- }
- /* 维修过程图片:独占一行;换行与间距由共享图片组件自己管。 */
- .wo-timeline__shots {
- margin-top: calc(2 * var(--u, 1px));
- }
- .wo-timeline__time,
- .wo-timeline__who,
- .wo-timeline__action {
- color: var(--muted, #5680b0);
- font-size: var(--fs-caption, 10.5px);
- }
- .wo-timeline__time {
- flex: none;
- font-family: var(--num, monospace);
- white-space: nowrap;
- }
- .wo-timeline__state {
- color: var(--text, #d7ecff);
- font-size: var(--fs-caption, 10.5px);
- font-weight: 700;
- }
- .wo-timeline__action {
- padding: 0 calc(4 * var(--u, 1px));
- border: 1px solid color-mix(in srgb, currentcolor 38%, transparent);
- border-radius: 3px;
- line-height: 1.5;
- }
- .wo-timeline__rollback {
- color: var(--lv2, #ffb020);
- font-size: var(--fs-caption, 10.5px);
- font-style: normal;
- letter-spacing: 0.04em;
- }
- .wo-timeline__op {
- min-width: 0;
- color: var(--text-strong, #eaf6ff);
- font-size: calc(11 * var(--u, 1px));
- font-weight: 600;
- overflow-wrap: anywhere;
- }
- .wo-timeline__desc {
- display: block;
- margin: 0;
- color: var(--text-2, #88b7e8);
- font-size: var(--fs-caption, 10.5px);
- line-height: 1.55;
- overflow-wrap: anywhere;
- }
- .wo-timeline__empty {
- margin: 0;
- color: var(--muted, #5680b0);
- font-size: var(--fs-caption, 10.5px);
- letter-spacing: 0.04em;
- }
- </style>
|