completeTask.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <view class="container">
  3. <Watermark />
  4. <Step :step="currentStep" :stepsData="currentText" />
  5. <scroll-view class="content" scroll-y>
  6. <!-- 任务信息 -->
  7. <view class="task-info-section">
  8. <view class="section-title">任务信息</view>
  9. <view class="info-item">
  10. <view class="info-label">任务名称:</view>
  11. <view class="info-value">{{ taskInfo.taskName || '-' }}</view>
  12. </view>
  13. <view class="info-item">
  14. <view class="info-label">任务类型:</view>
  15. <view class="info-value">{{ taskInfo.taskType || '-' }}</view>
  16. </view>
  17. <view class="info-item">
  18. <view class="info-label">任务描述:</view>
  19. <view class="info-value">{{ taskInfo.taskDesc || '-' }}</view>
  20. </view>
  21. </view>
  22. <!-- 完成情况 -->
  23. <view class="complete-section">
  24. <view class="section-title">完成情况</view>
  25. <view class="complete-item">
  26. <view class="complete-label">已完成客户:</view>
  27. <view class="complete-value">{{ completedCustomers.length }} / {{ totalCustomers }}</view>
  28. </view>
  29. <view class="progress-bar">
  30. <view class="progress-fill" :style="{ width: progressPercentage + '%' }"></view>
  31. </view>
  32. </view>
  33. <!-- 客户列表 -->
  34. <view class="customer-list">
  35. <view class="customer-item" v-for="(customer, index) in customerList" :key="customer.id">
  36. <view class="left">
  37. <image class="head" src="https://ysrw-1395926010.cos.ap-chengdu.myqcloud.com/image/my_heads_icon.png"></image>
  38. <view class="customer-info">
  39. <view class="customer-header">
  40. <view class="customer-name">{{ customer.doctorName ||'-'}}</view>
  41. <view class="customer-status" :class="customer.status === 'completed' ? 'completed' : 'pending'">
  42. {{ customer.status === 'completed' ? '已完成' : '待完成' }}
  43. </view>
  44. </view>
  45. <view class="customer-details">
  46. <view class="customer-hospital">{{ customer.cityName||'-' }}</view>
  47. <view class="customer-department">{{ customer.department ||'-'}}</view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="action-btn" v-if="customer.status === 'pending'" @click="completeCustomer(customer)">
  52. 完成
  53. </view>
  54. </view>
  55. </view>
  56. </scroll-view>
  57. <!-- 底部操作栏 -->
  58. <view class="bottom-bar">
  59. <view class="action-buttons">
  60. <view class="btn btn-cancel" @click="handlePrev">上一步</view>
  61. <view class="btn btn-submit" @click="handleNext" :disabled="completedCustomers.length === 0">提交</view>
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import Step from '@/pages_task/components/step.vue'
  68. export default {
  69. components: {
  70. Step
  71. },
  72. data() {
  73. return {
  74. currentText: [{
  75. id: 1,
  76. stepNumber: 1,
  77. title: '任务详情'
  78. },
  79. {
  80. id: 2,
  81. stepNumber: 2,
  82. title: '完成任务'
  83. },
  84. {
  85. id: 3,
  86. stepNumber: 3,
  87. title: '提交成功'
  88. }
  89. ],
  90. currentStep: 2,
  91. taskInfo: {},
  92. customerList: [],
  93. completedCustomers: []
  94. }
  95. },
  96. onLoad() {
  97. this.loadTaskData()
  98. this.loadCustomerData()
  99. },
  100. computed: {
  101. totalCustomers() {
  102. return this.customerList.length
  103. },
  104. progressPercentage() {
  105. if (this.totalCustomers === 0) return 0
  106. return Math.round((this.completedCustomers.length / this.totalCustomers) * 100)
  107. }
  108. },
  109. methods: {
  110. loadTaskData() {
  111. // 从本地存储获取任务信息
  112. const taskInfo = uni.getStorageSync('taskInfo')
  113. if (taskInfo) {
  114. this.taskInfo = JSON.parse(taskInfo)
  115. }
  116. },
  117. loadCustomerData() {
  118. // 从本地存储获取客户列表
  119. const selectedCustomers = uni.getStorageSync('selectedCustomers')
  120. if (selectedCustomers) {
  121. this.customerList = JSON.parse(selectedCustomers).map(customer => ({
  122. ...customer,
  123. status: 'pending'
  124. }))
  125. }
  126. },
  127. completeCustomer(customer) {
  128. // 标记客户为已完成
  129. const index = this.customerList.findIndex(item => item.id === customer.id)
  130. if (index > -1) {
  131. this.customerList[index].status = 'completed'
  132. // 更新已完成客户列表
  133. this.completedCustomers = this.customerList.filter(item => item.status === 'completed')
  134. }
  135. },
  136. handlePrev() {
  137. uni.navigateBack()
  138. },
  139. handleNext() {
  140. if (this.completedCustomers.length === 0) {
  141. uni.showToast({
  142. icon: 'none',
  143. title: '请至少完成一个客户的任务'
  144. })
  145. return
  146. }
  147. // 保存完成情况到本地存储
  148. uni.setStorageSync('completedCustomers', JSON.stringify(this.completedCustomers))
  149. // 跳转到提交成功页面
  150. uni.navigateTo({
  151. url: '/pages_task/taskCompleteSuccess'
  152. })
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .container {
  159. min-height: 100vh;
  160. background: #F7F8FA;
  161. display: flex;
  162. flex-direction: column;
  163. &::before {
  164. content: '';
  165. position: absolute;
  166. top: 0;
  167. left: 0;
  168. right: 0;
  169. width: 100%;
  170. height: 544rpx;
  171. background: linear-gradient(180deg, #E4EFFE 0%, rgba(228, 239, 254, 0) 100%);
  172. }
  173. }
  174. .content {
  175. flex: 1;
  176. padding: 24rpx;
  177. box-sizing: border-box;
  178. padding-bottom: 200rpx;
  179. }
  180. .task-info-section,
  181. .complete-section {
  182. background-color: #ffffff;
  183. border-radius: 24rpx 24rpx 24rpx 24rpx;
  184. padding: 24rpx;
  185. margin-bottom: 24rpx;
  186. .section-title {
  187. font-size: 32rpx;
  188. font-weight: 500;
  189. color: #333333;
  190. margin-bottom: 24rpx;
  191. }
  192. .info-item {
  193. display: flex;
  194. margin-bottom: 16rpx;
  195. .info-label {
  196. font-size: 28rpx;
  197. color: #666666;
  198. width: 120rpx;
  199. }
  200. .info-value {
  201. font-size: 28rpx;
  202. color: #333333;
  203. flex: 1;
  204. }
  205. }
  206. .complete-item {
  207. display: flex;
  208. justify-content: space-between;
  209. align-items: center;
  210. margin-bottom: 24rpx;
  211. .complete-label {
  212. font-size: 28rpx;
  213. color: #666666;
  214. }
  215. .complete-value {
  216. font-size: 28rpx;
  217. font-weight: 500;
  218. color: #388BFF;
  219. }
  220. }
  221. .progress-bar {
  222. width: 100%;
  223. height: 12rpx;
  224. background-color: #F2F3F5;
  225. border-radius: 6rpx;
  226. overflow: hidden;
  227. .progress-fill {
  228. height: 100%;
  229. background-color: #388BFF;
  230. transition: width 0.3s ease;
  231. }
  232. }
  233. }
  234. .customer-list {
  235. .customer-item {
  236. border-radius: 24rpx 24rpx 24rpx 24rpx;
  237. display: flex;
  238. align-items: center;
  239. justify-content: space-between;
  240. padding: 32rpx;
  241. margin-bottom: 12rpx;
  242. background-color: #ffffff;
  243. &:last-child {
  244. margin-bottom: 0;
  245. }
  246. .left {
  247. display: flex;
  248. align-items: center;
  249. flex: 1;
  250. .head {
  251. width: 88rpx;
  252. height: 88rpx;
  253. border-radius: 50%;
  254. margin-right: 24rpx;
  255. }
  256. .customer-info {
  257. flex: 1;
  258. .customer-header {
  259. display: flex;
  260. align-items: center;
  261. margin-bottom: 12rpx;
  262. .customer-name {
  263. font-weight: 500;
  264. font-size: 32rpx;
  265. color: #333333;
  266. margin-right: 16rpx;
  267. }
  268. .customer-status {
  269. font-size: 24rpx;
  270. border-radius: 8rpx;
  271. padding: 4rpx 12rpx;
  272. &.completed {
  273. background: #E6F7EF;
  274. color: #00B42A;
  275. }
  276. &.pending {
  277. background: #FFF6E5;
  278. color: #C89743;
  279. }
  280. }
  281. }
  282. .customer-details {
  283. display: flex;
  284. align-items: center;
  285. .customer-hospital {
  286. font-size: 28rpx;
  287. color: #666;
  288. margin-right: 24rpx;
  289. border-right: 2rpx solid #EAEBEE;
  290. padding-right: 24rpx;
  291. }
  292. .customer-department {
  293. font-size: 28rpx;
  294. color: #666;
  295. }
  296. }
  297. }
  298. }
  299. .action-btn {
  300. background-color: #388BFF;
  301. color: #ffffff;
  302. padding: 12rpx 24rpx;
  303. border-radius: 100rpx;
  304. font-size: 28rpx;
  305. cursor: pointer;
  306. }
  307. }
  308. }
  309. .bottom-bar {
  310. position: fixed;
  311. bottom: 0;
  312. left: 0;
  313. right: 0;
  314. background: #fff;
  315. padding: 24rpx 32rpx;
  316. border-top: 1rpx solid #F2F3F5;
  317. z-index: 100;
  318. .action-buttons {
  319. display: flex;
  320. justify-content: space-between;
  321. .btn {
  322. width: 292rpx;
  323. height: 88rpx;
  324. display: flex;
  325. align-items: center;
  326. justify-content: center;
  327. font-size: 32rpx;
  328. font-weight: 500;
  329. border-radius: 200rpx 200rpx 200rpx 200rpx;
  330. cursor: pointer;
  331. &.btn-cancel {
  332. background: #fff;
  333. border: 2rpx solid #388BFF;
  334. color: #388BFF;
  335. }
  336. &.btn-submit {
  337. background: #388BFF;
  338. color: #fff;
  339. &:disabled {
  340. background: #C8C9CC;
  341. cursor: not-allowed;
  342. }
  343. }
  344. }
  345. }
  346. }
  347. </style>