feat(qc): 检测结果默认已完成/通过并记录修改历史
填写弹窗未落结论时默认任务状态已完成、结论通过(实验室与第三方); 每次保存追加操作留痕,卡片可查看修改时间线。关联 #148 #149。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8d7b2ada59
commit
9b6228860f
10 files changed
+740
-23
No files matched your search
@@ -154,6 +154,7 @@
|
||||
type QcTaskResultItem
|
||||
} from '@/api/qc-task-result'
|
||||
import { taskStatusLabel, taskStatusTagType } from '@/utils/qc-labels'
|
||||
import { resolveThirdPartyFillDefaults } from '@/utils/qc-result-fill-defaults'
|
||||
import { parseQcParamOptions } from '@/utils/qc-item-param-options'
|
||||
import {
|
||||
pickSharedRemarkAndAttachments,
|
||||
@@ -233,16 +234,6 @@
|
||||
emit('update:visible', false)
|
||||
}
|
||||
|
||||
/** 第三方弹窗仅展示待执行/已完成;其它状态按待执行回显 */
|
||||
function normalizeThirdPartySaveStatus(status?: string): 'dzx' | 'ywc' {
|
||||
return (status || '').trim() === 'ywc' ? 'ywc' : 'dzx'
|
||||
}
|
||||
|
||||
function normalizeConclusion(raw?: string): '' | 'tg' | 'btg' {
|
||||
const c = (raw || '').trim()
|
||||
return c === 'tg' || c === 'btg' ? c : ''
|
||||
}
|
||||
|
||||
function normalizeResultParams(items: QcTaskResultItem[]): QcTaskResultItem[] {
|
||||
return (items || []).map((p) => ({
|
||||
...p,
|
||||
@@ -319,13 +310,17 @@
|
||||
companyId: detail?.companyId ?? task.companyId,
|
||||
companyName: detail?.companyName ?? task.companyName
|
||||
}
|
||||
const fillDefaults = resolveThirdPartyFillDefaults({
|
||||
taskStatus: merged.taskStatus,
|
||||
conclusion: merged.conclusion
|
||||
})
|
||||
const item: ItemState = {
|
||||
taskId: task.id,
|
||||
itemName: merged.itemName || '—',
|
||||
companyName: thirdPartyCompanyDisplayName(merged),
|
||||
params: normalizeResultParams(results || []),
|
||||
saveStatus: normalizeThirdPartySaveStatus(merged.taskStatus),
|
||||
conclusion: normalizeConclusion(merged.conclusion)
|
||||
saveStatus: fillDefaults.saveStatus,
|
||||
conclusion: fillDefaults.conclusion
|
||||
}
|
||||
return { item, merged }
|
||||
})
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
<!-- 质检任务 · 检测结果修改记录 -->
|
||||
<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 {
|
||||
fetchQcTaskResultChangeLogs,
|
||||
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 {
|
||||
const list =
|
||||
ids.length > 1
|
||||
? await fetchQcTaskResultChangeLogsBatch(ids)
|
||||
: ids.length === 1
|
||||
? await fetchQcTaskResultChangeLogs(ids[0])
|
||||
: []
|
||||
if (seq !== loadSeq) return
|
||||
entries.value = 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>
|
||||
@@ -50,6 +50,13 @@
|
||||
uniqueAssigneeNames(item.tasks)
|
||||
}}</span>
|
||||
<div class="qc-work-order-task-sublist__ops">
|
||||
<el-button
|
||||
class="btn-op-item"
|
||||
size="small"
|
||||
@click.stop="openChangeLogForTasks(item.tasks, ALL_THIRD_PARTY_CARD_TITLE)"
|
||||
>
|
||||
<el-icon><Clock /></el-icon>修改记录
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="canFillAllThird(item)"
|
||||
class="btn-op-item primary"
|
||||
@@ -102,6 +109,13 @@
|
||||
item.task.assigneeUserNames || '—'
|
||||
}}</span>
|
||||
<div class="qc-work-order-task-sublist__ops">
|
||||
<el-button
|
||||
class="btn-op-item"
|
||||
size="small"
|
||||
@click.stop="openChangeLogForTask(item.task)"
|
||||
>
|
||||
<el-icon><Clock /></el-icon>修改记录
|
||||
</el-button>
|
||||
<template v-if="hasPrimaryTaskActions(item.task)">
|
||||
<el-button
|
||||
v-if="canStartTask(item.task)"
|
||||
@@ -414,6 +428,12 @@
|
||||
@saved="handleTaskMutationSuccess"
|
||||
/>
|
||||
|
||||
<QcTaskResultChangeLogDialog
|
||||
v-model:visible="changeLogVisible"
|
||||
:task-ids="changeLogTaskIds"
|
||||
:title-suffix="changeLogTitleSuffix"
|
||||
/>
|
||||
|
||||
<SystemViewDialog
|
||||
v-model:visible="viewVisible"
|
||||
title="任务详情"
|
||||
@@ -575,7 +595,8 @@
|
||||
EditPen,
|
||||
Plus,
|
||||
More,
|
||||
Delete
|
||||
Delete,
|
||||
Clock
|
||||
} from '@element-plus/icons-vue'
|
||||
import ProtocolFinanceConfirmFields from '@/components/business/protocol-finance-confirm-fields/index.vue'
|
||||
import ProtocolAttachmentReadonly from '@/views/cell-storage/protocol/ProtocolAttachmentReadonly.vue'
|
||||
@@ -612,6 +633,7 @@
|
||||
import { fetchItemUnitList } from '@/api/admin'
|
||||
import { SHOW_QC_TASK_MATERIAL_USAGE } from '@/utils/qc-material-ui'
|
||||
import { parseQcParamOptions } from '@/utils/qc-item-param-options'
|
||||
import { resolveQcResultFillDefaults } from '@/utils/qc-result-fill-defaults'
|
||||
import {
|
||||
taskTypeLabel,
|
||||
taskTypeTagType,
|
||||
@@ -656,6 +678,7 @@
|
||||
type QcTaskListDisplayItem
|
||||
} from '@/utils/qc-company-task-group'
|
||||
import QcCompanyTaskResultDialog from './QcCompanyTaskResultDialog.vue'
|
||||
import QcTaskResultChangeLogDialog from './QcTaskResultChangeLogDialog.vue'
|
||||
|
||||
/** 根据来源类型返回协议状态标签 */
|
||||
function protocolStatusLabelBySource(status: string, source: string, voidType?: string): string {
|
||||
@@ -739,6 +762,25 @@
|
||||
const companyDialogReadonly = ref(false)
|
||||
const companyDialogTasks = ref<QcTask[]>([])
|
||||
const companyDialogName = ref(ALL_THIRD_PARTY_CARD_TITLE)
|
||||
const changeLogVisible = ref(false)
|
||||
const changeLogTaskIds = ref<string[]>([])
|
||||
const changeLogTitleSuffix = ref('')
|
||||
|
||||
function openChangeLogForTask(task: QcTask) {
|
||||
const id = (task.id || '').trim()
|
||||
if (!id) return
|
||||
changeLogTaskIds.value = [id]
|
||||
changeLogTitleSuffix.value = task.itemName || task.taskNo || ''
|
||||
changeLogVisible.value = true
|
||||
}
|
||||
|
||||
function openChangeLogForTasks(tasks: QcTask[], title: string) {
|
||||
const ids = tasks.map((t) => (t.id || '').trim()).filter(Boolean)
|
||||
if (!ids.length) return
|
||||
changeLogTaskIds.value = ids
|
||||
changeLogTitleSuffix.value = title || ''
|
||||
changeLogVisible.value = true
|
||||
}
|
||||
|
||||
function openAllThirdResult(item: QcTaskListAllThirdItem, forceReadonly?: boolean) {
|
||||
let tasks = item.tasks
|
||||
@@ -864,11 +906,6 @@
|
||||
|
||||
const resultDialogWidth = computed(() => (resultTaskType.value === 'sysz' ? '1200px' : '960px'))
|
||||
|
||||
function normalizeResultSaveStatus(status?: string): 'dzx' | 'jxz' | 'ywc' {
|
||||
if (status === 'dzx' || status === 'jxz' || status === 'ywc') return status
|
||||
return 'jxz'
|
||||
}
|
||||
|
||||
function canFillResult(row: QcTask) {
|
||||
if (row.taskType === 'sysz') {
|
||||
return row.taskStatus === 'jxz' || row.taskStatus === 'ywc'
|
||||
@@ -1391,12 +1428,16 @@
|
||||
}
|
||||
return
|
||||
}
|
||||
const initialDefaults = resolveQcResultFillDefaults({
|
||||
taskStatus: row.taskStatus,
|
||||
conclusion: row.conclusion
|
||||
})
|
||||
resultTaskStatus.value = row.taskStatus
|
||||
resultSaveStatus.value = normalizeResultSaveStatus(row.taskStatus)
|
||||
resultSaveStatus.value = initialDefaults.saveStatus
|
||||
resultTaskId.value = row.id
|
||||
resultTaskType.value = row.taskType
|
||||
resultRemark.value = row.remark || ''
|
||||
resultConclusion.value = ''
|
||||
resultConclusion.value = initialDefaults.conclusion
|
||||
resultAttachments.value = apiFilesToFinanceItems(row.attachmentFiles)
|
||||
materialUsages.value = []
|
||||
requisitionOptions.value = []
|
||||
@@ -1404,10 +1445,13 @@
|
||||
try {
|
||||
const detail = await fetchQcTaskDetail(row.id)
|
||||
resultTaskStatus.value = detail.taskStatus || row.taskStatus
|
||||
resultSaveStatus.value = normalizeResultSaveStatus(detail.taskStatus || row.taskStatus)
|
||||
const fillDefaults = resolveQcResultFillDefaults({
|
||||
taskStatus: detail.taskStatus || row.taskStatus,
|
||||
conclusion: detail.conclusion
|
||||
})
|
||||
resultSaveStatus.value = fillDefaults.saveStatus
|
||||
resultRemark.value = detail.remark || row.remark || ''
|
||||
const c = (detail.conclusion || '').trim()
|
||||
resultConclusion.value = c === 'tg' || c === 'btg' ? c : ''
|
||||
resultConclusion.value = fillDefaults.conclusion
|
||||
resultAttachments.value = apiFilesToFinanceItems(detail.attachmentFiles)
|
||||
const results = await fetchQcTaskResults(row.id)
|
||||
resultParams.value = normalizeResultParams(results || [])
|
||||
|
||||
Reference in new issue
Block a user