Browse Source

fix(cockpit): 优化工单处置流程视觉与时间格式,昵称隐私

- 工单动作轨迹改为竖向时间轴:语义色圆点/连线、动作标签、时间右对齐、操作人与描述分层
- 时间统一 yyyy-MM-dd HH:mm:ss,覆盖设备详情与工单详情共用组件
- 预警处置人/核验人只认 nick_name;移除 user_name 回退
ChenJZ 1 hour ago
parent
commit
b3fcddb6d5

+ 100 - 28
src/modules/cockpit/components/WorkOrderTimeline.vue

@@ -53,24 +53,24 @@
                 :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)"
             >
-                <span class="wo-timeline__step-head">
-                    <span class="wo-timeline__time">{{ step.operatedAt || placeholder }}</span>
-                    <span class="wo-timeline__state">{{ step.stateName || placeholder }}</span>
-                    <!-- 回退的可见标记:颜色之外的第二种提示(灰度下也读得出) -->
+                <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>
-                <!-- 流水正文用 div:里面要放图片网格(block 内容),span 装不下。 -->
-                <div class="wo-timeline__step-body">
-                    <span class="wo-timeline__op">{{ step.operationName || placeholder }}</span>
-                    <span v-if="step.operationDesc" class="wo-timeline__desc">{{ step.operationDesc }}</span>
+                    <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>
-                    <!-- 维修过程上传的图片(维护者 2026-11-23):缩略图,点开看大图(交共享图片组件)。 -->
-                    <div v-if="step.attachImages && step.attachImages.length" class="wo-timeline__shots" data-wo-step-images>
-                        <ImageGallery :items="shotItems(step)" />
-                    </div>
+                </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>
@@ -86,7 +86,7 @@
 <script setup>
 import { computed } from 'vue'
 import { DETAIL_PLACEHOLDER } from '../domain/detailFlow.js'
