IntelligentRecognition/ah-jjsp-web/.svn/pristine/41/414b42bca5bb4694bec674c9590...

92 lines
2.4 KiB
Plaintext
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, util;
let obj = {
macId: '',
proName: ''
}
function setForm(id, name, proId) {
obj.macId = id;
$(function () {
layui.use(['form', 'util'], function () {
form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
util = layui.util;
form.render();
util.event('lay-active', {
save: function () {
obj.proName = $('#proName').val();
updateBand(obj);
},
cancelBtn: function () {
cancel();
}
});
$('#deviceName').val(name)
getProList(proId);
});
})
}
// 绑定/修改绑定
function updateBand(obj) {
Ajax().post({
headers: {
"encrypt": sm3(JSON.stringify(obj))
},
url: dataUrl + 'proteam/pot/uav/updateBand',
data: obj,
success: function (data) {
if (data.code === 200) {
layer.msg(data.msg, {
icon: 1,
time: 2000 //2秒关闭如果不配置默认是3秒
}, function () {
cancel();
});
} else {
layer.msg(data.msg, {icon: -1});
}
}
});
}
/**
* 获取工程
* */
function getProList(id) {
Ajax().post({
headers: {
"encrypt": sm3(JSON.stringify({}))
},
url: dataUrl + 'proteam/pot/uav/getProList',
success: function (data) {
let obj = data.data;
let str = '';
if (obj != null && obj.length > 0) {
for (let i = 0; i < obj.length; i++) {
if (id === obj[i].id) {
str += '<option selected value=\'' + obj[i].id + '\'>' + obj[i].proName + '</option>';
} else {
str += '<option value=\'' + obj[i].id + '\'>' + obj[i].proName + '</option>';
}
}
}
$("#proName").empty().append(str);
layui.form.render('select'); //这里就是我们要渲染的地方了
}
});
}
function reloading() {
var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
parent.layer.close(index); //再执行关闭
}
// 取消
function cancel() {
reloading();
}