var layer;
|
|
$(function () {
|
layui.use(['layer'], function () {
|
layer = layui.layer;
|
|
|
//获取仓库配置和位置坐标
|
initDepotInfo();
|
});
|
});
|
|
//页面初始化后调整背景图片
|
window.onload = function () {
|
var imgName = "aerial-" + companyId + ".png";
|
$("#m-container").css("background", "#cae3ed url(../../static/img/" + imgName + ") left top no-repeat");
|
};
|
|
function showDetail(depotId) {
|
window.parent.openTab("./basic/quantity/view-check?d=" + depotId, "在线检测", "quantity");
|
};
|
|
//获取部门信息
|
function initDepotInfo() {
|
layer.msg("加载仓库信息……");
|
$.ajax({
|
type: 'GET',
|
url: "../../basic/common/list-depot-pos?d=" +deptId,
|
dataType: 'JSON',
|
contentType: "application/json;charset=UTF-8",
|
success: function (result) {
|
if ("0000" == result.code) {
|
addDepot(result.data);
|
} else {
|
layer.msg(result.msg);
|
}
|
},
|
error: function (result) {
|
layer.msg(result.msg);
|
}
|
});
|
}
|
|
function showTips(name) {
|
$("#camera_info").text("提示:当前设备名称- " + name);
|
};
|
|
// 开始拖拽
|
function drag() {
|
var tips = $(".tip");
|
if (tips.length == 0) {
|
return;
|
}
|
var container = $("#m-container");
|
var parentLeft = container.offset().left;
|
var maxX = parentLeft + container.width();
|
$.each(tips, function (index, item) {
|
var dd = new Dragdrop({
|
target: item,
|
area: [0, maxX, 0, 1000],
|
callback: function (obj) {
|
console.log('x:' + (obj.moveX) + ' y:' + (obj.moveY));
|
}
|
});
|
dd.dragAll();
|
});
|
};
|
|
//添加设备信息
|
function addDepot(list) {
|
|
console.log(list);
|
|
var container = $("#m-container");
|
var parentTop = container.offset().top;
|
var parentLeft = container.offset().left;
|
var temp;
|
var left = 50, top = 50;
|
|
$.each(list, function (index, item) {
|
|
if (item.posX) left = left = parentLeft + item.posX;
|
if (item.posY) top = parentTop + item.posY;
|
temp = "<div id='" + item.id +"' ";
|
temp += "class='tooltip-boxs tip' style='left:";
|
temp += left + "px; top:";
|
temp += top + "px;' ondblclick=showDetail('";
|
temp += item.id + "') >";
|
temp += "<div class='tooltip-tittle'>";
|
temp += item.name;
|
temp += "</div><div class='tooltip-triangle'></div></div>";
|
container.append(temp);
|
});
|
};
|
|
// 保存设备位置信息
|
function updatePos() {
|
var tips = $(".tip");
|
if (tips.length == 0) {
|
return;
|
}
|
var container = $("#m-container");
|
var parentTop = container.offset().top;
|
var parentLeft = container.offset().left;
|
|
// 封装数据进行保存
|
var data = new Array();
|
var id = null, posX = 0.0, posY = 0.0;
|
var offset;
|
$.each(tips, function (index, item) {
|
id = item.id;
|
offset = $('#' + id).offset();
|
data[index] = {
|
bizId: id,
|
posX: offset.left - parentLeft,
|
posY: offset.top - parentTop
|
};
|
});
|
|
$.ajax({
|
type: 'POST',
|
url: "../../basic/common/update-depot-pos",
|
dataType: 'JSON',
|
contentType: "application/json;charset=UTF-8",
|
data: JSON.stringify(data),
|
success: function (result) {
|
layer.msg("信息更新完成!!");
|
},
|
error: function (result) {
|
layer.msg(result.msg);
|
}
|
});
|
}
|