service-tasks.vue 9.7 KB

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