feat: 限制序号最多相差10

This commit is contained in:
2026-04-13 17:34:08 +08:00
parent 18c5ad9521
commit 309cf49a54
4 changed files with 29 additions and 10 deletions

View File

@@ -271,6 +271,7 @@ export default {
range: 'Set the download range', range: 'Set the download range',
startIndex:'start ID', startIndex:'start ID',
endIndex:'end ID', endIndex:'end ID',
download: 'Download' download: 'Download',
limit:'Maximum 10 entries can be downloaded at once'
} }
} }

View File

@@ -260,6 +260,7 @@ export default {
range: '设定下载区间', range: '设定下载区间',
startIndex: '起始序号', startIndex: '起始序号',
endIndex: '结束序号', endIndex: '结束序号',
download: '下载' download: '下载',
limit:'一次最多下载10条数据'
} }
} }

View File

@@ -5,7 +5,7 @@ import router from '@/router/index'
import { getCookie, clonAllCookie } from '@/utils/cookie' import { getCookie, clonAllCookie } from '@/utils/cookie'
// import cookie from '@/tools/cookie.js' // import cookie from '@/tools/cookie.js'
axios.defaults.timeout = 60000 //响应时间 axios.defaults.timeout = 600000 //响应时间
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; //配置请求头 // axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; //配置请求头
axios.defaults.headers.post['Content-Type'] = 'application/json' axios.defaults.headers.post['Content-Type'] = 'application/json'

View File

@@ -28,8 +28,13 @@
<input v-model.number="range.end" type="number" :placeholder="maxIndex" min="1" /> <input v-model.number="range.end" type="number" :placeholder="maxIndex" min="1" />
</div> </div>
</div> </div>
<div class="tips">{{ $t('Preview.limit') }}</div>
<button v-loading="fileDownloading" @click="handleDownload" :disabled="!isValid" class="download-btn"> <button
v-loading="fileDownloading"
@click="handleDownload"
:disabled="!isValid"
class="download-btn"
>
<span class="btn-text">{{ $t('Preview.download') }}</span> <span class="btn-text">{{ $t('Preview.download') }}</span>
</button> </button>
@@ -42,7 +47,7 @@
<script setup> <script setup>
import { ref, computed, onMounted } from 'vue' import { ref, computed, onMounted } from 'vue'
import { Https } from '@/utils/request' import { Https } from '@/utils/request'
import { debounce } from 'lodash-es' import { debounce, subtract } from 'lodash-es'
// 模拟已提交人数 // 模拟已提交人数
const submittedCount = ref(0) const submittedCount = ref(0)
@@ -63,8 +68,15 @@ const handleFetchSubmittedCount = async () => {
// 逻辑判断:区间是否合法 // 逻辑判断:区间是否合法
const isValid = computed(() => { const isValid = computed(() => {
const { start, end } = range.value const { start, end } = range.value
// 必须是数字,且起始>0结束>=起始,结束不超过当前总数 // 必须是数字,且起始>0结束>=起始,结束不超过当前总数相差不超过10
return start !== null && end !== null && start > 0 && end >= start && end <= maxIndex.value return (
start !== null &&
end !== null &&
start > 0 &&
end >= start &&
end <= maxIndex.value &&
subtract(end, start) <= 10
)
}) })
// 错误提示文案 // 错误提示文案
@@ -73,6 +85,7 @@ const errorMsg = computed(() => {
if (start === null || end === null) return '' if (start === null || end === null) return ''
if (start < 10000) return '起始序号必须大于 10000' if (start < 10000) return '起始序号必须大于 10000'
if (end < start) return '结束序号不能小于起始序号' if (end < start) return '结束序号不能小于起始序号'
if (subtract(end, start) > 10) return '起始序号和结束序号相差不能超过10'
if (end > maxIndex.value) return `结束序号不能超过最大值 ${maxIndex.value}` if (end > maxIndex.value) return `结束序号不能超过最大值 ${maxIndex.value}`
return '' return ''
}) })
@@ -229,7 +242,7 @@ onMounted(() => {
.input-group { .input-group {
display: flex; display: flex;
gap: 1.6rem; gap: 1.6rem;
margin-bottom: 2.4rem; margin-bottom: 1.2rem;
} }
.field { .field {
@@ -261,7 +274,11 @@ onMounted(() => {
border-color: #6c5ce7; border-color: #6c5ce7;
box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.1); box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.1);
} }
.tips{
text-align: center;
margin-bottom: 1.2rem;
font-size: 1.4rem;
}
/* 按钮逻辑 */ /* 按钮逻辑 */
.download-btn { .download-btn {
width: 100%; width: 100%;