execution.vue 15 KB

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