Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
Django Transportation Management System
提交
2588f66e
D
Django Transportation Management System
项目概览
k54kdk
/
Django Transportation Management System
10 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Django Transportation Management System
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2588f66e
编写于
4月 24, 2022
作者:
P
Pzqqt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Show the details of WaybillRouting by rendering template
Doing this in models.py is inappropriate.
上级
f135bc5d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
55 addition
and
72 deletion
+55
-72
wuliu/models.py
wuliu/models.py
+24
-70
wuliu/templates/wuliu/_inclusions/_waybill_routing_operation_info.html
...es/wuliu/_inclusions/_waybill_routing_operation_info.html
+21
-0
wuliu/templates/wuliu/waybill/detail_waybill.html
wuliu/templates/wuliu/waybill/detail_waybill.html
+2
-1
wuliu/templatetags/wuliu_extras.py
wuliu/templatetags/wuliu_extras.py
+8
-1
未找到文件。
wuliu/models.py
浏览文件 @
2588f66e
import
datetime
as
datetime_
import
datetime
as
datetime_
import
math
import
math
import
re
from
collections
import
defaultdict
from
collections
import
defaultdict
from
django.db
import
models
,
transaction
from
django.db
import
models
,
transaction
...
@@ -9,10 +8,8 @@ from django.db.models.query import QuerySet
...
@@ -9,10 +8,8 @@ from django.db.models.query import QuerySet
from
django.utils
import
timezone
from
django.utils
import
timezone
from
django.core.validators
import
MinValueValidator
,
validate_slug
from
django.core.validators
import
MinValueValidator
,
validate_slug
from
django.core.exceptions
import
ValidationError
from
django.core.exceptions
import
ValidationError
from
django.
urls
import
reverse
from
django.
template.loader
import
render_to_string
from
django.utils.functional
import
cached_property
from
django.utils.functional
import
cached_property
from
django.utils.safestring
import
mark_safe
from
django.utils.http
import
urlencode
from
django.utils.html
import
strip_tags
from
django.utils.html
import
strip_tags
from
utils.common
import
UnescapedDjangoJSONEncoder
,
ExpireLruCache
from
utils.common
import
UnescapedDjangoJSONEncoder
,
ExpireLruCache
...
@@ -562,74 +559,31 @@ class WaybillRouting(models.Model):
...
@@ -562,74 +559,31 @@ class WaybillRouting(models.Model):
self
.
waybill
.
get_full_id
,
self
.
get_operation_type_display
()
self
.
waybill
.
get_full_id
,
self
.
get_operation_type_display
()
)
)
def
_template_context
(
self
)
->
dict
:
wr_transport_out
=
None
wr_return_waybill
=
None
if
self
.
operation_type
in
(
Waybill
.
Statuses
.
GoodsYardDeparted
,
Waybill
.
Statuses
.
Departed
):
wr_transport_out_id
=
self
.
operation_info
.
get
(
"transport_out_id"
)
if
wr_transport_out_id
:
wr_transport_out
=
TransportOut
.
objects
.
get
(
id
=
wr_transport_out_id
)
elif
self
.
operation_type
==
Waybill
.
Statuses
.
Returned
:
wr_return_waybill_id
=
self
.
operation_info
.
get
(
"return_waybill_id"
)
if
wr_return_waybill_id
:
wr_return_waybill
=
Waybill
.
objects
.
get
(
id
=
wr_return_waybill_id
)
return
{
"wr"
:
self
,
"WB_STATUSES"
:
Waybill
.
Statuses
,
"transport_out"
:
wr_transport_out
,
"return_waybill"
:
wr_return_waybill
,
}
def
gen_print_operation_info
(
self
)
->
str
:
def
gen_print_operation_info
(
self
)
->
str
:
""" 生成运单路由的详细文本内容 """
""" 生成运单路由的详细文本内容 """
operation_info_string
=
""
operation_info_string
=
render_to_string
(
if
self
.
operation_type
==
Waybill
.
Statuses
.
Created
:
"wuliu/_inclusions/_waybill_routing_operation_info.html"
,
if
self
.
waybill
.
return_waybill
:
self
.
_template_context
(),
operation_info_string
=
(
)
'该运单为退货运单,退货原因【{return_reason}】,原始运单'
return
operation_info_string
.
strip
()
'【<a href="{stock_waybill_url}">{stock_waybill_full_id}</a>】'
.
format
(
return_reason
=
self
.
operation_info
.
get
(
"return_reason"
,
"Unknown"
),
stock_waybill_url
=
reverse
(
"wuliu:detail_waybill"
,
args
=
[
self
.
waybill
.
return_waybill_id
,
]),
stock_waybill_full_id
=
self
.
waybill
.
return_waybill
.
get_full_id
,
)
)
else
:
operation_info_string
=
"货物已由【{user_name}】揽收,运单号【{waybill}】"
.
format
(
user_name
=
self
.
operation_user
.
name
,
waybill
=
self
.
waybill
.
get_full_id
,
)
elif
self
.
operation_type
in
(
Waybill
.
Statuses
.
Departed
,
Waybill
.
Statuses
.
GoodsYardDeparted
):
try
:
transport_out_id
=
self
.
operation_info
[
"transport_out_id"
]
except
KeyError
:
pass
else
:
transport_out
=
TransportOut
.
objects
.
get
(
id
=
transport_out_id
)
operation_info_string
=
(
'货物已由【{src_department}】发往【{dst_department}】,车次编号'
'【<a href="{transport_out_url}">{transport_out_full_id}</a>】,'
'车牌号【{truck_number_plate}】驾驶员【{driver_name}】电话【{driver_phone}】'
.
format
(
src_department
=
transport_out
.
src_department
,
dst_department
=
transport_out
.
dst_department
,
transport_out_url
=
"%s?%s"
%
(
reverse
(
"wuliu:detail_transport_out"
),
urlencode
({
"transport_out_id"
:
transport_out_id
})
),
transport_out_full_id
=
transport_out
.
get_full_id
,
truck_number_plate
=
transport_out
.
truck
.
number_plate
,
driver_name
=
transport_out
.
driver_name
,
driver_phone
=
transport_out
.
driver_phone
,
)
)
elif
self
.
operation_type
in
(
Waybill
.
Statuses
.
GoodsYardArrived
,
Waybill
.
Statuses
.
Arrived
):
operation_info_string
=
"货物已由【{user_name}】卸车入库"
.
format
(
user_name
=
self
.
operation_user
.
name
)
elif
self
.
operation_type
==
Waybill
.
Statuses
.
SignedFor
:
operation_info_string
=
"货物已由【{sign_for_name}】签收,签收人身份证号【{sign_for_credential_num}】"
.
format
(
sign_for_name
=
self
.
waybill
.
sign_for_customer_name
,
sign_for_credential_num
=
self
.
waybill
.
sign_for_customer_credential_num
,
)
elif
self
.
operation_type
==
Waybill
.
Statuses
.
Returned
:
try
:
return_waybill_id
=
self
.
operation_info
[
"return_waybill_id"
]
except
KeyError
:
pass
else
:
return_waybill
=
Waybill
.
objects
.
get
(
id
=
return_waybill_id
)
operation_info_string
=
"由于【{return_reason}】,客户要求退货,退货运单【{return_waybill}】"
.
format
(
return_reason
=
self
.
operation_info
.
get
(
"return_reason"
,
"Unknown"
),
return_waybill
=
'<a href="%s">%s</a>'
%
(
reverse
(
"wuliu:detail_waybill"
,
args
=
[
return_waybill_id
,
]),
return_waybill
.
get_full_id
,
)
)
elif
self
.
operation_type
==
Waybill
.
Statuses
.
Dropped
:
operation_info_string
=
"运单已作废,作废原因【{drop_reason}】"
.
format
(
drop_reason
=
self
.
waybill
.
drop_reason
)
else
:
raise
ValueError
(
"Unknown operation_type: %s"
%
self
.
operation_type
)
# 去除字符串中的大括号, 避免模板渲染出错
return
mark_safe
(
re
.
sub
(
r
'[{}]'
,
''
,
operation_info_string
))
def
gen_print_operation_info_text
(
self
)
->
str
:
def
gen_print_operation_info_text
(
self
)
->
str
:
""" 生成运单路由的详细文本内容(移除html标签) """
""" 生成运单路由的详细文本内容(移除html标签) """
...
...
wuliu/templates/wuliu/_inclusions/_waybill_routing_operation_info.html
0 → 100644
浏览文件 @
2588f66e
{% if wr.operation_type == WB_STATUSES.Created %}
{% if wr.waybill.return_waybill %}
该运单为退货运单,退货原因【{{ wr.operation_info.return_reason|default:"Unknown" }}】,原始运单【
<a
href=
"{% url "
wuliu:detail_waybill
"
wr.waybill.return_waybill_id
%}"
>
{{ wr.waybill.return_waybill.get_full_id }}
</a>
】
{% else %}
货物已由【{{ wr.operation_user.name }}】揽收,运单号【{{ wr.waybill.get_full_id }}】
{% endif %}
{% elif wr.operation_type == WB_STATUSES.Departed or wr.operation_type == WB_STATUSES.GoodsYardDeparted %}
{% if transport_out %}
货物已由【{{ transport_out.src_department }}】发往【{{ transport_out.dst_department }}】,车次编号【
<a
href=
"{% url "
wuliu:detail_transport_out
"
%}?
transport_out_id=
{{
transport_out.id
}}"
>
{{ transport_out.get_full_id }}
</a>
】,车牌号【{{ transport_out.truck.number_plate }}】驾驶员【{{ transport_out.driver_name }}】电话【{{ transport_out.driver_phone }}】
{% endif %}
{% elif wr.operation_type == WB_STATUSES.GoodsYardArrived or wr.operation_type == WB_STATUSES.Arrived %}
货物已由【{{ wr.operation_user.name }}】卸车入库
{% elif wr.operation_type == WB_STATUSES.SignedFor %}
货物已由【{{ wr.waybill.sign_for_customer_name }}】签收,签收人身份证号【{{ wr.waybill.sign_for_customer_credential_num }}】
{% elif wr.operation_type == WB_STATUSES.Returned %}
{% if return_waybill %}
由于【{{ wr.operation_info.return_reason|default:"Unknown" }}】,客户要求退货,退货运单【
<a
href=
"{% url 'wuliu:detail_waybill' return_waybill.id %}"
>
{{ return_waybill.get_full_id }}
</a>
】
{% endif %}
{% elif wr.operation_type == WB_STATUSES.Dropped %}
运单已作废,作废原因【{{ wr.waybill.drop_reason }}】
{% endif %}
wuliu/templates/wuliu/waybill/detail_waybill.html
浏览文件 @
2588f66e
{% extends "wuliu/waybill/_layout_edit_waybill.html" %}
{% extends "wuliu/waybill/_layout_edit_waybill.html" %}
{% load show_waybill_routing_operation_info from wuliu_extras %}
{% block title %}运单详情{% endblock %}
{% block title %}运单详情{% endblock %}
{% block header_title %}运单详情{% endblock %}
{% block header_title %}运单详情{% endblock %}
{% block content_header %}
{% block content_header %}
...
@@ -57,7 +58,7 @@
...
@@ -57,7 +58,7 @@
<td>
{{ rt.get_operation_type_display }}
</td>
<td>
{{ rt.get_operation_type_display }}
</td>
<td>
{{ rt.operation_dept.name }}
</td>
<td>
{{ rt.operation_dept.name }}
</td>
<td>
{{ rt.operation_user.name }}
</td>
<td>
{{ rt.operation_user.name }}
</td>
<td>
{
{ rt.gen_print_operation_info }
}
</td>
<td>
{
% show_waybill_routing_operation_info rt %
}
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</tbody>
...
...
wuliu/templatetags/wuliu_extras.py
浏览文件 @
2588f66e
...
@@ -4,7 +4,7 @@ from django.forms.fields import ChoiceField
...
@@ -4,7 +4,7 @@ from django.forms.fields import ChoiceField
from
django.contrib.messages
import
constants
from
django.contrib.messages
import
constants
from
..common
import
get_global_settings
,
is_logged_user_has_perm
,
get_logged_user
,
PERMISSION_TREE_LIST
from
..common
import
get_global_settings
,
is_logged_user_has_perm
,
get_logged_user
,
PERMISSION_TREE_LIST
from
..models
import
WaybillRouting
register
=
template
.
Library
()
register
=
template
.
Library
()
...
@@ -215,6 +215,13 @@ def show_form_input_field_with_append_select(field, field_append, label="", div_
...
@@ -215,6 +215,13 @@ def show_form_input_field_with_append_select(field, field_append, label="", div_
"div_class"
:
div_class
"div_class"
:
div_class
}
}
@
register
.
inclusion_tag
(
'wuliu/_inclusions/_waybill_routing_operation_info.html'
)
def
show_waybill_routing_operation_info
(
wr
:
WaybillRouting
):
""" 生成运单路由的详细文本内容
:param wr: WaybillRouting对象
"""
return
wr
.
_template_context
()
@
register
.
inclusion_tag
(
'wuliu/_inclusions/_tables/_waybill_table.html'
)
@
register
.
inclusion_tag
(
'wuliu/_inclusions/_tables/_waybill_table.html'
)
def
show_waybill_table
(
waybills_info_list
,
table_id
,
have_check_box
=
True
,
high_light_fee
=
False
,
high_light_dept_id
=-
1
):
def
show_waybill_table
(
waybills_info_list
,
table_id
,
have_check_box
=
True
,
high_light_fee
=
False
,
high_light_dept_id
=-
1
):
""" 运单表格
""" 运单表格
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录