mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
实现系统总览、统计分析的图标数据接口
This commit is contained in:
@@ -254,23 +254,18 @@ async function initSubpage(id) {
|
||||
})
|
||||
})
|
||||
}
|
||||
else if (id == 'role') {
|
||||
}
|
||||
else if (id == 'role') { }
|
||||
else if (id == 'price') {
|
||||
var elementSelectPriceType = document.getElementById('priceForm_type')
|
||||
elementSelectPriceType.innerHTML = ''
|
||||
await G.cppNative.queryPriceTypeList().then(res => {
|
||||
res.forEach(item => {
|
||||
elementSelectPriceType.options.add(new Option(item.name, item.id))
|
||||
})
|
||||
G.cppNative.queryPriceTypeList().then(res => {
|
||||
res.forEach(item => { elementSelectPriceType.options.add(new Option(item.name, item.id)) })
|
||||
})
|
||||
}
|
||||
else if (id == 'policy') {
|
||||
var elementSelectPolicyType = document.getElementById('policyForm_type')
|
||||
elementSelectPolicyType.innerHTML = ''
|
||||
for (var k in policyTypeDef) {
|
||||
elementSelectPolicyType.options.add(new Option(policyTypeDef[k], k))
|
||||
}
|
||||
for (var k in policyTypeDef) { elementSelectPolicyType.options.add(new Option(policyTypeDef[k], k)) }
|
||||
}
|
||||
|
||||
var tableInfo = tableDef[id]
|
||||
@@ -280,8 +275,11 @@ async function initSubpage(id) {
|
||||
return
|
||||
}
|
||||
|
||||
// 初始化表格
|
||||
G.initTable(id, tableInfo)
|
||||
// 初始化弹窗Form
|
||||
G.initForm(id, popConfirm)
|
||||
if (id == 'device') { G.initForm("deviceAttr", popConfirm) }
|
||||
|
||||
// 绑定行编辑
|
||||
tableInfo.table.on('click', '#btnRowEdit', function () {
|
||||
@@ -310,50 +308,67 @@ function showPop(id, rowData) {
|
||||
// 设置弹框的参数信息
|
||||
G.popSetParams(id, tableInfo.popkeys, popRowdata, callbackPopSetParams)
|
||||
|
||||
if (id == 'user') {
|
||||
G.popSetParamReadonly('user', 'account', isEdit)
|
||||
}
|
||||
if (id == 'user') { G.popSetParamReadonly('user', 'account', isEdit) }
|
||||
}
|
||||
|
||||
var deviceAttrKeyDef = {
|
||||
commType: "通讯方式",
|
||||
ip: "通讯地址",
|
||||
port: "通讯端口",
|
||||
isclient: "客户端",
|
||||
}
|
||||
var deviceAttrKeyDef = { commType: "通讯方式", ip: "通讯地址", port: "通讯端口", isclient: "客户端" }
|
||||
|
||||
// 显示设备的属性编辑弹窗,属性字段格式为JSON: attrs="{}"
|
||||
function showPopDeviceAttr(rowData) {
|
||||
G.showElement('deviceAttrPop', true)
|
||||
|
||||
popRowdata = (rowData && rowData.length > 0) ? rowData : null
|
||||
|
||||
var device_id = rowData[0]
|
||||
var deviceType = rowData[1]
|
||||
var deviceTypeStr = deviceTypeDef[deviceType]
|
||||
var attrsStr = rowData[9]
|
||||
|
||||
var attrs = { commType: "", ip: "", port: 0, isclient: 1 }
|
||||
try {
|
||||
attrs = JSON.parse(attrsStr);
|
||||
} catch (error) {
|
||||
}
|
||||
var attrs = {}
|
||||
try { attrs = JSON.parse(attrsStr); } catch (error) { attrs = {} }
|
||||
if (Object.keys(attrs).length == 0) { attrs = { commType: "", ip: "", port: 0, isclient: 1 } }
|
||||
|
||||
var elemtForm = document.getElementById('deviceAttrForm')
|
||||
elemtForm.innerHTML =
|
||||
`<div class="input-group mb-3">
|
||||
<span class="input-group-text" style="width: 90px; background-color: #a6c0da">编号</span>
|
||||
<span class="input-group-text" style="width: 90px; background-color: #a6c0da">ID</span>
|
||||
<input type="text" class="form-control" value='${device_id}' disabled />
|
||||
</div>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" style="width: 90px; background-color: #a6c0da">设备类型</span>
|
||||
<input type="text" class="form-control" value='${deviceTypeStr}' disabled />
|
||||
</div>`
|
||||
</div>
|
||||
`
|
||||
for (k in attrs) {
|
||||
var title = deviceAttrKeyDef[k]
|
||||
elemtForm.innerHTML += `<div class="input-group mb-3">
|
||||
<span class="input-group-text" style="width: 90px; background-color: #a6c0da">${title}</span>
|
||||
<input type="text" class="form-control" value='${attrs[k]}' />
|
||||
</div>`
|
||||
}
|
||||
}
|
||||
var v = attrs[k]
|
||||
if (k == "commType") {
|
||||
|
||||
var optionStr = ('<option ' + (v == "TCP" ? 'selected ' : '') + 'value="TCP">TCP</option>')
|
||||
+ ('<option ' + (v == "MODBUS" ? 'selected ' : '') + 'value="MODBUS">MODBUS</option>')
|
||||
+ ('<option ' + (v == "SDK" ? 'selected ' : '') + 'value="SDK">SDK</option>')
|
||||
+ ('<option ' + (v == "ACTIVEX" ? 'selected ' : '') + 'value="ACTIVEX">ACTIVEX</option>')
|
||||
|
||||
elemtForm.innerHTML +=
|
||||
`<div class="input-group mb-3">
|
||||
<span class="input-group-text" style="width: 90px; background-color: #a6c0da">${title}</span>
|
||||
<select id="${k}" class="form-select" required>
|
||||
${optionStr}
|
||||
</select>
|
||||
</div>
|
||||
`
|
||||
} else {
|
||||
elemtForm.innerHTML +=
|
||||
`<div class="input-group mb-3">
|
||||
<span class="input-group-text" style="width: 90px; background-color: #a6c0da">${title}</span>
|
||||
<input id="${k}" type="text" class="form-control" value='${v}' />
|
||||
</div>
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
G.cppNative.log(elemtForm.innerHTML);
|
||||
}
|
||||
|
||||
function showPrompt(text, status) {
|
||||
G.showElement('promptPop', true)
|
||||
@@ -404,9 +419,7 @@ function callbackPopGetParams(id, key) {
|
||||
val = []
|
||||
var elemtFormPermission = document.getElementById('roleForm_permission')
|
||||
var elemtPermissionList = elemtFormPermission.querySelectorAll('input')
|
||||
elemtPermissionList.forEach((elemt => {
|
||||
val.push({ permission_id: elemt.value, is_open: (elemt.checked ? 1 : 0) })
|
||||
}))
|
||||
elemtPermissionList.forEach((elemt => { val.push({ permission_id: elemt.value, is_open: (elemt.checked ? 1 : 0) }) }))
|
||||
}
|
||||
return val
|
||||
}
|
||||
@@ -417,13 +430,36 @@ function updateTableData(id) {
|
||||
if (!queryFunc) return
|
||||
|
||||
queryFunc(1, 10).then((res) => {
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// 用户弹窗确认
|
||||
function popConfirm(id) {
|
||||
// 设备属性弹窗: 读取属性配置
|
||||
if (id == "deviceAttr") {
|
||||
/// 选择所有表单元素(input, select, textarea) $('#parentElement :input')
|
||||
/// :input 是jQuery特有的选择器,可以匹配所有input、select、textarea和button元素。
|
||||
/// 同时选择input和select元素 $('#parentElement input, #parentElement select')
|
||||
var param = {}
|
||||
$("#deviceAttrForm :input").each(function () {
|
||||
var id = $(this).attr('id'); // 获取id属性
|
||||
var val = $(this).val(); // 获取value值
|
||||
if ((id == "port" || id == "isclient")) { param[id] = parseInt(val) }
|
||||
else if (id == "commType") { }
|
||||
else if (id) { param[id] = val }
|
||||
});
|
||||
G.cppNative.log(JSON.stringify(param))
|
||||
|
||||
// 存储更新数据
|
||||
G.cppNative.log("rowdata: " + JSON.stringify(popRowdata))
|
||||
var dataId = popRowdata[0]
|
||||
G.cppNative.updateDevice(dataId, { attrs: JSON.stringify(param) }).then(ret => {
|
||||
G.showElement('deviceAttrPop', false)
|
||||
showPrompt((ret == 0 ? '操作成功!' : '操作失败!'), ret)
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取数据表格操作对象
|
||||
var mytable = $('#' + id + 'Table').DataTable()
|
||||
// 获取弹框的参数信息
|
||||
@@ -471,6 +507,5 @@ for (k in deviceTypeDef) {
|
||||
|
||||
$(document).ready(function () {
|
||||
initSubpage('user')
|
||||
|
||||
//G.initTable('user', tableDef['user'])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user