index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. <template>
  2. <view class="file-select-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">请选择对应缺失文件</text>
  10. <view class="placeholder"></view>
  11. </view>
  12. </view>
  13. <!-- 搜索框 -->
  14. <view class="search-bar">
  15. <input
  16. class="search-input"
  17. v-model="searchName"
  18. placeholder="搜索文件名"
  19. @confirm="handleSearch"
  20. />
  21. <view class="search-btn" @click="handleSearch">
  22. <text class="search-text">搜索</text>
  23. </view>
  24. </view>
  25. <!-- 文件列表 -->
  26. <scroll-view
  27. scroll-y
  28. class="file-list"
  29. @scrolltolower="handleLoadMore"
  30. >
  31. <view
  32. v-for="item in fileList"
  33. :key="item.id"
  34. class="file-item"
  35. @click="handleSelectFile(item)"
  36. >
  37. <view class="file-icon-wrapper">
  38. <image src="/static/icon/document.svg" mode="aspectFit" class="file-icon" />
  39. </view>
  40. <view class="file-info">
  41. <text class="file-name">{{ item.name }}</text>
  42. <text class="file-detail">项目: {{ item.project }}</text>
  43. <text class="file-detail">文件夹: {{ item.folder }}</text>
  44. <text class="file-detail">创建人: {{ item.createBy }}</text>
  45. <text class="file-detail">截止日期: {{ formatDate(item.deadline) }}</text>
  46. </view>
  47. </view>
  48. <view v-if="fileList.length === 0 && !loading" class="empty-tip">
  49. <text class="empty-text">暂无待递交文件</text>
  50. <text class="empty-hint">您可以直接上传文件</text>
  51. </view>
  52. <view v-if="loading" class="loading-tip">
  53. <text class="loading-text">加载中...</text>
  54. </view>
  55. </scroll-view>
  56. <!-- 底部提交按钮 -->
  57. <view class="submit-footer">
  58. <view
  59. class="submit-btn secondary"
  60. @click="handleDirectUpload"
  61. >
  62. <text class="submit-text">直接上传</text>
  63. </view>
  64. </view>
  65. <!-- 生效日期选择弹窗 -->
  66. <view v-if="showDateModal" class="modal-overlay" @click="handleCloseModal">
  67. <view class="modal-content" @click.stop>
  68. <view class="modal-header">
  69. <text class="modal-title">选择生效日期</text>
  70. </view>
  71. <view class="modal-body">
  72. <view class="date-picker-wrapper">
  73. <picker
  74. mode="date"
  75. :value="selectedDate"
  76. @change="handleDateChange"
  77. >
  78. <view class="date-display">
  79. <text class="date-label">生效日期:</text>
  80. <text class="date-value" :class="{ placeholder: !selectedDate }">
  81. {{ selectedDate || '请选择日期' }}
  82. </text>
  83. <text class="date-arrow">›</text>
  84. </view>
  85. </picker>
  86. </view>
  87. </view>
  88. <view class="modal-footer">
  89. <view class="modal-btn cancel" @click="handleCloseModal">
  90. <text class="modal-btn-text">取消</text>
  91. </view>
  92. <view class="modal-btn confirm" @click="handleConfirmDate">
  93. <text class="modal-btn-text">确认</text>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </template>
  100. <script setup>
  101. import { ref, onMounted } from 'vue'
  102. import { getToSubmitList, uploadOnSubmit } from '@/apis/scan'
  103. // 状态栏高度
  104. const statusBarHeight = ref(0)
  105. // 文件列表
  106. const fileList = ref([])
  107. const searchName = ref('')
  108. const pageNum = ref(1)
  109. const pageSize = ref(10)
  110. const total = ref(0)
  111. const loading = ref(false)
  112. // 日期选择弹窗
  113. const showDateModal = ref(false)
  114. const selectedDate = ref('')
  115. const selectedFile = ref(null)
  116. onMounted(() => {
  117. // 获取系统信息
  118. const windowInfo = uni.getWindowInfo()
  119. statusBarHeight.value = windowInfo.statusBarHeight || 0
  120. // 加载文件列表
  121. loadFileList()
  122. })
  123. // 返回上一页
  124. const handleBack = () => {
  125. uni.navigateBack()
  126. }
  127. // 加载文件列表
  128. const loadFileList = async () => {
  129. if (loading.value) return
  130. try {
  131. loading.value = true
  132. const response = await getToSubmitList({
  133. name: searchName.value,
  134. pageNum: pageNum.value,
  135. pageSize: pageSize.value
  136. })
  137. if (response.code === 200) {
  138. if (pageNum.value === 1) {
  139. fileList.value = response.rows || []
  140. } else {
  141. fileList.value = [...fileList.value, ...(response.rows || [])]
  142. }
  143. total.value = response.total || 0
  144. }
  145. } catch (error) {
  146. console.error('加载文件列表失败:', error)
  147. uni.showToast({
  148. title: '加载失败',
  149. icon: 'none'
  150. })
  151. } finally {
  152. loading.value = false
  153. }
  154. }
  155. // 搜索
  156. const handleSearch = () => {
  157. pageNum.value = 1
  158. fileList.value = []
  159. loadFileList()
  160. }
  161. // 加载更多
  162. const handleLoadMore = () => {
  163. if (loading.value) return
  164. if (fileList.value.length >= total.value) return
  165. pageNum.value++
  166. loadFileList()
  167. }
  168. // 选择文件 - 先弹出日期选择框
  169. const handleSelectFile = (file) => {
  170. selectedFile.value = file
  171. selectedDate.value = ''
  172. showDateModal.value = true
  173. }
  174. // 关闭弹窗
  175. const handleCloseModal = () => {
  176. showDateModal.value = false
  177. selectedFile.value = null
  178. selectedDate.value = ''
  179. }
  180. // 日期选择变化
  181. const handleDateChange = (e) => {
  182. selectedDate.value = e.detail.value
  183. }
  184. // 确认日期并提交
  185. const handleConfirmDate = async () => {
  186. if (!selectedDate.value) {
  187. uni.showToast({
  188. title: '请选择生效日期',
  189. icon: 'none'
  190. })
  191. return
  192. }
  193. if (!selectedFile.value) {
  194. uni.showToast({
  195. title: '未选择文件',
  196. icon: 'none'
  197. })
  198. return
  199. }
  200. try {
  201. // 从全局数据中获取扫描的fileBase64List
  202. const fileBase64List = getApp().globalData.scannedFileBase64List
  203. if (!fileBase64List || fileBase64List.length === 0) {
  204. uni.showToast({
  205. title: '未找到扫描文件',
  206. icon: 'none'
  207. })
  208. return
  209. }
  210. // 关闭弹窗
  211. showDateModal.value = false
  212. uni.showLoading({
  213. title: '提交中...',
  214. mask: true
  215. })
  216. // 调用上传接口
  217. const response = await uploadOnSubmit({
  218. documentId: selectedFile.value.id,
  219. fileBase64List: fileBase64List,
  220. effectiveDate: selectedDate.value
  221. })
  222. uni.hideLoading()
  223. if (response.code === 200) {
  224. // 清除全局数据
  225. getApp().globalData.scannedFileBase64List = null
  226. uni.showToast({
  227. title: '提交成功',
  228. icon: 'success',
  229. duration: 2000
  230. })
  231. // 返回首页
  232. setTimeout(() => {
  233. uni.reLaunch({
  234. url: '/pages/home/index'
  235. })
  236. }, 2000)
  237. } else {
  238. throw new Error(response.msg || '提交失败')
  239. }
  240. } catch (error) {
  241. uni.hideLoading()
  242. console.error('提交失败:', error)
  243. uni.showToast({
  244. title: error.message || '提交失败',
  245. icon: 'none'
  246. })
  247. }
  248. }
  249. // 底部提交按钮(与点击文件相同的逻辑,但需要先选择文件)
  250. const handleSubmitAll = () => {
  251. if (fileList.value.length === 0) {
  252. uni.showToast({
  253. title: '暂无可选文件',
  254. icon: 'none'
  255. })
  256. return
  257. }
  258. uni.showToast({
  259. title: '请点击选择对应的文件',
  260. icon: 'none'
  261. })
  262. }
  263. // 直接上传 - 跳转到项目选择页面
  264. const handleDirectUpload = () => {
  265. // 从全局数据中获取扫描的fileBase64List
  266. const fileBase64List = getApp().globalData.scannedFileBase64List
  267. if (!fileBase64List || fileBase64List.length === 0) {
  268. uni.showToast({
  269. title: '未找到扫描文件',
  270. icon: 'none'
  271. })
  272. return
  273. }
  274. // 跳转到项目选择页面
  275. uni.navigateTo({
  276. url: '/pages/scan/projectSelect/index'
  277. })
  278. }
  279. // 格式化日期(只显示到天)
  280. const formatDate = (dateStr) => {
  281. if (!dateStr) return ''
  282. // 如果日期格式是 "2026-01-04 10:58:37",只取前10位
  283. return dateStr.split(' ')[0]
  284. }
  285. </script>
  286. <style lang="scss" scoped>
  287. .file-select-page {
  288. width: 100%;
  289. height: 100vh;
  290. display: flex;
  291. flex-direction: column;
  292. background-color: #f5f5f5;
  293. // 顶部导航栏
  294. .header-bg {
  295. background: linear-gradient(180deg, #1ec9c9 0%, #1eb8b8 100%);
  296. position: relative;
  297. z-index: 100;
  298. .header-content {
  299. height: 88rpx;
  300. display: flex;
  301. align-items: center;
  302. justify-content: space-between;
  303. padding: 0 24rpx;
  304. .back-btn {
  305. width: 60rpx;
  306. height: 60rpx;
  307. display: flex;
  308. align-items: center;
  309. justify-content: flex-start;
  310. .back-icon {
  311. font-size: 56rpx;
  312. color: #ffffff;
  313. font-weight: 300;
  314. }
  315. }
  316. .header-title {
  317. flex: 1;
  318. text-align: center;
  319. font-size: 32rpx;
  320. font-weight: 600;
  321. color: #ffffff;
  322. }
  323. .placeholder {
  324. width: 60rpx;
  325. }
  326. }
  327. }
  328. // 搜索框
  329. .search-bar {
  330. padding: 24rpx;
  331. background: #ffffff;
  332. display: flex;
  333. gap: 16rpx;
  334. .search-input {
  335. flex: 1;
  336. height: 64rpx;
  337. padding: 0 24rpx;
  338. background: #f5f5f5;
  339. border-radius: 32rpx;
  340. font-size: 28rpx;
  341. }
  342. .search-btn {
  343. width: 120rpx;
  344. height: 64rpx;
  345. background: #1ec9c9;
  346. border-radius: 32rpx;
  347. display: flex;
  348. align-items: center;
  349. justify-content: center;
  350. &:active {
  351. background: #1ab8b8;
  352. }
  353. .search-text {
  354. font-size: 28rpx;
  355. color: #ffffff;
  356. font-weight: 500;
  357. }
  358. }
  359. }
  360. // 文件列表
  361. .file-list {
  362. flex: 1;
  363. background: #ffffff;
  364. .file-item {
  365. padding: 24rpx;
  366. display: flex;
  367. align-items: center;
  368. border-bottom: 1rpx solid #f5f5f5;
  369. &:active {
  370. background: #f8f8f8;
  371. }
  372. .file-icon-wrapper {
  373. width: 80rpx;
  374. height: 80rpx;
  375. background: #f5f5f5;
  376. border-radius: 12rpx;
  377. display: flex;
  378. align-items: center;
  379. justify-content: center;
  380. margin-right: 24rpx;
  381. .file-icon {
  382. width: 48rpx;
  383. height: 48rpx;
  384. }
  385. }
  386. .file-info {
  387. flex: 1;
  388. display: flex;
  389. flex-direction: column;
  390. gap: 6rpx;
  391. .file-name {
  392. font-size: 32rpx;
  393. font-weight: 600;
  394. color: #333333;
  395. margin-bottom: 4rpx;
  396. }
  397. .file-detail {
  398. font-size: 26rpx;
  399. color: #666666;
  400. line-height: 1.5;
  401. }
  402. }
  403. }
  404. .empty-tip {
  405. padding: 200rpx 0;
  406. text-align: center;
  407. display: flex;
  408. flex-direction: column;
  409. gap: 16rpx;
  410. .empty-text {
  411. font-size: 28rpx;
  412. color: #999999;
  413. }
  414. .empty-hint {
  415. font-size: 26rpx;
  416. color: #1ec9c9;
  417. }
  418. }
  419. .loading-tip {
  420. padding: 32rpx 0;
  421. text-align: center;
  422. .loading-text {
  423. font-size: 28rpx;
  424. color: #999999;
  425. }
  426. }
  427. }
  428. // 底部提交按钮
  429. .submit-footer {
  430. background: #ffffff;
  431. padding: 24rpx 32rpx;
  432. padding-bottom: calc(24rpx + env(safe-area-inset-bottom));
  433. box-shadow: 0 -2rpx 8rpx rgba(0, 0, 0, 0.05);
  434. display: flex;
  435. gap: 16rpx;
  436. .submit-btn {
  437. flex: 1;
  438. height: 88rpx;
  439. background: linear-gradient(135deg, #1ec9c9 0%, #1eb8b8 100%);
  440. border-radius: 44rpx;
  441. display: flex;
  442. align-items: center;
  443. justify-content: center;
  444. box-shadow: 0 4rpx 16rpx rgba(30, 201, 201, 0.3);
  445. &:active {
  446. transform: scale(0.98);
  447. opacity: 0.9;
  448. }
  449. &.secondary {
  450. background: #ffffff;
  451. border: 2rpx solid #1ec9c9;
  452. box-shadow: none;
  453. .submit-text {
  454. color: #1ec9c9;
  455. }
  456. }
  457. .submit-text {
  458. font-size: 32rpx;
  459. font-weight: 600;
  460. color: #ffffff;
  461. }
  462. &.full-width {
  463. flex: 1;
  464. }
  465. }
  466. }
  467. // 日期选择弹窗
  468. .modal-overlay {
  469. position: fixed;
  470. top: 0;
  471. left: 0;
  472. right: 0;
  473. bottom: 0;
  474. background: rgba(0, 0, 0, 0.5);
  475. display: flex;
  476. align-items: center;
  477. justify-content: center;
  478. z-index: 1000;
  479. .modal-content {
  480. width: 600rpx;
  481. background: #ffffff;
  482. border-radius: 24rpx;
  483. overflow: hidden;
  484. .modal-header {
  485. padding: 32rpx;
  486. border-bottom: 1rpx solid #f5f5f5;
  487. .modal-title {
  488. font-size: 32rpx;
  489. font-weight: 600;
  490. color: #333333;
  491. text-align: center;
  492. display: block;
  493. }
  494. }
  495. .modal-body {
  496. padding: 32rpx;
  497. .date-picker-wrapper {
  498. .date-display {
  499. background: #f5f5f5;
  500. border-radius: 12rpx;
  501. padding: 24rpx;
  502. display: flex;
  503. align-items: center;
  504. .date-label {
  505. font-size: 28rpx;
  506. color: #666666;
  507. margin-right: 16rpx;
  508. }
  509. .date-value {
  510. flex: 1;
  511. font-size: 28rpx;
  512. color: #333333;
  513. &.placeholder {
  514. color: #999999;
  515. }
  516. }
  517. .date-arrow {
  518. font-size: 40rpx;
  519. color: #999999;
  520. font-weight: 300;
  521. }
  522. }
  523. }
  524. }
  525. .modal-footer {
  526. display: flex;
  527. border-top: 1rpx solid #f5f5f5;
  528. .modal-btn {
  529. flex: 1;
  530. height: 88rpx;
  531. display: flex;
  532. align-items: center;
  533. justify-content: center;
  534. &:active {
  535. background: #f5f5f5;
  536. }
  537. &.cancel {
  538. border-right: 1rpx solid #f5f5f5;
  539. .modal-btn-text {
  540. color: #666666;
  541. }
  542. }
  543. &.confirm {
  544. .modal-btn-text {
  545. color: #1ec9c9;
  546. font-weight: 600;
  547. }
  548. }
  549. .modal-btn-text {
  550. font-size: 32rpx;
  551. }
  552. }
  553. }
  554. }
  555. }
  556. }
  557. </style>