execution.vue 14 KB

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