execution.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  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/${this.executionId}`,
  133. method: 'GET',
  134. header: {
  135. 'Authorization': `Bearer ${uni.getStorageSync('token')}`
  136. }
  137. })
  138. if (res.data.code === 200) {
  139. this.execution = res.data.data
  140. } else {
  141. uni.showToast({ title: res.data.message || '加载失败', icon: 'none' })
  142. }
  143. } catch (e) {
  144. console.error('加载执行记录失败', e)
  145. uni.showToast({ title: '网络错误', icon: 'none' })
  146. } finally {
  147. this.loading = false
  148. }
  149. },
  150. async confirmService() {
  151. uni.showModal({
  152. title: '确认服务',
  153. content: '确认服务已完成?确认后可以进行评价。',
  154. success: async (res) => {
  155. if (res.confirm) {
  156. try {
  157. const response = await uni.request({
  158. url: `${config.API_BASE_URL}/api/dan-execution/confirm`,
  159. method: 'POST',
  160. header: {
  161. 'Authorization': `Bearer ${uni.getStorageSync('token')}`,
  162. 'Content-Type': 'application/json'
  163. },
  164. data: { executionId: this.executionId }
  165. })
  166. if (response.data.code === 200) {
  167. uni.showToast({ title: '确认成功', icon: 'success' })
  168. this.loadExecution()
  169. } else {
  170. uni.showToast({ title: response.data.message || '确认失败', icon: 'none' })
  171. }
  172. } catch (e) {
  173. console.error('确认服务失败', e)
  174. uni.showToast({ title: '网络错误', icon: 'none' })
  175. }
  176. }
  177. }
  178. })
  179. },
  180. goToRating() {
  181. uni.navigateTo({
  182. url: `/pages/assessment/rating?executionId=${this.executionId}`
  183. })
  184. },
  185. goBack() {
  186. uni.navigateBack()
  187. },
  188. formatTime(timeStr) {
  189. if (!timeStr) return ''
  190. const date = parseDate(timeStr)
  191. if (!date) return ''
  192. 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')}`
  193. },
  194. getStatusClass(exec) {
  195. if (exec.userConfirmed === 1) return 'completed'
  196. if (exec.assessorStatus === 'completed' && (!exec.plannerId || exec.plannerStatus === 'completed')) return 'ready'
  197. return 'pending'
  198. },
  199. getStatusIcon(exec) {
  200. if (exec.userConfirmed === 1) return '✓'
  201. if (exec.assessorStatus === 'completed' && (!exec.plannerId || exec.plannerStatus === 'completed')) return '!'
  202. return '⋯'
  203. },
  204. getStatusText(exec) {
  205. if (exec.userConfirmed === 1) return '服务已完成'
  206. if (exec.assessorStatus === 'completed' && (!exec.plannerId || exec.plannerStatus === 'completed')) return '待您确认'
  207. if (exec.assessorStatus === 'completed') return '规划师服务中'
  208. return '评估师服务中'
  209. }
  210. }
  211. }
  212. </script>
  213. <style scoped>
  214. .container {
  215. padding: 40rpx;
  216. background: #f5f5f5;
  217. min-height: 100vh;
  218. }
  219. .header {
  220. margin-bottom: 40rpx;
  221. }
  222. .title {
  223. font-size: 40rpx;
  224. font-weight: bold;
  225. color: #333;
  226. display: block;
  227. margin-bottom: 10rpx;
  228. }
  229. .subtitle {
  230. font-size: 28rpx;
  231. color: #999;
  232. }
  233. .loading, .empty {
  234. text-align: center;
  235. padding: 100rpx 0;
  236. color: #999;
  237. }
  238. .status-card {
  239. background: white;
  240. border-radius: 20rpx;
  241. padding: 60rpx 40rpx;
  242. text-align: center;
  243. margin-bottom: 30rpx;
  244. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  245. }
  246. .status-icon {
  247. width: 120rpx;
  248. height: 120rpx;
  249. border-radius: 50%;
  250. display: flex;
  251. align-items: center;
  252. justify-content: center;
  253. margin: 0 auto 30rpx;
  254. position: relative;
  255. }
  256. .icon-circle {
  257. width: 100%;
  258. height: 100%;
  259. border-radius: 50%;
  260. position: absolute;
  261. top: 0;
  262. left: 0;
  263. }
  264. /* CSS 对勾图标 */
  265. .icon-check {
  266. width: 40rpx;
  267. height: 24rpx;
  268. border-left: 6rpx solid #fff;
  269. border-bottom: 6rpx solid #fff;
  270. transform: rotate(-45deg);
  271. margin-top: -6rpx;
  272. z-index: 1;
  273. }
  274. /* CSS 感叹号图标 */
  275. .icon-alert {
  276. width: 6rpx;
  277. height: 36rpx;
  278. background: #fff;
  279. border-radius: 3rpx;
  280. position: relative;
  281. z-index: 1;
  282. }
  283. .icon-alert::after {
  284. content: '';
  285. position: absolute;
  286. bottom: -20rpx;
  287. left: 50%;
  288. transform: translateX(-50%);
  289. width: 10rpx;
  290. height: 10rpx;
  291. background: #fff;
  292. border-radius: 50%;
  293. }
  294. /* CSS 加载中三个点图标 */
  295. .icon-dots {
  296. display: flex;
  297. align-items: center;
  298. justify-content: center;
  299. gap: 10rpx;
  300. z-index: 1;
  301. }
  302. .icon-dots view {
  303. width: 12rpx;
  304. height: 12rpx;
  305. background: #fff;
  306. border-radius: 50%;
  307. }
  308. .status-icon.pending {
  309. background: linear-gradient(135deg, #ffe0b2, #ffcc80);
  310. }
  311. .status-icon.pending .icon-circle {
  312. background: linear-gradient(135deg, #ff9800, #f57c00);
  313. }
  314. .status-icon.ready {
  315. background: linear-gradient(135deg, #bbdefb, #90caf9);
  316. }
  317. .status-icon.ready .icon-circle {
  318. background: linear-gradient(135deg, #2196f3, #1976d2);
  319. }
  320. .status-icon.completed {
  321. background: linear-gradient(135deg, #c8e6c9, #a5d6a7);
  322. }
  323. .status-icon.completed .icon-circle {
  324. background: linear-gradient(135deg, #4caf50, #388e3c);
  325. }
  326. .status-text {
  327. font-size: 36rpx;
  328. font-weight: bold;
  329. color: #333;
  330. }
  331. .timeline {
  332. background: white;
  333. border-radius: 20rpx;
  334. padding: 40rpx;
  335. margin-bottom: 30rpx;
  336. }
  337. .timeline-item {
  338. display: flex;
  339. margin-bottom: 40rpx;
  340. position: relative;
  341. }
  342. .timeline-item:last-child {
  343. margin-bottom: 0;
  344. }
  345. .timeline-item::before {
  346. content: '';
  347. position: absolute;
  348. left: 15rpx;
  349. top: 30rpx;
  350. bottom: -40rpx;
  351. width: 2rpx;
  352. background: #e0e0e0;
  353. }
  354. .timeline-item:last-child::before {
  355. display: none;
  356. }
  357. .timeline-dot {
  358. width: 30rpx;
  359. height: 30rpx;
  360. border-radius: 50%;
  361. background: #e0e0e0;
  362. margin-right: 30rpx;
  363. flex-shrink: 0;
  364. z-index: 1;
  365. display: flex;
  366. align-items: center;
  367. justify-content: center;
  368. }
  369. .dot-check {
  370. width: 12rpx;
  371. height: 8rpx;
  372. border-left: 3rpx solid #fff;
  373. border-bottom: 3rpx solid #fff;
  374. transform: rotate(-45deg);
  375. margin-top: -2rpx;
  376. }
  377. .timeline-item.active .timeline-dot {
  378. background: #4caf50;
  379. }
  380. /* 时间线头部(图标+标题) */
  381. .timeline-header {
  382. display: flex;
  383. align-items: center;
  384. margin-bottom: 10rpx;
  385. }
  386. .timeline-icon {
  387. width: 36rpx;
  388. height: 36rpx;
  389. border-radius: 8rpx;
  390. margin-right: 16rpx;
  391. display: flex;
  392. align-items: center;
  393. justify-content: center;
  394. position: relative;
  395. }
  396. /* 评估师图标 */
  397. .assessor-icon {
  398. background: linear-gradient(135deg, #e3f2fd, #bbdefb);
  399. }
  400. .assessor-icon::after {
  401. content: '';
  402. width: 16rpx;
  403. height: 16rpx;
  404. border: 3rpx solid #2196f3;
  405. border-radius: 50%;
  406. position: absolute;
  407. top: 8rpx;
  408. left: 8rpx;
  409. }
  410. .assessor-icon::before {
  411. content: '';
  412. width: 20rpx;
  413. height: 3rpx;
  414. background: #2196f3;
  415. position: absolute;
  416. bottom: 10rpx;
  417. left: 8rpx;
  418. border-radius: 2rpx;
  419. }
  420. /* 规划师图标 */
  421. .planner-icon {
  422. background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  423. }
  424. .planner-icon::after {
  425. content: '';
  426. width: 16rpx;
  427. height: 16rpx;
  428. border: 3rpx solid #4caf50;
  429. border-radius: 50%;
  430. position: absolute;
  431. top: 8rpx;
  432. left: 8rpx;
  433. }
  434. .planner-icon::before {
  435. content: '';
  436. width: 20rpx;
  437. height: 3rpx;
  438. background: #4caf50;
  439. position: absolute;
  440. bottom: 10rpx;
  441. left: 8rpx;
  442. border-radius: 2rpx;
  443. }
  444. /* 确认图标 */
  445. .confirm-icon {
  446. background: linear-gradient(135deg, #fff3e0, #ffe0b2);
  447. }
  448. .confirm-icon::after {
  449. content: '';
  450. width: 16rpx;
  451. height: 16rpx;
  452. border: 3rpx solid #ff9800;
  453. border-radius: 50%;
  454. position: absolute;
  455. top: 8rpx;
  456. left: 8rpx;
  457. }
  458. .confirm-icon::before {
  459. content: '';
  460. width: 20rpx;
  461. height: 3rpx;
  462. background: #ff9800;
  463. position: absolute;
  464. bottom: 10rpx;
  465. left: 8rpx;
  466. border-radius: 2rpx;
  467. }
  468. .timeline-content {
  469. flex: 1;
  470. }
  471. .timeline-title {
  472. font-size: 32rpx;
  473. font-weight: bold;
  474. color: #333;
  475. display: block;
  476. margin-bottom: 10rpx;
  477. }
  478. .timeline-desc {
  479. font-size: 26rpx;
  480. color: #666;
  481. display: block;
  482. margin-bottom: 5rpx;
  483. }
  484. .timeline-time {
  485. font-size: 24rpx;
  486. color: #999;
  487. }
  488. .notes-section {
  489. background: white;
  490. border-radius: 20rpx;
  491. padding: 40rpx;
  492. margin-bottom: 30rpx;
  493. }
  494. .section-title {
  495. font-size: 32rpx;
  496. font-weight: bold;
  497. color: #333;
  498. display: block;
  499. margin-bottom: 20rpx;
  500. }
  501. .note-item {
  502. margin-bottom: 20rpx;
  503. }
  504. .note-label {
  505. font-size: 28rpx;
  506. color: #666;
  507. font-weight: bold;
  508. }
  509. .note-content {
  510. font-size: 28rpx;
  511. color: #333;
  512. }
  513. .actions {
  514. display: flex;
  515. flex-direction: column;
  516. gap: 20rpx;
  517. }
  518. .btn-primary, .btn-secondary, .btn-outline {
  519. border-radius: 20rpx;
  520. font-size: 32rpx;
  521. padding: 30rpx;
  522. text-align: center;
  523. }
  524. .btn-primary {
  525. background: #1E3A5F;
  526. color: white;
  527. border: none;
  528. }
  529. .btn-secondary {
  530. background: #ff9800;
  531. color: white;
  532. border: none;
  533. }
  534. .btn-outline {
  535. background: white;
  536. color: #666;
  537. border: 2rpx solid #ddd;
  538. }
  539. </style>