1轮修复
This commit is contained in:
@@ -1 +1,5 @@
|
||||
export * from './workcase'
|
||||
export * from './workcase'
|
||||
|
||||
// 从shared导入系统和聊天相关API
|
||||
export { guestAPI as systemAPI } from 'shared/api/sys/guest'
|
||||
export { workcaseChatAPI as chatAPI } from './workcase'
|
||||
@@ -77,6 +77,10 @@ declare module 'shared/api/ai' {
|
||||
export const aiChatAPI: any
|
||||
}
|
||||
|
||||
declare module 'shared/api/sys/guest' {
|
||||
export const guestAPI: any
|
||||
}
|
||||
|
||||
// ============ types模块 ==================
|
||||
declare module 'shared/types' {
|
||||
// 基础类型
|
||||
@@ -117,7 +121,7 @@ declare module 'shared/types' {
|
||||
export type { LoginParam, LoginDomain } from '../../../shared/src/types/auth'
|
||||
|
||||
// 重新导出 sys
|
||||
export type { SysUserVO, SysConfigVO, TbSysViewDTO } from '../../../shared/src/types/sys'
|
||||
export type { SysUserVO, SysConfigVO, TbSysViewDTO, TbGuestDTO } from '../../../shared/src/types/sys'
|
||||
|
||||
// 重新导出 file
|
||||
export type { TbSysFileDTO } from '../../../shared/src/types/file'
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<AdminLayout title="工单管理" info="查看和处理客户服务工单">
|
||||
<!-- <template #action>
|
||||
<template #action>
|
||||
<el-button type="primary" @click="showCreateDialog = true">
|
||||
<el-icon><Plus /></el-icon>
|
||||
创建工单
|
||||
</el-button>
|
||||
</template> -->
|
||||
</template>
|
||||
|
||||
<div class="workcase-container">
|
||||
<!-- 筛选区域 -->
|
||||
@@ -97,18 +97,42 @@
|
||||
<!-- 创建工单弹窗 -->
|
||||
<el-dialog v-model="showCreateDialog" title="创建工单" width="650px">
|
||||
<el-form :model="formData" label-width="90px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="客户姓名" required>
|
||||
<el-input v-model="formData.username" placeholder="请输入客户姓名" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="联系电话" required>
|
||||
<el-input v-model="formData.phone" placeholder="请输入联系电话" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="来客人员" required>
|
||||
<el-select
|
||||
v-model="selectedGuestId"
|
||||
placeholder="请选择来客人员"
|
||||
style="width: 100%;"
|
||||
:loading="loadingGuests"
|
||||
filterable
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="guest in guestsList"
|
||||
:key="guest.userId"
|
||||
:label="`${guest.name} (${guest.phone || '无电话'})`"
|
||||
:value="guest.userId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="聊天室" required>
|
||||
<el-select
|
||||
v-model="formData.roomId"
|
||||
placeholder="请选择聊天室"
|
||||
style="width: 100%;"
|
||||
:loading="loadingChatRooms"
|
||||
filterable
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="room in chatRoomsList"
|
||||
:key="room.roomId"
|
||||
:label="`聊天室 ${room.roomName}`"
|
||||
:value="room.roomId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="故障类型" required>
|
||||
@@ -131,6 +155,13 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="设备代码" required>
|
||||
<el-input v-model="formData.deviceCode" placeholder="请输入设备代码" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="设备型号" required>
|
||||
<el-select v-model="formData.device" placeholder="请选择设备型号" style="width: 100%;">
|
||||
<el-option label="TH-500GF" value="TH-500GF" />
|
||||
@@ -172,15 +203,16 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { ref, computed, onMounted, watch } from 'vue'
|
||||
import AdminLayout from '@/views/admin/AdminLayout.vue'
|
||||
import { Plus, Search } from 'lucide-vue-next'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { workcaseAPI } from '@/api/workcase'
|
||||
import { workcaseAPI, chatAPI } from '@/api'
|
||||
import WorkcaseDetail from '@/views/public/workcase/WorkcaseDetail/WorkcaseDetail.vue'
|
||||
import { WorkcaseAssign } from '@/components'
|
||||
import type { TbWorkcaseDTO, TbWorkcaseProcessDTO } from '@/types/workcase'
|
||||
import type { PageRequest, PageParam } from 'shared/types'
|
||||
import type { TbWorkcaseDTO, TbWorkcaseProcessDTO, TbChatRoomDTO } from '@/types/workcase'
|
||||
import type { PageRequest, PageParam, TbGuestDTO } from 'shared/types'
|
||||
import { guestAPI } from 'shared/api/sys/guest'
|
||||
|
||||
const statusFilter = ref('all')
|
||||
const typeFilter = ref('')
|
||||
@@ -201,8 +233,12 @@ const assignCurrentProcessor = ref('')
|
||||
|
||||
const formData = ref<TbWorkcaseDTO>({
|
||||
username: '',
|
||||
userId: '',
|
||||
phone: '',
|
||||
device: '',
|
||||
deviceCode: '',
|
||||
roomId: '',
|
||||
deviceNamePlate: '',
|
||||
type: '',
|
||||
emergency: 'normal',
|
||||
description: ''
|
||||
@@ -210,6 +246,97 @@ const formData = ref<TbWorkcaseDTO>({
|
||||
|
||||
const workcaseList = ref<TbWorkcaseDTO[]>([])
|
||||
|
||||
// 来客人员相关
|
||||
const guestsList = ref<TbGuestDTO[]>([])
|
||||
const loadingGuests = ref(false)
|
||||
const selectedGuestId = ref('')
|
||||
|
||||
// 聊天室相关
|
||||
const chatRoomsList = ref<TbChatRoomDTO[]>([])
|
||||
const loadingChatRooms = ref(false)
|
||||
|
||||
// 加载来客人员列表
|
||||
const loadGuests = async () => {
|
||||
loadingGuests.value = true
|
||||
try {
|
||||
const res = await guestAPI.listGuest()
|
||||
if (res.success) {
|
||||
guestsList.value = res.dataList || []
|
||||
} else {
|
||||
ElMessage.error(res.message || '加载来客人员失败')
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error('加载来客人员失败')
|
||||
} finally {
|
||||
loadingGuests.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 根据来客ID加载聊天室列表
|
||||
const loadChatRoomsByGuest = async (guestId: string) => {
|
||||
if (!guestId) {
|
||||
chatRoomsList.value = []
|
||||
return
|
||||
}
|
||||
|
||||
loadingChatRooms.value = true
|
||||
try {
|
||||
const filter = {
|
||||
guestId: guestId
|
||||
}
|
||||
const pageRequest = {
|
||||
filter,
|
||||
pageParam: {
|
||||
page: 1,
|
||||
pageSize: 100
|
||||
}
|
||||
}
|
||||
const res = await chatAPI.getChatRoomPage(pageRequest)
|
||||
if (res.success) {
|
||||
chatRoomsList.value = res.dataList || res.pageDomain?.dataList || []
|
||||
} else {
|
||||
ElMessage.error(res.message || '加载聊天室列表失败')
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error('加载聊天室列表失败')
|
||||
} finally {
|
||||
loadingChatRooms.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 监听来客人员选择变化,加载对应的聊天室列表
|
||||
watch(selectedGuestId, (newGuestId) => {
|
||||
const selectedGuest = guestsList.value.find(guest => guest.userId === newGuestId)
|
||||
if (selectedGuest) {
|
||||
formData.value.username = selectedGuest.name
|
||||
formData.value.userId = selectedGuest.userId
|
||||
formData.value.phone = selectedGuest.phone
|
||||
// 加载该来客的聊天室列表
|
||||
loadChatRoomsByGuest(selectedGuest.userId)
|
||||
} else {
|
||||
formData.value.username = ''
|
||||
formData.value.userId = ''
|
||||
formData.value.phone = ''
|
||||
chatRoomsList.value = []
|
||||
}
|
||||
})
|
||||
|
||||
// 监听弹窗打开状态,加载来客人员列表
|
||||
watch(showCreateDialog, (newVal) => {
|
||||
if (newVal) {
|
||||
// 弹窗打开时,加载来客人员列表
|
||||
loadGuests()
|
||||
} else {
|
||||
// 弹窗关闭时,重置相关数据
|
||||
selectedGuestId.value = ''
|
||||
formData.value.username = ''
|
||||
formData.value.userId = ''
|
||||
formData.value.phone = ''
|
||||
formData.value.roomId = ''
|
||||
chatRoomsList.value = []
|
||||
}
|
||||
})
|
||||
|
||||
// ========================= API 调用方法 =========================
|
||||
/**
|
||||
* 加载工单列表
|
||||
@@ -253,10 +380,11 @@ const loadWorkcases = async () => {
|
||||
* 创建工单 - API调用
|
||||
*/
|
||||
const createWorkcaseAPI = async () => {
|
||||
if (!formData.value.username || !formData.value.phone || !formData.value.device || !formData.value.type) {
|
||||
if (!formData.value.username || !formData.value.phone || !formData.value.deviceCode || !formData.value.type || !formData.value.roomId) {
|
||||
ElMessage.error('请填写必填项')
|
||||
return
|
||||
}
|
||||
formData.value.deviceNamePlate = formData.value.deviceCode; // 将设备代码赋值给设备铭牌字段
|
||||
|
||||
const res = await workcaseAPI.createWorkcase(formData.value)
|
||||
if (res.success) {
|
||||
|
||||
Reference in New Issue
Block a user