1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431 |
- // JScript 文件
- var dicDeviceAppGroups = {};
- //表格数据
- var tableData = [];
- var comboBoxData = [];
- //组网方式
- var networkComboBoxData = [];
- //数据通道
- var dataChannels = [];
- //用户站模板
- var userStationTypes = {};
- //通讯设备模板
- var commDeviceTypes = {};
- //传输设备模板
- var transDeviceTypes = {};
- var mnId = "";
- var operateType = "Add";
- var operateDevObj = {};
- var devLevelName = "设备";
- var mnLevelName = "单位";
- //左侧树形选中节点的管理ID
- var currentSelManageId;
- var currentSelDeviceId;
- var operateDataChannel = "Add";
- var operateDCIndex = "";
- //无协议项对应的value值
- var val = "";
- //是否加载新建的手机号
- var loadSimNumFlag = false;
- //手机卡号与id对应关系
- var simcardjsa = [];
- //当前手机号
- var currentsimnum = "";
- //设备手机卡号是否加入管理--2016-09-08
- var simManageFlag = false;
- //初始化串口数量
- var serialPortCount = 256;
- var remarkText = "备注信息";
- //用于存储查询出来的图片信息
- var imgNameArray = [];
- //用于存储设备列表当前编辑的设备Id
- var currentOperateDevId;
- //用于存储当前操作的图片的guid
- var currentOperateIndex;
- var fieldwidth = {};
- var fieldnamerel = {};
- var excelUrl = "";
- $(document).ready(function () {
- var defaultTheme = $.cookie("psbsTheme");
- if (defaultTheme != null && defaultTheme != "default") {
- var link = $(document).find('link:first');
- link.attr('href', '../App_Themes/easyui/themes/' + defaultTheme + '/easyui.css');
- }
- $.ShowMask("数据加载中,请稍等……");
- //初始化串口选择下拉框
- InitSerialPortDDL();
- //获取组网方式
- GetNetworks();
- //获取数据通道
- GetDataChannels();
- //获取模板信息
- GetTemplateInfos();
- //获取数据卡信息
- GetSIMCardNumber();
- GetSystemInfo();
- //获取资费标准信息
- GetChargeInfos();
- $("#simManageBtn").linkbutton({ "disabled": true });
- $("#text_SimNum").textbox({
- inputEvents: $.extend({}, $.fn.textbox.defaults.inputEvents, {
- keyup: function (e) {
- var newSim = $("#text_SimNum").textbox('getText');
- if (newSim != "") {
- var containflag = false;
- for (var i in simcardjsa) {
- if (simcardjsa[i]["text"] == newSim) {
- containflag = true;
- }
- }
- if (!containflag) {
- $("#simManageBtn").linkbutton({ "disabled": false });
- $("#txt_SimNum").textbox('setValue', newSim);
- $("#txt_SimNum").textbox({ "disabled": true });
- }
- else {
- $("#simManageBtn").linkbutton({ "disabled": true });
- }
- }
- else {
- $("#simManageBtn").linkbutton({ "disabled": true });
- }
- }
- })
- });
- });
- //从服务器取得系统运行状态信息
- function GetSystemInfo() {
- $.ajax(
- {
- url: "../WebServices/SystemService.asmx/GetSystemStateInfo",
- type: "POST",
- data: { "loginIdentifer": window.parent.guid },
- dataType: "text",
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- if (data.Result)//登录成功
- {
- mnId = data.SysStateInfo.当前登录操作员管理ID;
- mnLevelName = data.SysStateInfo.监测点管理名称;
- devLevelName = data.SysStateInfo.监测点级别名称;
- $("#divContainer").layout('panel', 'west').panel({ title: devLevelName + "管理" });
- $("#divContainer").layout('panel', 'center').panel({ title: devLevelName + "信息列表" });
- $("#devLevelNameForSearch").text(devLevelName);
- $("#devLevelNameForDetail").text(devLevelName);
- $("#txt_DevName").validatebox({ missingMessage: "请输入" + devLevelName + "名称" });
- $("#devNameColumnSpan").text(devLevelName);
- $("#devTypeColumnSpan").text(devLevelName);
- //20170218注释老程序
- // var columnOptions = $("#tbDevInfos").datagrid("options").columns[0];
- // for (var i = 0; i < columnOptions.length; i++) {
- // if (columnOptions[i].field == "devName") {
- // columnOptions[i].title = devLevelName + "名称";
- // }
- // else if (columnOptions[i].field == "devType") {
- // columnOptions[i].title = devLevelName + "类型";
- // }
- // }
- // $("#tbDevInfos").datagrid({ columns: [columnOptions] });
- manageNodeLoaded = false;
- deviceNodeLoaded = false;
- LoadTree("divAreaTree", mnId, true, false);
- LoadTableData();
- LoadComboboxData();
- TreeBindSelect();
- TableCellClick();
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
- }
- });
- }
- function GetTemplateInfos() {
- $.ajax(
- {
- url: "../WebServices/TemplateInfoService.asmx/GetTemplateInfos",
- type: "POST",
- data: { "loginIdentifer": window.parent.guid },
- dataType: "text",
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- if (data.Result)//登录成功
- {
- var typeObjs = data.传输设备;
- var typeComboBoxData = [];
- var selectedValue = "";
- for (var i = 0; i < typeObjs.length; i++) {
- if (i == 0) {
- selectedValue = typeObjs[i].ID;
- }
- var typeObj = {};
- typeObj["id"] = typeObjs[i].ID;
- typeObj["text"] = typeObjs[i].模板名称;
- typeComboBoxData.push(typeObj);
- transDeviceTypes[typeObjs[i].ID] = typeObjs[i];
- }
- $("#cbb_TransArgeement1").combobox({
- data: typeComboBoxData,
- onSelect: cbb_TransArgeement_Select
- }).combobox("select", selectedValue);
- typeObjs = data.通讯设备;
- typeComboBoxData = [];
- selectedValue = "";
- for (var i = 0; i < typeObjs.length; i++) {
- if (i == 0) {
- selectedValue = typeObjs[i].ID;
- }
- var typeObj = {};
- typeObj["id"] = typeObjs[i].ID;
- typeObj["text"] = typeObjs[i].模板名称;
- typeComboBoxData.push(typeObj);
- commDeviceTypes[typeObjs[i].ID] = typeObjs[i];
- }
- $("#cbb_CommDeviceType1").combobox({
- data: typeComboBoxData,
- onSelect: cbb_CommDeviceType_Select
- }).combobox("select", selectedValue);
- typeObjs = data.用户站;
- typeComboBoxData = [];
- selectedValue = "";
- for (var i = 0; i < typeObjs.length; i++) {
- if (i == 0) {
- selectedValue = typeObjs[i].ID;
- }
- var typeObj = {};
- typeObj["id"] = typeObjs[i].ID;
- typeObj["text"] = typeObjs[i].模板名称;
- typeComboBoxData.push(typeObj);
- userStationTypes[typeObjs[i].ID] = typeObjs[i];
- }
- $("#cbb_DevType").combobox({
- data: typeComboBoxData,
- onSelect: cbb_DevType_Select
- }).combobox('select', selectedValue);
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
- }
- });
- }
- function GetNetworks() {
- $.ajax(
- {
- url: "../WebServices/DataChannelService.asmx/GetNetworks",
- type: "POST",
- data: { "loginIdentifer": window.parent.guid },
- dataType: "text",
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- if (data.Result)//登录成功
- {
- var networks = data.Networks;
- networkComboBoxData = [];
- var selectedValue = "";
- for (i = 0; i < networks.length; i++) {
- var devObj = {};
- devObj["id"] = networks[i].ID;
- devObj["text"] = networks[i].Text;
- networkComboBoxData.push(devObj);
- if (data.Networks[i].Selected) {
- selectedValue = networks[i].ID;
- }
- }
- $("#cbb_Network1").combobox({
- data: networkComboBoxData,
- onSelect: cbb_Network_Select
- }).combobox("select", selectedValue);
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
- }
- });
- }
- function GetChargeInfos() {
- $.ajax({
- url: "../WebServices/SIMMaintainService.asmx/GetCharges",
- type: "POST",
- data: {
- "loginIdentifer": window.parent.guid
- },
- dataType: "text",
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- var chargesDataB = [];
- if (data.Result) //登录成功
- {
- var charges = data.Charges;
- for (var i = 0; i < charges.length; i++) {
- if (i == 0) {
- chargesDataB.push({ value: charges[i].ID, text: charges[i].名称, selected: true });
- }
- else {
- chargesDataB.push({ value: charges[i].ID, text: charges[i].名称 });
- }
- }
- $("#txt_Charge").combobox("loadData", chargesDataB);
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- $.messager.alert("提示信息", errorThrown + "\r\n" + XMLHttpRequest.responseText);
- }
- });
- }
- /*获取数据卡信息,并将手机卡号信息加载到添加或编辑设备的对话框中*/
- function GetSIMCardNumber() {
- $.ajax(
- {
- url: "../WebServices/SIMMaintainService.asmx/GetSIMCardInfos",
- type: "POST",
- data: { "loginIdentifer": window.parent.guid },
- dataType: "Text",
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- if (data.Result) //登录成功
- {
- var simCards = data.SIMCards;
- var simnumData = [];
- for (var i = 0; i < simCards.length; i++) {
- var rowData = {};
- rowData["id"] = simCards[i].ID;
- rowData["text"] = simCards[i].手机卡号;
-
- var simcardJson = { 'id': simCards[i].ID, 'text': simCards[i].手机卡号 };
- simcardjsa.push(simcardJson);
- simnumData.push(rowData);
- }
-
- if (loadSimNumFlag == true) {
- $.messager.alert("提示信息", "添加成功");
- $('#dlgSIM').dialog({ closed: true });
- loadSimNumFlag = false;
- }
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- $.messager.alert("提示信息", errorThrown + "\r\n" + XMLHttpRequest.responseText);
- }
- }
- );
- }
- function GetDataChannels() {
- $.ajax(
- {
- url: "../WebServices/DataChannelService.asmx/GetDataChannels",
- type: "POST",
- data: { "loginIdentifer": window.parent.guid },
- dataType: "text",
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- if (data.Result) {
- dataChannels = data.DataChannels;
- //重新加载devtype
- if ($("#cbb_DevType").combobox("getValue") != null) {
- var val = $("#cbb_DevType").combobox("getValue");
- $("#cbb_DevType").combobox("unselect", val).combobox("select", val);
- }
- if ($("#cbb_Network1").combobox("getValue") != null) {
- var val = $("#cbb_Network1").combobox("getValue");
- $("#cbb_Network1").combobox("unselect", val).combobox("select", val);
- }
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
- }
- });
- }
- function InitSerialPortDDL() {
- var dllSerialPortObj = document.getElementById("ddl_SerialPort");
- for (var i = dllSerialPortObj.options.length; i > 0; i--) {
- dllSerialPortObj.removeChild(dllSerialPortObj.options[0]);
- }
- for (var i = 1; i <= serialPortCount; i++) {
- var op = document.createElement("OPTION");
- dllSerialPortObj.options.add(op);
- op.innerText = "COM" + i;
- op.value = "COM" + i;
- }
- }
- function TreeBindSelect() {
- $('#divAreaTree').tree({
- onSelect: function (node) {
- $.ShowMask("数据加载中,请稍等……");
- if (node.attributes["nodeType"] == "manage") {
- currentSelManageId = node.attributes["manage"].ID;
- var selectedLevelName = node.attributes["manage"]["级别别名"];
- if (selectedLevelName == "") {
- selectedLevelName = node.attributes["manage"]["级别名称"];
- }
- if (selectedLevelName == mnLevelName) {
- $("#btn_Add").linkbutton({
- disabled: false
- });
- }
- else {
- $("#btn_Add").linkbutton({
- disabled: true
- });
- }
- }
- else {
- currentSelManageId = "";
- currentSelDeviceId = node.attributes["device"].ID;
- $("#btn_Add").linkbutton({
- disabled: true
- });
- }
- var devIds = GetDeviceIDsByNode(node);
- ReLoadTableData(devIds);
- }
- });
- }
- function TableCellClick() {
- $('#tbDevInfos').datagrid({
- onClickCell: function (index, field, value) {
- if (field == "editDev") {
- operateType = "Modify";
- var selectedRow = $(this).datagrid("getRows")[index];
- var devId = selectedRow["devId"]
- $('#dlgDevice').dialog({ title: '编辑' + devLevelName + '信息', closed: false });
- $('#divDeviceTabs').tabs("select", 0);
- $("#btn_Next").linkbutton({ text: "下一步" });
- LoadDeviceDetailInfo(devId);
- //管理数据卡标志设为false
- simManageFlag = false;
- }
- else if (field == "removeDev") {
- var selectedRow = $(this).datagrid("getRows")[index];
- var devId = selectedRow["devId"];
- $.messager.confirm('提示信息', '您确定要删除该终端吗?', function (r) {
- if (r) {
- $.ShowMask("数据加载中,请稍等……");
- $.ajax({
- url: "../WebServices/DeviceNodeService.asmx/DeleteDeviceNode",
- type: "POST",
- data: { "loginIdentifer": window.parent.guid, "devID": devId },
- dataType: "text",
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- if (data.Result)//登录成功
- {
- //更新左侧树和设备下拉框
- $.messager.alert('提示信息', '删除成功!');
- $("#tbDevInfos").datagrid("deleteRow", index);
- for (var i = 0; i < deviceJson.length; i++) {
- if (deviceJson[i].ID == devId) {
- deviceJson.splice(i, 1);
- break;
- }
- }
- LoadComboboxData();
- GetDataChannels();
- delete deviceNodes[devId];
- var treeNode = $("#divAreaTree").tree("find", "dn_" + devId);
- $("#divAreaTree").tree("remove", treeNode.target);
- }
- else {
- $.messager.alert('提示信息', data.Message, 'warning');
- }
- $.HideMask();
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
- $.HideMask();
- }
- });
- }
- });
- }
- }
- });
- }
- var rtuHTML = "<fieldset style='height:183px'>" +
- "<legend>采集设备</legend>" +
- "<div style='width:100%;height:100%;text-align:center'>" +
- "<table id='tbCommDevice' style='margin:auto'>" +
- "<tr height='30px'>" +
- "<td align='right'><span>设备协议:</span></td>" +
- "<td><input id='cbb_CommDeviceType' class='easyui-combobox' data-options=\"valueField: 'id',textField: 'text',required:true,editable:false,panelHeight:'auto'\" style='width:150px' /></td>" +
- "<td><span>*</span></td>" +
- "</tr>" +
- "<tr height='30px'>" +
- "<td align='right'><span>设备地址:</span></td>" +
- "<td><input id='txt_CommDeviceAddr' class='easyui-validatebox textbox' data-options=\"required:true,validType:'length[1,25]'\" style='height:21px;width:150px'/></td>" +
- "<td><span>*</span></td>" +
- "</tr>" +
- "<tr height='30px'>" +
- "<td align='right'><span>是否轮询:</span></td>" +
- "<td><input id='cbb_IsAsk' class='easyui-combobox' data-options=\"valueField: 'id',textField: 'text',data:[{'id':'是','text':'是'},{'id':'否','text':'否'}],required:true,editable:false,panelHeight:'auto'\" style='width:150px' /></td>" +
- "<td><span>*</span></td>" +
- "</tr>" +
- "<tr height='30px'>" +
- "<td align='right'><span>轮询间隔:</span></td>" +
- "<td><input id='txt_Interval' class='easyui-validatebox textbox' data-options=\"required:true,validType:'length[1,25]'\" value=\"120\" style='height:21px;width:150px'/></td>" +
- "<td><span>*</span></td>" +
- "</tr>" +
- "</table>" +
- "</div>" +
- "</fieldset>";
- var dtuHTML = "<fieldset style='height:183px'>" +
- "<legend>传输设备</legend>" +
- "<div style='width:100%;height:100%;text-align:center'>" +
- "<table id='tbTransDevice' style='margin:auto'>" +
- "<tr height='30px'>" +
- "<td align='right'><span>组网方式:</span></td>" +
- "<td><input id='cbb_Network' class='easyui-combobox' data-options=\"valueField: 'id',textField: 'text',required:true,editable:false,panelHeight:'auto'\" style='width:150px' /></td>" +
- "<td><span>*</span></td>" +
- "</tr>" +
- "<tr height='30px'>" +
- "<td align='right'><span>传输协议:</span></td>" +
- "<td><input id='cbb_TransArgeement' class='easyui-combobox' data-options=\"valueField: 'id',textField: 'text',required:true,editable:false,panelHeight:'auto'\" style='width:150px' /></td>" +
- "<td><span>*</span></td>" +
- "</tr>" +
- "<tr id='trDataChannel' height='30px'>" +
- "<td align='right'><span>通道服务:</span></td>" +
- "<td><input id='cbb_DataChannel' class='easyui-combobox' data-options=\"valueField: 'id',textField: 'text',required:true,editable:false,panelHeight:'auto'\" style='width:150px' /></td>" +
- "<td><span>*</span></td>" +
- "</tr>" +
- "<tr id='trTransIdentify' height='30px'>" +
- "<td align='right'><span>传输标识:</span></td>" +
- "<td><input id='txt_TransIdentify' class='easyui-validatebox textbox' data-options=\"required:true,validType:'length[1,25]'\" style='height:21px;width:150px'/></td>" +
- "<td><span>*</span></td>" +
- "</tr>" +
- "<tr id='trIpAndPort' height='30px'>" +
- "<td align='right'><span>IP和端口:</span></td>" +
- "<td><input id='txt_Ip' class='easyui-validatebox textbox' data-options=\"required:true,validType:'length[1,25]'\" style='width:105px;height:21px' />:<input id='txt_Port' class='easyui-validatebox textbox' data-options=\"required:true,validType:'length[1,25]'\" style='width:40px;height:21px' /></td>" +
- "<td><span>*</span></td>" +
- "</tr>" +
- "</table>" +
- "</div>" +
- "</fieldset>";
- function cbb_DevType_Select(record) {
- var devType = userStationTypes[record ? record.id : $("#cbb_DevType").combobox("getValue")];
- //处理辅助信息
- var tbAuxInfos = $("#tbAuxInfo");
- var trAuxInfos = $("#tbAuxInfo tr");
- for (var i = 3; i < trAuxInfos.length; i++) {
- trAuxInfos.eq(i).remove();
- }
- var devAuxInfos = devType.辅助信息;
- for (var i = 0; i < devAuxInfos.length; i++) {
- if (devAuxInfos[i].量名 == "安装时间" || devAuxInfos[i].量名 == "安装位置" || devAuxInfos[i].量名 == "手机卡号" || devAuxInfos[i].量名 == "经度" || devAuxInfos[i].量名 == "纬度") {
- continue;
- }
- switch (devAuxInfos[i].控件类型.substring(0, 1)) {
- case "T":
- var trTextHTML = "<tr height='30px'>" +
- "<td align='right'><span>" + devAuxInfos[i].量名 + ":</span></td>" +
- "<td><input id='txt_AuxInfo" + i + "' class='easyui-validatebox textbox' style='height:21px;width:150px' " + (devAuxInfos[i].规则提示 == "" ? "" : ("title='" + devAuxInfos[i].规则提示 + "'")) + "/></td>" +
- "<td><span>" + (devAuxInfos[i].必填项 == "是" ? "*" : "") + "</span></td>" +
- "</tr>";
- $(trTextHTML).appendTo(tbAuxInfos);
- if (devAuxInfos[i].必填项 == "是") {
- $("#txt_AuxInfo" + i).validatebox({ required: true, missingMessage: ("请输入" + devAuxInfos[i].量名 + (devAuxInfos[i].规则提示 == "" ? "" : ("," + devAuxInfos[i].规则提示))) });
- }
- break;
- case "D":
- var trDateHTML = "<tr height='30px'>" +
- "<td align='right'><span>" + devAuxInfos[i].量名 + ":</span></td>" +
- "<td><input id='txt_AuxInfo" + i + "' class='easyui-validatebox textbox' style='height:21px;width:150px' value='" + new Date().Format("yyyy-MM-dd HH:mm") + "' onfocus='WdatePicker({dateFmt:\"yyyy-MM-dd HH:mm\"})' /></td>" +
- "<td><span>" + (devAuxInfos[i].必填项 == "是" ? "*" : "") + "</span></td>" +
- "</tr>";
- $(trDateHTML).appendTo(tbAuxInfos);
- break;
- case "C":
- var trComHTML = "<tr height='30px'>" +
- "<td align='right'><span>" + devAuxInfos[i].量名 + ":</span></td>" +
- "<td><input id='cbb_AuxInfo" + i + "' class='easyui-combobox' data-options=\"valueField: 'id',textField: 'text',required:true,editable:false,panelHeight:'auto'\" style='width:150px' /></td>" +
- "<td><span>" + (devAuxInfos[i].必填项 == "是" ? "*" : "") + "</span></td>" +
- "</tr>";
- $(trComHTML).appendTo(tbAuxInfos);
- if (devAuxInfos[i].控件类型.indexOf("CDB") == 0) {
- var comAuxId = "cbb_AuxInfo" + i;
- var comAuxValues = devAuxInfos[i].控件类型.substring(3).split("-");
- $("#" + comAuxId).combobox({
- valueField: 'id',
- textField: 'text',
- required: true,
- editable: false,
- panelHeight: 'auto'
- });
- $.ajax({
- url: "../WebServices/DataBaseService.asmx/GetRecordsByTableNameAndColumns",
- type: "POST",
- data: { "loginIdentifer": window.parent.guid, "requestInfos": (comAuxId + "," + comAuxValues.join(',')), "tableName": comAuxValues[0], "columns": (comAuxValues[1] + ',' + comAuxValues[2]) },
- dataType: "text",
- async: true,
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- if (data.Result) {
- var auxComDatas = [];
- var requestInfos = data.RequestInfos.split(',');
- for (var j = 0; j < data.Records.length; j++) {
- auxComDatas.push({ id: data.Records[j][requestInfos[2]], text: data.Records[j][requestInfos[3]] });
- }
- var comAuxValue = $("#" + requestInfos[0]).combobox("getValue");
- $("#" + requestInfos[0]).combobox({
- data: auxComDatas
- });
- if (typeof (comAuxValue) != "undefined" && comAuxValue != "") {
- $("#" + requestInfos[0]).combobox("select", comAuxValue);
- }
- else {
- if (auxComDatas.length > 0) {
- $("#" + requestInfos[0]).combobox("select", auxComDatas[0].id);
- }
- }
- }
- else {
- $.messager.alert("提示信息", data.Message);
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
- }
- });
- }
- else {
- var comAuxValues = devAuxInfos[i].控件类型.substring(1).split("-");
- var auxComDatas = [];
- for (var j = 0; j < comAuxValues.length; j++) {
- if (comAuxValues[i] == "") {
- continue;
- }
- auxComDatas.push({ id: comAuxValues[j], text: comAuxValues[j] })
- }
- $("#cbb_AuxInfo" + i).combobox({
- valueField: 'id',
- textField: 'text',
- required: true,
- editable: false,
- panelHeight: 'auto',
- data: auxComDatas
- });
- if (auxComDatas.length > 0) {
- $("#cbb_AuxInfo" + i).combobox("select", auxComDatas[0].id);
- }
- }
- break;
- default:
- break;
- }
- }
- //处理组合站
- var subDevNames = devType.子设备.split(",");
- var devTabs = $("#divDeviceTabs");
- var devTabsCount = devTabs.tabs("tabs").length;
- /*当传输协议是平升协议、水资源协议或者是水文协议时,会显示出手机卡号,则其传输设备后对应的就存在数据卡信息页面*/
- /*待添加处理程序*/
- while (devTabsCount > 4) {
- devTabs.tabs('close', 5);
- devTabs.tabs('close', 4);
- devTabsCount = devTabs.tabs("tabs").length;
- }
- devTabs.tabs("select", 0);
- if (subDevNames.length > 1) {
- $("#rtuLegend1").text(subDevNames[0] + "_采集设备");
- $("#dtuLegend1").text(subDevNames[0] + "_传输设备");
- }
- else {
- $("#rtuLegend1").text("采集设备");
- $("#dtuLegend1").text("传输设备");
- }
- var index = 0;
- for (var i = 1; i < subDevNames.length; i++) {
- index = i + 1;
- var rtuPanel = { id: "divRTU" + index, title: "RTU" + index, content: rtuHTML.replace("采集设备", subDevNames[i] + "_采集设备").replace("cbb_CommDeviceType", "cbb_CommDeviceType" + index).replace("txt_CommDeviceAddr", "txt_CommDeviceAddr" + index).replace("cbb_IsAsk", "cbb_IsAsk" + index).replace("txt_Interval", "txt_Interval" + index), selected: false };
- var dtuPanel = { id: "divDTU" + index, title: "DTU" + index, content: dtuHTML.replace("传输设备", subDevNames[i] + "_传输设备").replace("cbb_Network", "cbb_Network" + index).replace("cbb_TransArgeement", "cbb_TransArgeement" + index).replace("cbb_DataChannel", "cbb_DataChannel" + index).replace("trDataChannel", "trDataChannel" + index).replace("txt_TransIdentify", "txt_TransIdentify" + index).replace("txt_Ip", "txt_Ip" + index).replace("txt_Port", "txt_Port" + index).replace("trTransIdentify", "trTransIdentify" + index).replace("trIpAndPort", "trIpAndPort" + index), selected: false };
- devTabs.tabs('add', rtuPanel);
- devTabs.tabs('add', dtuPanel);
- $("#cbb_Network" + index).combobox("clear").combobox({
- data: networkComboBoxData,
- onSelect: cbb_Network_Select
- }).combobox("select", $("#cbb_Network1").combobox("getValue"));
- }
- var subCommDevTempIds = devType.可支持的模板ID.split(";");
- for (var i = 0; i < subCommDevTempIds.length; i++) {
- var commDevComboboxData = [];
- if (subCommDevTempIds[i] == "") {
- for (var cdTempId in commDeviceTypes) {
- commDevComboboxData.push({ id: commDeviceTypes[cdTempId].ID, text: commDeviceTypes[cdTempId].模板名称 });
- }
- }
- else {
- var subTemps = subCommDevTempIds[i].split(",");
- for (var j = 0; j < subTemps.length; j++) {
- if (subTemps[j] == "" || typeof (commDeviceTypes[subTemps[j]]) == "undefined") {
- continue;
- }
- commDevComboboxData.push({ id: commDeviceTypes[subTemps[j]].ID, text: commDeviceTypes[subTemps[j]].模板名称 });
- }
- }
- var commDevTypeObj = $("#cbb_CommDeviceType" + (i + 1))
- commDevTypeObj.combobox('clear').combobox({
- data: commDevComboboxData,
- onSelect: cbb_CommDeviceType_Select
- });
- if (commDevComboboxData.length > 0) {
- commDevTypeObj.combobox('select', commDevComboboxData[0].id);
- }
- }
- }
- function cbb_CommDeviceType_Select(record) {
- var commType = commDeviceTypes[record ? record.id : $("#cbb_CommDeviceType1").combobox("getValue")];
- switch (commType.协议名称) {
- case "CD_CellMonitor":
- case "CD_Camera":
- case "CD_CameraZM460":
- $("#cbb_IsAsk" + $(this).attr("id").substring(18)).combobox("select", "否");
- break;
- default:
- $("#cbb_IsAsk" + $(this).attr("id").substring(18)).combobox("select", "是");
- break;
- }
- var transDevComboboxData = [];
- if (commType.可支持的模板ID == "") {
- for (var tdTempId in transDeviceTypes) {
- transDevComboboxData.push({ id: transDeviceTypes[tdTempId].ID, text: transDeviceTypes[tdTempId].模板名称 });
- }
- }
- else {
- var subTransDevTempIds = commType.可支持的模板ID.split(",");
- for (var i = 0; i < subTransDevTempIds.length; i++) {
- if (typeof (transDeviceTypes[subTransDevTempIds[i]]) == "undefined") {
- continue;
- }
- transDevComboboxData.push({ id: transDeviceTypes[subTransDevTempIds[i]].ID, text: transDeviceTypes[subTransDevTempIds[i]].模板名称 });
- }
- }
- var transDevTypeObj = $("#cbb_TransArgeement" + $(this).attr("id").substring(18));
- var transargeement = transDevTypeObj.combobox("getValue");
- transDevTypeObj.combobox('clear').combobox({
- data: transDevComboboxData,
- onSelect: cbb_TransArgeement_Select
- });
- if (transargeement != null && transargeement != "") {
- transDevTypeObj.combobox('select', transargeement);
- }
- else {
- if (transDevComboboxData.length > 0) {
- //修改待确认
- var netdata = $("#cbb_Network" + $(this).attr("id").substring(18)).combobox("getValue");
- if (netdata != "" && netdata != null) {
- $("#cbb_Network" + $(this).attr("id").substring(18)).combobox("unselect", netdata).combobox("select", netdata);
- }
- else {
- transDevTypeObj.combobox('select', transDevComboboxData[0].id);
- }
- }
- }
- }
- function cbb_TransArgeement_Select(record) {
- }
- function cbb_Network_Select(record) {
- if (record == null) {
- return;
- }
- var networkingMode = record.id;
- var index = $(this).attr("id").substring(11);
- $("#cbb_TransArgeement" + index).combobox({ disabled: false });
- if (networkingMode != 1 && networkingMode != 6 && networkingMode != 7) {
- $("#trTransIdentify" + index).show();//传输标识
- $("#txt_TransIdentify" + index).val("");
- $("#trIpAndPort" + index).hide();
- $("#trDataChannel" + index).show();//通道服务
- //组网方式为“北斗卫星”时,传输协议设置为“北斗协议”,置灰不可修改--2016-09-08
- if (networkingMode == 8) {
- var data = $("#cbb_TransArgeement" + index).combobox("getData");
- var val = "";
- for (var a in data) {
- if (data[a].text == "北斗协议") {
- val = data[a].id;
- }
- }
- $("#cbb_TransArgeement" + index).combobox({ disabled: true });
- $("#cbb_TransArgeement" + index).combobox("select", val);
- }
- else {
- //传输协议赋默认值
- var transdata = $("#cbb_TransArgeement" + index).combobox("getData");
- if (transdata[0]) {
- $("#cbb_TransArgeement" + index).combobox("select", transdata[0].id);
- }
- }
- }
- else {
- var data = $("#cbb_TransArgeement" + index).combobox("getData");
- var val = "";
- for (var a in data) {
- if (data[a].text == "无协议") {
- val = data[a].id;
- }
- }
- $("#cbb_TransArgeement" + index).combobox({ disabled: true });
- $("#cbb_TransArgeement" + index).combobox("select", val);
- if (networkingMode == 1) {
- $("#trTransIdentify" + index).hide();
- $("#trDataChannel" + index).show();
- $("#trIpAndPort" + index).hide();
- }
- else {
- $("#trTransIdentify" + index).hide();
- $("#trDataChannel" + index).hide();
- $("#trIpAndPort" + index).show();
- }
- }
- var ddlServerList = [];
- ddlServerList.push({ 'id': '0', 'text': '新建...' });
-
- switch (networkingMode) {
- case "1":
- for (var dcID in dataChannels) {
- if (dataChannels[dcID].ChannelType == "DC_COM" && (dataChannels[dcID].Text.indexOf("COM") == 0 || dataChannels[dcID].Text.Contains("串口直连"))) {
- ddlServerList.push({ 'id': dataChannels[dcID].ID, 'text': dataChannels[dcID].Text });
- }
- }
- //$("#TelephoneTD").show();
- // $("#trIPAndPort"+index).hide();
- if (operateType == "Add") {
- // $("#cbb_TransArgeement"+index).combobox('select',"无协议");
- }
- break;
- case "2":
- for (var dcID in dataChannels) {
- if (dataChannels[dcID].ChannelType == "DC_COM" && (dataChannels[dcID].Text == "" || dataChannels[dcID].Text.Contains("移动专网"))) {
- ddlServerList.push({ 'id': dataChannels[dcID].ID, 'text': dataChannels[dcID].Text });
- }
- }
- break;
- case "3":
- break;
- case "4":
- for (var dcID in dataChannels) {
- if (dataChannels[dcID].ChannelType == "DC_TCP_FromServer") {
- ddlServerList.push({ 'id': dataChannels[dcID].ID, 'text': dataChannels[dcID].Text });
- }
- }
- break;
- case "5":
- for (var dcID in dataChannels) {
- if (dataChannels[dcID].ChannelType == "DC_UDP_FromServer") {
- ddlServerList.push({ 'id': dataChannels[dcID].ID, 'text': dataChannels[dcID].Text });
- }
- }
- break;
- case "6":
- case "7":
- var dcType = "DC_TCP_Client";
- if (networkingMode == "7") {
- dcType = "DC_UDP_Client";
- }
- for (var dcID in dataChannels) {
- if (dataChannels[dcID].ChannelType == dcType) {
- ddlServerList.push({ 'id': dataChannels[dcID].ID, 'text': dataChannels[dcID].Text });
- }
- }
- if (operateType == "Add") {
- // $("#cbb_TransArgeement"+index).combobox('select',"无协议");
- }
- break;
- //组网方式为”北斗卫星”时,加载对应的通道服务--2016-09-09
- case "8":
- for (var dcID in dataChannels) {
- if (dataChannels[dcID].ChannelType == "DC_COM" && (dataChannels[dcID].Text == "" || dataChannels[dcID].Text.Contains("北斗卫星"))) {
- ddlServerList.push({ 'id': dataChannels[dcID].ID, 'text': dataChannels[dcID].Text });
- }
- }
- break;
- default:
- break;
- }
- $("#cbb_DataChannel" + index).combobox('clear').combobox({
- data: ddlServerList,
- onSelect: cbb_DataChannel_Select
- });
- if (networkingMode != "6" && networkingMode != "7" && ddlServerList.length > 1) {
- $("#cbb_DataChannel" + index).combobox('setValue', ddlServerList[1].id);
- }
- //ddl_ServerList_SelectChanged();
- }
- function cbb_DataChannel_Select(record) {
- if (record == undefined) {
- return;
- }
- if (record.id == "0") {
- var index = $(this).attr("id").substring(15);
- var networkingMode = $("#cbb_Network" + index).combobox("getValue");
- //组网方式为“北斗卫星”时,隐藏组网方式、监听端口,显示串口号项--2016-09-09
- if (networkingMode == "1" || networkingMode == "2" || networkingMode == "3" || networkingMode == "8") {
- $(".NetServer").hide();
- $(".SerialPort").show();
- }
- else if (networkingMode == "4" || networkingMode == "5") {
- var ntk = $("#selNetworking").val(networkingMode);
- ntk.attr("disabled", true);
- $(".NetServer").show();
- $(".SerialPort").hide();
- }
- $("#btn_EditServer").linkbutton({ text: "确定" });
- $('#dlgEditServer').dialog({
- title: '新建通道服务',
- closed: false
- });
- operateDataChannel = "Add";
- operateDCIndex = index;
- //设置通道服务下拉框中不选择任何项160907
- $(this).combobox("select", "");
- }
- }
- function OperateServer() {
- var dcID = $("#cbb_DataChannel" + operateDCIndex).combobox("getValue");
- var networkingMode = $("#cbb_Network" + operateDCIndex).combobox("getValue");
- if (networkingMode == "4" || networkingMode == "5") {
- networkingMode = document.getElementById("selNetworking").value;
- }
- //监听端口
- var serverPort = document.getElementById("txt_ServerPort").value;
- //串口号
- var serialPort = document.getElementById("ddl_SerialPort").value;
- //波特率
- var baudRate = document.getElementById("ddl_BaudRate").value;
- //数据位
- var dataBit = document.getElementById("ddl_DataBit").value;
- //停止位
- var stopBit = document.getElementById("ddl_StopBit").value;
- //校验位
- var parity = document.getElementById("ddl_Parity").value;
- var serverJson = "{'通道ID':'" + dcID + "','组网方式':'" + networkingMode + "','监听端口':'" + serverPort + "','串口号':'" + serialPort + "','波特率':'" + baudRate + "','数据位':'" + dataBit + "','停止位':'" + stopBit + "','校验位':'" + parity + "'}";
- $.ajax(
- {
- url: "../WebServices/DataChannelService.asmx/AddDataChannel",
- type: "POST",
- data: { "loginIdentifer": window.parent.guid, 'dcJsonString': serverJson },
- dataType: "text",
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- if (data.Result) {
- if (dcID == "0") {
- dataChannels.push(data.DataChannel);
- }
- //$("#cbb_Network"+operateDCIndex).combobox("unselect", networkingMode).combobox("select", networkingMode);
- var channelDatas = $("#cbb_DataChannel" + operateDCIndex).combobox("getData");
- channelDatas.push({ id: data.DataChannel.ID, text: data.DataChannel.Text });
- $("#cbb_DataChannel" + operateDCIndex).combobox({ data: channelDatas }).combobox("select", data.DataChannel.ID);
- $.messager.alert("提示信息", "添加成功");
- $('#dlgEditServer').dialog("close");
- }
- else {
- $.messager.alert("提示信息", data.Message);
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- $.messager.alert("提示信息", errorThrown + "\r\n" + XMLHttpRequest.responseText);
- $('#dlgEditServer').dialog("close");
- }
- });
- }
- function LoadTableData(showLastPage, treeSelectedMnId) {
- if (!deviceNodeLoaded) {
- window.setTimeout("LoadTableData(" + showLastPage + "," + treeSelectedMnId + ")", 500);
- return;
- }
- if (treeSelectedMnId) {
- var node = $('#divAreaTree').tree('find', "mn_" + treeSelectedMnId);
- $('#divAreaTree').tree('select', node.target);
- return;
- }
- var devIds = "";
- for (var key in deviceNodes) {
- devIds += key + ",";
- }
- devIds = devIds.substring(0, devIds.length - 1);
- InitDatagridColumnsAndLoadData(devIds);
- if (showLastPage) {
- var pager = $('#tbDevInfos').datagrid("getPager");
- var pagerOptions = pager.pagination("options");
- var pageCount = parseInt((pagerOptions["total"] + pagerOptions["pageSize"] - 1) / pagerOptions["pageSize"]);
- if (pageCount > 1) {
- pager.pagination("select", pageCount);
- }
- }
- }
- //devIds格式:1,2,3,4
- function InitDatagridColumnsAndLoadData(devIds) {
- $.ajax(
- {
- url: "../WebServices/DeviceNodeService.asmx/GetDeviceDisplayColumns",
- type: "POST",
- data: { 'loginIdentifer': window.parent.guid, 'deviceIds': devIds },
- dataType: "text",
- async: false,
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- if (data.Result) {
- var Columns = data.Columns;
- excelUrl = data.ExcelURL;
- var groupConfigs = null;
- var firstFrozen = [];
- var secondFrozen = [];
- var firstPlain = [];
- var secondPlain = [];
- for (var item in Columns) {
- var colwidth;
- if (fieldwidth[Columns[item].Field]) {
- colwidth = fieldwidth[Columns[item].Field];
- }
- else {
- fieldwidth[Columns[item].Field] = Columns[item].property.columnWidth;
- colwidth = fieldwidth[Columns[item].Field];
- }
- fieldnamerel[Columns[item].Field] = Columns[item].property.paramName;
- var gridtitle = Columns[item].HeadText;
- if (gridtitle > 4) {
- gridtitle = gridtitle.substr(0, 4) + "<br/>" + gridtitle.substr(4, Columns[item].HeadText.length);
- }
- if (Columns[item].property.groupName == "") {
- var obj = {
- field: Columns[item].Field,
- title: gridtitle,
- align: Columns[item].property.alignStyle,
- sortable: Columns[item].property.isSort,
- order: 'asc',
- sorter: function (a, b) { return a.localeCompare(b) }
- //width:120
- };
- if (colwidth == "") {
- if (obj.title.indexOf("时间") >= 0) {
- obj.width = 120;
- }
- else if (obj.title.indexOf("操作") >= 0 || obj.title.indexOf("编辑") >= 0 || obj.title.indexOf("删除") >= 0) {
- obj.width = 30;
- }
- else {
- obj.width = 150;
- }
- }
- else {
- obj.width = colwidth;
- }
- if (Columns[item].property.isFrozen) {
- firstFrozen.push(obj);
- }
- else {
- if (obj.title == "操作") {
- obj["formatter"] = function (value, row, index) {
- return "<a href='javascript:void(0)' onclick='ShowMore(" + row[Columns[item].Field] + ",event)'><Img id='imgedit' style='height:18px;width:18px;' border='0' src='../images/edit.png' /></a>";
- };
- }
- firstPlain.push(obj);
- }
- }
- else {
- if (groupConfigs == null) {
- groupConfigs = {};
- }
- if (groupConfigs[Columns[item].property.groupName]) {
- groupConfigs[Columns[item].property.groupName].push(Columns[item]);
- }
- else {
- var obj = {
- title: Columns[item].property.groupName,
- align: "center"
- };
- if (Columns[item].property.isFrozen) {
- firstFrozen.push(obj);
- }
- else {
- firstPlain.push(obj);
- }
- groupConfigs[Columns[item].property.groupName] = [];
- groupConfigs[Columns[item].property.groupName].push(Columns[item]);
- }
- }
- }
- if (groupConfigs) {
- for (var i = 0; i < firstFrozen.length; i++) {
- if (groupConfigs[firstFrozen[i].title]) {
- firstFrozen[i].colspan = groupConfigs[firstFrozen[i].title].length;
- var width = 0;
- for (var j = 0; j < groupConfigs[firstFrozen[i].title].length; j++) {
- var col = groupConfigs[firstFrozen[i].title][j];
- var obj = {
- field: col.Field,
- title: col.HeadText,
- align: col.property.alignStyle,
- sortable: col.property.isSort,
- order: 'asc',
- sorter: function (a, b) { return a.localeCompare(b) }
- //width:120
- };
- if (fieldwidth[col.Field]) {
- colwidth = fieldwidth[col.Field];
- }
- else {
- fieldwidth[col.Field] = col.property.columnWidth;
- colwidth = fieldwidth[col.Field];
- }
- if (colwidth == "") {
- if (obj.title.indexOf("时间") >= 0) {
- obj.width = 120;
- }
- else if (obj.title.indexOf("操作") >= 0 || obj.title.indexOf("编辑") >= 0 || obj.title.indexOf("删除") >= 0) {
- obj.width = 30;
- }
- else {
- obj.width = 90;
- }
- }
- else {
- obj.width = colwidth;
- }
- secondFrozen.push(obj);
- width = width + obj.width;
- }
- firstFrozen[i].width = width;
- }
- else {
- //firstFrozen[i].rowspan = 2;
- }
- }
- for (var i = 0; i < firstPlain.length; i++) {
- if (groupConfigs[firstPlain[i].title]) {
- firstPlain[i].colspan = groupConfigs[firstPlain[i].title].length;
- var width = 0;
- for (var j = 0; j < groupConfigs[firstPlain[i].title].length; j++) {
- var col = groupConfigs[firstPlain[i].title][j];
- var obj = {
- field: col.Field,
- title: col.HeadText,
- align: col.property.alignStyle,
- sortable: col.property.isSort
- //width:120
- };
- if (fieldwidth[col.Field]) {
- colwidth = fieldwidth[col.Field];
- }
- else {
- fieldwidth[col.Field] = col.property.columnWidth;
- colwidth = fieldwidth[col.Field];
- }
- if (colwidth == "") {
- if (obj.title.indexOf("时间") >= 0) {
- obj.width = 128;
- }
- else if (obj.title.indexOf("操作") >= 0 || obj.title.indexOf("编辑") >= 0 || obj.title.indexOf("删除") >= 0) {
- obj.width = 30;
- }
- else {
- obj.width = 100;
- }
- }
- else {
- obj.width = colwidth;
- }
- secondPlain.push(obj);
- width = width + obj.width;
- }
- firstPlain[i].width = width;
- }
- else {
- firstPlain[i].rowspan = 2;
- }
- }
- }
- $('#tbDevInfos').datagrid({ frozenColumns: (secondFrozen.length == 0 ? [firstFrozen] : [firstFrozen, secondFrozen]), columns: (secondPlain.length == 0 ? [firstPlain] : [firstPlain, secondPlain]) });
- $('#tbDevInfos').datagrid("hideColumn", "devId");
- var deviceJason = data.Devices;
- for (var i = 0; i < deviceJason.length; i++) {
- var tableRow = {};
- for (var item in deviceJason[i]) {
- tableRow[deviceJason[i][item].Field] = deviceJason[i][item].Value;
- }
- tableRow["editDev"] = "<img src='../Images/Detail.gif' style='cursor:pointer' />";
- tableRow["removeDev"] = "<img src='../Images/Delete.gif' style='cursor:pointer' />";
- tableData.push(tableRow);
- }
- var tableDataObj = {
- total: deviceJason.length,
- rows: tableData
- }
- $('#tbDevInfos').datagrid({ loadFilter: pagerFilter }).datagrid('loadData', tableDataObj);
- $.HideMask();
- }
- else {
- $.HideMask();
- $.messager.alert("提示信息", data.Message);
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- $.HideMask();
- $.messager.alert("提示信息", errorThrown + "\r\n" + XMLHttpRequest.responseText);
- }
- });
- }
- function ReLoadTableData(devIds) {
- $("#tbDevInfos").datagrid('loadData', { total: 0, rows: [] });
- tableData = [];
- if (devIds.length == 0) {
- $.HideMask();
- return;
- }
- var deviceIds = "";
- for (var i = 0; i < devIds.length; i++) {
- deviceIds += devIds[i] + ",";
- }
- deviceIds = deviceIds.substring(0, deviceIds.length - 1);
- InitDatagridColumnsAndLoadData(deviceIds);
- }
- function pagerFilter(data) {
- if (typeof data.length == 'number' && typeof data.splice == 'function') { // is array
- data = {
- total: data.length,
- rows: data
- }
- }
- var dg = $(this);
- var opts = dg.datagrid('options');
- var pager = dg.datagrid('getPager');
- pager.pagination({
- onSelectPage: function (pageNum, pageSize) {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh', {
- pageNumber: pageNum,
- pageSize: pageSize
- });
- dg.datagrid('loadData', data);
- }
- });
- if (!data.originalRows) {
- data.originalRows = (data.rows);
- }
- var start = (opts.pageNumber - 1) * parseInt(opts.pageSize);
- var end = start + parseInt(opts.pageSize);
- data.rows = (data.originalRows.slice(start, end));
- return data;
- }
- function LoadComboboxData() {
- if (!deviceNodeLoaded) {
- window.setTimeout("LoadComboboxData()", 500);
- return;
- }
- comboBoxData = [];
- for (i = 0; i < deviceJson.length; i++) {
- var devObj = {};
- devObj["id"] = deviceJson[i].ID;
- devObj["text"] = deviceJson[i].名称;
- comboBoxData.push(devObj);
- }
- $("#cbb_DevCombobox").combobox({
- data: comboBoxData
- });
- }
- function LoadManageAndDevCombobox() {
- $("#cb_DevRefer").attr("checked", false);
- $("#cbb_DevRefer").combotree({ 'disabled': true });
- var rootNode = $("#divAreaTree").tree("getRoot");
- var treeData = $("#divAreaTree").tree("getData", rootNode.target);
- var mnComboboxData = [];
- mnComboboxData.push(LoadMnComboboxDataFromTreeData(treeData));
- $('#cbb_DevManager').combotree('loadData', mnComboboxData);
- $('#cbb_DevManager').combotree('tree').tree({
- onBeforeSelect: function (node) {
- var selectedLevelName = node.attributes["manage"]["级别别名"];
- if (selectedLevelName == "") {
- selectedLevelName = node.attributes["manage"]["级别名称"];
- }
- if (selectedLevelName == mnLevelName) {
- return true;
- }
- else {
- return false;
- }
- }
- });
- var devComboboxData = [];
- devComboboxData.push(LoadDevComboboxDataFromTreeData(treeData))
- $('#cbb_DevRefer').combotree('loadData', devComboboxData);
- }
- function LoadMnComboboxDataFromTreeData(treeData) {
- var comTreeDataObj = {};
- comTreeDataObj["id"] = treeData.id;
- comTreeDataObj["text"] = treeData.text;
- comTreeDataObj["attributes"] = treeData.attributes;
- comTreeDataObj["children"] = [];
- for (var i = 0; i < treeData.children.length; i++) {
- if (treeData.children[i].attributes.nodeType == "device") {
- continue;
- }
- comTreeDataObj["children"].push(LoadMnComboboxDataFromTreeData(treeData.children[i]));
- }
- return comTreeDataObj;
- }
- function LoadDevComboboxDataFromTreeData(treeData) {
- var comTreeDataObj = {};
- comTreeDataObj["id"] = treeData.id;
- comTreeDataObj["text"] = treeData.text;
- comTreeDataObj["attributes"] = treeData.attributes;
- comTreeDataObj["children"] = [];
- for (var i = 0; i < treeData.children.length; i++) {
- comTreeDataObj["children"].push(LoadDevComboboxDataFromTreeData(treeData.children[i]));
- }
- return comTreeDataObj;
- }
- //删除轮播控件重新加载
- function LoadImageControl() {
- //删除整个轮播控件再重新创建
- var fieldsetImgObj = $("#fieldsetImg");
- $("#b06").remove();
- var divInfos = $("<div class='banner' id='b06'></div>");
- var ulInfos = $("<ul id='imgul' style='padding-left: 0px; margin-top: 0px;'></ul>");
- var alObj = $("<a href='javascript:void(0);' class='unslider-arrow06 prev'><img class='arrow' id='al' src='../Images/arrowl.png' alt='prev' width='20' height='35'></a>");
- var arObj = $("<a href='javascript:void(0);' class='unslider-arrow06 next'><img class='arrow' id='ar' src='../Images/arrowr.png' alt='next' width='20' height='37'></a>")
- if (imgNameArray.length == 0) {
- index = "0";
- imgUrl = "../Images/addImage.png";
- var liStr = "";
- liStr = "<li id='li_1'>";
- liStr += "<span class='fileinput-button'>";
- liStr += "<input id='fileupload1' type='file' name='files[]' onchange='previewImage(this,1)' autoupload='false'>";
- liStr += "<img id='img_1' class='sliderimg' src='" +
- imgUrl + "' alt='' width='280px' height='170px' >";
- liStr += "</li>";
- liObj = $(liStr);
- remark = "";
- imgNameArray.push({ '显示序号': 0, '图片索引': "0", '图片路径': imgUrl, '备注': "" });
- ulInfos.append(liObj);
- }
- else {
- for (var i = 0; i < imgNameArray.length; i++) {
- var index = imgNameArray[i].图片索引;
- var imgUrl;
- var remark;
- var liObj;
- if (i == imgNameArray.length - 1 && imgNameArray.length <= 6) {
- imgUrl = "../Images/addImage.png";
- var liStr = "";
- liStr = "<li id='li_" + (i + 1) + "'>";
- liStr += "<span class='fileinput-button'>";
- liStr += "<input id='fileupload1' type='file' name='files[]' onchange='previewImage(this," + (i + 1) + ")' autoupload='false'>";
- liStr += "<img id='img_" + (i + 1) + "' class='sliderimg' src='" +
- imgUrl + "' alt='' width='280px' height='170px' >";
- liStr += "</li>";
- liObj = $(liStr);
- remark = "";
- }
- else {
- imgUrl = imgNameArray[i].图片路径;
- remark = imgNameArray[i].备注;
- var liStr = "";
- liStr = "<li id='li_" + (i + 1) + "'><img id='img_" + (i + 1) + "' class='sliderimg' guid='" + index + "' src='" + imgUrl + "' alt='' width='280px' height='170px' ></li>";
- liObj = $(liStr);
- currentOperateImgUrl = imgUrl;
- $('#smartMenu_').remove();
- rightMenu((i + 1));
- }
- ulInfos.append(liObj);
- }
- }
- divInfos.appendTo(fieldsetImgObj);
- ulInfos.appendTo(divInfos);
- alObj.appendTo(divInfos);
- arObj.appendTo(divInfos);
- InitImage();
- uploadImage();
- }
- function LoadDeviceDetailInfo(devId) {
- ClearDeviceDetailInfo();
- LoadManageAndDevCombobox();
- var deviceNode = deviceNodes[devId];
- var deviceObj = deviceNode.attributes.device;
- operateDevObj = $.extend(true, {}, deviceObj);
- //基本信息
- $("#txt_DevName").val(deviceNode.text);
- $("#cbb_DevManager").combotree('setValue', "mn_" + deviceObj.管理ID);
- $("#cbb_DevType").combobox('select', deviceObj.模板信息ID);
- //图片信息
- $.ajax({
- url: "../WebServices/DeviceNodeService.asmx/GetDevImage",
- type: "GET",
- data: { "devId": devId },
- dataType: "text",
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- if (data.Result == true) {
- var imgData = data.ImageData;
- currentOperateDevId = devId;
- imgNameArray = [];
- for (var i = 0; i < imgData.length; i++) {
- imgNameArray.push({ '显示序号': i + 1, '图片索引': imgData[i].图片索引, '图片路径': imgData[i].图片路径, '备注': imgData[i].备注 });
- }
- imgNameArray.push({ '显示序号': 0, '图片索引': "0", '图片路径': "../Images/addImage.png", '备注': "" });
- LoadImageControl();
- }
- else {
- $.messager.alert("提示信息", data.Message);
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- $.messager.alert("提示信息", errorThrown + "\r\n" + XMLHttpRequest.responseText);
- }
- });
- //辅助信息
- var lng = (typeof (deviceObj.辅助信息.经度) == "undefined" ? "" : deviceObj.辅助信息.经度);
- var lat = (typeof (deviceObj.辅助信息.纬度) == "undefined" ? "" : deviceObj.辅助信息.纬度);
- if (lng != "" && lat != "") {
- $("#txt_DevPosition").val(lng + "|" + lat);
- }
- else {
- $("#txt_DevPosition").val("");
- }
- $("#txt_InstallTime").val(typeof (deviceObj.辅助信息.安装时间) == "undefined" ? "" : deviceObj.辅助信息.安装时间);
- $("#txt_InstallSite").val(typeof (deviceObj.辅助信息.安装位置) == "undefined" ? "" : deviceObj.辅助信息.安装位置);
- var simnum = typeof (deviceObj.辅助信息.手机卡号) == "undefined" ? "" : deviceObj.辅助信息.手机卡号;
- $("#text_SimNum").textbox("setValue", simnum);
- //通讯设备
- var index = 0;
- for (var i = 0; i < deviceObj.通讯设备.length; i++) {
- index = i + 1;
- $("#cbb_CommDeviceType" + index).combobox('setValue', deviceObj.通讯设备[i].模板信息ID);
- $("#txt_CommDeviceAddr" + index).val(deviceObj.通讯设备[i].设备地址);
- $("#cbb_IsAsk" + index).combobox('setValue', deviceObj.通讯设备[i].是否轮询);
- $("#txt_Interval" + index).val(deviceObj.通讯设备[i].轮询间隔);
- }
- //传输设备
- for (var i = 0; i < deviceObj.传输设备.length; i++) {
- index = i + 1;
- $("#cbb_Network" + index).combobox('select', deviceObj.传输设备[i].组网方式);
- var netType = $("#cbb_Network" + index).combobox("getText");
- if (netType.indexOf("设备主机") >= 0) {
- $("#cbb_TransArgeement" + index).combobox({ disabled: true });
- $("#cbb_TransArgeement" + index).combobox('setValue', deviceObj.传输设备[i].模板信息ID);
- $("#trDataChannel" + index).hide();
- $("#cbb_DataChannel" + index).combobox('setValue', deviceObj.传输设备[i].数据通道ID);
- $("#trTransIdentify" + index).hide();
- $("#txt_TransIdentify" + index).val(deviceObj.传输设备[i].传输标识);
- $("#trIpAndPort" + index).show();
- $("#txt_Ip" + index).val(deviceObj.传输设备[i].传输标识.split(":")[0]);
- $("#txt_Port" + index).val(deviceObj.传输设备[i].传输标识.split(":")[1]);
- }
- else if (netType.indexOf("串口直连") >= 0) {
- $("#cbb_TransArgeement" + index).combobox({ disabled: true });
- $("#cbb_TransArgeement" + index).combobox('setValue', deviceObj.传输设备[i].模板信息ID);
- $("#trDataChannel" + index).show();
- $("#cbb_DataChannel" + index).combobox('setValue', deviceObj.传输设备[i].数据通道ID);
- $("#trTransIdentify" + index).hide();
- $("#txt_TransIdentify" + index).val(deviceObj.传输设备[i].传输标识);
- $("#trIpAndPort" + index).hide();
- $("#txt_Ip" + index).val("");
- $("#txt_Port" + index).val("");
- }
- else {
- $("#cbb_TransArgeement" + index).combobox('setValue', deviceObj.传输设备[i].模板信息ID);
- $("#trDataChannel" + index).show();
- $("#cbb_DataChannel" + index).combobox('setValue', deviceObj.传输设备[i].数据通道ID);
- $("#trTransIdentify" + index).show();
- $("#txt_TransIdentify" + index).val(deviceObj.传输设备[i].传输标识);
- }
- }
- }
- function ClearDeviceDetailInfo() {
- //基本信息
- $("#txt_DevName").val("");
- //清空轮播控件中的图片
- imgNameArray = [];
- imgNameArray.push({ '显示序号': 0, '图片索引': "0", '图片路径': "../Images/addImage.png", '备注': "" });
- LoadImageControl();
- //辅助信息
- $("#txt_DevPosition").val("");
- $("#txt_InstallTime").val(new Date().Format('yyyy-MM-dd HH:mm'));
- $("#txt_InstallSite").val("");
- $("#text_SimNum").textbox("setValue", "");
- cbb_DevType_Select();
- var tabsConut = $('#divDeviceTabs').tabs('tabs').length;
- for (var i = 2; i < tabsConut; i++) {
- var subIndex = parseInt(i / 2);
- if ((i % 2) == 0) {
- //通讯设备
- var commDevType = commDeviceTypes[$("#cbb_CommDeviceType" + subIndex).combobox('getValue')];
- switch (commDevType.协议名称) {
- case "CD_PSCtrlPlus":
- case "CD_PSController":
- $("#txt_CommDeviceAddr" + subIndex).val("101");
- //清空轮询间隔文本框
- // $("#txt_Interval"+subIndex).val("");
- break;
- case "CD_CellMonitor":
- $("#txt_CommDeviceAddr" + subIndex).val("1");
- break;
- default:
- $("#txt_CommDeviceAddr" + subIndex).val("");
- }
- }
- else {
- //传输设备
- //组网方式
- // var data=$("#cbb_Network"+subIndex).combobox("getData");
- // var id=null;
- // for(var a in data)
- // {
- // if(data[a].text=="串口直连")
- // {
- // id=data[a].id;
- // break;
- // }
- // }
- $("#cbb_Network" + subIndex).combobox("select", "");
- //传输标识
- $("#trTransIdentify" + subIndex).show();
- $("#txt_TransIdentify" + subIndex).val("");
- //ip和端口
- $("#trIpAndPort" + subIndex).show();
- $("#txt_Ip" + subIndex).val("");
- $("#txt_Port" + subIndex).val("");
- //传输协议
- $("#cbb_TransArgeement" + subIndex).combobox("select", "");
- //数据通道
- $("#trDataChannel" + subIndex).css("display");
- $("#cbb_DataChannel" + subIndex).combobox("select", "");
- }
- }
- }
- function Btn_Query_Click() {
- var devIds = [];
- var devComboboxObj = $("#cbb_DevCombobox");
- var value = devComboboxObj.combobox("getValue");
- $.ShowMask("数据加载中,请稍等……");
- //值为空时采用模糊获取ID
- if (value == null || value == "") {
- var text = devComboboxObj.combobox("getText");
- //文本为空时按Combobox加载数据获取设备ID
- if ($.trim(text) != "") {
- var comboboxData = devComboboxObj.combobox("getData");
- var opts = devComboboxObj.combobox('options');
- for (var i = 0; i < comboboxData.length; i++) {
- if (comboboxData[i][opts.textField].indexOf(text) > -1) {
- devIds.push(comboboxData[i][opts.valueField]);
- }
- }
- if (devIds.length == 0) {
- $.messager.alert("提示信息", "查询结果为空");
- }
- $("#divAreaTree").find("div.tree-node-selected").removeClass("tree-node-selected");
- currentSelManageId = "";
- currentSelDeviceId = "";
- ReLoadTableData(devIds);
- }
- else {
- LoadTableData();
- return;
- }
- }
- else {
- var treeNode = $("#divAreaTree").tree("find", "dn_" + value);
- $("#divAreaTree").tree("select", treeNode.target);
- }
- }
- function btn_Add_Click() {
- operateType = "Add";
- operateDevObj = {};
- ClearDeviceDetailInfo();
- LoadManageAndDevCombobox();
- if (currentSelManageId != "") {
- $('#cbb_DevManager').combotree('setValue', "mn_" + currentSelManageId);
- }
- $('#dlgDevice').dialog({ title: "添加" + devLevelName + "信息", closed: false });
- $('#divDeviceTabs').tabs("select", 0);
- $("#btn_Next").linkbutton({ text: "下一步" });
- /*获取最新数据卡信息*/
- GetSIMCardNumber();
- }
- function btn_Back_Click() {
- var tabsObj = $('#divDeviceTabs');
- var tab = tabsObj.tabs('getSelected');
- var index = tabsObj.tabs('getTabIndex', tab);
- if (index != 0) {
- $("#btn_Next").linkbutton({ text: "下一步" });
- tabsObj.tabs("select", index - 1);
- if ((index - 1) == 0) {
- $("#btn_Back").linkbutton("disable");
- }
- }
- }
- function btn_Next_Click() {
- $("#btn_Back").linkbutton("enable");
- var tabsObj = $('#divDeviceTabs');
- var tabsConut = tabsObj.tabs('tabs').length;
- var tab = tabsObj.tabs('getSelected');
- var index = tabsObj.tabs('getTabIndex', tab);
- switch (index) {
- case 0:
- //基本信息校验
- var devNameTemp = $("#txt_DevName").val();
- if (devNameTemp.trim() == "") {
- $.messager.alert("提示信息", devLevelName + "名称不能为空");
- return;
- }
- var mnIdTemp = $("#cbb_DevManager").combotree('getValue');
- if (mnIdTemp == null || mnIdTemp == "") {
- $.messager.alert("提示信息", "请选择区域(单位)");
- return;
- }
- var mnTnTemp = $("#divAreaTree").tree("find", mnIdTemp);
- for (var i = 0; i < mnTnTemp.children.length; i++) {
- if (mnTnTemp.children[i].attributes.nodeType != "device") {
- continue;
- }
- if (operateType == "Add") {
- if ($("#txt_DevName").val() == mnTnTemp.children[i].text) {
- $.messager.alert("提示信息", devLevelName + "名称重复,请重新填写");
- $("#txt_DevName").focus();
- return;
- }
- }
- else {
- if (mnTnTemp.children[i].id != ("dn_" + operateDevObj.ID) && $("#txt_DevName").val() == mnTnTemp.children[i].text) {
- $.messager.alert("提示信息", devLevelName + "名称重复,请重新填写");
- $("#txt_DevName").focus();
- return;
- }
- }
- }
- operateDevObj["名称"] = devNameTemp;
- operateDevObj["管理ID"] = mnIdTemp.substring(3);
- operateDevObj["管理名称"] = mnTnTemp.text;
- var devTypeTemp = $("#cbb_DevType").combotree('getValue');
- if (devTypeTemp == null || devTypeTemp == "") {
- $.messager.alert("提示信息", "请选择" + devLevelName + "类型");
- return;
- }
- var devTypeObjTemp = userStationTypes[devTypeTemp];
- operateDevObj["用户站协议"] = devTypeObjTemp.协议名称;
- operateDevObj["用户站参数"] = devTypeObjTemp.用户站参数;
- operateDevObj["模板信息ID"] = devTypeObjTemp.ID;
- operateDevObj["模板信息名称"] = mnTnTemp.模板名称;
- if (typeof (operateDevObj.辅助信息) == 'undefined') {
- operateDevObj.辅助信息 = {};
- }
- var devPositionTemp = $("#txt_DevPosition").val().trim();
- if (devPositionTemp == "") {
- operateDevObj.辅助信息["经度"] = "";
- operateDevObj.辅助信息["纬度"] = "";
- }
- else {
- var devPositionsTemp = devPositionTemp.split("|");
- if (devPositionsTemp.length < 2 || devPositionsTemp[0].trim() == "" || devPositionsTemp[1].trim() == "") {
- $.messager.alert("提示信息", "地图坐标格式不正确,正确格式为x|y");
- return;
- }
- operateDevObj.辅助信息["经度"] = devPositionsTemp[0];
- operateDevObj.辅助信息["纬度"] = devPositionsTemp[1];
- }
- if (operateType != "Add") {
- var devAuxInfos = devTypeObjTemp.辅助信息;
- for (var i = 0; i < devAuxInfos.length; i++) {
- if (devAuxInfos[i].量名 == "安装时间" || devAuxInfos[i].量名 == "安装位置" || devAuxInfos[i].量名 == "手机卡号" || devAuxInfos[i].量名 == "经度" || devAuxInfos[i].量名 == "纬度") {
- continue;
- }
- var auxValue = typeof (operateDevObj.辅助信息[devAuxInfos[i].量名]) == "undefined" ? "" : operateDevObj.辅助信息[devAuxInfos[i].量名];
- switch (devAuxInfos[i].控件类型.substring(0, 1)) {
- case "T":
- case "D":
- $("#txt_AuxInfo" + i).val(auxValue);
- break;
- case "C":
- $("#cbb_AuxInfo" + i).combobox("select", auxValue);
- break;
- default:
- break;
- }
- }
- }
- break;
- case 1:
- //辅助信息校验
- operateDevObj.辅助信息["安装时间"] = $("#txt_InstallTime").val();
- operateDevObj.辅助信息["安装位置"] = $("#txt_InstallSite").val();
- operateDevObj.辅助信息["手机卡号"] = $("#text_SimNum").textbox("getText");
- var devAuxInfos = userStationTypes[operateDevObj.模板信息ID].辅助信息;
- for (var i = 0; i < devAuxInfos.length; i++) {
- if (devAuxInfos[i].量名 == "安装时间" || devAuxInfos[i].量名 == "安装位置" || devAuxInfos[i].量名 == "手机卡号" || devAuxInfos[i].量名 == "经度" || devAuxInfos[i].量名 == "纬度") {
- continue;
- }
- switch (devAuxInfos[i].控件类型.substring(0, 1)) {
- case "T":
- case "D":
- if (devAuxInfos[i].必填项 == "是" && $("#txt_AuxInfo" + i).val().trim() == "") {
- $.messager.alert("提示信息", devAuxInfos[i].量名 + "不能为空");
- $("#txt_AuxInfo" + i).focus();
- return;
- }
- operateDevObj.辅助信息[devAuxInfos[i].量名] = $("#txt_AuxInfo" + i).val();
- break;
- case "C":
- operateDevObj.辅助信息[devAuxInfos[i].量名] = $("#cbb_AuxInfo" + i).combobox("getValue");
- break;
- default:
- break;
- }
- }
- break;
- default:
- var subDevIndex = parseInt(index / 2);
- if (index % 2 == 0) {
- var commDevTypeId = $("#cbb_CommDeviceType" + subDevIndex).combobox('getValue');
- if (typeof (commDevTypeId) == "undefined" || commDevTypeId == "") {
- $.messager.alert("提示信息", "请选择设备协议");
- return;
- }
- //通讯设备校验
- var commDevAddrTemp = $("#txt_CommDeviceAddr" + subDevIndex).val();
- if (commDevAddrTemp.trim() == "") {
- $.messager.alert("提示信息", "设备地址不能为空");
- return;
- }
- var isAskTemp = $("#cbb_IsAsk" + subDevIndex).combobox('getValue');
- var pollingIntervalTemp = $("#txt_Interval" + subDevIndex).val();
- if (isAskTemp == "是") {
- if (pollingIntervalTemp.trim() == "") {
- $.messager.alert("提示信息", "轮询间隔不能为空");
- return;
- }
- if (isNaN(pollingIntervalTemp)) {
- $.messager.alert("提示信息", "轮询间隔格式不正确,请输入数字");
- return;
- }
- }
- if (typeof (operateDevObj.通讯设备) == 'undefined') {
- operateDevObj.通讯设备 = [];
- }
- if (operateDevObj.通讯设备.length < subDevIndex) {
- operateDevObj.通讯设备.push({});
- }
- var cdName = $("#cbb_CommDeviceType" + subDevIndex).combobox('getText');
- var subDevNames = userStationTypes[operateDevObj.模板信息ID].子设备.split(",");
- if (subDevNames.length >= subDevIndex) {
- cdName = subDevNames[subDevIndex - 1];
- }
- operateDevObj.通讯设备[subDevIndex - 1].设备名称 = operateDevObj.名称 + "_" + cdName;
- var commDevTypeTemp = commDeviceTypes[commDevTypeId];
- operateDevObj.通讯设备[subDevIndex - 1].设备协议 = commDevTypeTemp.协议名称;
- operateDevObj.通讯设备[subDevIndex - 1].协议参数 = commDevTypeTemp.用户站参数;
- operateDevObj.通讯设备[subDevIndex - 1].设备地址 = commDevAddrTemp;
- operateDevObj.通讯设备[subDevIndex - 1].是否轮询 = isAskTemp;
- operateDevObj.通讯设备[subDevIndex - 1].轮询间隔 = pollingIntervalTemp;
- operateDevObj.通讯设备[subDevIndex - 1].模板信息ID = commDevTypeTemp.ID;
- operateDevObj.通讯设备[subDevIndex - 1].模板信息名称 = commDevTypeTemp.模板名称;
- }
- else {
- //传输设备校验
- if (typeof (operateDevObj.传输设备) == 'undefined') {
- operateDevObj.传输设备 = [];
- }
- if (operateDevObj.传输设备.length < subDevIndex) {
- operateDevObj.传输设备.push({});
- }
- var networkingMode = $("#cbb_Network" + subDevIndex).combobox('getValue');
- var transDevTypeTemp = transDeviceTypes[$("#cbb_TransArgeement" + subDevIndex).combobox('getValue')];
- operateDevObj.传输设备[subDevIndex - 1].模板信息ID = transDevTypeTemp.ID;
- operateDevObj.传输设备[subDevIndex - 1].模板信息名称 = transDevTypeTemp.模板名称;
- operateDevObj.传输设备[subDevIndex - 1].传输协议 = transDevTypeTemp.协议名称;
- operateDevObj.传输设备[subDevIndex - 1].组网方式 = networkingMode;
- var dcIdTemp = $("#cbb_DataChannel" + subDevIndex).combobox('getValue');
- if ($("#cbb_DataChannel" + (subDevIndex + 1)).length > 0) {
- var channeldata = $("#cbb_DataChannel" + subDevIndex).combobox('getData');
- var channelval = $("#cbb_DataChannel" + (subDevIndex + 1)).combobox("getValue");
- for (var a in channeldata) {
- if (channeldata[a].id == channelval) {
- $("#cbb_DataChannel" + (subDevIndex + 1)).combobox({ data: channeldata });
- $("#cbb_DataChannel" + (subDevIndex + 1)).combobox("setValue", channelval);
- }
- }
- }
- var channelShowText = $("#cbb_DataChannel" + subDevIndex).combobox('getText');
- switch (networkingMode) {
- //串口直连
- case "1":
- if (typeof (dcIdTemp) == "undefined" || dcIdTemp == "" || dcIdTemp == "0") {
- $.messager.alert("提示信息", "请选择或新建通道服务");
- return;
- }
- operateDevObj.传输设备[subDevIndex - 1].数据通道ID = dcIdTemp;
- if (channelShowText.indexOf(":") > 0) {
- operateDevObj.传输设备[subDevIndex - 1].传输标识 = $("#cbb_DataChannel" + subDevIndex).combobox('getText').split(":")[1];
- }
- else {
- operateDevObj.传输设备[subDevIndex - 1].传输标识 = channelShowText;
- }
- break;
- //tcp-设备主机
- case "6":
- //udp-设备主机
- case "7":
- operateDevObj.传输设备[subDevIndex - 1].数据通道ID = (dcIdTemp == "") ? "0" : dcIdTemp;
- //ip地址和端口
- if ($("#txt_Ip" + subDevIndex).val() == "" || $("#txt_Port" + subDevIndex).val() == "") {
- $.messager.alert("提示信息", "请将ip和端口号填写完整");
- return;
- }
- var re = /^\d+\.\d+\.\d+\.\d+$/;
- var ip = $("#txt_Ip" + subDevIndex).val();
- if (!re.test(ip) || parseInt(ip.split(".")[0]) > 255 || parseInt(ip.split(".")[1]) > 255 || parseInt(ip.split(".")[2]) > 255 || parseInt(ip.split(".")[3]) > 255) {
- $.messager.alert("提示信息", "ip地址错误,请修改");
- return;
- }
- // if($("#txt_Ip"+subDevIndex).val().split(".")[3]==undefined||$("#txt_Ip"+subDevIndex).val().split(".")[3]=="")
- // {
- // $.messager.alert("提示信息", "ip地址错误,请修改");
- // return;
- // }
- operateDevObj.传输设备[subDevIndex - 1].传输标识 = $("#txt_Ip" + subDevIndex).val() + ":" + $("#txt_Port" + subDevIndex).val();
- break;
- default:
- if (typeof (dcIdTemp) == "undefined" || dcIdTemp == "" || dcIdTemp == "0") {
- $.messager.alert("提示信息", "请选择或新建通道服务");
- return;
- }
- operateDevObj.传输设备[subDevIndex - 1].数据通道ID = dcIdTemp;
- var transIdentifyTemp = $("#txt_TransIdentify" + subDevIndex).val();
- if (transIdentifyTemp.trim() == "") {
- $.messager.alert("提示信息", "传输标识不能为空");
- $("#txt_TransIdentify").focus();
- return;
- }
- operateDevObj.传输设备[subDevIndex - 1].传输标识 = transIdentifyTemp;
- break;
- }
- }
- break;
- }
- if (index == (tabsConut - 1)) {
- $.ShowMask("数据加载中,请稍等……");
- var subDevCount = userStationTypes[operateDevObj.模板信息ID].子设备.split(",").length;
- while (operateDevObj.通讯设备.length > subDevCount) {
- operateDevObj.通讯设备.pop();
- }
- while (operateDevObj.传输设备.length > subDevCount) {
- operateDevObj.传输设备.pop();
- }
- operateDevObj["管理数据卡"] = simManageFlag;
- //获取图片名称和备注
- var imgInfoArray = [];
- for (var i = 0; i < imgNameArray.length; i++) {
- var index = imgNameArray[i].图片索引
- var imgUrl = imgNameArray[i].图片路径;
- var remark = imgNameArray[i].备注;
- if (index == "0") {
- continue;
- }
- imgInfoArray.push({ '图片索引': index, '图片名称': imgUrl, '备注': remark });
- }
- operateDevObj["图片信息"] = imgInfoArray;
- var deviceJSONString = JSON2.stringify(operateDevObj);
- if (operateType == "Add") {
- $.ajax(
- {
- url: "../WebServices/DeviceNodeService.asmx/AddDeviceNodeImage",
- type: "POST",
- data: { "loginIdentifer": window.parent.guid, 'deviceJSONString': deviceJSONString },
- dataType: "text",
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- if (data.Result) {
- LoadTree("divAreaTree", mnId, true, false);
- LoadTableData(true, operateDevObj["管理ID"]);
- LoadComboboxData();
- $.messager.alert("提示信息", "添加" + devLevelName + "成功");
- $('#dlgDevice').dialog("close");
- GetDataChannels();
- }
- else {
- $.messager.alert("提示信息", "添加" + devLevelName + "失败");
- }
- $.HideMask();
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
- $.HideMask();
- }
- });
- }
- else {
- $.ajax(
- {
- url: "../WebServices/DeviceNodeService.asmx/ModifyDeviceNode",
- type: "POST",
- data: { "loginIdentifer": window.parent.guid, 'deviceJSONString': deviceJSONString },
- dataType: "text",
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- if (data.Result) {
- LoadTree("divAreaTree", mnId, true, false);
- LoadTableData(true, operateDevObj["管理ID"]);
- LoadComboboxData();
- $.messager.alert("提示信息", "修改" + devLevelName + "成功");
- $('#dlgDevice').dialog("close");
- GetDataChannels();
- }
- else {
- $.messager.alert("提示信息", "修改" + devLevelName + "失败");
- }
- $.HideMask();
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
- $.HideMask();
- }
- });
- }
- }
- else {
- if ((index + 1) == (tabsConut - 1)) {
- $("#btn_Next").linkbutton({ text: "确定" });
- }
- else {
- $("#btn_Next").linkbutton({ text: "下一步" });
- }
- tabsObj.tabs("select", index + 1);
- }
- }
- //导出Excel
- function btn_Export_Click() {
- if (excelUrl == null || excelUrl == "") {
- $.messager.alert("提示信息", "请先进行查询");
- return;
- }
- location.href = excelUrl;
- }
- function cb_DevRefer_Click() {
- if ($("#cb_DevRefer")[0].checked) {
- $("#cbb_DevRefer").combotree({ 'disabled': false });
- }
- else {
- $("#cbb_DevRefer").combotree({ 'disabled': true });
- }
- }
- function OpenPickCoordinate() {
- //显示弹出窗口
- divFlyBar.style.display = "block";
- document.getElementById("pickCoordinate").src = "PickLongitudeAndLattude.html?id=txt_DevPosition";
- $("#divFlyBar").css("zIndex", 99999);
- }
- function Close() {
- divFlyBar.style.display = "none";
- }
- function TranslateCoordinate() {
- var value = $("#txt_DevPosition").val();
- if (value == "") {
- return;
- }
- var values = value.split('|');
- if (values.length != 2) {
- return;
- }
- if (values[0] == "" || values[1] == "") {
- return;
- }
- var gpsPoint = new BMap.Point(values[0], values[1]);
- var gpsPoints = [];
- gpsPoints.push(gpsPoint);
- var convertor = new BMap.Convertor();
- convertor.translate(gpsPoints, 1, 5, TranslateCoordinateCallback)
- }
- TranslateCoordinateCallback = function (data) {
- if (data.status === 0) {
- var dbPoint = data.points[0];
- $("#txt_DevPosition").val(dbPoint.lng + "|" + dbPoint.lat);
- }
- }
- function SIM_Add_Click() {
- $('#dlgSIM').dialog({ title: '添加数据卡', closed: false, iconCls: 'icon-mobile' });
- $("#txt_ChargeTime").val(new Date().Format("yyyy-MM-dd HH:mm"));
- // $("#txt_SimNum").textbox({ value:"",disabled: false });
- $("#txt_ChargeAmount").textbox({ value: "" });
- $("#txt_ChargePerson").textbox({ value: "" });
- //operateType = "Add";
- }
- //================有关设备图片功能================//
- function previewImage(file, imgNum) {
- if (file.files && file.files[0]) {
- var reader = new FileReader();
- reader.readAsDataURL(file.files[0]);
- }
- }
- var data06;
- function InitImage() {
- var unslider06 = $('#b06').unslider({
- dots: true,
- fluid: false
- });
- data06 = unslider06.data('unslider');
- $('.unslider-arrow06').click(function () {
- var fn = this.className.split(' ')[1];
- data06[fn]();
- });
- }
- function StartSlider() {
- if (data06) {
- data06.el.hover(data06.stop, data06.start);
- data06.start();
- $.smartMenu.setslider(data06);
- }
- }
- function StopSlider() {
- if (data06) {
- data06.el.unbind("mouseenter").unbind("mouseleave");
- data06.stop();
- $.smartMenu.setslider(null);
- }
- }
- function uploadImage() {
- $("#fileupload1").fileupload({
- url: "../WebServices/DeviceNodeService.asmx/DevImageStor",
- dataType: "text",
- sequentialUploads: true,
- add: function (e, data) {
- // $('#uploadProgress').progressbar('setValue', 0);
- data.submit();
- },
- done: function (e, data) {
- var iVal = this.id.replace("fileupload", "");
- var result = eval("(" + $.xml2json(data.result) + ")");
- if (result.Result) {
- imgNameArray.splice(imgNameArray.length - 1, 0, { '显示序号': imgNameArray.length, '图片索引': result.ImageName.图片索引, '图片路径': "../DevImg/" + result.ImageName.图片名称, '备注': "" });
- LoadImageControl();
- }
- else {
- $.messager.alert("提示信息", "上传失败,原因:" + result.Message);
- }
- },
- progressall: function (e, data) {
- // var progress = parseInt(data.loaded / data.total * 100, 10);
- // $('#uploadProgress').progressbar('setValue', progress);
- }
- });
- // }
- }
- //鼠标右键菜单
- function rightMenu(indexCol) {
- $('#devBody').bind("mousedown", (function (e) {
- if (e.which == 3) {
- $('#smartMenu_').css("display", "none");
- }
- }));
- $("body").on("mousedown", '#img_' + indexCol, MenuMethod);
- }
- function MenuMethod(e, event) {
- if (e.which == 3) {
- var opertion = {
- name: "",
- offsetX: 2,
- offsetY: 2,
- textLimit: 10,
- beforeShow: $.noop,
- afterShow: $.noop
- }
- var imageMenuData = [
- [{
- text: "删除",
- func: function () {
- //停止图片轮播
- StopSlider();
- //获取点击的控件的索引
- var indexC = this.id.replace("img_", "");
- var index = $("#" + this.id).attr("guid");
- var src = $("#" + this.id).attr("src");
- $.messager.confirm('提示信息', '您确定要删除该图片吗?', function (r) {
- if (r) {
- if (currentOperateDevId == null || currentOperateDevId == "") {
- imgNameArray.splice(indexC - 1, 1);
- LoadImageControl();
- }
- else {
- $.ajax(
- {
- url: "../WebServices/DeviceNodeService.asmx/DeleteDeviceImage",
- type: "POST",
- data: { "loginIdentifer": window.parent.guid, 'devID': currentOperateDevId, 'index': index, 'imgUrl': src },
- dataType: "text",
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- if (data.Result) {
- imgNameArray.splice(indexC - 1, 1);
- LoadImageControl();
- $.messager.alert("提示信息", "图片删除成功");
- }
- else {
- StartSlider();
- $.messager.alert("提示信息", "删除失败");
- }
- $.HideMask();
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
- StartSlider();
- $.HideMask();
- }
- });
- }
- }
- else {
- StartSlider();
- }
- });
- }
- },
- {
- text: "查看原图",
- func: function () {
- StopSlider();
- //获取点击的控件的索引
- var indexC = this.id.replace("img_", "");
- CheckOrgImage(indexC);
- }
- },
- {
- text: remarkText,
- func: function () {
- //获取点击的控件的索引
- var indexC = this.id.replace("img_", "");
- for (var c = 0; c < imgNameArray.length; c++) {
- var imgInfo = imgNameArray[c];
- if (imgInfo.显示序号 == indexC) {
- $("#reMarkImg").textbox("setValue", imgInfo.备注);
- break;
- }
- }
- StopSlider();
- $('#reMarkHidden').val(indexC);
- $('#remarkDiv').dialog({ closed: false });
- }
- }]
- // ,
- // [{
- // text:"11",
- // func:function(){
- // alert("11");
- // }
- // }]
- ];
- //停止图片轮播
- StopSlider();
- $(this).smartMenu(imageMenuData, opertion);
- $.smartMenu.setslider(data06);
- //去掉默认的contextmenu事件,否则会和右键事件同时出现。
- e.preventDefault();
- }
- }
- //点击右键菜单的查看原图
- function CheckOrgImage(indexC) {
- var img = new Image();
- img.src = $('#img_' + indexC).attr("src");
- w = img.width;
- h = img.height;
- var BigW = 1340;
- var BigH = 470;
- var popupDivW = 0;
- var popupDivH = 0;
- if (w < BigW) {
- popupDivW = w + 15;
- }
- else {
- popupDivW == BigW;
- }
- if (h < BigH) {
- popupDivH = h + 40;
- }
- else {
- popupDivH = BigH;
- }
- $("<div id='popupDiv'><img id='imgPhoto' width='" + w + "' height='" + h + "' alt='' src='" + img.src + "' /></div>").dialog({
- title: "查看原图",
- width: popupDivW,
- height: popupDivH,
- closed: false,
- cache: false,
- modal: true,
- onClose: function () {
- $(this).dialog('destroy');
- }
- });
- }
- //点击查看原图层的关闭事件
- function HidePopupDiv() {
- document.getElementById("popupDiv").style.display = "none";
- document.getElementById("divPhoto").innerHTML = "";
- StartSlider();
- }
- //点击右键菜单的添加备注
- function btnRemark_Ok_Click() {
- var ind = $('#reMarkHidden').val().trim();
- var remarkStr = $('#reMarkImg').val().trim();
- //循环imgNameArray,得到显示序号为ind的,并对比备注信息是否一样
- for (var i = 0; i < imgNameArray.length; i++) {
- var sort = imgNameArray[i].显示序号;
- if (sort == ind) {
- var remarkOld = imgNameArray[i].备注;
- if (remarkStr != remarkOld) {
- imgNameArray[i].备注 = remarkStr;
- }
- break;
- }
- }
- StartSlider();
- $('#remarkDiv').dialog('close');
- }
- //点击添加备注层的关闭事件
- function HideRemarkDiv() {
- StartSlider();
- $('#remarkDiv').dialog({ closed: true });
- $('#reMarkHidden').val("");
- $("#reMarkImg").textbox("setValue", "");
- }
- //================有关设备图片功能================//
- function Close() {
- divFlyBar.style.display = "none";
- }
- function Btn_OK_Click() {
- var simNum = $("#txt_SimNum").textbox("getText");
- if (!(/^\d{11,20}$/.test(simNum))) {
- $.messager.alert("提示信息", "手机卡号格式不正确");
- return;
- }
- var rechargeAmount = $("#txt_ChargeAmount").textbox("getText");
- if (!(/^\d{1,}$/.test(rechargeAmount))) {
- $.messager.alert("提示信息", "充值金额格式不正确");
- return;
- }
- var simCardInfo = {};
- simCardInfo["手机卡号"] = simNum;
- simCardInfo["资费标准"] = $("#txt_Charge").combobox("getValue");
- simCardInfo["充值时间"] = $("#txt_ChargeTime").val();
- simCardInfo["充值金额"] = rechargeAmount;
- simCardInfo["充值人"] = $("#txt_ChargePerson").textbox("getText");
- $.ShowMask("正在添加,请稍等……");
- $.ajax({
- url: "../WebServices/SIMMaintainService.asmx/AddSIMCardInfo",
- type: "POST",
- data: {
- "loginIdentifer": window.parent.guid,
- "simCardInfo": JSON2.stringify(simCardInfo)
- },
- dataType: "text",
- cache: false,
- success: function (responseText) {
- var data = eval("(" + $.xml2json(responseText) + ")");
- if (data.Result) {
- $.HideMask();
- /*更新数据卡下拉框中数据*/
- currentsimnum = simNum;
- loadSimNumFlag = true;
- GetSIMCardNumber();
- //管理数据卡,则置管理标志为true
- simManageFlag = true;
- }
- else {
- simManageFlag = false;
- $.HideMask();
- $.messager.alert("提示信息", data.Message);
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- $.HideMask();
- $.messager.alert("提示信息", errorThrown + "\r\n" + XMLHttpRequest.responseText);
- }
- });
- }
|