OrderDetailDrawer.vue 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125
  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 v-if="serviceProgressSteps.length === 0" class="empty-progress"
  215. style="padding:40px; text-align:center; color:#909399;">
  216. <el-result icon="info" title="待接单" sub-title="履约者接单后将在此记录服务进度"></el-result>
  217. </div>
  218. <el-timeline style="padding: 10px 20px;" v-else>
  219. <el-timeline-item v-for="(step, index) in serviceProgressSteps" :key="index"
  220. :timestamp="step.time" placement="top" :color="step.color" :icon="step.icon"
  221. size="large">
  222. <div class="progress-card">
  223. <h4 class="p-title">{{ step.title }}</h4>
  224. <p class="p-desc">{{ step.desc }}</p>
  225. <div class="p-media" v-if="step.media && step.media.length">
  226. <div v-for="(item, i) in step.media" :key="i" class="media-item">
  227. <!-- 图片类型 -->
  228. <el-image v-if="item.type === 'image'" :src="item.url"
  229. :preview-src-list="step.media.filter(m => m.type === 'image').map(m => m.url)"
  230. fit="cover" class="p-img" :preview-teleported="true" />
  231. <!-- 视频类型 -->
  232. <div v-else-if="item.type === 'video'" class="p-video-box"
  233. @click="openVideoPreview(item.url)">
  234. <video :src="item.url" preload="metadata"
  235. class="p-img p-video"></video>
  236. <div class="play-icon-overlay">
  237. <el-icon>
  238. <VideoPlay />
  239. </el-icon>
  240. </div>
  241. </div>
  242. </div>
  243. </div>
  244. </div>
  245. </el-timeline-item>
  246. </el-timeline>
  247. </div>
  248. </el-tab-pane>
  249. <!-- Tab 4: Logs -->
  250. <el-tab-pane label="订单日志" name="logs">
  251. <div class="tab-pane-content">
  252. <div style="display: flex; justify-content: flex-end; margin-bottom: 15px;">
  253. <el-button type="primary" size="small" icon="Download"
  254. v-hasPermi="['order:management:queryExportExcel']"
  255. @click="handleExportLogs">导出日志Excel</el-button>
  256. </div>
  257. <el-timeline>
  258. <el-timeline-item v-for="(log, index) in (orderLogs || [])" :key="index"
  259. :timestamp="log.createTime || log.time || ''" :type="'primary'" :icon="undefined"
  260. placement="top">
  261. <div class="log-card">
  262. <div class="l-tit">{{ log.title }}</div>
  263. <div class="l-txt">{{ log.content }}</div>
  264. </div>
  265. </el-timeline-item>
  266. </el-timeline>
  267. </div>
  268. </el-tab-pane>
  269. <!-- Tab 5: Complaint Records -->
  270. <el-tab-pane label="投诉记录" name="complaints">
  271. <div class="tab-pane-content">
  272. <div v-if="complaintList.length === 0" class="empty-state">
  273. <el-result icon="success" title="暂无投诉" sub-title="该订单暂无投诉记录"></el-result>
  274. </div>
  275. <el-timeline v-else>
  276. <el-timeline-item v-for="(complaint, index) in complaintList" :key="index"
  277. :timestamp="complaint.createTime" placement="top" color="#f56c6c">
  278. <div class="log-card">
  279. <div class="l-tit">履约者:{{ complaint.fulfiller }}</div>
  280. <div class="l-txt">{{ complaint.reason }}</div>
  281. <div class="l-txt" v-if="complaint.photoUrls">
  282. <span>图片:</span>
  283. <div style="display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px;">
  284. <ImagePreview v-for="(url, imgIndex) in complaint.photoUrls.split(',')"
  285. :key="imgIndex" :src="url" :width="40" :height="40" />
  286. </div>
  287. </div>
  288. </div>
  289. </el-timeline-item>
  290. </el-timeline>
  291. </div>
  292. </el-tab-pane>
  293. <!-- Tab 6: Service Change Records -->
  294. <el-tab-pane label="服务变更记录" name="serviceChanges">
  295. <div class="tab-pane-content">
  296. <div v-if="serviceChangeList.length === 0" class="empty-state">
  297. <el-result icon="success" title="暂无服务变更" sub-title="该订单暂无服务变更记录"></el-result>
  298. </div>
  299. <el-timeline v-else>
  300. <el-timeline-item v-for="(change, index) in serviceChangeList" :key="index"
  301. :timestamp="change.createTime" placement="top" color="#409eff">
  302. <div class="log-card">
  303. <div class="l-tit">服务变更 - {{ change.service }}</div>
  304. <div class="l-txt">申诉理由:{{ change.reason }}</div>
  305. <div class="l-txt" v-if="change.auditStatus === 1" style="color:#67c23a;">
  306. 审核状态:已通过</div>
  307. <div class="l-txt" v-else-if="change.auditStatus === 2" style="color:#f56c6c;">
  308. 审核状态:已驳回
  309. </div>
  310. <div class="l-txt" v-else style="color:#e6a23c;">审核状态:待审核</div>
  311. <div class="l-txt" v-if="change.photoUrls">
  312. <span>图片:</span>
  313. <div style="display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px;">
  314. <ImagePreview v-for="(url, imgIndex) in change.photoUrls.split(',')"
  315. :key="imgIndex" :src="url" :width="40" :height="40" />
  316. </div>
  317. </div>
  318. </div>
  319. </el-timeline-item>
  320. </el-timeline>
  321. </div>
  322. </el-tab-pane>
  323. </el-tabs>
  324. </div>
  325. <PetDetailDrawer v-model:visible="petDetailVisible" :pet-id="order?.pet || order?.petId" />
  326. </div>
  327. </el-drawer>
  328. <!-- 视频播放弹窗 -->
  329. <el-dialog v-model="videoPreview.visible" title="视频播放" width="800px" append-to-body @closed="videoPreview.url = ''">
  330. <div
  331. style="width: 100%; display: flex; justify-content: center; background: #000; border-radius: 4px; overflow: hidden;">
  332. <video v-if="videoPreview.url" :src="videoPreview.url" controls autoplay
  333. style="max-width: 100%; max-height: 70vh;"></video>
  334. </div>
  335. </el-dialog>
  336. </template>
  337. <script setup>
  338. import { ref, reactive, computed, watch, getCurrentInstance } from 'vue'
  339. import { ElMessage } from 'element-plus'
  340. import { getPet } from '@/api/archieves/pet'
  341. import { getCustomer } from '@/api/archieves/customer'
  342. import { listSubOrderLog, exportSubOrderLogUrl } from '@/api/order/subOrderLog/index'
  343. import { listComplaintByOrder } from '@/api/fulfiller/complaint'
  344. import { listSubOrderAppealByOrderId } from '@/api/order/subOrderAppeal'
  345. import { getFulfillerDetail } from '@/api/fulfiller/fulfiller/index'
  346. import PetDetailDrawer from '@/components/PetDetailDrawer/index.vue'
  347. import ImagePreview from '@/components/ImagePreview/index.vue'
  348. // 视频判定辅助函数
  349. const isVideo = (url) => {
  350. if (!url) return false;
  351. const videoExts = ['.mp4', '.mov', '.avi', '.wmv', '.webm', '.ogg'];
  352. return videoExts.some(ext => String(url).toLowerCase().endsWith(ext));
  353. }
  354. // 视频预览状态
  355. const videoPreview = reactive({
  356. visible: false,
  357. url: ''
  358. })
  359. const openVideoPreview = (url) => {
  360. videoPreview.url = url;
  361. videoPreview.visible = true;
  362. }
  363. const { proxy } = getCurrentInstance()
  364. const props = defineProps({
  365. visible: Boolean,
  366. order: Object
  367. })
  368. const emit = defineEmits(['update:visible', 'dispatch', 'cancel', 'command', 'care-summary'])
  369. const drawerVisible = computed({
  370. get: () => props.visible,
  371. set: (val) => emit('update:visible', val)
  372. })
  373. const orderDetail = ref(null)
  374. const order = computed(() => orderDetail.value || props.order)
  375. const loadSeq = ref(0)
  376. const orderLogs = ref([])
  377. const fulfillerLogs = ref([])
  378. const complaintList = ref([])
  379. const serviceChangeList = ref([])
  380. const loadOrderLogs = async (order) => {
  381. const id = order?.id
  382. if (!id) {
  383. orderLogs.value = []
  384. fulfillerLogs.value = []
  385. complaintList.value = []
  386. serviceChangeList.value = []
  387. return
  388. }
  389. try {
  390. const res = await listSubOrderLog({ orderId: id })
  391. const list = res?.data?.data || res?.data || []
  392. const arr = Array.isArray(list) ? list : []
  393. orderLogs.value = arr.filter(i => Number(i?.logType) === 0)
  394. fulfillerLogs.value = arr.filter(i => Number(i?.logType) === 1)
  395. } catch {
  396. orderLogs.value = []
  397. fulfillerLogs.value = []
  398. }
  399. try {
  400. const complaintRes = await listComplaintByOrder(id)
  401. complaintList.value = complaintRes?.data || []
  402. } catch {
  403. complaintList.value = []
  404. }
  405. try {
  406. const serviceChangeRes = await listSubOrderAppealByOrderId(id)
  407. serviceChangeList.value = serviceChangeRes?.data || []
  408. } catch {
  409. serviceChangeList.value = []
  410. }
  411. }
  412. const loadPetAndCustomer = async (order) => {
  413. const seq = ++loadSeq.value
  414. const next = { ...(order || {}) }
  415. const petId = next?.pet || next?.petId
  416. if (petId) {
  417. try {
  418. const res = await getPet(petId)
  419. const pet = res?.data
  420. console.log('Web商户端 - 宠物详情:', pet)
  421. if (pet) {
  422. next.petName = pet.name ?? next.petName
  423. next.petAvatar = pet.avatarUrl || pet.avatar || next.petAvatar
  424. next.petGender = pet.gender ?? next.petGender
  425. next.petAge = (pet.age !== undefined && pet.age !== null) ? `${pet.age}岁` : next.petAge
  426. next.petWeight = (pet.weight !== undefined && pet.weight !== null) ? `${pet.weight}kg` : next.petWeight
  427. next.petBreed = pet.breed ?? next.petBreed
  428. next.petSterilized = (pet.isSterilized !== undefined && pet.isSterilized !== null)
  429. ? (Number(pet.isSterilized) === 1)
  430. : next.petSterilized
  431. next.petVaccine = pet.vaccineStatus ?? next.petVaccine
  432. next.petCharacter = (pet.cutePersonality || pet.personality) ?? next.petCharacter
  433. next.petHealth = pet.healthStatus ?? next.petHealth
  434. }
  435. } catch {
  436. }
  437. }
  438. const customerId = next?.customer || next?.customerId
  439. if (customerId) {
  440. try {
  441. const res = await getCustomer(customerId)
  442. const customer = res?.data
  443. console.log('Web商户端 - 客户详情:', customer)
  444. if (customer) {
  445. next.userName = customer.name ?? next.userName
  446. next.userAvatar = customer.avatarUrl || customer.avatar || next.userAvatar
  447. next.contactPhone = customer.phone ?? next.contactPhone
  448. next.city = customer.areaName ?? next.city
  449. next.address = customer.address ?? next.address
  450. }
  451. } catch {
  452. }
  453. }
  454. const fulfillerId = next?.fulfiller || next?.fulfillerId
  455. if (fulfillerId) {
  456. try {
  457. const res = await getFulfillerDetail(fulfillerId)
  458. const fulfillerData = res?.data?.data || res?.data
  459. console.log('Web商户端 - 履约者详情:', fulfillerData)
  460. if (fulfillerData) {
  461. next.fulfillerAvatar = fulfillerData.avatarUrl || fulfillerData.avatar || next.fulfillerAvatar
  462. next.fulfillerPhone = fulfillerData.phone ?? next.fulfillerPhone
  463. next.fulfillerStation = fulfillerData.stationName ?? next.fulfillerStation
  464. next.fulfillerName = fulfillerData.name ?? next.fulfillerName
  465. }
  466. } catch {
  467. }
  468. }
  469. if (seq !== loadSeq.value) return
  470. orderDetail.value = next
  471. }
  472. watch(() => props.order, (val) => {
  473. if (!val) {
  474. orderDetail.value = null
  475. orderLogs.value = []
  476. fulfillerLogs.value = []
  477. return
  478. }
  479. loadPetAndCustomer(val)
  480. loadOrderLogs(val)
  481. }, { immediate: true, deep: true })
  482. const petDetailVisible = ref(false)
  483. const activeDetailTab = ref('basic')
  484. const getStatusName = (status) => {
  485. const map = { 0: '待派单', 1: '待接单', 2: '服务中', 3: '待商家确认', 4: '已完成', 5: '已取消', 6: '已拒绝', 7: '已关闭' }
  486. return map[status] || '未知'
  487. }
  488. const getStatusTag = (status) => {
  489. const map = { 0: 'danger', 1: 'warning', 2: 'primary', 3: 'warning', 4: 'success', 5: 'info', 6: 'danger', 7: 'info' }
  490. return map[status] || 'info'
  491. }
  492. const getTypeName = (type) => {
  493. const map = { transport: '宠物接送', feeding: '上门喂遛', washing: '上门洗护' }
  494. return map[type]
  495. }
  496. const getTransportModeName = (type) => {
  497. const map = { round: '往返接送', pick: '单程接(到店)', drop: '单程送(回家)' }
  498. return map[type] || '接送服务'
  499. }
  500. const previewImage = (url, urls) => {
  501. // 直接在新窗口打开图片
  502. window.open(url, '_blank')
  503. }
  504. const getTransportLabel = (t) => {
  505. if (t === 0 || t === '0') return '接'
  506. if (t === 1 || t === '1') return '送'
  507. if (t === 2 || t === '2') return '单程接'
  508. if (t === 3 || t === '3') return '单程送'
  509. return '接送'
  510. }
  511. const getServiceTimeRange = (timeStr) => {
  512. if (!timeStr) return '--'
  513. try {
  514. if (timeStr.length < 16) return timeStr
  515. let timePart = timeStr.substring(11, 16)
  516. let [hh, mm] = timePart.split(':').map(Number)
  517. let endH = hh + 2
  518. if (endH >= 24) endH -= 24
  519. let endHStr = endH.toString().padStart(2, '0')
  520. return `${timeStr}-${endHStr}:${mm.toString().padStart(2, '0')}`
  521. } catch (e) {
  522. return timeStr
  523. }
  524. }
  525. const currentOrderSteps = computed(() => {
  526. if (!props.order) return { active: 0, steps: [] }
  527. const status = props.order.status
  528. const logs = orderLogs.value || []
  529. const findTime = (keyword) => {
  530. const log = logs.find(l => l.title.includes(keyword) || l.content.includes(keyword))
  531. return log ? log.time : ''
  532. }
  533. // 已取消 — 特殊两步流程
  534. if (status === 5) {
  535. const createTime = props.order.createTime || findTime('下单') || findTime('创建')
  536. return {
  537. active: 1,
  538. steps: [
  539. { title: '商户下单', time: createTime },
  540. { title: '已取消', time: findTime('取消') || '订单已取消' }
  541. ]
  542. }
  543. }
  544. // 已拒绝 — 特殊两步流程
  545. if (status === 6) {
  546. const createTime = props.order.createTime || findTime('下单') || findTime('创建')
  547. return {
  548. active: 1,
  549. steps: [
  550. { title: '商户下单', time: createTime },
  551. { title: '已拒绝', time: findTime('拒绝') || '订单已拒绝' }
  552. ]
  553. }
  554. }
  555. // 已关闭 — 特殊两步流程
  556. if (status === 7) {
  557. const createTime = props.order.createTime || findTime('下单') || findTime('创建')
  558. return {
  559. active: 1,
  560. steps: [
  561. { title: '商户下单', time: createTime },
  562. { title: '已关闭', time: findTime('关闭') || '订单已关闭' }
  563. ]
  564. }
  565. }
  566. // 六步流程:商户下单 → 运营派单 → 履约接单 → 等待服务 → 服务进行 → 订单完成
  567. const steps = [
  568. { title: '商户下单', time: props.order.createTime || findTime('下单') || findTime('创建') },
  569. { title: '运营派单', time: findTime('派单') || '' },
  570. { title: '履约接单', time: findTime('接单') || '' },
  571. { title: '等待服务', time: findTime('到达') || '' },
  572. { title: '服务进行', time: findTime('完成') || '' },
  573. { title: '订单完成', time: findTime('完成') || '' }
  574. ]
  575. let active = 1 // 默认停在「运营派单」
  576. switch (status) {
  577. case 0:
  578. active = 1
  579. break
  580. case 1:
  581. active = 2
  582. steps[2].title = '等待接单'
  583. break
  584. case 2:
  585. active = 3
  586. steps[2].title = '已确认接'
  587. break
  588. case 3:
  589. active = 4
  590. steps[2].title = '已确认接'
  591. steps[3].title = '已到达点'
  592. break
  593. case 4:
  594. active = 6
  595. steps[2].title = '已确认接'
  596. steps[3].title = '已到达点'
  597. break
  598. }
  599. return { active, steps }
  600. })
  601. // 从订单日志中取派单/接单时间 @Author: Antigravity
  602. const dispatchTime = computed(() => orderLogs.value.find(l => l.title === '系统派单')?.createTime || '-')
  603. const acceptTime = computed(() => orderLogs.value.find(l => l.title === '接单成功')?.createTime || '-')
  604. const serviceProgressSteps = computed(() => {
  605. const list = fulfillerLogs.value || []
  606. return list.map((i) => {
  607. const media = (i?.photoUrls || []).map(url => {
  608. const isVideo = url.toLowerCase().match(/\.(mp4|mov|avi|wmv|flv|mkv)$/)
  609. return {
  610. type: isVideo ? 'video' : 'image',
  611. url
  612. }
  613. })
  614. return {
  615. title: i?.title || '--',
  616. time: i?.createTime || '',
  617. icon: undefined,
  618. color: '#ff9900',
  619. desc: i?.content || '',
  620. media: media
  621. }
  622. })
  623. })
  624. const handleExportLogs = () => {
  625. const id = props.order?.id;
  626. if (!id) {
  627. ElMessage.warning('订单信息不完整,无法导出');
  628. return;
  629. }
  630. proxy?.download(
  631. exportSubOrderLogUrl(id),
  632. {},
  633. `OrderLogs_${props.order.orderNo}_${new Date().getTime()}.xlsx`
  634. );
  635. }
  636. </script>
  637. <style scoped>
  638. /* Detail Styles */
  639. .order-detail-drawer :deep(.el-drawer__body) {
  640. padding: 0 !important;
  641. }
  642. .detail-container {
  643. height: 100%;
  644. display: flex;
  645. flex-direction: column;
  646. background: #f5f7fa;
  647. }
  648. .detail-header {
  649. background: #fff;
  650. padding: 20px 24px;
  651. border-bottom: 1px solid #ebeef5;
  652. display: flex;
  653. justify-content: space-between;
  654. align-items: center;
  655. }
  656. .left-head {
  657. display: flex;
  658. align-items: center;
  659. gap: 12px;
  660. }
  661. .order-no {
  662. font-size: 20px;
  663. font-weight: bold;
  664. color: #303133;
  665. }
  666. .type-tag {
  667. font-weight: normal;
  668. }
  669. .detail-actions {
  670. display: flex;
  671. align-items: center;
  672. gap: 12px;
  673. }
  674. .detail-scroll-area {
  675. flex: 1;
  676. overflow-y: auto;
  677. padding: 20px 24px;
  678. }
  679. /* Progress */
  680. .progress-section {
  681. background: #fff;
  682. padding: 30px 20px 20px;
  683. border-radius: 8px;
  684. margin-bottom: 20px;
  685. box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  686. }
  687. .custom-steps :deep(.el-step__title) {
  688. font-size: 13px;
  689. }
  690. /* Top Info Row */
  691. .top-info-row {
  692. display: flex;
  693. gap: 20px;
  694. margin-bottom: 20px;
  695. align-items: stretch;
  696. }
  697. .info-section {
  698. flex: 1;
  699. background: #fff;
  700. border-radius: 8px;
  701. padding: 15px;
  702. box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  703. }
  704. .sec-header {
  705. display: flex;
  706. justify-content: space-between;
  707. align-items: center;
  708. margin-bottom: 15px;
  709. padding-bottom: 10px;
  710. border-bottom: 1px solid #f2f2f2;
  711. }
  712. .sec-header .label {
  713. font-weight: bold;
  714. font-size: 15px;
  715. color: #303133;
  716. border-left: 3px solid #409eff;
  717. padding-left: 8px;
  718. }
  719. /* Pet Section */
  720. .pet-basic-row {
  721. display: flex;
  722. gap: 15px;
  723. margin-bottom: 15px;
  724. align-items: center;
  725. }
  726. .pet-avatar-lg {
  727. border-radius: 8px;
  728. background: #ecf5ff;
  729. color: #409eff;
  730. font-size: 20px;
  731. font-weight: bold;
  732. }
  733. .pet-names {
  734. display: flex;
  735. flex-direction: column;
  736. gap: 6px;
  737. }
  738. .b-name {
  739. font-size: 18px;
  740. font-weight: bold;
  741. display: flex;
  742. align-items: center;
  743. gap: 6px;
  744. }
  745. .b-tags {
  746. display: flex;
  747. gap: 5px;
  748. }
  749. .pet-desc :deep(.el-descriptions__label) {
  750. width: 70px;
  751. }
  752. /* User Section */
  753. .u-row {
  754. display: flex;
  755. gap: 12px;
  756. align-items: center;
  757. margin-bottom: 12px;
  758. }
  759. .u-info .nm {
  760. font-weight: bold;
  761. font-size: 15px;
  762. color: #303133;
  763. display: flex;
  764. align-items: center;
  765. gap: 6px;
  766. }
  767. .u-info .ph {
  768. font-size: 13px;
  769. color: #909399;
  770. margin-top: 2px;
  771. }
  772. .addr-box {
  773. background: #fdf6ec;
  774. padding: 8px 10px;
  775. border-radius: 4px;
  776. margin-bottom: 10px;
  777. }
  778. .addr-label {
  779. font-size: 12px;
  780. color: #e6a23c;
  781. margin-bottom: 2px;
  782. font-weight: bold;
  783. }
  784. .addr-txt {
  785. font-size: 13px;
  786. color: #606266;
  787. line-height: 1.4;
  788. }
  789. /* Tabs */
  790. .detail-tabs {
  791. background: #fff;
  792. padding: 10px 20px;
  793. border-radius: 8px;
  794. box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  795. min-height: 400px;
  796. }
  797. .tab-pane-content {
  798. padding: 15px 0;
  799. }
  800. /* Fulfiller Card inside Tab */
  801. .fulfiller-card {
  802. display: flex;
  803. align-items: center;
  804. gap: 20px;
  805. padding: 20px;
  806. background: #fff;
  807. border: 1px solid #ebeef5;
  808. border-radius: 8px;
  809. }
  810. .f-right {
  811. flex: 1;
  812. display: flex;
  813. flex-direction: column;
  814. gap: 8px;
  815. }
  816. .f-row1 {
  817. display: flex;
  818. align-items: center;
  819. gap: 10px;
  820. }
  821. .f-name {
  822. font-size: 18px;
  823. font-weight: bold;
  824. color: #303133;
  825. }
  826. .f-row2 {
  827. font-size: 13px;
  828. color: #606266;
  829. display: flex;
  830. gap: 10px;
  831. }
  832. .sep {
  833. color: #e4e7ed;
  834. }
  835. .empty-state {
  836. padding: 40px 0;
  837. text-align: center;
  838. }
  839. /* Progress Card Styles */
  840. .progress-card {
  841. background: #f8fcfb;
  842. border-radius: 8px;
  843. padding: 12px;
  844. border: 1px solid #ebeef5;
  845. }
  846. .p-title {
  847. margin: 0 0 8px;
  848. font-size: 15px;
  849. font-weight: bold;
  850. color: #303133;
  851. }
  852. .p-desc {
  853. margin: 0 0 12px;
  854. color: #606266;
  855. font-size: 13px;
  856. line-height: 1.5;
  857. }
  858. .p-media {
  859. display: flex;
  860. gap: 8px;
  861. flex-wrap: wrap;
  862. }
  863. .p-video {
  864. object-fit: cover;
  865. }
  866. .p-img {
  867. width: 80px;
  868. height: 80px;
  869. border-radius: 4px;
  870. border: 1px solid #e4e7ed;
  871. cursor: pointer;
  872. background: #f5f7fa;
  873. }
  874. .p-video-box {
  875. position: relative;
  876. width: 80px;
  877. height: 80px;
  878. cursor: pointer;
  879. }
  880. .play-icon-overlay {
  881. position: absolute;
  882. top: 50%;
  883. left: 50%;
  884. transform: translate(-50%, -50%);
  885. background: rgba(0, 0, 0, 0.4);
  886. color: #fff;
  887. width: 32px;
  888. height: 32px;
  889. border-radius: 50%;
  890. display: flex;
  891. align-items: center;
  892. justify-content: center;
  893. font-size: 18px;
  894. transition: all 0.2s;
  895. }
  896. .p-video-box:hover .play-icon-overlay {
  897. background: rgba(0, 0, 0, 0.6);
  898. transform: translate(-50%, -50%) scale(1.1);
  899. }
  900. /* New Transport Split Styles */
  901. .transport-split-block {
  902. margin-top: 20px;
  903. }
  904. .transport-grid {
  905. display: flex;
  906. gap: 20px;
  907. }
  908. .transport-card {
  909. flex: 1;
  910. border: 1px solid #ebeef5;
  911. border-radius: 6px;
  912. overflow: hidden;
  913. background: #fff;
  914. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  915. }
  916. .transport-card .t-header {
  917. background: #f5f7fa;
  918. padding: 10px 15px;
  919. border-bottom: 1px solid #ebeef5;
  920. display: flex;
  921. justify-content: space-between;
  922. align-items: center;
  923. }
  924. .transport-card .t-header .time {
  925. font-size: 13px;
  926. font-weight: bold;
  927. color: #f56c6c;
  928. }
  929. .transport-card .t-body {
  930. padding: 15px;
  931. display: flex;
  932. flex-direction: column;
  933. gap: 10px;
  934. }
  935. .transport-card .row {
  936. display: flex;
  937. align-items: flex-start;
  938. gap: 8px;
  939. font-size: 14px;
  940. color: #303133;
  941. line-height: 1.4;
  942. }
  943. .transport-card .row.sub {
  944. color: #909399;
  945. font-size: 13px;
  946. margin-top: 4px;
  947. }
  948. .transport-card .row .el-icon {
  949. margin-top: 3px;
  950. }
  951. .transport-one {
  952. border: 1px solid #ebeef5;
  953. border-radius: 6px;
  954. background: #fff;
  955. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  956. padding: 14px 16px;
  957. display: flex;
  958. flex-direction: column;
  959. gap: 10px;
  960. }
  961. .transport-one .t-row {
  962. display: flex;
  963. align-items: baseline;
  964. gap: 10px;
  965. }
  966. .transport-one .t-row .time {
  967. font-size: 13px;
  968. font-weight: bold;
  969. color: #f56c6c;
  970. }
  971. .transport-one .t-k {
  972. width: 40px;
  973. color: #909399;
  974. font-size: 13px;
  975. }
  976. .transport-one .t-v {
  977. color: #303133;
  978. font-size: 14px;
  979. line-height: 1.4;
  980. }
  981. .transport-one .t-row.sub .t-v {
  982. color: #909399;
  983. font-size: 13px;
  984. }
  985. /* Logs */
  986. .log-card {
  987. background: #f4f4f5;
  988. padding: 10px 15px;
  989. border-radius: 4px;
  990. position: relative;
  991. top: -5px;
  992. width: 100%;
  993. }
  994. .l-tit {
  995. font-weight: bold;
  996. font-size: 14px;
  997. margin-bottom: 4px;
  998. color: #303133;
  999. }
  1000. .l-txt {
  1001. font-size: 13px;
  1002. color: #606266;
  1003. line-height: 1.5;
  1004. }
  1005. </style>