index.vue 18 KB

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