| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652 |
- <template>
- <view class="file-select-page">
- <!-- 顶部导航栏 -->
- <view class="header-bg" :style="{ paddingTop: statusBarHeight + 'px' }">
- <view class="header-content">
- <view class="back-btn" @click="handleBack">
- <text class="back-icon">‹</text>
- </view>
- <text class="header-title">{{ t('fileSelect.title') }}</text>
- <view class="placeholder"></view>
- </view>
- </view>
-
- <!-- 搜索框 -->
- <view class="search-bar">
- <input
- class="search-input"
- v-model="searchName"
- :placeholder="t('fileSelect.search.placeholder')"
- @confirm="handleSearch"
- />
- <view class="search-btn" @click="handleSearch">
- <text class="search-text">{{ t('fileSelect.search.button') }}</text>
- </view>
- </view>
-
- <!-- 文件列表 -->
- <scroll-view
- scroll-y
- class="file-list"
- @scrolltolower="handleLoadMore"
- >
- <view
- v-for="item in fileList"
- :key="item.id"
- class="file-item"
- @click="handleSelectFile(item)"
- >
- <view class="file-icon-wrapper">
- <image src="/static/icon/document.svg" mode="aspectFit" class="file-icon" />
- </view>
- <view class="file-info">
- <text class="file-name">{{ item.name }}</text>
- <text class="file-detail">{{ t('fileSelect.fileInfo.project') }}: {{ item.project }}</text>
- <text class="file-detail">{{ t('fileSelect.fileInfo.folder') }}: {{ item.folder }}</text>
- <text class="file-detail">{{ t('fileSelect.fileInfo.createBy') }}: {{ item.createBy }}</text>
- <text class="file-detail">{{ t('fileSelect.fileInfo.deadline') }}: {{ formatDate(item.deadline) }}</text>
- </view>
- </view>
-
- <view v-if="fileList.length === 0 && !loading" class="empty-tip">
- <text class="empty-text">{{ t('fileSelect.empty.noFiles') }}</text>
- <text class="empty-hint">{{ t('fileSelect.empty.hint') }}</text>
- </view>
-
- <view v-if="loading" class="loading-tip">
- <text class="loading-text">{{ t('fileSelect.message.loading') }}</text>
- </view>
- </scroll-view>
-
- <!-- 底部提交按钮 -->
- <view class="submit-footer">
- <view
- class="submit-btn secondary"
- @click="handleDirectUpload"
- >
- <text class="submit-text">{{ t('fileSelect.action.directUpload') }}</text>
- </view>
- </view>
-
- <!-- 生效日期选择弹窗 -->
- <view v-if="showDateModal" class="modal-overlay" @click="handleCloseModal">
- <view class="modal-content" @click.stop>
- <view class="modal-header">
- <text class="modal-title">{{ t('fileSelect.dateModal.title') }}</text>
- </view>
-
- <view class="modal-body">
- <view class="date-picker-wrapper">
- <picker
- mode="date"
- :value="selectedDate"
- @change="handleDateChange"
- >
- <view class="date-display">
- <text class="date-label">{{ t('fileSelect.dateModal.label') }}</text>
- <text class="date-value" :class="{ placeholder: !selectedDate }">
- {{ selectedDate || t('fileSelect.dateModal.placeholder') }}
- </text>
- <text class="date-arrow">›</text>
- </view>
- </picker>
- </view>
- </view>
-
- <view class="modal-footer">
- <view class="modal-btn cancel" @click="handleCloseModal">
- <text class="modal-btn-text">{{ t('fileSelect.action.cancel') }}</text>
- </view>
- <view class="modal-btn confirm" @click="handleConfirmDate">
- <text class="modal-btn-text">{{ t('fileSelect.action.confirm') }}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script setup>
- import { ref, onMounted } from 'vue'
- import { useI18n } from 'vue-i18n'
- import { getToSubmitList, uploadOnSubmit } from '@/apis/scan'
- const { t } = useI18n()
- // 状态栏高度
- const statusBarHeight = ref(0)
- // 文件列表
- const fileList = ref([])
- const searchName = ref('')
- const pageNum = ref(1)
- const pageSize = ref(10)
- const total = ref(0)
- const loading = ref(false)
- // 日期选择弹窗
- const showDateModal = ref(false)
- const selectedDate = ref('')
- const selectedFile = ref(null)
- onMounted(() => {
- // 获取系统信息
- const windowInfo = uni.getWindowInfo()
- statusBarHeight.value = windowInfo.statusBarHeight || 0
-
- // 加载文件列表
- loadFileList()
- })
- // 返回上一页
- const handleBack = () => {
- uni.navigateBack()
- }
- // 加载文件列表
- const loadFileList = async () => {
- if (loading.value) return
-
- try {
- loading.value = true
-
- const response = await getToSubmitList({
- name: searchName.value,
- pageNum: pageNum.value,
- pageSize: pageSize.value
- })
-
- if (response.code === 200) {
- if (pageNum.value === 1) {
- fileList.value = response.rows || []
- } else {
- fileList.value = [...fileList.value, ...(response.rows || [])]
- }
- total.value = response.total || 0
- }
- } catch (error) {
- console.error('加载文件列表失败:', error)
- uni.showToast({
- title: t('fileSelect.message.loadFailed'),
- icon: 'none'
- })
- } finally {
- loading.value = false
- }
- }
- // 搜索
- const handleSearch = () => {
- pageNum.value = 1
- fileList.value = []
- loadFileList()
- }
- // 加载更多
- const handleLoadMore = () => {
- if (loading.value) return
- if (fileList.value.length >= total.value) return
-
- pageNum.value++
- loadFileList()
- }
- // 选择文件 - 先弹出日期选择框
- const handleSelectFile = (file) => {
- selectedFile.value = file
- selectedDate.value = ''
- showDateModal.value = true
- }
- // 关闭弹窗
- const handleCloseModal = () => {
- showDateModal.value = false
- selectedFile.value = null
- selectedDate.value = ''
- }
- // 日期选择变化
- const handleDateChange = (e) => {
- selectedDate.value = e.detail.value
- }
- // 确认日期并提交
- const handleConfirmDate = async () => {
- if (!selectedDate.value) {
- uni.showToast({
- title: t('fileSelect.message.selectDateFirst'),
- icon: 'none'
- })
- return
- }
-
- if (!selectedFile.value) {
- uni.showToast({
- title: t('fileSelect.message.noFileSelected'),
- icon: 'none'
- })
- return
- }
-
- try {
- // 从全局数据中获取扫描的fileBase64List
- const fileBase64List = getApp().globalData.scannedFileBase64List
-
- if (!fileBase64List || fileBase64List.length === 0) {
- uni.showToast({
- title: t('fileSelect.message.noScanFile'),
- icon: 'none'
- })
- return
- }
-
- // 关闭弹窗
- showDateModal.value = false
-
- uni.showLoading({
- title: t('fileSelect.message.submitting'),
- mask: true
- })
-
- // 调用上传接口
- const response = await uploadOnSubmit({
- documentId: selectedFile.value.id,
- fileBase64List: fileBase64List,
- effectiveDate: selectedDate.value
- })
-
- uni.hideLoading()
-
- if (response.code === 200) {
- // 清除全局数据
- getApp().globalData.scannedFileBase64List = null
-
- uni.showToast({
- title: t('fileSelect.message.submitSuccess'),
- icon: 'success',
- duration: 2000
- })
-
- // 返回首页
- setTimeout(() => {
- uni.reLaunch({
- url: '/pages/home/index'
- })
- }, 2000)
- } else {
- throw new Error(response.msg || '提交失败')
- }
- } catch (error) {
- uni.hideLoading()
- console.error('提交失败:', error)
- uni.showToast({
- title: t('fileSelect.message.submitFailed'),
- icon: 'none'
- })
- }
- }
- // 底部提交按钮(与点击文件相同的逻辑,但需要先选择文件)
- const handleSubmitAll = () => {
- if (fileList.value.length === 0) {
- uni.showToast({
- title: t('fileSelect.message.noAvailableFile'),
- icon: 'none'
- })
- return
- }
-
- uni.showToast({
- title: t('fileSelect.message.pleaseSelectFile'),
- icon: 'none'
- })
- }
- // 直接上传 - 跳转到项目选择页面
- const handleDirectUpload = () => {
- // 从全局数据中获取扫描的fileBase64List
- const fileBase64List = getApp().globalData.scannedFileBase64List
-
- if (!fileBase64List || fileBase64List.length === 0) {
- uni.showToast({
- title: t('fileSelect.message.noScanFile'),
- icon: 'none'
- })
- return
- }
-
- // 跳转到项目选择页面
- uni.navigateTo({
- url: '/pages/scan/projectSelect/index'
- })
- }
- // 格式化日期(只显示到天)
- const formatDate = (dateStr) => {
- if (!dateStr) return ''
- // 如果日期格式是 "2026-01-04 10:58:37",只取前10位
- return dateStr.split(' ')[0]
- }
- </script>
- <style lang="scss" scoped>
- .file-select-page {
- width: 100%;
- height: 100vh;
- display: flex;
- flex-direction: column;
- background-color: #f5f5f5;
-
- // 顶部导航栏
- .header-bg {
- background: linear-gradient(180deg, #1ec9c9 0%, #1eb8b8 100%);
- position: relative;
- z-index: 100;
-
- .header-content {
- height: 88rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 24rpx;
-
- .back-btn {
- width: 60rpx;
- height: 60rpx;
- display: flex;
- align-items: center;
- justify-content: flex-start;
-
- .back-icon {
- font-size: 56rpx;
- color: #ffffff;
- font-weight: 300;
- }
- }
-
- .header-title {
- flex: 1;
- text-align: center;
- font-size: 32rpx;
- font-weight: 600;
- color: #ffffff;
- }
-
- .placeholder {
- width: 60rpx;
- }
- }
- }
-
- // 搜索框
- .search-bar {
- padding: 24rpx;
- background: #ffffff;
- display: flex;
- gap: 16rpx;
-
- .search-input {
- flex: 1;
- height: 64rpx;
- padding: 0 24rpx;
- background: #f5f5f5;
- border-radius: 32rpx;
- font-size: 28rpx;
- }
-
- .search-btn {
- width: 120rpx;
- height: 64rpx;
- background: #1ec9c9;
- border-radius: 32rpx;
- display: flex;
- align-items: center;
- justify-content: center;
-
- &:active {
- background: #1ab8b8;
- }
-
- .search-text {
- font-size: 28rpx;
- color: #ffffff;
- font-weight: 500;
- }
- }
- }
-
- // 文件列表
- .file-list {
- flex: 1;
- background: #ffffff;
-
- .file-item {
- padding: 24rpx;
- display: flex;
- align-items: center;
- border-bottom: 1rpx solid #f5f5f5;
-
- &:active {
- background: #f8f8f8;
- }
-
- .file-icon-wrapper {
- width: 80rpx;
- height: 80rpx;
- background: #f5f5f5;
- border-radius: 12rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 24rpx;
-
- .file-icon {
- width: 48rpx;
- height: 48rpx;
- }
- }
-
- .file-info {
- flex: 1;
- display: flex;
- flex-direction: column;
- gap: 6rpx;
-
- .file-name {
- font-size: 32rpx;
- font-weight: 600;
- color: #333333;
- margin-bottom: 4rpx;
- }
-
- .file-detail {
- font-size: 26rpx;
- color: #666666;
- line-height: 1.5;
- }
- }
- }
-
- .empty-tip {
- padding: 200rpx 0;
- text-align: center;
- display: flex;
- flex-direction: column;
- gap: 16rpx;
-
- .empty-text {
- font-size: 28rpx;
- color: #999999;
- }
-
- .empty-hint {
- font-size: 26rpx;
- color: #1ec9c9;
- }
- }
-
- .loading-tip {
- padding: 32rpx 0;
- text-align: center;
-
- .loading-text {
- font-size: 28rpx;
- color: #999999;
- }
- }
- }
-
- // 底部提交按钮
- .submit-footer {
- background: #ffffff;
- padding: 24rpx 32rpx;
- padding-bottom: calc(24rpx + env(safe-area-inset-bottom));
- box-shadow: 0 -2rpx 8rpx rgba(0, 0, 0, 0.05);
- display: flex;
- gap: 16rpx;
-
- .submit-btn {
- flex: 1;
- height: 88rpx;
- background: linear-gradient(135deg, #1ec9c9 0%, #1eb8b8 100%);
- border-radius: 44rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- box-shadow: 0 4rpx 16rpx rgba(30, 201, 201, 0.3);
-
- &:active {
- transform: scale(0.98);
- opacity: 0.9;
- }
-
- &.secondary {
- background: #ffffff;
- border: 2rpx solid #1ec9c9;
- box-shadow: none;
-
- .submit-text {
- color: #1ec9c9;
- }
- }
-
- .submit-text {
- font-size: 32rpx;
- font-weight: 600;
- color: #ffffff;
- }
-
- &.full-width {
- flex: 1;
- }
- }
- }
-
- // 日期选择弹窗
- .modal-overlay {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.5);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 1000;
-
- .modal-content {
- width: 600rpx;
- background: #ffffff;
- border-radius: 24rpx;
- overflow: hidden;
-
- .modal-header {
- padding: 32rpx;
- border-bottom: 1rpx solid #f5f5f5;
-
- .modal-title {
- font-size: 32rpx;
- font-weight: 600;
- color: #333333;
- text-align: center;
- display: block;
- }
- }
-
- .modal-body {
- padding: 32rpx;
-
- .date-picker-wrapper {
- .date-display {
- background: #f5f5f5;
- border-radius: 12rpx;
- padding: 24rpx;
- display: flex;
- align-items: center;
-
- .date-label {
- font-size: 28rpx;
- color: #666666;
- margin-right: 16rpx;
- }
-
- .date-value {
- flex: 1;
- font-size: 28rpx;
- color: #333333;
-
- &.placeholder {
- color: #999999;
- }
- }
-
- .date-arrow {
- font-size: 40rpx;
- color: #999999;
- font-weight: 300;
- }
- }
- }
- }
-
- .modal-footer {
- display: flex;
- border-top: 1rpx solid #f5f5f5;
-
- .modal-btn {
- flex: 1;
- height: 88rpx;
- display: flex;
- align-items: center;
- justify-content: center;
-
- &:active {
- background: #f5f5f5;
- }
-
- &.cancel {
- border-right: 1rpx solid #f5f5f5;
-
- .modal-btn-text {
- color: #666666;
- }
- }
-
- &.confirm {
- .modal-btn-text {
- color: #1ec9c9;
- font-weight: 600;
- }
- }
-
- .modal-btn-text {
- font-size: 32rpx;
- }
- }
- }
- }
- }
- }
- </style>
|