提交 f8db32d2 authored 作者: 张颂恩's avatar 张颂恩

产品规格功能调整

上级 3981bcdf
...@@ -3653,9 +3653,8 @@ def ajax_stkclosing_list(request): ...@@ -3653,9 +3653,8 @@ def ajax_stkclosing_list(request):
#lisin 2024-8-15 库存盘点批次明细 #lisin 2024-8-15 库存盘点批次明细
def stkclosingbatchdetails_list(request): def stkclosingbatchdetails_list(request):
data = {'data': [], 'clmns': [], 'e': [],'subtt': ['进销存报表', '库存盘点批次明细'], 'murl': '', 'dt': True, 'add': True} data = {'data': [], 'clmns': [], 'e': [],'subtt': ['进销存报表', '库存盘点批次明细'], 'murl': '', 'dt': True, 'add': True}
company_id=str(request.user.company.id) company_id = str(request.user.company.id)
ancestor_id = str(request.user.company.id) ancestor_id = str(request.user.company.id)
data['murl'] = '/inventory/stkclosingbatchdetails'
dt = datetime.datetime.now().strftime('%Y-%m-%d') dt = datetime.datetime.now().strftime('%Y-%m-%d')
dt_fr = request.GET.get('date_from', dt) dt_fr = request.GET.get('date_from', dt)
dt_to = request.GET.get('date_to', (datetime.datetime.now() + datetime.timedelta(days=1)).strftime("%Y-%m-%d")) dt_to = request.GET.get('date_to', (datetime.datetime.now() + datetime.timedelta(days=1)).strftime("%Y-%m-%d"))
......
...@@ -115,7 +115,7 @@ class Product(models.Model): ...@@ -115,7 +115,7 @@ class Product(models.Model):
components=models.JSONField(_('组合包装产品明细'),blank=True,null=True,default=dict) components=models.JSONField(_('组合包装产品明细'),blank=True,null=True,default=dict)
# 2023-10-31 # 2023-10-31
bottlecap=models.SmallIntegerField(_('瓶盖码'),blank=True,null=True,default=0) bottlecap=models.SmallIntegerField(_('瓶盖码'),blank=True,null=True,default=0)
scpc = models.TextField(_('产品规格JSON格式'), blank=True, null=True)
class Meta: class Meta:
verbose_name = _('产品信息') verbose_name = _('产品信息')
......
...@@ -119,8 +119,6 @@ ...@@ -119,8 +119,6 @@
}); });
$('#no_form').submit(function(){ $('#no_form').submit(function(){
return false; return false;
}); });
......
...@@ -81,7 +81,6 @@ ...@@ -81,7 +81,6 @@
var editorData = editor.txt.html(); var editorData = editor.txt.html();
$("#id_product_content").val(editorData); $("#id_product_content").val(editorData);
} }
$(this).hide();
//2022-06-12 //2022-06-12
if( !$.isEmpty($('#shelf_life_value').val()) ){ if( !$.isEmpty($('#shelf_life_value').val()) ){
...@@ -90,6 +89,20 @@ ...@@ -90,6 +89,20 @@
$('#id_shelf_life').val('{"period":"'+period+'","value":'+value+'}'); $('#id_shelf_life').val('{"period":"'+period+'","value":'+value+'}');
} }
var scpc = []
var trs = $("#tb_scpc tbody tr")
if(trs.length>0){
for(const t of trs){
scpc.push({
name: $(t).find('.scpc-name').val(),
value: $(t).find('.scpc-value').val()
})
}
$("#id_product_scpc").val(JSON.stringify(scpc))
}
console.log(scpc)
$(this).hide();
$.SubmitForm('#obj_form form','{{request.path}}'); $.SubmitForm('#obj_form form','{{request.path}}');
}); });
//2022-06-12 //2022-06-12
...@@ -222,6 +235,47 @@ ...@@ -222,6 +235,47 @@
$('#tb-components tbody').append(sTr); $('#tb-components tbody').append(sTr);
{% endif %} {% endif %}
var initial_scpc = $("#id_product_scpc").val()
if(initial_scpc!=""){
try{
initial_scpc = JSON.parse(initial_scpc)
for(const s of initial_scpc){
appendScpcItem(s.name, s.value)
}
}
catch(e){
console.log(e)
}
}
$("#btn_scpc_add").click(function(){
var scpc_name = $("#input_scpc_name").val().trim()
var scpc_value = $("#input_scpc_value").val()
if(scpc_name.length === 0){
alert('请输入规格名称')
return
}
if(scpc_value.length === 0){
alert('请输入规格值')
return
}
appendScpcItem(scpc_name, scpc_value)
})
function appendScpcItem(name,value){
$("#tb_scpc tbody").append(`
<tr>
<td><input type="text" value="${name}" class="scpc-name"/></td>
<td><input type="text" value="${value}" class="scpc-value"/></td>
<td><input type="button" value="删除" class="btn-delete"></td>
</tr>
`)
}
$('#tb_scpc tbody').on('click', '.btn-delete', function(){
$(this).parent().parent().remove();
});
{% endblock %} {% endblock %}
{% block subtitle-1 %} {% block subtitle-1 %}
...@@ -244,6 +298,14 @@ ...@@ -244,6 +298,14 @@
padding:0px; padding:0px;
margin:0px; margin:0px;
} }
#tb_scpc tbody input{
border: none;
}
#tb_scpc .btn-delete{
background-color: #f00;
color: #fff;
border: none;
}
</style> </style>
...@@ -428,6 +490,28 @@ ...@@ -428,6 +490,28 @@
</div> </div>
{% endif %} {% endif %}
<div style="margin-bottom:30px">
<h5>产品规格:</h5>
<div style="display: flex; align-items: center;">
<input type="text" id="input_scpc_name" placeholder="输入规格名称" style="width: 200px;">
<div style="padding: 0 10px;">:</div>
<input type="text" id="input_scpc_value" placeholder="输入规格值" style="width: 200px;">
<div style="margin-left: 20px;">
<input type="button" value="添加" id="btn_scpc_add">
</div>
</div>
<table id='tb_scpc' class="table table-condensed table-responsive table-bordered table-hover" style="margin-top: 10px;">
<thead>
<th>规格名称</th>
<th>规格值</th>
<th>操作</th>
</thead>
<tbody>
</tbody>
</table>
</div>
<div> <div>
{% if form.instance.id %} {% if form.instance.id %}
{% if is_show %} {% if is_show %}
...@@ -438,4 +522,5 @@ ...@@ -438,4 +522,5 @@
</div> </div>
<input type="hidden" id="id_product_content" name="contents" value="{{ form.instance.contents }}"> <input type="hidden" id="id_product_content" name="contents" value="{{ form.instance.contents }}">
<input type="hidden" id="id_product_scpc" name="scpc" value="{{ form.instance.scpc }}">
{% endblock %} {% endblock %}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论