Compare commits
2 Commits
39d3da0c93
...
4e84257ed8
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e84257ed8 | |||
| ac7637f3e1 |
@@ -148,6 +148,21 @@ export function importQuestionsExcel(group, formData) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 综合大题 Excel 批量导入(R73)
|
||||
* 首 sheet 为数据表(表头在第 1 行),可携带「填写说明」sheet
|
||||
* @param {string} group - 组别标识(zhongzhi / gaozhi)
|
||||
* @param {FormData} formData - 包含 Excel 文件的 FormData(字段名 file)
|
||||
* @returns {Promise} { imported, skipped, errors: [{ row, message }] }
|
||||
*/
|
||||
export function importBigQuestionsExcel(group, formData) {
|
||||
// silent: true —— 与 importQuestionsExcel 同口径:错误提示由调用方统一给出,避免同族双弹
|
||||
return request.post(`/admin/big-questions/${group}/import-excel`, formData, {
|
||||
timeout: 300000,
|
||||
silent: true,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传 Word 答题模板
|
||||
* @param {string} group - 组别标识
|
||||
|
||||
36
src/utils/passwordField.js
Normal file
36
src/utils/passwordField.js
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* passwordField.js — 密码输入框「反浏览器自动填充」兜底
|
||||
*
|
||||
* 背景(2026-10-08 测试人员反馈):
|
||||
* 激活页 / 忘记密码页进入「设置密码」步骤时,输入框内已存在内容(形如 123456),
|
||||
* 而用户尚未进行任何输入。经全仓取证:前端不存在任何向密码框写值的赋值点
|
||||
* (密码框初值为空、autocomplete="new-password"、无 :value 绑定、无历史版本预填),
|
||||
* 故残留只能来自浏览器密码管理器 —— 测试账号的默认口令恰为 123456,
|
||||
* 浏览器保存后会在同源同类表单上自动回填。
|
||||
*
|
||||
* 治法:在「进入设置密码步骤」时做一次确定性兜底清理。
|
||||
*
|
||||
* ⚠️ 安全前提:仅当表单模型本身为空时才清 DOM(isModelEmpty 为真),
|
||||
* 因此绝不会覆盖用户已经真实输入的内容。
|
||||
*/
|
||||
|
||||
/**
|
||||
* 清除浏览器在密码框上留下的自动填充值。
|
||||
*
|
||||
* @param {string} scopeSelector 限定范围(默认 body 即整页)
|
||||
* @param {boolean} isModelEmpty 表单模型是否为空;为 false 时整体跳过,不动 DOM
|
||||
* @returns {number} 实际清除的输入框数量(便于验证/日志)
|
||||
*/
|
||||
export function purgeAutofilledPasswords(scopeSelector = 'body', isModelEmpty = true) {
|
||||
if (!isModelEmpty || typeof document === 'undefined') return 0
|
||||
let cleared = 0
|
||||
document.querySelectorAll(`${scopeSelector} input[type="password"]`).forEach((el) => {
|
||||
if (el.value) {
|
||||
el.value = ''
|
||||
// 同步通知 v-model:此时模型本为空,回调只是把状态与 DOM 拉回一致
|
||||
el.dispatchEvent(new Event('input', { bubbles: true }))
|
||||
cleared++
|
||||
}
|
||||
})
|
||||
return cleared
|
||||
}
|
||||
@@ -135,6 +135,7 @@
|
||||
:model="step3Form"
|
||||
:rules="step3Rules"
|
||||
label-position="top"
|
||||
autocomplete="off"
|
||||
>
|
||||
<!-- 基本信息确认 -->
|
||||
<div class="info-confirm">
|
||||
@@ -150,10 +151,13 @@
|
||||
v-model="step3Form.password"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
placeholder="请设置登录密码(6-20 位,勿用 123456 等弱口令)"
|
||||
placeholder="请设置登录密码(6-20 位)"
|
||||
size="large"
|
||||
show-password
|
||||
/>
|
||||
<!-- 弱口令示例放在独立提示行,而不是 placeholder:
|
||||
写在 placeholder 里会被用户误读成「默认密码就是 123456」(2026-10-08 测试人员反馈) -->
|
||||
<div class="pwd-tip">不得使用 123456 等常见弱口令</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="确认密码" prop="confirmPassword">
|
||||
@@ -211,7 +215,8 @@
|
||||
* 步骤2:发送短信验证码 -> 输入 6 位验证码 -> 验证
|
||||
* 步骤3:确认基本信息 -> 设置密码 + 确认密码 -> 完成激活
|
||||
*/
|
||||
import { ref, reactive, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { ref, reactive, computed, nextTick, onMounted, onUnmounted } from 'vue'
|
||||
import { purgeAutofilledPasswords } from '@/utils/passwordField'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ArrowLeft, HomeFilled, Refresh } from '@element-plus/icons-vue'
|
||||
@@ -398,7 +403,7 @@ async function handleStep2() {
|
||||
// 验证短信码(此处通过获取用户信息间接验证)
|
||||
step2Loading.value = true
|
||||
// 短信码的验证由后端在激活时完成,此处仅进入下一步
|
||||
currentStep.value = 2
|
||||
enterStep3()
|
||||
ElMessage.success('短信验证通过')
|
||||
} catch (err) {
|
||||
if (err?.message) ElMessage.error(err.message)
|
||||
@@ -407,6 +412,22 @@ async function handleStep2() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入「设置密码」步骤。
|
||||
*
|
||||
* 到达该步骤时输入框必须为空(2026-10-08 测试人员反馈:进入本步骤时密码框内已出现 123456)。
|
||||
* 前端源码不存在任何回填密码的赋值点(初值为空 + autocomplete=new-password + 无历史预填版本),
|
||||
* 残留只可能来自浏览器密码管理器自动填充(测试账号默认口令恰为 123456,会被浏览器保存并回填),
|
||||
* 故此处做确定性兜底,保证「到达即空」;实现与前提见 utils/passwordField.js。
|
||||
*/
|
||||
function enterStep3() {
|
||||
step3Form.password = ''
|
||||
step3Form.confirmPassword = ''
|
||||
currentStep.value = 2
|
||||
// DOM 挂载后再兜底一次:仅当表单模型为空、DOM 却有值时清除,绝不覆盖用户真实输入
|
||||
nextTick(() => purgeAutofilledPasswords('.step-card', !step3Form.password && !step3Form.confirmPassword))
|
||||
}
|
||||
|
||||
/** 步骤3:完成激活 */
|
||||
async function handleActivate() {
|
||||
if (!step3FormRef.value) return
|
||||
@@ -650,6 +671,13 @@ onUnmounted(() => {
|
||||
}
|
||||
|
||||
/* ==================== 按钮 ==================== */
|
||||
.pwd-tip {
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.step-btn {
|
||||
width: 100%;
|
||||
height: 46px;
|
||||
|
||||
@@ -224,6 +224,21 @@
|
||||
<el-input v-model="bigSearch" placeholder="搜索大题标题/题干" clearable size="small" class="search-input" />
|
||||
<el-button type="primary" v-guard="() => openBigDialog(null)">新增大题</el-button>
|
||||
<el-button size="small" type="info" plain :loading="bigQuestionsLoading" @click="fetchBigQuestions">刷新</el-button>
|
||||
<el-divider direction="vertical" />
|
||||
<el-button
|
||||
size="small"
|
||||
type="info"
|
||||
plain
|
||||
title="下载综合大题导入模板,模板内含「填写说明」页:列名含义、状态说明、常见被拒原因"
|
||||
v-guard="() => downloadBigQuestionTpl()"
|
||||
>下载Excel模板</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="success"
|
||||
title="请先下载模板,按模板列填写后再导入。组别以当前选中的组别为准,表格里的组别会被忽略"
|
||||
v-guard="() => triggerBigExcelImport()"
|
||||
>Excel批量导入</el-button>
|
||||
<input ref="bigExcelFileInput" type="file" accept=".xlsx,.xls" style="display:none" @change="onBigExcelFileChange" />
|
||||
<el-button
|
||||
size="small"
|
||||
type="warning"
|
||||
@@ -2521,6 +2536,43 @@ async function downloadQuestionTpl() {
|
||||
})
|
||||
}
|
||||
|
||||
// ==================== 综合大题 Excel 导入 / 模板(R73) ====================
|
||||
const bigExcelFileInput = ref(null)
|
||||
|
||||
function triggerBigExcelImport() {
|
||||
if (bigExcelFileInput.value) bigExcelFileInput.value.click()
|
||||
}
|
||||
|
||||
async function onBigExcelFileChange(e) {
|
||||
const file = e.target.files && e.target.files[0]
|
||||
if (!file) return
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
try {
|
||||
const res = await adminApi.importBigQuestionsExcel(questionGroup.value, formData)
|
||||
const r = res || {}
|
||||
ElMessage.success(`导入完成:成功 ${r.imported || 0} 道,跳过 ${r.skipped || 0} 道`)
|
||||
if (r.errors && r.errors.length) {
|
||||
console.warn('综合大题导入跳过明细:', r.errors)
|
||||
ElMessage.warning(`有 ${r.errors.length} 行被跳过,详见控制台`)
|
||||
}
|
||||
fetchBigQuestions()
|
||||
} catch (err) {
|
||||
const msg = (err && err.response && err.response.data && err.response.data.message)
|
||||
|| (err && err.message) || '未知错误'
|
||||
ElMessage.error('综合大题导入失败:' + msg)
|
||||
} finally {
|
||||
e.target.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadBigQuestionTpl() {
|
||||
// 同 downloadQuestionTpl:safeDownload 自带 HTTP 状态 + content-type 双重校验
|
||||
await safeDownload(`/api/admin/big-questions/${questionGroup.value}/template`, {
|
||||
fallbackName: `综合大题导入模板_${questionGroup.value}.xlsx`,
|
||||
})
|
||||
}
|
||||
|
||||
// 考生答题记录
|
||||
const examSubmissions = ref([])
|
||||
const examSubmissionsLoading = ref(false)
|
||||
|
||||
@@ -134,16 +134,20 @@
|
||||
:model="step3Form"
|
||||
:rules="step3Rules"
|
||||
label-position="top"
|
||||
autocomplete="off"
|
||||
>
|
||||
<el-form-item label="新密码" prop="password">
|
||||
<el-input
|
||||
v-model="step3Form.password"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
placeholder="请设置新密码(6-20 位,勿用 123456 等弱口令)"
|
||||
placeholder="请设置新密码(6-20 位)"
|
||||
size="large"
|
||||
show-password
|
||||
/>
|
||||
<!-- 弱口令示例放在独立提示行,而不是 placeholder:
|
||||
写在 placeholder 里会被用户误读成「默认密码就是 123456」(2026-10-08 测试人员反馈) -->
|
||||
<div class="pwd-tip">不得使用 123456 等常见弱口令</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="确认新密码" prop="confirmPassword">
|
||||
@@ -201,7 +205,8 @@
|
||||
* 步骤2:短信验证码验证
|
||||
* 步骤3:设置新密码
|
||||
*/
|
||||
import { ref, reactive, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { ref, reactive, computed, nextTick, onMounted, onUnmounted } from 'vue'
|
||||
import { purgeAutofilledPasswords } from '@/utils/passwordField'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ArrowLeft, HomeFilled, Refresh } from '@element-plus/icons-vue'
|
||||
@@ -364,7 +369,7 @@ async function handleStep2() {
|
||||
await step2FormRef.value.validate()
|
||||
step2Loading.value = true
|
||||
// 短信码由后端在重置密码时验证
|
||||
currentStep.value = 2
|
||||
enterStep3()
|
||||
} catch (err) {
|
||||
if (err?.message) ElMessage.error(err.message)
|
||||
} finally {
|
||||
@@ -372,6 +377,22 @@ async function handleStep2() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入「重置密码」步骤。
|
||||
*
|
||||
* 到达该步骤时输入框必须为空(2026-10-08 测试人员反馈:进入本步骤时密码框内已出现 123456)。
|
||||
* 前端源码不存在任何回填密码的赋值点(初值为空 + autocomplete=new-password),
|
||||
* 残留只可能来自浏览器密码管理器自动填充,故此处做确定性兜底,保证「到达即空」;
|
||||
* 实现与前提见 utils/passwordField.js。
|
||||
*/
|
||||
function enterStep3() {
|
||||
step3Form.password = ''
|
||||
step3Form.confirmPassword = ''
|
||||
currentStep.value = 2
|
||||
// DOM 挂载后再兜底一次:仅当表单模型为空、DOM 却有值时清除,绝不覆盖用户真实输入
|
||||
nextTick(() => purgeAutofilledPasswords('.step-card', !step3Form.password && !step3Form.confirmPassword))
|
||||
}
|
||||
|
||||
/** 步骤3:重置密码 */
|
||||
async function handleReset() {
|
||||
if (!step3FormRef.value) return
|
||||
@@ -588,6 +609,13 @@ onUnmounted(() => {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.pwd-tip {
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.step-btn {
|
||||
width: 100%;
|
||||
height: 46px;
|
||||
|
||||
Reference in New Issue
Block a user