service-tasks.vue 9.6 KB

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