-import { pathView } from '../domain/workOrderTimeline.js'
+import { pathView, TIMELINE_ACTION } from '../domain/workOrderTimeline.js'
 import ImageGallery from './ImageGallery.vue'
 
 const props = defineProps({
@@ -111,6 +111,19 @@ function shotItems(step) {
 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 蓝;
@@ -205,48 +218,88 @@ function nodeTone(node) {
 }
 
 .wo-timeline__steps {
+    position: relative;
     display: grid;
-    gap: calc(2 * var(--u, 1px));
+    gap: 0;
     margin: 0;
-    padding: 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: 1px;
-    padding: 2px 0 2px calc(5 * var(--u, 1px));
-    border-left: 2px solid rgba(1, 171, 234, 0.35);
+    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 {
-    border-left-color: var(--lv2, #ffb020);
-    background: linear-gradient(90deg, rgba(255, 176, 32, 0.12), transparent 70%);
+    background: linear-gradient(90deg, rgba(255, 176, 32, 0.13), transparent 72%);
+    border-radius: 0 6px 6px 0;
 }
 
-.wo-timeline__step-head,
-.wo-timeline__step-body {
+.wo-timeline__step-head {
     display: flex;
-    flex-wrap: wrap;
+    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));
 }
 
-/* 维修过程图片(维护者 2026-11-23):独占一行;换行与间距由共享图片组件自己管。 */
+/* 维修过程图片:独占一行;换行与间距由共享图片组件自己管。 */
 .wo-timeline__shots {
-    flex-basis: 100%;
     margin-top: calc(2 * var(--u, 1px));
 }
 .wo-timeline__time,
 .wo-timeline__who,
-.wo-timeline__desc {
+.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 {
@@ -255,6 +308,13 @@ function nodeTone(node) {
     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);
@@ -263,8 +323,20 @@ function nodeTone(node) {
 }
 
 .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 {

+ 2 - 2
src/modules/cockpit/domain/entityDetail.js

@@ -686,7 +686,7 @@ function normalizeEvent(identity, source) {
             : [tab('overview', '报警信息'), tab('devices', '设备信息'), tab('records', '处置记录'), tab('attachments', '附件')],
         relatedAlarms: Array.isArray(source.alarmList) ? source.alarmList.map(relatedAlarm) : [],
         stage: eventStage(family, rawStatus, auditRecords),
-        people: peopleItems([['发布人', source.publisherName || source.publisher], ['处置人', source.handlerName || source.handler], ['核验人', source.reviewerName || source.reviewer]]),
+        people: peopleItems([['发布人', source.publisherName], ['处置人', source.handlerName], ['核验人', source.reviewerName]]),
         devices: deviceItems(source),
         attachments,
         records: recordItems(auditRecords),
@@ -806,7 +806,7 @@ function recordItems(value) {
     return (Array.isArray(value) ? value : []).map((item) => ({
         title: item.operationName || item.operationType || item.action || item.disposalTypeName || item.disposalStatus || '处置记录',
         time: formatEventTime(item.operatedAt || item.operationTime || item.createTime || item.create_time || item.disposalTime || ''),
-        operator: item.operatorName || item.operator || item.createByName || item.disposal_user_name || item.disposalUser || item.disposal_user || '',
+        operator: item.operatorName || item.operator || item.createByName || item.disposal_user_name || '',
         description: item.operationDesc || item.remark || item.content || item.disposal_content || item.disposalContent || '',
     }))
 }

+ 2 - 1
src/modules/cockpit/domain/workOrderTimeline.js

@@ -20,6 +20,7 @@
  *      与后端「旁路/终态」的定义一致。ADR 0003 的「不展示延期」已按此更正。
  */
 import { WORK_ORDER_STATES, workOrderStateName } from './workOrder.js'
+import { formatEventTime } from './eventList.js'
 
 /** 已取消的码(路径外终态)。 */
 export const WORK_ORDER_CANCELLED_CODE = 7
@@ -132,7 +133,7 @@ export function trackOf(timeline) {
             operationName: entry.operationName ? /\p{Script=Han}/u.test(entry.operationName) ? entry.operationName : '操作未知' : '',
             operationDesc: entry.operationDesc || '',
             operatorName: entry.operatorName || '',
-            operatedAt: entry.operatedAt || '',
+            operatedAt: formatEventTime(entry.operatedAt || ''),
             stateCode: known ? rawCode : null,
             stateName: known ? workOrderStateName(rawCode) : '状态未知',
             fromStateName,

+ 21 - 0
tests/entityDetailWarning.test.js

@@ -160,4 +160,25 @@ test('工单卡片用 workOrderCode 作为身份,不再报缺少主键', () =>
     assert.equal(card.identityCode, 'WO1')
     assert.equal(card.identityReason, '')
     assert.equal(card.identityPayload.orderDesc, 'x')
+})
+
+test('预警处置人/核验人不回退到 user_name 字段', () => {
+    const raw = {
+        warningNo: 'YJ1',
+        handler: 'drain-ops01',
+        handlerName: '排水运维员01',
+        reviewer: 'drain-admin01',
+        reviewerName: '排水管理员01',
+        disposalHistory: [{
+            disposalTypeName: '发布预警',
+            disposal_user: 'drain-ops01',
+            disposal_user_name: '排水运维员01',
+            disposal_content: '发布预警;处置人:排水运维员01;核查人:排水管理员01',
+            create_time: '2026-10-28T09:36:46+08:00',
+        }],
+    }
+    const view = entityDetailView(normalizeEntityDetail({ kind: 'event', id: 'YJ1', family: 'WARNING' }, raw))
+    assert.deepEqual(view.people.map((item) => item.name), ['排水运维员01', '排水管理员01'])
+    assert.equal(view.records[0].operator, '排水运维员01')
+    assert.ok(!view.records[0].operator.includes('drain-'))
 })

+ 2 - 1
tests/entityDetailWorkOrder.test.js

@@ -25,7 +25,7 @@ test('工单详情保留时间线过程图片与维修前后图片', () => {
                 operationName: '现场处置',
                 operationDesc: '更换探头',
                 operatorName: '张工',
-                operatedAt: '2026-12-01 09:30:00',
+                operatedAt: '2026-12-01T09:30:00+08:00',
                 attachImages: ['/upload/process-1.png', '/upload/process-2.png'],
             },
         ],
@@ -34,6 +34,7 @@ test('工单详情保留时间线过程图片与维修前后图片', () => {
 
     assert.equal(view.track.steps.length, 1)
     assert.deepEqual(view.track.steps[0].attachImages, ['/upload/process-1.png', '/upload/process-2.png'])
+    assert.equal(view.track.steps[0].operatedAt, '2026-12-01 09:30:00')
     assert.deepEqual(view.maintenanceImages.map((group) => ({ label: group.label, images: group.images })), [
         { label: '维修前', images: ['/upload/before.png'] },
         { label: '维修后', images: ['/upload/after.png'] },