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 dd0aa330
authored
Nov 16, 2026
by
黄南光
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化前端
1 parent
00aa1d64
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
131 additions
and
15 deletions
server/app/features/restock/planner.py
server/app/features/restock/service.py
server/app/features/restock/texts.py
server/tests/test_planner.py
server/tests/test_restock_flow.py
web/src/pages/restock/RunDetail.vue
web/src/pages/restock/Runs.vue
server/app/features/restock/planner.py
View file @
dd0aa33
...
@@ -106,6 +106,31 @@ class Line:
...
@@ -106,6 +106,31 @@ class Line:
def
source_label
(
self
)
->
str
:
def
source_label
(
self
)
->
str
:
return
SOURCE_LABEL
[
"manual"
]
if
self
.
modified
else
SOURCE_LABEL
.
get
(
self
.
default_source
,
""
)
return
SOURCE_LABEL
[
"manual"
]
if
self
.
modified
else
SOURCE_LABEL
.
get
(
self
.
default_source
,
""
)
@property
def
default_checked
(
self
)
->
bool
:
"""系统默认勾选:历史常备件 / 单次补货勾,其他出库件不勾。"""
return
self
.
grp
!=
"other"
@property
def
check_changed
(
self
)
->
bool
:
"""勾选状态和系统默认不一样(常备件被取消、其他出库件被手动勾上)。"""
return
self
.
checked
!=
self
.
default_checked
@property
def
changed
(
self
)
->
bool
:
"""用户改过:改了期望,或勾选和默认不一样。后台「改过」统计 / 筛选、确认消息都按这个口径。"""
return
self
.
modified
or
self
.
check_changed
@property
def
change_text
(
self
)
->
str
:
"""改了什么(一句话):「取消勾选(默认勾);期望 92→100」。"""
parts
=
[]
if
self
.
check_changed
:
parts
.
append
(
"取消勾选(默认勾)"
if
not
self
.
checked
else
"手动勾选(默认不勾)"
)
if
self
.
modified
:
parts
.
append
(
f
"期望 {self.default_expected}→{self.expected}"
)
return
";"
.
join
(
parts
)
def
preview
(
self
)
->
tuple
[
int
,
str
]:
def
preview
(
self
)
->
tuple
[
int
,
str
]:
"""勾选后会补多少(只给页面显示用):已勾选 = final_qty / note;未勾选 = 假设勾选重算一遍,本行不变、不会下单。"""
"""勾选后会补多少(只给页面显示用):已勾选 = final_qty / note;未勾选 = 假设勾选重算一遍,本行不变、不会下单。"""
if
self
.
checked
:
if
self
.
checked
:
...
@@ -119,7 +144,8 @@ class Line:
...
@@ -119,7 +144,8 @@ class Line:
d
.
update
(
label
=
TAG_LABEL
.
get
(
self
.
tag
,
""
),
orderable
=
self
.
orderable
,
recommend
=
self
.
recommend
,
d
.
update
(
label
=
TAG_LABEL
.
get
(
self
.
tag
,
""
),
orderable
=
self
.
orderable
,
recommend
=
self
.
recommend
,
amount
=
round
(
self
.
final_qty
*
(
self
.
unit_price
or
0
),
2
),
wh_total
=
self
.
wh_total
,
amount
=
round
(
self
.
final_qty
*
(
self
.
unit_price
or
0
),
2
),
wh_total
=
self
.
wh_total
,
wh_short
=
self
.
wh_short
,
group_label
=
GROUP_LABEL
.
get
(
self
.
grp
,
self
.
grp
),
wh_short
=
self
.
wh_short
,
group_label
=
GROUP_LABEL
.
get
(
self
.
grp
,
self
.
grp
),
source_label
=
self
.
source_label
,
wh_cn
=
wh_cn
(
self
.
wh
))
source_label
=
self
.
source_label
,
wh_cn
=
wh_cn
(
self
.
wh
),
default_checked
=
self
.
default_checked
,
check_changed
=
self
.
check_changed
,
changed
=
self
.
changed
,
change_text
=
self
.
change_text
)
return
d
return
d
...
@@ -286,6 +312,7 @@ def summary(lines: list[Line]) -> dict:
...
@@ -286,6 +312,7 @@ def summary(lines: list[Line]) -> dict:
"other_count"
:
sum
(
1
for
l
in
lines
if
l
.
grp
==
"other"
),
"other_count"
:
sum
(
1
for
l
in
lines
if
l
.
grp
==
"other"
),
"checked_count"
:
sum
(
1
for
l
in
lines
if
l
.
checked
),
"checked_count"
:
sum
(
1
for
l
in
lines
if
l
.
checked
),
"modified_count"
:
sum
(
1
for
l
in
lines
if
l
.
modified
),
"modified_count"
:
sum
(
1
for
l
in
lines
if
l
.
modified
),
"changed_count"
:
sum
(
1
for
l
in
lines
if
l
.
changed
),
"capped"
:
[
l
.
part_no
for
l
in
lines
if
l
.
tag
==
"capped"
],
"oos"
:
[
l
.
part_no
for
l
in
lines
if
l
.
tag
==
"oos"
],
"capped"
:
[
l
.
part_no
for
l
in
lines
if
l
.
tag
==
"capped"
],
"oos"
:
[
l
.
part_no
for
l
in
lines
if
l
.
tag
==
"oos"
],
"errors"
:
[
l
.
part_no
for
l
in
lines
if
l
.
tag
==
"error"
],
"errors"
:
[
l
.
part_no
for
l
in
lines
if
l
.
tag
==
"error"
],
"wh_short"
:
[
l
.
part_no
for
l
in
lines
if
l
.
wh_short
and
l
.
tag
!=
"oos"
],
"wh_short"
:
[
l
.
part_no
for
l
in
lines
if
l
.
wh_short
and
l
.
tag
!=
"oos"
],
...
...
server/app/features/restock/service.py
View file @
dd0aa33
...
@@ -391,6 +391,17 @@ class RestockService(SingleMixin):
...
@@ -391,6 +391,17 @@ class RestockService(SingleMixin):
return
""
return
""
return
self
.
t
(
run
[
"store_id"
],
"stale_hint"
,
biz_date
=
f
"{run['biz_date']:
%
m月
%
d日}"
,
doc
=
run
[
"doc_no"
])
return
self
.
t
(
run
[
"store_id"
],
"stale_hint"
,
biz_date
=
f
"{run['biz_date']:
%
m月
%
d日}"
,
doc
=
run
[
"doc_no"
])
CHANGES_LISTED
=
5
def
changes_text
(
self
,
sid
:
int
,
lines
:
list
[
planner
.
Line
])
->
str
:
"""确认消息后面的「其中改了 N 处」:改了期望,或勾选和系统默认不一样的零件,最多列 5 条;没改过返回空。"""
changed
=
[
l
for
l
in
lines
if
l
.
changed
]
if
not
changed
:
return
""
return
self
.
t
(
sid
,
"confirm_changes"
,
count
=
len
(
changed
),
more
=
max
(
len
(
changed
)
-
self
.
CHANGES_LISTED
,
0
),
changes
=
[{
"name"
:
l
.
name
,
"part_no"
:
l
.
part_no
,
"text"
:
l
.
change_text
}
for
l
in
changed
[:
self
.
CHANGES_LISTED
]])
@staticmethod
@staticmethod
def
_late_tail
(
text
:
str
)
->
str
:
def
_late_tail
(
text
:
str
)
->
str
:
return
f
"
\n
{text}"
if
text
else
""
return
f
"
\n
{text}"
if
text
else
""
...
@@ -874,7 +885,7 @@ class RestockService(SingleMixin):
...
@@ -874,7 +885,7 @@ class RestockService(SingleMixin):
"source"
:
l
.
source_label
,
"stock"
:
l
.
stock
,
"in_transit"
:
l
.
in_transit
,
"source"
:
l
.
source_label
,
"stock"
:
l
.
stock
,
"in_transit"
:
l
.
in_transit
,
"qty"
:
l
.
final_qty
}
for
l
in
ok
]})
"qty"
:
l
.
final_qty
}
for
l
in
ok
]})
await
self
.
say
(
run
,
self
.
t
(
sid
,
"msg_confirmed"
,
s
=
s
,
by
=
actor
.
name
,
eta
=
eta_text
(
ETA_SECONDS
))
await
self
.
say
(
run
,
self
.
t
(
sid
,
"msg_confirmed"
,
s
=
s
,
by
=
actor
.
name
,
eta
=
eta_text
(
ETA_SECONDS
))
+
self
.
_late_tail
(
self
.
late_hint
(
sid
)))
+
self
.
_late_tail
(
self
.
changes_text
(
sid
,
lines
))
+
self
.
_late_tail
(
self
.
late_hint
(
sid
)))
self
.
spawn
(
self
.
_create_guard
(
run
[
"id"
]),
f
"restock-create-{run['id']}"
)
self
.
spawn
(
self
.
_create_guard
(
run
[
"id"
]),
f
"restock-create-{run['id']}"
)
return
True
,
"已确认,正在 DMS 建单"
return
True
,
"已确认,正在 DMS 建单"
...
...
server/app/features/restock/texts.py
View file @
dd0aa33
...
@@ -132,6 +132,13 @@ TEXTS = [
...
@@ -132,6 +132,13 @@ TEXTS = [
T
(
"restock.msg_confirmed"
,
"message"
,
"建单"
,
"确认后开始建单"
,
T
(
"restock.msg_confirmed"
,
"message"
,
"建单"
,
"确认后开始建单"
,
"✅ {{ by }} 已确认,正在 DMS 建单
\n
{{ s.order_count }} 项 · {{ s.order_qty }} 件,{{ eta }}"
,
(
"s"
,
"by"
,
"eta"
),
"✅ {{ by }} 已确认,正在 DMS 建单
\n
{{ s.order_count }} 项 · {{ s.order_qty }} 件,{{ eta }}"
,
(
"s"
,
"by"
,
"eta"
),
{
"s"
:
_S
,
"by"
:
"邹新"
,
"eta"
:
"大概 3 分钟"
}),
{
"s"
:
_S
,
"by"
:
"邹新"
,
"eta"
:
"大概 3 分钟"
}),
T
(
"restock.confirm_changes"
,
"message"
,
"建单"
,
"确认时用户改过的零件(拼在确认消息后面)"
,
"✏️ 其中改了 {{ count }} 处:{
%
for c in changes
%
}
\n
· {{ c.name }} {{ c.part_no }}:{{ c.text }}{
%
endfor
%
}"
"{
%
if more
%
}
\n
…还有 {{ more }} 处,详见后台补货单{
%
endif
%
}"
,
(
"count"
,
"changes"
,
"more"
),
{
"count"
:
2
,
"more"
:
0
,
"changes"
:
[{
"name"
:
"机油滤清器滤芯"
,
"part_no"
:
"90915YZZM3"
,
"text"
:
"期望 92→100"
},
{
"name"
:
"衬垫(用于油底壳排放"
,
"part_no"
:
"90430C0005"
,
"text"
:
"取消勾选(默认勾)"
}]},
"只有用户改过(改了期望,或勾选和系统默认不一样)才拼上;最多列 5 条。"
),
T
(
"restock.msg_recover_shot"
,
"message"
,
"建单"
,
"云端重启时正在截图(采购单已建好)"
,
T
(
"restock.msg_recover_shot"
,
"message"
,
"建单"
,
"云端重启时正在截图(采购单已建好)"
,
"⚠️ 系统重启时采购单 {{ order_no }} 正在截图,截图没发出来,但单已经在 DMS 建好(待提交)。
\n
"
"⚠️ 系统重启时采购单 {{ order_no }} 正在截图,截图没发出来,但单已经在 DMS 建好(待提交)。
\n
"
"请点开链接核对明细(或到 DMS「采购订单管理」看这张单),没问题点「确认提交」 👉
\n
{{ link }}"
,
"请点开链接核对明细(或到 DMS「采购订单管理」看这张单),没问题点「确认提交」 👉
\n
{{ link }}"
,
...
@@ -449,6 +456,7 @@ WHEN = {
...
@@ -449,6 +456,7 @@ WHEN = {
"restock.msg_scheduled_no_chat"
:
"回复计划员:在群里说「帮我查库存补货」想发起定时补货时"
,
"restock.msg_scheduled_no_chat"
:
"回复计划员:在群里说「帮我查库存补货」想发起定时补货时"
,
"restock.msg_cancelled"
:
"发到补货对话群:页面上点「今天不订」之后"
,
"restock.msg_cancelled"
:
"发到补货对话群:页面上点「今天不订」之后"
,
"restock.msg_confirmed"
:
"发到补货对话群:页面上确认清单,开始在 DMS 建单"
,
"restock.msg_confirmed"
:
"发到补货对话群:页面上确认清单,开始在 DMS 建单"
,
"restock.confirm_changes"
:
"拼在「确认后开始建单」后面:用户在单据页改了期望或勾选(和系统默认不一样)时,列出改了哪些"
,
"restock.msg_po_done"
:
"发到补货对话群:采购单建好、截图发出后的回执,等确认提交(定时 / 单次共用)"
,
"restock.msg_po_done"
:
"发到补货对话群:采购单建好、截图发出后的回执,等确认提交(定时 / 单次共用)"
,
"restock.msg_shot_fallback"
:
"发到补货对话群:DMS 页面截图失败,发兜底截图(或文字明细)之前的说明"
,
"restock.msg_shot_fallback"
:
"发到补货对话群:DMS 页面截图失败,发兜底截图(或文字明细)之前的说明"
,
"restock.msg_po_failed"
:
"发到补货对话群:建单失败或结果未知时"
,
"restock.msg_po_failed"
:
"发到补货对话群:建单失败或结果未知时"
,
...
...
server/tests/test_planner.py
View file @
dd0aa33
...
@@ -163,3 +163,20 @@ def test_single_restock():
...
@@ -163,3 +163,20 @@ def test_single_restock():
assert
planner
.
plan_single
(
dict
(
it
,
daily_surplus
=
1
),
2
)
.
final_qty
==
1
assert
planner
.
plan_single
(
dict
(
it
,
daily_surplus
=
1
),
2
)
.
final_qty
==
1
assert
planner
.
plan_single
(
dict
(
it
,
warehouses
=
{
"GTMC广州"
:
0
,
"华南GTMC"
:
0
}),
2
)
.
tag
==
"oos"
assert
planner
.
plan_single
(
dict
(
it
,
warehouses
=
{
"GTMC广州"
:
0
,
"华南GTMC"
:
0
}),
2
)
.
tag
==
"oos"
assert
planner
.
plan_single
(
dict
(
it
,
error
=
"查不到"
),
2
)
.
tag
==
"error"
assert
planner
.
plan_single
(
dict
(
it
,
error
=
"查不到"
),
2
)
.
tag
==
"error"
def
test_changed_counts_expected_and_check_state
():
"""「改过」= 改了期望,或勾选和系统默认不一样(常备件默认勾、其他出库件默认不勾)。"""
l
=
line
(
outbound
=
5
,
stock
=
10
)
assert
(
l
.
changed
,
l
.
change_text
)
==
(
False
,
""
)
l
=
line
(
outbound
=
5
,
stock
=
10
,
modified_to
=
20
)
assert
(
l
.
changed
,
l
.
change_text
)
==
(
True
,
"期望 15→20"
)
l
=
line
(
outbound
=
5
,
stock
=
10
,
checked
=
False
)
assert
(
l
.
check_changed
,
l
.
change_text
)
==
(
True
,
"取消勾选(默认勾)"
)
l
=
line
(
outbound
=
5
,
stock
=
10
,
grp
=
"other"
,
checked
=
True
)
assert
(
l
.
check_changed
,
l
.
change_text
)
==
(
True
,
"手动勾选(默认不勾)"
)
assert
line
(
outbound
=
5
,
grp
=
"other"
,
checked
=
False
)
.
changed
is
False
s
=
planner
.
summary
([
line
(
modified_to
=
20
),
line
(
checked
=
False
),
line
()])
assert
(
s
[
"modified_count"
],
s
[
"changed_count"
])
==
(
1
,
2
)
d
=
line
(
checked
=
False
)
.
to_dict
()
assert
d
[
"changed"
]
and
d
[
"check_changed"
]
and
d
[
"default_checked"
]
server/tests/test_restock_flow.py
View file @
dd0aa33
...
@@ -361,6 +361,12 @@ def test_confirm_expires_and_refresh_reruns_chain(client, admin, outbox, fake_ed
...
@@ -361,6 +361,12 @@ def test_confirm_expires_and_refresh_reruns_chain(client, admin, outbox, fake_ed
settle
(
k
)
settle
(
k
)
acts
=
[
r
[
"action"
]
for
r
in
audit
.
query
(
store_ids
=
[
k
.
store_id
],
actor_type
=
"public"
,
limit
=
50
)[
1
]]
acts
=
[
r
[
"action"
]
for
r
in
audit
.
query
(
store_ids
=
[
k
.
store_id
],
actor_type
=
"public"
,
limit
=
50
)[
1
]]
assert
{
"restock.run.confirm_rejected"
,
"restock.run.refresh"
,
"restock.run.confirm"
}
<=
set
(
acts
)
assert
{
"restock.run.confirm_rejected"
,
"restock.run.refresh"
,
"restock.run.confirm"
}
<=
set
(
acts
)
# 确认消息列出用户改过的零件;后台详情 / 列表的「改过」按同一口径
done
=
next
(
m
for
m
in
group_msgs
(
k
,
outbox
)
if
"已确认,正在 DMS 建单"
in
m
)
assert
"其中改了 1 处"
in
done
and
"0888080463"
in
done
and
f
"期望 {oil['default_expected']}→20"
in
done
detail
=
client
.
get
(
f
"/api/restock/runs/{run['id']}"
,
headers
=
k
.
h
)
.
json
()
assert
detail
[
"summary"
][
"changed_count"
]
==
1
assert
[
l
[
"part_no"
]
for
l
in
detail
[
"lines"
]
if
l
[
"changed"
]]
==
[
"0888080463"
]
def
test_chat_cannot_start_scheduled
(
client
,
admin
,
outbox
,
fake_edge
):
def
test_chat_cannot_start_scheduled
(
client
,
admin
,
outbox
,
fake_edge
):
...
...
web/src/pages/restock/RunDetail.vue
View file @
dd0aa33
...
@@ -120,9 +120,8 @@ const lineKw = ref('')
...
@@ -120,9 +120,8 @@ const lineKw = ref('')
const
lineView
=
ref
(
'all'
)
const
lineView
=
ref
(
'all'
)
const
VIEWS
=
[{
v
:
'all'
,
t
:
'全部'
},
{
v
:
'stock'
,
t
:
'历史常备件'
},
{
v
:
'other'
,
t
:
'其他出库件'
},
const
VIEWS
=
[{
v
:
'all'
,
t
:
'全部'
},
{
v
:
'stock'
,
t
:
'历史常备件'
},
{
v
:
'other'
,
t
:
'其他出库件'
},
{
v
:
'order'
,
t
:
'要订'
},
{
v
:
'skip'
,
t
:
'不订'
},
{
v
:
'modified'
,
t
:
'用户改过'
}]
{
v
:
'order'
,
t
:
'要订'
},
{
v
:
'skip'
,
t
:
'不订'
},
{
v
:
'modified'
,
t
:
'用户改过'
}]
// 分组配色:历史常备件 蓝、其他出库件 灰、单次补货 橙(只给标签上色)
// 行着色:用户改过(期望或勾选和默认不一样)浅橙底;没勾选的灰字
const
GROUP_TAG
:
Record
<
string
,
string
>
=
{
stock
:
'primary'
,
other
:
'info'
,
single
:
'warning'
}
const
rowClass
=
({
row
}:
any
)
=>
[
row
.
changed
?
'row-orange'
:
''
,
row
.
checked
?
''
:
'row-grey'
].
join
(
' '
)
const
rowClass
=
({
row
}:
any
)
=>
(
row
.
checked
?
''
:
'row-grey'
)
const
shownLines
=
computed
(()
=>
{
const
shownLines
=
computed
(()
=>
{
const
k
=
lineKw
.
value
.
trim
().
toUpperCase
()
const
k
=
lineKw
.
value
.
trim
().
toUpperCase
()
return
(
st
.
value
?.
lines
||
[]).
filter
((
l
:
any
)
=>
{
return
(
st
.
value
?.
lines
||
[]).
filter
((
l
:
any
)
=>
{
...
@@ -130,11 +129,32 @@ const shownLines = computed(() => {
...
@@ -130,11 +129,32 @@ const shownLines = computed(() => {
if
(
lineView
.
value
===
'stock'
||
lineView
.
value
===
'other'
)
return
l
.
grp
===
lineView
.
value
if
(
lineView
.
value
===
'stock'
||
lineView
.
value
===
'other'
)
return
l
.
grp
===
lineView
.
value
if
(
lineView
.
value
===
'order'
)
return
l
.
final_qty
>
0
if
(
lineView
.
value
===
'order'
)
return
l
.
final_qty
>
0
if
(
lineView
.
value
===
'skip'
)
return
!
(
l
.
final_qty
>
0
)
if
(
lineView
.
value
===
'skip'
)
return
!
(
l
.
final_qty
>
0
)
if
(
lineView
.
value
===
'modified'
)
return
!!
l
.
modifi
ed
if
(
lineView
.
value
===
'modified'
)
return
!!
l
.
chang
ed
return
true
return
true
})
})
})
})
const
filtering
=
computed
(()
=>
!!
lineKw
.
value
.
trim
()
||
lineView
.
value
!==
'all'
)
const
filtering
=
computed
(()
=>
!!
lineKw
.
value
.
trim
()
||
lineView
.
value
!==
'all'
)
// 按分组分段显示(和手机单据页一致):每段一个小标题,不再每行重复「历史常备件」标签
const
GROUP_ORDER
=
[
'stock'
,
'single'
,
'other'
]
const
shownGroups
=
computed
(()
=>
GROUP_ORDER
.
map
((
g
)
=>
{
const
rows
=
shownLines
.
value
.
filter
((
l
:
any
)
=>
l
.
grp
===
g
)
return
{
grp
:
g
,
label
:
GROUP
[
g
]
||
g
,
rows
,
order
:
rows
.
filter
((
l
:
any
)
=>
l
.
final_qty
>
0
).
length
}
}).
filter
((
g
)
=>
g
.
rows
.
length
))
const
multiGroup
=
computed
(()
=>
new
Set
((
st
.
value
?.
lines
||
[]).
map
((
l
:
any
)
=>
l
.
grp
)).
size
>
1
)
// 用户在单据页改过的零件(期望改了 / 勾选和默认不一样):页面顶部提示
const
changedLines
=
computed
(()
=>
(
st
.
value
?.
lines
||
[]).
filter
((
l
:
any
)
=>
l
.
changed
))
const
changeWho
=
computed
(()
=>
{
const
r
=
st
.
value
?.
run
||
{}
return
r
.
confirmed_by
?
`
${
r
.
confirmed_by
}
${
fmtShort
(
r
.
confirmed_at
)}
确认时`
:
'用户在单据页刷新时带上了修改(还没确认),'
})
const
CHANGES_SHOWN
=
3
const
changeBrief
=
computed
(()
=>
changedLines
.
value
.
slice
(
0
,
CHANGES_SHOWN
).
map
((
l
:
any
)
=>
`
${
l
.
name
||
l
.
part_no
}
${
l
.
change_text
}
`
).
join
(
';'
)
+
(
changedLines
.
value
.
length
>
CHANGES_SHOWN
?
` 等
${
changedLines
.
value
.
length
}
处`
:
''
))
function
onlyChanged
()
{
lineKw
.
value
=
''
;
lineView
.
value
=
'modified'
}
// 说明列的短标签:不订的原因(勾选状态已在勾选列,不重复)
const
reasonTag
=
(
r
:
any
)
=>
(
r
.
label
&&
r
.
tag
!==
'unchecked'
?
r
.
label
:
''
)
const
reasonText
=
(
r
:
any
)
=>
{
const
n
=
r
.
note
||
''
;
return
reasonTag
(
r
)
&&
n
.
includes
(
r
.
label
)
?
n
.
replace
(
r
.
label
,
''
).
replace
(
/^
[
::,,
\s]
+/
,
''
)
:
n
}
const
pretty
=
(
v
:
any
)
=>
(
v
===
null
||
v
===
undefined
||
v
===
''
?
''
:
typeof
v
===
'string'
?
v
:
JSON
.
stringify
(
v
,
null
,
2
))
const
pretty
=
(
v
:
any
)
=>
(
v
===
null
||
v
===
undefined
||
v
===
''
?
''
:
typeof
v
===
'string'
?
v
:
JSON
.
stringify
(
v
,
null
,
2
))
</
script
>
</
script
>
...
@@ -174,10 +194,14 @@ const pretty = (v: any) => (v === null || v === undefined || v === '' ? '' : typ
...
@@ -174,10 +194,14 @@ const pretty = (v: any) => (v === null || v === undefined || v === '' ? '' : typ
</div>
</div>
<div
v-if=
"st.run.message && ['error', 'scan_retry', 'expired', 'awaiting_confirm', 'terminated'].includes(st.run.status)"
class=
"notice err"
>
{{ st.run.message }}
</div>
<div
v-if=
"st.run.message && ['error', 'scan_retry', 'expired', 'awaiting_confirm', 'terminated'].includes(st.run.status)"
class=
"notice err"
>
{{ st.run.message }}
</div>
<div
v-if=
"st.run.status === 'awaiting_submit' && st.po?.submit_error"
class=
"notice err"
>
上次提交失败:{{ st.po.submit_error }}
</div>
<div
v-if=
"st.run.status === 'awaiting_submit' && st.po?.submit_error"
class=
"notice err"
>
上次提交失败:{{ st.po.submit_error }}
</div>
<div
v-if=
"isScheduled && changedLines.length"
class=
"notice warn"
>
<span>
✏️ {{ changeWho }}改了
<b>
{{ changedLines.length }}
</b>
处:{{ changeBrief }}
<el-button
link
type=
"primary"
size=
"small"
@
click=
"onlyChanged"
>
只看改过的
</el-button></span>
</div>
<div
class=
"grid grid-4"
>
<div
class=
"grid grid-4"
>
<StatCard
label=
"要订"
:value=
"`${st.summary.order_count} 项 / ${st.summary.order_qty} 件`"
<StatCard
label=
"要订"
:value=
"`${st.summary.order_count} 项 / ${st.summary.order_qty} 件`"
:hint=
"isScheduled ? `常备件 ${st.summary.stock_count} · 其他 ${st.summary.other_count} · 改过 ${st.summary.modified_count}` : ''"
/>
:hint=
"isScheduled ? `常备件 ${st.summary.stock_count} · 其他 ${st.summary.other_count} · 改过 ${st.summary.
changed_count ?? st.summary.
modified_count}` : ''"
/>
<StatCard
label=
"金额"
:value=
"fmtMoney(st.summary.amount)"
/>
<StatCard
label=
"金额"
:value=
"fmtMoney(st.summary.amount)"
/>
<StatCard
label=
"确认人"
:value=
"st.run.confirmed_by || '—'"
<StatCard
label=
"确认人"
:value=
"st.run.confirmed_by || '—'"
:hint=
"(st.run.confirmed_at ? fmtShort(st.run.confirmed_at) : '') + (st.run.submitted_by ? ` · 提交确认 ${st.run.submitted_by}(${st.submitted_via_cn})` : '')"
/>
:hint=
"(st.run.confirmed_at ? fmtShort(st.run.confirmed_at) : '') + (st.run.submitted_by ? ` · 提交确认 ${st.run.submitted_by}(${st.submitted_via_cn})` : '')"
/>
...
@@ -194,11 +218,10 @@ const pretty = (v: any) => (v === null || v === undefined || v === '' ? '' : typ
...
@@ -194,11 +218,10 @@ const pretty = (v: any) => (v === null || v === undefined || v === '' ? '' : typ
<el-button
v-if=
"isScheduled"
size=
"small"
@
click=
"openOutbound"
>
出库明细原样
</el-button>
<el-button
v-if=
"isScheduled"
size=
"small"
@
click=
"openOutbound"
>
出库明细原样
</el-button>
<a
:href=
"st.links.order"
target=
"_blank"
class=
"small"
>
手机单据页
</a>
<a
:href=
"st.links.order"
target=
"_blank"
class=
"small"
>
手机单据页
</a>
</
template
>
</
template
>
<el-table
:data=
"shownLines"
:row-class-name=
"rowClass"
>
<
template
v-for=
"g in (shownGroups.length ? shownGroups : [{ grp: '', label: '', rows: [], order: 0 }])"
:key=
"g.grp"
>
<el-table-column
prop=
"seq"
label=
"序号"
width=
"56"
align=
"center"
/>
<div
v-if=
"multiGroup && g.grp"
class=
"grp-title"
>
{{
g
.
label
}}
<span>
{{
g
.
rows
.
length
}}
项 · 要订
{{
g
.
order
}}
</span></div>
<el-table-column
label=
"分组"
width=
"104"
>
<el-table
:data=
"g.rows"
:row-class-name=
"rowClass"
>
<
template
#
default=
"{ row }"
><el-tag
size=
"small"
:type=
"(GROUP_TAG[row.grp] || 'info') as any"
effect=
"light"
>
{{
GROUP
[
row
.
grp
]
||
row
.
grp
}}
</el-tag></
template
>
<el-table-column
prop=
"seq"
label=
"#"
width=
"48"
align=
"center"
/>
</el-table-column>
<el-table-column
label=
"配件码"
width=
"130"
><template
#
default=
"
{ row }">
<span
class=
"mono"
>
{{
row
.
part_no
}}
</span></
template
></el-table-column>
<el-table-column
label=
"配件码"
width=
"130"
><template
#
default=
"
{ row }">
<span
class=
"mono"
>
{{
row
.
part_no
}}
</span></
template
></el-table-column>
<el-table-column
prop=
"name"
label=
"名称"
min-width=
"130"
/>
<el-table-column
prop=
"name"
label=
"名称"
min-width=
"130"
/>
<el-table-column
label=
"分类 / SO"
width=
"120"
>
<el-table-column
label=
"分类 / SO"
width=
"120"
>
...
@@ -215,14 +238,27 @@ const pretty = (v: any) => (v === null || v === undefined || v === '' ? '' : typ
...
@@ -215,14 +238,27 @@ const pretty = (v: any) => (v === null || v === undefined || v === '' ? '' : typ
<div
v-if=
"row.modified"
class=
"small muted exp-def"
>
默认
{{
row
.
default_expected
}}
</div>
<div
v-if=
"row.modified"
class=
"small muted exp-def"
>
默认
{{
row
.
default_expected
}}
</div>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"勾选"
width=
"56"
align=
"center"
><
template
#
default=
"{ row }"
>
{{
row
.
checked
?
'✓'
:
''
}}
</
template
></el-table-column>
<el-table-column
label=
"勾选"
width=
"92"
align=
"center"
>
<el-table-column
label=
"补货"
width=
"64"
align=
"right"
><
template
#
default=
"{ row }"
><b>
{{
row
.
final_qty
}}
</b></
template
></el-table-column>
<
template
#
default=
"{ row }"
>
<el-tag
v-if=
"row.check_changed"
size=
"small"
type=
"warning"
>
{{
row
.
checked
?
'手动勾选'
:
'取消勾选'
}}
</el-tag>
<template
v-else
>
{{
row
.
checked
?
'✓'
:
''
}}
</
template
>
</template>
</el-table-column>
<el-table-column
label=
"补货"
width=
"64"
align=
"right"
>
<
template
#
default=
"{ row }"
><b
v-if=
"row.final_qty > 0"
>
{{
row
.
final_qty
}}
</b><span
v-else
class=
"muted"
>
—
</span></
template
>
</el-table-column>
<el-table-column
label=
"关注仓"
min-width=
"140"
>
<el-table-column
label=
"关注仓"
min-width=
"140"
>
<
template
#
default=
"{ row }"
><span
v-for=
"(q, w) in row.wh"
:key=
"w"
class=
"wh"
>
{{
whLabel
(
String
(
w
))
}}
{{
q
}}
</span></
template
>
<
template
#
default=
"{ row }"
><span
v-for=
"(q, w) in row.wh"
:key=
"w"
class=
"wh"
>
{{
whLabel
(
String
(
w
))
}}
{{
q
}}
</span></
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"说明"
min-width=
"150"
><
template
#
default=
"{ row }"
>
{{
lineNote
(
row
)
}}
<span
class=
"err"
>
{{
row
.
error
}}
</span></
template
></el-table-column>
<el-table-column
label=
"说明"
min-width=
"170"
show-overflow-tooltip
>
<
template
#
default=
"{ row }"
>
<el-tag
v-if=
"reasonTag(row)"
size=
"small"
:type=
"row.orderable ? 'info' : 'warning'"
class=
"reason"
>
{{
reasonTag
(
row
)
}}
</el-tag>
{{
reasonText
(
row
)
}}
<span
class=
"err"
>
{{
row
.
error
}}
</span>
</
template
>
</el-table-column>
<
template
#
empty
>
{{
filtering
?
'没有符合筛选条件的配件'
:
'暂无数据'
}}
</
template
>
<
template
#
empty
>
{{
filtering
?
'没有符合筛选条件的配件'
:
'暂无数据'
}}
</
template
>
</el-table>
</el-table>
</template>
<div
v-if=
"filtering"
class=
"muted small filter-hint"
>
筛选后 {{ shownLines.length }} / {{ st.lines.length }} 项
</div>
<div
v-if=
"filtering"
class=
"muted small filter-hint"
>
筛选后 {{ shownLines.length }} / {{ st.lines.length }} 项
</div>
</Panel>
</Panel>
...
@@ -344,4 +380,9 @@ const pretty = (v: any) => (v === null || v === undefined || v === '' ? '' : typ
...
@@ -344,4 +380,9 @@ const pretty = (v: any) => (v === null || v === undefined || v === '' ? '' : typ
.exp
b
{
display
:
inline-block
;
min-width
:
32px
;
text-align
:
right
;
font-variant-numeric
:
tabular-nums
;
}
.exp
b
{
display
:
inline-block
;
min-width
:
32px
;
text-align
:
right
;
font-variant-numeric
:
tabular-nums
;
}
.exp-def
{
padding-left
:
38px
;
}
.exp-def
{
padding-left
:
38px
;
}
.filter-hint
{
padding
:
8px
16px
;
}
.filter-hint
{
padding
:
8px
16px
;
}
/* 补货清单按分组分段:每段一个小标题 */
.grp-title
{
padding
:
12px
16px
8px
;
border-top
:
1px
solid
var
(
--c-border
);
color
:
var
(
--c-text
);
font-size
:
13.5px
;
font-weight
:
600
;
}
.grp-title
:first-child
{
border-top
:
0
;
}
.grp-title
span
{
margin-left
:
8px
;
color
:
var
(
--c-text-3
);
font-size
:
12px
;
font-weight
:
400
;
}
.reason
{
margin-right
:
6px
;
}
</
style
>
</
style
>
web/src/pages/restock/Runs.vue
View file @
dd0aa33
...
@@ -81,6 +81,12 @@ async function exportTrace() {
...
@@ -81,6 +81,12 @@ async function exportTrace() {
</el-table-column>
</el-table-column>
<el-table-column
label=
"状态"
width=
"150"
><
template
#
default=
"{ row }"
><StatusPill
:tone=
"STAGE[row.status]?.tone"
>
{{
STAGE
[
row
.
status
]?.
text
||
row
.
stage_cn
}}
</StatusPill></
template
></el-table-column>
<el-table-column
label=
"状态"
width=
"150"
><
template
#
default=
"{ row }"
><StatusPill
:tone=
"STAGE[row.status]?.tone"
>
{{
STAGE
[
row
.
status
]?.
text
||
row
.
stage_cn
}}
</StatusPill></
template
></el-table-column>
<el-table-column
label=
"可订"
width=
"130"
align=
"right"
><
template
#
default=
"{ row }"
><span
class=
"num"
>
{{
row
.
summary
.
order_count
}}
项 /
{{
row
.
summary
.
order_qty
}}
件
</span></
template
></el-table-column>
<el-table-column
label=
"可订"
width=
"130"
align=
"right"
><
template
#
default=
"{ row }"
><span
class=
"num"
>
{{
row
.
summary
.
order_count
}}
项 /
{{
row
.
summary
.
order_qty
}}
件
</span></
template
></el-table-column>
<el-table-column
label=
"改过"
width=
"80"
align=
"center"
>
<
template
#
default=
"{ row }"
>
<el-tag
v-if=
"row.summary.changed_count"
size=
"small"
type=
"warning"
>
改
{{
row
.
summary
.
changed_count
}}
处
</el-tag>
<span
v-else
class=
"muted"
>
—
</span>
</
template
>
</el-table-column>
<el-table-column
label=
"金额"
width=
"110"
align=
"right"
><
template
#
default=
"{ row }"
><span
class=
"num"
>
{{
fmtMoney
(
row
.
summary
.
amount
)
}}
</span></
template
></el-table-column>
<el-table-column
label=
"金额"
width=
"110"
align=
"right"
><
template
#
default=
"{ row }"
><span
class=
"num"
>
{{
fmtMoney
(
row
.
summary
.
amount
)
}}
</span></
template
></el-table-column>
<el-table-column
label=
"发起人"
width=
"110"
show-overflow-tooltip
><
template
#
default=
"{ row }"
>
{{
row
.
triggered_by
||
'—'
}}
</
template
></el-table-column>
<el-table-column
label=
"发起人"
width=
"110"
show-overflow-tooltip
><
template
#
default=
"{ row }"
>
{{
row
.
triggered_by
||
'—'
}}
</
template
></el-table-column>
<el-table-column
label=
"确认人"
width=
"110"
show-overflow-tooltip
><
template
#
default=
"{ row }"
>
{{
row
.
confirmed_by
||
'—'
}}
</
template
></el-table-column>
<el-table-column
label=
"确认人"
width=
"110"
show-overflow-tooltip
><
template
#
default=
"{ row }"
>
{{
row
.
confirmed_by
||
'—'
}}
</
template
></el-table-column>
...
...
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