refactor(oa): 将审批决策中的「驳回」统一替换为「校验不通过未处理」
1. 统一所有模块的决策状态命名,替换原「驳回」为「校验不通过未处理」 2. 调整配置注释、文档说明、报告输出文案与推送文本 3. 新增请假附件OCR详情识别函数,支持多附件校验与命中关键词记录 4. 优化多附件下载逻辑,支持逗号分隔fileId与避免文件覆盖 5. 调整请假校验逻辑,适配小时假日期区间获取与多附件处理 6. 更新测试用例与审批提交逻辑,适配新的决策状态
This commit is contained in:
@@ -40,10 +40,9 @@ logger = get_logger(__name__)
|
||||
|
||||
|
||||
# ==================== 真实审批提交(默认关闭) ====================
|
||||
# 审批按钮:通过->同意(#chooseSubmit),驳回->退回申请人(#backApplySubmit)
|
||||
# 仅自动提交"同意"(校验通过):驳回/校验不通过未处理一律不自动提交,保留待人工处理
|
||||
_APPROVE_BUTTONS = {
|
||||
"通过": ("#chooseSubmit", "同意"),
|
||||
"驳回": ("#backApplySubmit", "退回申请人"),
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +86,7 @@ def submit_approval(browser, decision: str) -> Dict[str, str]:
|
||||
|
||||
Args:
|
||||
browser: 停留在详情页的 ChromiumPage
|
||||
decision: 校验决策(通过/驳回;其余决策不提交)
|
||||
decision: 校验决策(通过/校验不通过未处理;其余决策不提交)
|
||||
|
||||
Returns:
|
||||
{"action": "同意"/"退回申请人"/"-", "ok": "true"/"false", "message": ...}
|
||||
@@ -103,21 +102,31 @@ def submit_approval(browser, decision: str) -> Dict[str, str]:
|
||||
return {"action": label, "ok": "false", "message": msg}
|
||||
logger.info("点击审批按钮: %s(%s)", selector, label)
|
||||
btn.click()
|
||||
# 点击同意/退回后,弹出的弹窗结构不固定,需兼容两类"确定"按钮:
|
||||
# 1) #custom-confirm-modal-ok(普通确认框);
|
||||
# 2) tag:button@@class:btn-primary@@onclick:confirmSelect(选择人员弹窗,如加班
|
||||
# "选择中心负责人",人员由系统自动选中,确定按钮 onclick=confirmSelect()
|
||||
# 为弹窗独有,用多属性与匹配(@@)+包含匹配(:)精确咬住,避免误点页面其它
|
||||
# modal-footer 里的同类确定按钮)
|
||||
# 确认框由点击审批按钮后动态生成(modal 渐入动画),轮询等待其出现。
|
||||
# 确认按钮为唯一 id,主文档直接用 ele() 高频等待其动态出现,避免 _find_button 的 iframe 遍历开销
|
||||
# 普通流程确认框 #custom-confirm-modal-ok 为主;选人弹窗 .wf-select-people 为特殊单据才触发
|
||||
def _visible(el):
|
||||
try:
|
||||
return el.states.is_displayed
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
confirm = None
|
||||
for _ in range(10):
|
||||
confirm = _find_button(browser, "#custom-confirm-modal-ok", timeout=1)
|
||||
if confirm is None:
|
||||
confirm = _find_button(browser, "tag:button@@class:btn-primary@@onclick:confirmSelect", timeout=1)
|
||||
if confirm:
|
||||
for _ in range(20):
|
||||
c1 = browser.ele("#custom-confirm-modal-ok", timeout=0.2)
|
||||
if c1 is not None and _visible(c1):
|
||||
confirm = c1
|
||||
break
|
||||
time.sleep(0.5)
|
||||
# 选人弹窗(容器常驻但默认隐藏,仅弹出时才可见)兜底
|
||||
people = browser.ele(".wf-select-people", timeout=0.2)
|
||||
if people is not None and _visible(people):
|
||||
try:
|
||||
c2 = people.ele("css:.modal-footer button.btn.btn-primary", timeout=0.2)
|
||||
except Exception:
|
||||
c2 = None
|
||||
if c2 is not None and _visible(c2):
|
||||
confirm = c2
|
||||
break
|
||||
time.sleep(0.2)
|
||||
if confirm is None:
|
||||
msg = "未找到确认框确定按钮(#custom-confirm-modal-ok 或 .modal-footer .btn.btn-primary),审批未提交"
|
||||
logger.error(msg)
|
||||
@@ -240,7 +249,7 @@ def run_flow(
|
||||
orig_decision = result.get("decision")
|
||||
submit = submit_approval(browser, orig_decision)
|
||||
result["审批动作"] = submit["action"]
|
||||
# 提交失败兜底:单据在 OA 中状态未变,不能仍标为通过/驳回,
|
||||
# 提交失败兜底:单据在 OA 中状态未变,不能仍标为通过/校验不通过未处理,
|
||||
# 归为「异常」并附机器结论,交由人工跟进
|
||||
if submit["ok"] == "false":
|
||||
result["decision"] = "异常"
|
||||
|
||||
Reference in New Issue
Block a user