WorkOrderTimeline.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <!--
  2. 单张工单的时间线(票 12):**状态路径** + **动作轨迹**两段。
  3. 为什么两段都要有(而不是只画一条动作流水):
  4. · 动作流水回答「什么时候、谁、做了什么」——它是**发生过的事实**;
  5. · 状态路径回答「这张工单在码表里的什么位置」——同一时刻只有一张工单的整体位置。
  6. 只画流水,值班人员得自己数着状态读;只画路径,回退(待验收→处理中)就看不出来了。
  7. 两条本票验收原句的落地方式:
  8. · 「验收驳回显示为**回退动作**,不是独立终态」→ 回退在动作流水里是一行带 `回退` 标记的记录
  9. (`domain/workOrderTimeline.js` 按状态码比较判定),状态路径**只铺码表里的节点**,
  10. 驳回不会多出节点;
  11. · 「不展示延期状态」→ **票 20 已按后端枚举更正**:码表是 `WorkOrderStatusEnum` 的 0–7,
  12. 其中 **6 就是「延期中」**(处理旁路),是正式状态,不再是"不展示"的档位。
  13. 「已取消」(7) 与「延期中」(6) 都刻意画成**路径外**节点:主线是 0→5,
  14. 把它们接在主线上看起来就像多出来的一步。
  15. 只读:本组件没有任何写入口(spec 验收第 6 条),也不改工单状态。
  16. -->
  17. <template>
  18. <div class="wo-timeline" data-work-order-timeline :data-wo-code="track.code">
  19. <!-- ---------- 状态路径:码表节点一个不少,当前位置与走到过的最远处分开标 ---------- -->
  20. <ol class="wo-timeline__path" data-wo-path>
  21. <li
  22. v-for="(node, index) in nodes"
  23. :key="node.code"
  24. class="wo-timeline__node"
  25. :data-wo-path-node="node.code"
  26. :data-wo-path-name="node.name"
  27. :data-wo-path-state="node.current ? 'current' : node.reached ? 'reached' : 'pending'"
  28. :data-wo-path-off="node.offPath ? 'true' : 'false'"
  29. :data-wo-path-bypass="node.bypass ? 'true' : 'false'"
  30. :data-wo-path-tone="nodeTone(node)"
  31. :title="`${node.code} ${node.name}${node.bypass ? '(处理旁路)' : node.offPath ? '(路径外终态)' : ''}`"
  32. >
  33. <!-- 每一步都标出序号与名称,并用箭头指向下一步(维护者 2026-11-13)。 -->
  34. <span class="wo-timeline__chip">
  35. <b class="wo-timeline__index">{{ index + 1 }}</b>
  36. <span class="wo-timeline__node-name">{{ node.name }}</span>
  37. </span>
  38. <span v-if="index < nodes.length - 1" class="wo-timeline__arrow" aria-hidden="true">›</span>
  39. </li>
  40. </ol>
  41. <!-- ---------- 动作轨迹:每条记录一行,回退单独带标记 ---------- -->
  42. <ol v-if="track.steps.length" class="wo-timeline__steps" data-wo-steps>
  43. <li
  44. v-for="step in track.steps"
  45. :key="step.key"
  46. class="wo-timeline__step"
  47. :class="{ 'is-rollback': step.isRollback }"
  48. :data-wo-step="step.index"
  49. :data-wo-step-action="step.action"
  50. :data-wo-step-state="step.stateCode === null ? '' : step.stateCode"
  51. :data-wo-step-tone="stepTone(step)"
  52. >
  53. <div class="wo-timeline__step-head">
  54. <span class="wo-timeline__op">{{ step.operationName || step.stateName || placeholder }}</span>
  55. <time class="wo-timeline__time">{{ step.operatedAt || placeholder }}</time>
  56. </div>
  57. <div class="wo-timeline__step-meta">
  58. <span v-if="step.stateName && step.stateName !== step.operationName" class="wo-timeline__state">{{ step.stateName }}</span>
  59. <em v-if="step.isRollback" class="wo-timeline__rollback" data-wo-rollback>
  60. {{ step.actionLabel }} · 自{{ step.fromStateName }}
  61. </em>
  62. <span v-else-if="step.actionLabel" class="wo-timeline__action">{{ step.actionLabel }}</span>
  63. <span v-if="step.operatorName" class="wo-timeline__who">{{ step.operatorName }}</span>
  64. </div>
  65. <p v-if="step.operationDesc" class="wo-timeline__desc">{{ step.operationDesc }}</p>
  66. <!-- 维修过程上传的图片:缩略图,点开交共享图片组件看大图。 -->
  67. <div v-if="step.attachImages && step.attachImages.length" class="wo-timeline__shots" data-wo-step-images>
  68. <ImageGallery :items="shotItems(step)" />
  69. </div>
  70. </li>
  71. </ol>
  72. <!--
  73. 没有动作流水时:说清楚是哪一种"没有"。
  74. 轨迹分区没拿到(`pathOnly`)时**不说**「这张工单没有动作记录」——
  75. 那是把"没取到"说成"没有"(两者在工单面板里是分开的两句话,见 EquipmentDetailSections.vue)。
  76. -->
  77. <p v-else-if="!pathOnly" class="wo-timeline__empty" data-wo-steps-empty>这张工单没有动作记录</p>
  78. </div>
  79. </template>
  80. <script setup>
  81. import { computed } from 'vue'
  82. import { DETAIL_PLACEHOLDER } from '../domain/detailFlow.js'
  83. import { pathView, TIMELINE_ACTION } from '../domain/workOrderTimeline.js'
  84. import ImageGallery from './ImageGallery.vue'
  85. const props = defineProps({
  86. /** `domain/equipmentDetailView.js` 的 `timelineSource().tracks[workOrderCode]`。 */
  87. track: { type: Object, required: true },
  88. /**
  89. * 只画状态路径、不画动作流水(轨迹分区没取到时由调用方传 true)。
  90. * 它决定"没有流水"这一行**说不出**「这张工单没有动作记录」—— 见上面的注释。
  91. */
  92. pathOnly: { type: Boolean, default: false },
  93. })
  94. /** 维修过程图片:每张带自己的 caption(时间 · 动作 · 序号),点开由共享组件弹大图。 */
  95. function shotItems(step) {
  96. return (step.attachImages || []).map((path, shot) => ({
  97. url: path,
  98. alt: `${step.operationName || '处置'}第${shot + 1}张图片`,
  99. caption: [step.operatedAt, `${step.operationName || '处置'}第${shot + 1}张图片`].filter(Boolean).join(' · '),
  100. }))
  101. }
  102. const placeholder = DETAIL_PLACEHOLDER
  103. const nodes = computed(() => pathView(props.track))
  104. /** 动作轨迹节点色:推进蓝、起点绿、回退/旁路黄、取消红;灰度下仍靠箭头/文字读方向。 */
  105. function stepTone(step) {
  106. if (!step) return 'neutral'
  107. switch (step.action) {
  108. case TIMELINE_ACTION.START: return 'lv4'
  109. case TIMELINE_ACTION.FORWARD: return 'lv3'
  110. case TIMELINE_ACTION.ROLLBACK: return 'lv2'
  111. case TIMELINE_ACTION.CANCEL: return 'lv1'
  112. case TIMELINE_ACTION.BYPASS: return 'lv2'
  113. default: return 'neutral'
  114. }
  115. }
  116. /**
  117. * 进度节点语义色(维护者 2026-11-13:每一步用对应颜色语义)。
  118. * 已走过 reached → lv4 绿;当前 current → lv3 蓝;
  119. * 路径外终态(已取消)→ lv1 红;处理旁路(延期中)→ lv2 黄;未到 → neutral 灰。
  120. * 颜色只在 tokens.css 声明,这里只给色键。
  121. */
  122. function nodeTone(node) {
  123. if (node.current) {
  124. if (node.offPath) return 'lv1'
  125. if (node.bypass) return 'lv2'
  126. return 'lv3'
  127. }
  128. if (node.reached) return 'lv4'
  129. return 'neutral'
  130. }
  131. </script>
  132. <style scoped>
  133. .wo-timeline,
  134. .wo-timeline * {
  135. box-sizing: border-box;
  136. }
  137. .wo-timeline {
  138. display: grid;
  139. gap: calc(3 * var(--u, 1px));
  140. margin-top: calc(3 * var(--u, 1px));
  141. padding-left: calc(6 * var(--u, 1px));
  142. border-left: 1px solid rgba(1, 171, 234, 0.28);
  143. }
  144. /* 状态路径:横向铺开,节点等宽;窄栏里允许换行。 */
  145. .wo-timeline__path {
  146. display: flex;
  147. flex-wrap: wrap;
  148. gap: calc(4 * var(--u, 1px));
  149. margin: 0;
  150. padding: 0;
  151. list-style: none;
  152. }
  153. /* 节点=「序号 + 名称」胶囊,后面跟箭头;箭头在胶囊之外,所以不会被边框圈住。 */
  154. .wo-timeline__node {
  155. display: inline-flex;
  156. align-items: center;
  157. gap: calc(2 * var(--u, 1px));
  158. }
  159. .wo-timeline__chip {
  160. display: inline-flex;
  161. align-items: center;
  162. gap: calc(4 * var(--u, 1px));
  163. padding: 1px calc(6 * var(--u, 1px));
  164. border: 1px solid currentcolor;
  165. border-radius: calc(8 * var(--u, 1px));
  166. background: color-mix(in srgb, currentcolor 12%, transparent);
  167. font-size: var(--fs-caption, 10.5px);
  168. white-space: nowrap;
  169. opacity: .75;
  170. }
  171. .wo-timeline__index {
  172. flex: none;
  173. min-width: calc(12 * var(--u, 1px));
  174. border-radius: 50%;
  175. background: color-mix(in srgb, currentcolor 26%, transparent);
  176. font-weight: 700;
  177. text-align: center;
  178. }
  179. /* 箭头:指向下一步,颜色跟随「这一步」的语义色。 */
  180. .wo-timeline__arrow {
  181. flex: none;
  182. color: currentcolor;
  183. font-size: var(--fs-caption, 10.5px);
  184. opacity: .8;
  185. }
  186. /* 语义色:由 data-wo-path-tone 决定(色值只在 tokens.css 声明一份)。 */
  187. .wo-timeline__node[data-wo-path-tone='lv1'] { color: var(--lv1, #ff3b52); }
  188. .wo-timeline__node[data-wo-path-tone='lv2'] { color: var(--lv2, #ffb020); }
  189. .wo-timeline__node[data-wo-path-tone='lv3'] { color: var(--lv3, #01abea); }
  190. .wo-timeline__node[data-wo-path-tone='lv4'] { color: var(--lv4, #27d17a); }
  191. .wo-timeline__node[data-wo-path-tone='neutral'] { color: var(--neutral, #5680b0); }
  192. /* 走到过与当前态更实,未到态更淡:颜色之外再用不透明度区分。 */
  193. .wo-timeline__node[data-wo-path-state='reached'] .wo-timeline__chip,
  194. .wo-timeline__node[data-wo-path-state='current'] .wo-timeline__chip { opacity: 1; }
  195. .wo-timeline__node[data-wo-path-state='current'] .wo-timeline__chip {
  196. background: color-mix(in srgb, currentcolor 28%, transparent);
  197. box-shadow: inset 0 0 8px color-mix(in srgb, currentcolor 30%, transparent);
  198. }
  199. .wo-timeline__steps {
  200. position: relative;
  201. display: grid;
  202. gap: 0;
  203. margin: 0;
  204. padding: calc(4 * var(--u, 1px)) 0 calc(2 * var(--u, 1px)) calc(2 * var(--u, 1px));
  205. list-style: none;
  206. }
  207. /* 竖向时间轴:每个动作一颗语义色圆点,连线贯穿整条流;与预警处置记录同一视觉语言。 */
  208. .wo-timeline__steps::before {
  209. content: '';
  210. position: absolute;
  211. left: calc(4 * var(--u, 1px));
  212. top: calc(8 * var(--u, 1px));
  213. bottom: calc(8 * var(--u, 1px));
  214. width: 1px;
  215. background: linear-gradient(180deg, rgba(1, 171, 234, .55), rgba(1, 171, 234, .08));
  216. }
  217. .wo-timeline__step {
  218. position: relative;
  219. display: grid;
  220. gap: calc(2 * var(--u, 1px));
  221. padding: calc(4 * var(--u, 1px)) 0 calc(7 * var(--u, 1px)) calc(15 * var(--u, 1px));
  222. border-left: 0;
  223. background: transparent;
  224. color: var(--neutral, #5680b0);
  225. }
  226. .wo-timeline__step::before {
  227. content: '';
  228. position: absolute;
  229. left: 0;
  230. top: calc(8 * var(--u, 1px));
  231. width: calc(8 * var(--u, 1px));
  232. height: calc(8 * var(--u, 1px));
  233. border-radius: 50%;
  234. background: currentcolor;
  235. box-shadow: 0 0 0 calc(3 * var(--u, 1px)) color-mix(in srgb, currentcolor 18%, transparent);
  236. }
  237. .wo-timeline__step[data-wo-step-tone='lv1'] { color: var(--lv1, #ff3b52); }
  238. .wo-timeline__step[data-wo-step-tone='lv2'] { color: var(--lv2, #ffb020); }
  239. .wo-timeline__step[data-wo-step-tone='lv3'] { color: var(--lv3, #01abea); }
  240. .wo-timeline__step[data-wo-step-tone='lv4'] { color: var(--lv4, #27d17a); }
  241. .wo-timeline__step[data-wo-step-tone='neutral'] { color: var(--neutral, #5680b0); }
  242. /* 回退:底色与圆点同时变警示色,时刻能看出“往回走”。 */
  243. .wo-timeline__step.is-rollback {
  244. background: linear-gradient(90deg, rgba(255, 176, 32, 0.13), transparent 72%);
  245. border-radius: 0 6px 6px 0;
  246. }
  247. .wo-timeline__step-head {
  248. display: flex;
  249. align-items: baseline;
  250. justify-content: space-between;
  251. gap: var(--space-2, 8px);
  252. }
  253. .wo-timeline__step-meta {
  254. display: flex;
  255. flex-wrap: wrap;
  256. align-items: baseline;
  257. gap: calc(6 * var(--u, 1px));
  258. }
  259. /* 维修过程图片:独占一行;换行与间距由共享图片组件自己管。 */
  260. .wo-timeline__shots {
  261. margin-top: calc(2 * var(--u, 1px));
  262. }
  263. .wo-timeline__time,
  264. .wo-timeline__who,
  265. .wo-timeline__action {
  266. color: var(--muted, #5680b0);
  267. font-size: var(--fs-caption, 10.5px);
  268. }
  269. .wo-timeline__time {
  270. flex: none;
  271. font-family: var(--num, monospace);
  272. white-space: nowrap;
  273. }
  274. .wo-timeline__state {
  275. color: var(--text, #d7ecff);
  276. font-size: var(--fs-caption, 10.5px);
  277. font-weight: 700;
  278. }
  279. .wo-timeline__action {
  280. padding: 0 calc(4 * var(--u, 1px));
  281. border: 1px solid color-mix(in srgb, currentcolor 38%, transparent);
  282. border-radius: 3px;
  283. line-height: 1.5;
  284. }
  285. .wo-timeline__rollback {
  286. color: var(--lv2, #ffb020);
  287. font-size: var(--fs-caption, 10.5px);
  288. font-style: normal;
  289. letter-spacing: 0.04em;
  290. }
  291. .wo-timeline__op {
  292. min-width: 0;
  293. color: var(--text-strong, #eaf6ff);
  294. font-size: calc(11 * var(--u, 1px));
  295. font-weight: 600;
  296. overflow-wrap: anywhere;
  297. }
  298. .wo-timeline__desc {
  299. display: block;
  300. margin: 0;
  301. color: var(--text-2, #88b7e8);
  302. font-size: var(--fs-caption, 10.5px);
  303. line-height: 1.55;
  304. overflow-wrap: anywhere;
  305. }
  306. .wo-timeline__empty {
  307. margin: 0;
  308. color: var(--muted, #5680b0);
  309. font-size: var(--fs-caption, 10.5px);
  310. letter-spacing: 0.04em;
  311. }
  312. </style>