service-tasks.vue 9.8 KB

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