feat: 限制序号最多相差10
This commit is contained in:
@@ -271,6 +271,7 @@ export default {
|
||||
range: 'Set the download range',
|
||||
startIndex:'start ID',
|
||||
endIndex:'end ID',
|
||||
download: 'Download'
|
||||
download: 'Download',
|
||||
limit:'Maximum 10 entries can be downloaded at once'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,6 +260,7 @@ export default {
|
||||
range: '设定下载区间',
|
||||
startIndex: '起始序号',
|
||||
endIndex: '结束序号',
|
||||
download: '下载'
|
||||
download: '下载',
|
||||
limit:'一次最多下载10条数据'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import router from '@/router/index'
|
||||
import { getCookie, clonAllCookie } from '@/utils/cookie'
|
||||
// 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/json'
|
||||
|
||||
|
||||
@@ -28,8 +28,13 @@
|
||||
<input v-model.number="range.end" type="number" :placeholder="maxIndex" min="1" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button v-loading="fileDownloading" @click="handleDownload" :disabled="!isValid" class="download-btn">
|
||||
<div class="tips">{{ $t('Preview.limit') }}</div>
|
||||
<button
|
||||
v-loading="fileDownloading"
|
||||
@click="handleDownload"
|
||||
:disabled="!isValid"
|
||||
class="download-btn"
|
||||
>
|
||||
<span class="btn-text">{{ $t('Preview.download') }}</span>
|
||||
</button>
|
||||
|
||||
@@ -42,7 +47,7 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { Https } from '@/utils/request'
|
||||
import { debounce } from 'lodash-es'
|
||||
import { debounce, subtract } from 'lodash-es'
|
||||
|
||||
// 模拟已提交人数
|
||||
const submittedCount = ref(0)
|
||||
@@ -63,8 +68,15 @@ const handleFetchSubmittedCount = async () => {
|
||||
// 逻辑判断:区间是否合法
|
||||
const isValid = computed(() => {
|
||||
const { start, end } = range.value
|
||||
// 必须是数字,且起始>0,结束>=起始,结束不超过当前总数
|
||||
return start !== null && end !== null && start > 0 && end >= start && end <= maxIndex.value
|
||||
// 必须是数字,且起始>0,结束>=起始,结束不超过当前总数,相差不超过10
|
||||
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 < 10000) return '起始序号必须大于 10000'
|
||||
if (end < start) return '结束序号不能小于起始序号'
|
||||
if (subtract(end, start) > 10) return '起始序号和结束序号相差不能超过10'
|
||||
if (end > maxIndex.value) return `结束序号不能超过最大值 ${maxIndex.value}`
|
||||
return ''
|
||||
})
|
||||
@@ -229,7 +242,7 @@ onMounted(() => {
|
||||
.input-group {
|
||||
display: flex;
|
||||
gap: 1.6rem;
|
||||
margin-bottom: 2.4rem;
|
||||
margin-bottom: 1.2rem;
|
||||
}
|
||||
|
||||
.field {
|
||||
@@ -261,7 +274,11 @@ onMounted(() => {
|
||||
border-color: #6c5ce7;
|
||||
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 {
|
||||
width: 100%;
|
||||
|
||||
Reference in New Issue
Block a user