feat: 更新3个插件版本并优化XQ0006考勤异常处理逻辑
- XQ0036门店员工起调薪处理:版本升至0.1.6,优化纳税单位解析逻辑,优先使用接口返回值,新增金色印象、金色湖畔、后浪会馆的纳税单位兜底规则 - XQ0047微盟数据导出:版本升至1.0.5,新增等待生成上限配置项,优化轮询超时处理逻辑 - XQ0006 EHR系统周考勤异常处理:版本升至1.4.1,重构推送逻辑,支持组织架构范围选择,新增dws推送通道,优化自动确认范围为整月轻微异常,新增组织架构同步功能
This commit is contained in:
@@ -75,8 +75,8 @@
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<el-tooltip placement="top"
|
||||
content="对查询范围内全部异常(不再只限迟到/早退<30 分钟)批量调用确认接口,接口按批次提交">
|
||||
<span class="lbl">自动确认(全量)</span>
|
||||
content="对整月轻微异常(迟到/早退<30 分钟,不分职能序列)批量调用确认接口;严重异常只推送不确认">
|
||||
<span class="lbl">自动确认(轻微)</span>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<el-switch v-model="form.auto_confirm" :disabled="running || form.dry_run" />
|
||||
@@ -84,7 +84,7 @@
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<el-tooltip placement="top"
|
||||
content="推送上周职能序列及下方推送范围单位的严重异常给当事人,并把条数汇总推送到钉钉群;消息内容与影刀版一致">
|
||||
content="推送上周组织架构所选范围的严重异常给当事人,并把条数汇总推送到钉钉群;消息内容与影刀版一致">
|
||||
<span class="lbl">钉钉推送</span>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
@@ -92,10 +92,11 @@
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="tip">
|
||||
自动确认会<b>真正提交</b>到 EHR(范围=本次查询到的全部异常),关闭则只导出与统计。
|
||||
自动确认会<b>真正提交</b>到 EHR(范围=整月轻微异常:迟到/早退 < 30 分钟,不分职能序列),
|
||||
关闭则只导出与统计。
|
||||
<b>试算模式</b>只出表:不确认、不推送,用于核对数据。
|
||||
钉钉推送口径:仅上周严重异常,覆盖职能序列 + 推送范围单位
|
||||
(部门路径不含排除关键字),按人合并推送,当事人需 2 日内对接人事处理。
|
||||
钉钉推送口径:仅上周严重异常,覆盖组织架构所选范围(含下级),
|
||||
按人合并推送,当事人需 2 日内对接人事处理。
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
@@ -111,36 +112,60 @@
|
||||
</div>
|
||||
<div class="sec-body">
|
||||
<el-form label-position="top">
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<span class="lbl">推送范围(组织架构)</span>
|
||||
<span v-if="orgMeta.count" class="org-meta">
|
||||
组织架构 {{ orgMeta.count }} 个节点<template v-if="orgMeta.fetched_at"> · 同步于 {{ orgMeta.fetched_at }}</template>
|
||||
</span>
|
||||
</template>
|
||||
<div class="scope-row">
|
||||
<span class="scope-summary" :class="{ empty: !selectedPaths.length }">
|
||||
{{ selectedPaths.length
|
||||
? `已选 ${selectedPaths.length} 个组织节点(含全部下级)`
|
||||
: '未选择组织(不推送当事人)' }}
|
||||
</span>
|
||||
<el-button size="small" type="primary" plain :disabled="running"
|
||||
@click="openScopeDialog">选择组织范围</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<div class="grid">
|
||||
<el-form-item label="推送范围单位">
|
||||
<el-input v-model="form.push_units" :disabled="running" clearable
|
||||
placeholder="总办,集团财经中心,金色湖畔事业部,集团管理中心,集团营建中心,金色印象事业部(留空 = 只推职能序列)" />
|
||||
<el-form-item label="dws 路径(留空自动检测)">
|
||||
<div class="dir-ctrl">
|
||||
<el-input v-model="form.dws_path" class="dir-input" :disabled="running" clearable
|
||||
placeholder="留空 = 自动检测 DINGTALK_DWS_BIN / 用户目录 / PATH" />
|
||||
<el-button class="dir-btn" :disabled="running || pickingDws"
|
||||
:loading="pickingDws" @click="pickDws">选择</el-button>
|
||||
<el-button class="dir-btn" :disabled="running || probing"
|
||||
:loading="probing" @click="probeDws">检测</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<el-tooltip placement="top"
|
||||
content="部门路径包含该关键字则不推送;留空表示不按部门路径排除">
|
||||
<span class="lbl">排除部门路径关键字</span>
|
||||
content="dws 推送时的群全称,按群名精确匹配;汇总消息附带本次 Excel 底稿">
|
||||
<span class="lbl">汇总群名</span>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<el-input v-model="form.push_exclude_keyword" :disabled="running" clearable
|
||||
placeholder="留空 = 不排除" />
|
||||
<el-input v-model="form.push_group" :disabled="running" clearable
|
||||
placeholder="留空 = 数字人沟通群" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="grid">
|
||||
<el-form-item label="钉钉 Webhook(可选)">
|
||||
<el-input v-model="form.dingtalk_webhook" placeholder="留空 = 内置机器人"
|
||||
:disabled="running" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="加签密钥(可选)">
|
||||
<el-input v-model="form.dingtalk_secret" type="password" show-password
|
||||
placeholder="机器人启用了加签才填" :disabled="running" />
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<el-tooltip placement="top"
|
||||
content="仅 dws 通道生效;需群里有 @所有人 权限">
|
||||
<span class="lbl">汇总群 @所有人</span>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<el-switch v-model="form.push_at_all" :disabled="running" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="tip">
|
||||
当事人提醒走企业内部应用「工作通知」(按<b>工号</b>精确匹配账号);
|
||||
群汇总走群机器人。推送范围=职能序列 ∪ 上方单位(部门路径不含排除关键字),
|
||||
单位与关键字均可改,留空分别=只推职能序列 / 不按部门路径排除。
|
||||
推送范围=<b>组织架构勾选的节点</b>(勾父节点即含其全部下级,按组织全路径匹配当事人所在部门);
|
||||
<b>未勾选则本次不推送当事人</b>。组织架构不随插件升级,需在弹窗里点「同步组织架构」拉取最新。
|
||||
检测到 dws 时:当事人走 <b>dws 单聊</b>,汇总连同 <b>Excel 底稿</b>发到「汇总群名」;
|
||||
未检测到 dws 时:当事人回退企业内部应用「工作通知」(按<b>工号</b>精确匹配账号),
|
||||
群汇总需要附件能力、<b>不发送</b>。
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
@@ -154,15 +179,15 @@
|
||||
(1 号运行查上月,否则查当月;手动指定月份则查该月),自动分页拉全。</div>
|
||||
<div class="hb-line"><b>② 导出</b>:按固定列口径导出 Excel 底稿到输出目录,
|
||||
文件名「周考勤异常_YYYY-MM_时间戳.xlsx」;试算模式只做这一步,文件名带「_试算」前缀。</div>
|
||||
<div class="hb-line"><b>③ 自动确认(全量)</b>:对查询范围内<b>全部异常</b>批量调用确认接口
|
||||
(每 200 条一批,失败自动重试 3 次、单批失败不影响其余批次);试算模式不执行。</div>
|
||||
<div class="hb-line"><b>③ 自动确认(轻微)</b>:对整月<b>轻微异常</b>(迟到/早退 < 30 分钟,不分职能序列)
|
||||
批量调用确认接口(每 200 条一批,失败自动重试 3 次、单批失败不影响其余批次);严重异常只推送不确认;试算模式不执行。</div>
|
||||
<div class="hb-line"><b>④ 当事人推送</b>:仅取<b>上周</b>、<b>严重异常</b>(迟到/早退 ≥ 30 分钟或其他类型),
|
||||
推送范围=<b>职能序列</b> ∪ <b>推送范围单位</b>(默认总办 / 集团财经中心 / 金色湖畔事业部 /
|
||||
集团管理中心 / 集团营建中心 / 金色印象事业部,部门路径不含排除关键字,界面可改),
|
||||
按「姓名+工号」合并为一人一条文本,经内部应用工作通知发送。</div>
|
||||
<div class="hb-line"><b>⑤ 群汇总</b>:推送条数汇总(总数、自动确认、待通知、上周非职能、
|
||||
其他严重异常)到钉钉群,走 dingtalk_sdk 统一格式(彩色标题 + 正文 + 页脚署名/时间);
|
||||
「自动确认」段落为<b>整月全量</b>口径,「待通知」含职能与推送范围单位。
|
||||
推送范围=<b>组织架构勾选的节点</b>(含全部下级,按组织全路径匹配),未勾选则不推送;
|
||||
按「姓名+工号」合并为一人一条文本;检测到 dws 时走 <b>dws 单聊</b>,否则回退内部应用工作通知。</div>
|
||||
<div class="hb-line"><b>⑤ 群汇总</b>:推送条数汇总(总数、自动确认、待通知、上周范围外、
|
||||
其他严重异常)到钉钉群;检测到 dws 时发到「汇总群名」并附带 <b>Excel 底稿</b>,
|
||||
未检测到 dws 时不发送(群机器人无法带附件)。
|
||||
「自动确认」段落为<b>整月轻微异常</b>口径,「待通知」含组织架构所选范围。
|
||||
试算模式不发送任何钉钉消息。</div>
|
||||
</div>
|
||||
</details>
|
||||
@@ -186,13 +211,50 @@
|
||||
<span>正在执行,日志与进度实时显示在工作台下方「运行日志」区</span>
|
||||
<span class="pct">{{ progress }}%</span>
|
||||
</div>
|
||||
|
||||
<!-- 组织架构选择弹窗 -->
|
||||
<el-dialog v-model="scopeDialog" title="选择推送范围(组织架构)" width="720px"
|
||||
append-to-body class="scope-dialog" @opened="applyDraftToTree">
|
||||
<div class="org-box">
|
||||
<div class="org-tools">
|
||||
<el-button size="small" type="primary" plain :loading="syncing" :disabled="running"
|
||||
@click="syncOrg">同步组织架构</el-button>
|
||||
<el-button size="small" :disabled="running || syncing || !draftPaths.length"
|
||||
@click="clearDraft">清空选择</el-button>
|
||||
<span class="org-count">已选 {{ draftPaths.length }} 个节点</span>
|
||||
<span class="spacer" />
|
||||
<span v-if="orgMeta.count" class="org-meta">
|
||||
共 {{ orgMeta.count }} 个节点<template v-if="orgMeta.fetched_at"> · 同步于 {{ orgMeta.fetched_at }}</template>
|
||||
</span>
|
||||
</div>
|
||||
<el-input v-model="orgKeyword" size="small" clearable class="org-search"
|
||||
:disabled="running || !orgTree.length" placeholder="搜索组织名称" />
|
||||
<div v-if="!orgTree.length" class="org-empty">
|
||||
尚未加载组织架构:点「同步组织架构」从 HR 拉取最新组织并固化为 JSON(本机缓存,升级不丢)
|
||||
</div>
|
||||
<div v-else class="org-tree">
|
||||
<el-tree ref="treeRef" :data="orgTree" show-checkbox node-key="path"
|
||||
:props="treeProps" :filter-node-method="filterNode"
|
||||
:expand-on-click-node="false" @check="onTreeCheck" />
|
||||
</div>
|
||||
<div class="org-note">
|
||||
勾选父节点=其全部下级一并纳入;按当事人所在组织的全路径(集团-事业部-…)匹配。
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<span class="scope-foot-count">已选 {{ draftPaths.length }} 个节点</span>
|
||||
<el-button @click="scopeDialog = false">取消</el-button>
|
||||
<el-button type="primary" :disabled="running || syncing" @click="confirmScope">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { nextTick, onMounted, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { usePluginUI } from './usePluginUI'
|
||||
import { PLUGIN_ID } from './api'
|
||||
|
||||
const DEFAULTS = () => ({
|
||||
ref_month: '',
|
||||
@@ -200,39 +262,206 @@ const DEFAULTS = () => ({
|
||||
dry_run: false,
|
||||
auto_confirm: true,
|
||||
push_enabled: true,
|
||||
push_units: '总办,集团财经中心,金色湖畔事业部,集团管理中心,集团营建中心,金色印象事业部',
|
||||
push_exclude_keyword: '大区',
|
||||
dingtalk_webhook: '',
|
||||
dingtalk_secret: '',
|
||||
push_scope_paths: '',
|
||||
dws_path: '',
|
||||
push_group: '数字人沟通群',
|
||||
push_at_all: false,
|
||||
})
|
||||
|
||||
function buildPayload(f) {
|
||||
const t = (v) => (v || '').trim()
|
||||
return {
|
||||
ref_month: t(f.ref_month),
|
||||
save_dir: t(f.save_dir),
|
||||
dry_run: !!f.dry_run,
|
||||
auto_confirm: !!f.auto_confirm,
|
||||
push_enabled: !!f.push_enabled,
|
||||
push_scope_paths: t(f.push_scope_paths),
|
||||
dws_path: t(f.dws_path),
|
||||
push_group: t(f.push_group),
|
||||
push_at_all: !!f.push_at_all,
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
form, notice, lastSavedAt, running, progress, stopping,
|
||||
saveNow, resetDefaults, restoreLastFields,
|
||||
schemeSel, schemeOptions, onSchemeChange, saveSchemeAs, removeScheme,
|
||||
run, forceStop,
|
||||
} = usePluginUI({
|
||||
defaults: DEFAULTS,
|
||||
buildPayload(f) {
|
||||
const t = (v) => (v || '').trim()
|
||||
return {
|
||||
ref_month: t(f.ref_month),
|
||||
save_dir: t(f.save_dir),
|
||||
dry_run: !!f.dry_run,
|
||||
auto_confirm: !!f.auto_confirm,
|
||||
push_enabled: !!f.push_enabled,
|
||||
push_units: t(f.push_units),
|
||||
push_exclude_keyword: t(f.push_exclude_keyword),
|
||||
dingtalk_webhook: t(f.dingtalk_webhook),
|
||||
dingtalk_secret: t(f.dingtalk_secret),
|
||||
}
|
||||
},
|
||||
})
|
||||
} = usePluginUI({ defaults: DEFAULTS, buildPayload })
|
||||
|
||||
function start() {
|
||||
run()
|
||||
}
|
||||
|
||||
// ---------------- 推送范围:组织架构树 ----------------
|
||||
const ORG_CACHE_KEY = `plugin:${PLUGIN_ID}:orgTree`
|
||||
const orgTree = ref([])
|
||||
const orgMeta = ref({ count: 0, fetched_at: '' })
|
||||
const selectedPaths = ref([])
|
||||
const orgKeyword = ref('')
|
||||
const treeRef = ref(null)
|
||||
const treeProps = { label: 'name', children: 'children' }
|
||||
const syncing = ref(false)
|
||||
// 弹窗内草稿:确定才写回 selectedPaths / 配置,取消不影响已保存范围
|
||||
const scopeDialog = ref(false)
|
||||
const draftPaths = ref([])
|
||||
let applyingTree = false
|
||||
|
||||
function parseScope(value) {
|
||||
if (Array.isArray(value)) return value.filter(Boolean)
|
||||
const raw = String(value || '').trim()
|
||||
if (!raw) return []
|
||||
try {
|
||||
const data = JSON.parse(raw)
|
||||
if (Array.isArray(data)) return data.filter(Boolean)
|
||||
} catch (_) { /* 兼容换行文本 */ }
|
||||
return raw.split('\n').map((s) => s.trim()).filter(Boolean)
|
||||
}
|
||||
|
||||
// 勾选父节点时 setCheckedKeys 会连带勾选全部下级,保存前去掉「已有祖先被选中」的冗余路径
|
||||
function pruneScope(keys) {
|
||||
const paths = [...new Set(keys)].sort((a, b) => a.length - b.length)
|
||||
const kept = []
|
||||
paths.forEach((p) => {
|
||||
if (!kept.some((q) => p === q || p.startsWith(q + '-'))) kept.push(p)
|
||||
})
|
||||
return kept
|
||||
}
|
||||
|
||||
function openScopeDialog() {
|
||||
draftPaths.value = [...selectedPaths.value]
|
||||
scopeDialog.value = true
|
||||
}
|
||||
|
||||
function applyDraftToTree() {
|
||||
if (!treeRef.value) return
|
||||
applyingTree = true
|
||||
treeRef.value.setCheckedKeys(draftPaths.value)
|
||||
nextTick(() => { applyingTree = false })
|
||||
}
|
||||
|
||||
function onTreeCheck() {
|
||||
if (applyingTree || !treeRef.value) return
|
||||
draftPaths.value = pruneScope(treeRef.value.getCheckedKeys())
|
||||
}
|
||||
|
||||
function clearDraft() {
|
||||
draftPaths.value = []
|
||||
if (treeRef.value) treeRef.value.setCheckedKeys([])
|
||||
}
|
||||
|
||||
function confirmScope() {
|
||||
selectedPaths.value = pruneScope(draftPaths.value)
|
||||
// 空值也存 "[]":配置合并规则会跳过空字符串,存空串会导致切方案时清不掉旧范围
|
||||
form.push_scope_paths = JSON.stringify(selectedPaths.value)
|
||||
scopeDialog.value = false
|
||||
}
|
||||
|
||||
function filterNode(value, data) {
|
||||
if (!value) return true
|
||||
return String(data.name || '').includes(String(value).trim())
|
||||
}
|
||||
|
||||
watch(orgKeyword, (v) => { if (treeRef.value) treeRef.value.filter(v) })
|
||||
|
||||
watch(() => form.push_scope_paths, (v) => {
|
||||
const paths = parseScope(v)
|
||||
if (JSON.stringify(paths) === JSON.stringify(selectedPaths.value)) return
|
||||
selectedPaths.value = paths
|
||||
})
|
||||
|
||||
function readOrgCache() {
|
||||
try {
|
||||
const raw = localStorage.getItem(ORG_CACHE_KEY)
|
||||
if (!raw) return null
|
||||
const data = JSON.parse(raw)
|
||||
return data && Array.isArray(data.tree) ? data : null
|
||||
} catch (_) { return null }
|
||||
}
|
||||
|
||||
function writeOrgCache(tree) {
|
||||
try {
|
||||
localStorage.setItem(ORG_CACHE_KEY, JSON.stringify({
|
||||
count: orgMeta.value.count, fetched_at: orgMeta.value.fetched_at, tree,
|
||||
}))
|
||||
} catch (_) { /* 缓存写入失败不影响当次使用 */ }
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const cache = readOrgCache()
|
||||
selectedPaths.value = parseScope(form.push_scope_paths)
|
||||
if (cache && cache.tree.length) {
|
||||
orgTree.value = cache.tree
|
||||
orgMeta.value = { count: cache.count || 0, fetched_at: cache.fetched_at || '' }
|
||||
} else if (selectedPaths.value.length) {
|
||||
// 浏览器缓存丢了但已配过范围:读本机固化的 org_tree.json 回填,打开弹窗时即可看到勾选
|
||||
loadOrgFromDisk()
|
||||
}
|
||||
})
|
||||
|
||||
// 起一次运行并轮询到结束(组织架构同步/读取共用)
|
||||
async function startRunAndWait(fields, maxTries) {
|
||||
const r = await fetch('/api/runs', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ plugin_id: PLUGIN_ID, fields }),
|
||||
})
|
||||
const d = await r.json().catch(() => ({}))
|
||||
if (!r.ok) throw new Error(d.detail || d.error || ('HTTP ' + r.status))
|
||||
if (!d.run_id) throw new Error('未返回 run_id')
|
||||
const run = await waitRunDone(d.run_id, maxTries)
|
||||
if (run.status === 'error') throw new Error(run.error || '运行失败')
|
||||
if (run.status === 'cancelled') throw new Error(run.error || '运行已取消')
|
||||
return run.result || {}
|
||||
}
|
||||
|
||||
async function loadOrgFromDisk() {
|
||||
try {
|
||||
const res = await startRunAndWait({ action: 'load_org' }, 20)
|
||||
const tree = Array.isArray(res.org_tree) ? res.org_tree : []
|
||||
if (!tree.length) return
|
||||
orgTree.value = tree
|
||||
orgMeta.value = { count: Number(res.count || 0), fetched_at: String(res.fetched_at || '') }
|
||||
writeOrgCache(tree)
|
||||
if (scopeDialog.value) nextTick(applyDraftToTree)
|
||||
} catch (_) { /* 读不到就保持空态,用户可手动同步 */ }
|
||||
}
|
||||
|
||||
async function syncOrg() {
|
||||
if (syncing.value) return
|
||||
syncing.value = true
|
||||
try {
|
||||
const res = await startRunAndWait(
|
||||
{ ...buildPayload(form), action: 'sync_org' }, 600)
|
||||
const tree = Array.isArray(res.org_tree) ? res.org_tree : []
|
||||
if (!tree.length) throw new Error('未返回组织架构数据')
|
||||
const count = Number(res.count || (res.detail || {}).count || 0)
|
||||
const fetchedAt = String(res.fetched_at || (res.detail || {}).fetched_at || '')
|
||||
orgTree.value = tree
|
||||
orgMeta.value = { count, fetched_at: fetchedAt }
|
||||
// 组织可能改名/撤销:保留仍然存在的已选路径
|
||||
const exists = new Set()
|
||||
const stack = [...tree]
|
||||
while (stack.length) {
|
||||
const node = stack.pop()
|
||||
exists.add(node.path)
|
||||
;(node.children || []).forEach((c) => stack.push(c))
|
||||
}
|
||||
const kept = draftPaths.value.filter((p) => exists.has(p))
|
||||
const dropped = draftPaths.value.length - kept.length
|
||||
draftPaths.value = kept
|
||||
nextTick(applyDraftToTree)
|
||||
writeOrgCache(tree)
|
||||
ElMessage.success(`组织架构已同步:${count || exists.size} 个节点`
|
||||
+ (dropped ? `,${dropped} 个已选节点已不存在` : ''))
|
||||
} catch (e) {
|
||||
ElMessage.error('同步组织架构失败:' + (e.message || e))
|
||||
} finally {
|
||||
syncing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 调用壳子本机接口打开原生「选择文件夹」对话框(壳子 /api/dialog/directory,仅返回路径)
|
||||
const picking = ref(false)
|
||||
async function pickDir() {
|
||||
@@ -252,6 +481,79 @@ async function pickDir() {
|
||||
picking.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 选择 dws:先弹文件选择,取消则改选目录(dws.exe 可能放在任意目录)
|
||||
const pickingDws = ref(false)
|
||||
async function pickDws() {
|
||||
pickingDws.value = true
|
||||
try {
|
||||
const r = await fetch('/api/dialog/file', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ title: '选择 dws.exe', filter: 'exe' }),
|
||||
})
|
||||
if (r.status === 404) {
|
||||
const d = await fetch('/api/dialog/directory', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ title: '选择 dws.exe 所在目录', current: form.dws_path || '' }),
|
||||
}).then((x) => x.json().catch(() => ({}))).catch(() => ({}))
|
||||
if (d.path) form.dws_path = d.path
|
||||
return
|
||||
}
|
||||
const d = await r.json().catch(() => ({}))
|
||||
if (!r.ok) throw new Error(d.detail || d.error || ('HTTP ' + r.status))
|
||||
if (d.path) form.dws_path = d.path
|
||||
} catch (e) {
|
||||
ElMessage.warning('选择文件失败:' + e.message)
|
||||
} finally {
|
||||
pickingDws.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// dws 检测:跑一次只检测的运行(probe_dws),命中路径回填
|
||||
const probing = ref(false)
|
||||
async function waitRunDone(runId, maxTries = 40) {
|
||||
for (let i = 0; i < maxTries; i += 1) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 500))
|
||||
const r = await fetch('/api/runs/' + encodeURIComponent(runId))
|
||||
if (!r.ok) continue
|
||||
const d = await r.json().catch(() => ({}))
|
||||
if (['done', 'error', 'cancelled'].includes(d.status)) return d
|
||||
}
|
||||
throw new Error('等待运行结束超时')
|
||||
}
|
||||
|
||||
async function probeDws() {
|
||||
probing.value = true
|
||||
try {
|
||||
const r = await fetch('/api/runs', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
plugin_id: PLUGIN_ID,
|
||||
fields: { ...buildPayload(form), probe_dws: true },
|
||||
}),
|
||||
})
|
||||
const d = await r.json().catch(() => ({}))
|
||||
if (!r.ok) throw new Error(d.detail || d.error || ('HTTP ' + r.status))
|
||||
if (!d.run_id) throw new Error('未返回 run_id')
|
||||
const run = await waitRunDone(d.run_id)
|
||||
const path = String((run.result || {}).dws_path || '')
|
||||
if (path) {
|
||||
form.dws_path = path
|
||||
ElMessage.success('dws 可用,已回填路径')
|
||||
} else if (run.status === 'error') {
|
||||
throw new Error(run.error || '检测失败')
|
||||
} else {
|
||||
ElMessage.warning('未检测到 dws:执行时将回退工作通知 + 群机器人')
|
||||
}
|
||||
} catch (e) {
|
||||
ElMessage.warning('检测失败:' + (e.message || e))
|
||||
} finally {
|
||||
probing.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -265,4 +567,20 @@ async function pickDir() {
|
||||
.row-4 .lbl { cursor: help; white-space: nowrap; border-bottom: 1px dashed var(--line-soft); }
|
||||
/* 区块标题右侧的即时摘要 */
|
||||
.sec-tag { flex: 0 0 auto; font-size: 12px; opacity: 0.6; white-space: nowrap; }
|
||||
/* 组织架构范围:按钮栏 + 搜索 + 可滚动树 */
|
||||
.org-box { width: 100%; border: 1px solid var(--line-soft); border-radius: 8px;
|
||||
padding: var(--space-2); display: flex; flex-direction: column; gap: var(--space-2); }
|
||||
.org-tools { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
|
||||
.org-tools .spacer { flex: 1 1 auto; }
|
||||
.org-count { font-size: 12px; opacity: 0.7; }
|
||||
.org-search { max-width: 260px; }
|
||||
.org-tree { max-height: 46vh; overflow: auto; }
|
||||
.org-empty { font-size: 12px; opacity: 0.65; padding: 10px 2px; }
|
||||
.org-meta { margin-left: var(--space-2); font-size: 12px; font-weight: normal; opacity: 0.55; }
|
||||
.org-note { font-size: 12px; opacity: 0.7; }
|
||||
/* 表单里的范围摘要行 + 弹窗底部计数 */
|
||||
.scope-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
|
||||
.scope-summary { font-size: 13px; }
|
||||
.scope-summary.empty { opacity: 0.6; }
|
||||
.scope-foot-count { float: left; line-height: 32px; font-size: 12px; opacity: 0.7; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user