You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yy_rms_39zhiyao_duizhao/templates/drug/drug_weigh_copy.html

292 lines
13 KiB

{% extends 'base.html' %}
{% block content %}
<style>
.dl-horizontal dt {
line-height: 45px;
font-size: 15px;
}
.dl-horizontal dd {
line-height: 45px;
font-size: 15px;
}
</style>
<div class="wrapper wrapper-content animated fadeInDown">
<div class="row">
<div class="col-md-5" style="text-align:center;padding-top:0">
<div> <i class="iconfont icon-RFID"></i></div>
<div style="font-size:45px;padding-top: 0">请在此检测您的RFID标签</div>
</div>
<div class="col-md-5" style="margin-left:50px;padding-left:100px;padding-top:20px;border-left-color:#8B8989;border-left-width:1px;border-left-style:solid;height:auto;font-size: 16px;">
<div class="panel panel-default">
<div class="panel-heading" style="height: 50px;line-height: 30px;font-size: 25px">药剂称重信息</div>
<div class="panel-body">
<div class="row">
<div class="col-md-5">
RFID编号
</div>
<div class="col-md-7">
<span id="barcode"></span>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-5">
药剂名称
</div>
<div class="col-md-7">
<span id="Name"></span>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-5">
英文名称
</div>
<div class="col-md-7">
<span id="EnglishName"></span>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-5">
CAS码
</div>
<div class="col-md-7">
<span id="CASNumber"></span>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-5">
纯度
</div>
<div class="col-md-7">
<span id="Purity"></span>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-5">
药剂余量
</div>
<div class="col-md-7">
<span id="drug_margin"></span>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-5">
当前状态
</div>
<div class="col-md-7">
<span id="Status"></span>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-5">
最后使用人
</div>
<div class="col-md-7">
<span id="ByUserName"></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% load static %}
<script src="{% static 'js/utils.js' %}"></script>
<script type="text/javascript">
$(function () {
var flag_status = true;
var socket = new WebSocket("ws:" + window.location.host + "/drug/drug_socket/");
socket.onopen = function () {
console.log('WebSocket open');//成功连接上Websocket
socket.send('adasdasda1。。。。');//发送数据到服务端
setInterval(function () {
if (flag_status){
console.log(flag_status, 9999)
socket.send('adasdasda1。。。。');
}
}, 1000);
};
socket.onmessage = function (e) {
console.log('message: ' + e.data);//打印服务端返回的数据
if (e.data) {
if (flag_status) {
flag_status = false;
var index = '';
index = parent.layer.load(2,{time: 3*1000});
$.get('{% url 'drug:GetDrugInfo' %}', { drugId: e.data }, function (obj) {
if (obj.data.status == 0) {
flag_status = true;
msg(obj.data.message);
parent.layer.close(index);
socket.send('23213');
return;
}
obj.data = JSON.parse(obj.data.data?obj.data.data:'');
html = '<input type="number" name="" id="drug_margin_" style="color:black;margin-top:20px;" oninput="this.value=this.value.replace(/[^0-9.]+/,\'\');" value=' + obj.drug_margin + '>'
// 关闭layer加载框
parent.layer.close(index);
new $.flavr({ title : '药剂称重', iconPath : 'flavr/images/icons/',
content : '确定更改当前药剂余量为:', dialog : 'form', form : { content: html, method:
'post' }, buttons: {
danger: {
text: '确定',
style: 'danger',
action: function() {
if($('#drug_margin_').val()){
$.ajax({
url: '{% url 'drug:drug_weigh' %}',
type: 'POST',
async: false,
data: {
'drug_margin': $('#drug_margin_').val(),
'drug_id': obj.data.MedicamentId,
},
success: function (obj) {
if(obj.data.status == 0){
flag_status = true;
msg(obj.data.message);
socket.send('23213');
return;
}
obj.data = JSON.parse(obj.data.data?obj.data.data:'');
if(obj.data){
$("#barcode").text(obj.data.BarCode?obj.data.BarCode:'');
$("#Name").text(obj.data.Name?obj.data.Name:'');
$("#EnglishName").text(obj.data.EnglishName?obj.data.EnglishName:'');
$("#CASNumber").text(obj.data.CASNumber?obj.data.CASNumber:'');
$("#Purity").text(obj.data.Purity?obj.data.Purity:'');
$("#drug_margin").text(obj.data.Remain + ' /g');
$("#Status").text(format_status(obj.data.Status));
$("#ByUserName").text(obj.data.ByUserName?obj.data.ByUserName: '');
new $.flavr({
modal: false,
autoclose: false,
timeout: 2000,
buttons: {OK: {
text: '确认',
style: 'danger',
addClass: null,
action: function (e) {
flag_status = true;
socket.send('123123');
}
},},
content: '修改成功!'
});
}else{
flag_status = true;
new $.flavr('请求数据为空!')
}
},
error: function (e) {
flag_status = true;
socket.send('23123123');
new $.flavr('网络请求异常!');
}
})
}else{
flag_status = true;
socket.send('23123123');
new $.flavr('药剂余量必须为数字!');
}
}
},
cancel: {
text: '取消',
style: 'default',
action: function () {
console.log('取消');
flag_status = true;
socket.send('23123123');
}
}
}, });
});
}
}
};
//监听窗口关闭事件当窗口关闭时主动去关闭websocket连接防止连接还没断开就关闭窗口server端会抛异常。
window.onbeforeunload = confirmExit;
function confirmExit() {
// 如果发生刷新页面或者关闭窗口事件则向后端发送 886 关闭连接请求
socket.send('886');
console.log('大鱼');
}
$('#navTitle', window.parent.document).text('药剂称重');
function format_status(params){
switch (params) {
case 1:
return '在库';
case 2:
return '出库';
case 3:
return '空瓶';
case 5:
return '预备入库';
default:
return ''
}
}
})
</script>
{% endblock %}