/qc-tasks/result-change-logs 须先于 /qc-tasks/{task_id} 注册;
无留痕时返回 [],不再因路径被当成任务 ID 报「任务不存在」。
Co-authored-by: Cursor <cursoragent@cursor.com>
203 lines
5.4 KiB
Vue
203 lines
5.4 KiB
Vue
<!-- 质检任务 · 检测结果修改记录 -->
|
||
<template>
|
||
<el-dialog
|
||
:model-value="visible"
|
||
:title="dialogTitle"
|
||
width="560px"
|
||
class="dialog-form-layout qc-task-result-change-log-dialog"
|
||
align-center
|
||
modal-class="protocol-dialog-mask"
|
||
append-to-body
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
@update:model-value="onVisibleChange"
|
||
>
|
||
<DialogFormBody :loading="loading">
|
||
<el-empty
|
||
v-if="!loading && !entries.length"
|
||
description="暂无修改记录"
|
||
:image-size="56"
|
||
/>
|
||
<div v-else class="qc-result-chg-tl">
|
||
<div v-for="(entry, idx) in entries" :key="entry.id" class="qc-result-chg-tl__item">
|
||
<div class="qc-result-chg-tl__rail">
|
||
<span class="qc-result-chg-tl__dot" />
|
||
<span v-if="idx < entries.length - 1" class="qc-result-chg-tl__line" />
|
||
</div>
|
||
<div class="qc-result-chg-tl__content">
|
||
<div class="qc-result-chg-tl__meta">
|
||
{{ entry.operateTime || '—' }} · {{ entry.operatorUserName || '—' }}
|
||
<template v-if="showItemName && entry.itemName">
|
||
· {{ entry.itemName }}
|
||
</template>
|
||
</div>
|
||
<template v-if="entry.hasFieldChange && entry.changes?.length">
|
||
<div
|
||
v-for="(chg, cIdx) in entry.changes"
|
||
:key="`${entry.id}-${cIdx}`"
|
||
class="qc-result-chg-tl__line-text"
|
||
>
|
||
<template v-if="chg.oldValue">
|
||
{{ chg.fieldLabel }}:{{ chg.oldValue || '—' }} → {{ chg.newValue || '—' }}
|
||
</template>
|
||
<template v-else>
|
||
{{ chg.fieldLabel }}:{{ chg.newValue || '—' }}
|
||
</template>
|
||
</div>
|
||
</template>
|
||
<div v-else class="qc-result-chg-tl__line-text">保存操作(字段无变更)</div>
|
||
<div v-if="!entry.hasFieldChange" class="qc-result-chg-tl__note">
|
||
即使未改值,点击保存也会记一条操作留痕
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</DialogFormBody>
|
||
<template #footer>
|
||
<el-button class="btn-ghost" @click="close">
|
||
<el-icon><Close /></el-icon>关闭
|
||
</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { computed, ref, watch } from 'vue'
|
||
import { ElMessage } from 'element-plus'
|
||
import { Close } from '@element-plus/icons-vue'
|
||
import DialogFormBody from '@/components/business/dialog-form-body/index.vue'
|
||
import {
|
||
fetchQcTaskResultChangeLogsBatch,
|
||
type QcTaskResultChangeLog
|
||
} from '@/api/qc-task-result'
|
||
|
||
defineOptions({ name: 'QcTaskResultChangeLogDialog' })
|
||
|
||
const props = withDefaults(
|
||
defineProps<{
|
||
visible: boolean
|
||
taskIds: string[]
|
||
titleSuffix?: string
|
||
}>(),
|
||
{
|
||
titleSuffix: ''
|
||
}
|
||
)
|
||
|
||
const emit = defineEmits<{
|
||
'update:visible': [value: boolean]
|
||
}>()
|
||
|
||
const loading = ref(false)
|
||
const entries = ref<QcTaskResultChangeLog[]>([])
|
||
let loadSeq = 0
|
||
|
||
const showItemName = computed(() => (props.taskIds || []).length > 1)
|
||
|
||
const dialogTitle = computed(() => {
|
||
const suffix = (props.titleSuffix || '').trim()
|
||
return suffix ? `修改记录 · ${suffix}` : '修改记录'
|
||
})
|
||
|
||
function onVisibleChange(v: boolean) {
|
||
emit('update:visible', v)
|
||
}
|
||
|
||
function close() {
|
||
emit('update:visible', false)
|
||
}
|
||
|
||
async function loadLogs() {
|
||
const seq = ++loadSeq
|
||
const ids = (props.taskIds || []).map((x) => (x || '').trim()).filter(Boolean)
|
||
loading.value = true
|
||
entries.value = []
|
||
try {
|
||
// 多任务统一走批量接口,避免路径被 /qc-tasks/{id} 误匹配
|
||
const list = ids.length
|
||
? await fetchQcTaskResultChangeLogsBatch(ids)
|
||
: []
|
||
if (seq !== loadSeq) return
|
||
entries.value = Array.isArray(list) ? list : []
|
||
} catch {
|
||
if (seq !== loadSeq) return
|
||
entries.value = []
|
||
ElMessage.error('加载修改记录失败')
|
||
} finally {
|
||
if (seq === loadSeq) loading.value = false
|
||
}
|
||
}
|
||
|
||
watch(
|
||
() => [props.visible, (props.taskIds || []).join(',')] as const,
|
||
([vis]) => {
|
||
if (vis) void loadLogs()
|
||
}
|
||
)
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.qc-result-chg-tl {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 4px;
|
||
padding: 4px 0 8px;
|
||
}
|
||
|
||
.qc-result-chg-tl__item {
|
||
display: flex;
|
||
gap: 12px;
|
||
}
|
||
|
||
.qc-result-chg-tl__rail {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
width: 12px;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.qc-result-chg-tl__dot {
|
||
width: 10px;
|
||
height: 10px;
|
||
margin-top: 4px;
|
||
border-radius: 50%;
|
||
background: var(--mint-primary, #10b981);
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.qc-result-chg-tl__line {
|
||
width: 2px;
|
||
flex: 1;
|
||
min-height: 36px;
|
||
margin-top: 4px;
|
||
background: var(--mint-primary-bg, #ecfdf5);
|
||
}
|
||
|
||
.qc-result-chg-tl__content {
|
||
flex: 1;
|
||
min-width: 0;
|
||
padding-bottom: 14px;
|
||
}
|
||
|
||
.qc-result-chg-tl__meta {
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
color: var(--mint-primary-dark, #059669);
|
||
margin-bottom: 6px;
|
||
}
|
||
|
||
.qc-result-chg-tl__line-text {
|
||
font-size: 13px;
|
||
color: var(--mint-text, #1e293b);
|
||
margin: 2px 0;
|
||
word-break: break-word;
|
||
}
|
||
|
||
.qc-result-chg-tl__note {
|
||
margin-top: 4px;
|
||
font-size: 12px;
|
||
color: var(--mint-text-muted, #334155);
|
||
}
|
||
</style>
|