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.

440 lines
18 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{% extends 'baseBZP.html' %}
{% block content %}
{% load static %}
<div class="layui-fluid">
<div class="layui-card">
<div class="layui-form layui-card-header layuiadmin-card-header-auto">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">药柜搜索</label>
<div class="layui-input-block">
<input type="text" class="layui-input" id="searchValue" ReserveSearch='' value="{{ searchValue }}" name="searchValue" placeholder="搜索药柜名称">
</div>
</div>
<div class="layui-inline" style="height: 42px;">
<button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="btnTableSearch">
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
</button>
</div>
</div>
</div>
<div class="layui-card-body">
<div style="padding-bottom: 10px;">
<button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="btnTableAdd" style="margin-right:3px;" data-toggle="tooltip" data-placement="left" title="添加新模板"><i class="fa fa-plus-square" aria-hidden="true"></i>新增药剂模板</button>
<button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="btnTableEdit" style="margin-right:3px;" data-toggle="tooltip" data-placement="left" title="编辑选中模板"><i class="fa fa-pencil-square-o" aria-hidden="true"></i>编辑药剂模板</button>
<button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="btnTableDelete" style="margin-right:3px;" data-toggle="tooltip" data-placement="left" title="删除选中模板"><i class="fa fa-times" aria-hidden="true"></i>删除</button>
<button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="btnBarAdd" style="margin-right:3px;" data-toggle="tooltip" data-placement="left" title="绑定入库"><i class="fa fa-barcode" aria-hidden="true"></i>绑定入库</button>
<button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="printer_template_code" style="margin-right:3px;" data-toggle="tooltip" data-placement="left" title="打印用户条码"><i class="fa fa-print" aria-hidden="true"></i>打印选中入库模板条码</button>
<button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="export_template" style="margin-right:3px;" data-toggle="tooltip" data-placement="left" title="导入入库模板"><i class="fa fa-folder-open-o" aria-hidden="true"></i>导入入库模板</button>
</div>
<table id="demo" lay-filter="test" lay-data="{id: 'idTest'}"></table>
</div>
</div>
</div>
<div style="margin-bottom:1600px"></div>
<div id="selectGuizi" style="overflow: hidden;height: 300px;">
<div class="layui-form" style="margin-top: 20px;">
<div class="layui-inline">
<label class="layui-form-label">药柜</label>
<div class="layui-input-block">
<select data-placeholder="选择所属药柜..." id="cabinetSelect" name="interest" lay-filter="aihao">
<option value="">全部</option>
</select>
</div>
</div>
<div class="layui-inline" style="margin-top: 20px;">
<label class="layui-form-label">模板名称</label>
<div class="layui-input-block">
<select data-placeholder="选择所属药柜..." id="template_name" name="interest" lay-filter="aihao">
<option value="">全部</option>
</select>
</div>
</div>
</div>
<button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="submitExport" style="margin-right:3px;margin-left: 40%;margin-top: 40px;" data-toggle="tooltip" data-placement="left" title="确认导入">确认导入</button>
</div>
<script src="{% static 'js/utils.js' %}"></script>
{#<script src="{% static 'js/socket/socket.io.min.js' %}"></script>#}
<script src="{% static 'js/warning.js' %}"></script>
<script type="text/javascript">
var visitType=window.parent.frames.getUrlParam('visitType');
if(visitType!='1')
{
$(".centerVisit").hide();
}
$(function () {
$.get('{% url 'dataReport:getClientListJson' %}', function (obj) {
$(obj.data).each(function (index, data) {
$("#cabinetSelect").append("<option value='" + data.ClientId + "' hassubinfo='true'>" + data.ClientName + "</option>");
});
$(".chosen-select").chosen({
no_results_text: "没有找到",
disable_search: true,
allow_single_deselect: true
});
});
$.get("../getUpanTemplateFile", function (obj) {
$(obj.data).each(function (index, data) {
console.log(data);
$("#template_name").append("<option value='" + data + "' hassubinfo='true'>" + data + "</option>");
});
$(".chosen-select").chosen({
no_results_text: "没有找到",
disable_search: true,
allow_single_deselect: true
});
});
var table = layui.table;
let dataTable = []
//执行渲染
table.render({
elem: '#demo', //指定原始表格元素选择器推荐id选择器
// height: 312, //容器高度
cols: [
[{type: 'checkbox', fixed: 'left'},
{ field: 'TemplateName', title: '模板名称', width: 220},
{ field: 'ClientName', title: '所属药柜', width: 110},
{ field: 'BarCodeCount', title: '入库数量', width: 110},
{ field: 'CreateDate', title: '创建时间', width: 190},
{ field: 'CreateUserName', title: '创建人', width: 100},
{ field: 'TemplateContent', title: '详细内容', width: 500, templet: function(d){
var xxnrObj=d.TemplateContent;
var xxnr='';
console.log(xxnrObj)
$.each(xxnrObj,function(index,item){
xxnr+=item.Name+':'+item.Manufacturer+",";
});
return xxnr
}}
]
], //设置表头
url: "{% url 'drugTemplate_getTemplateListJson' %}",
id: "test",
page: {
layout: [ 'count', 'prev', 'page', 'next',], //自定义分页布局
prev:'上一页',
next:'下一页'
},
limit: 15,
limits: [10, 15, 20, 25, 30],
height: 'full-160',
size:'lg',
done: function (res, curr, count) {
},
});
var active = {
submitExport:(function(){
if($('#cabinetSelect').val()=="")
{
layer.msg('请先选择药柜!', {time: 5000, icon:6});
return;
}
if($('#template_name').val()=="")
{
layer.msg('请先选择模板!', {time: 5000, icon:6});
return;
}
$.get('{% url 'drugTemplate:exportPutInTemplate' %}', { ClientId: $('#cabinetSelect').val(),template_name: $("#template_name").val()}, function (obj) {
if(obj.data.status==1)
{
layer.alert(obj.data.message);
}else{
msg(obj.data.message,function () {
location.reload();
});
}
})
}),
btnTableSearch: function () {
table.reload('test', {
where: { //设定异步数据接口的额外参数,任意设
searchValue: $("#searchValue").val(),
//…
},page: {
curr: 1 //重新从第 1 页开始
}
}) //只重载数据
},
btnTableAdd:function () {
parent.layer.open({
title: "添加药剂模板",
shift: 2,
type: 2,
area: ['1000px', '560px'],
content: ["{% url 'drugTemplate_form' %}"],
end: function () {
// currentTime = 0;
// quiteTime = 600;
// tableModel.ajax.reload();
table.reload('test'); //数据刷新
}
});
},
btnTableEdit:function () {
var checkStatus = table.checkStatus('test'), selectRow = checkStatus.data; //得到选中的数据
if (selectRow.length === 0) {
return layer.msg('请选择要编辑的数据!');
}
selectRow = selectRow[0]
parent.layer.open({
title: "编辑药剂模板",
shift: 2,
type: 2,
area: ['1000px', '560px'],
content: ['/drugTemplate/' + selectRow.TemplateId + '/update_form/'],
end: function () {
// tableModel.ajax.reload();
table.reload('test'); //数据刷新
}
});
},
btnTableDelete:function () {
var checkStatus = table.checkStatus('test'), selectRow = checkStatus.data; //得到选中的数据
if (selectRow.length === 0) {
return layer.msg('请选择要删除的数据!');
}
selectRow = selectRow[0]
layer.open({
title: '药剂解锁/锁定',
content: '确定要删除模板 “' + selectRow.TemplateName + '”',
btn: ["确认", "取消"],
btn1:function(index, layero){
$.post("{% url 'drugTemplate_deleteTemplate' %}", { templateId: selectRow.TemplateId }, function (obj) {
if (obj.status == 1) {
// tableModel.draw(false);
layer.alert('删除成功!', {time:1500,btn:[],title:""});
table.reload('test', {
where: { //设定异步数据接口的额外参数,任意设
searchValue: $("#searchValue").val(),
//…
},page: {
curr: 1 //重新从第 1 页开始
}
}) //只重载数据
}
else {
layer.alert('删除失败,请稍后再试', {time:1500,btn:[],title:""});
}
});
},
btn2:function(index, layero){
console.log(index,"2222")
},
})
},
btnBarAdd:function(){
var checkStatus = table.checkStatus('test'), selectRow = checkStatus.data; //得到选中的数据
if (selectRow.length === 0) {
return layer.msg('请选择绑定入库的模板数据!');
}
selectRow = selectRow[0]
// layer弹出一个新的一维条码入库框
quiteTime = Infinity;
parent.layer.open({
title: "绑定入库",
shift: 2,
type: 2,
area: ['1100px', '680px'],
// content: ['/drug/DrugPutInByBarCode/?template_id=' + selectRow.TemplateId],
content: ['/drug/' + selectRow.TemplateId + '/DrugPutInByBarCode/'],
end: function () {
currentTime = 0;
quiteTime = 600;
tableModel.ajax.reload();
}
})
},
RFIDAdd: function(){
var checkStatus = table.checkStatus('test'), selectRow = checkStatus.data; //得到选中的数据
if (selectRow.length === 0) {
return layer.msg('请选择RFID入库的模板数据');
}
selectRow = selectRow[0]
quiteTime = Infinity;
parent.layer.open({
title: "RFID药剂入库",
shift: 2,
type: 2,
area: ['1000px', '600px'],
content: ['/drugTemplate/' + selectRow.TemplateId + '/RFIDStorage/'],
end: function () {
currentTime = 0;
quiteTime = 600;
tableModel.ajax.reload();
}
})
},
printer_template_code: function(){
var checkStatus = table.checkStatus('test'), selectRow = checkStatus.data; //得到选中的数据
if (selectRow.length === 0) {
return layer.msg('请选择要删除的数据!');
}
selectRow = selectRow[0]
if(!selectRow.StartBarCode){
msg("该模板暂不支持打印!");
return false;
}
layer.open({
content: '确定要打印条码范围 <h1 style="color:red">' + selectRow.StartBarCode + '~' + (selectRow.StartBarCode + parseInt(selectRow.BarCodeCount) - 1) + '</h1>吗?',
btn: ["确认", "取消"],
btn1:function(index, layero){
$.ajax({
url: '{% url 'drugTemplate:printer_drug_code' %}',
type: 'GET',
data: {
TemplateId: selectRow.TemplateId
},
success: function (e) {
// parent.layer.close(layer_index)
console.log(e)
if(e.data.status == 0){
layer.alert('打印成功', {time:1500,btn:[],title:""});
}else{
layer.alert("打印失败", {time:1500,btn:[],title:""});
}
},
error: function () {
layer.alert("请求失败!", {time:1500,btn:[],title:""});
}
});
},
btn2:function(index, layero){
console.log(index,"2222")
},
})
},
export_template: function(){
layui.use('form', function () {
var form = layui.form;
form.render(); //刷新select选择框渲染
});
layer.open({
type: 1,
shade: false,
title: "选择导入模板药柜", //不显示标题
area: ['480px', '360px'], //宽高
content: $('#selectGuizi'), //捕获的元素注意最好该指定的元素要存放在body最外层否则可能被其它的相对元素所影响
cancel: function(){
}
});
},
}
$('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
$('#navTitle', window.parent.document).text('药剂入库');
var searchValue = $("#searchValue").val();
$("#searchValue").val(searchValue);
var tableModel = $('#dataTableModel').DataTable({
// searching: false,
lengthChange: false,
select: true,
ajax: {
url: "{% url 'drugTemplate_getTemplateListJson' %}",
data: { searchValue: searchValue },
dataSrc: 'data'
},
columns: [
{ data: 'TemplateId' },
{ data: 'TemplateName' },
{ data: 'ClientName' },
{ data: 'BarCodeCount' },
// { data: 'StartBarCode' }, // 条码范围 经过createdRow进行修改
{ data: 'CreateDate' },
{ data: 'CreateUserName' },
{ data: 'TemplateContent' }
],
"order": [[4, "desc"]],
createdRow: function (row, data, dataIndex) {
var xxnrObj=JSON.parse(data.TemplateContent);
var xxnr='';
$.each(xxnrObj,function(index,item){
xxnr+=item.Name+':'+item.Manufacturer+",";
});
$(row).children('td').eq(5).html(xxnr);
// alert(xxnrObj.length);
//$(row).children('td').eq(9).attr('style', 'text-align: center;')
// $(row).children('td').eq(6).html(data.IsWaitExport == 1 ? "<span class='label label-warning'>是</span>" : "<span class='label label-default'>否</span>");
// $(row).children('td').eq(6).attr('style', 'text-align: center;');
// 格式化条码范围
// $(row).children('td').eq(3).html(data.StartBarCode ?data.StartBarCode + '~' + (data.StartBarCode + parseInt(data.BarCodeCount) - 1): '')
},
columnDefs: [
{
"targets": [0],
"visible": false
}
]
});
$("#searchValue").keyup(function () {
// $("#searchValue").attr('ReserveSearch', $("#searchValue").val());
tableModel.search($("#searchValue").val()).draw();
})
$("#btnTableReload").click(function () {
location.href = "{% url 'drugTemplate_index' %}";
});
$("#btnTableExport").click(function () {
var selectRow = tableModel.row('.selected').data();
if (selectRow == null) {
msg("请选择要导出到本地的模板!");
return;
}
document.getElementById("export").src = '@Url.Content("~/Template/ExportTemplate?templateId=")' + selectRow.TemplateId;
})
});
</script>
<iframe width=0 height=0 frameborder=0 id="export" />
{% endblock %}