execution.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <template>
  2. <view class="container">
  3. <!-- 执行状态头部 -->
  4. <view class="header">
  5. <text class="title">服务执行进度</text>
  6. <text class="subtitle">查看测评服务完成情况</text>
  7. </view>
  8. <!-- 加载状态 -->
  9. <view v-if="loading" class="loading">
  10. <text>加载中...</text>
  11. </view>
  12. <!-- 执行记录详情 -->
  13. <view v-else-if="execution" class="execution-detail">
  14. <!-- 状态卡片 -->
  15. <view class="status-card">
  16. <view class="status-icon" :class="getStatusClass(execution)">
  17. <view class="icon-circle"></view>
  18. <view v-if="getStatusClass(execution) === 'completed'" class="icon-check"></view>
  19. <view v-else-if="getStatusClass(execution) === 'ready'" class="icon-alert"></view>
  20. <view v-else class="icon-dots"><view></view><view></view><view></view></view>
  21. </view>
  22. <text class="status-text">{{ getStatusText(execution) }}</text>
  23. </view>
  24. <!-- 进度时间线 -->
  25. <view class="timeline">
  26. <view class="timeline-item" :class="{ active: execution.assessorStatus === 'completed' }">
  27. <view class="timeline-dot"><view v-if="execution.assessorStatus === 'completed'" class="dot-check"></view></view>
  28. <view class="timeline-content">
  29. <view class="timeline-header">
  30. <view class="timeline-icon assessor-icon"></view>
  31. <text class="timeline-title">评估师服务</text>
  32. </view>
  33. <text class="timeline-desc">{{ execution.assessorStatus === 'completed' ? '已完成' : '进行中' }}</text>
  34. <text v-if="execution.assessorCompletedAt" class="timeline-time">
  35. {{ formatTime(execution.assessorCompletedAt) }}
  36. </text>
  37. </view>
  38. </view>
  39. <view v-if="execution.plannerId" class="timeline-item" :class="{ active: execution.plannerStatus === 'completed' }">
  40. <view class="timeline-dot"><view v-if="execution.plannerStatus === 'completed'" class="dot-check"></view></view>
  41. <view class="timeline-content">
  42. <view class="timeline-header">
  43. <view class="timeline-icon planner-icon"></view>
  44. <text class="timeline-title">规划师服务</text>
  45. </view>
  46. <text class="timeline-desc">{{ execution.plannerStatus === 'completed' ? '已完成' : '进行中' }}</text>
  47. <text v-if="execution.plannerCompletedAt" class="timeline-time">
  48. {{ formatTime(execution.plannerCompletedAt) }}
  49. </text>
  50. </view>
  51. </view>
  52. <view class="timeline-item" :class="{ active: execution.userConfirmed === 1 }">
  53. <view class="timeline-dot"><view v-if="execution.userConfirmed === 1" class="dot-check"></view></view>
  54. <view class="timeline-content">
  55. <view class="timeline-header">
  56. <view class="timeline-icon confirm-icon"></view>
  57. <text class="timeline-title">用户确认</text>
  58. </view>
  59. <text class="timeline-desc">{{ execution.userConfirmed === 1 ? '已确认' : '待确认' }}</text>
  60. <text v-if="execution.userConfirmedAt" class="timeline-time">
  61. {{ formatTime(execution.userConfirmedAt) }}
  62. </text>
  63. </view>
  64. </view>
  65. </view>
  66. <!-- 服务备注 -->
  67. <view v-if="execution.assessorNotes || execution.plannerNotes" class="notes-section">
  68. <text class="section-title">服务备注</text>
  69. <view v-if="execution.assessorNotes" class="note-item">
  70. <text class="note-label">评估师:</text>
  71. <text class="note-content">{{ execution.assessorNotes }}</text>
  72. </view>
  73. <view v-if="execution.plannerNotes" class="note-item">
  74. <text class="note-label">规划师:</text>
  75. <text class="note-content">{{ execution.plannerNotes }}</text>
  76. </view>
  77. </view>
  78. <!-- 操作按钮 -->
  79. <view class="actions">
  80. <button v-if="canConfirm" class="btn-primary" @click="confirmService">
  81. 确认服务完成
  82. </button>
  83. <button v-if="canRate" class="btn-secondary" @click="goToRating">
  84. 评价服务
  85. </button>
  86. <button class="btn-outline" @click="goBack">
  87. 返回
  88. </button>
  89. </view>
  90. </view>
  91. <!-- 无数据 -->
  92. <view v-else class="empty">
  93. <text>暂无执行记录</text>
  94. </view>
  95. </view>
  96. </template>
  97. <script>
  98. import config from '@/config.js'
  99. import { parseDate } from '../../utils/format.js'
  100. export default {
  101. data() {
  102. return {
  103. executionId: null,
  104. execution: null,
  105. loading: true
  106. }
  107. },
  108. computed: {
  109. canConfirm() {
  110. if (!this.execution) return false
  111. // 评估师和规划师(如果有)都完成后才能确认
  112. const assessorDone = this.execution.assessorStatus === 'completed'
  113. const plannerDone = !this.execution.plannerId || this.execution.plannerStatus === 'completed'
  114. return assessorDone && plannerDone && this.execution.userConfirmed === 0
  115. },
  116. canRate() {
  117. if (!this.execution) return false
  118. return this.execution.userConfirmed === 1
  119. }
  120. },
  121. onLoad(options) {
  122. if (options.executionId) {
  123. this.executionId = options.executionId
  124. this.loadExecution()
  125. }
  126. },
  127. methods: {
  128. async loadExecution() {
  129. this.loading = true
  130. try {
  131. const res = await uni.request({
  132. url: `${config.API_BASE_URL}/api/dan-execution/detail`,
  133. method: 'POST',
  134. data: { executionId: this.executionId },
  135. header: {
  136. 'Authorization': `Bearer ${uni.getStorageSync('token')}`,
  137. 'Content-Type': 'application/json'
  138. }
  139. })
  140. if (res.data.code === 200) {
  141. this.execution = res.data.data
  142. } else {
  143. uni.showToast({ title: res.data.message || '加载失败', icon: 'none' })
  144. }
  145. } catch (e) {
  146. console.error('加载执行记录失败', e)
  147. uni.showToast({ title: '网络错误', icon: 'none' })
  148. } finally {
  149. this.loading = false
  150. }
  151. },
  152. async confirmService() {
  153. uni.showModal({
  154. title: '确认服务',
  155. content: '确认服务已完成?确认后可以进行评价。',
  156. success: async (res) => {
  157. if (res.confirm) {
  158. try {
  159. const response = await uni.request({
  160. url: `${config.API_BASE_URL}/api/dan-execution/confirm`,
  161. method: 'POST',
  162. header: {
  163. 'Authorization': `Bearer ${uni.getStorageSync('token')}`,
  164. 'Content-Type': 'application/json'
  165. },
  166. data: { executionId: this.executionId }
  167. })
  168. if (response.data.code === 200) {
  169. uni.showToast({ title: '确认成功', icon: 'success' })
  170. this.loadExecution()
  171. } else {
  172. uni.showToast({ title: response.data.message || '确认失败', icon: 'none' })
  173. }
  174. } catch (e) {
  175. console.error('确认服务失败', e)
  176. uni.showToast({ title: '网络错误', icon: 'none' })
  177. }
  178. }
  179. }
  180. })
  181. },
  182. goToRating() {
  183. uni.navigateTo({
  184. url: `/pages/assessment/rating?executionId=${this.executionId}`
  185. })
  186. },
  187. goBack() {
  188. uni.navigateBack()
  189. },
  190. formatTime(timeStr) {
  191. if (!timeStr) return ''
  192. const date = parseDate(timeStr)
  193. if (!date) return ''
  194. return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`
  195. },
  196. getStatusClass(exec) {
  197. if (exec.userConfirmed === 1) return 'completed'
  198. if (exec.assessorStatus === 'completed' && (!exec.plannerId || exec.plannerStatus === 'completed')) return 'ready'
  199. return 'pending'
  200. },
  201. getStatusIcon(exec) {
  202. if (exec.userConfirmed === 1) return '✓'
  203. if (exec.assessorStatus === 'completed' && (!exec.plannerId || exec.plannerStatus === 'completed')) return '!'
  204. return '⋯'
  205. },
  206. getStatusText(exec) {
  207. if (exec.userConfirmed === 1) return '服务已完成'
  208. if (exec.assessorStatus === 'completed' && (!exec.plannerId || exec.plannerStatus === 'completed')) return '待您确认'
  209. if (exec.assessorStatus === 'completed') return '规划师服务中'
  210. return '评估师服务中'
  211. }
  212. }
  213. }
  214. </script>
  215. <style scoped>
  216. .container {
  217. padding: 40rpx;
  218. background: #f5f5f5;
  219. min-height: 100vh;
  220. }
  221. .header {
  222. margin-bottom: 40rpx;
  223. }
  224. .title {
  225. font-size: 40rpx;
  226. font-weight: bold;
  227. color: #333;
  228. display: block;
  229. margin-bottom: 10rpx;
  230. }
  231. .subtitle {
  232. font-size: 28rpx;
  233. color: #999;
  234. }
  235. .loading, .empty {
  236. text-align: center;
  237. padding: 100rpx 0;
  238. color: #999;
  239. }
  240. .status-card {
  241. background: white;
  242. border-radius: 20rpx;
  243. padding: 60rpx 40rpx;
  244. text-align: center;
  245. margin-bottom: 30rpx;
  246. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  247. }
  248. .status-icon {
  249. width: 120rpx;
  250. height: 120rpx;
  251. border-radius: 50%;
  252. display: flex;
  253. align-items: center;
  254. justify-content: center;
  255. margin: 0 auto 30rpx;
  256. position: relative;
  257. }
  258. .icon-circle {
  259. width: 100%;
  260. height: 100%;
  261. border-radius: 50%;
  262. position: absolute;
  263. top: 0;
  264. left: 0;
  265. }
  266. /* CSS 对勾图标 */
  267. .icon-check {
  268. width: 40rpx;
  269. height: 24rpx;
  270. border-left: 6rpx solid #fff;
  271. border-bottom: 6rpx solid #fff;
  272. transform: rotate(-45deg);
  273. margin-top: -6rpx;
  274. z-index: 1;
  275. }
  276. /* CSS 感叹号图标 */
  277. .icon-alert {
  278. width: 6rpx;
  279. height: 36rpx;
  280. background: #fff;
  281. border-radius: 3rpx;
  282. position: relative;
  283. z-index: 1;
  284. }
  285. .icon-alert::after {
  286. content: '';
  287. position: absolute;
  288. bottom: -20rpx;
  289. left: 50%;
  290. transform: translateX(-50%);
  291. width: 10rpx;
  292. height: 10rpx;
  293. background: #fff;
  294. border-radius: 50%;
  295. }
  296. /* CSS 加载中三个点图标 */
  297. .icon-dots {
  298. display: flex;
  299. align-items: center;
  300. justify-content: center;
  301. gap: 10rpx;
  302. z-index: 1;
  303. }
  304. .icon-dots view {
  305. width: 12rpx;
  306. height: 12rpx;
  307. background: #fff;
  308. border-radius: 50%;
  309. }
  310. .status-icon.pending {
  311. background: linear-gradient(135deg, #ffe0b2, #ffcc80);
  312. }
  313. .status-icon.pending .icon-circle {
  314. background: linear-gradient(135deg, #ff9800, #f57c00);
  315. }
  316. .status-icon.ready {
  317. background: linear-gradient(135deg, #bbdefb, #90caf9);
  318. }
  319. .status-icon.ready .icon-circle {
  320. background: linear-gradient(135deg, #2196f3, #1976d2);
  321. }
  322. .status-icon.completed {
  323. background: linear-gradient(135deg, #c8e6c9, #a5d6a7);
  324. }
  325. .status-icon.completed .icon-circle {
  326. background: linear-gradient(135deg, #4caf50, #388e3c);
  327. }
  328. .status-text {
  329. font-size: 36rpx;
  330. font-weight: bold;
  331. color: #333;
  332. }
  333. .timeline {
  334. background: white;
  335. border-radius: 20rpx;
  336. padding: 40rpx;
  337. margin-bottom: 30rpx;
  338. }
  339. .timeline-item {
  340. display: flex;
  341. margin-bottom: 40rpx;
  342. position: relative;
  343. }
  344. .timeline-item:last-child {
  345. margin-bottom: 0;
  346. }
  347. .timeline-item::before {
  348. content: '';
  349. position: absolute;
  350. left: 15rpx;
  351. top: 30rpx;
  352. bottom: -40rpx;
  353. width: 2rpx;
  354. background: #e0e0e0;
  355. }
  356. .timeline-item:last-child::before {
  357. display: none;
  358. }
  359. .timeline-dot {
  360. width: 30rpx;
  361. height: 30rpx;
  362. border-radius: 50%;
  363. background: #e0e0e0;
  364. margin-right: 30rpx;
  365. flex-shrink: 0;
  366. z-index: 1;
  367. display: flex;
  368. align-items: center;
  369. justify-content: center;
  370. }
  371. .dot-check {
  372. width: 12rpx;
  373. height: 8rpx;
  374. border-left: 3rpx solid #fff;
  375. border-bottom: 3rpx solid #fff;
  376. transform: rotate(-45deg);
  377. margin-top: -2rpx;
  378. }
  379. .timeline-item.active .timeline-dot {
  380. background: #4caf50;
  381. }
  382. /* 时间线头部(图标+标题) */
  383. .timeline-header {
  384. display: flex;
  385. align-items: center;
  386. margin-bottom: 10rpx;
  387. }
  388. .timeline-icon {
  389. width: 36rpx;
  390. height: 36rpx;
  391. border-radius: 8rpx;
  392. margin-right: 16rpx;
  393. display: flex;
  394. align-items: center;
  395. justify-content: center;
  396. position: relative;
  397. }
  398. /* 评估师图标 */
  399. .assessor-icon {
  400. background: linear-gradient(135deg, #e3f2fd, #bbdefb);
  401. }
  402. .assessor-icon::after {
  403. content: '';
  404. width: 16rpx;
  405. height: 16rpx;
  406. border: 3rpx solid #2196f3;
  407. border-radius: 50%;
  408. position: absolute;
  409. top: 8rpx;
  410. left: 8rpx;
  411. }
  412. .assessor-icon::before {
  413. content: '';
  414. width: 20rpx;
  415. height: 3rpx;
  416. background: #2196f3;
  417. position: absolute;
  418. bottom: 10rpx;
  419. left: 8rpx;
  420. border-radius: 2rpx;
  421. }
  422. /* 规划师图标 */
  423. .planner-icon {
  424. background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  425. }
  426. .planner-icon::after {
  427. content: '';
  428. width: 16rpx;
  429. height: 16rpx;
  430. border: 3rpx solid #4caf50;
  431. border-radius: 50%;
  432. position: absolute;
  433. top: 8rpx;
  434. left: 8rpx;
  435. }
  436. .planner-icon::before {
  437. content: '';
  438. width: 20rpx;
  439. height: 3rpx;
  440. background: #4caf50;
  441. position: absolute;
  442. bottom: 10rpx;
  443. left: 8rpx;
  444. border-radius: 2rpx;
  445. }
  446. /* 确认图标 */
  447. .confirm-icon {
  448. background: linear-gradient(135deg, #fff3e0, #ffe0b2);
  449. }
  450. .confirm-icon::after {
  451. content: '';
  452. width: 16rpx;
  453. height: 16rpx;
  454. border: 3rpx solid #ff9800;
  455. border-radius: 50%;
  456. position: absolute;
  457. top: 8rpx;
  458. left: 8rpx;
  459. }
  460. .confirm-icon::before {
  461. content: '';
  462. width: 20rpx;
  463. height: 3rpx;
  464. background: #ff9800;
  465. position: absolute;
  466. bottom: 10rpx;
  467. left: 8rpx;
  468. border-radius: 2rpx;
  469. }
  470. .timeline-content {
  471. flex: 1;
  472. }
  473. .timeline-title {
  474. font-size: 32rpx;
  475. font-weight: bold;
  476. color: #333;
  477. display: block;
  478. margin-bottom: 10rpx;
  479. }
  480. .timeline-desc {
  481. font-size: 26rpx;
  482. color: #666;
  483. display: block;
  484. margin-bottom: 5rpx;
  485. }
  486. .timeline-time {
  487. font-size: 24rpx;
  488. color: #999;
  489. }
  490. .notes-section {
  491. background: white;
  492. border-radius: 20rpx;
  493. padding: 40rpx;
  494. margin-bottom: 30rpx;
  495. }
  496. .section-title {
  497. font-size: 32rpx;
  498. font-weight: bold;
  499. color: #333;
  500. display: block;
  501. margin-bottom: 20rpx;
  502. }
  503. .note-item {
  504. margin-bottom: 20rpx;
  505. }
  506. .note-label {
  507. font-size: 28rpx;
  508. color: #666;
  509. font-weight: bold;
  510. }
  511. .note-content {
  512. font-size: 28rpx;
  513. color: #333;
  514. }
  515. .actions {
  516. display: flex;
  517. flex-direction: column;
  518. gap: 20rpx;
  519. }
  520. .btn-primary, .btn-secondary, .btn-outline {
  521. border-radius: 20rpx;
  522. font-size: 32rpx;
  523. padding: 30rpx;
  524. text-align: center;
  525. }
  526. .btn-primary {
  527. background: #1E3A5F;
  528. color: white;
  529. border: none;
  530. }
  531. .btn-secondary {
  532. background: #ff9800;
  533. color: white;
  534. border: none;
  535. }
  536. .btn-outline {
  537. background: white;
  538. color: #666;
  539. border: 2rpx solid #ddd;
  540. }
  541. </style>