Ei kuvausta

index.vue 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. <script setup lang="ts">
  2. import dayjs from 'dayjs'
  3. import { keyBy } from 'lodash-es'
  4. import { ref } from 'vue'
  5. import { useRoute, useRouter } from 'vue-router'
  6. import { useMessage, useToast } from 'wot-design-uni'
  7. import { confirmDoneTask, getTaskDetail } from '@/api/schedule/task'
  8. import { authStatusOptions, taskLevelOptions, taskStatusOptions } from '@/utils/dicts'
  9. const message = useMessage()
  10. const toast = useToast()
  11. // 定义页面配置,注册路由
  12. definePage({
  13. excludeLoginPath: true,
  14. })
  15. // 状态管理
  16. const isExpanded = ref(false)
  17. const router = useRouter()
  18. const route = useRoute()
  19. const taskId = ref(Number(route.query.id))
  20. const taskInfo: any = ref({})
  21. const taskOther: any = ref({})
  22. const taskResult: any = ref({})
  23. // 切换更多内容显示/隐藏
  24. function toggleMore() {
  25. isExpanded.value = !isExpanded.value
  26. }
  27. async function dealConfirmTaskEvent() {
  28. // 二次弹框确认
  29. message.confirm({
  30. msg: `确认完成任务 ${taskInfo.value.taskName} 吗?`,
  31. title: '确认完成',
  32. }).then(async () => {
  33. try {
  34. await confirmDoneTask(taskInfo.value.id || 0)
  35. toast.success('确认完成任务成功')
  36. await init()
  37. }
  38. catch {
  39. toast.error('操作失败')
  40. }
  41. }).catch(() => {
  42. return
  43. })
  44. }
  45. // 查看详情按钮点击事件
  46. async function dealTaskEvent() {
  47. // 根据任务类型进行判断
  48. let params: any = {}
  49. let isModelPage = false
  50. switch (taskInfo.value.formType) {
  51. case 'inspection': {
  52. uni.navigateTo({
  53. url: `/pages/schedule/details/deal/inspection?id=${taskId.value}&checkId=${taskInfo.value.taskList[0].id}`,
  54. })
  55. return
  56. }
  57. case 'confirm': {
  58. await dealConfirmTaskEvent()
  59. return
  60. }
  61. case 'form': {
  62. if (
  63. ['annualExamination_task', 'replacement_task'].includes(
  64. taskInfo.value.subFormType,
  65. )
  66. ) {
  67. try {
  68. // await dealAnnualExaminationTask()
  69. }
  70. catch {
  71. // ElMessage.error('处理任务失败')
  72. }
  73. return
  74. }
  75. params = {
  76. taskId: taskInfo.value.taskList?.[0]?.id || '',
  77. taskName: taskInfo.value.taskName,
  78. taskList: taskInfo.value.taskList || [],
  79. remark: taskResult.value.content,
  80. stationId: taskInfo.value.stationId || 0,
  81. subFormType: taskInfo.value.subFormType,
  82. attachmentUrl: taskResult.value.images,
  83. }
  84. if (
  85. [
  86. 'ambulance_check',
  87. 'emergency_protection_monthly_check',
  88. 'filter_maintenance',
  89. 'fire_extinguisher_check',
  90. ].includes(taskInfo.value.subFormType)
  91. ) {
  92. isModelPage = true
  93. }
  94. break
  95. }
  96. case 'upload': {
  97. uni.navigateTo({
  98. url: `/pages/schedule/details/deal/upload?id=${taskId.value}`,
  99. })
  100. return
  101. }
  102. default: {
  103. // return ElMessage.error('当前任务无法处理')
  104. }
  105. }
  106. // if (isModelPage) {
  107. // pageModalApi.open()
  108. // }
  109. // else {
  110. // dealDrawerApi.setData(params).open()
  111. // }
  112. }
  113. // 查看详情按钮点击事件2
  114. function viewDetails2() {
  115. uni.navigateTo({
  116. url: '/pages/schedule/details/taskmanagement/index2',
  117. })
  118. }
  119. function viewDetails3() {
  120. uni.navigateTo({
  121. url: '/pages/schedule/details/taskdetails/index',
  122. })
  123. }
  124. /**
  125. * 获取任务时间
  126. * @returns 任务时间字符串
  127. */
  128. function getTaskTime() {
  129. return `${dayjs(taskInfo.value.startTime).format('MM-DD HH:mm')}~${dayjs(taskInfo.value.endTime).format('MM-DD HH:mm')}`
  130. }
  131. /**
  132. * 下载文件
  133. * @param file 文件对象或链接
  134. * @param fileName 文件名
  135. */
  136. function downloadFile(file: any, fileName: string) {
  137. // 这里实现文件下载逻辑
  138. console.log('downloadFile:', file, fileName)
  139. }
  140. async function init() {
  141. const res: any = await getTaskDetail(taskId.value)
  142. taskInfo.value = res.data || {}
  143. if (!taskInfo.value.status) {
  144. taskInfo.value.status = 0
  145. }
  146. // 假设从接口返回数据中获取taskOther和taskResult
  147. taskOther.value.taskTypeName = taskInfo.value?.formTypeName || '-'
  148. if (!taskInfo.value.executorName && taskInfo.value.taskList?.length) {
  149. taskInfo.value.executorName = taskInfo.value.taskList[0].executorName
  150. }
  151. if (taskInfo.value.formType === 'photo') {
  152. const result = taskInfo.value?.taskList?.[0] || {}
  153. if (result.remark) {
  154. taskResult.value.content = result.remark
  155. }
  156. if (result?.attachmentUrl?.length) {
  157. taskResult.value.images = result.attachmentUrl
  158. }
  159. }
  160. else if (taskInfo.value.formType === 'upload') {
  161. // attachmentUrl
  162. const result = taskInfo.value?.taskList?.[0] || {}
  163. if (result.remark) {
  164. taskResult.value.content = result.remark
  165. }
  166. if (result?.attachmentUrl?.length) {
  167. taskResult.value.files = result.attachmentUrl
  168. taskResult.value.fileNames = result.attachmentName.split(',')
  169. }
  170. }
  171. else {
  172. // taskResult.value = taskInfo.value?.taskList?.[0] || {};
  173. }
  174. if (taskInfo.value?.taskTemplate) {
  175. taskOther.value.taskFrequencyName
  176. = taskInfo.value?.taskTemplate?.taskFrequencyName || '-'
  177. }
  178. }
  179. // 状态标签配置
  180. const statusConfig: any = keyBy(taskStatusOptions, 'value')
  181. // 优先级标签配置
  182. const priorityConfig: any = keyBy(taskLevelOptions, 'value')
  183. // 授权状态标签配置
  184. const authStatusConfig: any = keyBy(authStatusOptions, 'value')
  185. onMounted(async () => {
  186. await init()
  187. })
  188. </script>
  189. <template>
  190. <view class="details-box">
  191. <!-- 标题区域 -->
  192. <view class="details-box-title">
  193. <view class="details-box-title-text">
  194. {{ taskInfo.taskName || '任务详情' }}
  195. </view>
  196. </view>
  197. <!-- 标签区域 -->
  198. <view class="tags-box">
  199. <view class="tag">
  200. {{ priorityConfig[taskInfo.level]?.label || taskInfo.level }}
  201. </view>
  202. <view class="tag">
  203. {{ statusConfig[`${taskInfo.status || 0}`]?.label || taskInfo.status }}
  204. </view>
  205. <view class="tag">
  206. {{ authStatusConfig[taskInfo.authStatus || 0]?.label || taskInfo.authStatus }}
  207. </view>
  208. </view>
  209. <!-- 任务描述 -->
  210. <view class="section">
  211. <view class="section-title">
  212. 任务描述
  213. </view>
  214. <view class="task-description" v-html="taskInfo.description || '暂无'" />
  215. </view>
  216. <!-- 标准指引 -->
  217. <view class="section">
  218. <view class="section-title">
  219. 任务信息
  220. </view>
  221. <view class="standard-guide">
  222. <view class="guide-item">
  223. <view class="guide-label">
  224. 场站
  225. </view>
  226. <view class="guide-value">
  227. {{ taskInfo.stationName || '-' }}
  228. </view>
  229. </view>
  230. <view class="guide-item">
  231. <view class="guide-label">
  232. 标准指引
  233. </view>
  234. <view class="guide-value">
  235. {{ taskInfo.standardGuide || '-' }}
  236. </view>
  237. </view>
  238. <view class="guide-item">
  239. <view class="guide-label">
  240. 执行人
  241. </view>
  242. <view class="guide-value">
  243. {{ taskInfo.executorName || '-' }}
  244. </view>
  245. </view>
  246. <view class="guide-item">
  247. <view class="guide-label">
  248. 计划时间
  249. </view>
  250. <view class="guide-value">
  251. {{ taskInfo.displayDate || '-' }}
  252. </view>
  253. </view>
  254. <view class="guide-item">
  255. <view class="guide-label">
  256. 创建
  257. </view>
  258. <view class="guide-value">
  259. {{ taskInfo.createBy || '' }}
  260. </view>
  261. </view>
  262. <view class="guide-item">
  263. <view class="guide-label">
  264. 任务类型
  265. </view>
  266. <view class="guide-value">
  267. {{ taskInfo.subFormTypeName || taskOther.taskTypeName || '-' }}
  268. </view>
  269. </view>
  270. <view class="guide-item">
  271. <view class="guide-label">
  272. 任务负责人
  273. </view>
  274. <view class="guide-value">
  275. {{ taskInfo.taskLeaderName || '-' }}
  276. </view>
  277. </view>
  278. <view class="guide-item">
  279. <view class="guide-label">
  280. 任务频率
  281. </view>
  282. <view class="guide-value">
  283. {{ taskOther.taskFrequencyName || '-' }}
  284. </view>
  285. </view>
  286. <view class="guide-item">
  287. <view class="guide-label">
  288. 任务时间
  289. </view>
  290. <view class="guide-value">
  291. {{ getTaskTime() || '-' }}
  292. </view>
  293. </view>
  294. <!-- <view class="guide-item">
  295. <view class="guide-label">
  296. 任务描述
  297. </view>
  298. <view class="guide-value">
  299. {{ taskInfo.description || '-' }}
  300. </view>
  301. </view> -->
  302. <view v-if="taskInfo.descriptionFilesUrl && taskInfo.descriptionFilesUrl.length > 0" class="guide-item">
  303. <view class="guide-label">
  304. 详情附件
  305. </view>
  306. <view class="guide-value">
  307. <!-- 使用wot-ui样式显示附件 -->
  308. <view class="attachment-list">
  309. <wd-tag
  310. v-for="(file, index) in taskInfo.descriptionFilesUrl"
  311. :key="index"
  312. custom-class="attachment-tag"
  313. type="primary"
  314. plain
  315. >
  316. 附件{{ index + 1 }}
  317. </wd-tag>
  318. </view>
  319. </view>
  320. </view>
  321. <view v-if="taskResult.handleContent || taskInfo.cancelReason" class="guide-item">
  322. <view class="guide-label">
  323. 处理情况
  324. </view>
  325. <view class="guide-value">
  326. {{ taskResult.handleContent || taskInfo.cancelReason || '' }}
  327. </view>
  328. </view>
  329. <view class="guide-item">
  330. <view class="guide-label">
  331. 处理时间
  332. </view>
  333. <view class="guide-value">
  334. {{ taskInfo.completeTime || taskInfo.cancelTime || '-' }}
  335. </view>
  336. </view>
  337. <view v-if="taskResult.files && taskResult.files.length > 0" class="guide-item">
  338. <view class="guide-label">
  339. 处理附件
  340. </view>
  341. <view class="guide-value">
  342. <!-- 使用wot-ui样式显示附件列表 -->
  343. <view class="attachment-list">
  344. <wd-tag
  345. v-for="(file, index) in taskResult.files"
  346. :key="index"
  347. custom-class="attachment-tag"
  348. type="success"
  349. plain
  350. @click="downloadFile(file, taskResult.fileNames[index] || `附件${index + 1}`)"
  351. >
  352. {{ taskResult.fileNames[index] || `附件${index + 1}` }}
  353. </wd-tag>
  354. </view>
  355. </view>
  356. </view>
  357. </view>
  358. </view>
  359. <!-- 查看更多 -->
  360. <!-- <view class="more-btn" @tap="toggleMore">
  361. <text class="arrow">点击查看更多</text>
  362. <wd-icon
  363. class="arrow"
  364. :name="isExpanded ? 'arrow-up' : 'arrow-down'"
  365. size="20px"
  366. />
  367. </view> -->
  368. <!-- 更多内容(默认隐藏) -->
  369. <view v-if="isExpanded" class="more-content">
  370. <view class="section">
  371. <view class="section-title">
  372. 注意事项
  373. </view>
  374. <view class="notice-content">
  375. <view class="notice-item">
  376. • 巡视过程中请注意安全,佩戴好防护装备
  377. </view>
  378. <view class="notice-item">
  379. • 发现异常情况请及时记录并上报
  380. </view>
  381. <view class="notice-item">
  382. • 确保所有检查项目都已完成并签字确认
  383. </view>
  384. </view>
  385. </view>
  386. </view>
  387. <view class="detail-btn" @tap="dealTaskEvent">
  388. <text>处理任务</text>
  389. </view>
  390. <!-- <view class="detail-btn" @tap="viewDetails2">
  391. <text>查 看 详 情2</text>
  392. </view>
  393. <view class="detail-btn" @tap="viewDetails3">
  394. <text>查 看 详 情3</text>
  395. </view> -->
  396. </view>
  397. </template>
  398. <style lang="scss" scoped>
  399. .details-box {
  400. display: flex;
  401. flex-direction: column;
  402. padding: 30rpx 24rpx;
  403. background-color: #ffffff;
  404. .details-box-title {
  405. margin-bottom: 24rpx;
  406. .details-box-title-text {
  407. font-size: 48rpx;
  408. font-weight: 500;
  409. color: #31373d;
  410. }
  411. }
  412. // 标签样式
  413. .tags-box {
  414. display: flex;
  415. gap: 12rpx;
  416. margin-bottom: 24rpx;
  417. .tag {
  418. padding: 8rpx 16rpx;
  419. border-radius: 14rpx;
  420. font-size: 24rpx;
  421. font-weight: 400;
  422. color: #215acd;
  423. background-color: #e8f3ff;
  424. }
  425. }
  426. // 通用区块样式
  427. .section {
  428. margin-bottom: 32rpx;
  429. .section-title {
  430. font-size: 36rpx;
  431. font-weight: 500;
  432. color: #31373d;
  433. margin-bottom: 20rpx;
  434. }
  435. }
  436. // 任务描述样式
  437. .task-description {
  438. padding: 0 0 24rpx 0;
  439. border-bottom: 1rpx solid #e5e5e5;
  440. // 针对HTML内容的样式
  441. & :deep(ol),
  442. & :deep(ul) {
  443. padding-left: 32rpx;
  444. margin: 0;
  445. }
  446. & :deep(li) {
  447. font-size: 28rpx;
  448. font-weight: 400;
  449. color: #31373d;
  450. line-height: 52rpx;
  451. margin-bottom: 8rpx;
  452. }
  453. & :deep(p) {
  454. font-size: 28rpx;
  455. font-weight: 400;
  456. color: #31373d;
  457. line-height: 52rpx;
  458. margin: 0 0 12rpx 0;
  459. }
  460. }
  461. // 标准指引样式
  462. .standard-guide {
  463. .guide-item {
  464. display: flex;
  465. margin-bottom: 24rpx;
  466. &:last-child {
  467. margin-bottom: 0;
  468. }
  469. .guide-label {
  470. width: 160rpx;
  471. font-size: 28rpx;
  472. color: #6c757d;
  473. font-weight: 400;
  474. }
  475. .guide-value {
  476. flex: 1;
  477. font-size: 28rpx;
  478. font-weight: 400;
  479. color: #31373d;
  480. }
  481. }
  482. }
  483. // 查看更多按钮
  484. .more-btn {
  485. display: flex;
  486. align-items: center;
  487. justify-content: center;
  488. gap: 8rpx;
  489. margin: 32rpx 0;
  490. text {
  491. font-size: 32rpx;
  492. color: #3498db;
  493. }
  494. .arrow {
  495. font-size: 24rpx;
  496. color: #215acd;
  497. }
  498. }
  499. // 查看详情按钮
  500. .detail-btn {
  501. display: flex;
  502. align-items: center;
  503. justify-content: center;
  504. height: 96rpx;
  505. background-color: #215acd;
  506. border-radius: 14rpx;
  507. margin-bottom: 32rpx;
  508. position: fixed;
  509. bottom: 32rpx;
  510. left: 24rpx;
  511. right: 24rpx;
  512. z-index: 999;
  513. text {
  514. font-size: 32rpx;
  515. color: #ffffff;
  516. font-weight: 500;
  517. }
  518. }
  519. // 更多内容样式
  520. .more-content {
  521. margin-bottom: 32rpx;
  522. .notice-content {
  523. background-color: #f8f9fa;
  524. padding: 24rpx;
  525. border-radius: 12rpx;
  526. .notice-item {
  527. font-size: 32rpx;
  528. color: #31373d;
  529. line-height: 52rpx;
  530. margin-bottom: 12rpx;
  531. &:last-child {
  532. margin-bottom: 0;
  533. }
  534. }
  535. }
  536. }
  537. // 附件列表样式
  538. .attachment-list {
  539. display: flex;
  540. flex-wrap: wrap;
  541. gap: 12rpx;
  542. .attachment-tag {
  543. margin-bottom: 12rpx;
  544. }
  545. }
  546. }
  547. :deep(.attachment-tag) {
  548. margin-right: 12rpx;
  549. margin-bottom: 12rpx;
  550. }
  551. </style>