工单细节处理

This commit is contained in:
2025-12-29 14:10:38 +08:00
parent 6a2544e964
commit 23b4383563
5 changed files with 50 additions and 42 deletions

View File

@@ -83,7 +83,7 @@
<template #default="{ row }"> <template #default="{ row }">
<el-button type="primary" link size="small" @click="viewDetail(row)">详情</el-button> <el-button type="primary" link size="small" @click="viewDetail(row)">详情</el-button>
<el-button v-if="row.status === 'pending'" type="warning" link size="small" @click="assignTicket(row)">指派</el-button> <el-button v-if="row.status === 'pending'" type="warning" link size="small" @click="assignTicket(row)">指派</el-button>
<el-button v-if="row.status === 'processing'" type="success" link size="small" @click="completeTicket(row)">完成</el-button> <el-button v-if="row.status === 'processing' || row.status === 'process'" type="success" link size="small" @click="completeTicket(row)">完成</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@@ -151,11 +151,12 @@
<!-- 工单详情弹窗 --> <!-- 工单详情弹窗 -->
<el-dialog v-model="showDetailDialog" title="工单详情" width="900px" destroy-on-close> <el-dialog v-model="showDetailDialog" title="工单详情" width="900px" destroy-on-close>
<WorkcaseDetail <WorkcaseDetail
v-if="showDetailDialog" v-if="showDetailDialog"
:workcase="currentWorkcase" :workcase-id="currentWorkcase.workcaseId"
mode="view" mode="view"
@cancel="showDetailDialog = false" @cancel="showDetailDialog = false"
@complete="handleCompleteFromDetail"
/> />
</el-dialog> </el-dialog>
@@ -293,7 +294,7 @@ const completeWorkcaseAPI = async (workcase: TbWorkcaseDTO) => {
action: 'finish', action: 'finish',
message: '工单完成' message: '工单完成'
} }
const res = await workcaseAPI.createWorkcaseProcess(process) const res = await workcaseAPI.createWorkcaseProcess(process)
if (res.success) { if (res.success) {
ElMessage.success('完成成功') ElMessage.success('完成成功')
@@ -303,15 +304,25 @@ const completeWorkcaseAPI = async (workcase: TbWorkcaseDTO) => {
} }
} }
// ========================= Mock 数据 ========================= /**
const mockTickets = [ * 从详情页完成工单
{ workcaseId: 'WC001', optsn: 'TK001', username: '张三', phone: '13800138000', type: 'electrical', device: 'TH-500GF', emergency: 'emergency' as const, status: 'pending' as const, processor: '', createTime: '2024-12-13 10:30' }, */
{ workcaseId: 'WC002', optsn: 'TK002', username: '李四', phone: '13800138001', type: 'mechanical', device: 'TH-300D', emergency: 'normal' as const, status: 'processing' as const, processor: '王五', createTime: '2024-12-13 09:15' }, const handleCompleteFromDetail = async (workcaseId: string) => {
{ workcaseId: 'WC003', optsn: 'TK003', username: '王五', phone: '13800138002', type: 'control', device: 'S-200X', emergency: 'normal' as const, status: 'done' as const, processor: '赵六', createTime: '2024-12-12 14:20' }, const process: TbWorkcaseProcessDTO = {
{ workcaseId: 'WC004', optsn: 'TK004', username: '赵六', phone: '13800138003', type: 'parts', device: 'TH-800GF', emergency: 'normal' as const, status: 'pending' as const, processor: '', createTime: '2024-12-13 11:00' }, workcaseId: workcaseId,
{ workcaseId: 'WC005', optsn: 'TK005', username: '孙七', phone: '13800138004', type: 'install', device: 'G-100S', emergency: 'emergency' as const, status: 'processing' as const, processor: '李四', createTime: '2024-12-13 08:45' } action: 'finish',
] message: '工单完成'
}
const res = await workcaseAPI.createWorkcaseProcess(process)
if (res.success) {
ElMessage.success('完成成功')
showDetailDialog.value = false
loadWorkcases()
} else {
ElMessage.error(res.message || '操作失败')
}
}
// ========================= 字段映射 ========================= // ========================= 字段映射 =========================
@@ -331,6 +342,7 @@ const emergencyMap: Record<string, string> = {
const statusMap: Record<string, string> = { const statusMap: Record<string, string> = {
pending: '待处理', pending: '待处理',
process: '处理中',
processing: '处理中', processing: '处理中',
done: '已完成' done: '已完成'
} }
@@ -363,6 +375,7 @@ const filteredTickets = computed(() => {
const getStatusType = (status: string) => { const getStatusType = (status: string) => {
const map: Record<string, string> = { const map: Record<string, string> = {
pending: 'warning', pending: 'warning',
process: 'info',
processing: 'info', processing: 'info',
done: 'success' done: 'success'
} }

View File

@@ -0,0 +1,9 @@
<template>
</template>
<script setup lang="ts">
</script>
<style lang="scss" scoped>
@import url('./CommentMessageCard.scss');
</style>

View File

@@ -149,8 +149,13 @@
<div class="title-bar"></div> <div class="title-bar"></div>
处理记录 处理记录
</div> </div>
<!-- 工单处理人记录工单过程--> <!-- 工单处理人记录工单过程 - 仅在处理中状态显示-->
<ElButton v-if="isProcessor" type="primary" size="small" @click="showAddProcessDialog = true"> <ElButton
v-if="isProcessor && (formData.status === 'processing')"
type="primary"
size="small"
@click="showAddProcessDialog = true"
>
添加处理记录 添加处理记录
</ElButton> </ElButton>
</div> </div>
@@ -211,14 +216,14 @@
指派工程师 指派工程师
</ElButton> </ElButton>
<ElButton <ElButton
v-if="mode === 'view' && !isCreator && formData.status === 'processing'" v-if="mode === 'view' && !isCreator && (formData.status === 'processing')"
type="warning" type="warning"
@click="handleRedeploy" @click="handleRedeploy"
> >
转派工程师 转派工程师
</ElButton> </ElButton>
<ElButton <ElButton
v-if="mode === 'view' && !isCreator && formData.status === 'processing'" v-if="mode === 'view' && !isCreator && (formData.status === 'processing')"
type="success" type="success"
@click="handleComplete" @click="handleComplete"
> >
@@ -293,15 +298,12 @@ interface Props {
mode?: 'view' | 'edit' | 'create' mode?: 'view' | 'edit' | 'create'
workcaseId?: string // 查看/编辑模式传入 workcaseId组件内部加载数据 workcaseId?: string // 查看/编辑模式传入 workcaseId组件内部加载数据
roomId?: string // 创建模式传入 roomId roomId?: string // 创建模式传入 roomId
workcase?: TbWorkcaseDTO // 兼容旧用法,直接传入数据
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
mode: 'view', mode: 'view',
workcaseId: '', workcaseId: '',
roomId: '', roomId: ''})
workcase: () => ({} as TbWorkcaseDTO)
})
const emit = defineEmits<{ const emit = defineEmits<{
cancel: [] cancel: []
@@ -313,7 +315,6 @@ const emit = defineEmits<{
const loading = ref(false) const loading = ref(false)
const formData = ref<TbWorkcaseDTO>({ const formData = ref<TbWorkcaseDTO>({
...props.workcase
}) })
// 故障类型选项(与微信端保持一致) // 故障类型选项(与微信端保持一致)
@@ -526,16 +527,7 @@ onMounted(() => {
if (props.mode === 'view' || props.mode === 'edit') { if (props.mode === 'view' || props.mode === 'edit') {
// 查看/编辑模式:通过 workcaseId 加载数据 // 查看/编辑模式:通过 workcaseId 加载数据
if (props.workcaseId) { loadWorkcaseDetail(props.workcaseId)
loadWorkcaseDetail(props.workcaseId)
} else if (props.workcase?.workcaseId) {
// 兼容旧用法
formData.value = { ...props.workcase }
currentRoomId.value = props.workcase.roomId || ''
if (props.workcase.workcaseId) {
loadProcessList(props.workcase.workcaseId)
}
}
} else if (props.mode === 'create') { } else if (props.mode === 'create') {
// 创建模式:初始化空表单,设置 roomId // 创建模式:初始化空表单,设置 roomId
formData.value = { formData.value = {
@@ -556,16 +548,10 @@ watch(() => props.workcaseId, (newVal) => {
} }
}) })
// 兼容旧用法:监听 workcase prop 变化
watch(() => props.workcase, (newVal) => {
if (newVal && !props.workcaseId) {
formData.value = { ...newVal }
}
}, { deep: true })
const statusLabel = (status: string) => { const statusLabel = (status: string) => {
const map: Record<string, string> = { const map: Record<string, string> = {
pending: '待处理', pending: '待处理',
process: '处理中',
processing: '处理中', processing: '处理中',
done: '已完成' done: '已完成'
} }
@@ -575,6 +561,7 @@ const statusLabel = (status: string) => {
const statusClass = (status: string) => { const statusClass = (status: string) => {
const map: Record<string, string> = { const map: Record<string, string> = {
pending: 'status-pending', pending: 'status-pending',
process: 'status-processing',
processing: 'status-processing', processing: 'status-processing',
done: 'status-done' done: 'status-done'
} }
@@ -729,8 +716,7 @@ const submitProcessRecord = async () => {
try { try {
// 从已上传文件列表获取文件ID // 从已上传文件列表获取文件ID
const fileIds = processUploadedFiles.value const fileIds = processUploadedFiles.value
.map(f => f.fileId) .map((f: TbSysFileDTO) => f.fileId)
.filter((id): id is string => !!id)
// 提交处理记录 // 提交处理记录
const params: TbWorkcaseProcessDTO = { const params: TbWorkcaseProcessDTO = {

View File

@@ -164,8 +164,8 @@
<view class="title-bar"></view> <view class="title-bar"></view>
<text class="title-text">处理记录</text> <text class="title-text">处理记录</text>
</view> </view>
<!-- 处理人记录处理过程 --> <!-- 处理人记录处理过程 - 仅在处理中状态显示 -->
<view v-if="isProcessor" class="add-process-section"> <view v-if="isProcessor && workcase.status === 'processing'" class="add-process-section">
<button class="add-process-btn" type="primary" size="mini" @tap="navigateToAddProcess"> <button class="add-process-btn" type="primary" size="mini" @tap="navigateToAddProcess">
添加处理记录 添加处理记录
</button> </button>