index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. <template>
  2. <view class="task-documents-page">
  3. <!-- 顶部导航栏 -->
  4. <view class="header-bg" :style="{ paddingTop: statusBarHeight + 'px' }">
  5. <view class="header-content">
  6. <view class="back-btn" @click="handleBack">
  7. <text class="back-icon">‹</text>
  8. </view>
  9. <text class="header-title">{{ pageTitle }}</text>
  10. <view class="placeholder"></view>
  11. </view>
  12. </view>
  13. <!-- 页面内容 -->
  14. <scroll-view
  15. scroll-y
  16. class="page-scroll"
  17. :style="{ paddingTop: (statusBarHeight * 2 + 88) + 'rpx' }"
  18. @scrolltolower="handleLoadMore"
  19. >
  20. <view class="page-content">
  21. <!-- 搜索和筛选区域 -->
  22. <view class="search-filter-row">
  23. <!-- 搜索框 -->
  24. <view class="search-box">
  25. <image class="search-icon" src="/static/pages/home/search.png" mode="aspectFit" />
  26. <input
  27. class="search-input"
  28. :placeholder="t('taskDocuments.searchPlaceholder')"
  29. placeholder-class="search-placeholder"
  30. v-model="searchKeyword"
  31. @confirm="handleSearch"
  32. />
  33. <view class="search-btn" @click="handleSearch">
  34. <text class="btn-text">{{ t('taskDocuments.search') }}</text>
  35. </view>
  36. </view>
  37. <!-- 状态选择器 -->
  38. <view class="status-selector">
  39. <picker
  40. mode="selector"
  41. :range="statusOptions"
  42. range-key="label"
  43. :value="statusOptions.findIndex(opt => opt.value === taskStatus)"
  44. @change="handleStatusChange"
  45. >
  46. <view class="selector-value">
  47. <text class="value-text">{{ selectedStatusLabel }}</text>
  48. <text class="arrow-icon">▼</text>
  49. </view>
  50. </picker>
  51. </view>
  52. </view>
  53. <!-- 文档列表 -->
  54. <view class="document-list">
  55. <view
  56. v-for="(doc, index) in documentList"
  57. :key="doc.id"
  58. class="document-item"
  59. @click="handleDocumentClick(doc)"
  60. >
  61. <image class="doc-thumbnail" :src="getFileIcon(doc.url)" mode="aspectFit" />
  62. <view class="doc-info">
  63. <text class="doc-name">{{ formatDocName(doc.name) }}</text>
  64. <view class="doc-meta">
  65. <text class="meta-text">{{ t('taskDocuments.createTime') }}:{{ doc.createTime }}</text>
  66. <text class="meta-text" v-if="doc.submitter">{{ t('taskDocuments.submitter') }}:{{ doc.submitter }}</text>
  67. </view>
  68. </view>
  69. <!-- 审核拒绝状态显示查看驳回理由按钮 -->
  70. <view
  71. v-if="doc.status === 2"
  72. class="rejection-btn"
  73. @click.stop="handleViewRejection(doc)"
  74. >
  75. <text class="rejection-btn-text">查看驳回理由</text>
  76. </view>
  77. </view>
  78. <!-- 加载状态 -->
  79. <view v-if="loading" class="loading-more">
  80. <text class="loading-text">{{ t('taskDocuments.loading') }}</text>
  81. </view>
  82. <!-- 没有更多数据 -->
  83. <view v-if="!hasMore && documentList.length > 0" class="no-more">
  84. <text class="no-more-text">{{ t('taskDocuments.noMore') }}</text>
  85. </view>
  86. <!-- 空状态 -->
  87. <view v-if="!loading && documentList.length === 0" class="empty-state">
  88. <text class="empty-text">{{ t('taskDocuments.empty') }}</text>
  89. </view>
  90. </view>
  91. </view>
  92. </scroll-view>
  93. <!-- 驳回理由弹窗 -->
  94. <view v-if="showRejectionModal" class="modal-overlay" @click="closeRejectionModal">
  95. <view class="modal-content" @click.stop>
  96. <view class="modal-header">
  97. <text class="modal-title">驳回理由</text>
  98. <view class="modal-close" @click="closeRejectionModal">
  99. <text class="close-icon">×</text>
  100. </view>
  101. </view>
  102. <view class="modal-body">
  103. <text class="rejection-text">{{ rejectionReason }}</text>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. </template>
  109. <script setup>
  110. import { ref, onMounted, computed } from 'vue'
  111. import { useI18n } from 'vue-i18n'
  112. import { getTaskDocuments, getRejection } from '@/apis/auth'
  113. import { formatDocumentNameForDisplay } from '@/utils/documentName'
  114. const { t } = useI18n()
  115. // 状态栏高度
  116. const statusBarHeight = ref(0)
  117. // 任务状态
  118. const taskStatus = ref(null)
  119. // 状态选项列表
  120. const statusOptions = computed(() => [
  121. { label: t('taskDocuments.status.all'), value: null },
  122. { label: t('taskDocuments.status.unUpload'), value: 0 },
  123. { label: t('taskDocuments.status.unAudit'), value: 1 },
  124. { label: t('taskDocuments.status.auditReject'), value: 2 }
  125. // { label: t('taskDocuments.status.unFiling'), value: 3 },
  126. // { label: t('taskDocuments.status.filing'), value: 4 },
  127. // { label: t('taskDocuments.status.unQualityControl'), value: 5 },
  128. // { label: t('taskDocuments.status.qualityControlPass'), value: 6 },
  129. // { label: t('taskDocuments.status.qualityControlReject'), value: 7 }
  130. ])
  131. // 当前选中的状态标签
  132. const selectedStatusLabel = computed(() => {
  133. const option = statusOptions.value.find(opt => opt.value === taskStatus.value)
  134. return option ? option.label : t('taskDocuments.status.all')
  135. })
  136. // 搜索关键词
  137. const searchKeyword = ref('')
  138. // 文档列表
  139. const documentList = ref([])
  140. // 分页参数
  141. const pageNum = ref(1)
  142. const pageSize = ref(10)
  143. const total = ref(0)
  144. const loading = ref(false)
  145. const hasMore = ref(true)
  146. // 驳回理由弹窗
  147. const showRejectionModal = ref(false)
  148. const rejectionReason = ref('')
  149. // 页面标题
  150. const pageTitle = computed(() => {
  151. if (taskStatus.value === 0) return t('taskDocuments.toSubmit')
  152. if (taskStatus.value === 1) return t('taskDocuments.toAudit')
  153. return t('taskDocuments.myTasks')
  154. })
  155. // 根据文件URL获取文件类型图标
  156. const getFileIcon = (url) => {
  157. if (!url) return '/static/icon/document.svg'
  158. // 提取文件扩展名
  159. const extension = url.split('.').pop().toLowerCase()
  160. // 根据扩展名返回对应图标
  161. const iconMap = {
  162. // Word文档
  163. 'doc': '/static/icon/word.svg',
  164. 'docx': '/static/icon/word.svg',
  165. // Excel表格
  166. 'xls': '/static/icon/excel.svg',
  167. 'xlsx': '/static/icon/excel.svg',
  168. // PowerPoint演示
  169. 'ppt': '/static/icon/ppt.svg',
  170. 'pptx': '/static/icon/ppt.svg',
  171. // PDF文档
  172. 'pdf': '/static/icon/pdf.svg'
  173. }
  174. return iconMap[extension] || '/static/icon/document.svg'
  175. }
  176. // 格式化文档名称用于显示
  177. const formatDocName = (name) => {
  178. return formatDocumentNameForDisplay(name)
  179. }
  180. onMounted(() => {
  181. // 获取系统信息
  182. const windowInfo = uni.getWindowInfo()
  183. statusBarHeight.value = windowInfo.statusBarHeight || 0
  184. // 获取页面参数
  185. const pages = getCurrentPages()
  186. const currentPage = pages[pages.length - 1]
  187. const status = currentPage.options.status
  188. if (status !== undefined && status !== '') {
  189. taskStatus.value = parseInt(status)
  190. }
  191. // 加载文档列表
  192. fetchDocuments()
  193. })
  194. // 获取文档列表
  195. const fetchDocuments = async (isLoadMore = false) => {
  196. if (loading.value) return
  197. try {
  198. loading.value = true
  199. // 构建请求参数
  200. const params = {
  201. pageNum: pageNum.value,
  202. pageSize: pageSize.value
  203. }
  204. // 只有当搜索关键词不为空时才添加 name 参数
  205. if (searchKeyword.value && searchKeyword.value.trim()) {
  206. params.name = searchKeyword.value.trim()
  207. }
  208. // 只有当状态不为空时才添加 status 参数
  209. if (taskStatus.value !== null && taskStatus.value !== undefined) {
  210. params.status = taskStatus.value
  211. }
  212. const response = await getTaskDocuments(params)
  213. if (response && response.code === 200) {
  214. const { rows, total: totalCount } = response
  215. total.value = totalCount
  216. if (isLoadMore) {
  217. // 加载更多,追加数据
  218. documentList.value = [...documentList.value, ...rows]
  219. } else {
  220. // 首次加载或搜索,替换数据
  221. documentList.value = rows
  222. }
  223. // 判断是否还有更多数据
  224. hasMore.value = documentList.value.length < total.value
  225. }
  226. } catch (error) {
  227. console.error('获取文档列表失败:', error)
  228. if (!isLoadMore) {
  229. documentList.value = []
  230. }
  231. uni.showToast({
  232. title: t('taskDocuments.loadFailed'),
  233. icon: 'none'
  234. })
  235. } finally {
  236. loading.value = false
  237. }
  238. }
  239. // 加载更多
  240. const handleLoadMore = () => {
  241. if (!hasMore.value || loading.value) return
  242. pageNum.value++
  243. fetchDocuments(true)
  244. }
  245. // 搜索
  246. const handleSearch = () => {
  247. // 重置分页
  248. pageNum.value = 1
  249. hasMore.value = true
  250. // 重新加载数据
  251. fetchDocuments()
  252. }
  253. // 状态选择
  254. const handleStatusChange = (e) => {
  255. const index = e.detail.value
  256. taskStatus.value = statusOptions.value[index].value
  257. // 重置分页
  258. pageNum.value = 1
  259. hasMore.value = true
  260. // 重新加载数据
  261. fetchDocuments()
  262. }
  263. // 点击文档
  264. const handleDocumentClick = (doc) => {
  265. // 状态 0: 待递交 - 跳转到扫描页面
  266. if (doc.status === 0) {
  267. uni.navigateTo({
  268. url: '/pages/scan/index'
  269. })
  270. return
  271. }
  272. // 状态 2: 审核拒绝 - 全屏预览文档
  273. if (doc.status === 2) {
  274. if (!doc.url) {
  275. uni.showToast({
  276. title: t('taskDocuments.invalidUrl'),
  277. icon: 'none'
  278. })
  279. return
  280. }
  281. // 使用 web-view 全屏预览文档
  282. uni.navigateTo({
  283. url: `/pages/home/documentViewer/index?url=${encodeURIComponent(doc.url)}&name=${encodeURIComponent(doc.name || '文档预览')}`
  284. })
  285. return
  286. }
  287. // 其他状态 - 默认处理
  288. if (!doc.url) {
  289. uni.showToast({
  290. title: t('taskDocuments.invalidUrl'),
  291. icon: 'none'
  292. })
  293. return
  294. }
  295. // 构建跳转URL,传递文档信息
  296. const params = []
  297. if (doc.name) {
  298. params.push(`name=${encodeURIComponent(doc.name)}`)
  299. }
  300. if (doc.url) {
  301. params.push(`url=${encodeURIComponent(doc.url)}`)
  302. }
  303. const queryString = params.join('&')
  304. uni.navigateTo({
  305. url: `/pages/home/documentViewer/index?${queryString}`
  306. })
  307. }
  308. // 查看驳回理由
  309. const handleViewRejection = async (doc) => {
  310. if (!doc.id) {
  311. uni.showToast({
  312. title: '文档ID无效',
  313. icon: 'none'
  314. })
  315. return
  316. }
  317. try {
  318. uni.showLoading({
  319. title: '加载中...',
  320. mask: true
  321. })
  322. const response = await getRejection(doc.id)
  323. uni.hideLoading()
  324. if (response && response.code === 200 && response.data) {
  325. rejectionReason.value = response.data.rejection || '暂无驳回理由'
  326. showRejectionModal.value = true
  327. } else {
  328. uni.showToast({
  329. title: response.msg || '获取驳回理由失败',
  330. icon: 'none'
  331. })
  332. }
  333. } catch (error) {
  334. uni.hideLoading()
  335. console.error('获取驳回理由失败:', error)
  336. uni.showToast({
  337. title: '获取驳回理由失败',
  338. icon: 'none'
  339. })
  340. }
  341. }
  342. // 关闭驳回理由弹窗
  343. const closeRejectionModal = () => {
  344. showRejectionModal.value = false
  345. rejectionReason.value = ''
  346. }
  347. // 返回
  348. const handleBack = () => {
  349. uni.navigateBack({
  350. fail: () => {
  351. uni.reLaunch({
  352. url: '/pages/my/index'
  353. })
  354. }
  355. })
  356. }
  357. </script>
  358. <style lang="scss" scoped>
  359. .task-documents-page {
  360. width: 100%;
  361. height: 100vh;
  362. background-color: #f5f5f5;
  363. position: relative;
  364. overflow: hidden;
  365. // 顶部导航栏
  366. .header-bg {
  367. position: fixed;
  368. top: 0;
  369. left: 0;
  370. right: 0;
  371. background: linear-gradient(180deg, #1ec9c9 0%, #1eb8b8 100%);
  372. z-index: 100;
  373. .header-content {
  374. height: 88rpx;
  375. display: flex;
  376. align-items: center;
  377. justify-content: space-between;
  378. padding: 0 24rpx;
  379. .back-btn {
  380. width: 60rpx;
  381. height: 60rpx;
  382. display: flex;
  383. align-items: center;
  384. justify-content: flex-start;
  385. .back-icon {
  386. font-size: 56rpx;
  387. color: #ffffff;
  388. font-weight: 300;
  389. }
  390. }
  391. .header-title {
  392. flex: 1;
  393. text-align: center;
  394. font-size: 32rpx;
  395. font-weight: 600;
  396. color: #ffffff;
  397. }
  398. .placeholder {
  399. width: 60rpx;
  400. }
  401. }
  402. }
  403. // 可滚动区域
  404. .page-scroll {
  405. width: 100%;
  406. height: 100%;
  407. .page-content {
  408. padding: 24rpx;
  409. padding-bottom: 40rpx;
  410. // 搜索和筛选行
  411. .search-filter-row {
  412. display: flex;
  413. gap: 16rpx;
  414. margin-bottom: 24rpx;
  415. }
  416. // 搜索框
  417. .search-box {
  418. flex: 1;
  419. background: #ffffff;
  420. border-radius: 16rpx;
  421. padding: 16rpx 20rpx;
  422. display: flex;
  423. align-items: center;
  424. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  425. .search-icon {
  426. width: 32rpx;
  427. height: 32rpx;
  428. margin-right: 12rpx;
  429. flex-shrink: 0;
  430. }
  431. .search-input {
  432. flex: 1;
  433. font-size: 26rpx;
  434. color: #333333;
  435. min-width: 0;
  436. }
  437. .search-placeholder {
  438. color: #999999;
  439. }
  440. .search-btn {
  441. margin-left: 12rpx;
  442. padding: 8rpx 20rpx;
  443. background: linear-gradient(135deg, #1ec9c9 0%, #17b3b3 100%);
  444. border-radius: 8rpx;
  445. flex-shrink: 0;
  446. &:active {
  447. opacity: 0.8;
  448. }
  449. .btn-text {
  450. font-size: 24rpx;
  451. color: #ffffff;
  452. font-weight: 500;
  453. }
  454. }
  455. }
  456. // 状态选择器
  457. .status-selector {
  458. background: #ffffff;
  459. border-radius: 16rpx;
  460. padding: 16rpx 20rpx;
  461. display: flex;
  462. align-items: center;
  463. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  464. flex-shrink: 0;
  465. picker {
  466. display: flex;
  467. }
  468. .selector-value {
  469. display: flex;
  470. align-items: center;
  471. gap: 8rpx;
  472. .value-text {
  473. font-size: 26rpx;
  474. color: #1ec9c9;
  475. font-weight: 500;
  476. white-space: nowrap;
  477. }
  478. .arrow-icon {
  479. font-size: 20rpx;
  480. color: #1ec9c9;
  481. }
  482. }
  483. }
  484. // 文档列表
  485. .document-list {
  486. .document-item {
  487. background: #ffffff;
  488. border-radius: 16rpx;
  489. padding: 24rpx;
  490. display: flex;
  491. align-items: center;
  492. margin-bottom: 16rpx;
  493. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  494. &:active {
  495. background-color: #f8f8f8;
  496. }
  497. .doc-thumbnail {
  498. width: 100rpx;
  499. height: 120rpx;
  500. border-radius: 8rpx;
  501. margin-right: 24rpx;
  502. background-color: #f0f0f0;
  503. padding: 10rpx;
  504. box-sizing: border-box;
  505. }
  506. .doc-info {
  507. flex: 1;
  508. display: flex;
  509. flex-direction: column;
  510. gap: 12rpx;
  511. min-width: 0;
  512. .doc-name {
  513. font-size: 28rpx;
  514. font-weight: 500;
  515. color: #333333;
  516. overflow: hidden;
  517. text-overflow: ellipsis;
  518. white-space: nowrap;
  519. }
  520. .doc-meta {
  521. display: flex;
  522. flex-direction: column;
  523. gap: 8rpx;
  524. .meta-text {
  525. font-size: 24rpx;
  526. color: #999999;
  527. }
  528. }
  529. }
  530. .rejection-btn {
  531. margin-left: 16rpx;
  532. padding: 12rpx 20rpx;
  533. background: linear-gradient(135deg, #ff6b6b 0%, #ff5252 100%);
  534. border-radius: 8rpx;
  535. flex-shrink: 0;
  536. &:active {
  537. opacity: 0.8;
  538. }
  539. .rejection-btn-text {
  540. font-size: 24rpx;
  541. color: #ffffff;
  542. font-weight: 500;
  543. white-space: nowrap;
  544. }
  545. }
  546. }
  547. // 加载更多
  548. .loading-more {
  549. padding: 32rpx;
  550. text-align: center;
  551. .loading-text {
  552. font-size: 24rpx;
  553. color: #999999;
  554. }
  555. }
  556. // 没有更多
  557. .no-more {
  558. padding: 32rpx;
  559. text-align: center;
  560. .no-more-text {
  561. font-size: 24rpx;
  562. color: #999999;
  563. }
  564. }
  565. // 空状态
  566. .empty-state {
  567. padding: 120rpx 32rpx;
  568. text-align: center;
  569. .empty-text {
  570. font-size: 28rpx;
  571. color: #999999;
  572. }
  573. }
  574. }
  575. }
  576. }
  577. // 驳回理由弹窗
  578. .modal-overlay {
  579. position: fixed;
  580. top: 0;
  581. left: 0;
  582. right: 0;
  583. bottom: 0;
  584. background: rgba(0, 0, 0, 0.5);
  585. display: flex;
  586. align-items: center;
  587. justify-content: center;
  588. z-index: 1000;
  589. .modal-content {
  590. width: 600rpx;
  591. background: #ffffff;
  592. border-radius: 16rpx;
  593. overflow: hidden;
  594. .modal-header {
  595. padding: 32rpx 24rpx;
  596. border-bottom: 1rpx solid #f0f0f0;
  597. display: flex;
  598. align-items: center;
  599. justify-content: space-between;
  600. .modal-title {
  601. font-size: 32rpx;
  602. font-weight: 600;
  603. color: #333333;
  604. }
  605. .modal-close {
  606. width: 48rpx;
  607. height: 48rpx;
  608. display: flex;
  609. align-items: center;
  610. justify-content: center;
  611. &:active {
  612. opacity: 0.6;
  613. }
  614. .close-icon {
  615. font-size: 48rpx;
  616. color: #999999;
  617. line-height: 1;
  618. font-weight: 300;
  619. }
  620. }
  621. }
  622. .modal-body {
  623. padding: 32rpx 24rpx;
  624. max-height: 400rpx;
  625. overflow-y: auto;
  626. .rejection-text {
  627. font-size: 28rpx;
  628. color: #666666;
  629. line-height: 1.6;
  630. word-break: break-all;
  631. }
  632. }
  633. }
  634. }
  635. }
  636. </style>