init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
@@ -0,0 +1,244 @@
|
||||
<!--[1.3.6]-->
|
||||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Retail/css/myscroll.css"/>
|
||||
<style>
|
||||
.goods_title {
|
||||
font-size: 14px;
|
||||
box-sizing: border-box;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
.goods_title_inner {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-left: 2px solid #232b42;
|
||||
box-sizing: border-box;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.goods_edit {
|
||||
box-sizing: border-box;
|
||||
padding: 10px 20px 10px 30px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.goods_edit_select {
|
||||
width: 230px;
|
||||
height: 35px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
box-sizing: border-box;
|
||||
background: white;
|
||||
margin-right: 20px;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
th > .layui-table-cell {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
td > .layui-table-cell {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.warnningTip {
|
||||
color: orangered;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
<div class="printerBox">
|
||||
<div class="goods_title">
|
||||
<div class="goods_title_inner">
|
||||
打印机管理
|
||||
</div>
|
||||
</div>
|
||||
<div class="goods_edit">
|
||||
<form id="select_serach">
|
||||
<div style="margin-right: 10px;">
|
||||
<input type="text" name="text" id="keyword" class="layui-input" placeholder="请输入要查询的打印机名称或编号">
|
||||
</div>
|
||||
</form>
|
||||
<div class="layui-btn " id="serach_icon" data-type="reload">搜索</div>
|
||||
<if condition="$authArr['printerSet'] eq true">
|
||||
<div class="layui-btn " id="createNew">新增</div>
|
||||
</if>
|
||||
</div>
|
||||
<div class="printerTable" style="padding:0 30px">
|
||||
<table class="layui-hide" id="test" lay-filter="demo"></table>
|
||||
</div>
|
||||
<script type="text/html" id="switchTpl">
|
||||
|
||||
<input type="checkbox" name="status" value="{{d.status}}"
|
||||
<if condition="$authArr['changePrinterStatus'] neq true"> disabled
|
||||
</if> data-id="{{d.id}}" lay-skin="switch" lay-text="开启|禁用" lay-filter="sexDemo" {{ d.status == 2 ? 'checked' : '' }}>
|
||||
|
||||
</script>
|
||||
<script type="text/html" id="barDemo">
|
||||
<if condition="$authArr['powerprinter'] eq true">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="setup">设置</a>
|
||||
</if>
|
||||
<if condition="$authArr['printerEdit'] eq true">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||
</if>
|
||||
{{# if(d.printer_type ==2){ }}
|
||||
<if condition="$authArr['refreshToken'] eq true">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="update_token">刷新token</a>
|
||||
</if>
|
||||
{{# } }}
|
||||
<if condition="$authArr['printerDelete'] eq true">
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
||||
</if>
|
||||
</script>
|
||||
</div>
|
||||
<script>
|
||||
layui.use(['table', 'form', 'layer'], function () {
|
||||
var table = layui.table, form = layui.form, layer = layui.layer;
|
||||
|
||||
table.render({
|
||||
elem: '#test'
|
||||
, url: "{:U('Printer/printerList')}"
|
||||
, method: 'post'
|
||||
, cols: [[
|
||||
{field: 'key', title: '序号', width: 60}
|
||||
, {field: 'printer_name', title: '打印机名称'}
|
||||
, {field: 'api_name', title: '管理员账号'}
|
||||
, {field: 'printer_sn', title: '打印机编号'}
|
||||
, {field: 'status', title: '状态', templet: '#switchTpl'}
|
||||
, {field: 'msg', title: '打印机在线状态'}
|
||||
, {field: 'addtime', title: '添加时间', sort: true}
|
||||
, {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 240}
|
||||
]]
|
||||
, id: "printers"
|
||||
, page: {
|
||||
layout: ['count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
|
||||
}, //是否开启分页
|
||||
});
|
||||
|
||||
//监听工具条
|
||||
table.on('tool(demo)', function (obj) {
|
||||
var data = obj.data;
|
||||
if (obj.event === 'detail') {
|
||||
layer.msg('ID:' + data.id + ' 的查看操作');
|
||||
} else if (obj.event === 'del') {
|
||||
layer.confirm('删除后所有标签将会重置为未绑定状态,该操作无法回退,确认删除吗?', {title: "警告", icon: 7}, function (index) {
|
||||
$.ajax({
|
||||
url: "{:U('Printer/printerDelete')}",
|
||||
type: "POST",
|
||||
data: {
|
||||
id: data.id
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.status == 1) {
|
||||
layer.msg(res.msg, {time: 2000});
|
||||
obj.del();
|
||||
layer.close(index);
|
||||
} else {
|
||||
layer.msg(res.msg, {time: 2000});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
} else if (obj.event === 'edit') {
|
||||
var id = data.id
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '打印机编辑',
|
||||
area: ['calc(100% - 160px)', 'calc(100% - 65px)'],
|
||||
offset: 'rb',
|
||||
shade: 0,
|
||||
content: "{:U('Printer/printerEdit')}?id=" + id,
|
||||
end: function () {
|
||||
MenuApp.refreshWindow();
|
||||
}
|
||||
});
|
||||
} else if (obj.event === 'setup') {
|
||||
//设置
|
||||
layer.open({
|
||||
title: "打印设置",
|
||||
type: 2,
|
||||
content: "{:U('Printer/powerprinter')}?id=" + data.id,
|
||||
area:["600px","350px"],
|
||||
})
|
||||
} else if (obj.event === 'update_token') {
|
||||
var tipstr = `提供此操作是为了<span class="warnningTip">防止token意外过期或不可用时进行刷新操作</span>,
|
||||
如果继续进行此操作,和该设备<span class="warnningTip">绑定同一个开发者后台的所有设备token都将被修改</span>,请谨慎操作!<br>
|
||||
<span class="warnningTip">注意:Token更新上限为20次/天</span>`;
|
||||
layer.confirm(tipstr, {title: '警告', icon: 7}, function (index) {
|
||||
//刷新token时请验证当前token是否可用;如可用请不要额外请求接口;接口请求上限每天20次
|
||||
$.post("{:U('refreshToken')}", {printerData: data}, function (res) {
|
||||
if (res.status == 1) {
|
||||
layer.msg(res.msg, {icon: 1, time: 1000}, function () {
|
||||
layer.close(index)
|
||||
table.reload('printers')
|
||||
})
|
||||
} else if (res.status == 2) {
|
||||
layer.msg(res.msg, {icon: 1}, function () {
|
||||
layer.close(index)
|
||||
})
|
||||
} else {
|
||||
layer.msg(res.msg, {icon: 7}, function () {
|
||||
layer.close(index)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
$("#serach_icon").click(function () {
|
||||
var keyword = $("#keyword").val();
|
||||
table.reload('printers', {
|
||||
page: {
|
||||
curr: 1 //重新从第 1 页开始
|
||||
}
|
||||
, where: {
|
||||
keyword: keyword
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
//监听状态操作
|
||||
form.on('switch(sexDemo)', function (obj) {
|
||||
var id = $(this).attr("data-id");
|
||||
var status = obj.elem.checked ? 2 : 1;
|
||||
// console.log(id);
|
||||
$.ajax({
|
||||
url: "{:U('Printer/changePrinterStatus')}",
|
||||
type: "POST",
|
||||
data: {
|
||||
id: id,
|
||||
status: status
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.status == 1) {
|
||||
layer.msg(res.msg, {time: 2000});
|
||||
} else {
|
||||
layer.msg(res.msg, {time: 2000});
|
||||
table.reload('printers');
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
$("#createNew").click(function () {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '打印机编辑',
|
||||
area: ['calc(100% - 160px)', 'calc(100% - 65px)'],
|
||||
offset: 'rb',
|
||||
shade: 0,
|
||||
content: "{:U('Printer/printerSet')}",
|
||||
end: function () {
|
||||
MenuApp.refreshWindow();
|
||||
}
|
||||
});
|
||||
// window.location.href = "{:U('Printer/printerSet')}";
|
||||
})
|
||||
});
|
||||
</script>
|
||||
在新工单中引用
屏蔽一个用户