提交 121ef23a authored 作者: Chris Harris's avatar Chris Harris

add: 易臻增加单行入库功能

上级 c58dc056
......@@ -2054,6 +2054,7 @@ def product_bind(request,action,what=None):
dt = datetime.datetime.now().strftime('%Y-%m-%d')
dt_fr = request.GET.get('dt_fr', dt)
dt_to = request.GET.get('dt_to', dt)
single_inbound = str(request.GET.get('singleInbound')).lower() == "true"
cur=connection.cursor()
sWhere=" where company_id="+cid+" and is_delete=false and (dt between '"+dt_fr+"' and '"+dt_to+"') "
#and inbound=false
......@@ -2085,6 +2086,35 @@ def product_bind(request,action,what=None):
"group by prd_line,batch_no,store_id,product_id,dt"+\
") g"
if cid.__eq__(19267):
data = {'data': [],
'clmns': ['日期', '生产时间', '产品', '包装规格', '生产批次号', '仓库', '产量', '待入库', '备注', '单行入库'],
'dt_fr': dt_fr, 'dt_to': dt_to, 'qty_uninbound': 0}
s = "select to_char(g.dt,'yyyy-mm-dd'),to_char(tm1,'HH24:MI:SS')||'--'||to_char(tm2,'HH24:MI:ss')," + \
"coalesce(prd_line,''),coalesce((select name from product_product where id=product_id),'')," + \
"coalesce(batch_no,''),coalesce((select name from inventory_storehouse where id=store_id),''),qty,lv," + \
"(select count(*) from mes_labelbindhx" + sWhere + " and inbound=false " + \
"and product_id=g.product_id and batch_no=g.batch_no and store_id=g.store_id and dt=g.dt)+" + \
"(select count(*) from mes_labelbindpx" + sWhere + " and inbound=false " + \
"and product_id=g.product_id and batch_no=g.batch_no and store_id=g.store_id and dt=g.dt) qty_inbound, " + \
"q0,coalesce((SELECT value FROM product_productprop where company_id=" + cid + " and categoryprop_id=" + \
"(SELECT id FROM company_categoryprop where name='package' " + \
"and category_id=(select category_id from company_company where id=" + cid + ")) " + \
"and id in (select prd_property_id from product_prdprops where product_id=g.product_id) limit 1),''),g.dt,product_id,store_id " + \
"from " + \
"(select min(tm1) tm1,max(tm2) tm2,prd_line,batch_no,store_id,product_id,count(*) qty,'三级绑定' lv,sum(q0) q0,dt from " + \
"(select min(tm) tm1,max(tm) tm2,prd_line,batch_no,store_id,product_id,carton_code,count(*) q0,dt FROM mes_labelbindhx" + sWhere + \
"group by prd_line,batch_no,store_id,product_id,carton_code,dt" + \
") h " + \
"group by prd_line,batch_no,store_id,product_id,dt " + \
"union all " + \
"select min(tm1) tm1,max(tm2) tm2,prd_line,batch_no,store_id,product_id,count(*) qty,'二级绑定' lv,sum(q0),dt from " + \
"(select min(tm) tm1,max(tm) tm2,prd_line,batch_no,store_id,product_id,carton_code,count(*) q0,dt FROM mes_labelbindpx" + sWhere + \
"group by prd_line,batch_no,store_id,product_id,carton_code,dt" + \
") h " + \
"group by prd_line,batch_no,store_id,product_id,dt" + \
") g"
# 2023-10-18
if cid in ['180087',]:
data['clmns']=['日期','生产时间','产品','包装规格','生产批次号','制种产地','仓库','产量','待入库','备注']
......@@ -2150,6 +2180,10 @@ def product_bind(request,action,what=None):
q1=q1.replace('箱','大袋').replace('盒','小袋')
q2=q2.replace('箱','大袋').replace('盒','小袋')
data['data'].append([ r[0],r[1],r[3],r[10],r[4],r[12],r[5],q1,q2,r[7] ])
elif cid.__eq__(19267):
btn_html = "<a type=\"button\" id='btn-single-inbound' class='btn btn-primary'>入库本行</a>" \
if int(qty_in/int(a[1])) else "已入库"
data['data'].append([r[0], r[1], r[3], r[10], r[4], r[5], q1, q2, r[7], btn_html, r[-2], r[-1]])
else:
data['data'].append([ r[0],r[1],r[3],r[10],r[4],r[5],q1,q2,r[7] ])
......@@ -2187,6 +2221,14 @@ def product_bind(request,action,what=None):
data['data'].append([r[0], str(r[1])+"--"+str(r[2]), r[3], r[4], r[5], ''])
return render(request, 'mes/product_bind.html', data)
elif action=='inbound':
if single_inbound:
# prd_line, batch_no, store_id, product_id, dt
batch_no = request.GET.get('batchNo', '')
store_id = request.GET.get('storeId', '0')
product_id = request.GET.get('productId', '0')
dt = request.GET.get('dt', dt)
sWhere = (f" WHERE company_id = {cid} AND is_delete = FALSE AND dt = '{dt}' AND batch_no = '{batch_no}' AND "
f"store_id = {store_id} AND product_id = {product_id}")
d=[]
# 将生产的产品按批次入库
tbs=['mes_labelbindhx','mes_labelbindpx']
......
......@@ -79,6 +79,35 @@
});
});
const rowData = {{ data|safe }}
table.on("click","#btn-single-inbound",function(e) {
e.preventDefault();
const thisRow = rowData[table.row($(this).closest('tr')).index()];
const url='/mes/product/bind/inbound';
const data = {
singleInbound: true,
dt: thisRow[0],
batchNo: thisRow[4],
productId: thisRow[10],
storeId: thisRow[11]
};
console.log(data);
$.ajax({
type:"get",
url:url,
data: data,
dataType: 'json',
success:function(res){
console.log(res);
$('.btn-qry').trigger('click');
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert('连接服务器失败');
}
});
});
});
</script>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论