Files

58 lines
4.1 KiB
HTML

{% extends "base.html" %}
{% block body %}
<h1 class="page">企业微信审批通知</h1>
<div class="card">
<p>提交后通知审批员,一次审批通过后即可归档正式文件。结果通知群可接收审批通过、驳回、撤回、变更和作废消息,可与审批通知群设为同一群。</p>
<p class="muted">手机连接公司 Wi-Fi 后,通过通知链接登录审批。系统主机须能访问企业微信接口,手机与主机须在可互通的内网。关闭通知会暂停队列,重新启用后继续处理仍有效的通知。</p>
<form method="post" class="form-grid two">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<label class="notification-wide"><span><input type="checkbox" name="enabled" value="1" {% if settings.enabled %}checked{% endif %}> 启用企业微信通知</span></label>
<label class="notification-wide">系统内网访问地址
<input name="base_url" value="{{ settings.base_url }}" placeholder="http://192.168.1.10:8080" maxlength="300">
<small class="muted">填写固定主机的实际 IP 与端口,或手机能解析的内网域名;不要填 localhost、127.0.0.1。</small>
</label>
{% for channel, label in channels.items() %}
<label class="notification-wide">{{ label }} Webhook {{ '(可选)' if channel == 'result' else '' }} · {{ '已配置' if settings.configured[channel] else '未配置' }}
<input type="password" name="{{ channel }}_webhook" autocomplete="new-password" placeholder="{{ '留空保留已有地址' if settings.configured[channel] else '粘贴企业微信群机器人的完整 Webhook 地址' }}">
{% if settings.configured[channel] %}<span><input type="checkbox" name="clear_{{ channel }}" value="1"> 清除此群配置</span>{% endif %}
</label>
{% endfor %}
<div class="notification-wide"><button class="btn primary">保存通知配置</button></div>
</form>
<p class="muted">Webhook 是发送凭据,保存后不显示原文。通知只包含单号、环节、提交版本、记录时间和内网链接。群内成员仍须使用各自账号,按订单权限查看和操作。</p>
</div>
<div class="card">
<h2>发送测试通知</h2>
<p>先保存配置,再选择要测试的群。消息将实际发送到该企业微信群。</p>
<div class="toolbar">
{% for channel, label in channels.items() %}
<form method="post" action="{{ url_for('notification_test') }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<input type="hidden" name="channel" value="{{ channel }}">
<button class="btn" {% if not settings.enabled or not settings.configured[channel] %}disabled{% endif %}>测试{{ label }}</button>
</form>
{% endfor %}
</div>
</div>
<div class="card">
<h2>最近 100 条通知 <a class="btn sm" href="{{ url_for('notification_settings') }}">刷新</a></h2>
<p class="muted">服务运行期间自动发送,每 4 秒最多尝试一条;失败最多尝试 5 次。已失效的待审批通知会跳过。网络超时后的重试可能重复通知,不会重复审批。时间以服务主机时区为准。</p>
<table class="grid">
<tr><th>时间</th><th>订单 / 环节</th><th>通知群</th><th>状态</th><th>尝试次数</th><th>说明 / 操作</th></tr>
{% for n in notices %}
<tr>
<td>{{ n.created_at|notice_time }}</td>
<td>{% if n.order_id %}<a href="{{ url_for('order_view',oid=n.order_id) }}">订单 #{{ n.order_id }}</a> · 第 {{ n.revision }} 次提交<br>{% endif %}{{ n.event }}</td>
<td>{{ channels.get(n.channel, '旧审核群') }}</td><td>{{ states[n.status] }}</td><td>{{ n.attempts }}</td>
<td>{{ n.last_error }}
{% if n.status in ['retry','failed'] %}
<form method="post" action="{{ url_for('notification_retry',nid=n.id) }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"><button class="btn sm">重试</button>
</form>{% endif %}
</td>
</tr>
{% else %}<tr><td colspan="6" class="muted">暂无通知。启用后产生的新审批操作会记录在这里,历史操作不补发。</td></tr>{% endfor %}
</table>
</div>
{% endblock %}