Files
T
puddy ee46776648 feat(通联登录): 优化验证码识别与风控锁定处理,升级插件UI
- 新增双模型验证码交叉识别提升准确率
- 增加账号风控锁定检测与异常处理
- 优化登录表单字段提交适配服务端校验
- 升级两个插件的UI为卡片式分区设计
- 升级插件版本至1.0.9
2026-09-29 10:37:24 +08:00

489 lines
15 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="page">
<!-- 未登录 / 结果横幅 -->
<transition name="fade-slide">
<el-alert v-if="needLogin" type="warning" :closable="false" show-icon
title="未登录:请先在壳子(工作台)登录统一账户,再刷新本界面" />
<el-alert v-else-if="banner" :type="banner.type" :closable="true" show-icon @close="banner = null">
<template #title>{{ banner.text }}</template>
</el-alert>
</transition>
<!-- 执行配置(头部含多配置方案:方案供「定时任务」引用,到点自动取方案最新参数) -->
<el-card shadow="never" class="panel">
<template #header>
<div class="panel-head">
<div class="panel-title">
<span class="title-ico">
<svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
<polyline points="7 10 12 15 17 10" />
<line x1="12" y1="15" x2="12" y2="3" />
</svg>
</span>
<div class="title-txts">
<div class="title-txt">执行配置</div>
<div class="title-sub">参数自动保存到本机,方案供定时任务到点引用</div>
</div>
</div>
<div class="head-tools">
<span v-if="lastSavedAt" class="saved">
<i class="dot" />已保存 {{ lastSavedAt }}
</span>
<el-select v-model="schemeSel" class="scheme-sel" size="small" :disabled="running"
@change="onSchemeChange">
<el-option v-for="o in schemeOptions" :key="o.value" :label="o.label" :value="o.value" />
</el-select>
<el-button size="small" :disabled="running" @click="saveSchemeAs">存为方案</el-button>
<el-button size="small" text type="danger" :disabled="running || !schemeSel"
@click="removeScheme">删除</el-button>
</div>
</div>
</template>
<el-form label-position="top">
<!-- 登录账号 -->
<section class="sec">
<div class="sec-head">
<span class="sec-badge">01</span>
<span class="sec-name">登录账号</span>
<span class="sec-line" />
</div>
<div class="grid">
<el-form-item label="通联账号">
<el-input v-model="form.tl_username" placeholder="商户服务平台登录账号" :disabled="running" clearable />
</el-form-item>
<el-form-item label="登录密码">
<el-input v-model="form.tl_password" type="password" show-password placeholder="仅保存在本机,下次免填"
:disabled="running" />
</el-form-item>
</div>
</section>
<!-- 导出参数 -->
<section class="sec">
<div class="sec-head">
<span class="sec-badge">02</span>
<span class="sec-name">导出参数</span>
<span class="sec-line" />
</div>
<div class="grid">
<el-form-item label="执行模式">
<el-radio-group v-model="form.mode" :disabled="running">
<el-radio-button value="日">按日</el-radio-button>
<el-radio-button value="月">按月</el-radio-button>
<el-radio-button value="日+月">日 + 月</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="导出内容">
<el-radio-group v-model="form.content" :disabled="running">
<el-radio-button value="交易查询">交易查询</el-radio-button>
<el-radio-button value="账单">账单</el-radio-button>
<el-radio-button value="两个都导">两个都导</el-radio-button>
</el-radio-group>
</el-form-item>
</div>
<!-- 日期选择器(组件复用:交易查询与账单共用,插件内部按导出类型自动换算区间) -->
<div v-if="form.mode === '日+月'" class="grid">
<el-form-item label="按日导出">
<el-date-picker v-model="form.day_date" type="date" value-format="YYYY-MM-DD"
placeholder="选择日期(默认昨天)" :disabled="running"
:disabled-date="disableFuture" class="wide" />
<div class="tip">默认昨天;区间=所选日 00:00 ~ 次日 24:00(跨 2 天)</div>
</el-form-item>
<el-form-item label="按月导出">
<el-date-picker v-model="form.month_date" type="month" value-format="YYYY-MM"
placeholder="选择月份(默认上月)" :disabled="running"
:disabled-date="disableFutureMonth" class="wide" />
<div class="tip">默认上月;区间=当月1日 10:00 ~ 下月1日 10:00(对账10点切日)</div>
</el-form-item>
</div>
<el-form-item v-else-if="form.mode === '日'" label="按日导出">
<el-date-picker v-model="form.day_date" type="date" value-format="YYYY-MM-DD"
placeholder="选择日期(默认昨天)" :disabled="running"
:disabled-date="disableFuture" class="wide" />
<div class="tip">默认昨天;区间=所选日 00:00 ~ 次日 24:00(跨 2 天);账单 = 所选日账单</div>
</el-form-item>
<el-form-item v-else label="按月导出">
<el-date-picker v-model="form.month_date" type="month" value-format="YYYY-MM"
placeholder="选择月份(默认上月)" :disabled="running"
:disabled-date="disableFutureMonth" class="wide" />
<div class="tip">默认上月;区间=当月1日 10:00 ~ 下月1日 10:00(对账10点切日);账单 = 该月账单</div>
</el-form-item>
<el-form-item label="保存目录">
<el-input v-model="form.save_dir" :disabled="running" clearable
placeholder="留空 = 桌面/金色印象通联数据_今天日期" />
<div class="tip">交易查询=每日期一份账号全量文件(日_日期.xlsx / 月_月份.xlsx,含全部商户);账单=按 账单_YYYYMM 目录存放</div>
</el-form-item>
</section>
<!-- 操作 -->
<div class="actions">
<el-button type="primary" size="large" class="btn-run" :loading="running" @click="run">
{{ running ? '执行中 ' + progress + '%' : '一键执行' }}
</el-button>
<el-button v-if="running" type="danger" size="large" plain :loading="stopping"
@click="forceStop">强制停止</el-button>
<span class="spacer" />
<el-button size="large" :disabled="running" @click="saveNow(true)">保存配置</el-button>
<el-button size="large" text :disabled="running" @click="resetDefaults">恢复默认</el-button>
</div>
</el-form>
</el-card>
<!-- 运行状态 -->
<transition name="fade-slide">
<div v-if="running" class="status">
<el-progress :percentage="progress" :stroke-width="10" :show-text="false" class="status-bar" />
<div class="status-row">
<span class="pulse" />
<span class="status-txt">正在执行,日志与进度实时显示在工作台下方【运行日志】区</span>
<span class="status-pct">{{ progress }}%</span>
</div>
</div>
</transition>
</div>
</template>
<script setup>
import { ElMessage } from 'element-plus'
import { usePluginUI } from './usePluginUI'
function fmtDate(d) {
const y = d.getFullYear()
const m = String(d.getMonth() + 1).padStart(2, '0')
const day = String(d.getDate()).padStart(2, '0')
return `${y}-${m}-${day}`
}
function fmtMonth(d) {
const y = d.getFullYear()
const m = String(d.getMonth() + 1).padStart(2, '0')
return `${y}-${m}`
}
function lastMonthStr(now) {
const d = new Date(now.getFullYear(), now.getMonth() - 1, 1)
return fmtMonth(d)
}
function yesterdayStr(now) {
const d = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1)
return fmtDate(d)
}
const DEFAULTS = () => {
const now = new Date()
return {
mode: '日+月',
content: '两个都导',
day_date: yesterdayStr(now), // 默认昨天
month_date: lastMonthStr(now), // 默认上月
tl_username: '',
tl_password: '',
save_dir: '',
}
}
function disableFuture(date) {
return date.getTime() > Date.now() + 86400000 // 今天及以前可选
}
function disableFutureMonth(date) {
const now = new Date()
return date.getTime() > new Date(now.getFullYear(), now.getMonth() + 1, 1).getTime()
}
const {
form, needLogin, banner, lastSavedAt, running, progress, stopping,
saveNow, resetDefaults,
schemeSel, schemeOptions, onSchemeChange, saveSchemeAs, removeScheme,
run, forceStop,
} = usePluginUI({
defaults: DEFAULTS,
validate() {
if (!form.tl_username.trim() || !form.tl_password) {
ElMessage.warning('请先填写通联登录账号和密码')
return false
}
if (form.mode !== '月' && !form.day_date) { ElMessage.warning('请选择按日导出的日期'); return false }
if (form.mode !== '日' && !form.month_date) { ElMessage.warning('请选择按月导出的月份'); return false }
return true
},
// 提交参数按执行模式裁剪:按日不带月份、按月不带日期
buildPayload(f) {
return {
mode: f.mode,
content: f.content,
day_date: f.mode === '月' ? '' : f.day_date,
month_date: f.mode === '日' ? '' : f.month_date,
tl_username: f.tl_username,
tl_password: f.tl_password,
save_dir: f.save_dir,
}
},
})
</script>
<style scoped>
/* ---------- 页面骨架 ---------- */
.page {
width: 100%;
padding: 6px 4px 28px;
display: flex;
flex-direction: column;
gap: 14px;
}
.fade-slide-enter-active,
.fade-slide-leave-active {
transition: opacity 0.25s ease, transform 0.25s ease;
}
.fade-slide-enter-from,
.fade-slide-leave-to {
opacity: 0;
transform: translateY(-6px);
}
/* ---------- 主容器(无边框平铺:外层由壳子 iframe 的边框统一包裹) ---------- */
.panel {
background: transparent;
border-radius: 0;
border: none;
box-shadow: none;
overflow: hidden;
}
.panel :deep(.el-card__header) {
padding: 6px 2px 16px;
border-bottom: 1px solid var(--el-border-color-lighter);
background: transparent;
}
.panel :deep(.el-card__body) {
padding: 16px 2px 2px;
}
/* ---------- 卡片头部 ---------- */
.panel-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
flex-wrap: wrap;
}
.panel-title {
display: flex;
align-items: center;
gap: 12px;
}
.title-ico {
width: 36px;
height: 36px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
color: var(--el-color-primary);
background: linear-gradient(135deg, var(--el-color-primary-light-8), var(--el-color-primary-light-6));
box-shadow: inset 0 0 0 1px var(--el-color-primary-light-5);
flex-shrink: 0;
}
.title-txts {
display: flex;
flex-direction: column;
gap: 2px;
}
.title-txt {
font-weight: 700;
font-size: 15px;
line-height: 1.2;
color: var(--el-text-color-primary);
}
.title-sub {
font-size: 12px;
color: var(--el-text-color-secondary);
line-height: 1.3;
}
.head-tools {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.scheme-sel {
width: 200px;
}
.saved {
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 12px;
color: #2ea44f;
background: rgba(46, 164, 79, 0.1);
border: 1px solid rgba(46, 164, 79, 0.25);
padding: 2px 10px;
border-radius: 999px;
white-space: nowrap;
}
.saved .dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: #2ea44f;
}
/* ---------- 表单分区 ---------- */
.sec {
margin-bottom: 20px;
}
.sec:last-of-type {
margin-bottom: 4px;
}
.sec-head {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 14px;
}
.sec-badge {
width: 24px;
height: 24px;
border-radius: 7px;
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 12px;
font-weight: 700;
color: var(--el-color-primary);
background: var(--el-color-primary-light-9);
border: 1px solid var(--el-color-primary-light-7);
flex-shrink: 0;
}
.sec-name {
font-size: 14px;
font-weight: 600;
color: var(--el-text-color-primary);
white-space: nowrap;
}
.sec-line {
flex: 1;
height: 1px;
background: linear-gradient(90deg, var(--el-border-color-lighter), transparent);
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 0 18px;
}
.grid :deep(.el-form-item) {
margin-bottom: 0;
}
.grid :deep(.el-form-item__label) {
padding-bottom: 6px;
font-weight: 500;
}
.grid :deep(.el-date-editor) {
width: 100%;
}
.wide {
width: 100%;
}
.tip {
width: 100%;
font-size: 12px;
color: var(--el-text-color-secondary);
line-height: 1.6;
margin-top: 6px;
}
/* ---------- 操作区 ---------- */
.actions {
display: flex;
align-items: center;
gap: 10px;
border-top: 1px dashed var(--el-border-color);
padding-top: 18px;
margin-top: 18px;
}
.spacer {
flex: 1;
}
.btn-run {
min-width: 150px;
border: none;
border-radius: 10px;
letter-spacing: 2px;
background: linear-gradient(135deg, var(--el-color-primary), var(--el-color-primary-dark-2));
box-shadow: 0 6px 16px var(--el-color-primary-light-6);
transition: filter 0.2s, box-shadow 0.2s, transform 0.15s;
}
.btn-run:hover {
filter: brightness(1.06);
box-shadow: 0 8px 20px var(--el-color-primary-light-5);
transform: translateY(-1px);
}
.btn-run:active {
transform: translateY(0);
}
.btn-run.is-loading {
pointer-events: none;
}
/* ---------- 运行状态 ---------- */
.status {
padding: 14px 16px;
border-radius: 12px;
background: linear-gradient(135deg, var(--el-color-primary-light-9), var(--el-color-primary-light-8));
border: 1px solid var(--el-color-primary-light-6);
box-shadow: 0 2px 10px var(--el-color-primary-light-7);
}
.status-bar :deep(.el-progress-bar__outer) {
background: rgba(64, 158, 255, 0.15);
}
.status-bar :deep(.el-progress-bar__inner) {
background: linear-gradient(90deg, var(--el-color-primary), var(--el-color-primary-dark-2));
}
.status-row {
display: flex;
align-items: center;
gap: 8px;
margin-top: 8px;
}
.pulse {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--el-color-primary);
animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse {
0% {
box-shadow: 0 0 0 0 var(--el-color-primary-light-6);
}
70% {
box-shadow: 0 0 0 8px transparent;
}
100% {
box-shadow: 0 0 0 0 transparent;
}
}
.status-txt {
flex: 1;
font-size: 12.5px;
color: var(--el-text-color-regular);
line-height: 1.5;
}
.status-pct {
font-size: 14px;
font-weight: 700;
color: var(--el-color-primary);
font-variant-numeric: tabular-nums;
}
</style>