源代码链接:https://pan.baidu.com/s/1cQ1XEA5nSVNHRjHL2oWwWw 提取码:kvl3
设备注册后就可以在云控设备页面进行审核,当然也可以删除(非法设备)
页面的核心功能是发布任务,其次是监听设备的是否在线的状态和任务情况。其中发布任务是可以多个设备一起发布也可以单个设备发布
发布任务后可以在发布任务页面查看。
个人建议还是单个设备发任务防止封号~
下面试云控设备的js代码 ,大家参考一下吧 没啥 难度主要就是jquery的技术对UI的ID操作很简单。
$(function () { let action_type = "add"; //不同按钮的Action类型默认是add let PKID = ""; //当前单表业务主键 let timer = null; let pager = null; let i = 30; let task_action_type="single" initializeData() function hideModalForm() { //关闭模态窗体 $("#AppRegister_table_modal").modal('hide'); //刷新grid表格 $('#AppRegister_table').bootstrapTable('refresh'); $("#AppRegister_table_delete").attr("disabled", true); } function initializeUIRight() { $("#AppRegister_table_update").attr("disabled", true); $("#AppRegister_table_delete").attr("disabled", true); $("#AppRegister_table_end").attr("disabled", true); $("#AppRegister_table_task").attr("disabled", true); $("#AppRegister_table_check").attr("disabled", true); } function validateForm() { return $("#AppRegister_form").validate({ rules: { AppRegister_TYPE: "required", AppRegister_CODE: "required", IS_USE: "required", AppRegister_REG: "required", }, messages: { AppRegister_TYPE: "邀请码类型必须填写.", AppRegister_CODE: "邀请码必须填写.", IS_USE: "是否生效必须填写.", AppRegister_REG: "邀请码规则必须填写.", }, }).form(); } function onCheck() { var row = $("#AppRegister_table").bootstrapTable('getSelections'); if (row[0].IS_USE == "1") { } else { $("#AppRegister_table_update").attr("disabled", false); $("#AppRegister_table_delete").attr("disabled", false); $("#AppRegister_table_task").attr("disabled", false); $("#AppRegister_table_check").attr("disabled", false); } if (row[0].APP_REGISTER_STATUS == "2") { $("#AppRegister_table_check").attr("disabled", true); } } function onUnCheck() { $("#AppRegister_table_update").attr("disabled", true); $("#AppRegister_table_delete").attr("disabled", true); $("#AppRegister_table_check").attr("disabled", true); $("#AppRegister_table_task").attr("disabled", true); if (row[0].APP_REGISTER_STATUS == "2") { $("#AppRegister_table_check").attr("disabled", false); } } function onCheckAll() { $("#AppRegister_table_task").attr("disabled", false); } function initializeData() { initializeUIRight(); let requestUrl = "../../../App/AjaxManageAppRegisterDevice"; let columns = [ { checkbox: true, align: 'center' }, { field: 'INDEX', title: '序号', align: 'center', formatter: function (value, row, index) { return index + 1; } }, { field: 'APP_DIS_NAME', title: '显示名称', align: 'center' }, { field: 'APP_REGISTER_ID', title: '业务主键', align: 'center' }, { field: 'APP_REGISTER_DEVICE_ID', title: '设备ID', align: 'center' }, { field: 'LIVE_TIME', title: '是否在线', align: 'center', formatter: function (value, row, index) { if (value == "0001-01-01T00:00:00") { return "<span style='color:red'>从未在线过</span>" } else { var endDate = new Date(value); var currentDate = new Date(); //2)计算两个日期相差的毫秒数 var msecNum = currentDate.getTime() - endDate.getTime(); var muit = ((msecNum / 1000) / 60).toFixed(2) var lasterHeartBeatTime = $.formatDateTime(endDate) var message = "" //超过2分钟是为不在线 if (muit > 2) { message = "已离线:" + muit + "分(" + lasterHeartBeatTime + ")" } else { message = "<span style='color:green;font-size:18px;'>在线</span>(" + lasterHeartBeatTime + ")" } return message } } }, { field: 'TASK_STATUS', title: '任务状态', align: 'center', formatter: function (value, row, index) { if (value == "") { return "<span style='color:green;font-size:18px;'>空闲中...</span>" } else if (value == "2") { return "<span style='color:red;font-size:16px;'>忙碌中...</span>" } else { return "<span style='color:green;font-size:18px;'>空闲中...</span>" } } }, { field: 'APP_REGISTER_STATUS', title: '注册状态', align: 'center', formatter: function (value, row, index) { if (value == "1") { return "待审核" } else if (value == "2") { return "<span style='color:green;font-size:16px;'>通过</span>" } else if (value == "3") { return "<span style='color:green;font-size:12px;'>废弃</span>" } } }, { field: 'APP_DEVICE_TYPE', title: '设备类型', align: 'center', formatter: function (value, row, index) { if (value == "Android") { return "Android" } else { return "IOS" } } }, { field: 'APP_RECORED_SOFT_CODE', title: '软件名', align: 'center' }, { field: 'CREATEDATE', title: '创建日期', align: 'center' }, { field: 'REMARK', title: '备注', align: 'center' }] let setting = { singleSelect: false, pagination: false, hideColumn: "APP_REGISTER_ID", onCheck: onCheck, onUncheck: onUnCheck, onCheckAll: onCheckAll }; $.gridTable("AppRegister_table", requestUrl, columns, setting); } $("#AppRegister_table_start").click(function () { timer = setInterval(function () { pager = setInterval(function () { i = i - 1; if (i == 0) { clearInterval(pager); //刷新grid表格 i = 30; $('#AppRegister_table').bootstrapTable('refresh'); } //刷新页面显示的值 $("#AppRegister_refresh_page").text("页面将于" + i + "S后刷新..."); }, 1000) }, i * 1000) $("#AppRegister_table_start").attr("disabled", true); $("#AppRegister_table_end").attr("disabled", false); $.showSuccessToast("监听服务开启成功!"); }) $("#AppRegister_table_end").click(function () { clearInterval(timer); clearInterval(pager); timer = null; pager = null; $("#AppRegister_refresh_page").text("页面将于" + i + "S后刷新..."); $("#AppRegister_table_start").attr("disabled", false); $("#AppRegister_table_end").attr("disabled", true); $.showSuccessToast("监听服务已经被关闭!"); }) $("#AppRegister_table_task").click(function () { var row = $("#AppRegister_table").bootstrapTable('getSelections'); if (row == "" || row == null) { $.showWaringToast("请选择行"); } else { clearInterval(timer); clearInterval(pager); let deviceID = row[0].APP_REGISTER_DEVICE_ID $.ajax({ type: "POST",//方法类型 dataType: "json",//预期服务器返回的数据类型 url: "../../../App/AjaxGetTaskTypeList",//url success: function (result) { if (result.success == "true") { let jsonResult = JSON.parse($.decrypt(result.message)) let categoryData = jsonResult.datas let optionstring = "" for (var i = 0, l = categoryData.length; i < l; i++) { optionstring += "<option value=\"" + categoryData[i]["APP_TASK_ID"] + "\" >" + categoryData[i]["APP_TASK_NAME"] + "</option>"; } $("#APP_TASK_ID").html("<option value=''>任务类型</option> " + optionstring); //获得要赋值的select的id,进行赋值 } else { $.showErrorToast(result.message); } }, error: function () { $.showErrorToast("连接服务器失败!请重试或者重新登录!"); } }); $.ajax({ type: "POST",//方法类型 dataType: "json",//预期服务器返回的数据类型 url: "../../../App/GetDeviceTaskingList?deviceId=" + deviceID+"",//url success: function (result) { if (result.success == "true") { if (result.havetask == "true") { let taskDataJson=(JSON.parse(result.data)) let statusHtml = "正在执行<span style='color:red;font-size:16px;'>[" + taskDataJson[0].APP_TASK_NAME+"]</span>任务." $("#DEVICE_TASK_STATUS").html(statusHtml) } else { $("#DEVICE_TASK_STATUS").html()("暂无任务") } } else { $.showErrorToast(result.message); } }, error: function () { $.showErrorToast("连接服务器失败!请重试或者重新登录!"); } }); let selectLen = row.length if (selectLen== 1) { let registerID = row[0].APP_REGISTER_ID; //注册ID 主键 let deviceName = row[0].APP_DIS_NAME $("#APP_REGISTER_ID_FK").val(registerID); $("#DEVICE_ID").val(deviceID); $("#DEVICE_NAME").val(deviceName); } else { task_action_type = "multi" let deviceNames = "" let deviceIds = "" let deviceRegisterIds="" for (let i = 0; i < selectLen; i++) { deviceNames = deviceNames + row[i].APP_DIS_NAME + "@" deviceIds = deviceIds + row[i].APP_REGISTER_DEVICE_ID + "@" deviceRegisterIds = deviceRegisterIds + row[i].APP_REGISTER_ID + "@" } $("#DEVICE_NAME").val(deviceNames.substr(0, deviceNames.length - 1)); //设备名 $("#APP_REGISTER_ID_FK").val(deviceRegisterIds.substr(0, deviceRegisterIds.length - 1)); //设备注册的id $("#DEVICE_ID").val(deviceIds.substr(0, deviceIds.length - 1)); //设备的ID } $("#ClusterTask_table_modal").modal(); //弹窗模态 } }) $("#APP_TASK_ID").change(function () { var appTaskId = $("#APP_TASK_ID").val(); $("#APP_TASK_NAME").val($("#APP_TASK_ID option:selected").text()); function refreshUI(data) { let taskJson = JSON.parse($.decrypt(data)); $("#APP_TASK_TYPE").val("Android"); $("#APP_TASK_CODE").val(taskJson.APP_TASK_CODE); $("#APP_TASK_TIME").val(taskJson.APP_TASK_TIME); $("#APP_TASK_ADDRESS").val(taskJson.APP_TASK_ADDRESS); } let requestUrl = "../../../App/AjaxGetTaskTypeEntity"; let form_datas = "APP_TASK_ID=" + appTaskId + "" $.ajaxPost(requestUrl, form_datas, refreshUI); }); $("#APP_TASK_form_submit").click(function () { function refreshUI() { //关闭模态窗体 $("#ClusterTask_table_modal").modal('hide'); } //alert(decodeURIComponent($('#ClusterTask_form').serialize())) let form_datas = decodeURIComponent($('#ClusterTask_form').serialize()) + " &ACTION_TYPE=" + task_action_type + "&TABLE =" + $("#ClusterTask_form").attr("table") + "&PRIMARYKEY=" + PKID; let requestUrl = "../../../App/AjaxSaveDeviceTask"; $.ajaxPost(requestUrl, form_datas, refreshUI); }); $("#AppRegister_table_add").click(function () { action_type = "add"; $('#AppRegister_form')[0].reset(); //清空Form表单 $("#AppRegister_table_modal").modal(); }); $("#AppRegister_table_update").click(function () { // 获取当前行 var row = $("#AppRegister_table").bootstrapTable('getSelections'); if (row == "" || row == null) { $.showWaringToast("请选择行"); } else { PKID = row[0].APP_REGISTER_ID; action_type = "update"; $("#APP_DIS_NAME").val(row[0].APP_DIS_NAME); $("#APP_REGISTER_DEVICE_ID").val(row[0].APP_REGISTER_DEVICE_ID); $("#APP_DEVICE_TYPE").val(row[0].APP_DEVICE_TYPE); $("#APP_RECORED_SOFT_CODE").val(row[0].APP_RECORED_SOFT_CODE); $("#REMARK").val(row[0].REMARK); $("#AppRegister_table_modal").modal(); } }); $("#AppRegister_table_delete").click(function () { action_type = "delete"; let row = $("#AppRegister_table").bootstrapTable('getSelections'); if (row == "" || row == null) { $.showWaringToast("请选择行!"); } else { if (row.length > 1) { $.showWaringToast("不支持批量删除!"); return } if (row[0].APP_REGISTER_STATUS == "2") { $.showWaringToast("审核通过的设备不支持物理删除!"); return; } function refreshTable() { $('#AppRegister_table').bootstrapTable('refresh'); $("#AppRegister_table_update").attr("disabled", true); $("#AppRegister_table_delete").attr("disabled", true); } let business_id = "PRIMARYKEY=" + row[0].APP_REGISTER_ID + "&ACTION_TYPE=" + action_type; let requestUrl = "../../../App/AjaxDeleteAppRegister"; $.ajaxPost(requestUrl, business_id, refreshTable); } }); $("#AppRegister_table_check").click(function () { action_type = "check"; let row = $("#AppRegister_table").bootstrapTable('getSelections'); if (row == "" || row == null) { $.showWaringToast("请选择行!"); } else { function refreshTable() { $('#AppRegister_table').bootstrapTable('refresh'); $("#AppRegister_table_update").attr("disabled", true); $("#AppRegister_table_delete").attr("disabled", true); $("#AppRegister_table_check").attr("disabled", true); } let business_id = "PRIMARYKEY=" + row[0].APP_REGISTER_ID + "&ACTION_TYPE=" + action_type; let requestUrl = "../../../App/AjaxCheckInDevice"; $.ajaxPost(requestUrl, business_id, refreshTable); } }) $("#AppRegister_form_submit").click(function () { if (validateForm()) { let form_datas = decodeURIComponent($('#AppRegister_form').serialize()) + "&ACTION_TYPE=" + action_type + "&TABLE=" + $("#AppRegister_form").attr("table") + "&PRIMARYKEY=" + PKID; let requestUrl = "../../../App/AjaxSaveAppRegister"; $.ajaxPost(requestUrl, form_datas, hideModalForm); } else { $.showWaringToast("取消了操作!"); } }); });
源代码链接:https://pan.baidu.com/s/1cQ1XEA5nSVNHRjHL2oWwWw 提取码:kvl3