OrderDetailDrawer.vue 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150
  1. <template>
  2. <el-drawer v-model="drawerVisible" title="订单详情" direction="rtl" size="60%" class="order-detail-drawer">
  3. <div class="detail-container" v-if="order">
  4. <!-- 1. Header Status -->
  5. <div class="detail-header">
  6. <div class="left-head">
  7. <span class="order-no">{{ order.orderNo }}</span>
  8. <el-tag :type="getStatusTag(order.status)" effect="dark" class="status-tag">{{
  9. getStatusName(order.status) }}</el-tag>
  10. <el-tag effect="plain" class="type-tag"
  11. :type="order.type === 'transport' ? '' : (order.type === 'feeding' ? 'warning' : 'danger')">
  12. {{ getTypeName(order.type) }}
  13. </el-tag>
  14. </div>
  15. <div class="right-head">
  16. <!-- Action Buttons Group -->
  17. <div class="detail-actions">
  18. <!-- <template v-if="[0, 1, 2].includes(order.status)">-->
  19. <!-- <el-button type="success" icon="Bicycle" @click="emit('dispatch', order)">-->
  20. <!-- {{ order.fulfiller || order.fulfillerName ? '重新派单' : '立即派单' }}-->
  21. <!-- </el-button>-->
  22. <!-- </template>-->
  23. <template v-if="[0, 1].includes(order.status)">
  24. <el-button v-hasPermi="['order:management:cancel']" type="danger" plain icon="CircleClose"
  25. @click="emit('cancel', order)">取消订单</el-button>
  26. </template>
  27. <template v-if="order.status === 3">
  28. <el-button type="primary" icon="CircleCheck"
  29. @click="emit('command', 'complete', order)">确认完成</el-button>
  30. </template>
  31. <template v-if="[3, 4].includes(order.status)">
  32. <el-button v-hasPermi="['order:management:nursingSummary']" icon="Notebook"
  33. @click="emit('care-summary', order)">护理小结</el-button>
  34. </template>
  35. <el-dropdown v-if="![7].includes(order.status)" trigger="click"
  36. @command="(cmd) => emit('command', cmd, order)" style="margin-left: 12px;">
  37. <el-button icon="More">更多操作</el-button>
  38. <template #dropdown>
  39. <el-dropdown-menu>
  40. <el-dropdown-item command="delete" v-if="[4, 5, 6].includes(order.status)" divided
  41. icon="Delete" style="color: #f56c6c;">删除订单</el-dropdown-item>
  42. </el-dropdown-menu>
  43. </template>
  44. </el-dropdown>
  45. </div>
  46. </div>
  47. </div>
  48. <div class="detail-scroll-area">
  49. <!-- 2. Progress Section -->
  50. <div class="progress-section">
  51. <el-steps :active="currentOrderSteps.active" finish-status="success" align-center
  52. class="custom-steps">
  53. <el-step v-for="(step, index) in currentOrderSteps.steps" :key="index" :title="step.title"
  54. :description="step.time" />
  55. </el-steps>
  56. </div>
  57. <!-- 3. Top Info: Pet & User -->
  58. <div class="top-info-row">
  59. <!-- Left: Pet Info -->
  60. <div class="info-section pet-section" style="cursor: pointer" @click="petDetailVisible = true">
  61. <div class="sec-header">
  62. <span class="label">宠物档案</span>
  63. <el-tag size="small" effect="plain">{{ order.petBreed }}</el-tag>
  64. </div>
  65. <div class="pet-basic-row">
  66. <el-avatar :size="50" :src="order.petAvatar" shape="square" class="pet-avatar-lg">{{
  67. (order.petName || '').charAt(0) }}</el-avatar>
  68. <div class="pet-names">
  69. <div class="b-name">{{ order.petName }}
  70. <el-icon v-if="order.petGender === 'male'" color="#409eff">
  71. <Male />
  72. </el-icon>
  73. <el-icon v-else color="#f56c6c">
  74. <Female />
  75. </el-icon>
  76. </div>
  77. <div class="b-tags">
  78. <el-tag size="small" type="info">{{ order.petAge || '-' }}</el-tag>
  79. <el-tag size="small" type="info">{{ order.petWeight || '-' }}</el-tag>
  80. </div>
  81. </div>
  82. </div>
  83. <el-descriptions :column="2" size="small" class="pet-desc" border>
  84. <el-descriptions-item label="品种">{{ order.petBreed || '-' }}</el-descriptions-item>
  85. <el-descriptions-item label="疫苗状态"><span style="color:#67c23a">{{ order.petVaccine || '-'
  86. }}</span></el-descriptions-item>
  87. <el-descriptions-item label="性格特点">{{ order.petCharacter || '-' }}</el-descriptions-item>
  88. <el-descriptions-item label="健康状况">{{ order.petHealth || '-' }}</el-descriptions-item>
  89. </el-descriptions>
  90. </div>
  91. <!-- Right: User Info -->
  92. <div class="info-section user-section">
  93. <div class="sec-header">
  94. <span class="label">用户信息</span>
  95. </div>
  96. <div class="user-content">
  97. <div class="u-row">
  98. <el-avatar :size="40" :src="order.userAvatar">{{ (order.userName || '').charAt(0)
  99. }}</el-avatar>
  100. <div class="u-info">
  101. <div class="nm">{{ order.userName }}</div>
  102. <div class="ph">{{ order.contactPhone }}</div>
  103. </div>
  104. </div>
  105. <div class="addr-box">
  106. <div class="addr-label">服务地址</div>
  107. <div class="addr-txt">{{ order.city }}{{ order.district }} {{ order.address || '-' }}
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <!-- 4. Bottom Tabs -->
  114. <el-tabs v-model="activeDetailTab" class="detail-tabs type-card">
  115. <!-- Tab 1: Basic Info -->
  116. <el-tab-pane label="订单基础信息" name="basic">
  117. <div class="tab-pane-content">
  118. <div class="section-block">
  119. <div class="sec-title-bar">基础业务信息</div>
  120. <el-descriptions :column="3" border size="default" class="custom-desc">
  121. <el-descriptions-item label="系统单号">{{ order.orderNo }}</el-descriptions-item>
  122. <el-descriptions-item label="服务类型">
  123. {{ getTypeName(order.type) }}
  124. </el-descriptions-item>
  125. <el-descriptions-item label="归属门店">{{ order.merchantName || '-' }}
  126. ({{ Number(order.platformId) === 1 ? '门店下单' : '平台代下单' }})</el-descriptions-item>
  127. <el-descriptions-item label="宠主信息">{{ order.userName || '-' }} / {{
  128. order.contactPhone || '-'
  129. }}</el-descriptions-item>
  130. <el-descriptions-item label="订单佣金" label-class-name="money-label">
  131. <span style="color:#f56c6c; font-weight:bold;">¥ {{ order.orderCommission ?
  132. (order.orderCommission / 100).toFixed(2) : '0.00' }}</span>
  133. </el-descriptions-item>
  134. <el-descriptions-item label="预约时间">{{ getServiceTimeRange(order.serviceTime) || '-'
  135. }}</el-descriptions-item>
  136. <el-descriptions-item label="团购套餐">{{ order.groupBuyPackage || '-'
  137. }}</el-descriptions-item>
  138. <el-descriptions-item label="创建时间">{{ order.createTime || '-'
  139. }}</el-descriptions-item>
  140. <el-descriptions-item label="订单备注" :span="3">
  141. {{ order.remark || '-' }}
  142. </el-descriptions-item>
  143. </el-descriptions>
  144. </div>
  145. <div v-if="order.type === 'transport'" class="section-block transport-split-block">
  146. <div class="sec-title-bar">接送任务详情</div>
  147. <div class="transport-one">
  148. <div class="t-row">
  149. <el-tag size="small" effect="plain" class="sub-badge">{{
  150. getTransportLabel(order.subOrderType) }}</el-tag>
  151. <span class="time">{{ order.serviceTime }}</span>
  152. </div>
  153. <div class="t-row">
  154. <span class="t-k">起点</span>
  155. <span class="t-v">{{ order.detail?.fromAddress || order.detail?.pickAddr || '-'
  156. }}</span>
  157. </div>
  158. <div class="t-row">
  159. <span class="t-k">终点</span>
  160. <span class="t-v">{{ order.detail?.toAddress || order.detail?.dropAddr ||
  161. order.toAddress ||
  162. '-' }}</span>
  163. </div>
  164. <div class="t-row sub">
  165. <span class="t-v">{{ order.contact || order.userName || '-' }} {{
  166. order.contactPhoneNumber
  167. || order.contactPhone || '-' }}</span>
  168. </div>
  169. </div>
  170. </div>
  171. <div v-if="['feeding', 'washing'].includes(order.type)" class="section-block">
  172. <div class="sec-title-bar">服务执行要求</div>
  173. <el-descriptions :column="2" border size="default" class="custom-desc">
  174. <el-descriptions-item label="服务地址" :span="2">{{ order.detail?.area || order.address
  175. || '-'
  176. }}</el-descriptions-item>
  177. </el-descriptions>
  178. </div>
  179. </div>
  180. </el-tab-pane>
  181. <!-- Tab 2: Fulfiller Info -->
  182. <el-tab-pane label="指派履约者" name="fulfiller">
  183. <div class="tab-pane-content">
  184. <div v-if="order.fulfillerName" class="fulfiller-card">
  185. <div class="f-left">
  186. <el-avatar :size="60" :src="order.fulfillerAvatar">{{ order.fulfillerName.charAt(0)
  187. }}</el-avatar>
  188. </div>
  189. <div class="f-right">
  190. <div class="f-row1">
  191. <span class="f-name">{{ order.fulfillerName }}</span>
  192. <el-tag size="small" type="primary" effect="plain" round>Lv1 普通</el-tag>
  193. </div>
  194. <div class="f-row2">
  195. <span>联系电话:{{ order.fulfillerPhone || '-' }}</span>
  196. <span class="sep">|</span>
  197. <span>归属区域:{{ order.fulfillerStation || '-' }}</span>
  198. </div>
  199. <div class="f-row3"
  200. style="margin-top: 8px; font-size: 13px; color: #606266; background: #f9fafe; padding: 8px; border-radius: 4px; display: flex; gap: 20px;">
  201. <span><span style="color:#909399;">指派时间:</span>{{ dispatchTime }}</span>
  202. <span><span style="color:#909399;">接单时间:</span>{{ acceptTime }}</span>
  203. </div>
  204. </div>
  205. </div>
  206. <div v-else class="empty-state">
  207. <el-result icon="info" title="暂无履约者" sub-title="该订单尚未指派履约人员"></el-result>
  208. </div>
  209. </div>
  210. </el-tab-pane>
  211. <!-- Tab 3: Service Progress -->
  212. <el-tab-pane label="服务进度" name="service">
  213. <div class="tab-pane-content">
  214. <div style="display: flex; justify-content: flex-end; margin-bottom: 15px; gap: 10px;">
  215. <el-button type="success" size="small" icon="Link"
  216. v-hasPermi="['order:management:queyGenerateFulfillPath']"
  217. @click="handleGenerateFulfillPath">生成履约路径</el-button>
  218. </div>
  219. <div v-if="serviceProgressSteps.length === 0" class="empty-progress"
  220. style="padding:40px; text-align:center; color:#909399;">
  221. <el-result icon="info" title="待接单" sub-title="履约者接单后将在此记录服务进度"></el-result>
  222. </div>
  223. <el-timeline style="padding: 10px 20px;" v-else>
  224. <el-timeline-item v-for="(step, index) in serviceProgressSteps" :key="index"
  225. :timestamp="step.time" placement="top" :color="step.color" :icon="step.icon"
  226. size="large">
  227. <div class="progress-card">
  228. <h4 class="p-title">{{ step.title }}</h4>
  229. <p class="p-desc">{{ step.desc }}</p>
  230. <div class="p-media" v-if="step.media && step.media.length">
  231. <div v-for="(item, i) in step.media" :key="i" class="media-item">
  232. <!-- 图片类型 -->
  233. <el-image v-if="item.type === 'image'" :src="item.url"
  234. :preview-src-list="step.media.filter(m => m.type === 'image').map(m => m.url)"
  235. fit="cover" class="p-img" :preview-teleported="true" />
  236. <!-- 视频类型 -->
  237. <div v-else-if="item.type === 'video'" class="p-video-box"
  238. @click="openVideoPreview(item.url)">
  239. <video :src="item.url" preload="metadata"
  240. class="p-img p-video"></video>
  241. <div class="play-icon-overlay">
  242. <el-icon>
  243. <VideoPlay />
  244. </el-icon>
  245. </div>
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. </el-timeline-item>
  251. </el-timeline>
  252. </div>
  253. </el-tab-pane>
  254. <!-- Tab 4: Logs -->
  255. <el-tab-pane label="订单日志" name="logs">
  256. <div class="tab-pane-content">
  257. <div style="display: flex; justify-content: flex-end; margin-bottom: 15px;">
  258. <el-button type="primary" size="small" icon="Download"
  259. v-hasPermi="['order:management:queryExportExcel']"
  260. @click="handleExportLogs">导出日志Excel</el-button>
  261. </div>
  262. <el-timeline>
  263. <el-timeline-item v-for="(log, index) in (orderLogs || [])" :key="index"
  264. :timestamp="log.createTime || log.time || ''" :type="'primary'" :icon="undefined"
  265. placement="top">
  266. <div class="log-card">
  267. <div class="l-tit">{{ log.title }}</div>
  268. <div class="l-txt">{{ log.content }}</div>
  269. </div>
  270. </el-timeline-item>
  271. </el-timeline>
  272. </div>
  273. </el-tab-pane>
  274. <!-- Tab 5: Complaint Records -->
  275. <el-tab-pane label="投诉记录" name="complaints">
  276. <div class="tab-pane-content">
  277. <div v-if="complaintList.length === 0" class="empty-state">
  278. <el-result icon="success" title="暂无投诉" sub-title="该订单暂无投诉记录"></el-result>
  279. </div>
  280. <el-timeline v-else>
  281. <el-timeline-item v-for="(complaint, index) in complaintList" :key="index"
  282. :timestamp="complaint.createTime" placement="top" color="#f56c6c">
  283. <div class="log-card">
  284. <div class="l-tit">履约者:{{ complaint.fulfiller }}</div>
  285. <div class="l-txt">{{ complaint.reason }}</div>
  286. <div class="l-txt" v-if="complaint.photoUrls">
  287. <span>图片:</span>
  288. <div style="display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px;">
  289. <ImagePreview v-for="(url, imgIndex) in complaint.photoUrls.split(',')"
  290. :key="imgIndex" :src="url" :width="40" :height="40" />
  291. </div>
  292. </div>
  293. </div>
  294. </el-timeline-item>
  295. </el-timeline>
  296. </div>
  297. </el-tab-pane>
  298. <!-- Tab 6: Service Change Records -->
  299. <el-tab-pane label="服务变更记录" name="serviceChanges">
  300. <div class="tab-pane-content">
  301. <div v-if="serviceChangeList.length === 0" class="empty-state">
  302. <el-result icon="success" title="暂无服务变更" sub-title="该订单暂无服务变更记录"></el-result>
  303. </div>
  304. <el-timeline v-else>
  305. <el-timeline-item v-for="(change, index) in serviceChangeList" :key="index"
  306. :timestamp="change.createTime" placement="top" color="#409eff">
  307. <div class="log-card">
  308. <div class="l-tit">服务变更 - {{ change.service }}</div>
  309. <div class="l-txt">申诉理由:{{ change.reason }}</div>
  310. <div class="l-txt" v-if="change.auditStatus === 1" style="color:#67c23a;">
  311. 审核状态:已通过</div>
  312. <div class="l-txt" v-else-if="change.auditStatus === 2" style="color:#f56c6c;">
  313. 审核状态:已驳回
  314. </div>
  315. <div class="l-txt" v-else style="color:#e6a23c;">审核状态:待审核</div>
  316. <div class="l-txt" v-if="change.photoUrls">
  317. <span>图片:</span>
  318. <div style="display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px;">
  319. <ImagePreview v-for="(url, imgIndex) in change.photoUrls.split(',')"
  320. :key="imgIndex" :src="url" :width="40" :height="40" />
  321. </div>
  322. </div>
  323. </div>
  324. </el-timeline-item>
  325. </el-timeline>
  326. </div>
  327. </el-tab-pane>
  328. </el-tabs>
  329. </div>
  330. <PetDetailDrawer v-model:visible="petDetailVisible" :pet-id="order?.pet || order?.petId" />
  331. </div>
  332. </el-drawer>
  333. <!-- 视频播放弹窗 -->
  334. <el-dialog v-model="videoPreview.visible" title="视频播放" width="800px" append-to-body @closed="videoPreview.url = ''">
  335. <div
  336. style="width: 100%; display: flex; justify-content: center; background: #000; border-radius: 4px; overflow: hidden;">
  337. <video v-if="videoPreview.url" :src="videoPreview.url" controls autoplay
  338. style="max-width: 100%; max-height: 70vh;"></video>
  339. </div>
  340. </el-dialog>
  341. </template>
  342. <script setup>
  343. import { ref, reactive, computed, watch, getCurrentInstance } from 'vue'
  344. import { ElMessage } from 'element-plus'
  345. import { getPet } from '@/api/archieves/pet'
  346. import { getCustomer } from '@/api/archieves/customer'
  347. import { listSubOrderLog, exportSubOrderLogUrl } from '@/api/order/subOrderLog/index'
  348. import { listComplaintByOrder } from '@/api/fulfiller/complaint'
  349. import { listSubOrderAppealByOrderId } from '@/api/order/subOrderAppeal'
  350. import { getFulfillerDetail } from '@/api/fulfiller/fulfiller/index'
  351. import PetDetailDrawer from '@/components/PetDetailDrawer/index.vue'
  352. import ImagePreview from '@/components/ImagePreview/index.vue'
  353. // 视频判定辅助函数
  354. const isVideo = (url) => {
  355. if (!url) return false;
  356. const videoExts = ['.mp4', '.mov', '.avi', '.wmv', '.webm', '.ogg'];
  357. return videoExts.some(ext => String(url).toLowerCase().endsWith(ext));
  358. }
  359. // 视频预览状态
  360. const videoPreview = reactive({
  361. visible: false,
  362. url: ''
  363. })
  364. const openVideoPreview = (url) => {
  365. videoPreview.url = url;
  366. videoPreview.visible = true;
  367. }
  368. const { proxy } = getCurrentInstance()
  369. const props = defineProps({
  370. visible: Boolean,
  371. order: Object
  372. })
  373. const emit = defineEmits(['update:visible', 'dispatch', 'cancel', 'command', 'care-summary'])
  374. const drawerVisible = computed({
  375. get: () => props.visible,
  376. set: (val) => emit('update:visible', val)
  377. })
  378. const orderDetail = ref(null)
  379. const order = computed(() => orderDetail.value || props.order)
  380. const loadSeq = ref(0)
  381. const orderLogs = ref([])
  382. const fulfillerLogs = ref([])
  383. const complaintList = ref([])
  384. const serviceChangeList = ref([])
  385. const loadOrderLogs = async (order) => {
  386. const id = order?.id
  387. if (!id) {
  388. orderLogs.value = []
  389. fulfillerLogs.value = []
  390. complaintList.value = []
  391. serviceChangeList.value = []
  392. return
  393. }
  394. try {
  395. const res = await listSubOrderLog({ orderId: id })
  396. const list = res?.data?.data || res?.data || []
  397. const arr = Array.isArray(list) ? list : []
  398. orderLogs.value = arr.filter(i => Number(i?.logType) === 0)
  399. fulfillerLogs.value = arr.filter(i => Number(i?.logType) === 1)
  400. } catch {
  401. orderLogs.value = []
  402. fulfillerLogs.value = []
  403. }
  404. try {
  405. const complaintRes = await listComplaintByOrder(id)
  406. complaintList.value = complaintRes?.data || []
  407. } catch {
  408. complaintList.value = []
  409. }
  410. try {
  411. const serviceChangeRes = await listSubOrderAppealByOrderId(id)
  412. serviceChangeList.value = serviceChangeRes?.data || []
  413. } catch {
  414. serviceChangeList.value = []
  415. }
  416. }
  417. const loadPetAndCustomer = async (order) => {
  418. const seq = ++loadSeq.value
  419. const next = { ...(order || {}) }
  420. const petId = next?.pet || next?.petId
  421. if (petId) {
  422. try {
  423. const res = await getPet(petId)
  424. const pet = res?.data
  425. console.log('Web商户端 - 宠物详情:', pet)
  426. if (pet) {
  427. next.petName = pet.name ?? next.petName
  428. next.petAvatar = pet.avatarUrl || pet.avatar || next.petAvatar
  429. next.petGender = pet.gender ?? next.petGender
  430. next.petAge = (pet.age !== undefined && pet.age !== null) ? `${pet.age}岁` : next.petAge
  431. next.petWeight = (pet.weight !== undefined && pet.weight !== null) ? `${pet.weight}kg` : next.petWeight
  432. next.petBreed = pet.breed ?? next.petBreed
  433. next.petSterilized = (pet.isSterilized !== undefined && pet.isSterilized !== null)
  434. ? (Number(pet.isSterilized) === 1)
  435. : next.petSterilized
  436. next.petVaccine = pet.vaccineStatus ?? next.petVaccine
  437. next.petCharacter = (pet.cutePersonality || pet.personality) ?? next.petCharacter
  438. next.petHealth = pet.healthStatus ?? next.petHealth
  439. }
  440. } catch {
  441. }
  442. }
  443. const customerId = next?.customer || next?.customerId
  444. if (customerId) {
  445. try {
  446. const res = await getCustomer(customerId)
  447. const customer = res?.data
  448. console.log('Web商户端 - 客户详情:', customer)
  449. if (customer) {
  450. next.userName = customer.name ?? next.userName
  451. next.userAvatar = customer.avatarUrl || customer.avatar || next.userAvatar
  452. next.contactPhone = customer.phone ?? next.contactPhone
  453. next.city = customer.areaName ?? next.city
  454. next.address = customer.address ?? next.address
  455. }
  456. } catch {
  457. }
  458. }
  459. const fulfillerId = next?.fulfiller || next?.fulfillerId
  460. if (fulfillerId) {
  461. try {
  462. const res = await getFulfillerDetail(fulfillerId)
  463. const fulfillerData = res?.data?.data || res?.data
  464. console.log('Web商户端 - 履约者详情:', fulfillerData)
  465. if (fulfillerData) {
  466. next.fulfillerAvatar = fulfillerData.avatarUrl || fulfillerData.avatar || next.fulfillerAvatar
  467. next.fulfillerPhone = fulfillerData.phone ?? next.fulfillerPhone
  468. next.fulfillerStation = fulfillerData.stationName ?? next.fulfillerStation
  469. next.fulfillerName = fulfillerData.name ?? next.fulfillerName
  470. }
  471. } catch {
  472. }
  473. }
  474. if (seq !== loadSeq.value) return
  475. orderDetail.value = next
  476. }
  477. watch(() => props.order, (val) => {
  478. if (!val) {
  479. orderDetail.value = null
  480. orderLogs.value = []
  481. fulfillerLogs.value = []
  482. return
  483. }
  484. loadPetAndCustomer(val)
  485. loadOrderLogs(val)
  486. }, { immediate: true, deep: true })
  487. const petDetailVisible = ref(false)
  488. const activeDetailTab = ref('basic')
  489. const getStatusName = (status) => {
  490. const map = { 0: '待派单', 1: '待接单', 2: '服务中', 3: '待商家确认', 4: '已完成', 5: '已取消', 6: '已拒绝', 7: '已关闭' }
  491. return map[status] || '未知'
  492. }
  493. const getStatusTag = (status) => {
  494. const map = { 0: 'danger', 1: 'warning', 2: 'primary', 3: 'warning', 4: 'success', 5: 'info', 6: 'danger', 7: 'info' }
  495. return map[status] || 'info'
  496. }
  497. const getTypeName = (type) => {
  498. const map = { transport: '宠物接送', feeding: '上门喂遛', washing: '上门洗护' }
  499. return map[type]
  500. }
  501. const getTransportModeName = (type) => {
  502. const map = { round: '往返接送', pick: '单程接(到店)', drop: '单程送(回家)' }
  503. return map[type] || '接送服务'
  504. }
  505. const previewImage = (url, urls) => {
  506. // 直接在新窗口打开图片
  507. window.open(url, '_blank')
  508. }
  509. const getTransportLabel = (t) => {
  510. if (t === 0 || t === '0') return '接'
  511. if (t === 1 || t === '1') return '送'
  512. if (t === 2 || t === '2') return '单程接'
  513. if (t === 3 || t === '3') return '单程送'
  514. return '接送'
  515. }
  516. const getServiceTimeRange = (timeStr) => {
  517. if (!timeStr) return '--'
  518. try {
  519. if (timeStr.length < 16) return timeStr
  520. let timePart = timeStr.substring(11, 16)
  521. let [hh, mm] = timePart.split(':').map(Number)
  522. let endH = hh + 2
  523. if (endH >= 24) endH -= 24
  524. let endHStr = endH.toString().padStart(2, '0')
  525. return `${timeStr}-${endHStr}:${mm.toString().padStart(2, '0')}`
  526. } catch (e) {
  527. return timeStr
  528. }
  529. }
  530. const currentOrderSteps = computed(() => {
  531. if (!props.order) return { active: 0, steps: [] }
  532. const status = props.order.status
  533. const logs = orderLogs.value || []
  534. const findTime = (keyword) => {
  535. const log = logs.find(l => l.title.includes(keyword) || l.content.includes(keyword))
  536. return log ? log.time : ''
  537. }
  538. // 已取消 — 特殊两步流程
  539. if (status === 5) {
  540. const createTime = props.order.createTime || findTime('下单') || findTime('创建')
  541. return {
  542. active: 1,
  543. steps: [
  544. { title: '商户下单', time: createTime },
  545. { title: '已取消', time: findTime('取消') || '订单已取消' }
  546. ]
  547. }
  548. }
  549. // 已拒绝 — 特殊两步流程
  550. if (status === 6) {
  551. const createTime = props.order.createTime || findTime('下单') || findTime('创建')
  552. return {
  553. active: 1,
  554. steps: [
  555. { title: '商户下单', time: createTime },
  556. { title: '已拒绝', time: findTime('拒绝') || '订单已拒绝' }
  557. ]
  558. }
  559. }
  560. // 已关闭 — 特殊两步流程
  561. if (status === 7) {
  562. const createTime = props.order.createTime || findTime('下单') || findTime('创建')
  563. return {
  564. active: 1,
  565. steps: [
  566. { title: '商户下单', time: createTime },
  567. { title: '已关闭', time: findTime('关闭') || '订单已关闭' }
  568. ]
  569. }
  570. }
  571. // 六步流程:商户下单 → 运营派单 → 履约接单 → 等待服务 → 服务进行 → 订单完成
  572. const steps = [
  573. { title: '商户下单', time: props.order.createTime || findTime('下单') || findTime('创建') },
  574. { title: '运营派单', time: findTime('派单') || '' },
  575. { title: '履约接单', time: findTime('接单') || '' },
  576. { title: '等待服务', time: findTime('到达') || '' },
  577. { title: '服务进行', time: findTime('完成') || '' },
  578. { title: '订单完成', time: findTime('完成') || '' }
  579. ]
  580. let active = 1 // 默认停在「运营派单」
  581. switch (status) {
  582. case 0:
  583. active = 1
  584. break
  585. case 1:
  586. active = 2
  587. steps[2].title = '等待接单'
  588. break
  589. case 2:
  590. active = 3
  591. steps[2].title = '已确认接'
  592. break
  593. case 3:
  594. active = 4
  595. steps[2].title = '已确认接'
  596. steps[3].title = '已到达点'
  597. break
  598. case 4:
  599. active = 6
  600. steps[2].title = '已确认接'
  601. steps[3].title = '已到达点'
  602. break
  603. }
  604. return { active, steps }
  605. })
  606. // 从订单日志中取派单/接单时间 @Author: Antigravity
  607. const dispatchTime = computed(() => orderLogs.value.find(l => l.title === '系统派单')?.createTime || '-')
  608. const acceptTime = computed(() => orderLogs.value.find(l => l.title === '接单成功')?.createTime || '-')
  609. const serviceProgressSteps = computed(() => {
  610. const list = fulfillerLogs.value || []
  611. return list.map((i) => {
  612. const media = (i?.photoUrls || []).map(url => {
  613. const isVideo = url.toLowerCase().match(/\.(mp4|mov|avi|wmv|flv|mkv)$/)
  614. return {
  615. type: isVideo ? 'video' : 'image',
  616. url
  617. }
  618. })
  619. return {
  620. title: i?.title || '--',
  621. time: i?.createTime || '',
  622. icon: undefined,
  623. color: '#ff9900',
  624. desc: i?.content || '',
  625. media: media
  626. }
  627. })
  628. })
  629. const handleExportLogs = () => {
  630. const id = props.order?.id;
  631. if (!id) {
  632. ElMessage.warning('订单信息不完整,无法导出');
  633. return;
  634. }
  635. proxy?.download(
  636. exportSubOrderLogUrl(id),
  637. {},
  638. `OrderLogs_${props.order.orderNo}_${new Date().getTime()}.xlsx`
  639. );
  640. }
  641. /**
  642. * 生成履约路径链接并复制到剪贴板
  643. */
  644. const handleGenerateFulfillPath = () => {
  645. const id = props.order?.id
  646. if (!id) {
  647. ElMessage.warning('订单信息不完整,无法生成链接')
  648. return
  649. }
  650. const hostname = window.location.hostname
  651. const isIp = /^(\d{1,3}\.){3}\d{1,3}$/.test(hostname)
  652. const baseUrl = isIp ? `http://${hostname}` : 'https://www.hoomeng.pet'
  653. const url = `${baseUrl}/fulfillPath?orderId=${id}`
  654. navigator.clipboard.writeText(url).then(() => {
  655. ElMessage.success('履约路径已复制到剪贴板')
  656. }).catch(() => {
  657. ElMessage({ message: url, type: 'success', duration: 10000, showClose: true })
  658. })
  659. }
  660. </script>
  661. <style scoped>
  662. /* Detail Styles */
  663. .order-detail-drawer :deep(.el-drawer__body) {
  664. padding: 0 !important;
  665. }
  666. .detail-container {
  667. height: 100%;
  668. display: flex;
  669. flex-direction: column;
  670. background: #f5f7fa;
  671. }
  672. .detail-header {
  673. background: #fff;
  674. padding: 20px 24px;
  675. border-bottom: 1px solid #ebeef5;
  676. display: flex;
  677. justify-content: space-between;
  678. align-items: center;
  679. }
  680. .left-head {
  681. display: flex;
  682. align-items: center;
  683. gap: 12px;
  684. }
  685. .order-no {
  686. font-size: 20px;
  687. font-weight: bold;
  688. color: #303133;
  689. }
  690. .type-tag {
  691. font-weight: normal;
  692. }
  693. .detail-actions {
  694. display: flex;
  695. align-items: center;
  696. gap: 12px;
  697. }
  698. .detail-scroll-area {
  699. flex: 1;
  700. overflow-y: auto;
  701. padding: 20px 24px;
  702. }
  703. /* Progress */
  704. .progress-section {
  705. background: #fff;
  706. padding: 30px 20px 20px;
  707. border-radius: 8px;
  708. margin-bottom: 20px;
  709. box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  710. }
  711. .custom-steps :deep(.el-step__title) {
  712. font-size: 13px;
  713. }
  714. /* Top Info Row */
  715. .top-info-row {
  716. display: flex;
  717. gap: 20px;
  718. margin-bottom: 20px;
  719. align-items: stretch;
  720. }
  721. .info-section {
  722. flex: 1;
  723. background: #fff;
  724. border-radius: 8px;
  725. padding: 15px;
  726. box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  727. }
  728. .sec-header {
  729. display: flex;
  730. justify-content: space-between;
  731. align-items: center;
  732. margin-bottom: 15px;
  733. padding-bottom: 10px;
  734. border-bottom: 1px solid #f2f2f2;
  735. }
  736. .sec-header .label {
  737. font-weight: bold;
  738. font-size: 15px;
  739. color: #303133;
  740. border-left: 3px solid #409eff;
  741. padding-left: 8px;
  742. }
  743. /* Pet Section */
  744. .pet-basic-row {
  745. display: flex;
  746. gap: 15px;
  747. margin-bottom: 15px;
  748. align-items: center;
  749. }
  750. .pet-avatar-lg {
  751. border-radius: 8px;
  752. background: #ecf5ff;
  753. color: #409eff;
  754. font-size: 20px;
  755. font-weight: bold;
  756. }
  757. .pet-names {
  758. display: flex;
  759. flex-direction: column;
  760. gap: 6px;
  761. }
  762. .b-name {
  763. font-size: 18px;
  764. font-weight: bold;
  765. display: flex;
  766. align-items: center;
  767. gap: 6px;
  768. }
  769. .b-tags {
  770. display: flex;
  771. gap: 5px;
  772. }
  773. .pet-desc :deep(.el-descriptions__label) {
  774. width: 70px;
  775. }
  776. /* User Section */
  777. .u-row {
  778. display: flex;
  779. gap: 12px;
  780. align-items: center;
  781. margin-bottom: 12px;
  782. }
  783. .u-info .nm {
  784. font-weight: bold;
  785. font-size: 15px;
  786. color: #303133;
  787. display: flex;
  788. align-items: center;
  789. gap: 6px;
  790. }
  791. .u-info .ph {
  792. font-size: 13px;
  793. color: #909399;
  794. margin-top: 2px;
  795. }
  796. .addr-box {
  797. background: #fdf6ec;
  798. padding: 8px 10px;
  799. border-radius: 4px;
  800. margin-bottom: 10px;
  801. }
  802. .addr-label {
  803. font-size: 12px;
  804. color: #e6a23c;
  805. margin-bottom: 2px;
  806. font-weight: bold;
  807. }
  808. .addr-txt {
  809. font-size: 13px;
  810. color: #606266;
  811. line-height: 1.4;
  812. }
  813. /* Tabs */
  814. .detail-tabs {
  815. background: #fff;
  816. padding: 10px 20px;
  817. border-radius: 8px;
  818. box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  819. min-height: 400px;
  820. }
  821. .tab-pane-content {
  822. padding: 15px 0;
  823. }
  824. /* Fulfiller Card inside Tab */
  825. .fulfiller-card {
  826. display: flex;
  827. align-items: center;
  828. gap: 20px;
  829. padding: 20px;
  830. background: #fff;
  831. border: 1px solid #ebeef5;
  832. border-radius: 8px;
  833. }
  834. .f-right {
  835. flex: 1;
  836. display: flex;
  837. flex-direction: column;
  838. gap: 8px;
  839. }
  840. .f-row1 {
  841. display: flex;
  842. align-items: center;
  843. gap: 10px;
  844. }
  845. .f-name {
  846. font-size: 18px;
  847. font-weight: bold;
  848. color: #303133;
  849. }
  850. .f-row2 {
  851. font-size: 13px;
  852. color: #606266;
  853. display: flex;
  854. gap: 10px;
  855. }
  856. .sep {
  857. color: #e4e7ed;
  858. }
  859. .empty-state {
  860. padding: 40px 0;
  861. text-align: center;
  862. }
  863. /* Progress Card Styles */
  864. .progress-card {
  865. background: #f8fcfb;
  866. border-radius: 8px;
  867. padding: 12px;
  868. border: 1px solid #ebeef5;
  869. }
  870. .p-title {
  871. margin: 0 0 8px;
  872. font-size: 15px;
  873. font-weight: bold;
  874. color: #303133;
  875. }
  876. .p-desc {
  877. margin: 0 0 12px;
  878. color: #606266;
  879. font-size: 13px;
  880. line-height: 1.5;
  881. }
  882. .p-media {
  883. display: flex;
  884. gap: 8px;
  885. flex-wrap: wrap;
  886. }
  887. .p-video {
  888. object-fit: cover;
  889. }
  890. .p-img {
  891. width: 80px;
  892. height: 80px;
  893. border-radius: 4px;
  894. border: 1px solid #e4e7ed;
  895. cursor: pointer;
  896. background: #f5f7fa;
  897. }
  898. .p-video-box {
  899. position: relative;
  900. width: 80px;
  901. height: 80px;
  902. cursor: pointer;
  903. }
  904. .play-icon-overlay {
  905. position: absolute;
  906. top: 50%;
  907. left: 50%;
  908. transform: translate(-50%, -50%);
  909. background: rgba(0, 0, 0, 0.4);
  910. color: #fff;
  911. width: 32px;
  912. height: 32px;
  913. border-radius: 50%;
  914. display: flex;
  915. align-items: center;
  916. justify-content: center;
  917. font-size: 18px;
  918. transition: all 0.2s;
  919. }
  920. .p-video-box:hover .play-icon-overlay {
  921. background: rgba(0, 0, 0, 0.6);
  922. transform: translate(-50%, -50%) scale(1.1);
  923. }
  924. /* New Transport Split Styles */
  925. .transport-split-block {
  926. margin-top: 20px;
  927. }
  928. .transport-grid {
  929. display: flex;
  930. gap: 20px;
  931. }
  932. .transport-card {
  933. flex: 1;
  934. border: 1px solid #ebeef5;
  935. border-radius: 6px;
  936. overflow: hidden;
  937. background: #fff;
  938. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  939. }
  940. .transport-card .t-header {
  941. background: #f5f7fa;
  942. padding: 10px 15px;
  943. border-bottom: 1px solid #ebeef5;
  944. display: flex;
  945. justify-content: space-between;
  946. align-items: center;
  947. }
  948. .transport-card .t-header .time {
  949. font-size: 13px;
  950. font-weight: bold;
  951. color: #f56c6c;
  952. }
  953. .transport-card .t-body {
  954. padding: 15px;
  955. display: flex;
  956. flex-direction: column;
  957. gap: 10px;
  958. }
  959. .transport-card .row {
  960. display: flex;
  961. align-items: flex-start;
  962. gap: 8px;
  963. font-size: 14px;
  964. color: #303133;
  965. line-height: 1.4;
  966. }
  967. .transport-card .row.sub {
  968. color: #909399;
  969. font-size: 13px;
  970. margin-top: 4px;
  971. }
  972. .transport-card .row .el-icon {
  973. margin-top: 3px;
  974. }
  975. .transport-one {
  976. border: 1px solid #ebeef5;
  977. border-radius: 6px;
  978. background: #fff;
  979. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  980. padding: 14px 16px;
  981. display: flex;
  982. flex-direction: column;
  983. gap: 10px;
  984. }
  985. .transport-one .t-row {
  986. display: flex;
  987. align-items: baseline;
  988. gap: 10px;
  989. }
  990. .transport-one .t-row .time {
  991. font-size: 13px;
  992. font-weight: bold;
  993. color: #f56c6c;
  994. }
  995. .transport-one .t-k {
  996. width: 40px;
  997. color: #909399;
  998. font-size: 13px;
  999. }
  1000. .transport-one .t-v {
  1001. color: #303133;
  1002. font-size: 14px;
  1003. line-height: 1.4;
  1004. }
  1005. .transport-one .t-row.sub .t-v {
  1006. color: #909399;
  1007. font-size: 13px;
  1008. }
  1009. /* Logs */
  1010. .log-card {
  1011. background: #f4f4f5;
  1012. padding: 10px 15px;
  1013. border-radius: 4px;
  1014. position: relative;
  1015. top: -5px;
  1016. width: 100%;
  1017. }
  1018. .l-tit {
  1019. font-weight: bold;
  1020. font-size: 14px;
  1021. margin-bottom: 4px;
  1022. color: #303133;
  1023. }
  1024. .l-txt {
  1025. font-size: 13px;
  1026. color: #606266;
  1027. line-height: 1.5;
  1028. }
  1029. </style>