Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
黄南光
/
auto-restock
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1c9f8a10
authored
Nov 10, 2026
by
黄南光
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
大幅优化整个系统
1 parent
6a88c238
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
8 deletions
server/app/api/wecom.py
server/tests/test_system.py
web/src/pages/restock/Categories.vue
web/src/pages/restock/RunDetail.vue
web/src/pages/system/Wecom.vue
web/src/styles/base.css
server/app/api/wecom.py
View file @
1c9f8a1
...
@@ -25,9 +25,10 @@ class TargetIn(BaseModel):
...
@@ -25,9 +25,10 @@ class TargetIn(BaseModel):
bot_ref
:
int
bot_ref
:
int
kind
:
str
=
"group"
kind
:
str
=
"group"
contact_id
:
str
contact_id
:
str
contact_name
:
str
=
""
# 单人对象库里这几项存的是 NULL,编辑时前端会原样带回来:允许 None,按空串处理(im.save_target 里统一清洗)
at_ids
:
str
=
""
contact_name
:
str
|
None
=
""
bot_names
:
str
=
""
at_ids
:
str
|
None
=
""
bot_names
:
str
|
None
=
""
purposes
:
list
[
str
]
=
[
"chat"
]
purposes
:
list
[
str
]
=
[
"chat"
]
alert_min
:
str
=
"warn"
alert_min
:
str
=
"warn"
enabled
:
bool
=
True
enabled
:
bool
=
True
...
...
server/tests/test_system.py
View file @
1c9f8a1
...
@@ -579,3 +579,17 @@ def test_msg_log_extra_filters(client, admin, kit):
...
@@ -579,3 +579,17 @@ def test_msg_log_extra_filters(client, admin, kit):
assert
{
x
[
"content"
]
for
x
in
get
(
"severity=error,critical"
)}
==
{
"紧急:补货取数失败"
,
"异常告警邮件"
}
assert
{
x
[
"content"
]
for
x
in
get
(
"severity=error,critical"
)}
==
{
"紧急:补货取数失败"
,
"异常告警邮件"
}
assert
get
(
"doc_no=不存在的单号"
)
==
[]
assert
get
(
"doc_no=不存在的单号"
)
==
[]
assert
client
.
get
(
"/api/wecom/logs?channel=xx"
,
headers
=
admin
)
.
status_code
==
400
assert
client
.
get
(
"/api/wecom/logs?channel=xx"
,
headers
=
admin
)
.
status_code
==
400
def
test_edit_single_target_with_null_fields
(
client
,
admin
,
kit
):
"""单人对象库里 at_ids / bot_names 是 NULL,编辑时原样提交回来也要能保存(以前报 Input should be a valid string)。"""
bot_ref
=
client
.
get
(
"/api/wecom/overview"
,
headers
=
admin
)
.
json
()[
"targets"
][
0
][
"bot_ref"
]
r
=
client
.
post
(
"/api/wecom/targets"
,
json
=
{
"name"
:
"张工"
,
"bot_ref"
:
bot_ref
,
"kind"
:
"single"
,
"contact_id"
:
"u-zg"
,
"purposes"
:
[
"chat"
]},
headers
=
admin
)
tid
=
r
.
json
()[
"id"
]
t
=
next
(
x
for
x
in
client
.
get
(
"/api/wecom/overview"
,
headers
=
admin
)
.
json
()[
"targets"
]
if
x
[
"id"
]
==
tid
)
assert
t
[
"at_ids"
]
is
None
and
t
[
"bot_names"
]
is
None
body
=
{
k
:
t
[
k
]
for
k
in
(
"name"
,
"bot_ref"
,
"kind"
,
"contact_id"
,
"contact_name"
,
"at_ids"
,
"bot_names"
,
"purposes"
,
"alert_min"
,
"enabled"
)}
|
{
"name"
:
"张工2"
}
r
=
client
.
put
(
f
"/api/wecom/targets/{tid}"
,
json
=
body
,
headers
=
admin
)
assert
r
.
status_code
==
200
,
r
.
text
web/src/pages/restock/Categories.vue
View file @
1c9f8a1
...
@@ -85,7 +85,7 @@ async function exportCsv() {
...
@@ -85,7 +85,7 @@ async function exportCsv() {
</el-table-column>
</el-table-column>
<el-table-column
prop=
"note"
label=
"备注"
min-width=
"140"
show-overflow-tooltip
/>
<el-table-column
prop=
"note"
label=
"备注"
min-width=
"140"
show-overflow-tooltip
/>
<el-table-column
label=
"最后修改"
min-width=
"190"
><
template
#
default=
"{ row }"
><span
class=
"small"
>
{{
row
.
updated_by
||
'—'
}}
·
{{
SOURCE
[
row
.
source
]
||
row
.
source
||
''
}}
·
{{
fmtShort
(
row
.
updated_at
)
}}
</span></
template
></el-table-column>
<el-table-column
label=
"最后修改"
min-width=
"190"
><
template
#
default=
"{ row }"
><span
class=
"small"
>
{{
row
.
updated_by
||
'—'
}}
·
{{
SOURCE
[
row
.
source
]
||
row
.
source
||
''
}}
·
{{
fmtShort
(
row
.
updated_at
)
}}
</span></
template
></el-table-column>
<el-table-column
label=
""
width=
"1
2
0"
align=
"right"
>
<el-table-column
label=
""
width=
"1
3
0"
align=
"right"
>
<
template
#
default=
"{ row }"
>
<
template
#
default=
"{ row }"
>
<el-button
link
type=
"primary"
@
click=
"openEdit(row)"
>
编辑
</el-button>
<el-button
link
type=
"primary"
@
click=
"openEdit(row)"
>
编辑
</el-button>
<el-button
link
type=
"danger"
@
click=
"remove(row)"
>
删除
</el-button>
<el-button
link
type=
"danger"
@
click=
"remove(row)"
>
删除
</el-button>
...
...
web/src/pages/restock/RunDetail.vue
View file @
1c9f8a1
...
@@ -25,7 +25,7 @@ const route = useRoute()
...
@@ -25,7 +25,7 @@ const route = useRoute()
const
router
=
useRouter
()
const
router
=
useRouter
()
const
id
=
computed
(()
=>
Number
(
route
.
params
.
id
))
const
id
=
computed
(()
=>
Number
(
route
.
params
.
id
))
const
st
=
ref
<
any
>
(
null
)
const
st
=
ref
<
any
>
(
null
)
const
kinds
=
ref
<
string
[]
>
([
'chat'
,
'audit'
,
'event'
,
'task'
,
'api'
,
'snapshot'
])
const
kinds
=
ref
<
string
[]
>
([
'chat'
])
// 默认只看聊天,其余类型按需勾选
const
snap
=
ref
<
any
>
(
null
)
const
snap
=
ref
<
any
>
(
null
)
const
outboundOpen
=
ref
(
false
)
const
outboundOpen
=
ref
(
false
)
const
traceOf
=
ref
<
number
|
null
>
(
null
)
const
traceOf
=
ref
<
number
|
null
>
(
null
)
...
...
web/src/pages/system/Wecom.vue
View file @
1c9f8a1
...
@@ -53,7 +53,8 @@ const targetOrig = ref('') // 打开弹窗时的表单快
...
@@ -53,7 +53,8 @@ const targetOrig = ref('') // 打开弹窗时的表单快
const
targetDirty
=
computed
(()
=>
!!
target
.
value
&&
JSON
.
stringify
(
target
.
value
)
!==
targetOrig
.
value
)
const
targetDirty
=
computed
(()
=>
!!
target
.
value
&&
JSON
.
stringify
(
target
.
value
)
!==
targetOrig
.
value
)
function
editTarget
(
t
?:
any
)
{
function
editTarget
(
t
?:
any
)
{
if
(
!
bots
.
value
.
length
)
return
ElMessage
.
warning
(
'请先在「机器人」里登记一个机器人'
)
if
(
!
bots
.
value
.
length
)
return
ElMessage
.
warning
(
'请先在「机器人」里登记一个机器人'
)
target
.
value
=
t
?
{
...
t
,
contact_name
:
t
.
contact_name
||
''
,
purposes
:
[...
t
.
purposes
]
}
// 单人对象的 at_ids / bot_names 在库里是 NULL,表单里统一成空串(否则输入框绑定 null,保存时接口校验不过)
target
.
value
=
t
?
{
...
t
,
contact_name
:
t
.
contact_name
||
''
,
at_ids
:
t
.
at_ids
||
''
,
bot_names
:
t
.
bot_names
||
''
,
purposes
:
[...
t
.
purposes
]
}
:
{
name
:
''
,
bot_ref
:
bots
.
value
[
0
].
id
,
kind
:
'group'
,
contact_id
:
''
,
contact_name
:
''
,
at_ids
:
''
,
bot_names
:
''
,
purposes
:
[
'chat'
,
'alert'
],
alert_min
:
'warn'
,
enabled
:
true
}
:
{
name
:
''
,
bot_ref
:
bots
.
value
[
0
].
id
,
kind
:
'group'
,
contact_id
:
''
,
contact_name
:
''
,
at_ids
:
''
,
bot_names
:
''
,
purposes
:
[
'chat'
,
'alert'
],
alert_min
:
'warn'
,
enabled
:
true
}
targetOrig
.
value
=
JSON
.
stringify
(
target
.
value
)
targetOrig
.
value
=
JSON
.
stringify
(
target
.
value
)
}
}
...
@@ -159,7 +160,7 @@ function pick(c: any) {
...
@@ -159,7 +160,7 @@ function pick(c: any) {
<
/el-table-column
>
<
/el-table-column
>
<
el
-
table
-
column
label
=
"机器人"
min
-
width
=
"120"
><
template
#
default
=
"
{
row
}"
>
{{
row
.
bot_name
}}
<
span
v
-
if
=
"!row.bot_enabled"
class
=
"err small"
>
(已停用)
<
/span></
template
><
/el-table-column
>
<
el
-
table
-
column
label
=
"机器人"
min
-
width
=
"120"
><
template
#
default
=
"
{
row
}"
>
{{
row
.
bot_name
}}
<
span
v
-
if
=
"!row.bot_enabled"
class
=
"err small"
>
(已停用)
<
/span></
template
><
/el-table-column
>
<
el
-
table
-
column
label
=
"状态"
width
=
"90"
><
template
#
default
=
"
{
row
}
"><StatusPill :tone="
row
.
enabled
?
'ok'
:
'info'
"
>
{{
row
.
enabled
?
'启用'
:
'停用'
}}
<
/StatusPill></
template
><
/el-table-column
>
<
el
-
table
-
column
label
=
"状态"
width
=
"90"
><
template
#
default
=
"
{
row
}
"><StatusPill :tone="
row
.
enabled
?
'ok'
:
'info'
"
>
{{
row
.
enabled
?
'启用'
:
'停用'
}}
<
/StatusPill></
template
><
/el-table-column
>
<
el
-
table
-
column
label
=
""
width
=
"1
1
0"
align
=
"right"
>
<
el
-
table
-
column
label
=
""
width
=
"1
3
0"
align
=
"right"
>
<
template
#
default
=
"
{
row
}
">
<
template
#
default
=
"
{
row
}
">
<el-button link type="
primary
" @click="
editTarget
(
row
)
">编辑</el-button>
<el-button link type="
primary
" @click="
editTarget
(
row
)
">编辑</el-button>
<el-button link type="
danger
" @click="
delTarget
(
row
)
">删除</el-button>
<el-button link type="
danger
" @click="
delTarget
(
row
)
">删除</el-button>
...
@@ -179,7 +180,7 @@ function pick(c: any) {
...
@@ -179,7 +180,7 @@ function pick(c: any) {
<
el
-
table
-
column
label
=
"被使用"
width
=
"100"
><
template
#
default
=
"
{
row
}"
>
{{
row
.
targets
}}
个对象
<
/template></
el
-
table
-
column
>
<
el
-
table
-
column
label
=
"被使用"
width
=
"100"
><
template
#
default
=
"
{
row
}"
>
{{
row
.
targets
}}
个对象
<
/template></
el
-
table
-
column
>
<
el
-
table
-
column
label
=
"状态"
width
=
"90"
><
template
#
default
=
"
{
row
}
"><StatusPill :tone="
row
.
enabled
?
'ok'
:
'info'
"
>
{{
row
.
enabled
?
'启用'
:
'停用'
}}
<
/StatusPill></
template
><
/el-table-column
>
<
el
-
table
-
column
label
=
"状态"
width
=
"90"
><
template
#
default
=
"
{
row
}
"><StatusPill :tone="
row
.
enabled
?
'ok'
:
'info'
"
>
{{
row
.
enabled
?
'启用'
:
'停用'
}}
<
/StatusPill></
template
><
/el-table-column
>
<
el
-
table
-
column
prop
=
"note"
label
=
"备注"
min
-
width
=
"120"
/>
<
el
-
table
-
column
prop
=
"note"
label
=
"备注"
min
-
width
=
"120"
/>
<
el
-
table
-
column
label
=
""
width
=
"1
2
0"
align
=
"right"
>
<
el
-
table
-
column
label
=
""
width
=
"1
3
0"
align
=
"right"
>
<
template
#
default
=
"
{
row
}
">
<
template
#
default
=
"
{
row
}
">
<el-button link type="
primary
" @click="
editBot
(
row
)
">编辑</el-button>
<el-button link type="
primary
" @click="
editBot
(
row
)
">编辑</el-button>
<el-button link type="
danger
" :disabled="
row
.
targets
>
0
" @click="
delBot
(
row
)
">删除</el-button>
<el-button link type="
danger
" :disabled="
row
.
targets
>
0
" @click="
delBot
(
row
)
">删除</el-button>
...
...
web/src/styles/base.css
View file @
1c9f8a1
...
@@ -109,6 +109,8 @@ code, .mono { font-family: var(--font-mono); font-size: 12.5px; }
...
@@ -109,6 +109,8 @@ code, .mono { font-family: var(--font-mono); font-size: 12.5px; }
.el-table
th
.el-table__cell
{
color
:
var
(
--c-text-2
);
font-weight
:
600
;
font-size
:
12.5px
;
}
.el-table
th
.el-table__cell
{
color
:
var
(
--c-text-2
);
font-weight
:
600
;
font-size
:
12.5px
;
}
.el-table
td
.el-table__cell
{
font-variant-numeric
:
tabular-nums
;
}
.el-table
td
.el-table__cell
{
font-variant-numeric
:
tabular-nums
;
}
.el-table
.cell
{
line-height
:
1.5
;
}
.el-table
.cell
{
line-height
:
1.5
;
}
/* 操作列(编辑 / 删除这类链接按钮)一行排开,列宽不够也不换行 */
.el-table
.cell
:has
(>
.el-button.is-link
)
{
white-space
:
nowrap
;
text-overflow
:
clip
;
}
.el-table--border
.el-table__inner-wrapper
::after
,
.el-table__border-left-patch
{
display
:
none
;
}
.el-table--border
.el-table__inner-wrapper
::after
,
.el-table__border-left-patch
{
display
:
none
;
}
.el-tabs__item
{
font-weight
:
500
;
font-size
:
14px
;
}
.el-tabs__item
{
font-weight
:
500
;
font-size
:
14px
;
}
.el-tabs__item.is-active
{
font-weight
:
600
;
}
.el-tabs__item.is-active
{
font-weight
:
600
;
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment