feat(frontend): 重构登录页面并新增插件强制更新功能

- 替换登录页面为极光背景玻璃拟态设计,移除注册/忘记密码页面
- 新增插件强制更新功能,支持设置最低版本和截止时间
- 修复通知账号选择占位文本和拉取失败注释
- 新增审计日志系统用户相关操作类型
- 新增用户菜单头像 fallback 逻辑
- 重构 XQ0037 工作簿写入逻辑,改用 openpyxl 直写避免时区问题
- 更新 XQ0034 脚本参数默认值和注释
This commit is contained in:
2026-10-16 11:40:43 +08:00
parent a7dbc5a77e
commit cad685fe40
21 changed files with 1145 additions and 1476 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 32 KiB

@@ -1,7 +1,7 @@
<!-- 系统logo -->
<template>
<div class="flex-cc">
<img :style="logoStyle" src="@imgs/common/logo.webp" alt="logo" class="w-full h-full" />
<img :style="logoStyle" src="@imgs/common/logo.png" alt="logo" class="w-full h-full" />
</div>
</template>
@@ -14,8 +14,9 @@
<template #reference>
<img
class="size-8.5 mr-5 c-p rounded-full max-sm:w-6.5 max-sm:h-6.5 max-sm:mr-[16px]"
src="@imgs/user/avatar.webp"
:src="avatarUrl"
alt="avatar"
@error="avatarError = true"
/>
</template>
<template #default>
@@ -23,13 +24,15 @@
<div class="flex-c pb-1 px-0">
<img
class="w-10 h-10 mr-3 ml-0 overflow-hidden rounded-full float-left"
src="@imgs/user/avatar.webp"
:src="avatarUrl"
/>
<div class="w-[calc(100%-60px)] h-full">
<span class="block text-sm font-medium text-g-800 truncate">{{
userInfo.userName
}}</span>
<span class="block mt-0.5 text-xs text-g-500 truncate">{{ userInfo.email }}</span>
<span class="block mt-0.5 text-xs text-g-500 truncate">
{{ userInfo.account || '—' }} · {{ userInfo.dept || '—' }}
</span>
</div>
</div>
<ul class="py-4 mt-3 border-t border-g-300/80">
@@ -57,6 +60,7 @@
import { ElMessageBox } from 'element-plus'
import { useUserStore } from '@/store/modules/user'
import { mittBus } from '@/utils/sys'
import defaultAvatar from '@imgs/user/avatar.webp'
defineOptions({ name: 'ArtUserMenu' })
@@ -67,6 +71,24 @@
const { getUserInfo: userInfo } = storeToRefs(userStore)
const userMenuPopover = ref()
// 真实头像(个人中心上传后回显;加载失败/未设置回退默认头像)
const avatarError = ref(false)
const avatarVersion = ref(Date.now())
const avatarUrl = computed(() => {
const acct = String(userInfo.value?.account || '')
if (!acct || avatarError.value || !userInfo.value?.avatar) {
return defaultAvatar
}
return `/api/avatar/${encodeURIComponent(acct)}?v=${avatarVersion.value}`
})
watch(
() => userInfo.value?.avatar,
() => {
avatarError.value = false
avatarVersion.value = Date.now()
}
)
/**
* 页面跳转
* @param {string} path - 目标路径
@@ -1,602 +0,0 @@
<!-- 登录、注册、忘记密码左侧背景 -->
<template>
<div class="login-left-view">
<div class="logo">
<ArtLogo class="icon" size="46" />
<h1 class="title">{{ AppConfig.systemInfo.name }}</h1>
</div>
<div class="left-img">
<ThemeSvg :src="loginIcon" size="100%" />
</div>
<div class="text-wrap">
<h1> {{ $t('login.leftView.title') }} </h1>
<p> {{ $t('login.leftView.subTitle') }} </p>
</div>
<!-- 几何装饰元素 -->
<div class="geometric-decorations">
<!-- 基础几何形状 -->
<div class="geo-element circle-outline animate-fade-in-up" style="animation-delay: 0s"></div>
<div
class="geo-element square-rotated animate-fade-in-left"
style="animation-delay: 0s"
></div>
<div class="geo-element circle-small animate-fade-in-up" style="animation-delay: 0.3s"></div>
<div
class="geo-element square-bottom-right animate-fade-in-right"
style="animation-delay: 0s"
></div>
<!-- 背景泡泡 -->
<div class="geo-element bg-bubble animate-scale-in" style="animation-delay: 0.5"></div>
<!-- 太阳/月亮 -->
<div
class="geo-element circle-top-right animate-fade-in-down"
style="animation-delay: 0.5"
@click="themeAnimation"
></div>
<!-- 装饰点 -->
<div class="geo-element dot dot-top-left animate-bounce-in" style="animation-delay: 0s"></div>
<div
class="geo-element dot dot-top-right animate-bounce-in"
style="animation-delay: 0s"
></div>
<div
class="geo-element dot dot-center-right animate-bounce-in"
style="animation-delay: 0s"
></div>
<!-- 叠加方块组 -->
<div class="squares-group">
<i
class="geo-element square square-blue animate-fade-in-left-rotated-blue"
style="animation-delay: 0.2s"
></i>
<i
class="geo-element square square-pink animate-fade-in-left-rotated-pink"
style="animation-delay: 0.4s"
></i>
<i
class="geo-element square square-purple animate-fade-in-left-no-rotation"
style="animation-delay: 0.6s"
></i>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import AppConfig from '@/config'
import loginIcon from '@imgs/svg/login_icon.svg'
import { themeAnimation } from '@/utils/ui/animation'
// 定义 props
defineProps<{
hideContent?: boolean // 是否隐藏内容,只显示 logo
}>()
</script>
<style lang="scss" scoped>
// 颜色变量定义
$primary-light-7: var(--el-color-primary-light-7);
$primary-light-8: var(--el-color-primary-light-8);
$primary-light-9: var(--el-color-primary-light-9);
$primary-base: var(--el-color-primary);
$main-bg: var(--default-box-color);
// 混合颜色函数
$bg-mix-light-9: color-mix(in srgb, $primary-light-9 100%, $main-bg);
$bg-mix-light-8: color-mix(in srgb, $primary-light-8 80%, $main-bg);
$bg-mix-light-7: color-mix(in srgb, $primary-light-7 80%, $main-bg);
.login-left-view {
position: relative;
box-sizing: border-box;
width: 65vw;
height: 100%;
padding: 15px;
overflow: hidden;
background-color: $bg-mix-light-9;
.logo {
position: relative;
z-index: 100;
display: flex;
align-items: center;
.title {
margin-left: 10px;
font-size: 20px;
font-weight: 400;
}
}
.left-img {
position: absolute;
inset: 0 0 10.5%;
z-index: 10;
width: 40%;
margin: auto;
animation: slideInLeft 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
.text-wrap {
position: absolute;
bottom: 80px;
width: 100%;
text-align: center;
animation: slideInLeft 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
h1 {
font-size: 24px;
font-weight: 400;
color: var(--art-gray-900) !important;
}
p {
margin-top: 10px;
font-size: 14px;
color: var(--art-gray-600) !important;
}
}
.geometric-decorations {
.geo-element {
position: absolute;
opacity: 0;
animation-fill-mode: forwards;
animation-duration: 0.8s;
animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
// 动画 mixin
@mixin fadeAnimation($direction: '', $rotation: 0deg) {
from {
opacity: 0;
@if $direction == 'up' {
transform: translateY(30px) rotate($rotation);
} @else if $direction == 'down' {
transform: translateY(-30px) rotate($rotation);
} @else if $direction == 'left' {
transform: translateX(-30px) rotate($rotation);
} @else if $direction == 'right' {
transform: translateX(30px) rotate($rotation);
}
}
to {
opacity: 1;
@if $direction == 'up' or $direction == 'down' {
transform: translateY(0) rotate($rotation);
} @else {
transform: translateX(0) rotate($rotation);
}
}
}
// 动画定义
@keyframes fadeInUp {
@include fadeAnimation('up');
}
@keyframes fadeInDown {
@include fadeAnimation('down');
}
@keyframes fadeInLeft {
@include fadeAnimation('left');
}
@keyframes fadeInLeftRotated {
@include fadeAnimation('left', -25deg);
}
@keyframes fadeInRight {
@include fadeAnimation('right');
}
@keyframes fadeInRightRotated {
@include fadeAnimation('right', 45deg);
}
@keyframes fadeInLeftRotatedBlue {
@include fadeAnimation('left', -10deg);
}
@keyframes fadeInLeftRotatedPink {
@include fadeAnimation('left', 10deg);
}
@keyframes fadeInLeftNoRotation {
@include fadeAnimation('left');
}
@keyframes scaleIn {
from {
opacity: 0;
transform: scale(0.8);
}
to {
opacity: 1;
transform: scale(1);
}
}
@keyframes bounceIn {
0% {
opacity: 0;
transform: scale(0.3);
}
50% {
opacity: 1;
transform: scale(1.05);
}
70% {
transform: scale(0.9);
}
100% {
opacity: 1;
transform: scale(1);
}
}
@keyframes lineGrow {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes slideInLeft {
from {
opacity: 0;
transform: translateX(-30px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
// 动画类
.animate-fade-in-up {
animation-name: fadeInUp;
}
.animate-fade-in-down {
animation-name: fadeInDown;
}
.animate-fade-in-left {
animation-name: fadeInLeft;
}
.animate-fade-in-right {
animation-name: fadeInRight;
}
.animate-scale-in {
animation-name: scaleIn;
animation-duration: 1.2s;
}
.animate-bounce-in {
animation-name: bounceIn;
animation-duration: 0.6s;
}
.animate-fade-in-left-rotated-blue {
animation-name: fadeInLeftRotatedBlue;
}
.animate-fade-in-left-rotated-pink {
animation-name: fadeInLeftRotatedPink;
}
.animate-fade-in-left-no-rotation {
animation-name: fadeInLeftNoRotation;
}
// 基础几何形状
.circle-outline {
top: 10%;
left: 25%;
width: 42px;
height: 42px;
border: 2px solid $primary-light-8;
border-radius: 50%;
}
.square-rotated {
top: 50%;
left: 16%;
width: 60px;
height: 60px;
background-color: $bg-mix-light-8;
&.animate-fade-in-left {
animation-name: fadeInLeftRotated;
}
}
.circle-small {
bottom: 26%;
left: 30%;
width: 18px;
height: 18px;
background-color: $primary-light-8;
border-radius: 50%;
}
// 太阳/月亮效果
.circle-top-right {
top: 3%;
right: 3%;
z-index: 100;
width: 50px;
height: 50px;
cursor: pointer;
background: $bg-mix-light-7;
border-radius: 50%;
transition: all 0.3s;
&::after {
position: absolute;
top: 50%;
left: 50%;
width: 100%;
height: 100%;
content: '';
background: linear-gradient(to right, #fcbb04, #fffc00);
border-radius: 50%;
opacity: 0;
transition: all 0.5s;
transform: translate(-50%, -50%);
}
&:hover {
box-shadow: 0 0 36px #fffc00;
&::after {
opacity: 1;
}
}
}
.square-bottom-right {
right: 10%;
bottom: 10%;
width: 50px;
height: 50px;
background-color: $primary-light-8;
&.animate-fade-in-right {
animation-name: fadeInRightRotated;
}
}
// 背景泡泡
.bg-bubble {
top: -120px;
right: -120px;
width: 360px;
height: 360px;
background-color: $bg-mix-light-8;
border-radius: 50%;
}
// 装饰点
.dot {
width: 14px;
height: 14px;
background-color: $primary-light-7;
border-radius: 50%;
&.dot-top-left {
top: 140px;
left: 100px;
}
&.dot-top-right {
top: 140px;
right: 120px;
}
&.dot-center-right {
top: 46%;
right: 22%;
background-color: $primary-light-8;
}
}
// 叠加方块组
.squares-group {
position: absolute;
bottom: 18px;
left: 20px;
width: 140px;
height: 140px;
pointer-events: none;
.square {
position: absolute;
display: block;
border-radius: 8px;
box-shadow: 0 8px 24px rgb(64 87 167 / 12%);
&.square-blue {
top: 12px;
left: 30px;
z-index: 2;
width: 50px;
height: 50px;
background-color: rgb(from $primary-base r g b / 30%);
}
&.square-pink {
top: 30px;
left: 48px;
z-index: 1;
width: 70px;
height: 70px;
background-color: rgb(from $primary-base r g b / 15%);
}
&.square-purple {
top: 66px;
left: 86px;
z-index: 3;
width: 32px;
height: 32px;
background-color: rgb(from $primary-base r g b / 45%);
}
}
// 装饰线条
&::after {
position: absolute;
top: 86px;
left: 72px;
width: 80px;
height: 1px;
content: '';
background: linear-gradient(90deg, var(--el-color-primary-light-6), transparent);
opacity: 0;
transform: rotate(50deg);
animation: lineGrow 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
animation-delay: 1.2s;
}
}
}
@media only screen and (width <= 1600px) {
width: 60vw;
.text-wrap {
bottom: 40px;
}
}
@media only screen and (width <= 1180px) {
width: auto;
height: auto;
padding: 0;
// 隐藏背景和其他内容,只保留 logo
background: transparent;
.left-img,
.text-wrap,
.geometric-decorations {
display: none;
}
.logo {
display: none;
}
}
}
// 暗色主题
.dark .login-left-view {
background-color: color-mix(in srgb, $primary-light-9 60%, #070707);
@media only screen and (width <= 1180px) {
background: transparent;
}
.geometric-decorations {
// 月亮效果
.circle-top-right {
background-color: $bg-mix-light-8;
box-shadow: 0 0 25px #333 inset;
transition: all 0.3s ease-in-out 0.1s;
rotate: -48deg;
&::before {
position: absolute;
top: 0;
left: 15px;
width: 50px;
height: 50px;
content: '';
background-color: $bg-mix-light-9;
border-radius: 50%;
transition: all 0.3s ease-in-out;
}
&:hover {
background-color: transparent;
box-shadow: 0 40px 25px #ddd inset;
&::before {
left: 18px;
}
&::after {
opacity: 0;
}
}
}
.bg-bubble {
background-color: $bg-mix-light-9;
}
// 其他元素颜色调整
.square-rotated {
background-color: $bg-mix-light-9;
}
.circle-small,
.dot {
background-color: $primary-light-8;
}
.square-bottom-right {
background-color: $primary-light-9;
}
.dot.dot-top-right {
background-color: $primary-light-8;
}
}
// 方块组暗色调整
.squares-group {
.square {
box-shadow: none;
&.square-blue {
background-color: rgb(from $primary-base r g b / 18%);
}
&.square-pink {
background-color: rgb(from $primary-base r g b / 10%);
}
&.square-purple {
background-color: rgb(from $primary-base r g b / 20%);
}
}
&::after {
background: linear-gradient(90deg, $primary-light-8, transparent);
}
}
}
</style>
@@ -24,18 +24,6 @@ export const staticRoutes: AppRouteRecordRaw[] = [
component: () => import('@views/auth/login/index.vue'),
meta: { title: 'menus.login.title', isHideTab: true }
},
{
path: '/auth/register',
name: 'Register',
component: () => import('@views/auth/register/index.vue'),
meta: { title: 'menus.register.title', isHideTab: true }
},
{
path: '/auth/forget-password',
name: 'ForgetPassword',
component: () => import('@views/auth/forget-password/index.vue'),
meta: { title: 'menus.forgetPassword.title', isHideTab: true }
},
{
path: '/403',
name: 'Exception403',
@@ -1,204 +1,204 @@
<script setup lang="ts">
/**
* 账号管理(37du 控制台)
* 列表/搜索/新建/编辑/重置密码/删除,对接 /api/admin/accounts*
*/
import { onMounted, reactive, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import {
fetchAccounts, createAccount, updateAccount, resetAccountPwd, deleteAccount
} from '@/api/business'
const loading = ref(false)
const list = ref<any[]>([])
const total = ref(0)
const query = reactive({ page: 1, page_size: 10, q: '' })
async function load() {
loading.value = true
try {
const r = await fetchAccounts(query)
list.value = r.items || []
total.value = r.total || 0
} finally {
loading.value = false
}
}
function search() {
query.page = 1
load()
}
// ---- 新建/编辑 ----
const dialogOpen = ref(false)
const isEdit = ref(false)
const saving = ref(false)
const form = reactive({ account: '', password: '', dept: '', nickname: '', is_admin: false, status: 1 })
function openCreate() {
isEdit.value = false
Object.assign(form, { account: '', password: '', dept: '', nickname: '', is_admin: false, status: 1 })
dialogOpen.value = true
}
function openEdit(row: any) {
isEdit.value = true
Object.assign(form, {
account: row.account, password: '', dept: row.dept || '', nickname: row.nickname || '',
is_admin: !!row.is_admin, status: row.status
})
dialogOpen.value = true
}
async function submit() {
if (!form.account) return ElMessage.warning('account 必填')
if (!isEdit.value && (!form.password || form.password.length < 8)) {
return ElMessage.warning('密码至少 8 位')
}
saving.value = true
try {
if (isEdit.value) {
await updateAccount({ account: form.account, dept: form.dept, nickname: form.nickname, is_admin: form.is_admin, status: form.status })
} else {
await createAccount(form)
}
ElMessage.success('保存成功')
dialogOpen.value = false
load()
} finally {
saving.value = false
}
}
// ---- 重置密码 ----
const pwdOpen = ref(false)
const pwdForm = reactive({ account: '', new_password: '' })
function openReset(row: any) {
Object.assign(pwdForm, { account: row.account, new_password: '' })
pwdOpen.value = true
}
async function submitReset() {
if (!pwdForm.new_password || pwdForm.new_password.length < 8) {
return ElMessage.warning('新密码至少 8 位')
}
await resetAccountPwd({ account: pwdForm.account, new_password: pwdForm.new_password })
ElMessage.success('密码已重置')
pwdOpen.value = false
}
// ---- 删除 ----
async function remove(row: any) {
await ElMessageBox.confirm(`确认删除账号「${row.account}」?`, '删除确认', { type: 'warning' })
await deleteAccount(row.account)
ElMessage.success('已删除')
load()
}
onMounted(load)
</script>
<template>
<div class="p-5 space-y-4">
<ArtPageHeader title="账号管理" description="统一账号维护、管理员标识与授权概览">
<template #actions>
<el-button type="primary" @click="openCreate"><ArtSvgIcon icon="ri:add-line" class="mr-1" />新建账号</el-button>
</template>
</ArtPageHeader>
<el-card shadow="never" class="rounded-xl">
<el-form inline @submit.prevent="search">
<el-form-item label="关键字">
<el-input v-model="query.q" placeholder="账号 / 昵称 / 部门" clearable style="width: 240px" @keyup.enter="search" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="search">查询</el-button>
<el-button @click="Object.assign(query, { q: '' }); search()">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card shadow="never" class="rounded-xl">
<el-table v-loading="loading" :data="list" border stripe>
<el-table-column prop="account" label="账号" min-width="120" />
<el-table-column prop="nickname" label="昵称" min-width="120" />
<el-table-column prop="dept" label="部门" width="120" />
<el-table-column label="管理员" width="90">
<template #default="{ row }">
<el-tag v-if="row.is_admin" size="small" type="primary">管理员</el-tag>
<span v-else class="text-gray-400">-</span>
</template>
</el-table-column>
<el-table-column label="状态" width="90">
<template #default="{ row }">
<el-tag :type="row.status === 1 ? 'success' : 'danger'" size="small">
{{ row.status === 1 ? '启用' : '停用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="插件授权" width="110">
<template #default="{ row }">
<el-tag v-if="row.plugins?.length" size="small" type="info">{{ row.plugins.length }} 个</el-tag>
<span v-else class="text-gray-400">-</span>
</template>
</el-table-column>
<el-table-column prop="created_at" label="创建时间" width="170" />
<el-table-column label="操作" width="220" fixed="right">
<template #default="{ row }">
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
<el-button link type="warning" @click="openReset(row)">重置密码</el-button>
<el-button link type="danger" @click="remove(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="flex justify-end mt-4">
<el-pagination
v-model:current-page="query.page"
v-model:page-size="query.page_size"
:total="total"
layout="total, prev, pager, next"
@current-change="load"
/>
</div>
</el-card>
<!-- 新建/编辑弹窗 -->
<el-dialog v-model="dialogOpen" :title="isEdit ? '编辑账号' : '新建账号'" width="480px">
<el-form label-width="90px">
<el-form-item label="账号" required>
<el-input v-model="form.account" :disabled="isEdit" placeholder="工号" />
</el-form-item>
<el-form-item v-if="!isEdit" label="初始密码" required>
<el-input v-model="form.password" type="password" show-password placeholder="至少 8 位" />
</el-form-item>
<el-form-item label="昵称">
<el-input v-model="form.nickname" />
</el-form-item>
<el-form-item label="部门">
<el-input v-model="form.dept" />
</el-form-item>
<el-form-item label="管理员">
<el-switch v-model="form.is_admin" />
</el-form-item>
<el-form-item v-if="isEdit" label="状态">
<el-switch v-model="form.status" :active-value="1" :inactive-value="0" active-text="启用" inactive-text="停用" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="dialogOpen = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="submit">保存</el-button>
</template>
</el-dialog>
<!-- 重置密码弹窗 -->
<el-dialog v-model="pwdOpen" title="重置密码" width="420px">
<el-form label-width="90px">
<el-form-item label="账号">{{ pwdForm.account }}</el-form-item>
<el-form-item label="新密码" required>
<el-input v-model="pwdForm.new_password" type="password" show-password placeholder="至少 8 位" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="pwdOpen = false">取消</el-button>
<el-button type="primary" @click="submitReset">重置</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
/**
* 账号管理(37du 控制台)
* 列表/搜索/新建/编辑/重置密码/删除,对接 /api/admin/accounts*
*/
import { onMounted, reactive, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import {
fetchAccounts, createAccount, updateAccount, resetAccountPwd, deleteAccount
} from '@/api/business'
const loading = ref(false)
const list = ref<any[]>([])
const total = ref(0)
const query = reactive({ page: 1, page_size: 10, q: '' })
async function load() {
loading.value = true
try {
const r = await fetchAccounts(query)
list.value = r.items || []
total.value = r.total || 0
} finally {
loading.value = false
}
}
function search() {
query.page = 1
load()
}
// ---- 新建/编辑 ----
const dialogOpen = ref(false)
const isEdit = ref(false)
const saving = ref(false)
const form = reactive({ account: '', password: '', dept: '', nickname: '', is_admin: false, status: 1 })
function openCreate() {
isEdit.value = false
Object.assign(form, { account: '', password: '', dept: '', nickname: '', is_admin: false, status: 1 })
dialogOpen.value = true
}
function openEdit(row: any) {
isEdit.value = true
Object.assign(form, {
account: row.account, password: '', dept: row.dept || '', nickname: row.nickname || '',
is_admin: !!row.is_admin, status: row.status
})
dialogOpen.value = true
}
async function submit() {
if (!form.account) return ElMessage.warning('account 必填')
if (!isEdit.value && (!form.password || form.password.length < 8)) {
return ElMessage.warning('密码至少 8 位')
}
saving.value = true
try {
if (isEdit.value) {
await updateAccount({ account: form.account, dept: form.dept, nickname: form.nickname, is_admin: form.is_admin, status: form.status })
} else {
await createAccount(form)
}
ElMessage.success('保存成功')
dialogOpen.value = false
load()
} finally {
saving.value = false
}
}
// ---- 重置密码 ----
const pwdOpen = ref(false)
const pwdForm = reactive({ account: '', new_password: '' })
function openReset(row: any) {
Object.assign(pwdForm, { account: row.account, new_password: '' })
pwdOpen.value = true
}
async function submitReset() {
if (!pwdForm.new_password || pwdForm.new_password.length < 8) {
return ElMessage.warning('新密码至少 8 位')
}
await resetAccountPwd({ account: pwdForm.account, new_password: pwdForm.new_password })
ElMessage.success('密码已重置')
pwdOpen.value = false
}
// ---- 删除 ----
async function remove(row: any) {
await ElMessageBox.confirm(`确认删除账号「${row.account}」?`, '删除确认', { type: 'warning' })
await deleteAccount(row.account)
ElMessage.success('已删除')
load()
}
onMounted(load)
</script>
<template>
<div class="p-5 space-y-4">
<ArtPageHeader title="账号管理" description="统一账号维护、管理员标识与授权概览">
<template #actions>
<el-button type="primary" @click="openCreate"><ArtSvgIcon icon="ri:add-line" class="mr-1" />新建账号</el-button>
</template>
</ArtPageHeader>
<el-card shadow="never" class="rounded-xl">
<el-form inline @submit.prevent="search">
<el-form-item label="关键字">
<el-input v-model="query.q" placeholder="账号 / 昵称 / 部门" clearable style="width: 240px" @keyup.enter="search" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="search">查询</el-button>
<el-button @click="Object.assign(query, { q: '' }); search()">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card shadow="never" class="rounded-xl">
<el-table v-loading="loading" :data="list" border stripe>
<el-table-column prop="account" label="账号" min-width="120" />
<el-table-column prop="nickname" label="昵称" min-width="120" />
<el-table-column prop="dept" label="部门" width="120" />
<el-table-column label="管理员" width="90">
<template #default="{ row }">
<el-tag v-if="row.is_admin" size="small" type="primary">管理员</el-tag>
<span v-else class="text-gray-400">-</span>
</template>
</el-table-column>
<el-table-column label="状态" width="90">
<template #default="{ row }">
<el-tag :type="row.status === 1 ? 'success' : 'danger'" size="small">
{{ row.status === 1 ? '启用' : '停用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="插件授权" width="110">
<template #default="{ row }">
<el-tag v-if="row.plugins?.length" size="small" type="info">{{ row.plugins.length }} 个</el-tag>
<span v-else class="text-gray-400">-</span>
</template>
</el-table-column>
<el-table-column prop="created_at" label="创建时间" width="170" />
<el-table-column label="操作" width="220" fixed="right">
<template #default="{ row }">
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
<el-button link type="warning" @click="openReset(row)">重置密码</el-button>
<el-button link type="danger" @click="remove(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="flex justify-end mt-4">
<el-pagination
v-model:current-page="query.page"
v-model:page-size="query.page_size"
:total="total"
layout="total, prev, pager, next"
@current-change="load"
/>
</div>
</el-card>
<!-- 新建/编辑弹窗 -->
<el-dialog v-model="dialogOpen" :title="isEdit ? '编辑账号' : '新建账号'" width="480px">
<el-form label-width="90px">
<el-form-item label="账号" required>
<el-input v-model="form.account" :disabled="isEdit" placeholder="账户编号(工号等)" />
</el-form-item>
<el-form-item v-if="!isEdit" label="初始密码" required>
<el-input v-model="form.password" type="password" show-password placeholder="至少 8 位" />
</el-form-item>
<el-form-item label="昵称">
<el-input v-model="form.nickname" />
</el-form-item>
<el-form-item label="部门">
<el-input v-model="form.dept" />
</el-form-item>
<el-form-item label="管理员">
<el-switch v-model="form.is_admin" />
</el-form-item>
<el-form-item v-if="isEdit" label="状态">
<el-switch v-model="form.status" :active-value="1" :inactive-value="0" active-text="启用" inactive-text="停用" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="dialogOpen = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="submit">保存</el-button>
</template>
</el-dialog>
<!-- 重置密码弹窗 -->
<el-dialog v-model="pwdOpen" title="重置密码" width="420px">
<el-form label-width="90px">
<el-form-item label="账号">{{ pwdForm.account }}</el-form-item>
<el-form-item label="新密码" required>
<el-input v-model="pwdForm.new_password" type="password" show-password placeholder="至少 8 位" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="pwdOpen = false">取消</el-button>
<el-button type="primary" @click="submitReset">重置</el-button>
</template>
</el-dialog>
</div>
</template>
@@ -13,9 +13,12 @@ const today = ref(0)
const query = reactive({ page: 1, page_size: 20, action: '', q: '' })
const actionOptions = ['account-create', 'account-update', 'account-reset-pwd', 'account-delete',
'grant', 'revoke-grant', 'grant-platform', 'revoke-platform', 'plugin-publish', 'plugin-delete',
'plugin-patch', 'shell-release', 'file-source-upsert', 'file-source-patch', 'file-source-delete',
'creds-seed', 'notify-create', 'notify-toggle', 'notify-delete', 'download-ticket']
'grant', 'revoke-grant', 'grant-platform', 'revoke-platform', 'grant-batch', 'grant-revoke-batch',
'plugin-publish', 'plugin-delete', 'plugin-patch', 'shell-release', 'file-source-upsert',
'file-source-patch', 'file-source-delete', 'creds-seed', 'notify-create', 'notify-toggle',
'notify-delete', 'download-ticket', 'sys-user-add', 'sys-user-edit', 'sys-user-del',
'sys-role-add', 'sys-role-edit', 'sys-role-del', 'sys-menu-add', 'sys-menu-edit', 'sys-menu-del',
'sys-dept-add', 'sys-dept-edit', 'sys-dept-del']
async function load() {
loading.value = true
@@ -1,62 +0,0 @@
<template>
<div class="flex w-full h-screen">
<LoginLeftView />
<div class="relative flex-1">
<AuthTopBar />
<div class="auth-right-wrap">
<div class="form">
<h3 class="title">{{ $t('forgetPassword.title') }}</h3>
<p class="sub-title">{{ $t('forgetPassword.subTitle') }}</p>
<div class="mt-5">
<span class="input-label" v-if="showInputLabel">账号</span>
<ElInput
class="custom-height"
:placeholder="$t('forgetPassword.placeholder')"
v-model.trim="username"
/>
</div>
<div style="margin-top: 15px">
<ElButton
class="w-full custom-height"
type="primary"
@click="register"
:loading="loading"
v-ripple
>
{{ $t('forgetPassword.submitBtnText') }}
</ElButton>
</div>
<div style="margin-top: 15px">
<ElButton class="w-full custom-height" plain @click="toLogin">
{{ $t('forgetPassword.backBtnText') }}
</ElButton>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
defineOptions({ name: 'ForgetPassword' })
const router = useRouter()
const showInputLabel = ref(false)
const username = ref('')
const loading = ref(false)
const register = async () => {}
const toLogin = () => {
router.push({ name: 'Login' })
}
</script>
<style scoped>
@import '../login/style.css';
</style>
@@ -1,120 +1,126 @@
<!-- 登录页面(37du 重构版:统一账户 + 密码 → cool-admin /api/admin/auth) -->
<!-- 登录页(37du:极光背景 + 玻璃拟态卡片;统一账户 + 密码 → /api/admin/auth) -->
<template>
<div class="flex w-full h-screen">
<LoginLeftView />
<div class="login-page">
<AuthTopBar />
<div class="relative flex-1">
<AuthTopBar />
<!-- 极光光斑 -->
<div class="blob blob-1"></div>
<div class="blob blob-2"></div>
<div class="blob blob-3"></div>
<!-- 点阵纹理 -->
<div class="grid-overlay"></div>
<div class="auth-right-wrap">
<div class="form">
<h3 class="title">{{ $t('login.title') }}</h3>
<p class="sub-title">{{ $t('login.subTitle') }}</p>
<ElForm
ref="formRef"
:model="formData"
:rules="rules"
:key="formKey"
@keyup.enter="handleSubmit"
style="margin-top: 25px"
>
<ElFormItem prop="account">
<ElInput
class="custom-height"
:placeholder="'工号 / 账号'"
v-model.trim="formData.account"
/>
</ElFormItem>
<ElFormItem prop="password">
<ElInput
class="custom-height"
:placeholder="$t('login.placeholder.password')"
v-model.trim="formData.password"
type="password"
autocomplete="off"
show-password
/>
</ElFormItem>
<!-- 左上角品牌 -->
<div class="corner-brand">
<ArtLogo size="30" />
<span>37du 控制台</span>
</div>
<!-- 拖拽验证 -->
<div class="relative pb-5 mt-6">
<div
class="relative z-[2] overflow-hidden select-none rounded-lg border border-transparent tad-300"
:class="{ '!border-[#FF4E4F]': !isPassing && isClickPass }"
>
<ArtDragVerify
ref="dragVerify"
v-model:value="isPassing"
:text="$t('login.sliderText')"
textColor="var(--art-gray-700)"
:successText="$t('login.sliderSuccessText')"
progressBarBg="var(--main-color)"
:background="isDark ? '#26272F' : '#F1F1F4'"
handlerBg="var(--default-box-color)"
/>
</div>
<p
class="absolute top-0 z-[1] px-px mt-2 text-xs text-[#f56c6c] tad-300"
:class="{ 'translate-y-10': !isPassing && isClickPass }"
>
{{ $t('login.placeholder.slider') }}
</p>
</div>
<div style="margin-top: 30px">
<ElButton
class="w-full custom-height"
type="primary"
@click="handleSubmit"
:loading="loading"
v-ripple
>
{{ $t('login.btnText') }}
</ElButton>
</div>
</ElForm>
<!-- 玻璃卡片 -->
<div class="login-card">
<div class="card-head">
<div class="brand-mark">
<ArtLogo size="46" />
</div>
<h2 class="title">{{ greeting }}</h2>
<p class="sub-title">登录 37du 控制台,继续管理插件与执行机</p>
</div>
<ElForm
ref="formRef"
:model="formData"
:rules="rules"
@keyup.enter="handleSubmit"
class="login-form"
>
<ElFormItem prop="account">
<ElInput
class="glass-input"
:prefix-icon="User"
placeholder="账户"
v-model.trim="formData.account"
clearable
/>
</ElFormItem>
<ElFormItem prop="password">
<ElInput
class="glass-input"
:prefix-icon="Lock"
placeholder="密码"
v-model.trim="formData.password"
type="password"
autocomplete="off"
show-password
/>
</ElFormItem>
<div class="form-opts">
<el-checkbox v-model="rememberAccount">记住账户</el-checkbox>
</div>
<ElButton
class="login-btn"
type="primary"
@click="handleSubmit"
:loading="loading"
v-ripple
>
<span v-if="!loading">登录控制台</span>
</ElButton>
</ElForm>
<div class="feature-row">
<div class="feature"><ArtSvgIcon icon="ri:box-3-line" /><span>插件分发</span></div>
<div class="feature"><ArtSvgIcon icon="ri:key-2-line" /><span>账号授权</span></div>
<div class="feature"><ArtSvgIcon icon="ri:line-chart-line" /><span>运行监控</span></div>
</div>
</div>
<div class="page-footer">
<ArtSvgIcon icon="ri:shield-keyhole-line" />
37du 自动化平台 · 内部系统 · 请妥善保管账户信息
</div>
</div>
</template>
<script setup lang="ts">
import { User, Lock } from '@element-plus/icons-vue'
import { useUserStore } from '@/store/modules/user'
import { useI18n } from 'vue-i18n'
import { HttpError } from '@/utils/http/error'
import { fetchLogin, fetchGetUserInfo, fetchUserMenus } from '@/api/auth'
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
import { useSettingStore } from '@/store/modules/setting'
import AuthTopBar from '@/components/core/views/login/AuthTopBar.vue'
defineOptions({ name: 'Login' })
const settingStore = useSettingStore()
const { isDark } = storeToRefs(settingStore)
const { t, locale } = useI18n()
const formKey = ref(0)
const REMEMBER_KEY = '37du-login-account'
watch(locale, () => {
formKey.value++
})
const dragVerify = ref()
const userStore = useUserStore()
const router = useRouter()
const route = useRoute()
const isPassing = ref(false)
const isClickPass = ref(false)
const formRef = ref<FormInstance>()
// 按时段问候
const greeting = computed(() => {
const h = new Date().getHours()
if (h >= 5 && h < 9) return '早上好'
if (h >= 9 && h < 12) return '上午好'
if (h >= 12 && h < 14) return '中午好'
if (h >= 14 && h < 18) return '下午好'
return '晚上好'
})
const formData = reactive({
account: '',
account: localStorage.getItem(REMEMBER_KEY) || '',
password: ''
})
const rules = computed<FormRules>(() => ({
account: [{ required: true, message: '请输入工号/账号', trigger: 'blur' }],
password: [{ required: true, message: t('login.placeholder.password'), trigger: 'blur' }]
}))
const rememberAccount = ref(!!formData.account)
const rules: FormRules = {
account: [{ required: true, message: '请输入账户', trigger: 'blur' }],
password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
}
const loading = ref(false)
@@ -124,10 +130,6 @@
try {
const valid = await formRef.value.validate()
if (!valid) return
if (!isPassing.value) {
isClickPass.value = true
return
}
loading.value = true
const login = await fetchLogin({ account: formData.account, password: formData.password })
@@ -146,15 +148,25 @@
console.error('[Login] fetch me/menus failed:', e)
}
// 初始密码强制改密提示
// 记住账户
try {
if (rememberAccount.value) localStorage.setItem(REMEMBER_KEY, formData.account)
else localStorage.removeItem(REMEMBER_KEY)
} catch (e) {
/* ignore */
}
// 初始密码强制改密:直接引导到个人中心改密页
if (login.must_change_pwd) {
ElMessage.warning('首次登录请尽快修改初始密码')
ElMessage.warning('当前为初始密码,请先修改密码后再使用')
router.push('/system/user-center')
return
}
const redirect = route.query.redirect as string
router.push(redirect || '/')
} catch (error) {
// 展示具体错误(如"账号或密码错误"),而非笼统提示
// 展示具体错误(如"账户或密码错误"),而非笼统提示
if (error instanceof HttpError) {
ElMessage.error(error.message)
} else {
@@ -163,21 +175,10 @@
}
} finally {
loading.value = false
resetDragVerify()
}
}
const resetDragVerify = () => {
dragVerify.value?.reset()
}
</script>
<style scoped>
@import './style.css';
</style>
<style lang="scss" scoped>
:deep(.el-input__wrapper) {
height: 40px !important;
}
</style>
@@ -1,38 +1,366 @@
@reference '@styles/core/tailwind.css';
/* 授权页右侧区域 */
.auth-right-wrap {
@apply absolute inset-0 w-[440px] h-[650px] py-[5px] m-auto overflow-hidden
max-sm:px-7 max-sm:w-full
animate-[slideInRight_0.6s_cubic-bezier(0.25,0.46,0.45,0.94)_forwards]
max-md:animate-none;
.form {
@apply h-full py-[40px];
}
.title {
@apply text-g-900 text-4xl font-semibold max-md:text-3xl max-sm:pt-10;
}
.sub-title {
@apply mt-[10px] text-g-600 text-sm;
}
.custom-height {
@apply !h-[40px];
}
}
/* 滑入动画 */
@keyframes slideInRight {
from {
opacity: 0;
transform: translateX(30px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
/* ============================================================
登录页:极光动态背景 + 点阵纹理 + 玻璃拟态卡片 + 微交互
适配明暗主题与主题色切换(全部走 CSS 变量)
============================================================ */
.login-page {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: 100vh;
overflow: hidden;
background: var(--main-bg, #f5f7fb);
}
/* ---------- 极光光斑(大范围模糊,缓慢漂浮) ---------- */
.blob {
position: absolute;
border-radius: 50%;
filter: blur(90px);
opacity: 0.55;
pointer-events: none;
will-change: transform;
}
.blob-1 {
top: -180px;
left: -120px;
width: 560px;
height: 560px;
background: radial-gradient(circle at 35% 35%,
color-mix(in srgb, var(--el-color-primary) 55%, transparent), transparent 70%);
animation: drift-a 16s ease-in-out infinite alternate;
}
.blob-2 {
right: -160px;
bottom: -200px;
width: 620px;
height: 620px;
background: radial-gradient(circle at 60% 60%,
rgba(124, 92, 255, 0.5), transparent 70%);
animation: drift-b 20s ease-in-out infinite alternate;
}
.blob-3 {
top: 40%;
left: 58%;
width: 380px;
height: 380px;
background: radial-gradient(circle at 50% 50%,
rgba(0, 200, 255, 0.38), transparent 70%);
animation: drift-c 18s ease-in-out infinite alternate;
}
@keyframes drift-a {
0% { transform: translate(0, 0) scale(1); }
100% { transform: translate(90px, 60px) scale(1.12); }
}
@keyframes drift-b {
0% { transform: translate(0, 0) scale(1); }
100% { transform: translate(-80px, -70px) scale(1.08); }
}
@keyframes drift-c {
0% { transform: translate(0, 0) scale(1); }
100% { transform: translate(-60px, 50px) scale(1.15); }
}
/* ---------- 点阵纹理(径向渐隐) ---------- */
.grid-overlay {
position: absolute;
inset: 0;
pointer-events: none;
background-image: radial-gradient(
circle,
color-mix(in srgb, var(--art-gray-400, #9ca3af) 55%, transparent) 1px,
transparent 1px
);
background-size: 26px 26px;
-webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 45%, #000 30%, transparent 75%);
mask-image: radial-gradient(ellipse 90% 80% at 50% 45%, #000 30%, transparent 75%);
opacity: 0.4;
}
/* ---------- 左上角品牌 ---------- */
.corner-brand {
position: absolute;
top: 22px;
left: 26px;
z-index: 20;
display: flex;
align-items: center;
gap: 9px;
font-size: 14px;
font-weight: 500;
color: var(--art-gray-700);
}
/* ---------- 玻璃拟态卡片 ---------- */
.login-card {
position: relative;
z-index: 10;
box-sizing: border-box;
width: 430px;
max-width: calc(100vw - 32px);
padding: 38px 38px 26px;
overflow: hidden;
background: rgba(255, 255, 255, 0.62);
border: 1px solid rgba(255, 255, 255, 0.65);
border-radius: 24px;
box-shadow:
0 30px 80px rgba(31, 38, 88, 0.16),
inset 0 1px 0 rgba(255, 255, 255, 0.7);
backdrop-filter: blur(22px) saturate(160%);
-webkit-backdrop-filter: blur(22px) saturate(160%);
animation: cardIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
@keyframes cardIn {
from {
opacity: 0;
transform: translateY(26px) scale(0.98);
}
to {
opacity: 1;
transform: translateY(0) scale(1);
}
}
/* 顶部主题色流光条 */
.login-card::before {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 3px;
content: '';
background: linear-gradient(90deg,
var(--el-color-primary),
rgba(124, 92, 255, 0.9),
rgba(0, 200, 255, 0.9),
var(--el-color-primary));
background-size: 300% 100%;
animation: sheen 6s linear infinite;
}
@keyframes sheen {
0% { background-position: 0% 0; }
100% { background-position: 300% 0; }
}
.card-head {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}
.brand-mark {
display: flex;
align-items: center;
justify-content: center;
width: 68px;
height: 68px;
margin-bottom: 16px;
background: var(--default-box-color);
border: 1px solid var(--art-border-color, rgba(0, 0, 0, 0.06));
border-radius: 20px;
box-shadow: 0 10px 26px rgba(31, 38, 88, 0.12);
}
.title {
margin: 0;
font-size: 26px;
font-weight: 700;
letter-spacing: 1px;
color: var(--art-gray-900);
}
.sub-title {
margin: 8px 0 0;
font-size: 13px;
color: var(--art-gray-500);
}
/* ---------- 表单 ---------- */
.login-form {
margin-top: 26px;
}
.login-form :deep(.el-form-item) {
margin-bottom: 18px;
}
/* 玻璃质感输入框 */
.login-form :deep(.el-input__wrapper) {
height: 44px;
padding: 0 14px;
background: rgba(255, 255, 255, 0.55);
border-radius: 12px;
box-shadow: 0 0 0 1px var(--art-border-color, rgba(0, 0, 0, 0.08)) inset;
transition: box-shadow 0.25s, background 0.25s;
}
.login-form :deep(.el-input__wrapper:hover) {
box-shadow: 0 0 0 1px color-mix(in srgb, var(--el-color-primary) 45%, transparent) inset;
}
.login-form :deep(.el-input__wrapper.is-focus) {
background: rgba(255, 255, 255, 0.85);
box-shadow:
0 0 0 1px var(--el-color-primary) inset,
0 0 0 4px color-mix(in srgb, var(--el-color-primary) 14%, transparent);
}
.form-opts {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: -6px;
}
/* 渐变主按钮 */
.login-btn {
width: 100%;
height: 44px;
margin-top: 8px;
font-size: 15px;
font-weight: 600;
letter-spacing: 4px;
border: none;
background: linear-gradient(135deg,
var(--el-color-primary) 0%,
color-mix(in srgb, var(--el-color-primary) 72%, #7c5cff) 100%);
box-shadow: 0 10px 24px color-mix(in srgb, var(--el-color-primary) 35%, transparent);
transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
}
.login-btn:hover {
transform: translateY(-1px);
filter: brightness(1.06);
box-shadow: 0 14px 30px color-mix(in srgb, var(--el-color-primary) 45%, transparent);
}
.login-btn:active {
transform: translateY(0) scale(0.99);
}
/* ---------- 特性胶囊 ---------- */
.feature-row {
display: flex;
justify-content: center;
gap: 10px;
margin-top: 22px;
}
.feature {
display: flex;
align-items: center;
gap: 6px;
padding: 6px 14px;
font-size: 12px;
color: var(--art-gray-600);
cursor: default;
background: color-mix(in srgb, var(--el-color-primary) 7%, transparent);
border-radius: 999px;
transition: all 0.2s;
}
.feature svg {
color: var(--el-color-primary);
font-size: 14px;
}
.feature:hover {
color: var(--el-color-primary);
background: color-mix(in srgb, var(--el-color-primary) 14%, transparent);
transform: translateY(-1px);
}
/* ---------- 页脚 ---------- */
.page-footer {
position: absolute;
bottom: 20px;
left: 0;
z-index: 10;
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
width: 100%;
font-size: 12px;
color: var(--art-gray-500);
}
/* ---------- 暗色主题 ---------- */
.dark .login-page {
background: #101116;
}
.dark .blob {
opacity: 0.42;
}
.dark .grid-overlay {
background-image: radial-gradient(
circle,
rgba(255, 255, 255, 0.16) 1px,
transparent 1px
);
opacity: 0.3;
}
.dark .corner-brand {
color: var(--art-gray-300);
}
.dark .login-card {
background: rgba(24, 25, 31, 0.62);
border: 1px solid rgba(255, 255, 255, 0.09);
box-shadow:
0 30px 80px rgba(0, 0, 0, 0.5),
inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.dark .login-form :deep(.el-input__wrapper) {
background: rgba(255, 255, 255, 0.05);
}
.dark .login-form :deep(.el-input__wrapper.is-focus) {
background: rgba(255, 255, 255, 0.09);
}
.dark .brand-mark {
background: rgba(255, 255, 255, 0.04);
border-color: rgba(255, 255, 255, 0.08);
}
.dark .title {
color: var(--art-gray-100);
}
.dark .feature {
background: rgba(255, 255, 255, 0.05);
color: var(--art-gray-300);
}
.dark .page-footer {
color: var(--art-gray-500);
}
/* ---------- 小屏适配 ---------- */
@media (width <= 640px) {
.login-card {
padding: 30px 22px 20px;
border-radius: 18px;
}
.corner-brand {
display: none;
}
}
@@ -1,240 +0,0 @@
<!-- 注册页面 -->
<template>
<div class="flex w-full h-screen">
<LoginLeftView />
<div class="relative flex-1">
<AuthTopBar />
<div class="auth-right-wrap">
<div class="form">
<h3 class="title">{{ $t('register.title') }}</h3>
<p class="sub-title">{{ $t('register.subTitle') }}</p>
<ElForm
class="mt-7.5"
ref="formRef"
:model="formData"
:rules="rules"
label-position="top"
:key="formKey"
>
<ElFormItem prop="username">
<ElInput
class="custom-height"
v-model.trim="formData.username"
:placeholder="$t('register.placeholder.username')"
/>
</ElFormItem>
<ElFormItem prop="password">
<ElInput
class="custom-height"
v-model.trim="formData.password"
:placeholder="$t('register.placeholder.password')"
type="password"
autocomplete="off"
show-password
/>
</ElFormItem>
<ElFormItem prop="confirmPassword">
<ElInput
class="custom-height"
v-model.trim="formData.confirmPassword"
:placeholder="$t('register.placeholder.confirmPassword')"
type="password"
autocomplete="off"
@keyup.enter="register"
show-password
/>
</ElFormItem>
<ElFormItem prop="agreement">
<ElCheckbox v-model="formData.agreement">
{{ $t('register.agreeText') }}
<RouterLink
style="color: var(--theme-color); text-decoration: none"
to="/privacy-policy"
>{{ $t('register.privacyPolicy') }}</RouterLink
>
</ElCheckbox>
</ElFormItem>
<div style="margin-top: 15px">
<ElButton
class="w-full custom-height"
type="primary"
@click="register"
:loading="loading"
v-ripple
>
{{ $t('register.submitBtnText') }}
</ElButton>
</div>
<div class="mt-5 text-sm text-g-600">
<span>{{ $t('register.hasAccount') }}</span>
<RouterLink class="text-theme" :to="{ name: 'Login' }">{{
$t('register.toLogin')
}}</RouterLink>
</div>
</ElForm>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
import type { FormInstance, FormRules } from 'element-plus'
defineOptions({ name: 'Register' })
interface RegisterForm {
username: string
password: string
confirmPassword: string
agreement: boolean
}
const USERNAME_MIN_LENGTH = 3
const USERNAME_MAX_LENGTH = 20
const PASSWORD_MIN_LENGTH = 6
const REDIRECT_DELAY = 1000
const { t, locale } = useI18n()
const router = useRouter()
const formRef = ref<FormInstance>()
const loading = ref(false)
const formKey = ref(0)
// 监听语言切换,重置表单
watch(locale, () => {
formKey.value++
})
const formData = reactive<RegisterForm>({
username: '',
password: '',
confirmPassword: '',
agreement: false
})
/**
* 验证密码
* 当密码输入后,如果确认密码已填写,则触发确认密码的验证
*/
const validatePassword = (_rule: any, value: string, callback: (error?: Error) => void) => {
if (!value) {
callback(new Error(t('register.placeholder.password')))
return
}
if (formData.confirmPassword) {
formRef.value?.validateField('confirmPassword')
}
callback()
}
/**
* 验证确认密码
* 检查确认密码是否与密码一致
*/
const validateConfirmPassword = (
_rule: any,
value: string,
callback: (error?: Error) => void
) => {
if (!value) {
callback(new Error(t('register.rule.confirmPasswordRequired')))
return
}
if (value !== formData.password) {
callback(new Error(t('register.rule.passwordMismatch')))
return
}
callback()
}
/**
* 验证用户协议
* 确保用户已勾选同意协议
*/
const validateAgreement = (_rule: any, value: boolean, callback: (error?: Error) => void) => {
if (!value) {
callback(new Error(t('register.rule.agreementRequired')))
return
}
callback()
}
const rules = computed<FormRules<RegisterForm>>(() => ({
username: [
{ required: true, message: t('register.placeholder.username'), trigger: 'blur' },
{
min: USERNAME_MIN_LENGTH,
max: USERNAME_MAX_LENGTH,
message: t('register.rule.usernameLength'),
trigger: 'blur'
}
],
password: [
{ required: true, validator: validatePassword, trigger: 'blur' },
{ min: PASSWORD_MIN_LENGTH, message: t('register.rule.passwordLength'), trigger: 'blur' }
],
confirmPassword: [{ required: true, validator: validateConfirmPassword, trigger: 'blur' }],
agreement: [{ validator: validateAgreement, trigger: 'change' }]
}))
/**
* 注册用户
* 验证表单后提交注册请求
*/
const register = async () => {
if (!formRef.value) return
try {
await formRef.value.validate()
loading.value = true
// TODO: 替换为真实 API 调用
// const params = {
// username: formData.username,
// password: formData.password
// }
// const res = await AuthService.register(params)
// if (res.code === ApiStatus.success) {
// ElMessage.success('注册成功')
// toLogin()
// }
// 模拟注册请求
setTimeout(() => {
loading.value = false
ElMessage.success('注册成功')
toLogin()
}, REDIRECT_DELAY)
} catch (error) {
console.error('表单验证失败:', error)
loading.value = false
}
}
/**
* 跳转到登录页面
*/
const toLogin = () => {
setTimeout(() => {
router.push({ name: 'Login' })
}, REDIRECT_DELAY)
}
</script>
<style scoped>
@import '../login/style.css';
</style>
@@ -25,7 +25,7 @@ async function loadAccounts() {
accounts.value = d.accounts || []
accountsLoaded.value = true
} catch (e) {
/* 拉取失败不阻断,仍可手输工号 */
/* 拉取失败不阻断,仍可手动输入账号 */
}
}
@@ -158,7 +158,7 @@ onMounted(load)
<el-select
v-model="form.account"
filterable
placeholder="搜索昵称 / 工号选择账号"
placeholder="搜索昵称 / 账号选择"
style="width: 100%"
>
<el-option
@@ -71,6 +71,50 @@ async function setStatus(row: any, status: string) {
load()
}
// ---- 强制更新 ----
const forceOpen = ref(false)
const forceSaving = ref(false)
const forceForm = reactive({ plugin_id: '', force_min_version: '', force_deadline: '' })
function openForce(row: any) {
Object.assign(forceForm, {
plugin_id: row.id,
force_min_version: row.force_min_version || '',
force_deadline: row.force_deadline || ''
})
forceOpen.value = true
}
async function submitForce() {
if (!forceForm.force_min_version || !forceForm.force_deadline) {
ElMessage.warning('最低版本与截止时间必须同时填写')
return
}
forceSaving.value = true
try {
await patchPlugin(forceForm.plugin_id, {
force_min_version: forceForm.force_min_version,
force_deadline: forceForm.force_deadline
})
ElMessage.success(`已设置强制更新:低于 v${forceForm.force_min_version} 的执行机将在截止时间前强制升级`)
forceOpen.value = false
load()
} finally {
forceSaving.value = false
}
}
async function clearForce(row: any) {
await ElMessageBox.confirm(`清除插件「${row.id}」的强制更新设置?`, '确认', { type: 'warning' })
await patchPlugin(row.id, { clear_force: true })
ElMessage.success('已清除强制更新')
load()
}
function fmtDeadline(s: string): string {
return String(s || '').replace('T', ' ').slice(0, 16)
}
// ---- 删除 ----
async function remove(row: any) {
await ElMessageBox.confirm(`确认删除插件「${row.id}」?将连带删除版本与授权。`, '删除确认', {
@@ -119,7 +163,7 @@ onMounted(load)
</el-tag>
</template>
</el-table-column>
<el-table-column label="版本历史" width="220">
<el-table-column label="版本历史" width="100">
<template #default="{ row }">
<el-tooltip v-if="row.versions?.length" :content="row.versions.map((v: any) => v.version).join(', ')">
<el-tag size="small" type="info">{{ row.versions.length }} 个版本</el-tag>
@@ -127,7 +171,20 @@ onMounted(load)
<span v-else class="text-gray-400">-</span>
</template>
</el-table-column>
<el-table-column label="操作" width="220" fixed="right">
<el-table-column label="强制更新" min-width="170">
<template #default="{ row }">
<el-tooltip
v-if="row.force_min_version"
:content="`低于 v${row.force_min_version} 的执行机须在 ${fmtDeadline(row.force_deadline)} 前完成升级`"
>
<el-tag size="small" type="danger" effect="light">
≥v{{ row.force_min_version }} · 至 {{ fmtDeadline(row.force_deadline) }}
</el-tag>
</el-tooltip>
<span v-else class="text-gray-300 text-xs">未设置</span>
</template>
</el-table-column>
<el-table-column label="操作" width="250" fixed="right">
<template #default="{ row }">
<el-button
v-if="row.status === 'disabled'"
@@ -144,6 +201,8 @@ onMounted(load)
link type="danger"
@click="setStatus(row, 'revoked')"
>下架</el-button>
<el-button link type="warning" @click="openForce(row)">强制更新</el-button>
<el-button v-if="row.force_min_version" link type="info" @click="clearForce(row)">清除</el-button>
<el-button link type="danger" @click="remove(row)">删除</el-button>
</template>
</el-table-column>
@@ -180,5 +239,31 @@ onMounted(load)
<el-button type="primary" :loading="uploading" @click="submitUpload">发布</el-button>
</template>
</el-dialog>
<!-- 强制更新弹窗 -->
<el-dialog v-model="forceOpen" :title="`强制更新 — ${forceForm.plugin_id}`" width="480px">
<el-form label-width="100px">
<el-form-item label="最低版本" required>
<el-input v-model="forceForm.force_min_version" placeholder="如 1.3.0(低于该版本将强制升级)" />
</el-form-item>
<el-form-item label="截止时间" required>
<el-date-picker
v-model="forceForm.force_deadline"
type="datetime"
placeholder="选择强制升级截止时间"
format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
style="width: 100%"
/>
</el-form-item>
<div class="px-1 text-xs text-gray-400 leading-5">
设置后:客户端 /api/plugins 将下发 force_min_version 与 force_deadline,
执行机壳子对低于最低版本的插件在截止时间前强制升级(旧版本不可继续运行)。
</div>
</el-form>
<template #footer>
<el-button @click="forceOpen = false">取消</el-button>
<el-button type="primary" :loading="forceSaving" @click="submitForce">设置</el-button>
</template>
</el-dialog>
</div>
</template>
@@ -2,7 +2,7 @@ import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { fileURLToPath } from 'url'
import vueDevTools from 'vite-plugin-vue-devtools'
// import vueDevTools from 'vite-plugin-vue-devtools' // Vue DevTools 悬浮调试入口已移除(内部系统不需要;生产构建本就不含)
import viteCompression from 'vite-plugin-compression'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
@@ -106,7 +106,7 @@ export default ({ mode }: { mode: string }) => {
threshold: 10240, // 只有大小大于该值的资源会被处理 10240B = 10KB
deleteOriginFile: false // 压缩后是否删除原文件
}),
vueDevTools()
// Vue DevTools 悬浮调试入口已移除(内部系统不需要;生产构建本就不含)
// 打包分析
// visualizer({
// open: true,
@@ -66,8 +66,9 @@ belongUnitStruId/struId 用员工岗位 org(tab 行 pt_staff_stru.STRU_ID)
接口版已实测 7 人全部提交成功并落库(谢丹首单 + 全跑 6 人)。
运行方式:
1. 影刀:注册为自定义指令「XQ0034续签电子签」,main(dry_run=...) 关键字传参;
2. 业务脚本:importlib 加载本模块调用 main(dry_run=False)(环境变量 XQ0034_DRY_RUN=0 同效)。
1. 影刀:注册为自定义指令「XQ0034续签电子签」,main(dry_run=...) 关键字传参(不传=实跑);
2. 业务脚本:importlib 加载本模块调用 main()(试算需显式 main(dry_run=True)
或设环境变量 XQ0034_DRY_RUN=1)。
全局变量:messages(结果摘要文本列表,供「37du钉钉群机器人推送」指令逐条发送)。
"""
@@ -597,13 +598,14 @@ def main(dry_run=None):
① 是否续签=否 且 人资是否推送为空 -> 人资是否推送=否;
② 是否续签=是 且 人资是否推送为空 -> HR 生效中合同属性页「续签合同」提交
(新合同信息直接取 AI 表字段),成功后回填人资是否推送=是、推送时间=期望推送日期。
dry_run: 默认取环境变量 XQ0034_DRY_RUN(缺省 "1"=试算,只读不写);
影刀实跑显式传 dry_run=False。
dry_run: 默认取环境变量 XQ0034_DRY_RUN(缺省 "0"=实跑提交;
设 XQ0034_DRY_RUN=1 为试算只读不写,试算结果走"试算通过"提示);
影刀调用可不传参直接实跑。
Returns:
{"success": bool, "message": str, "results": [...]}
"""
dry_run = (os.environ.get("XQ0034_DRY_RUN", "1") == "1"
dry_run = (os.environ.get("XQ0034_DRY_RUN", "0") == "1"
if dry_run is None else bool(dry_run))
results = []
try:
@@ -18,9 +18,12 @@
3. 业务脚本:懒加载本模块调用 main(...) / run_step1(...)
依赖安装(启动校验:所有库必须预先装齐,任一缺失启动即报错退出,不懒加载):
pip install requests websocket-client pandas pywin32
(推送工作簿写入/重算走 WPS 表格 COM(Ket.Application,回退 MS Excel),
机器需装有 WPS 专业版/企业版或 MS Excel)
pip install pandas openpyxl
(推送工作簿写入为 openpyxl 直写,不经 WPS/Excel COM —— COM 写 naive datetime
会按本地时区转 UTC 落盘,时间列整体 -8 小时(2026-10-15 实测踩坑,2026-10-16
修正);文件被 WPS/Excel 打开占用时保存会报错,需先关闭。openpyxl 保存清全簿
公式缓存,公式保留且已设打开自动重算,「是否需要发起改签」判断由 step2 在
Python 侧按规则复算,不读公式缓存)
登录态:读取 %LOCALAPPDATA%\\37duAutomation\\.sessions\\hr_cookies.json(由「37duHR登录」指令写入);
缺失/失效时共享指令会抛 LoginRequiredError,不自动补登,需先重新执行「37duHR登录」指令。
@@ -29,10 +32,11 @@
调动台账.xlsx 共享指令导出的近一月台账原文(模板=调动改签电子签导出模板)
调动改签近2天名单.xlsx 按操作时间筛选后的名单(含全部模板列)
{YYYYMM} 每日推送调动改签名单{MMDD}.xlsx
每日推送工作簿(无则复制最近前一天改名)。写入走 WPS/Excel COM
单会话:取消全部 sheet 筛选 -> 只清「调动导出」值列(第1~32列)
重写当前窗口记录(公式列/人工列不动、绝不删行)-> 全量重算公式
-> 保存(XQ0002 同款做法;文件被 WPS 打开时直接复用工作簿)
每日推送工作簿(无则复制最近前一天改名)。openpyxl 直写:
取消全部 sheet 筛选 -> 只清「调动导出」值列(第1~32列)
重写当前窗口记录(公式列/人工列不动、绝不删行)-> 保存
(时间列原样落值无时区换算;公式缓存随保存清空,已设
fullCalcOnLoad,WPS/Excel 打开自动全量重算显示)
"""
# ==================== 标准库导入 ====================
@@ -47,12 +51,11 @@ from datetime import date, datetime
# ==================== 第三方库导入(启动校验:全部必须预先安装,不懒加载) ====================
try:
import pandas as pd
import pythoncom
import win32com.client
from openpyxl import load_workbook
except ImportError as _import_err:
raise RuntimeError(
"缺少必需依赖,无法启动(影刀版要求所有库在启动前装齐,不懒加载)。\n"
"请先执行安装:\n pip install pandas pywin32\n"
"请先执行安装:\n pip install pandas openpyxl\n"
f"缺失依赖详情: {_import_err}")
# ==================== 共享指令懒加载(复用「37du调动台账导出」纯接口版) ====================
@@ -222,19 +225,21 @@ def find_or_create_target(output_dir: str, today: date = None) -> str:
return target_path
# ==================== 每日推送工作簿写入(WPS/Excel COM 单会话:清值列+写入+取消筛选+重算+保存) ====================
def write_and_recalc(target_path: str, df: pd.DataFrame) -> int:
"""把筛选名单写进推送工作簿「调动导出」sheet,全程 WPS/Excel COM 单会话完成。
# ==================== 每日推送工作簿写入(openpyxl 直写:取消筛选+清值列+写入+保存) ====================
def write_push_values(target_path: str, df: pd.DataFrame) -> int:
"""把筛选名单直写进推送工作簿「调动导出」sheet(openpyxl,不经 WPS/Excel COM)。
为什么不用 openpyxl 写入:目标文件常被用户在 WPS 中打开(有文件锁),
openpyxl 保存必报 PermissionError(已踩坑);COM 可复用已打开的工作簿直接写。
为什么不用 COM:pywin32 把 naive datetime 当本地时间转 UTC 再落 COM VARIANT
DATE,WPS/Excel 显示的时间整体 -8 小时(2026-10-15 实测踩坑);openpyxl 直写
datetime 原样落序列值,无时区换算。
写入规则(用户确认 2026-10-12):
写入规则(延续 2026-10-12 确认口径):
- 只清值列(第 1~32 列,序号~备注)后重写当前窗口记录,旧记录随窗口滚动淘汰;
- 预填公式列(第 33 列起:跨序列/是否跨门店/类型判断/是否需要发起改签/离职类型/
前序发起日期)与人工备注列一概不动、绝不删行(删行会连预填公式一起删掉);
- 写入前取消全部 sheet 筛选(残留筛选的隐藏行会导致维护错位,XQ0002 同款教训);
- 写入后 CalculateFullRebuild 全量重算并 Save,把公式缓存值写回磁盘。
- 写入前取消全部 sheet 筛选(残留筛选的隐藏行会导致维护错位);
- 保存设置 fullCalcOnLoad:公式缓存随保存清空,WPS/Excel 打开自动全量重算显示;
- 「是否需要发起改签」不再依赖公式缓存 —— step2 在 Python 侧按规则复算。
Args:
target_path: 推送工作簿路径
@@ -244,7 +249,7 @@ def write_and_recalc(target_path: str, df: pd.DataFrame) -> int:
写入行数
Raises:
RuntimeError: COM 不可用、sheet/表头不匹配、列越界或写入失败
RuntimeError: 文件不存在、sheet/表头不匹配、列越界或文件被 WPS/Excel 占用
"""
if len(df.columns) > VALUE_COL_END:
raise RuntimeError(f"名单列数 {len(df.columns)} 超过值列边界 {VALUE_COL_END}")
@@ -259,109 +264,79 @@ def write_and_recalc(target_path: str, df: pd.DataFrame) -> int:
target_path = os.path.abspath(target_path)
if not os.path.isfile(target_path):
raise RuntimeError(f"推送工作簿不存在:{target_path}")
pythoncom.CoInitialize()
app, wb, engine, already_open = None, None, "", False
try:
wb = load_workbook(target_path)
except PermissionError as exc:
raise RuntimeError(
f"文件被占用,无法写入:{target_path}\n"
"请先在 WPS/Excel 中关闭该文件后重试。") from exc
try:
# 1. 取消所有 sheet 的筛选(隐藏行残留会让维护/对账错位)
removed = 0
for ws in wb.worksheets:
if ws.auto_filter.ref:
ws.auto_filter.ref = None
removed += 1
ws = wb[TARGET_SHEET]
# 2. 校验值列表头(表头行)
hdr_raw = [ws.cell(row=TARGET_HEADER_ROW, column=c).value
for c in range(1, len(expected) + 1)]
hdr = [str(h).replace("\n", "").strip() if h is not None else ""
for h in hdr_raw]
if hdr != expected:
raise RuntimeError(
f"「{TARGET_SHEET}」表头与导出列不匹配。\n sheet 表头:{hdr}\n 导出列:{expected}")
# 3. 模板行(首个数据行)各列数字格式:新写入行格式为 General 时继承
fmt_by_col = {}
for idx in range(1, len(expected) + 1):
fmt = ws.cell(row=TARGET_HEADER_ROW + 1, column=idx).number_format
if fmt and fmt != "General":
fmt_by_col[idx] = fmt
# 4. 清空数据区值列(表头行之下到工作表末行,仅第1~32列;公式列/人工列不动)
last = ws.max_row
if last > TARGET_HEADER_ROW:
for r in range(TARGET_HEADER_ROW + 1, last + 1):
for c in range(1, VALUE_COL_END + 1):
ws.cell(row=r, column=c).value = None
# 5. 逐行写入当前窗口记录(NaN/NaT→空、Timestamp→datetime 原样落值,无时区换算)
n = len(df_out)
for i, row in enumerate(df_out.itertuples(index=False, name=None)):
r = TARGET_HEADER_ROW + 1 + i
for c, v in enumerate(row, start=1):
if pd.isna(v):
v = None
elif isinstance(v, pd.Timestamp):
v = v.to_pydatetime()
cell = ws.cell(row=r, column=c)
if isinstance(v, datetime) and cell.number_format == "General":
cell.number_format = fmt_by_col.get(c, "yyyy/mm/dd hh:mm:ss")
cell.value = v
# 6. 打开自动全量重算(公式列显示值由 WPS/Excel 打开时算出)并保存
try:
app = win32com.client.Dispatch("Ket.Application")
engine = "WPS"
except Exception:
try:
app = win32com.client.Dispatch("Excel.Application")
engine = "Excel"
except Exception as e:
raise RuntimeError(
"本机未检测到可用的 WPS 表格 COM / MS Excel COM,无法写入推送工作簿。\n"
"请安装 WPS 专业版/企业版或 MS Excel 后重试。") from e
# 不设置 Visible=False:Dispatch 可能附着到用户已打开的实例,隐藏其窗口
app.DisplayAlerts = False
wb.calculation.fullCalcOnLoad = True
except AttributeError:
pass
try:
for w in app.Workbooks:
try:
if os.path.normcase(str(w.FullName or "")) == os.path.normcase(target_path):
wb, already_open = w, True
break
except Exception:
continue
if wb is None:
wb = app.Workbooks.Open(target_path, UpdateLinks=2)
# 1. 取消所有 sheet 的筛选(隐藏行残留会让维护/对账错位)
removed = 0
for ws in wb.Worksheets:
try:
if ws.AutoFilterMode:
ws.AutoFilterMode = False
removed += 1
except Exception:
pass
# 2. 定位「调动导出」sheet 并校验值列表头
ws = wb.Worksheets(TARGET_SHEET)
hdr_range = ws.Range(ws.Cells(TARGET_HEADER_ROW, 1),
ws.Cells(TARGET_HEADER_ROW, len(expected))).Value
hdr = [str(h).replace("\n", "").strip() if h is not None else ""
for h in (hdr_range[0] if isinstance(hdr_range, tuple) else hdr_range)]
if hdr != expected:
raise RuntimeError(
f"「{TARGET_SHEET}」表头与导出列不匹配。\n sheet 表头:{hdr}\n 导出列:{expected}")
# 3. 清空数据区值列(表头行之下到已用区末行,仅第1~32列;公式列/人工列不动)
last = ws.UsedRange.Row + ws.UsedRange.Rows.Count - 1
if last > TARGET_HEADER_ROW:
ws.Range(ws.Cells(TARGET_HEADER_ROW + 1, 1),
ws.Cells(last, VALUE_COL_END)).ClearContents()
# 4. 批量写入当前窗口记录(一次 Range 赋二维数组;NaN→空、Timestamp→datetime)
n = len(df_out)
if n:
arr = tuple(
tuple(
None if pd.isna(v)
else (v.to_pydatetime() if isinstance(v, pd.Timestamp) else v)
for v in row)
for row in df_out.itertuples(index=False, name=None))
ws.Range(ws.Cells(TARGET_HEADER_ROW + 1, 1),
ws.Cells(TARGET_HEADER_ROW + n, len(expected))).Value = arr
# 5. 全量重算公式(预填公式列按新值出结果)并保存
wb.Application.CalculateFullRebuild()
wb.Save()
logger.info("已写入「%s」%d 条(值列第1~%d列,公式列未动),取消 %d 个 sheet 筛选"
"(%s COM%s),重算保存完成:%s",
TARGET_SHEET, n, VALUE_COL_END, removed, engine,
",复用已打开工作簿" if already_open else "", target_path)
return n
finally:
try:
app.DisplayAlerts = True
except Exception:
pass
if wb is not None and not already_open:
try:
wb.Close(SaveChanges=False)
except Exception:
pass
wb.save(target_path)
except PermissionError as exc:
raise RuntimeError(
f"保存失败,文件被占用:{target_path}\n"
"请先在 WPS/Excel 中关闭该文件后重试。") from exc
logger.info("已写入「%s」%d 条(值列第1~%d列,公式列未动),取消 %d 个 sheet 筛选"
"(openpyxl 直写,不经 COM):%s",
TARGET_SHEET, n, VALUE_COL_END, removed, target_path)
return n
except RuntimeError:
raise
except Exception as e:
raise RuntimeError(
f"推送工作簿写入失败({engine or 'COM'}):{e}\n"
"请确认文件未被 WPS/Excel 以受保护视图/只读打开(关闭后再试)。") from e
finally:
if app is not None:
# 仅当实例已无其他工作簿时才退出,避免关掉用户正在使用的 WPS/Excel
try:
if app.Workbooks.Count == 0:
app.Quit()
except Exception:
pass
try:
pythoncom.CoUninitialize()
except Exception:
pass
raise RuntimeError(f"推送工作簿写入失败(openpyxl):{e}") from e
@@ -397,8 +372,8 @@ def run_step1(output_dir: str = None, days: int = FILTER_DAYS,
# 3. 找/建当天推送工作簿
target_path = find_or_create_target(output_dir)
# 4. COM 单会话写入:取消筛选 -> 清值列重贴 -> 全量重算 -> 保存
pasted = write_and_recalc(target_path, result)
# 4. openpyxl 直写:取消筛选 -> 清值列重贴 -> 保存(打开自动重算,不经 COM)
pasted = write_push_values(target_path, result)
logger.info("===== XQ0037 第一步完成:名单 %d 条 -> %s =====", pasted, target_path)
return {"success": True, "raw_path": raw_path, "filtered_path": filtered_path,
@@ -4,10 +4,12 @@
@Author: 小布丁
@CreateTime: 2026-10-12
@Description: XQ0037 调动改签离职电子签 —— 第二步:改签名单贴入发起名单 + HR 变更电子签状态。
环节一(贴名单):从当天推送工作簿「调动导出」sheet 筛选「是否需要发起改签」
列(第39列,公式缓存值)="需要" 的记录,把 B~AF 列(第2~32列,姓名~备注)
直接复制,追加到同工作簿「本月发起名单」sheet 的 B~AF 列;追加去重键 =
工号 + 操作时间,「本月发起名单」的序号/公式列/其他列一概不动。
环节一(贴名单):从当天推送工作簿「调动导出」sheet 按 Python 复算的
「是否需要发起改签」规则筛选"需要"记录(推送表第39列公式存在多个历史
版本,且 step1 改 openpyxl 直写后公式缓存为空,不再读缓存判断),把
B~AF 列(第2~32列,姓名~备注)直接复制,追加到同工作簿「本月发起名单」
sheet 的 B~AF 列;追加去重键 = 工号 + 操作时间,「本月发起名单」的
序号/公式列/其他列一概不动。
环节二(变更电子签状态):对"需要"名单逐条在 HR「调动台账-调动已生效」Tab
(rosterId=10feec75)定位调动记录(MOVE_ID),调属性页
「变更离职电子签状态」(propertyPageId=1f3dada4...,getPropPageData →
@@ -23,14 +25,15 @@
依赖安装(启动校验:所有库必须预先装齐,任一缺失启动即报错退出,不懒加载):
pip install pandas openpyxl requests
(名单写入为 openpyxl 直写(不经 WPS COM);文件被 WPS/Excel 打开占用时会报错提示关闭。
openpyxl 保存会清全簿公式缓存值——公式保留、WPS 打开自动重算显示;「调动导出」判断列
缓存由下一次 step1 的 WPS 重算恢复,本脚本对缓存缺失有明确报错保护。
(名单读写均为 openpyxl 直写(不经 WPS COM);文件被 WPS/Excel 打开占用时会报错
提示关闭。openpyxl 保存会清全簿公式缓存——公式保留、step1 已设打开自动重算,
WPS/Excel 打开即恢复显示;「是否需要发起改签」由本模块按第39列公式最新版规则
在 Python 侧复算,不读公式缓存。
HR 会话复用共享指令「37duHR登录」cookies,失效时经 ensure_login 自动重登)
输入输出(目录 D:\\资料\\人资\\调动改签离职电子签\\):
输入:{YYYYMM} 每日推送调动改签名单{MMDD}.xlsx(当天文件,step1 产出并已 WPS 重算)
输出:同文件「本月发起名单」sheet 追加"需要"记录(B~AF),公式列不动,重算保存;
输入:{YYYYMM} 每日推送调动改签名单{MMDD}.xlsx(当天文件,step1 产出)
输出:同文件「本月发起名单」sheet 追加"需要"记录(B~AF),公式列不动;
HR 侧对应调动记录 ext_is_leave_sign / ext_is_new_contract 置 1
"""
@@ -70,18 +73,33 @@ logger = _PrintLogger()
DEFAULT_OUTPUT_DIR = r"D:\资料\人资\调动改签离职电子签"
# 当天推送文件命名:{YYYYMM} 每日推送调动改签名单{MMDD}.xlsx
TARGET_FILE_RE = re.compile(r"^(20\d{6}) 每日推送调动改签名单(\d{4})\.xlsx$")
SOURCE_SHEET = "调动导出" # 来源 sheet(step1 已写入并重算)
SOURCE_SHEET = "调动导出" # 来源 sheet(step1 已写入)
TARGET_SHEET = "本月发起名单" # 追加目标 sheet
SOURCE_HEADER_ROW = 2 # 「调动导出」表头行(第1行说明行)
SOURCE_HEADER_ROW = 2 # 「调动导出」表头行(第1行说明行),数据从第3行起
MONTHLY_HEADER_ROW = 1 # 「本月发起名单」表头行(单行表头,数据从第2行起)
JUDGE_COL = 39 # 「调动导出」是否需要发起改签(公式列,读缓存值)
JUDGE_VALUE = "需要" # 命中值
JUDGE_VALUE = "需要" # 「是否需要发起改签」命中值(自动发起)
JUDGE_MANUAL = "人工处理" # 职能相关 -> 人工处理(不自动发起,仅日志提示跟进)
JUDGE_VENUE = "会馆" # 培训会馆分支:HR 已批量发起改签离职签流程,跳过 HR 置位,
# 直接登记待办进 step3(完善信息,是否新签合同=否)+ step4 管道
COPY_COL_START, COPY_COL_END = 2, 32 # B~AF 列(姓名~备注),两边 sheet 布局一致
KEY_CODE_COL, KEY_NAME_COL = 3, 2 # 去重键列:工号 + 姓名(去重键=工号+调动时间(按天),
# 缺调动时间时回退工号+姓名,见 append_to_monthly)
TRANSFER_TIME_COL = "调动时间" # 去重键组成部分(按天归一:吸收 COM 写入 ±8h 时区漂移,
TRANSFER_TIME_COL = "调动时间" # 去重键组成部分(按天归一:吸收时间写入/解析的偏差,
# 同人工号在不同调动日调动多次时各自保留,不再漏掉第二笔)
# ---------- 「是否需要发起改签」Python 复算规则 ----------
# 对应推送表「调动导出」第39列公式最新版(2026-10 版:行3~158 区间公式);
# 该列公式在表内存在多个历史版本(行159 过渡版、行160 以下旧版排除条件为
# 现四级部门=培训学校),且 openpyxl 保存后公式缓存为空,故统一按最新版规则
# 在 Python 侧复算 —— HR 调整第39列公式时必须同步修改此处。
EXCLUDE_DEPT = "职业技术培训会馆" # 原/现四级部门任一命中即排除
EXCLUDE_SEQ_KEYWORD = "职能" # 原/现职位序列任一含此关键词 -> 人工处理(2026-10-16 新公式
# 第一分支:SEARCH 子串命中,优先级最高,不自动发起)
EXCLUDE_SEQ_EXACT_FROM = "职能系管理序列" # 原职位序列精确等于 -> "-"(实际被含职能先拦截,防御保留)
EXCLUDE_SEQ_EXACT_TO = "管理系专业序列" # 现职位序列精确等于 -> "-"(不含"职能",可达)
MENU_SHEET = "菜单" # 类型判断 VLOOKUP 数据源(A列调动类型/B列是否需要发起改签流程)
TYPE_PENDING = "待定" # 类型判断 = 待定 才参与「跨门店+待定」分支
# ==================== 环节二(HR 变更电子签状态)常量 ====================
SHARE_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "share")
CSRF_HEADERS = {"X-Requested-With": "XMLHttpRequest", "Csrf-Token": "RP"}
@@ -115,49 +133,133 @@ def find_today_target(output_dir: str, today: date = None) -> str:
return target_path
# ==================== 读取「需要」名单 ====================
def read_needed_rows(target_path: str) -> pd.DataFrame:
"""从「调动导出」读「是否需要发起改签」="需要" 的行,返回 B~AF 列数据。
# ==================== 「需要」名单(Python 复算第39列规则) ====================
def _load_menu_types(wb) -> dict:
"""读「菜单」sheet A/B 列 -> {调动类型: 是否需要发起改签流程}(动态跟随人工维护)。"""
if MENU_SHEET not in wb.sheetnames:
raise RuntimeError(
f"推送文件缺少「{MENU_SHEET}」sheet(类型判断数据源):{wb.sheetnames}")
mws = wb[MENU_SHEET]
menu = {}
for row in mws.iter_rows(min_row=1, max_col=2, values_only=True):
a = row[0]
b = row[1] if len(row) > 1 else None
if a is None:
continue
a = str(a).strip()
if not a or a == "调动类型": # 表头行
continue
menu[a] = str(b).strip() if b is not None else ""
return menu
「调动导出」表头在第2行;第39列为公式列,读 WPS 重算后的缓存值
(openpyxl data_only=True),所以本脚本必须在 step1 之后执行。
def _judge_need(row: dict, menu: dict) -> str:
"""复算「是否需要发起改签」第39列公式最新版,返回 "-" / "已发" / "需要" / "人工处理"。
对应公式(第39列,2026-10-16 HR 新版,行号以 10 为例):
=IF(OR(IFERROR(SEARCH("职能",M10),0),IFERROR(SEARCH("职能",W10),0)), "人工处理",
IF(OR(U10="职业技术培训会馆",K10="职业技术培训会馆",
M10="职能系管理序列",W10="管理系专业序列"), "-",
IF(AD10="是","已发",
IF(AK10="是","-",
IF(AG10=1,"需要",
IF(AND(AH10=1,AI10="待定"),"需要","-"))))))
M/W = 原/现职位序列;U/K = 现/原四级部门;AD = 是否已发起流程;
AG = 跨序列(原职位序列<>现职位序列 -> 1);
AK = 是否转岗技师(跨序列且现职位序列含"技师" -> "是");
AH = 是否跨门店(IFS 数组:现单位含"金色印象"比原/现五段路径拼接、
含"金色湖畔"比三段路径拼接,均不等->1;其他单位无分支 -> #N/A);
AI = 类型判断(VLOOKUP 调动类型 -> 菜单表,未命中 #N/A)。
"""
def s(v):
return "" if v is None else str(v).strip()
seq_from, seq_to = s(row.get("原职位序列")), s(row.get("现职位序列"))
# 第一分支(最高优先级):原/现职位序列任一含"职能" -> 人工处理
if EXCLUDE_SEQ_KEYWORD in seq_from or EXCLUDE_SEQ_KEYWORD in seq_to:
return JUDGE_MANUAL
if seq_from == EXCLUDE_SEQ_EXACT_FROM or seq_to == EXCLUDE_SEQ_EXACT_TO:
return "-"
if EXCLUDE_DEPT in (s(row.get("现四级部门")), s(row.get("原四级部门"))):
# 培训会馆:HR 侧批量发起「改签离职电子签」流程(不需要新签合同),
# 本脚本跳过 HR 置位,检测到「是否已发起流程=是」后直接进完善信息管道
return JUDGE_VENUE
if s(row.get("是否已发起流程")) == "是":
return "已发"
cross_seq = 0 if seq_from == seq_to else 1
if cross_seq == 1 and "技师" in seq_to: # AK = 是
return "-"
if cross_seq == 1: # AG = 1
return "需要"
def path(cols):
return "".join(s(row.get(k)) for k in cols)
cur_unit = s(row.get("现单位"))
if "金色印象" in cur_unit:
cross_shop = 0 if path(("原单位", "原一级部门", "原二级部门", "原三级部门", "原四级部门")) \
== path(("现单位", "现一级部门", "现二级部门", "现三级部门", "现四级部门")) else 1
elif "金色湖畔" in cur_unit:
cross_shop = 0 if path(("原单位", "原一级部门", "原二级部门")) \
== path(("现单位", "现一级部门", "现二级部门")) else 1
else:
cross_shop = None # IFS 无默认分支 -> #N/A
if cross_shop == 1 and menu.get(s(row.get("调动类型"))) == TYPE_PENDING:
return "需要"
return "-"
def read_needed_rows(target_path: str) -> pd.DataFrame:
"""从「调动导出」读数据行,按 _judge_need 复算筛选,返回 B~AF 列数据 + _verdict 辅助列。
「调动导出」表头在第2行;判断规则在 Python 侧复算(不读第39列公式缓存,
缓存随 openpyxl 保存已清空)。
Returns:
DataFrame(列为 B~AF 共 31 列,列名与表头一致),可能为空表
DataFrame(列为 B~AF 共 31 列 + `_verdict` 复算结果列,取值 需要/会馆),
可能为空表;调用方按 `_verdict` 分流后写名单前需 drop 该列
Raises:
RuntimeError: sheet/表头缺失或无公式缓存值
RuntimeError: sheet/表头缺失或文件被占用
"""
wb = load_workbook(target_path, data_only=True)
try:
wb = load_workbook(target_path, data_only=True)
except PermissionError as exc:
raise RuntimeError(
f"文件被占用,无法读取:{target_path}\n"
"请先在 WPS/Excel 中关闭该文件后重试。") from exc
if SOURCE_SHEET not in wb.sheetnames:
raise RuntimeError(f"推送文件缺少「{SOURCE_SHEET}」sheet:{wb.sheetnames}")
ws = wb[SOURCE_SHEET]
# 表头(B~AF)与判断列、键列名
# 表头(B~AF)映射
header = {}
for c in range(COPY_COL_START, COPY_COL_END + 1):
v = ws.cell(row=SOURCE_HEADER_ROW, column=c).value
header[c] = str(v).replace("\n", "").strip() if v is not None else f"col{c}"
# 判断列缓存保护:数据区存在但第39列全为空 = 公式缓存丢失(openpyxl 保存过全簿,
# step1 未再跑),openpyxl 无法重算,必须先跑 step1(WPS COM 重算)恢复缓存
has_data = any(ws.cell(row=r, column=3).value not in (None, "")
for r in range(SOURCE_HEADER_ROW + 1, ws.max_row + 1))
judge_vals = [ws.cell(row=r, column=JUDGE_COL).value
for r in range(SOURCE_HEADER_ROW + 1, ws.max_row + 1)]
if has_data and all(v in (None, "") for v in judge_vals):
raise RuntimeError(
"「调动导出」公式缓存值缺失(文件曾被 openpyxl 保存,未重新计算)。\n"
"请先执行第一步(XQ0037调动台账导出筛选,WPS COM 重算)再运行本脚本。")
rows = []
menu = _load_menu_types(wb)
rows, manual = [], []
for r in range(SOURCE_HEADER_ROW + 1, ws.max_row + 1):
if ws.cell(row=r, column=JUDGE_COL).value == JUDGE_VALUE:
rows.append({header[c]: ws.cell(row=r, column=c).value
for c in range(COPY_COL_START, COPY_COL_END + 1)})
vals = {c: ws.cell(row=r, column=c).value
for c in range(COPY_COL_START, COPY_COL_END + 1)}
if vals.get(KEY_CODE_COL) in (None, ""): # 工号空 = 非数据行(模板空行)
continue
named = {header[c]: vals[c] for c in vals}
verdict = _judge_need(named, menu)
if verdict in (JUDGE_VALUE, JUDGE_VENUE):
named["_verdict"] = verdict
rows.append(named)
elif verdict == JUDGE_MANUAL:
manual.append(f"{named.get('姓名')}({named.get('工号')})")
df = pd.DataFrame(rows)
logger.info("「%s」筛选 %s=%s:%d 条", SOURCE_SHEET,
ws.cell(row=SOURCE_HEADER_ROW, column=JUDGE_COL).value, JUDGE_VALUE, len(df))
n_need = int((df["_verdict"] == JUDGE_VALUE).sum()) if not df.empty else 0
n_venue = len(df) - n_need
logger.info("「%s」按规则复算筛选:%s %d 条,%s %d 条",
SOURCE_SHEET, JUDGE_VALUE, n_need, JUDGE_VENUE, n_venue)
if manual:
logger.info("职能相关 %s %d 人(不自动发起,需人工跟进):%s",
JUDGE_MANUAL, len(manual), "、".join(manual))
return df
@@ -176,8 +278,9 @@ def _norm_transfer_day(v):
"""调动时间按天归一(yyyy-MM-dd):datetime/Timestamp/字符串/Excel 序列号均可;
失败返回 None(调用方回退「工号+姓名」去重键)。
按天粒度可吸收 COM 写入 ±8h 时区漂移(跨午夜边界除外);同人同日仅可能有一笔
调动,不会误合并不同调动(与 step5 AI表格防重「工号+调动日期」口径一致)。
按天粒度可吸收时间写入/解析的偏差(历史上 COM 写入曾整体 -8h);
同人工号在不同调动日调动多次时各自保留,不会误合并不同调动
(与 step5 AI表格防重「工号+调动日期」口径一致)。
"""
if v is None:
return None
@@ -205,9 +308,9 @@ def append_to_monthly(target_path: str, df: pd.DataFrame) -> int:
- 只写 B~AF 列,序号/公式列/其他列一概不动;
- 新行单元格拷贝上一行同列样式,保证显示格式一致。
注意:openpyxl 保存会清空全簿公式缓存值(公式保留、显示不受影响,WPS 打开自动
重算),「调动导出」判断列缓存由下一次 step1 的 WPS 重算恢复;当天单独重跑本脚本
若遇缓存缺失会在 read_needed_rows 处明确报错提示先跑 step1。
注意:openpyxl 保存会清空全簿公式缓存值(公式保留、显示不受影响,WPS/Excel 打开
自动重算);「是否需要发起改签」由本模块 Python 复算,与公式缓存无关,当天单独
重跑本脚本无需先跑 step1。
Returns:
实际追加行数
@@ -216,7 +319,7 @@ def append_to_monthly(target_path: str, df: pd.DataFrame) -> int:
RuntimeError: 表头不匹配 / 文件被占用(WPS/Excel 打开)等
"""
if df.empty:
logger.info("无 %s 记录,跳过写入", JUDGE_VALUE)
logger.info("无 %s/%s 记录,跳过写入", JUDGE_VALUE, JUDGE_VENUE)
return 0
target_path = os.path.abspath(target_path)
@@ -242,7 +345,7 @@ def append_to_monthly(target_path: str, df: pd.DataFrame) -> int:
# 2. 数据末行(按工号列向上)与去重(工号+调动时间按天;缺调动时间回退工号+姓名,类型归一)
# 同人工号在不同调动日调动多次时各自保留(去重键含调动时间,不再漏掉第二笔调动);
# 调动时间按天归一可吸收 COM 写入 ±8h 时区漂移(与 step5「工号+调动日期」防重口径一致)。
# 调动时间按天归一可吸收时间写入/解析的偏差(与 step5「工号+调动日期」防重口径一致)。
last = MONTHLY_HEADER_ROW
for r in range(MONTHLY_HEADER_ROW + 1, ws.max_row + 1):
if ws.cell(row=r, column=KEY_CODE_COL).value not in (None, ""):
@@ -546,9 +649,45 @@ def process_needed(df: pd.DataFrame) -> list:
return results
def process_venue(df: pd.DataFrame) -> list:
"""培训会馆分支:流程由 HR 批量发起,跳过 HR 置位,直接登记待办进后续管道。
- 「是否已发起流程」=是(批量流程已发起)→ 登记待办工号列表,
由 step3 完善信息(是否新签合同=否)+ step4 发起离职电子签接力;
- ≠是 → 跳过(HR 批量流程尚未发起),等下次导出刷新后再进。
Returns:
[{"工号", "姓名", "result", "message"}, ...]
"""
if df.empty:
return []
code_col = "工号" if "工号" in df.columns else df.columns[1]
name_col = "姓名" if "姓名" in df.columns else df.columns[0]
results, added = [], []
for _, r in df.iterrows():
base_code = str(r[code_col]).strip()
staff_name = str(r[name_col]).strip()
item = {"工号": base_code, "姓名": staff_name, "result": "跳过", "message": ""}
if str(r.get("是否已发起流程") or "").strip() != "是":
item["message"] = "是否已发起流程≠是,跳过"
results.append(item)
logger.info("【%s %s】会馆:%s", base_code, staff_name, item["message"])
continue
item["result"] = "已登记"
item["message"] = "会馆流程已发起,直接进完善信息管道(不置 HR 标志)"
results.append(item)
added.append((base_code, staff_name))
logger.info("【%s %s】会馆:%s", base_code, staff_name, item["message"])
if added:
cur = add_pending(added)
logger.info("会馆分支登记待办 %d 人(累计 %d):%s",
len(added), len(cur), "、".join(c for c, _ in added))
return results
# ==================== 第二步主流程 ====================
def run_step2(output_dir: str = None, do_hr_change: bool = True) -> dict:
"""XQ0037 第二步:筛"需要"记录 → B~AF 追加「本月发起名单」→ HR 变更电子签状态。
"""XQ0037 第二步:筛"需要/会馆"记录 → B~AF 追加「本月发起名单」→ HR 变更电子签状态。
Args:
output_dir: 推送文件目录(默认 D:\\资料\\人资\\调动改签离职电子签)
@@ -556,21 +695,34 @@ def run_step2(output_dir: str = None, do_hr_change: bool = True) -> dict:
Returns:
{"success": bool, "target_path": str, "needed": int, "appended": int,
"hr_results": [...]}(do_hr_change=False 时无 hr_results)
"hr_results": [...], "venue_results": [...]}
(do_hr_change=False 时无 hr_results)
"""
output_dir = output_dir or DEFAULT_OUTPUT_DIR
logger.info("===== XQ0037 第二步开始 =====")
target_path = find_today_target(output_dir)
df = read_needed_rows(target_path)
appended = append_to_monthly(target_path, df)
if "_verdict" in df.columns:
need_df = df[df["_verdict"] == JUDGE_VALUE].drop(columns=["_verdict"])
venue_df = df[df["_verdict"] == JUDGE_VENUE].drop(columns=["_verdict"])
else: # 空表(无列)
need_df = venue_df = df
# 会馆的人也追加进「本月发起名单」(step3 完善信息/step5 回填按名单取行)
appended = append_to_monthly(target_path, df.drop(columns=["_verdict"])
if "_verdict" in df.columns else df)
hr_results = process_needed(df) if (do_hr_change and not df.empty) else []
hr_results = (process_needed(need_df)
if (do_hr_change and not need_df.empty) else [])
venue_results = process_venue(venue_df)
logger.info("===== XQ0037 第二步完成:命中 %d,追加 %d,HR 处理 %d 条 =====",
len(df), appended, len(hr_results))
logger.info("===== XQ0037 第二步完成:命中 %d(%s %d / %s %d),追加 %d,"
"HR 处理 %d 条,会馆处理 %d 条 =====",
len(df), JUDGE_VALUE, len(need_df), JUDGE_VENUE, len(venue_df),
appended, len(hr_results), len(venue_results))
return {"success": True, "target_path": target_path,
"needed": len(df), "appended": appended, "hr_results": hr_results}
"needed": len(need_df), "appended": appended,
"hr_results": hr_results, "venue_results": venue_results}
def main(output_dir=None, do_hr_change=True):
@@ -582,7 +734,7 @@ def main(output_dir=None, do_hr_change=True):
Returns:
{"success": bool, "target_path": str, "needed": int, "appended": int,
"hr_results": [...]}
"hr_results": [...], "venue_results": [...]}
失败时 {"success": False, "error": str}
"""
try:
@@ -58,6 +58,8 @@ TPL_SOCIAL = "3cd64878-0261-4ebc-ae03-e2d68bfca8cc" # 6.0 自愿放弃社
UNIT_GOLDEN_LAKESIDE = "金色湖畔事业部" # 特殊签署单位判断的现单位
UNIT_SHIQIAOPU = "石桥铺会馆"
UNIT_LAKESIDE_COMPANY = "金色湖畔企业管理公司"
UNIT_TRAINING_VENUE = "职业技术培训会馆" # 培训会馆:流程 HR 批量发起,
# 完善信息时是否新签合同=否(不算合同)
# 发起名单 sheet 列名(B~AF 31 列 + 后续跟踪列),按表头行动态解析
NEEDED_COLS = ("工号", "姓名", "现单位", "现四级部门", "现职位序列")
@@ -321,8 +323,11 @@ def calc_plan(session, biz, roster_row):
def submit_task(session, task, biz, plan):
"""saveWorkform 保存 + sendNextWeTask 送审。
plan=None 为培训会馆模式:不新签合同,仅置 is_new_sign=0(否),
其余业务字段保留流程业务数据/页面默认。
注意:saveWorkform 会作废页面 GET 发的 workflowToken,
送审前必须重新打开页面取新 token,否则报「没有权限审批此流程任务」。
送审前必须重新打开页面取新 token,否则报「没有权限」。
"""
tid = task.get("taskId")
@@ -333,20 +338,23 @@ def submit_task(session, task, biz, plan):
payload = {k: v for k, v in page["fields"].items()}
for k, v in biz.items():
payload[k] = "" if v is None else str(v)
payload.update({
"is_new_sign": biz.get("is_new_sign") or "1",
"trigger_type": biz.get("trigger_type") or "1",
"treaty_type": biz.get("treaty_type") or "1",
"contract_type": biz.get("contract_type") or "0",
"contract_deadline": str(plan["months"]),
"contract_start_date": plan["start"],
"end_time": plan["end_time"],
"contract_end_date": plan["end"],
"si_area": plan["si_area"],
"ext_license_name": plan["license_name"],
"contract_type_template": plan["templates"],
"ext_push_time": plan["push_time"],
})
if plan is None:
payload.update({"is_new_sign": "0"}) # 培训会馆:是否新签合同=否
else:
payload.update({
"is_new_sign": biz.get("is_new_sign") or "1",
"trigger_type": biz.get("trigger_type") or "1",
"treaty_type": biz.get("treaty_type") or "1",
"contract_type": biz.get("contract_type") or "0",
"contract_deadline": str(plan["months"]),
"contract_start_date": plan["start"],
"end_time": plan["end_time"],
"contract_end_date": plan["end"],
"si_area": plan["si_area"],
"ext_license_name": plan["license_name"],
"contract_type_template": plan["templates"],
"ext_push_time": plan["push_time"],
})
url = (f"{HR_BASE_URL}/RedseaPlatform/WorkformEngine.mc?method=saveWorkform"
f"&weStruId={page['weStruId']}&taskId={tid}&formId={WORKFORM_FORM_ID}")
resp = _request_retry("POST", url, session, data=payload)
@@ -459,14 +467,23 @@ def process_one(session, flow, task, launch_rows, dry_run, pending=None):
write_abnormal(code, name, title, "名单缺失", "发起名单中未找到该工号",
dry_run)
return "abnormal", code
plan, abnormal = calc_plan(session, biz, row)
is_venue = UNIT_TRAINING_VENUE in (
str(row.get("现四级部门") or ""), str(row.get("原四级部门") or ""))
if is_venue:
# 培训会馆:流程 HR 批量发起、不新签合同 -> 不算合同,is_new_sign=0 提交
plan, abnormal = None, None
_log(f"[会馆] {code} {name} | {row.get('现四级部门')} | "
f"不新签合同(是否新签合同=否),保留流程业务数据")
else:
plan, abnormal = calc_plan(session, biz, row)
if abnormal:
write_abnormal(code, name, title, "超龄/规则异常", abnormal, dry_run)
return "abnormal", code
_log(f"[计算] {code} {name} | {row.get('现职位序列')} | {plan['months']}月 | "
f"{plan['start']}~{plan['end']} | {plan['unit_name']} | "
f"模板{plan['templates'].count(',') + 1}个")
if not is_venue:
_log(f"[计算] {code} {name} | {row.get('现职位序列')} | {plan['months']}月 | "
f"{plan['start']}~{plan['end']} | {plan['unit_name']} | "
f"模板{plan['templates'].count(',') + 1}个")
if dry_run:
return "dry", code
@@ -221,7 +221,7 @@ def backfill_init_dates(rows, items):
实际更新行数(单元格已是同一天则跳过,跨天重跑幂等)
openpyxl 直写保留公式(同 step2 风格),保存清公式缓存无碍
(step1 下次跑时 WPS 重算恢复)。
(公式保留,打开自动重算显示)。
"""
path, header = _find_push_table()
if FIELD_INIT_DATE not in header: