yn_img_tool/target/classes/static/js/system/temporaryUser.js

301 lines
8.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

let form, layer, table, tableIns;
let pageNum = 1, limitSize = 10; // 默认第一页分页数量为10
layui.use(['form', 'layer', 'table', 'laydate'], function () {
form = layui.form;
layer = layui.layer;
table = layui.table;
layui.form.render();
pages(1, 10, 1);
form.on('switch(is-longErm)', function (obj) {
let url = dataUrl + "/sys/temporaryUser/editLongErm";
let params = {
'id': this.value,
'longErm': obj.elem.checked ? 1 : 0
}
console.log(params)
params={
encryptedData:encryptCBC(JSON.stringify(params))
}
console.log(params)
ajaxRequest(url, "POST", params, true, function () {}, function (result) {
console.log(result)
if (result.status === 200) {
reloadData();
parent.layer.msg(result.msg, {icon: 1})
} else if (result.status === 500) {
layer.alert(result.msg, {icon: 2})
}
}, function (xhr) {
error(xhr)
});
});
})
function pages(pageNum, pageSize, typeNum) {
let params = getReqParams(pageNum, pageSize, typeNum);
$.ajax({
url: dataUrl + "/sys/temporaryUser/getList",
headers: {
"token": tokens
},
data: params,
type: 'POST',
async: false,
success: function (result) {
if (result.status === 200) {
if (result.data) {
initTable(result.data, result.limit, result.curr)
laypages(result.count, result.curr, result.limit)
}
} else if (result.status === 500) {
layer.alert(result.msg, {icon: 2})
}
}, error: function (xhr) {
error(xhr);
}
});
}
function laypages(total, page, limit) {
layui.use(['laypage'], function () {
let laypage = layui.laypage;
laypage.render({
elem: 'voi-page',
count: total,
curr: page,
limit: limit,
limits: [10, 20, 50, 100, 200, 500],
layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
groups: 5,
jump: function (obj, first) {
if (!first) {
pageNum = obj.curr, limitSize = obj.limit;
pages(obj.curr, obj.limit, null);
}
}
});
})
}
/*初始化表格*/
function initTable(dataList, limit, page) {
let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
tableIns = table.render({
elem: "#table_data",
height: "full-130",
data: dataList,
limit: limit,
cols: [
[
//表头
{
title: "序号",
width: 80,
unresize: true,
align: "center",
templet: function (d) {
return (page - 1) * limit + d.LAY_INDEX;
}
},
{
field: "userCode",
title: "访客编号",
unresize: true,
align: "center"
},
{
field: "temporaryName",
title: "访客名称",
unresize: true,
align: "center"
},
{
field: "userUnit",
title: "访客单位",
unresize: true,
align: "center"
},
{
field: "userName",
title: "被访人",
unresize: true,
align: "center"
},
{
field: "temporaryTime",
title: "来访日期",
unresize: true,
align: "center"
},
{
field: "times",
title: "门禁有效期",
width: 350,
unresize: true,
align: "center",
templet: function (d) {
if(d.doorIps=='' || d.doorIps==null){
return '';
}else{
return d.times;
}
},
},
{
field: "qrCode",
title: "门禁二维码",
unresize: true,
align: "center",
templet: '#qcCodeView'
},
{
field: "imageUrl",
title: "人脸信息",
unresize: true,
align: "center",
templet: '#imageView'
},
{
title: "操作",
unresize: true,
width: 280,
align: "center",
templet: function (d) {
let html = '';
var url = d.imageUrl;
html +="<a class='layui-icon layui-icon-username' title='更新人脸信息' onclick=\"buttonImageView('" + d.id + "', '" + encodeURIComponent(url) + "')\"></a>" +
"<a class='layui-icon layui-icon-edit' title='修改' onclick=\"addData('" + d.id + "')\"></a>" +
"<a class='layui-icon layui-icon-delete' title='删除' onclick=\"delData('" + d.id + "')\"></a>";
return html;
}
},
],
],
done: function (res, curr, count) {
layer.close(loadingMsg);
table.resize("table_data");
count || this.elem.next(".layui-table-view").find(".layui-table-header").css("display", "inline-block");
count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto");
},
});
}
function buttonImageView(id,imageUrl) {
console.log(id,imageUrl)
var decodedUrl = decodeURIComponent(imageUrl);
console.log(id,decodedUrl)
localStorage.setItem("id",id);
localStorage.setItem("imageUrl",decodedUrl);
var index = layer.open({
title: ["查看", 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 2,
content: 'child/imageView.html',
area: ["500px","500px"],
maxmin: false,
});
}
function buttonQcCodeView(qrCode) {
/*let title = '查看'
let param = {
"qrCode": qrCode
}
openIframe2("qcCodeView", title, "child/temporaryUserForm.html", '1000px', '625px', param);*/
localStorage.setItem("qrCode",qrCode);
var index = layer.open({
title: ["查看", 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 2,
content: 'child/qcCodeView.html',
area: ["500px","500px"],
maxmin: false,
});
}
// 获取参数
function getReqParams(page, limit, type) {
let obj = {};
if (!type) {
obj = {
page: page + "",
limit: limit + "",
keyWord: $('#keyWord').val(),
};
} else {
obj = {
page: '1',
limit: '10',
keyWord: '',
};
}
obj={
encryptedData:encryptCBC(JSON.stringify(obj))
}
return obj;
}
// 查询/重置
function query() {
pageNum = 1;
pages(1, limitSize);
}
function reloadData() {
pages(pageNum, limitSize);
}
// 新增/修改平台用户
function addData(id) {
let title = '新增用户'
if (id) {
title = '修改用户';
}
let param = {
'id': id
}
openIframe2("addOrEditUser", title, "child/temporaryUserForm.html", '1000px', '625px', param);
}
/*删除用户*/
function delData(id) {
layer.confirm("确定删除吗?", {
move: false
}, function () {
let loadingMsg = layer.msg('数据删除中,请稍候...', {icon: 16, scrollbar: false, time: 0});
let url = dataUrl + "/sys/temporaryUser/delById";
let params = {
'id': id
}
params={
encryptedData:encryptCBC(JSON.stringify(params))
}
ajaxRequest(url, "POST", params, true, function () {
}, function (result) {
layer.close(loadingMsg); // 关闭提示层
if (result.status === 200) {
parent.layer.msg(result.msg, {icon: 1})
query()
} else if (result.status === 500) {
layer.alert(result.msg, {icon: 2})
}else if (result.status === 204) {
layer.alert(result.msg, {icon: 2})
}
}, function (xhr) {
layer.close(loadingMsg); // 关闭提示层
error(xhr)
});
})
}