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.

409 lines
17 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="btnTableReload" style="margin-right:3px;" data-toggle="tooltip" data-placement="left" title="刷新"><i class="fa fa-refresh" aria-hidden="true"></i>刷新</button>
<button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="btnTableWarning" 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="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="btnTableClear" 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="btnTableClearAll" 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="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="btnTableLock" style="margin-right:3px;" data-toggle="tooltip" data-placement="left" title="锁定/解锁药柜"><i class="fa fa-lock" aria-hidden="true"></i>锁定/解锁药柜</button>
<button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="btnTableQx" style="margin-right:3px;" data-toggle="tooltip" data-placement="left" title="分配禁用用户"><i class="fa fa-sort" aria-hidden="true"></i>分配禁用用户</button>
<button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="btnTableCellQx" style="margin-right:3px;" data-toggle="tooltip" data-placement="left" title="分配抽屉权限"><i class="fa fa-sort" aria-hidden="true"></i>分配抽屉权限</button>
</div>
<table id="demo" lay-filter="test" lay-data="{id: 'idTest'}"></table>
</div>
</div>
</div>
{% load static %}
<script src="{% static 'js/warning.js' %}"></script>
<script type="text/javascript">
var table = layui.table;
let dataTable = []
//执行渲染
table.render({
elem: '#demo', //指定原始表格元素选择器推荐id选择器
// height: 312, //容器高度
cols: [
[{type: 'checkbox', fixed: 'left'},
{ field: 'ClientCode', title: '药柜序号', width: 110, sort: true},
{ field: 'ClientName', title: '药柜名称', width: 110, sort: true },
{ field: 'ClientTitle', title: '药柜标题', width: 249, sort: true },
{ field: 'ClientUseCode', title: '药柜类型', width: 110, sort: true},
{ field: 'Place', title: '位置', width: 300, sort: true},
{ field: 'ContactPeopleName', title: '联系人', width: 110, sort: true},
{ field: 'ContactPhone', title: '联系电话', width: 130, sort: true},
{ field: 'IsEnabled', title: '状态', width: 110, sort: true, templet: function(d){
if (d.IsEnabled == 1){
return "正常"
}
return "锁定"
}},
{ field: 'Description', title: '说明', width: 220, sort: true},
]
], //设置表头
url: '{% url 'cabinet:getCabinetListJson' %}',
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 = {
btnTableSearch: function () {
table.reload('test', {
where: { //设定异步数据接口的额外参数,任意设
searchValue: $("#searchValue").val(),
//…
},page: {
curr: 1 //重新从第 1 页开始
}
}) //只重载数据
},
btnTableReload: function(){
location.reload();
},
btnTableWarning: function(){
var checkStatus = table.checkStatus('test'), selectRow = checkStatus.data; //得到选中的数据
if (selectRow.length === 0) {
return layer.msg('请选择要设置的药柜!');
}
selectRow = selectRow[0]
quiteTime = Infinity;
parent.layer.open({
title: "设置药柜信息",
shift: 2,
type: 2,
area: ['800px', '600px'],
skin: 'layui-layer-rim', //加上边框
content: ['/cabinet/warningSetting/?ClientId=' + selectRow.ClientId, 'no'],
end: function () {
currentTime = 0;
quiteTime = 600;
tableModel.ajax.reload();
}
});
},
btnTableAdd: function(){
quiteTime = Infinity;
parent.layer.open({
title: "新增自定义药柜",
shift: 2,
type: 2,
area: ['800px', '600px'],
skin: 'layui-layer-rim', //加上边框
content: ['/cabinet/warningSetting/', 'no'],
end: function () {
currentTime = 0;
quiteTime = 600;
tableModel.ajax.reload();
}
});
},
btnTableClear: function(){
var checkStatus = table.checkStatus('test'), selectRow = checkStatus.data; //得到选中的数据
if (selectRow.length === 0) {
return layer.msg('请选中要清空数据的药柜!');
}
selectRow = selectRow[0]
layer.open({
title: '药柜数据',
content: '确定要清空当前所选药柜,序号<p style="line-height:30px;color:red;font-size:20px;">"' + selectRow.ClientCode + '"</p>',
btn: ["确认", "取消"],
btn1:function(index, layero){
$.post("{% url 'cabinet:clearCabinet' %}", { clientId: selectRow.ClientId }, function (obj) {
if (obj.status == 1) {
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")
},
});
},
btnTableClearAll:function () {
layer.open({
title: '药柜数据',
content: '确定要清空所有药柜数据么?',
btn: ["确认", "取消"],
btn1:function(index, layero){
$.post("{% url 'cabinet:clearAllCabinet' %}", 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")
},
})
},
btnTableDelete:function () {
var checkStatus = table.checkStatus('test'), selectRow = checkStatus.data; //得到选中的数据
if (selectRow.length === 0) {
return layer.msg('请选中要删除的药柜!');
}
selectRow = selectRow[0]
layer.open({
title: '药柜数据',
content: '确定要删除当前所选药柜,序号<p style="line-height:30px;color:red;font-size:20px;">"' + selectRow.ClientCode + '"</p>',
btn: ["确认", "取消"],
btn1:function(index, layero){
$.post("{% url 'cabinet:deleteCabinet' %}", { clientId: selectRow.ClientId }, 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")
},
})
},
btnTableQx:function () {
var checkStatus = table.checkStatus('test'), selectRow = checkStatus.data; //得到选中的数据
if (selectRow.length === 0) {
return layer.msg('请选择要分配用户的终端!');
}
selectRow = selectRow[0]
quiteTime = Infinity;
parent.layer.open({
title: "分配柜子禁用用户-" + selectRow.ClientName,
shift: 2,
type: 2,
area: ['860px', '520px'],
skin: 'layui-layer-rim', //加上边框
content: ["/cabinet/powerForm/?clientId=" + selectRow.ClientId, 'no'],
end: function () {
currentTime = 0;
quiteTime = 600;
tableModel.ajax.reload();
}
});
},
btnTableLock:function () {
var checkStatus = table.checkStatus('test'), selectRow = checkStatus.data; //得到选中的数据
if (selectRow.length === 0) {
return layer.msg('请选择要锁定/解锁的药柜!');
}
selectRow = selectRow[0]
var txt = selectRow.IsEnabled == 1 ? "锁定" : "解锁";
layer.open({
title: '药剂解锁/锁定',
content: '确定要' + txt + '此药柜?',
btn: ["确认", "取消"],
btn1:function(index, layero){
$.post('{% url 'cabinet:lockCabinet' %}', { clientId: selectRow.ClientId }, 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")
},
})
},
btnTableCellQx:function () {
var checkStatus = table.checkStatus('test'), selectRow = checkStatus.data; //得到选中的数据
if (selectRow.length === 0) {
return layer.msg('请选择要分配权限的终端!');
}
selectRow = selectRow[0]
quiteTime = Infinity;
parent.layer.open({
title: "分配柜子抽屉权限-" + selectRow.ClientName,
shift: 2,
type: 2,
area: ['860px', '520px'],
skin: 'layui-layer-rim', //加上边框
content: ["/cabinet/cellPowerForm/?clientId=" + selectRow.ClientId, 'no'],
end: function () {
currentTime = 0;
quiteTime = 600;
tableModel.ajax.reload();
}
});
}
}
$('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
$(function () {
$('#navTitle', window.parent.document).text('药柜管理');
var searchValue = $("#searchValue").val();
var tableModel = $('#dataTableModel').DataTable({
searching: false,
lengthChange: false,
select: true,
ajax: {
url: '{% url 'cabinet:getCabinetListJson' %}',
data: { searchValue: searchValue },
dataSrc: 'data'
},
columns: [
{ data: 'ClientId' },
{ data: 'ClientCode' },
{ data: 'ClientName' },
{ data: 'ClientTitle' },
{ data: 'ClientUseCode' },
{ data: 'Place' },
{ data: 'ContactPeopleName' },
{ data: 'ContactPhone' },
{ data: 'IsEnabled' },
{ data: 'Description' }
],
"order": [[1, "asc"]],
createdRow: function (row, data, dataIndex) {
$(row).children('td').eq(0).html("<span class='label label-info'>" + data.ClientCode + "</span>");
$(row).children('td').eq(7).html(data.IsEnabled == 1 ? "<span class='label label-warning'>正常</span>" : "<span class='label label-default'>锁定</span>");
$(row).children('td').eq(7).attr('style', 'text-align: center;')
},
columnDefs: [
{
"targets": [0],
"visible": false
}
]
});
/* $("#btnTableCamera").click(function () {
var selectRow = tableModel.row('.selected').data();
if (selectRow == null) {
layer.msg("请选择要设置的药柜!");
return;
}
parent.layer.open({
title: "配置药柜摄像头信息",
shift: 2,
type: 2,
area: ['800px', '420px'],
skin: 'layui-layer-rim', //加上边框
content: ['@Url.Content("~/Cabinet/CameraSetting?clientId=")' + selectRow.ClientId, 'no'],
end: function () {
tableModel.ajax.reload();
}
});
}); */
$("#tablePre").click(function () {
$("#dataTableModel_previous").click();
});
$("#tableNext").click(function () {
$("#dataTableModel_next").click();
})
});
</script>
{% endblock %}