execution.vue 14 KB

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