service-tasks.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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="tasks.length > 0" class="task-list">
  14. <view
  15. v-for="task in tasks"
  16. :key="task.id"
  17. class="task-card"
  18. @click="viewTaskDetail(task)">
  19. <view class="task-header">
  20. <view class="task-title-row">
  21. <view class="task-icon" :class="task.plannerStatus === 'completed' ? 'completed' : (task.assessorStatus === 'completed' ? 'ready' : 'pending')">
  22. <view v-if="getStatusClass(task) === 'completed'" class="icon-check"></view>
  23. <view v-else-if="getStatusClass(task) === 'ready'" class="icon-alert"></view>
  24. <view v-else class="icon-clock"></view>
  25. </view>
  26. <text class="task-title">服务执行 #{{ task.id }}</text>
  27. </view>
  28. <text class="task-status" :class="task.plannerStatus === 'completed' ? 'completed' : (task.assessorStatus === 'completed' ? 'ready' : 'pending')">
  29. {{ getStatusText(task) }}
  30. </text>
  31. </view>
  32. <view class="task-info">
  33. <view class="info-row">
  34. <view class="info-icon order-icon"></view>
  35. <text class="info-label">订单号</text>
  36. <text class="info-value">{{ task.assessmentOrderId }}</text>
  37. </view>
  38. <view class="info-row">
  39. <view class="info-icon time-icon"></view>
  40. <text class="info-label">创建时间</text>
  41. <text class="info-value">{{ formatTime(task.createdAt) }}</text>
  42. </view>
  43. <view class="info-row">
  44. <view class="info-icon assessor-info-icon"></view>
  45. <text class="info-label">评估师</text>
  46. <text class="info-value">{{ task.assessorStatus === 'completed' ? '已完成' : '进行中' }}</text>
  47. </view>
  48. <view v-if="task.plannerId" class="info-row">
  49. <view class="info-icon planner-info-icon"></view>
  50. <text class="info-label">您的状态</text>
  51. <text class="info-value">{{ task.plannerStatus === 'completed' ? '已完成' : '待处理' }}</text>
  52. </view>
  53. </view>
  54. <view v-if="task.plannerStatus !== 'completed'" class="task-action">
  55. <button class="btn-complete" @click.stop="completeTask(task)">
  56. 标记完成
  57. </button>
  58. </view>
  59. </view>
  60. </view>
  61. <!-- 无任务 -->
  62. <view v-else class="empty">
  63. <text>暂无待办任务</text>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import config from '@/config.js'
  69. import { parseDate } from '../../utils/format.js'
  70. import fontScaleMixin from '@/mixins/font-scale.js'
  71. export default {
  72. mixins: [fontScaleMixin],
  73. data() {
  74. return {
  75. tasks: [],
  76. loading: true
  77. }
  78. },
  79. onLoad() {
  80. this.loadTasks()
  81. this._onLoadFired = true
  82. },
  83. onShow() {
  84. if (this._onLoadFired) {
  85. this._onLoadFired = false
  86. } else {
  87. this.loadTasks()
  88. }
  89. },
  90. methods: {
  91. async loadTasks() {
  92. this.loading = true
  93. try {
  94. // 获取当前用户的 plannerId(这里假设当前用户就是规划师)
  95. const userInfo = uni.getStorageSync('userInfo')
  96. const plannerId = userInfo && userInfo.id
  97. if (!plannerId) {
  98. uni.showToast({ title: '未登录', icon: 'none' })
  99. return
  100. }
  101. const res = await uni.request({
  102. url: `${config.API_BASE_URL}/api/dan-execution/guide/my-tasks`,
  103. method: 'POST',
  104. data: { plannerId: plannerId },
  105. header: {
  106. 'Authorization': `Bearer ${uni.getStorageSync('token')}`,
  107. 'Content-Type': 'application/json'
  108. }
  109. })
  110. if (res.data.code === 200) {
  111. this.tasks = res.data.data || []
  112. } else {
  113. uni.showToast({ title: res.data.message || '加载失败', icon: 'none' })
  114. }
  115. } catch (e) {
  116. console.error('加载任务列表失败', e)
  117. uni.showToast({ title: '网络错误', icon: 'none' })
  118. } finally {
  119. this.loading = false
  120. }
  121. },
  122. viewTaskDetail(task) {
  123. uni.navigateTo({
  124. url: `/pages/assessment/execution?executionId=${task.id}`
  125. })
  126. },
  127. completeTask(task) {
  128. uni.showModal({
  129. title: '标记完成',
  130. content: '确认标记此服务为已完成?',
  131. editable: true,
  132. placeholderText: '请填写服务备注(选填)',
  133. success: async (res) => {
  134. if (res.confirm) {
  135. try {
  136. const response = await uni.request({
  137. url: `${config.API_BASE_URL}/api/dan-execution/complete`,
  138. method: 'POST',
  139. header: {
  140. 'Authorization': `Bearer ${uni.getStorageSync('token')}`,
  141. 'Content-Type': 'application/json'
  142. },
  143. data: {
  144. executionId: task.id,
  145. notes: res.content || ''
  146. }
  147. })
  148. if (response.data.code === 200) {
  149. uni.showToast({ title: '标记成功', icon: 'success' })
  150. this.loadTasks()
  151. } else {
  152. uni.showToast({ title: response.data.message || '操作失败', icon: 'none' })
  153. }
  154. } catch (e) {
  155. console.error('标记完成失败', e)
  156. uni.showToast({ title: '网络错误', icon: 'none' })
  157. }
  158. }
  159. }
  160. })
  161. },
  162. formatTime(timeStr) {
  163. if (!timeStr) return ''
  164. const date = parseDate(timeStr)
  165. if (!date) return ''
  166. 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')}`
  167. },
  168. getStatusClass(task) {
  169. if (task.plannerStatus === 'completed') return 'completed'
  170. if (task.assessorStatus === 'completed') return 'ready'
  171. return 'pending'
  172. },
  173. getStatusText(task) {
  174. if (task.plannerStatus === 'completed') return '已完成'
  175. if (task.assessorStatus === 'completed') return '待您处理'
  176. return '进行中'
  177. }
  178. }
  179. }
  180. </script>
  181. <style scoped lang="scss">
  182. .container {
  183. padding: 40rpx;
  184. background: $facade-fill-2;
  185. min-height: 100vh;
  186. }
  187. .header {
  188. margin-bottom: 40rpx;
  189. }
  190. .title {
  191. font-size: calc(40rpx * var(--font-scale, 1));
  192. font-weight: bold;
  193. color: $facade-text-strong;
  194. display: block;
  195. margin-bottom: 10rpx;
  196. }
  197. .subtitle {
  198. font-size: calc(28rpx * var(--font-scale, 1));
  199. color: $facade-text-muted;
  200. }
  201. .loading, .empty {
  202. text-align: center;
  203. padding: 100rpx 0;
  204. color: $facade-text-muted;
  205. }
  206. .task-list {
  207. display: flex;
  208. flex-direction: column;
  209. gap: $uni-space-lg;
  210. }
  211. .task-card {
  212. background: white;
  213. border-radius: 24rpx;
  214. padding: 40rpx;
  215. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  216. }
  217. .task-header {
  218. display: flex;
  219. justify-content: space-between;
  220. align-items: center;
  221. margin-bottom: $uni-space-lg;
  222. }
  223. .task-title-row {
  224. display: flex;
  225. align-items: center;
  226. }
  227. .task-icon {
  228. width: 40rpx;
  229. height: 40rpx;
  230. border-radius: 50%;
  231. margin-right: 16rpx;
  232. display: flex;
  233. align-items: center;
  234. justify-content: center;
  235. position: relative;
  236. }
  237. .task-icon.completed {
  238. background: linear-gradient(135deg, $mat-green, $mat-green-700);
  239. }
  240. .task-icon.ready {
  241. background: linear-gradient(135deg, $mat-blue-base, $mat-blue);
  242. }
  243. .task-icon.pending {
  244. background: linear-gradient(135deg, $mat-orange-base, $mat-orange-700);
  245. }
  246. /* 对勾 */
  247. .task-icon .icon-check {
  248. width: 16rpx;
  249. height: 10rpx;
  250. border-left: 4rpx solid $app-surface;
  251. border-bottom: 4rpx solid $app-surface;
  252. transform: rotate(-45deg);
  253. margin-top: -2rpx;
  254. }
  255. /* 感叹号 */
  256. .task-icon .icon-alert {
  257. width: 4rpx;
  258. height: 16rpx;
  259. background: $app-surface;
  260. border-radius: 8rpx;
  261. }
  262. /* 时钟 */
  263. .task-icon .icon-clock {
  264. width: 18rpx;
  265. height: 18rpx;
  266. border: 3rpx solid $app-surface;
  267. border-radius: 50%;
  268. position: relative;
  269. }
  270. .task-icon .icon-clock::before {
  271. content: '';
  272. position: absolute;
  273. width: 3rpx;
  274. height: 8rpx;
  275. background: $app-surface;
  276. top: 2rpx;
  277. left: 50%;
  278. transform: translateX(-50%);
  279. }
  280. .task-icon .icon-clock::after {
  281. content: '';
  282. position: absolute;
  283. width: 6rpx;
  284. height: 3rpx;
  285. background: $app-surface;
  286. top: 50%;
  287. left: 50%;
  288. transform: translateY(-50%);
  289. }
  290. .task-title {
  291. font-size: calc(32rpx * var(--font-scale, 1));
  292. font-weight: bold;
  293. color: $facade-text-strong;
  294. }
  295. .task-status {
  296. font-size: calc(24rpx * var(--font-scale, 1));
  297. padding: 10rpx 20rpx;
  298. border-radius: 24rpx;
  299. }
  300. .task-status.pending {
  301. background: $fortune-1-tint;
  302. color: $mat-orange-base;
  303. }
  304. .task-status.ready {
  305. background: $mat-blue-tint;
  306. color: $mat-blue-base;
  307. }
  308. .task-status.completed {
  309. background: $mat-green-tint;
  310. color: $mat-green;
  311. }
  312. .task-info {
  313. margin-bottom: 20rpx;
  314. }
  315. .info-row {
  316. display: flex;
  317. align-items: center;
  318. margin-bottom: 18rpx;
  319. }
  320. .info-icon {
  321. width: 28rpx;
  322. height: 28rpx;
  323. border-radius: 8rpx;
  324. margin-right: 12rpx;
  325. flex-shrink: 0;
  326. position: relative;
  327. display: flex;
  328. align-items: center;
  329. justify-content: center;
  330. }
  331. /* 订单图标 */
  332. .order-icon {
  333. background: $mat-blue-tint;
  334. }
  335. .order-icon::after {
  336. content: '';
  337. width: 12rpx;
  338. height: 14rpx;
  339. border: 2rpx solid $mat-blue-base;
  340. border-radius: 8rpx;
  341. }
  342. /* 时间图标 */
  343. .time-icon {
  344. background: $fortune-1-tint;
  345. }
  346. .time-icon::after {
  347. content: '';
  348. width: 12rpx;
  349. height: 12rpx;
  350. border: 2rpx solid $mat-orange-base;
  351. border-radius: 50%;
  352. }
  353. /* 评估师图标 */
  354. .assessor-info-icon {
  355. background: $mat-green-tint;
  356. }
  357. .assessor-info-icon::after {
  358. content: '';
  359. width: 8rpx;
  360. height: 8rpx;
  361. background: $mat-green;
  362. border-radius: 50%;
  363. }
  364. /* 规划师图标 */
  365. .planner-info-icon {
  366. background: $accent-pink-tint-2;
  367. }
  368. .planner-info-icon::after {
  369. content: '';
  370. width: 8rpx;
  371. height: 8rpx;
  372. background: #e91e63;
  373. border-radius: 50%;
  374. }
  375. .info-label {
  376. font-size: calc(26rpx * var(--font-scale, 1));
  377. color: $facade-text-body;
  378. width: 140rpx;
  379. }
  380. .info-value {
  381. font-size: calc(26rpx * var(--font-scale, 1));
  382. color: $facade-text-strong;
  383. flex: 1;
  384. }
  385. .task-action {
  386. margin-top: 20rpx;
  387. }
  388. .btn-complete {
  389. background: linear-gradient(135deg, $mat-green, $mat-green-700);
  390. color: white;
  391. border: none;
  392. border-radius: 16rpx;
  393. font-size: calc(28rpx * var(--font-scale, 1));
  394. padding: 24rpx;
  395. width: 100%;
  396. box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.3);
  397. }
  398. </style>