支持粘贴多只股票名称并明确输入提示

This commit is contained in:
baobao 2026-11-03 12:33:10 +08:00
parent 9d1035cec7
commit fa8f997c54
2 changed files with 23 additions and 6 deletions

View File

@ -693,7 +693,7 @@ make changes # 页面同款结论
## 2026-11-03 补充:在选股计划中添加关注股票
PMS 在原选股计划抽屉提供“添加股票”。支持按名称或代码搜索、批量输入沪深 A 股代码、填写理由和关注截止日。北交所在登记入口排除。同一股票的有效登记不重复创建,移除和到期保留历史;不会由此生成卖出或撤单命令。
PMS 在原选股计划抽屉提供“添加股票”。支持按名称或代码搜索、批量输入沪深 A 股完整名称或代码、填写理由和关注截止日。名称来自上市证券基础表,精确匹配后统一保存代码;模糊或重名输入需先选择搜索结果或改用代码,整批校验通过后才保存。北交所在资料读取和登记入口排除。同一股票的有效登记不重复创建,移除和到期保留历史;不会由此生成卖出或撤单命令。
| 上游接口 | 用途 |
| --- | --- |

View File

@ -2596,10 +2596,11 @@ body.dock-r:not(.r-fold) .side-r .strip{display:none;}
<el-form-item label="股票">
<el-select v-model="planAdd.codes" multiple filterable remote :allow-create="!planSearchBusy && !planSearchRows.length" default-first-option
:remote-method="searchPlanStocks" :loading="planSearchBusy" :reserve-keyword="false"
placeholder="搜索名称或代码,也可输入代码后回车" :disabled="planUserBusy">
@change="changePlanStocks" @paste="pastePlanStocks"
placeholder="搜索或粘贴股票名称、代码" :disabled="planUserBusy">
<el-option v-for="r in planSearchRows" :key="r.code" :value="r.code" :label="r.name+' '+r.code"></el-option>
</el-select>
<div class="muted" style="margin-top:5px">仅支持沪深 A 股。批量代码可用空格或逗号分隔,每次最多 30 只。</div>
<div class="muted" style="margin-top:5px">仅支持沪深 A 股。可批量粘贴完整名称或代码,用空格、逗号或换行分隔,每次最多 30 只。</div>
</el-form-item>
<el-form-item label="添加理由">
<el-input v-model="planAdd.reason" type="textarea" :rows="2" maxlength="300" show-word-limit
@ -2956,6 +2957,19 @@ createApp({
if (!planUserWritable.value) planAddError.value=planUserError.value||'添加功能尚未启用,请联系管理员';
}
let planSearchSerial=0;
const splitPlanStocks = values => [...new Set(values.flatMap(x=>String(x).trim().split(/[\s,,;;、]+/)).filter(Boolean))];
function changePlanStocks(values) {
planAdd.codes=splitPlanStocks(values);
planAddError.value='';
}
function pastePlanStocks(event) {
if(planUserBusy.value)return;
const values=splitPlanStocks([event.clipboardData?.getData('text')||'']);
if(values.length<2)return;
event.preventDefault();
changePlanStocks([...planAdd.codes,...values]);
++planSearchSerial; planSearchRows.value=[]; planSearchBusy.value=false;
}
async function searchPlanStocks(q) {
const serial=++planSearchSerial;
if (!q || !q.trim()) { planSearchRows.value=[]; planSearchBusy.value=false; return; }
@ -2966,14 +2980,17 @@ createApp({
}
async function submitPlanAdd() {
if(planUserBusy.value)return;
const codes=[...new Set(planAdd.codes.flatMap(x=>String(x).trim().split(/[\s,,;;]+/)).filter(Boolean))];
const codes=splitPlanStocks(planAdd.codes);
if(!codes.length || codes.length>30){planAddError.value='请选择 1 至 30 只股票';return;}
if(!planAdd.reason.trim()){planAddError.value='请填写添加理由';return;}
if(!planAdd.expires_on){planAddError.value='请选择关注截止日期';return;}
planUserBusy.value=true; planAddError.value='';
try {
const d=await call('post','/api/plan/user-candidates',{codes,reason:planAdd.reason.trim(),expires_on:planAdd.expires_on});
if(!d||!d.ok){planAddError.value=(d||{}).error||'添加未完成,请刷新列表核对';return;}
if(!d||!d.ok){
const message=String((d||{}).error||'添加未完成,请刷新列表核对');
planAddError.value=message.startsWith('ValueError:') ? message.slice(11).trim() : message; return;
}
ElementPlus.ElMessage.success(d.added ? '已保存,等待更新评估' : '所选股票已在关注中');
planAdd.codes=[];planAdd.reason='';planAddOpen.value=false;
await loadPlanUsers();
@ -5286,7 +5303,7 @@ createApp({
loadPlan, openPlan, refreshPlan,
planAddOpen, planUserBusy, planAddError, planUserError, planUserRows, planUserHistory,
planUserShown, planUserActiveCount, planUserState, planUserDetail, planDateDisabled,
planSearchRows, planSearchBusy, planAdd, openPlanAdd, searchPlanStocks, submitPlanAdd, removePlanUser,
planSearchRows, planSearchBusy, planAdd, openPlanAdd, searchPlanStocks, changePlanStocks, pastePlanStocks, submitPlanAdd, removePlanUser,
techStatus, techChipText, techChipCls,
chgRaw, chgSt, chgLoading, chgTab, chg, chgHeld, chgLog, chgRevised, chgWatch,
loadChanges,