jiangsu.js 102 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431
  1. // JScript 文件
  2. var dicDeviceAppGroups = {};
  3. //表格数据
  4. var tableData = [];
  5. var comboBoxData = [];
  6. //组网方式
  7. var networkComboBoxData = [];
  8. //数据通道
  9. var dataChannels = [];
  10. //用户站模板
  11. var userStationTypes = {};
  12. //通讯设备模板
  13. var commDeviceTypes = {};
  14. //传输设备模板
  15. var transDeviceTypes = {};
  16. var mnId = "";
  17. var operateType = "Add";
  18. var operateDevObj = {};
  19. var devLevelName = "设备";
  20. var mnLevelName = "单位";
  21. //左侧树形选中节点的管理ID
  22. var currentSelManageId;
  23. var currentSelDeviceId;
  24. var operateDataChannel = "Add";
  25. var operateDCIndex = "";
  26. //无协议项对应的value值
  27. var val = "";
  28. //是否加载新建的手机号
  29. var loadSimNumFlag = false;
  30. //手机卡号与id对应关系
  31. var simcardjsa = [];
  32. //当前手机号
  33. var currentsimnum = "";
  34. //设备手机卡号是否加入管理--2016-09-08
  35. var simManageFlag = false;
  36. //初始化串口数量
  37. var serialPortCount = 256;
  38. var remarkText = "备注信息";
  39. //用于存储查询出来的图片信息
  40. var imgNameArray = [];
  41. //用于存储设备列表当前编辑的设备Id
  42. var currentOperateDevId;
  43. //用于存储当前操作的图片的guid
  44. var currentOperateIndex;
  45. var fieldwidth = {};
  46. var fieldnamerel = {};
  47. var excelUrl = "";
  48. $(document).ready(function () {
  49. var defaultTheme = $.cookie("psbsTheme");
  50. if (defaultTheme != null && defaultTheme != "default") {
  51. var link = $(document).find('link:first');
  52. link.attr('href', '../App_Themes/easyui/themes/' + defaultTheme + '/easyui.css');
  53. }
  54. $.ShowMask("数据加载中,请稍等……");
  55. //初始化串口选择下拉框
  56. InitSerialPortDDL();
  57. //获取组网方式
  58. GetNetworks();
  59. //获取数据通道
  60. GetDataChannels();
  61. //获取模板信息
  62. GetTemplateInfos();
  63. //获取数据卡信息
  64. GetSIMCardNumber();
  65. GetSystemInfo();
  66. //获取资费标准信息
  67. GetChargeInfos();
  68. $("#simManageBtn").linkbutton({ "disabled": true });
  69. $("#text_SimNum").textbox({
  70. inputEvents: $.extend({}, $.fn.textbox.defaults.inputEvents, {
  71. keyup: function (e) {
  72. var newSim = $("#text_SimNum").textbox('getText');
  73. if (newSim != "") {
  74. var containflag = false;
  75. for (var i in simcardjsa) {
  76. if (simcardjsa[i]["text"] == newSim) {
  77. containflag = true;
  78. }
  79. }
  80. if (!containflag) {
  81. $("#simManageBtn").linkbutton({ "disabled": false });
  82. $("#txt_SimNum").textbox('setValue', newSim);
  83. $("#txt_SimNum").textbox({ "disabled": true });
  84. }
  85. else {
  86. $("#simManageBtn").linkbutton({ "disabled": true });
  87. }
  88. }
  89. else {
  90. $("#simManageBtn").linkbutton({ "disabled": true });
  91. }
  92. }
  93. })
  94. });
  95. });
  96. //从服务器取得系统运行状态信息
  97. function GetSystemInfo() {
  98. $.ajax(
  99. {
  100. url: "../WebServices/SystemService.asmx/GetSystemStateInfo",
  101. type: "POST",
  102. data: { "loginIdentifer": window.parent.guid },
  103. dataType: "text",
  104. cache: false,
  105. success: function (responseText) {
  106. var data = eval("(" + $.xml2json(responseText) + ")");
  107. if (data.Result)//登录成功
  108. {
  109. mnId = data.SysStateInfo.当前登录操作员管理ID;
  110. mnLevelName = data.SysStateInfo.监测点管理名称;
  111. devLevelName = data.SysStateInfo.监测点级别名称;
  112. $("#divContainer").layout('panel', 'west').panel({ title: devLevelName + "管理" });
  113. $("#divContainer").layout('panel', 'center').panel({ title: devLevelName + "信息列表" });
  114. $("#devLevelNameForSearch").text(devLevelName);
  115. $("#devLevelNameForDetail").text(devLevelName);
  116. $("#txt_DevName").validatebox({ missingMessage: "请输入" + devLevelName + "名称" });
  117. $("#devNameColumnSpan").text(devLevelName);
  118. $("#devTypeColumnSpan").text(devLevelName);
  119. //20170218注释老程序
  120. // var columnOptions = $("#tbDevInfos").datagrid("options").columns[0];
  121. // for (var i = 0; i < columnOptions.length; i++) {
  122. // if (columnOptions[i].field == "devName") {
  123. // columnOptions[i].title = devLevelName + "名称";
  124. // }
  125. // else if (columnOptions[i].field == "devType") {
  126. // columnOptions[i].title = devLevelName + "类型";
  127. // }
  128. // }
  129. // $("#tbDevInfos").datagrid({ columns: [columnOptions] });
  130. manageNodeLoaded = false;
  131. deviceNodeLoaded = false;
  132. LoadTree("divAreaTree", mnId, true, false);
  133. LoadTableData();
  134. LoadComboboxData();
  135. TreeBindSelect();
  136. TableCellClick();
  137. }
  138. },
  139. error: function (XMLHttpRequest, textStatus, errorThrown) {
  140. alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
  141. }
  142. });
  143. }
  144. function GetTemplateInfos() {
  145. $.ajax(
  146. {
  147. url: "../WebServices/TemplateInfoService.asmx/GetTemplateInfos",
  148. type: "POST",
  149. data: { "loginIdentifer": window.parent.guid },
  150. dataType: "text",
  151. cache: false,
  152. success: function (responseText) {
  153. var data = eval("(" + $.xml2json(responseText) + ")");
  154. if (data.Result)//登录成功
  155. {
  156. var typeObjs = data.传输设备;
  157. var typeComboBoxData = [];
  158. var selectedValue = "";
  159. for (var i = 0; i < typeObjs.length; i++) {
  160. if (i == 0) {
  161. selectedValue = typeObjs[i].ID;
  162. }
  163. var typeObj = {};
  164. typeObj["id"] = typeObjs[i].ID;
  165. typeObj["text"] = typeObjs[i].模板名称;
  166. typeComboBoxData.push(typeObj);
  167. transDeviceTypes[typeObjs[i].ID] = typeObjs[i];
  168. }
  169. $("#cbb_TransArgeement1").combobox({
  170. data: typeComboBoxData,
  171. onSelect: cbb_TransArgeement_Select
  172. }).combobox("select", selectedValue);
  173. typeObjs = data.通讯设备;
  174. typeComboBoxData = [];
  175. selectedValue = "";
  176. for (var i = 0; i < typeObjs.length; i++) {
  177. if (i == 0) {
  178. selectedValue = typeObjs[i].ID;
  179. }
  180. var typeObj = {};
  181. typeObj["id"] = typeObjs[i].ID;
  182. typeObj["text"] = typeObjs[i].模板名称;
  183. typeComboBoxData.push(typeObj);
  184. commDeviceTypes[typeObjs[i].ID] = typeObjs[i];
  185. }
  186. $("#cbb_CommDeviceType1").combobox({
  187. data: typeComboBoxData,
  188. onSelect: cbb_CommDeviceType_Select
  189. }).combobox("select", selectedValue);
  190. typeObjs = data.用户站;
  191. typeComboBoxData = [];
  192. selectedValue = "";
  193. for (var i = 0; i < typeObjs.length; i++) {
  194. if (i == 0) {
  195. selectedValue = typeObjs[i].ID;
  196. }
  197. var typeObj = {};
  198. typeObj["id"] = typeObjs[i].ID;
  199. typeObj["text"] = typeObjs[i].模板名称;
  200. typeComboBoxData.push(typeObj);
  201. userStationTypes[typeObjs[i].ID] = typeObjs[i];
  202. }
  203. $("#cbb_DevType").combobox({
  204. data: typeComboBoxData,
  205. onSelect: cbb_DevType_Select
  206. }).combobox('select', selectedValue);
  207. }
  208. },
  209. error: function (XMLHttpRequest, textStatus, errorThrown) {
  210. alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
  211. }
  212. });
  213. }
  214. function GetNetworks() {
  215. $.ajax(
  216. {
  217. url: "../WebServices/DataChannelService.asmx/GetNetworks",
  218. type: "POST",
  219. data: { "loginIdentifer": window.parent.guid },
  220. dataType: "text",
  221. cache: false,
  222. success: function (responseText) {
  223. var data = eval("(" + $.xml2json(responseText) + ")");
  224. if (data.Result)//登录成功
  225. {
  226. var networks = data.Networks;
  227. networkComboBoxData = [];
  228. var selectedValue = "";
  229. for (i = 0; i < networks.length; i++) {
  230. var devObj = {};
  231. devObj["id"] = networks[i].ID;
  232. devObj["text"] = networks[i].Text;
  233. networkComboBoxData.push(devObj);
  234. if (data.Networks[i].Selected) {
  235. selectedValue = networks[i].ID;
  236. }
  237. }
  238. $("#cbb_Network1").combobox({
  239. data: networkComboBoxData,
  240. onSelect: cbb_Network_Select
  241. }).combobox("select", selectedValue);
  242. }
  243. },
  244. error: function (XMLHttpRequest, textStatus, errorThrown) {
  245. alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
  246. }
  247. });
  248. }
  249. function GetChargeInfos() {
  250. $.ajax({
  251. url: "../WebServices/SIMMaintainService.asmx/GetCharges",
  252. type: "POST",
  253. data: {
  254. "loginIdentifer": window.parent.guid
  255. },
  256. dataType: "text",
  257. cache: false,
  258. success: function (responseText) {
  259. var data = eval("(" + $.xml2json(responseText) + ")");
  260. var chargesDataB = [];
  261. if (data.Result) //登录成功
  262. {
  263. var charges = data.Charges;
  264. for (var i = 0; i < charges.length; i++) {
  265. if (i == 0) {
  266. chargesDataB.push({ value: charges[i].ID, text: charges[i].名称, selected: true });
  267. }
  268. else {
  269. chargesDataB.push({ value: charges[i].ID, text: charges[i].名称 });
  270. }
  271. }
  272. $("#txt_Charge").combobox("loadData", chargesDataB);
  273. }
  274. },
  275. error: function (XMLHttpRequest, textStatus, errorThrown) {
  276. $.messager.alert("提示信息", errorThrown + "\r\n" + XMLHttpRequest.responseText);
  277. }
  278. });
  279. }
  280. /*获取数据卡信息,并将手机卡号信息加载到添加或编辑设备的对话框中*/
  281. function GetSIMCardNumber() {
  282. $.ajax(
  283. {
  284. url: "../WebServices/SIMMaintainService.asmx/GetSIMCardInfos",
  285. type: "POST",
  286. data: { "loginIdentifer": window.parent.guid },
  287. dataType: "Text",
  288. cache: false,
  289. success: function (responseText) {
  290. var data = eval("(" + $.xml2json(responseText) + ")");
  291. if (data.Result) //登录成功
  292. {
  293. var simCards = data.SIMCards;
  294. var simnumData = [];
  295. for (var i = 0; i < simCards.length; i++) {
  296. var rowData = {};
  297. rowData["id"] = simCards[i].ID;
  298. rowData["text"] = simCards[i].手机卡号;
  299. var simcardJson = { 'id': simCards[i].ID, 'text': simCards[i].手机卡号 };
  300. simcardjsa.push(simcardJson);
  301. simnumData.push(rowData);
  302. }
  303. if (loadSimNumFlag == true) {
  304. $.messager.alert("提示信息", "添加成功");
  305. $('#dlgSIM').dialog({ closed: true });
  306. loadSimNumFlag = false;
  307. }
  308. }
  309. },
  310. error: function (XMLHttpRequest, textStatus, errorThrown) {
  311. $.messager.alert("提示信息", errorThrown + "\r\n" + XMLHttpRequest.responseText);
  312. }
  313. }
  314. );
  315. }
  316. function GetDataChannels() {
  317. $.ajax(
  318. {
  319. url: "../WebServices/DataChannelService.asmx/GetDataChannels",
  320. type: "POST",
  321. data: { "loginIdentifer": window.parent.guid },
  322. dataType: "text",
  323. cache: false,
  324. success: function (responseText) {
  325. var data = eval("(" + $.xml2json(responseText) + ")");
  326. if (data.Result) {
  327. dataChannels = data.DataChannels;
  328. //重新加载devtype
  329. if ($("#cbb_DevType").combobox("getValue") != null) {
  330. var val = $("#cbb_DevType").combobox("getValue");
  331. $("#cbb_DevType").combobox("unselect", val).combobox("select", val);
  332. }
  333. if ($("#cbb_Network1").combobox("getValue") != null) {
  334. var val = $("#cbb_Network1").combobox("getValue");
  335. $("#cbb_Network1").combobox("unselect", val).combobox("select", val);
  336. }
  337. }
  338. },
  339. error: function (XMLHttpRequest, textStatus, errorThrown) {
  340. alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
  341. }
  342. });
  343. }
  344. function InitSerialPortDDL() {
  345. var dllSerialPortObj = document.getElementById("ddl_SerialPort");
  346. for (var i = dllSerialPortObj.options.length; i > 0; i--) {
  347. dllSerialPortObj.removeChild(dllSerialPortObj.options[0]);
  348. }
  349. for (var i = 1; i <= serialPortCount; i++) {
  350. var op = document.createElement("OPTION");
  351. dllSerialPortObj.options.add(op);
  352. op.innerText = "COM" + i;
  353. op.value = "COM" + i;
  354. }
  355. }
  356. function TreeBindSelect() {
  357. $('#divAreaTree').tree({
  358. onSelect: function (node) {
  359. $.ShowMask("数据加载中,请稍等……");
  360. if (node.attributes["nodeType"] == "manage") {
  361. currentSelManageId = node.attributes["manage"].ID;
  362. var selectedLevelName = node.attributes["manage"]["级别别名"];
  363. if (selectedLevelName == "") {
  364. selectedLevelName = node.attributes["manage"]["级别名称"];
  365. }
  366. if (selectedLevelName == mnLevelName) {
  367. $("#btn_Add").linkbutton({
  368. disabled: false
  369. });
  370. }
  371. else {
  372. $("#btn_Add").linkbutton({
  373. disabled: true
  374. });
  375. }
  376. }
  377. else {
  378. currentSelManageId = "";
  379. currentSelDeviceId = node.attributes["device"].ID;
  380. $("#btn_Add").linkbutton({
  381. disabled: true
  382. });
  383. }
  384. var devIds = GetDeviceIDsByNode(node);
  385. ReLoadTableData(devIds);
  386. }
  387. });
  388. }
  389. function TableCellClick() {
  390. $('#tbDevInfos').datagrid({
  391. onClickCell: function (index, field, value) {
  392. if (field == "editDev") {
  393. operateType = "Modify";
  394. var selectedRow = $(this).datagrid("getRows")[index];
  395. var devId = selectedRow["devId"]
  396. $('#dlgDevice').dialog({ title: '编辑' + devLevelName + '信息', closed: false });
  397. $('#divDeviceTabs').tabs("select", 0);
  398. $("#btn_Next").linkbutton({ text: "下一步" });
  399. LoadDeviceDetailInfo(devId);
  400. //管理数据卡标志设为false
  401. simManageFlag = false;
  402. }
  403. else if (field == "removeDev") {
  404. var selectedRow = $(this).datagrid("getRows")[index];
  405. var devId = selectedRow["devId"];
  406. $.messager.confirm('提示信息', '您确定要删除该终端吗?', function (r) {
  407. if (r) {
  408. $.ShowMask("数据加载中,请稍等……");
  409. $.ajax({
  410. url: "../WebServices/DeviceNodeService.asmx/DeleteDeviceNode",
  411. type: "POST",
  412. data: { "loginIdentifer": window.parent.guid, "devID": devId },
  413. dataType: "text",
  414. cache: false,
  415. success: function (responseText) {
  416. var data = eval("(" + $.xml2json(responseText) + ")");
  417. if (data.Result)//登录成功
  418. {
  419. //更新左侧树和设备下拉框
  420. $.messager.alert('提示信息', '删除成功!');
  421. $("#tbDevInfos").datagrid("deleteRow", index);
  422. for (var i = 0; i < deviceJson.length; i++) {
  423. if (deviceJson[i].ID == devId) {
  424. deviceJson.splice(i, 1);
  425. break;
  426. }
  427. }
  428. LoadComboboxData();
  429. GetDataChannels();
  430. delete deviceNodes[devId];
  431. var treeNode = $("#divAreaTree").tree("find", "dn_" + devId);
  432. $("#divAreaTree").tree("remove", treeNode.target);
  433. }
  434. else {
  435. $.messager.alert('提示信息', data.Message, 'warning');
  436. }
  437. $.HideMask();
  438. },
  439. error: function (XMLHttpRequest, textStatus, errorThrown) {
  440. alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
  441. $.HideMask();
  442. }
  443. });
  444. }
  445. });
  446. }
  447. }
  448. });
  449. }
  450. var rtuHTML = "<fieldset style='height:183px'>" +
  451. "<legend>采集设备</legend>" +
  452. "<div style='width:100%;height:100%;text-align:center'>" +
  453. "<table id='tbCommDevice' style='margin:auto'>" +
  454. "<tr height='30px'>" +
  455. "<td align='right'><span>设备协议:</span></td>" +
  456. "<td><input id='cbb_CommDeviceType' class='easyui-combobox' data-options=\"valueField: 'id',textField: 'text',required:true,editable:false,panelHeight:'auto'\" style='width:150px' /></td>" +
  457. "<td><span>*</span></td>" +
  458. "</tr>" +
  459. "<tr height='30px'>" +
  460. "<td align='right'><span>设备地址:</span></td>" +
  461. "<td><input id='txt_CommDeviceAddr' class='easyui-validatebox textbox' data-options=\"required:true,validType:'length[1,25]'\" style='height:21px;width:150px'/></td>" +
  462. "<td><span>*</span></td>" +
  463. "</tr>" +
  464. "<tr height='30px'>" +
  465. "<td align='right'><span>是否轮询:</span></td>" +
  466. "<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>" +
  467. "<td><span>*</span></td>" +
  468. "</tr>" +
  469. "<tr height='30px'>" +
  470. "<td align='right'><span>轮询间隔:</span></td>" +
  471. "<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>" +
  472. "<td><span>*</span></td>" +
  473. "</tr>" +
  474. "</table>" +
  475. "</div>" +
  476. "</fieldset>";
  477. var dtuHTML = "<fieldset style='height:183px'>" +
  478. "<legend>传输设备</legend>" +
  479. "<div style='width:100%;height:100%;text-align:center'>" +
  480. "<table id='tbTransDevice' style='margin:auto'>" +
  481. "<tr height='30px'>" +
  482. "<td align='right'><span>组网方式:</span></td>" +
  483. "<td><input id='cbb_Network' class='easyui-combobox' data-options=\"valueField: 'id',textField: 'text',required:true,editable:false,panelHeight:'auto'\" style='width:150px' /></td>" +
  484. "<td><span>*</span></td>" +
  485. "</tr>" +
  486. "<tr height='30px'>" +
  487. "<td align='right'><span>传输协议:</span></td>" +
  488. "<td><input id='cbb_TransArgeement' class='easyui-combobox' data-options=\"valueField: 'id',textField: 'text',required:true,editable:false,panelHeight:'auto'\" style='width:150px' /></td>" +
  489. "<td><span>*</span></td>" +
  490. "</tr>" +
  491. "<tr id='trDataChannel' height='30px'>" +
  492. "<td align='right'><span>通道服务:</span></td>" +
  493. "<td><input id='cbb_DataChannel' class='easyui-combobox' data-options=\"valueField: 'id',textField: 'text',required:true,editable:false,panelHeight:'auto'\" style='width:150px' /></td>" +
  494. "<td><span>*</span></td>" +
  495. "</tr>" +
  496. "<tr id='trTransIdentify' height='30px'>" +
  497. "<td align='right'><span>传输标识:</span></td>" +
  498. "<td><input id='txt_TransIdentify' class='easyui-validatebox textbox' data-options=\"required:true,validType:'length[1,25]'\" style='height:21px;width:150px'/></td>" +
  499. "<td><span>*</span></td>" +
  500. "</tr>" +
  501. "<tr id='trIpAndPort' height='30px'>" +
  502. "<td align='right'><span>IP和端口:</span></td>" +
  503. "<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>" +
  504. "<td><span>*</span></td>" +
  505. "</tr>" +
  506. "</table>" +
  507. "</div>" +
  508. "</fieldset>";
  509. function cbb_DevType_Select(record) {
  510. var devType = userStationTypes[record ? record.id : $("#cbb_DevType").combobox("getValue")];
  511. //处理辅助信息
  512. var tbAuxInfos = $("#tbAuxInfo");
  513. var trAuxInfos = $("#tbAuxInfo tr");
  514. for (var i = 3; i < trAuxInfos.length; i++) {
  515. trAuxInfos.eq(i).remove();
  516. }
  517. var devAuxInfos = devType.辅助信息;
  518. for (var i = 0; i < devAuxInfos.length; i++) {
  519. if (devAuxInfos[i].量名 == "安装时间" || devAuxInfos[i].量名 == "安装位置" || devAuxInfos[i].量名 == "手机卡号" || devAuxInfos[i].量名 == "经度" || devAuxInfos[i].量名 == "纬度") {
  520. continue;
  521. }
  522. switch (devAuxInfos[i].控件类型.substring(0, 1)) {
  523. case "T":
  524. var trTextHTML = "<tr height='30px'>" +
  525. "<td align='right'><span>" + devAuxInfos[i].量名 + ":</span></td>" +
  526. "<td><input id='txt_AuxInfo" + i + "' class='easyui-validatebox textbox' style='height:21px;width:150px' " + (devAuxInfos[i].规则提示 == "" ? "" : ("title='" + devAuxInfos[i].规则提示 + "'")) + "/></td>" +
  527. "<td><span>" + (devAuxInfos[i].必填项 == "是" ? "*" : "") + "</span></td>" +
  528. "</tr>";
  529. $(trTextHTML).appendTo(tbAuxInfos);
  530. if (devAuxInfos[i].必填项 == "是") {
  531. $("#txt_AuxInfo" + i).validatebox({ required: true, missingMessage: ("请输入" + devAuxInfos[i].量名 + (devAuxInfos[i].规则提示 == "" ? "" : ("," + devAuxInfos[i].规则提示))) });
  532. }
  533. break;
  534. case "D":
  535. var trDateHTML = "<tr height='30px'>" +
  536. "<td align='right'><span>" + devAuxInfos[i].量名 + ":</span></td>" +
  537. "<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>" +
  538. "<td><span>" + (devAuxInfos[i].必填项 == "是" ? "*" : "") + "</span></td>" +
  539. "</tr>";
  540. $(trDateHTML).appendTo(tbAuxInfos);
  541. break;
  542. case "C":
  543. var trComHTML = "<tr height='30px'>" +
  544. "<td align='right'><span>" + devAuxInfos[i].量名 + ":</span></td>" +
  545. "<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>" +
  546. "<td><span>" + (devAuxInfos[i].必填项 == "是" ? "*" : "") + "</span></td>" +
  547. "</tr>";
  548. $(trComHTML).appendTo(tbAuxInfos);
  549. if (devAuxInfos[i].控件类型.indexOf("CDB") == 0) {
  550. var comAuxId = "cbb_AuxInfo" + i;
  551. var comAuxValues = devAuxInfos[i].控件类型.substring(3).split("-");
  552. $("#" + comAuxId).combobox({
  553. valueField: 'id',
  554. textField: 'text',
  555. required: true,
  556. editable: false,
  557. panelHeight: 'auto'
  558. });
  559. $.ajax({
  560. url: "../WebServices/DataBaseService.asmx/GetRecordsByTableNameAndColumns",
  561. type: "POST",
  562. data: { "loginIdentifer": window.parent.guid, "requestInfos": (comAuxId + "," + comAuxValues.join(',')), "tableName": comAuxValues[0], "columns": (comAuxValues[1] + ',' + comAuxValues[2]) },
  563. dataType: "text",
  564. async: true,
  565. cache: false,
  566. success: function (responseText) {
  567. var data = eval("(" + $.xml2json(responseText) + ")");
  568. if (data.Result) {
  569. var auxComDatas = [];
  570. var requestInfos = data.RequestInfos.split(',');
  571. for (var j = 0; j < data.Records.length; j++) {
  572. auxComDatas.push({ id: data.Records[j][requestInfos[2]], text: data.Records[j][requestInfos[3]] });
  573. }
  574. var comAuxValue = $("#" + requestInfos[0]).combobox("getValue");
  575. $("#" + requestInfos[0]).combobox({
  576. data: auxComDatas
  577. });
  578. if (typeof (comAuxValue) != "undefined" && comAuxValue != "") {
  579. $("#" + requestInfos[0]).combobox("select", comAuxValue);
  580. }
  581. else {
  582. if (auxComDatas.length > 0) {
  583. $("#" + requestInfos[0]).combobox("select", auxComDatas[0].id);
  584. }
  585. }
  586. }
  587. else {
  588. $.messager.alert("提示信息", data.Message);
  589. }
  590. },
  591. error: function (XMLHttpRequest, textStatus, errorThrown) {
  592. alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
  593. }
  594. });
  595. }
  596. else {
  597. var comAuxValues = devAuxInfos[i].控件类型.substring(1).split("-");
  598. var auxComDatas = [];
  599. for (var j = 0; j < comAuxValues.length; j++) {
  600. if (comAuxValues[i] == "") {
  601. continue;
  602. }
  603. auxComDatas.push({ id: comAuxValues[j], text: comAuxValues[j] })
  604. }
  605. $("#cbb_AuxInfo" + i).combobox({
  606. valueField: 'id',
  607. textField: 'text',
  608. required: true,
  609. editable: false,
  610. panelHeight: 'auto',
  611. data: auxComDatas
  612. });
  613. if (auxComDatas.length > 0) {
  614. $("#cbb_AuxInfo" + i).combobox("select", auxComDatas[0].id);
  615. }
  616. }
  617. break;
  618. default:
  619. break;
  620. }
  621. }
  622. //处理组合站
  623. var subDevNames = devType.子设备.split(",");
  624. var devTabs = $("#divDeviceTabs");
  625. var devTabsCount = devTabs.tabs("tabs").length;
  626. /*当传输协议是平升协议、水资源协议或者是水文协议时,会显示出手机卡号,则其传输设备后对应的就存在数据卡信息页面*/
  627. /*待添加处理程序*/
  628. while (devTabsCount > 4) {
  629. devTabs.tabs('close', 5);
  630. devTabs.tabs('close', 4);
  631. devTabsCount = devTabs.tabs("tabs").length;
  632. }
  633. devTabs.tabs("select", 0);
  634. if (subDevNames.length > 1) {
  635. $("#rtuLegend1").text(subDevNames[0] + "_采集设备");
  636. $("#dtuLegend1").text(subDevNames[0] + "_传输设备");
  637. }
  638. else {
  639. $("#rtuLegend1").text("采集设备");
  640. $("#dtuLegend1").text("传输设备");
  641. }
  642. var index = 0;
  643. for (var i = 1; i < subDevNames.length; i++) {
  644. index = i + 1;
  645. 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 };
  646. 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 };
  647. devTabs.tabs('add', rtuPanel);
  648. devTabs.tabs('add', dtuPanel);
  649. $("#cbb_Network" + index).combobox("clear").combobox({
  650. data: networkComboBoxData,
  651. onSelect: cbb_Network_Select
  652. }).combobox("select", $("#cbb_Network1").combobox("getValue"));
  653. }
  654. var subCommDevTempIds = devType.可支持的模板ID.split(";");
  655. for (var i = 0; i < subCommDevTempIds.length; i++) {
  656. var commDevComboboxData = [];
  657. if (subCommDevTempIds[i] == "") {
  658. for (var cdTempId in commDeviceTypes) {
  659. commDevComboboxData.push({ id: commDeviceTypes[cdTempId].ID, text: commDeviceTypes[cdTempId].模板名称 });
  660. }
  661. }
  662. else {
  663. var subTemps = subCommDevTempIds[i].split(",");
  664. for (var j = 0; j < subTemps.length; j++) {
  665. if (subTemps[j] == "" || typeof (commDeviceTypes[subTemps[j]]) == "undefined") {
  666. continue;
  667. }
  668. commDevComboboxData.push({ id: commDeviceTypes[subTemps[j]].ID, text: commDeviceTypes[subTemps[j]].模板名称 });
  669. }
  670. }
  671. var commDevTypeObj = $("#cbb_CommDeviceType" + (i + 1))
  672. commDevTypeObj.combobox('clear').combobox({
  673. data: commDevComboboxData,
  674. onSelect: cbb_CommDeviceType_Select
  675. });
  676. if (commDevComboboxData.length > 0) {
  677. commDevTypeObj.combobox('select', commDevComboboxData[0].id);
  678. }
  679. }
  680. }
  681. function cbb_CommDeviceType_Select(record) {
  682. var commType = commDeviceTypes[record ? record.id : $("#cbb_CommDeviceType1").combobox("getValue")];
  683. switch (commType.协议名称) {
  684. case "CD_CellMonitor":
  685. case "CD_Camera":
  686. case "CD_CameraZM460":
  687. $("#cbb_IsAsk" + $(this).attr("id").substring(18)).combobox("select", "否");
  688. break;
  689. default:
  690. $("#cbb_IsAsk" + $(this).attr("id").substring(18)).combobox("select", "是");
  691. break;
  692. }
  693. var transDevComboboxData = [];
  694. if (commType.可支持的模板ID == "") {
  695. for (var tdTempId in transDeviceTypes) {
  696. transDevComboboxData.push({ id: transDeviceTypes[tdTempId].ID, text: transDeviceTypes[tdTempId].模板名称 });
  697. }
  698. }
  699. else {
  700. var subTransDevTempIds = commType.可支持的模板ID.split(",");
  701. for (var i = 0; i < subTransDevTempIds.length; i++) {
  702. if (typeof (transDeviceTypes[subTransDevTempIds[i]]) == "undefined") {
  703. continue;
  704. }
  705. transDevComboboxData.push({ id: transDeviceTypes[subTransDevTempIds[i]].ID, text: transDeviceTypes[subTransDevTempIds[i]].模板名称 });
  706. }
  707. }
  708. var transDevTypeObj = $("#cbb_TransArgeement" + $(this).attr("id").substring(18));
  709. var transargeement = transDevTypeObj.combobox("getValue");
  710. transDevTypeObj.combobox('clear').combobox({
  711. data: transDevComboboxData,
  712. onSelect: cbb_TransArgeement_Select
  713. });
  714. if (transargeement != null && transargeement != "") {
  715. transDevTypeObj.combobox('select', transargeement);
  716. }
  717. else {
  718. if (transDevComboboxData.length > 0) {
  719. //修改待确认
  720. var netdata = $("#cbb_Network" + $(this).attr("id").substring(18)).combobox("getValue");
  721. if (netdata != "" && netdata != null) {
  722. $("#cbb_Network" + $(this).attr("id").substring(18)).combobox("unselect", netdata).combobox("select", netdata);
  723. }
  724. else {
  725. transDevTypeObj.combobox('select', transDevComboboxData[0].id);
  726. }
  727. }
  728. }
  729. }
  730. function cbb_TransArgeement_Select(record) {
  731. }
  732. function cbb_Network_Select(record) {
  733. if (record == null) {
  734. return;
  735. }
  736. var networkingMode = record.id;
  737. var index = $(this).attr("id").substring(11);
  738. $("#cbb_TransArgeement" + index).combobox({ disabled: false });
  739. if (networkingMode != 1 && networkingMode != 6 && networkingMode != 7) {
  740. $("#trTransIdentify" + index).show();//传输标识
  741. $("#txt_TransIdentify" + index).val("");
  742. $("#trIpAndPort" + index).hide();
  743. $("#trDataChannel" + index).show();//通道服务
  744. //组网方式为“北斗卫星”时,传输协议设置为“北斗协议”,置灰不可修改--2016-09-08
  745. if (networkingMode == 8) {
  746. var data = $("#cbb_TransArgeement" + index).combobox("getData");
  747. var val = "";
  748. for (var a in data) {
  749. if (data[a].text == "北斗协议") {
  750. val = data[a].id;
  751. }
  752. }
  753. $("#cbb_TransArgeement" + index).combobox({ disabled: true });
  754. $("#cbb_TransArgeement" + index).combobox("select", val);
  755. }
  756. else {
  757. //传输协议赋默认值
  758. var transdata = $("#cbb_TransArgeement" + index).combobox("getData");
  759. if (transdata[0]) {
  760. $("#cbb_TransArgeement" + index).combobox("select", transdata[0].id);
  761. }
  762. }
  763. }
  764. else {
  765. var data = $("#cbb_TransArgeement" + index).combobox("getData");
  766. var val = "";
  767. for (var a in data) {
  768. if (data[a].text == "无协议") {
  769. val = data[a].id;
  770. }
  771. }
  772. $("#cbb_TransArgeement" + index).combobox({ disabled: true });
  773. $("#cbb_TransArgeement" + index).combobox("select", val);
  774. if (networkingMode == 1) {
  775. $("#trTransIdentify" + index).hide();
  776. $("#trDataChannel" + index).show();
  777. $("#trIpAndPort" + index).hide();
  778. }
  779. else {
  780. $("#trTransIdentify" + index).hide();
  781. $("#trDataChannel" + index).hide();
  782. $("#trIpAndPort" + index).show();
  783. }
  784. }
  785. var ddlServerList = [];
  786. ddlServerList.push({ 'id': '0', 'text': '新建...' });
  787. switch (networkingMode) {
  788. case "1":
  789. for (var dcID in dataChannels) {
  790. if (dataChannels[dcID].ChannelType == "DC_COM" && (dataChannels[dcID].Text.indexOf("COM") == 0 || dataChannels[dcID].Text.Contains("串口直连"))) {
  791. ddlServerList.push({ 'id': dataChannels[dcID].ID, 'text': dataChannels[dcID].Text });
  792. }
  793. }
  794. //$("#TelephoneTD").show();
  795. // $("#trIPAndPort"+index).hide();
  796. if (operateType == "Add") {
  797. // $("#cbb_TransArgeement"+index).combobox('select',"无协议");
  798. }
  799. break;
  800. case "2":
  801. for (var dcID in dataChannels) {
  802. if (dataChannels[dcID].ChannelType == "DC_COM" && (dataChannels[dcID].Text == "" || dataChannels[dcID].Text.Contains("移动专网"))) {
  803. ddlServerList.push({ 'id': dataChannels[dcID].ID, 'text': dataChannels[dcID].Text });
  804. }
  805. }
  806. break;
  807. case "3":
  808. break;
  809. case "4":
  810. for (var dcID in dataChannels) {
  811. if (dataChannels[dcID].ChannelType == "DC_TCP_FromServer") {
  812. ddlServerList.push({ 'id': dataChannels[dcID].ID, 'text': dataChannels[dcID].Text });
  813. }
  814. }
  815. break;
  816. case "5":
  817. for (var dcID in dataChannels) {
  818. if (dataChannels[dcID].ChannelType == "DC_UDP_FromServer") {
  819. ddlServerList.push({ 'id': dataChannels[dcID].ID, 'text': dataChannels[dcID].Text });
  820. }
  821. }
  822. break;
  823. case "6":
  824. case "7":
  825. var dcType = "DC_TCP_Client";
  826. if (networkingMode == "7") {
  827. dcType = "DC_UDP_Client";
  828. }
  829. for (var dcID in dataChannels) {
  830. if (dataChannels[dcID].ChannelType == dcType) {
  831. ddlServerList.push({ 'id': dataChannels[dcID].ID, 'text': dataChannels[dcID].Text });
  832. }
  833. }
  834. if (operateType == "Add") {
  835. // $("#cbb_TransArgeement"+index).combobox('select',"无协议");
  836. }
  837. break;
  838. //组网方式为”北斗卫星”时,加载对应的通道服务--2016-09-09
  839. case "8":
  840. for (var dcID in dataChannels) {
  841. if (dataChannels[dcID].ChannelType == "DC_COM" && (dataChannels[dcID].Text == "" || dataChannels[dcID].Text.Contains("北斗卫星"))) {
  842. ddlServerList.push({ 'id': dataChannels[dcID].ID, 'text': dataChannels[dcID].Text });
  843. }
  844. }
  845. break;
  846. default:
  847. break;
  848. }
  849. $("#cbb_DataChannel" + index).combobox('clear').combobox({
  850. data: ddlServerList,
  851. onSelect: cbb_DataChannel_Select
  852. });
  853. if (networkingMode != "6" && networkingMode != "7" && ddlServerList.length > 1) {
  854. $("#cbb_DataChannel" + index).combobox('setValue', ddlServerList[1].id);
  855. }
  856. //ddl_ServerList_SelectChanged();
  857. }
  858. function cbb_DataChannel_Select(record) {
  859. if (record == undefined) {
  860. return;
  861. }
  862. if (record.id == "0") {
  863. var index = $(this).attr("id").substring(15);
  864. var networkingMode = $("#cbb_Network" + index).combobox("getValue");
  865. //组网方式为“北斗卫星”时,隐藏组网方式、监听端口,显示串口号项--2016-09-09
  866. if (networkingMode == "1" || networkingMode == "2" || networkingMode == "3" || networkingMode == "8") {
  867. $(".NetServer").hide();
  868. $(".SerialPort").show();
  869. }
  870. else if (networkingMode == "4" || networkingMode == "5") {
  871. var ntk = $("#selNetworking").val(networkingMode);
  872. ntk.attr("disabled", true);
  873. $(".NetServer").show();
  874. $(".SerialPort").hide();
  875. }
  876. $("#btn_EditServer").linkbutton({ text: "确定" });
  877. $('#dlgEditServer').dialog({
  878. title: '新建通道服务',
  879. closed: false
  880. });
  881. operateDataChannel = "Add";
  882. operateDCIndex = index;
  883. //设置通道服务下拉框中不选择任何项160907
  884. $(this).combobox("select", "");
  885. }
  886. }
  887. function OperateServer() {
  888. var dcID = $("#cbb_DataChannel" + operateDCIndex).combobox("getValue");
  889. var networkingMode = $("#cbb_Network" + operateDCIndex).combobox("getValue");
  890. if (networkingMode == "4" || networkingMode == "5") {
  891. networkingMode = document.getElementById("selNetworking").value;
  892. }
  893. //监听端口
  894. var serverPort = document.getElementById("txt_ServerPort").value;
  895. //串口号
  896. var serialPort = document.getElementById("ddl_SerialPort").value;
  897. //波特率
  898. var baudRate = document.getElementById("ddl_BaudRate").value;
  899. //数据位
  900. var dataBit = document.getElementById("ddl_DataBit").value;
  901. //停止位
  902. var stopBit = document.getElementById("ddl_StopBit").value;
  903. //校验位
  904. var parity = document.getElementById("ddl_Parity").value;
  905. var serverJson = "{'通道ID':'" + dcID + "','组网方式':'" + networkingMode + "','监听端口':'" + serverPort + "','串口号':'" + serialPort + "','波特率':'" + baudRate + "','数据位':'" + dataBit + "','停止位':'" + stopBit + "','校验位':'" + parity + "'}";
  906. $.ajax(
  907. {
  908. url: "../WebServices/DataChannelService.asmx/AddDataChannel",
  909. type: "POST",
  910. data: { "loginIdentifer": window.parent.guid, 'dcJsonString': serverJson },
  911. dataType: "text",
  912. cache: false,
  913. success: function (responseText) {
  914. var data = eval("(" + $.xml2json(responseText) + ")");
  915. if (data.Result) {
  916. if (dcID == "0") {
  917. dataChannels.push(data.DataChannel);
  918. }
  919. //$("#cbb_Network"+operateDCIndex).combobox("unselect", networkingMode).combobox("select", networkingMode);
  920. var channelDatas = $("#cbb_DataChannel" + operateDCIndex).combobox("getData");
  921. channelDatas.push({ id: data.DataChannel.ID, text: data.DataChannel.Text });
  922. $("#cbb_DataChannel" + operateDCIndex).combobox({ data: channelDatas }).combobox("select", data.DataChannel.ID);
  923. $.messager.alert("提示信息", "添加成功");
  924. $('#dlgEditServer').dialog("close");
  925. }
  926. else {
  927. $.messager.alert("提示信息", data.Message);
  928. }
  929. },
  930. error: function (XMLHttpRequest, textStatus, errorThrown) {
  931. $.messager.alert("提示信息", errorThrown + "\r\n" + XMLHttpRequest.responseText);
  932. $('#dlgEditServer').dialog("close");
  933. }
  934. });
  935. }
  936. function LoadTableData(showLastPage, treeSelectedMnId) {
  937. if (!deviceNodeLoaded) {
  938. window.setTimeout("LoadTableData(" + showLastPage + "," + treeSelectedMnId + ")", 500);
  939. return;
  940. }
  941. if (treeSelectedMnId) {
  942. var node = $('#divAreaTree').tree('find', "mn_" + treeSelectedMnId);
  943. $('#divAreaTree').tree('select', node.target);
  944. return;
  945. }
  946. var devIds = "";
  947. for (var key in deviceNodes) {
  948. devIds += key + ",";
  949. }
  950. devIds = devIds.substring(0, devIds.length - 1);
  951. InitDatagridColumnsAndLoadData(devIds);
  952. if (showLastPage) {
  953. var pager = $('#tbDevInfos').datagrid("getPager");
  954. var pagerOptions = pager.pagination("options");
  955. var pageCount = parseInt((pagerOptions["total"] + pagerOptions["pageSize"] - 1) / pagerOptions["pageSize"]);
  956. if (pageCount > 1) {
  957. pager.pagination("select", pageCount);
  958. }
  959. }
  960. }
  961. //devIds格式:1,2,3,4
  962. function InitDatagridColumnsAndLoadData(devIds) {
  963. $.ajax(
  964. {
  965. url: "../WebServices/DeviceNodeService.asmx/GetDeviceDisplayColumns",
  966. type: "POST",
  967. data: { 'loginIdentifer': window.parent.guid, 'deviceIds': devIds },
  968. dataType: "text",
  969. async: false,
  970. cache: false,
  971. success: function (responseText) {
  972. var data = eval("(" + $.xml2json(responseText) + ")");
  973. if (data.Result) {
  974. var Columns = data.Columns;
  975. excelUrl = data.ExcelURL;
  976. var groupConfigs = null;
  977. var firstFrozen = [];
  978. var secondFrozen = [];
  979. var firstPlain = [];
  980. var secondPlain = [];
  981. for (var item in Columns) {
  982. var colwidth;
  983. if (fieldwidth[Columns[item].Field]) {
  984. colwidth = fieldwidth[Columns[item].Field];
  985. }
  986. else {
  987. fieldwidth[Columns[item].Field] = Columns[item].property.columnWidth;
  988. colwidth = fieldwidth[Columns[item].Field];
  989. }
  990. fieldnamerel[Columns[item].Field] = Columns[item].property.paramName;
  991. var gridtitle = Columns[item].HeadText;
  992. if (gridtitle > 4) {
  993. gridtitle = gridtitle.substr(0, 4) + "<br/>" + gridtitle.substr(4, Columns[item].HeadText.length);
  994. }
  995. if (Columns[item].property.groupName == "") {
  996. var obj = {
  997. field: Columns[item].Field,
  998. title: gridtitle,
  999. align: Columns[item].property.alignStyle,
  1000. sortable: Columns[item].property.isSort,
  1001. order: 'asc',
  1002. sorter: function (a, b) { return a.localeCompare(b) }
  1003. //width:120
  1004. };
  1005. if (colwidth == "") {
  1006. if (obj.title.indexOf("时间") >= 0) {
  1007. obj.width = 120;
  1008. }
  1009. else if (obj.title.indexOf("操作") >= 0 || obj.title.indexOf("编辑") >= 0 || obj.title.indexOf("删除") >= 0) {
  1010. obj.width = 30;
  1011. }
  1012. else {
  1013. obj.width = 150;
  1014. }
  1015. }
  1016. else {
  1017. obj.width = colwidth;
  1018. }
  1019. if (Columns[item].property.isFrozen) {
  1020. firstFrozen.push(obj);
  1021. }
  1022. else {
  1023. if (obj.title == "操作") {
  1024. obj["formatter"] = function (value, row, index) {
  1025. 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>";
  1026. };
  1027. }
  1028. firstPlain.push(obj);
  1029. }
  1030. }
  1031. else {
  1032. if (groupConfigs == null) {
  1033. groupConfigs = {};
  1034. }
  1035. if (groupConfigs[Columns[item].property.groupName]) {
  1036. groupConfigs[Columns[item].property.groupName].push(Columns[item]);
  1037. }
  1038. else {
  1039. var obj = {
  1040. title: Columns[item].property.groupName,
  1041. align: "center"
  1042. };
  1043. if (Columns[item].property.isFrozen) {
  1044. firstFrozen.push(obj);
  1045. }
  1046. else {
  1047. firstPlain.push(obj);
  1048. }
  1049. groupConfigs[Columns[item].property.groupName] = [];
  1050. groupConfigs[Columns[item].property.groupName].push(Columns[item]);
  1051. }
  1052. }
  1053. }
  1054. if (groupConfigs) {
  1055. for (var i = 0; i < firstFrozen.length; i++) {
  1056. if (groupConfigs[firstFrozen[i].title]) {
  1057. firstFrozen[i].colspan = groupConfigs[firstFrozen[i].title].length;
  1058. var width = 0;
  1059. for (var j = 0; j < groupConfigs[firstFrozen[i].title].length; j++) {
  1060. var col = groupConfigs[firstFrozen[i].title][j];
  1061. var obj = {
  1062. field: col.Field,
  1063. title: col.HeadText,
  1064. align: col.property.alignStyle,
  1065. sortable: col.property.isSort,
  1066. order: 'asc',
  1067. sorter: function (a, b) { return a.localeCompare(b) }
  1068. //width:120
  1069. };
  1070. if (fieldwidth[col.Field]) {
  1071. colwidth = fieldwidth[col.Field];
  1072. }
  1073. else {
  1074. fieldwidth[col.Field] = col.property.columnWidth;
  1075. colwidth = fieldwidth[col.Field];
  1076. }
  1077. if (colwidth == "") {
  1078. if (obj.title.indexOf("时间") >= 0) {
  1079. obj.width = 120;
  1080. }
  1081. else if (obj.title.indexOf("操作") >= 0 || obj.title.indexOf("编辑") >= 0 || obj.title.indexOf("删除") >= 0) {
  1082. obj.width = 30;
  1083. }
  1084. else {
  1085. obj.width = 90;
  1086. }
  1087. }
  1088. else {
  1089. obj.width = colwidth;
  1090. }
  1091. secondFrozen.push(obj);
  1092. width = width + obj.width;
  1093. }
  1094. firstFrozen[i].width = width;
  1095. }
  1096. else {
  1097. //firstFrozen[i].rowspan = 2;
  1098. }
  1099. }
  1100. for (var i = 0; i < firstPlain.length; i++) {
  1101. if (groupConfigs[firstPlain[i].title]) {
  1102. firstPlain[i].colspan = groupConfigs[firstPlain[i].title].length;
  1103. var width = 0;
  1104. for (var j = 0; j < groupConfigs[firstPlain[i].title].length; j++) {
  1105. var col = groupConfigs[firstPlain[i].title][j];
  1106. var obj = {
  1107. field: col.Field,
  1108. title: col.HeadText,
  1109. align: col.property.alignStyle,
  1110. sortable: col.property.isSort
  1111. //width:120
  1112. };
  1113. if (fieldwidth[col.Field]) {
  1114. colwidth = fieldwidth[col.Field];
  1115. }
  1116. else {
  1117. fieldwidth[col.Field] = col.property.columnWidth;
  1118. colwidth = fieldwidth[col.Field];
  1119. }
  1120. if (colwidth == "") {
  1121. if (obj.title.indexOf("时间") >= 0) {
  1122. obj.width = 128;
  1123. }
  1124. else if (obj.title.indexOf("操作") >= 0 || obj.title.indexOf("编辑") >= 0 || obj.title.indexOf("删除") >= 0) {
  1125. obj.width = 30;
  1126. }
  1127. else {
  1128. obj.width = 100;
  1129. }
  1130. }
  1131. else {
  1132. obj.width = colwidth;
  1133. }
  1134. secondPlain.push(obj);
  1135. width = width + obj.width;
  1136. }
  1137. firstPlain[i].width = width;
  1138. }
  1139. else {
  1140. firstPlain[i].rowspan = 2;
  1141. }
  1142. }
  1143. }
  1144. $('#tbDevInfos').datagrid({ frozenColumns: (secondFrozen.length == 0 ? [firstFrozen] : [firstFrozen, secondFrozen]), columns: (secondPlain.length == 0 ? [firstPlain] : [firstPlain, secondPlain]) });
  1145. $('#tbDevInfos').datagrid("hideColumn", "devId");
  1146. var deviceJason = data.Devices;
  1147. for (var i = 0; i < deviceJason.length; i++) {
  1148. var tableRow = {};
  1149. for (var item in deviceJason[i]) {
  1150. tableRow[deviceJason[i][item].Field] = deviceJason[i][item].Value;
  1151. }
  1152. tableRow["editDev"] = "<img src='../Images/Detail.gif' style='cursor:pointer' />";
  1153. tableRow["removeDev"] = "<img src='../Images/Delete.gif' style='cursor:pointer' />";
  1154. tableData.push(tableRow);
  1155. }
  1156. var tableDataObj = {
  1157. total: deviceJason.length,
  1158. rows: tableData
  1159. }
  1160. $('#tbDevInfos').datagrid({ loadFilter: pagerFilter }).datagrid('loadData', tableDataObj);
  1161. $.HideMask();
  1162. }
  1163. else {
  1164. $.HideMask();
  1165. $.messager.alert("提示信息", data.Message);
  1166. }
  1167. },
  1168. error: function (XMLHttpRequest, textStatus, errorThrown) {
  1169. $.HideMask();
  1170. $.messager.alert("提示信息", errorThrown + "\r\n" + XMLHttpRequest.responseText);
  1171. }
  1172. });
  1173. }
  1174. function ReLoadTableData(devIds) {
  1175. $("#tbDevInfos").datagrid('loadData', { total: 0, rows: [] });
  1176. tableData = [];
  1177. if (devIds.length == 0) {
  1178. $.HideMask();
  1179. return;
  1180. }
  1181. var deviceIds = "";
  1182. for (var i = 0; i < devIds.length; i++) {
  1183. deviceIds += devIds[i] + ",";
  1184. }
  1185. deviceIds = deviceIds.substring(0, deviceIds.length - 1);
  1186. InitDatagridColumnsAndLoadData(deviceIds);
  1187. }
  1188. function pagerFilter(data) {
  1189. if (typeof data.length == 'number' && typeof data.splice == 'function') { // is array
  1190. data = {
  1191. total: data.length,
  1192. rows: data
  1193. }
  1194. }
  1195. var dg = $(this);
  1196. var opts = dg.datagrid('options');
  1197. var pager = dg.datagrid('getPager');
  1198. pager.pagination({
  1199. onSelectPage: function (pageNum, pageSize) {
  1200. opts.pageNumber = pageNum;
  1201. opts.pageSize = pageSize;
  1202. pager.pagination('refresh', {
  1203. pageNumber: pageNum,
  1204. pageSize: pageSize
  1205. });
  1206. dg.datagrid('loadData', data);
  1207. }
  1208. });
  1209. if (!data.originalRows) {
  1210. data.originalRows = (data.rows);
  1211. }
  1212. var start = (opts.pageNumber - 1) * parseInt(opts.pageSize);
  1213. var end = start + parseInt(opts.pageSize);
  1214. data.rows = (data.originalRows.slice(start, end));
  1215. return data;
  1216. }
  1217. function LoadComboboxData() {
  1218. if (!deviceNodeLoaded) {
  1219. window.setTimeout("LoadComboboxData()", 500);
  1220. return;
  1221. }
  1222. comboBoxData = [];
  1223. for (i = 0; i < deviceJson.length; i++) {
  1224. var devObj = {};
  1225. devObj["id"] = deviceJson[i].ID;
  1226. devObj["text"] = deviceJson[i].名称;
  1227. comboBoxData.push(devObj);
  1228. }
  1229. $("#cbb_DevCombobox").combobox({
  1230. data: comboBoxData
  1231. });
  1232. }
  1233. function LoadManageAndDevCombobox() {
  1234. $("#cb_DevRefer").attr("checked", false);
  1235. $("#cbb_DevRefer").combotree({ 'disabled': true });
  1236. var rootNode = $("#divAreaTree").tree("getRoot");
  1237. var treeData = $("#divAreaTree").tree("getData", rootNode.target);
  1238. var mnComboboxData = [];
  1239. mnComboboxData.push(LoadMnComboboxDataFromTreeData(treeData));
  1240. $('#cbb_DevManager').combotree('loadData', mnComboboxData);
  1241. $('#cbb_DevManager').combotree('tree').tree({
  1242. onBeforeSelect: function (node) {
  1243. var selectedLevelName = node.attributes["manage"]["级别别名"];
  1244. if (selectedLevelName == "") {
  1245. selectedLevelName = node.attributes["manage"]["级别名称"];
  1246. }
  1247. if (selectedLevelName == mnLevelName) {
  1248. return true;
  1249. }
  1250. else {
  1251. return false;
  1252. }
  1253. }
  1254. });
  1255. var devComboboxData = [];
  1256. devComboboxData.push(LoadDevComboboxDataFromTreeData(treeData))
  1257. $('#cbb_DevRefer').combotree('loadData', devComboboxData);
  1258. }
  1259. function LoadMnComboboxDataFromTreeData(treeData) {
  1260. var comTreeDataObj = {};
  1261. comTreeDataObj["id"] = treeData.id;
  1262. comTreeDataObj["text"] = treeData.text;
  1263. comTreeDataObj["attributes"] = treeData.attributes;
  1264. comTreeDataObj["children"] = [];
  1265. for (var i = 0; i < treeData.children.length; i++) {
  1266. if (treeData.children[i].attributes.nodeType == "device") {
  1267. continue;
  1268. }
  1269. comTreeDataObj["children"].push(LoadMnComboboxDataFromTreeData(treeData.children[i]));
  1270. }
  1271. return comTreeDataObj;
  1272. }
  1273. function LoadDevComboboxDataFromTreeData(treeData) {
  1274. var comTreeDataObj = {};
  1275. comTreeDataObj["id"] = treeData.id;
  1276. comTreeDataObj["text"] = treeData.text;
  1277. comTreeDataObj["attributes"] = treeData.attributes;
  1278. comTreeDataObj["children"] = [];
  1279. for (var i = 0; i < treeData.children.length; i++) {
  1280. comTreeDataObj["children"].push(LoadDevComboboxDataFromTreeData(treeData.children[i]));
  1281. }
  1282. return comTreeDataObj;
  1283. }
  1284. //删除轮播控件重新加载
  1285. function LoadImageControl() {
  1286. //删除整个轮播控件再重新创建
  1287. var fieldsetImgObj = $("#fieldsetImg");
  1288. $("#b06").remove();
  1289. var divInfos = $("<div class='banner' id='b06'></div>");
  1290. var ulInfos = $("<ul id='imgul' style='padding-left: 0px; margin-top: 0px;'></ul>");
  1291. 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>");
  1292. 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>")
  1293. if (imgNameArray.length == 0) {
  1294. index = "0";
  1295. imgUrl = "../Images/addImage.png";
  1296. var liStr = "";
  1297. liStr = "<li id='li_1'>";
  1298. liStr += "<span class='fileinput-button'>";
  1299. liStr += "<input id='fileupload1' type='file' name='files[]' onchange='previewImage(this,1)' autoupload='false'>";
  1300. liStr += "<img id='img_1' class='sliderimg' src='" +
  1301. imgUrl + "' alt='' width='280px' height='170px' >";
  1302. liStr += "</li>";
  1303. liObj = $(liStr);
  1304. remark = "";
  1305. imgNameArray.push({ '显示序号': 0, '图片索引': "0", '图片路径': imgUrl, '备注': "" });
  1306. ulInfos.append(liObj);
  1307. }
  1308. else {
  1309. for (var i = 0; i < imgNameArray.length; i++) {
  1310. var index = imgNameArray[i].图片索引;
  1311. var imgUrl;
  1312. var remark;
  1313. var liObj;
  1314. if (i == imgNameArray.length - 1 && imgNameArray.length <= 6) {
  1315. imgUrl = "../Images/addImage.png";
  1316. var liStr = "";
  1317. liStr = "<li id='li_" + (i + 1) + "'>";
  1318. liStr += "<span class='fileinput-button'>";
  1319. liStr += "<input id='fileupload1' type='file' name='files[]' onchange='previewImage(this," + (i + 1) + ")' autoupload='false'>";
  1320. liStr += "<img id='img_" + (i + 1) + "' class='sliderimg' src='" +
  1321. imgUrl + "' alt='' width='280px' height='170px' >";
  1322. liStr += "</li>";
  1323. liObj = $(liStr);
  1324. remark = "";
  1325. }
  1326. else {
  1327. imgUrl = imgNameArray[i].图片路径;
  1328. remark = imgNameArray[i].备注;
  1329. var liStr = "";
  1330. liStr = "<li id='li_" + (i + 1) + "'><img id='img_" + (i + 1) + "' class='sliderimg' guid='" + index + "' src='" + imgUrl + "' alt='' width='280px' height='170px' ></li>";
  1331. liObj = $(liStr);
  1332. currentOperateImgUrl = imgUrl;
  1333. $('#smartMenu_').remove();
  1334. rightMenu((i + 1));
  1335. }
  1336. ulInfos.append(liObj);
  1337. }
  1338. }
  1339. divInfos.appendTo(fieldsetImgObj);
  1340. ulInfos.appendTo(divInfos);
  1341. alObj.appendTo(divInfos);
  1342. arObj.appendTo(divInfos);
  1343. InitImage();
  1344. uploadImage();
  1345. }
  1346. function LoadDeviceDetailInfo(devId) {
  1347. ClearDeviceDetailInfo();
  1348. LoadManageAndDevCombobox();
  1349. var deviceNode = deviceNodes[devId];
  1350. var deviceObj = deviceNode.attributes.device;
  1351. operateDevObj = $.extend(true, {}, deviceObj);
  1352. //基本信息
  1353. $("#txt_DevName").val(deviceNode.text);
  1354. $("#cbb_DevManager").combotree('setValue', "mn_" + deviceObj.管理ID);
  1355. $("#cbb_DevType").combobox('select', deviceObj.模板信息ID);
  1356. //图片信息
  1357. $.ajax({
  1358. url: "../WebServices/DeviceNodeService.asmx/GetDevImage",
  1359. type: "GET",
  1360. data: { "devId": devId },
  1361. dataType: "text",
  1362. cache: false,
  1363. success: function (responseText) {
  1364. var data = eval("(" + $.xml2json(responseText) + ")");
  1365. if (data.Result == true) {
  1366. var imgData = data.ImageData;
  1367. currentOperateDevId = devId;
  1368. imgNameArray = [];
  1369. for (var i = 0; i < imgData.length; i++) {
  1370. imgNameArray.push({ '显示序号': i + 1, '图片索引': imgData[i].图片索引, '图片路径': imgData[i].图片路径, '备注': imgData[i].备注 });
  1371. }
  1372. imgNameArray.push({ '显示序号': 0, '图片索引': "0", '图片路径': "../Images/addImage.png", '备注': "" });
  1373. LoadImageControl();
  1374. }
  1375. else {
  1376. $.messager.alert("提示信息", data.Message);
  1377. }
  1378. },
  1379. error: function (XMLHttpRequest, textStatus, errorThrown) {
  1380. $.messager.alert("提示信息", errorThrown + "\r\n" + XMLHttpRequest.responseText);
  1381. }
  1382. });
  1383. //辅助信息
  1384. var lng = (typeof (deviceObj.辅助信息.经度) == "undefined" ? "" : deviceObj.辅助信息.经度);
  1385. var lat = (typeof (deviceObj.辅助信息.纬度) == "undefined" ? "" : deviceObj.辅助信息.纬度);
  1386. if (lng != "" && lat != "") {
  1387. $("#txt_DevPosition").val(lng + "|" + lat);
  1388. }
  1389. else {
  1390. $("#txt_DevPosition").val("");
  1391. }
  1392. $("#txt_InstallTime").val(typeof (deviceObj.辅助信息.安装时间) == "undefined" ? "" : deviceObj.辅助信息.安装时间);
  1393. $("#txt_InstallSite").val(typeof (deviceObj.辅助信息.安装位置) == "undefined" ? "" : deviceObj.辅助信息.安装位置);
  1394. var simnum = typeof (deviceObj.辅助信息.手机卡号) == "undefined" ? "" : deviceObj.辅助信息.手机卡号;
  1395. $("#text_SimNum").textbox("setValue", simnum);
  1396. //通讯设备
  1397. var index = 0;
  1398. for (var i = 0; i < deviceObj.通讯设备.length; i++) {
  1399. index = i + 1;
  1400. $("#cbb_CommDeviceType" + index).combobox('setValue', deviceObj.通讯设备[i].模板信息ID);
  1401. $("#txt_CommDeviceAddr" + index).val(deviceObj.通讯设备[i].设备地址);
  1402. $("#cbb_IsAsk" + index).combobox('setValue', deviceObj.通讯设备[i].是否轮询);
  1403. $("#txt_Interval" + index).val(deviceObj.通讯设备[i].轮询间隔);
  1404. }
  1405. //传输设备
  1406. for (var i = 0; i < deviceObj.传输设备.length; i++) {
  1407. index = i + 1;
  1408. $("#cbb_Network" + index).combobox('select', deviceObj.传输设备[i].组网方式);
  1409. var netType = $("#cbb_Network" + index).combobox("getText");
  1410. if (netType.indexOf("设备主机") >= 0) {
  1411. $("#cbb_TransArgeement" + index).combobox({ disabled: true });
  1412. $("#cbb_TransArgeement" + index).combobox('setValue', deviceObj.传输设备[i].模板信息ID);
  1413. $("#trDataChannel" + index).hide();
  1414. $("#cbb_DataChannel" + index).combobox('setValue', deviceObj.传输设备[i].数据通道ID);
  1415. $("#trTransIdentify" + index).hide();
  1416. $("#txt_TransIdentify" + index).val(deviceObj.传输设备[i].传输标识);
  1417. $("#trIpAndPort" + index).show();
  1418. $("#txt_Ip" + index).val(deviceObj.传输设备[i].传输标识.split(":")[0]);
  1419. $("#txt_Port" + index).val(deviceObj.传输设备[i].传输标识.split(":")[1]);
  1420. }
  1421. else if (netType.indexOf("串口直连") >= 0) {
  1422. $("#cbb_TransArgeement" + index).combobox({ disabled: true });
  1423. $("#cbb_TransArgeement" + index).combobox('setValue', deviceObj.传输设备[i].模板信息ID);
  1424. $("#trDataChannel" + index).show();
  1425. $("#cbb_DataChannel" + index).combobox('setValue', deviceObj.传输设备[i].数据通道ID);
  1426. $("#trTransIdentify" + index).hide();
  1427. $("#txt_TransIdentify" + index).val(deviceObj.传输设备[i].传输标识);
  1428. $("#trIpAndPort" + index).hide();
  1429. $("#txt_Ip" + index).val("");
  1430. $("#txt_Port" + index).val("");
  1431. }
  1432. else {
  1433. $("#cbb_TransArgeement" + index).combobox('setValue', deviceObj.传输设备[i].模板信息ID);
  1434. $("#trDataChannel" + index).show();
  1435. $("#cbb_DataChannel" + index).combobox('setValue', deviceObj.传输设备[i].数据通道ID);
  1436. $("#trTransIdentify" + index).show();
  1437. $("#txt_TransIdentify" + index).val(deviceObj.传输设备[i].传输标识);
  1438. }
  1439. }
  1440. }
  1441. function ClearDeviceDetailInfo() {
  1442. //基本信息
  1443. $("#txt_DevName").val("");
  1444. //清空轮播控件中的图片
  1445. imgNameArray = [];
  1446. imgNameArray.push({ '显示序号': 0, '图片索引': "0", '图片路径': "../Images/addImage.png", '备注': "" });
  1447. LoadImageControl();
  1448. //辅助信息
  1449. $("#txt_DevPosition").val("");
  1450. $("#txt_InstallTime").val(new Date().Format('yyyy-MM-dd HH:mm'));
  1451. $("#txt_InstallSite").val("");
  1452. $("#text_SimNum").textbox("setValue", "");
  1453. cbb_DevType_Select();
  1454. var tabsConut = $('#divDeviceTabs').tabs('tabs').length;
  1455. for (var i = 2; i < tabsConut; i++) {
  1456. var subIndex = parseInt(i / 2);
  1457. if ((i % 2) == 0) {
  1458. //通讯设备
  1459. var commDevType = commDeviceTypes[$("#cbb_CommDeviceType" + subIndex).combobox('getValue')];
  1460. switch (commDevType.协议名称) {
  1461. case "CD_PSCtrlPlus":
  1462. case "CD_PSController":
  1463. $("#txt_CommDeviceAddr" + subIndex).val("101");
  1464. //清空轮询间隔文本框
  1465. // $("#txt_Interval"+subIndex).val("");
  1466. break;
  1467. case "CD_CellMonitor":
  1468. $("#txt_CommDeviceAddr" + subIndex).val("1");
  1469. break;
  1470. default:
  1471. $("#txt_CommDeviceAddr" + subIndex).val("");
  1472. }
  1473. }
  1474. else {
  1475. //传输设备
  1476. //组网方式
  1477. // var data=$("#cbb_Network"+subIndex).combobox("getData");
  1478. // var id=null;
  1479. // for(var a in data)
  1480. // {
  1481. // if(data[a].text=="串口直连")
  1482. // {
  1483. // id=data[a].id;
  1484. // break;
  1485. // }
  1486. // }
  1487. $("#cbb_Network" + subIndex).combobox("select", "");
  1488. //传输标识
  1489. $("#trTransIdentify" + subIndex).show();
  1490. $("#txt_TransIdentify" + subIndex).val("");
  1491. //ip和端口
  1492. $("#trIpAndPort" + subIndex).show();
  1493. $("#txt_Ip" + subIndex).val("");
  1494. $("#txt_Port" + subIndex).val("");
  1495. //传输协议
  1496. $("#cbb_TransArgeement" + subIndex).combobox("select", "");
  1497. //数据通道
  1498. $("#trDataChannel" + subIndex).css("display");
  1499. $("#cbb_DataChannel" + subIndex).combobox("select", "");
  1500. }
  1501. }
  1502. }
  1503. function Btn_Query_Click() {
  1504. var devIds = [];
  1505. var devComboboxObj = $("#cbb_DevCombobox");
  1506. var value = devComboboxObj.combobox("getValue");
  1507. $.ShowMask("数据加载中,请稍等……");
  1508. //值为空时采用模糊获取ID
  1509. if (value == null || value == "") {
  1510. var text = devComboboxObj.combobox("getText");
  1511. //文本为空时按Combobox加载数据获取设备ID
  1512. if ($.trim(text) != "") {
  1513. var comboboxData = devComboboxObj.combobox("getData");
  1514. var opts = devComboboxObj.combobox('options');
  1515. for (var i = 0; i < comboboxData.length; i++) {
  1516. if (comboboxData[i][opts.textField].indexOf(text) > -1) {
  1517. devIds.push(comboboxData[i][opts.valueField]);
  1518. }
  1519. }
  1520. if (devIds.length == 0) {
  1521. $.messager.alert("提示信息", "查询结果为空");
  1522. }
  1523. $("#divAreaTree").find("div.tree-node-selected").removeClass("tree-node-selected");
  1524. currentSelManageId = "";
  1525. currentSelDeviceId = "";
  1526. ReLoadTableData(devIds);
  1527. }
  1528. else {
  1529. LoadTableData();
  1530. return;
  1531. }
  1532. }
  1533. else {
  1534. var treeNode = $("#divAreaTree").tree("find", "dn_" + value);
  1535. $("#divAreaTree").tree("select", treeNode.target);
  1536. }
  1537. }
  1538. function btn_Add_Click() {
  1539. operateType = "Add";
  1540. operateDevObj = {};
  1541. ClearDeviceDetailInfo();
  1542. LoadManageAndDevCombobox();
  1543. if (currentSelManageId != "") {
  1544. $('#cbb_DevManager').combotree('setValue', "mn_" + currentSelManageId);
  1545. }
  1546. $('#dlgDevice').dialog({ title: "添加" + devLevelName + "信息", closed: false });
  1547. $('#divDeviceTabs').tabs("select", 0);
  1548. $("#btn_Next").linkbutton({ text: "下一步" });
  1549. /*获取最新数据卡信息*/
  1550. GetSIMCardNumber();
  1551. }
  1552. function btn_Back_Click() {
  1553. var tabsObj = $('#divDeviceTabs');
  1554. var tab = tabsObj.tabs('getSelected');
  1555. var index = tabsObj.tabs('getTabIndex', tab);
  1556. if (index != 0) {
  1557. $("#btn_Next").linkbutton({ text: "下一步" });
  1558. tabsObj.tabs("select", index - 1);
  1559. if ((index - 1) == 0) {
  1560. $("#btn_Back").linkbutton("disable");
  1561. }
  1562. }
  1563. }
  1564. function btn_Next_Click() {
  1565. $("#btn_Back").linkbutton("enable");
  1566. var tabsObj = $('#divDeviceTabs');
  1567. var tabsConut = tabsObj.tabs('tabs').length;
  1568. var tab = tabsObj.tabs('getSelected');
  1569. var index = tabsObj.tabs('getTabIndex', tab);
  1570. switch (index) {
  1571. case 0:
  1572. //基本信息校验
  1573. var devNameTemp = $("#txt_DevName").val();
  1574. if (devNameTemp.trim() == "") {
  1575. $.messager.alert("提示信息", devLevelName + "名称不能为空");
  1576. return;
  1577. }
  1578. var mnIdTemp = $("#cbb_DevManager").combotree('getValue');
  1579. if (mnIdTemp == null || mnIdTemp == "") {
  1580. $.messager.alert("提示信息", "请选择区域(单位)");
  1581. return;
  1582. }
  1583. var mnTnTemp = $("#divAreaTree").tree("find", mnIdTemp);
  1584. for (var i = 0; i < mnTnTemp.children.length; i++) {
  1585. if (mnTnTemp.children[i].attributes.nodeType != "device") {
  1586. continue;
  1587. }
  1588. if (operateType == "Add") {
  1589. if ($("#txt_DevName").val() == mnTnTemp.children[i].text) {
  1590. $.messager.alert("提示信息", devLevelName + "名称重复,请重新填写");
  1591. $("#txt_DevName").focus();
  1592. return;
  1593. }
  1594. }
  1595. else {
  1596. if (mnTnTemp.children[i].id != ("dn_" + operateDevObj.ID) && $("#txt_DevName").val() == mnTnTemp.children[i].text) {
  1597. $.messager.alert("提示信息", devLevelName + "名称重复,请重新填写");
  1598. $("#txt_DevName").focus();
  1599. return;
  1600. }
  1601. }
  1602. }
  1603. operateDevObj["名称"] = devNameTemp;
  1604. operateDevObj["管理ID"] = mnIdTemp.substring(3);
  1605. operateDevObj["管理名称"] = mnTnTemp.text;
  1606. var devTypeTemp = $("#cbb_DevType").combotree('getValue');
  1607. if (devTypeTemp == null || devTypeTemp == "") {
  1608. $.messager.alert("提示信息", "请选择" + devLevelName + "类型");
  1609. return;
  1610. }
  1611. var devTypeObjTemp = userStationTypes[devTypeTemp];
  1612. operateDevObj["用户站协议"] = devTypeObjTemp.协议名称;
  1613. operateDevObj["用户站参数"] = devTypeObjTemp.用户站参数;
  1614. operateDevObj["模板信息ID"] = devTypeObjTemp.ID;
  1615. operateDevObj["模板信息名称"] = mnTnTemp.模板名称;
  1616. if (typeof (operateDevObj.辅助信息) == 'undefined') {
  1617. operateDevObj.辅助信息 = {};
  1618. }
  1619. var devPositionTemp = $("#txt_DevPosition").val().trim();
  1620. if (devPositionTemp == "") {
  1621. operateDevObj.辅助信息["经度"] = "";
  1622. operateDevObj.辅助信息["纬度"] = "";
  1623. }
  1624. else {
  1625. var devPositionsTemp = devPositionTemp.split("|");
  1626. if (devPositionsTemp.length < 2 || devPositionsTemp[0].trim() == "" || devPositionsTemp[1].trim() == "") {
  1627. $.messager.alert("提示信息", "地图坐标格式不正确,正确格式为x|y");
  1628. return;
  1629. }
  1630. operateDevObj.辅助信息["经度"] = devPositionsTemp[0];
  1631. operateDevObj.辅助信息["纬度"] = devPositionsTemp[1];
  1632. }
  1633. if (operateType != "Add") {
  1634. var devAuxInfos = devTypeObjTemp.辅助信息;
  1635. for (var i = 0; i < devAuxInfos.length; i++) {
  1636. if (devAuxInfos[i].量名 == "安装时间" || devAuxInfos[i].量名 == "安装位置" || devAuxInfos[i].量名 == "手机卡号" || devAuxInfos[i].量名 == "经度" || devAuxInfos[i].量名 == "纬度") {
  1637. continue;
  1638. }
  1639. var auxValue = typeof (operateDevObj.辅助信息[devAuxInfos[i].量名]) == "undefined" ? "" : operateDevObj.辅助信息[devAuxInfos[i].量名];
  1640. switch (devAuxInfos[i].控件类型.substring(0, 1)) {
  1641. case "T":
  1642. case "D":
  1643. $("#txt_AuxInfo" + i).val(auxValue);
  1644. break;
  1645. case "C":
  1646. $("#cbb_AuxInfo" + i).combobox("select", auxValue);
  1647. break;
  1648. default:
  1649. break;
  1650. }
  1651. }
  1652. }
  1653. break;
  1654. case 1:
  1655. //辅助信息校验
  1656. operateDevObj.辅助信息["安装时间"] = $("#txt_InstallTime").val();
  1657. operateDevObj.辅助信息["安装位置"] = $("#txt_InstallSite").val();
  1658. operateDevObj.辅助信息["手机卡号"] = $("#text_SimNum").textbox("getText");
  1659. var devAuxInfos = userStationTypes[operateDevObj.模板信息ID].辅助信息;
  1660. for (var i = 0; i < devAuxInfos.length; i++) {
  1661. if (devAuxInfos[i].量名 == "安装时间" || devAuxInfos[i].量名 == "安装位置" || devAuxInfos[i].量名 == "手机卡号" || devAuxInfos[i].量名 == "经度" || devAuxInfos[i].量名 == "纬度") {
  1662. continue;
  1663. }
  1664. switch (devAuxInfos[i].控件类型.substring(0, 1)) {
  1665. case "T":
  1666. case "D":
  1667. if (devAuxInfos[i].必填项 == "是" && $("#txt_AuxInfo" + i).val().trim() == "") {
  1668. $.messager.alert("提示信息", devAuxInfos[i].量名 + "不能为空");
  1669. $("#txt_AuxInfo" + i).focus();
  1670. return;
  1671. }
  1672. operateDevObj.辅助信息[devAuxInfos[i].量名] = $("#txt_AuxInfo" + i).val();
  1673. break;
  1674. case "C":
  1675. operateDevObj.辅助信息[devAuxInfos[i].量名] = $("#cbb_AuxInfo" + i).combobox("getValue");
  1676. break;
  1677. default:
  1678. break;
  1679. }
  1680. }
  1681. break;
  1682. default:
  1683. var subDevIndex = parseInt(index / 2);
  1684. if (index % 2 == 0) {
  1685. var commDevTypeId = $("#cbb_CommDeviceType" + subDevIndex).combobox('getValue');
  1686. if (typeof (commDevTypeId) == "undefined" || commDevTypeId == "") {
  1687. $.messager.alert("提示信息", "请选择设备协议");
  1688. return;
  1689. }
  1690. //通讯设备校验
  1691. var commDevAddrTemp = $("#txt_CommDeviceAddr" + subDevIndex).val();
  1692. if (commDevAddrTemp.trim() == "") {
  1693. $.messager.alert("提示信息", "设备地址不能为空");
  1694. return;
  1695. }
  1696. var isAskTemp = $("#cbb_IsAsk" + subDevIndex).combobox('getValue');
  1697. var pollingIntervalTemp = $("#txt_Interval" + subDevIndex).val();
  1698. if (isAskTemp == "是") {
  1699. if (pollingIntervalTemp.trim() == "") {
  1700. $.messager.alert("提示信息", "轮询间隔不能为空");
  1701. return;
  1702. }
  1703. if (isNaN(pollingIntervalTemp)) {
  1704. $.messager.alert("提示信息", "轮询间隔格式不正确,请输入数字");
  1705. return;
  1706. }
  1707. }
  1708. if (typeof (operateDevObj.通讯设备) == 'undefined') {
  1709. operateDevObj.通讯设备 = [];
  1710. }
  1711. if (operateDevObj.通讯设备.length < subDevIndex) {
  1712. operateDevObj.通讯设备.push({});
  1713. }
  1714. var cdName = $("#cbb_CommDeviceType" + subDevIndex).combobox('getText');
  1715. var subDevNames = userStationTypes[operateDevObj.模板信息ID].子设备.split(",");
  1716. if (subDevNames.length >= subDevIndex) {
  1717. cdName = subDevNames[subDevIndex - 1];
  1718. }
  1719. operateDevObj.通讯设备[subDevIndex - 1].设备名称 = operateDevObj.名称 + "_" + cdName;
  1720. var commDevTypeTemp = commDeviceTypes[commDevTypeId];
  1721. operateDevObj.通讯设备[subDevIndex - 1].设备协议 = commDevTypeTemp.协议名称;
  1722. operateDevObj.通讯设备[subDevIndex - 1].协议参数 = commDevTypeTemp.用户站参数;
  1723. operateDevObj.通讯设备[subDevIndex - 1].设备地址 = commDevAddrTemp;
  1724. operateDevObj.通讯设备[subDevIndex - 1].是否轮询 = isAskTemp;
  1725. operateDevObj.通讯设备[subDevIndex - 1].轮询间隔 = pollingIntervalTemp;
  1726. operateDevObj.通讯设备[subDevIndex - 1].模板信息ID = commDevTypeTemp.ID;
  1727. operateDevObj.通讯设备[subDevIndex - 1].模板信息名称 = commDevTypeTemp.模板名称;
  1728. }
  1729. else {
  1730. //传输设备校验
  1731. if (typeof (operateDevObj.传输设备) == 'undefined') {
  1732. operateDevObj.传输设备 = [];
  1733. }
  1734. if (operateDevObj.传输设备.length < subDevIndex) {
  1735. operateDevObj.传输设备.push({});
  1736. }
  1737. var networkingMode = $("#cbb_Network" + subDevIndex).combobox('getValue');
  1738. var transDevTypeTemp = transDeviceTypes[$("#cbb_TransArgeement" + subDevIndex).combobox('getValue')];
  1739. operateDevObj.传输设备[subDevIndex - 1].模板信息ID = transDevTypeTemp.ID;
  1740. operateDevObj.传输设备[subDevIndex - 1].模板信息名称 = transDevTypeTemp.模板名称;
  1741. operateDevObj.传输设备[subDevIndex - 1].传输协议 = transDevTypeTemp.协议名称;
  1742. operateDevObj.传输设备[subDevIndex - 1].组网方式 = networkingMode;
  1743. var dcIdTemp = $("#cbb_DataChannel" + subDevIndex).combobox('getValue');
  1744. if ($("#cbb_DataChannel" + (subDevIndex + 1)).length > 0) {
  1745. var channeldata = $("#cbb_DataChannel" + subDevIndex).combobox('getData');
  1746. var channelval = $("#cbb_DataChannel" + (subDevIndex + 1)).combobox("getValue");
  1747. for (var a in channeldata) {
  1748. if (channeldata[a].id == channelval) {
  1749. $("#cbb_DataChannel" + (subDevIndex + 1)).combobox({ data: channeldata });
  1750. $("#cbb_DataChannel" + (subDevIndex + 1)).combobox("setValue", channelval);
  1751. }
  1752. }
  1753. }
  1754. var channelShowText = $("#cbb_DataChannel" + subDevIndex).combobox('getText');
  1755. switch (networkingMode) {
  1756. //串口直连
  1757. case "1":
  1758. if (typeof (dcIdTemp) == "undefined" || dcIdTemp == "" || dcIdTemp == "0") {
  1759. $.messager.alert("提示信息", "请选择或新建通道服务");
  1760. return;
  1761. }
  1762. operateDevObj.传输设备[subDevIndex - 1].数据通道ID = dcIdTemp;
  1763. if (channelShowText.indexOf(":") > 0) {
  1764. operateDevObj.传输设备[subDevIndex - 1].传输标识 = $("#cbb_DataChannel" + subDevIndex).combobox('getText').split(":")[1];
  1765. }
  1766. else {
  1767. operateDevObj.传输设备[subDevIndex - 1].传输标识 = channelShowText;
  1768. }
  1769. break;
  1770. //tcp-设备主机
  1771. case "6":
  1772. //udp-设备主机
  1773. case "7":
  1774. operateDevObj.传输设备[subDevIndex - 1].数据通道ID = (dcIdTemp == "") ? "0" : dcIdTemp;
  1775. //ip地址和端口
  1776. if ($("#txt_Ip" + subDevIndex).val() == "" || $("#txt_Port" + subDevIndex).val() == "") {
  1777. $.messager.alert("提示信息", "请将ip和端口号填写完整");
  1778. return;
  1779. }
  1780. var re = /^\d+\.\d+\.\d+\.\d+$/;
  1781. var ip = $("#txt_Ip" + subDevIndex).val();
  1782. if (!re.test(ip) || parseInt(ip.split(".")[0]) > 255 || parseInt(ip.split(".")[1]) > 255 || parseInt(ip.split(".")[2]) > 255 || parseInt(ip.split(".")[3]) > 255) {
  1783. $.messager.alert("提示信息", "ip地址错误,请修改");
  1784. return;
  1785. }
  1786. // if($("#txt_Ip"+subDevIndex).val().split(".")[3]==undefined||$("#txt_Ip"+subDevIndex).val().split(".")[3]=="")
  1787. // {
  1788. // $.messager.alert("提示信息", "ip地址错误,请修改");
  1789. // return;
  1790. // }
  1791. operateDevObj.传输设备[subDevIndex - 1].传输标识 = $("#txt_Ip" + subDevIndex).val() + ":" + $("#txt_Port" + subDevIndex).val();
  1792. break;
  1793. default:
  1794. if (typeof (dcIdTemp) == "undefined" || dcIdTemp == "" || dcIdTemp == "0") {
  1795. $.messager.alert("提示信息", "请选择或新建通道服务");
  1796. return;
  1797. }
  1798. operateDevObj.传输设备[subDevIndex - 1].数据通道ID = dcIdTemp;
  1799. var transIdentifyTemp = $("#txt_TransIdentify" + subDevIndex).val();
  1800. if (transIdentifyTemp.trim() == "") {
  1801. $.messager.alert("提示信息", "传输标识不能为空");
  1802. $("#txt_TransIdentify").focus();
  1803. return;
  1804. }
  1805. operateDevObj.传输设备[subDevIndex - 1].传输标识 = transIdentifyTemp;
  1806. break;
  1807. }
  1808. }
  1809. break;
  1810. }
  1811. if (index == (tabsConut - 1)) {
  1812. $.ShowMask("数据加载中,请稍等……");
  1813. var subDevCount = userStationTypes[operateDevObj.模板信息ID].子设备.split(",").length;
  1814. while (operateDevObj.通讯设备.length > subDevCount) {
  1815. operateDevObj.通讯设备.pop();
  1816. }
  1817. while (operateDevObj.传输设备.length > subDevCount) {
  1818. operateDevObj.传输设备.pop();
  1819. }
  1820. operateDevObj["管理数据卡"] = simManageFlag;
  1821. //获取图片名称和备注
  1822. var imgInfoArray = [];
  1823. for (var i = 0; i < imgNameArray.length; i++) {
  1824. var index = imgNameArray[i].图片索引
  1825. var imgUrl = imgNameArray[i].图片路径;
  1826. var remark = imgNameArray[i].备注;
  1827. if (index == "0") {
  1828. continue;
  1829. }
  1830. imgInfoArray.push({ '图片索引': index, '图片名称': imgUrl, '备注': remark });
  1831. }
  1832. operateDevObj["图片信息"] = imgInfoArray;
  1833. var deviceJSONString = JSON2.stringify(operateDevObj);
  1834. if (operateType == "Add") {
  1835. $.ajax(
  1836. {
  1837. url: "../WebServices/DeviceNodeService.asmx/AddDeviceNodeImage",
  1838. type: "POST",
  1839. data: { "loginIdentifer": window.parent.guid, 'deviceJSONString': deviceJSONString },
  1840. dataType: "text",
  1841. cache: false,
  1842. success: function (responseText) {
  1843. var data = eval("(" + $.xml2json(responseText) + ")");
  1844. if (data.Result) {
  1845. LoadTree("divAreaTree", mnId, true, false);
  1846. LoadTableData(true, operateDevObj["管理ID"]);
  1847. LoadComboboxData();
  1848. $.messager.alert("提示信息", "添加" + devLevelName + "成功");
  1849. $('#dlgDevice').dialog("close");
  1850. GetDataChannels();
  1851. }
  1852. else {
  1853. $.messager.alert("提示信息", "添加" + devLevelName + "失败");
  1854. }
  1855. $.HideMask();
  1856. },
  1857. error: function (XMLHttpRequest, textStatus, errorThrown) {
  1858. alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
  1859. $.HideMask();
  1860. }
  1861. });
  1862. }
  1863. else {
  1864. $.ajax(
  1865. {
  1866. url: "../WebServices/DeviceNodeService.asmx/ModifyDeviceNode",
  1867. type: "POST",
  1868. data: { "loginIdentifer": window.parent.guid, 'deviceJSONString': deviceJSONString },
  1869. dataType: "text",
  1870. cache: false,
  1871. success: function (responseText) {
  1872. var data = eval("(" + $.xml2json(responseText) + ")");
  1873. if (data.Result) {
  1874. LoadTree("divAreaTree", mnId, true, false);
  1875. LoadTableData(true, operateDevObj["管理ID"]);
  1876. LoadComboboxData();
  1877. $.messager.alert("提示信息", "修改" + devLevelName + "成功");
  1878. $('#dlgDevice').dialog("close");
  1879. GetDataChannels();
  1880. }
  1881. else {
  1882. $.messager.alert("提示信息", "修改" + devLevelName + "失败");
  1883. }
  1884. $.HideMask();
  1885. },
  1886. error: function (XMLHttpRequest, textStatus, errorThrown) {
  1887. alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
  1888. $.HideMask();
  1889. }
  1890. });
  1891. }
  1892. }
  1893. else {
  1894. if ((index + 1) == (tabsConut - 1)) {
  1895. $("#btn_Next").linkbutton({ text: "确定" });
  1896. }
  1897. else {
  1898. $("#btn_Next").linkbutton({ text: "下一步" });
  1899. }
  1900. tabsObj.tabs("select", index + 1);
  1901. }
  1902. }
  1903. //导出Excel
  1904. function btn_Export_Click() {
  1905. if (excelUrl == null || excelUrl == "") {
  1906. $.messager.alert("提示信息", "请先进行查询");
  1907. return;
  1908. }
  1909. location.href = excelUrl;
  1910. }
  1911. function cb_DevRefer_Click() {
  1912. if ($("#cb_DevRefer")[0].checked) {
  1913. $("#cbb_DevRefer").combotree({ 'disabled': false });
  1914. }
  1915. else {
  1916. $("#cbb_DevRefer").combotree({ 'disabled': true });
  1917. }
  1918. }
  1919. function OpenPickCoordinate() {
  1920. //显示弹出窗口
  1921. divFlyBar.style.display = "block";
  1922. document.getElementById("pickCoordinate").src = "PickLongitudeAndLattude.html?id=txt_DevPosition";
  1923. $("#divFlyBar").css("zIndex", 99999);
  1924. }
  1925. function Close() {
  1926. divFlyBar.style.display = "none";
  1927. }
  1928. function TranslateCoordinate() {
  1929. var value = $("#txt_DevPosition").val();
  1930. if (value == "") {
  1931. return;
  1932. }
  1933. var values = value.split('|');
  1934. if (values.length != 2) {
  1935. return;
  1936. }
  1937. if (values[0] == "" || values[1] == "") {
  1938. return;
  1939. }
  1940. var gpsPoint = new BMap.Point(values[0], values[1]);
  1941. var gpsPoints = [];
  1942. gpsPoints.push(gpsPoint);
  1943. var convertor = new BMap.Convertor();
  1944. convertor.translate(gpsPoints, 1, 5, TranslateCoordinateCallback)
  1945. }
  1946. TranslateCoordinateCallback = function (data) {
  1947. if (data.status === 0) {
  1948. var dbPoint = data.points[0];
  1949. $("#txt_DevPosition").val(dbPoint.lng + "|" + dbPoint.lat);
  1950. }
  1951. }
  1952. function SIM_Add_Click() {
  1953. $('#dlgSIM').dialog({ title: '添加数据卡', closed: false, iconCls: 'icon-mobile' });
  1954. $("#txt_ChargeTime").val(new Date().Format("yyyy-MM-dd HH:mm"));
  1955. // $("#txt_SimNum").textbox({ value:"",disabled: false });
  1956. $("#txt_ChargeAmount").textbox({ value: "" });
  1957. $("#txt_ChargePerson").textbox({ value: "" });
  1958. //operateType = "Add";
  1959. }
  1960. //================有关设备图片功能================//
  1961. function previewImage(file, imgNum) {
  1962. if (file.files && file.files[0]) {
  1963. var reader = new FileReader();
  1964. reader.readAsDataURL(file.files[0]);
  1965. }
  1966. }
  1967. var data06;
  1968. function InitImage() {
  1969. var unslider06 = $('#b06').unslider({
  1970. dots: true,
  1971. fluid: false
  1972. });
  1973. data06 = unslider06.data('unslider');
  1974. $('.unslider-arrow06').click(function () {
  1975. var fn = this.className.split(' ')[1];
  1976. data06[fn]();
  1977. });
  1978. }
  1979. function StartSlider() {
  1980. if (data06) {
  1981. data06.el.hover(data06.stop, data06.start);
  1982. data06.start();
  1983. $.smartMenu.setslider(data06);
  1984. }
  1985. }
  1986. function StopSlider() {
  1987. if (data06) {
  1988. data06.el.unbind("mouseenter").unbind("mouseleave");
  1989. data06.stop();
  1990. $.smartMenu.setslider(null);
  1991. }
  1992. }
  1993. function uploadImage() {
  1994. $("#fileupload1").fileupload({
  1995. url: "../WebServices/DeviceNodeService.asmx/DevImageStor",
  1996. dataType: "text",
  1997. sequentialUploads: true,
  1998. add: function (e, data) {
  1999. // $('#uploadProgress').progressbar('setValue', 0);
  2000. data.submit();
  2001. },
  2002. done: function (e, data) {
  2003. var iVal = this.id.replace("fileupload", "");
  2004. var result = eval("(" + $.xml2json(data.result) + ")");
  2005. if (result.Result) {
  2006. imgNameArray.splice(imgNameArray.length - 1, 0, { '显示序号': imgNameArray.length, '图片索引': result.ImageName.图片索引, '图片路径': "../DevImg/" + result.ImageName.图片名称, '备注': "" });
  2007. LoadImageControl();
  2008. }
  2009. else {
  2010. $.messager.alert("提示信息", "上传失败,原因:" + result.Message);
  2011. }
  2012. },
  2013. progressall: function (e, data) {
  2014. // var progress = parseInt(data.loaded / data.total * 100, 10);
  2015. // $('#uploadProgress').progressbar('setValue', progress);
  2016. }
  2017. });
  2018. // }
  2019. }
  2020. //鼠标右键菜单
  2021. function rightMenu(indexCol) {
  2022. $('#devBody').bind("mousedown", (function (e) {
  2023. if (e.which == 3) {
  2024. $('#smartMenu_').css("display", "none");
  2025. }
  2026. }));
  2027. $("body").on("mousedown", '#img_' + indexCol, MenuMethod);
  2028. }
  2029. function MenuMethod(e, event) {
  2030. if (e.which == 3) {
  2031. var opertion = {
  2032. name: "",
  2033. offsetX: 2,
  2034. offsetY: 2,
  2035. textLimit: 10,
  2036. beforeShow: $.noop,
  2037. afterShow: $.noop
  2038. }
  2039. var imageMenuData = [
  2040. [{
  2041. text: "删除",
  2042. func: function () {
  2043. //停止图片轮播
  2044. StopSlider();
  2045. //获取点击的控件的索引
  2046. var indexC = this.id.replace("img_", "");
  2047. var index = $("#" + this.id).attr("guid");
  2048. var src = $("#" + this.id).attr("src");
  2049. $.messager.confirm('提示信息', '您确定要删除该图片吗?', function (r) {
  2050. if (r) {
  2051. if (currentOperateDevId == null || currentOperateDevId == "") {
  2052. imgNameArray.splice(indexC - 1, 1);
  2053. LoadImageControl();
  2054. }
  2055. else {
  2056. $.ajax(
  2057. {
  2058. url: "../WebServices/DeviceNodeService.asmx/DeleteDeviceImage",
  2059. type: "POST",
  2060. data: { "loginIdentifer": window.parent.guid, 'devID': currentOperateDevId, 'index': index, 'imgUrl': src },
  2061. dataType: "text",
  2062. cache: false,
  2063. success: function (responseText) {
  2064. var data = eval("(" + $.xml2json(responseText) + ")");
  2065. if (data.Result) {
  2066. imgNameArray.splice(indexC - 1, 1);
  2067. LoadImageControl();
  2068. $.messager.alert("提示信息", "图片删除成功");
  2069. }
  2070. else {
  2071. StartSlider();
  2072. $.messager.alert("提示信息", "删除失败");
  2073. }
  2074. $.HideMask();
  2075. },
  2076. error: function (XMLHttpRequest, textStatus, errorThrown) {
  2077. alert(errorThrown + "\r\n" + XMLHttpRequest.responseText);
  2078. StartSlider();
  2079. $.HideMask();
  2080. }
  2081. });
  2082. }
  2083. }
  2084. else {
  2085. StartSlider();
  2086. }
  2087. });
  2088. }
  2089. },
  2090. {
  2091. text: "查看原图",
  2092. func: function () {
  2093. StopSlider();
  2094. //获取点击的控件的索引
  2095. var indexC = this.id.replace("img_", "");
  2096. CheckOrgImage(indexC);
  2097. }
  2098. },
  2099. {
  2100. text: remarkText,
  2101. func: function () {
  2102. //获取点击的控件的索引
  2103. var indexC = this.id.replace("img_", "");
  2104. for (var c = 0; c < imgNameArray.length; c++) {
  2105. var imgInfo = imgNameArray[c];
  2106. if (imgInfo.显示序号 == indexC) {
  2107. $("#reMarkImg").textbox("setValue", imgInfo.备注);
  2108. break;
  2109. }
  2110. }
  2111. StopSlider();
  2112. $('#reMarkHidden').val(indexC);
  2113. $('#remarkDiv').dialog({ closed: false });
  2114. }
  2115. }]
  2116. // ,
  2117. // [{
  2118. // text:"11",
  2119. // func:function(){
  2120. // alert("11");
  2121. // }
  2122. // }]
  2123. ];
  2124. //停止图片轮播
  2125. StopSlider();
  2126. $(this).smartMenu(imageMenuData, opertion);
  2127. $.smartMenu.setslider(data06);
  2128. //去掉默认的contextmenu事件,否则会和右键事件同时出现。
  2129. e.preventDefault();
  2130. }
  2131. }
  2132. //点击右键菜单的查看原图
  2133. function CheckOrgImage(indexC) {
  2134. var img = new Image();
  2135. img.src = $('#img_' + indexC).attr("src");
  2136. w = img.width;
  2137. h = img.height;
  2138. var BigW = 1340;
  2139. var BigH = 470;
  2140. var popupDivW = 0;
  2141. var popupDivH = 0;
  2142. if (w < BigW) {
  2143. popupDivW = w + 15;
  2144. }
  2145. else {
  2146. popupDivW == BigW;
  2147. }
  2148. if (h < BigH) {
  2149. popupDivH = h + 40;
  2150. }
  2151. else {
  2152. popupDivH = BigH;
  2153. }
  2154. $("<div id='popupDiv'><img id='imgPhoto' width='" + w + "' height='" + h + "' alt='' src='" + img.src + "' /></div>").dialog({
  2155. title: "查看原图",
  2156. width: popupDivW,
  2157. height: popupDivH,
  2158. closed: false,
  2159. cache: false,
  2160. modal: true,
  2161. onClose: function () {
  2162. $(this).dialog('destroy');
  2163. }
  2164. });
  2165. }
  2166. //点击查看原图层的关闭事件
  2167. function HidePopupDiv() {
  2168. document.getElementById("popupDiv").style.display = "none";
  2169. document.getElementById("divPhoto").innerHTML = "";
  2170. StartSlider();
  2171. }
  2172. //点击右键菜单的添加备注
  2173. function btnRemark_Ok_Click() {
  2174. var ind = $('#reMarkHidden').val().trim();
  2175. var remarkStr = $('#reMarkImg').val().trim();
  2176. //循环imgNameArray,得到显示序号为ind的,并对比备注信息是否一样
  2177. for (var i = 0; i < imgNameArray.length; i++) {
  2178. var sort = imgNameArray[i].显示序号;
  2179. if (sort == ind) {
  2180. var remarkOld = imgNameArray[i].备注;
  2181. if (remarkStr != remarkOld) {
  2182. imgNameArray[i].备注 = remarkStr;
  2183. }
  2184. break;
  2185. }
  2186. }
  2187. StartSlider();
  2188. $('#remarkDiv').dialog('close');
  2189. }
  2190. //点击添加备注层的关闭事件
  2191. function HideRemarkDiv() {
  2192. StartSlider();
  2193. $('#remarkDiv').dialog({ closed: true });
  2194. $('#reMarkHidden').val("");
  2195. $("#reMarkImg").textbox("setValue", "");
  2196. }
  2197. //================有关设备图片功能================//
  2198. function Close() {
  2199. divFlyBar.style.display = "none";
  2200. }
  2201. function Btn_OK_Click() {
  2202. var simNum = $("#txt_SimNum").textbox("getText");
  2203. if (!(/^\d{11,20}$/.test(simNum))) {
  2204. $.messager.alert("提示信息", "手机卡号格式不正确");
  2205. return;
  2206. }
  2207. var rechargeAmount = $("#txt_ChargeAmount").textbox("getText");
  2208. if (!(/^\d{1,}$/.test(rechargeAmount))) {
  2209. $.messager.alert("提示信息", "充值金额格式不正确");
  2210. return;
  2211. }
  2212. var simCardInfo = {};
  2213. simCardInfo["手机卡号"] = simNum;
  2214. simCardInfo["资费标准"] = $("#txt_Charge").combobox("getValue");
  2215. simCardInfo["充值时间"] = $("#txt_ChargeTime").val();
  2216. simCardInfo["充值金额"] = rechargeAmount;
  2217. simCardInfo["充值人"] = $("#txt_ChargePerson").textbox("getText");
  2218. $.ShowMask("正在添加,请稍等……");
  2219. $.ajax({
  2220. url: "../WebServices/SIMMaintainService.asmx/AddSIMCardInfo",
  2221. type: "POST",
  2222. data: {
  2223. "loginIdentifer": window.parent.guid,
  2224. "simCardInfo": JSON2.stringify(simCardInfo)
  2225. },
  2226. dataType: "text",
  2227. cache: false,
  2228. success: function (responseText) {
  2229. var data = eval("(" + $.xml2json(responseText) + ")");
  2230. if (data.Result) {
  2231. $.HideMask();
  2232. /*更新数据卡下拉框中数据*/
  2233. currentsimnum = simNum;
  2234. loadSimNumFlag = true;
  2235. GetSIMCardNumber();
  2236. //管理数据卡,则置管理标志为true
  2237. simManageFlag = true;
  2238. }
  2239. else {
  2240. simManageFlag = false;
  2241. $.HideMask();
  2242. $.messager.alert("提示信息", data.Message);
  2243. }
  2244. },
  2245. error: function (XMLHttpRequest, textStatus, errorThrown) {
  2246. $.HideMask();
  2247. $.messager.alert("提示信息", errorThrown + "\r\n" + XMLHttpRequest.responseText);
  2248. }
  2249. });
  2250. }