123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456 |
- $(function () {
- let url = ``;
- // let url = `http://192.168.0.135:8004`;
- let gName = "Gridtable";
- let grtable = document.querySelector("#gridtb");
- grtable.GM({
- gridManagerName: gName,
- height: "300px",
- ajaxData: function (setting) {
- console.log(setting.pageData,setting.sortData);
- // 传入分页及排序的配置项
- return getList(Object.assign({}, setting.pageData, setting.sortData));
- },
- ajaxType: "POST",
- supportCheckbox: false,
- supportAjaxPage: true,
- useNoTotalsMode: true,
- pageSize:10,
- columnData: [
- {
- key: "code",
- text: "硬件编号",
- },
- {
- key: "devTypeName",
- text: "硬件状态",
- },
- {
- key: "name",
- text: "热点名字",
- },
- ,
- {
- key: "id",
- width: "100px",
- align: "center",
- text: "查看",
- template: function (username) {
- var titleNode = document.createElement("div");
- // titleNode.attr('href', `https://www.lovejavascript.com/#!zone/blog/content.html?id=${rowObject.id}`);
- titleNode.setAttribute("title", username);
- titleNode.classList.add("plugin-action");
- titleNode.innerHTML = `<img src="./images/jiantou2.png" alt="">`;
- return titleNode;
- },
- },
- ],
- });
- // 阻止冒泡
- $(".hardware-list").on("click keydown keyup keypress", function (event) {
- event.stopPropagation();
- });
- //点击前往查看
- $(grtable).on("click", ".plugin-action", function (e) {
- const row = GridManager.getRowData(
- gName,
- e.currentTarget.parentElement.parentElement
- );
- console.log(row);
- window.hardwareHotList[row.id] &&
- window.hardwareHotList[row.id].showPannel({ focus: true });
- });
- $(".hard-header").click(function () {
- $(".hard-body").toggle();
- }
- )
-
- $("#moshi").click(function () {
- $(".air-con").hide();
- $(".oper-con").fadeToggle();
- }
- )
- $("#fengxiang").click(function () {
- $(".oper-con").hide();
- $(".air-con").fadeToggle();
- }
- )
-
- let getList = function (params) {
- return new Promise((resolve, reject) => {
- $.ajax({
- method: "POST",
- data : JSON.stringify({
- "devTypeId": "",
- "name": "",
- "pageNum": params.cPage,
- "pageSize": params.pSize,
- "searchKey": "",
- "userId": "77547f7af360c5d8e14932866b844d53"
- }),
- headers: {
- "Content-Type": "application/json",
- },
- dataType: "json",
- contentType: "application/json",
- url: url + "/api/device/listPage",
- success: function (data) {
- if (data.code == 0) {
- resolve({
- data:data.data.records,
- totals: data.data.total,
- });
- } else {
- reject(data);
- }
- },
- });
- });
- };
- window.changeDeviceStatus = function (item, paramCode, paramValue, success, fail) {//设置设备
- console.log(item);
- $(".waiting").addClass('showloading')
- let tmp = item.infoAttribute.hardware
- $.ajax({
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- dataType: "json",
- contentType: "application/json",
- url: url + `/api/device/control/${tmp.id}/${paramCode}/${paramValue}/03`,
-
- success: function (data) {
- console.log(data.msg)
- $(".waiting").removeClass('showloading')
- if (data.code === 0) {
- success && success()
- } else {
- fail && fail()
- }
- },error:function(){
- $(".waiting").removeClass('showloading')
- fail && fail()
- }
- });
- }
- window.loadTemperature = function (params={}) {
- let {id="temperature",val} = params
- //加载温度计
- var chartDom = document.getElementById(id);
- var myChart = echarts.init(chartDom);
-
-
- let option = {
- series: [
- {
- name: "Indicator",
- type: "gauge",
- data: [{
- value: val,
- name:'温度',
- itemStyle:{
- color: "#23EACF",
- fontSize:14
- },
- detail: {
- formatter: "{value}℃",
- color: "#23EACF",
- fontSize:24,
- offsetCenter: ['0%', '28%'],
- },
- title: {
- offsetCenter: ['0%', '80%'],
- color: "#fff",
- fontSize:20
- }
- }],
- radius: "100%",
- startAngle: 240,
- endAngle: -60,
- axisLine: {
- show: false
- },
- axisTick:{
- show: true,
- length:12,
- lineStyle:{
- color:'#339ED3'
- }
- },
- splitLine: {
- show: true,
- length:15,
- lineStyle:{
- color: "rgba(255, 255, 255, 1)",
- }
- },
- axisLabel: {
- color: "#23EACF"
- },
- pointer: {
- show: true,
- itemStyle:{
- color: "#23EACF"
- },
- width: 4.5,
- length: "46%"
- }
- },
- {
- name: "Indicator1",
- type: "gauge",
- data: [{
- value: val,
- detail:{
- show:false
- }
- }],
- radius: "50%",
- startAngle: 240,
- endAngle: -60,
- axisLine: {
- show: true,
- lineStyle:{
- width:5
- }
- },
- progress: {
- show: true,
- width:5,
- itemStyle:{
- color: "#23EACF"
- }
- },
- axisTick:{
- show: false,
- },
- splitLine: {
- show: false,
- },
- axisLabel: {
- show: false,
- },
- pointer: {
- show: false,
- }
- }
- ]
- }
- option && myChart.setOption(option, true);
- }
- window.loadAirConditioner = function (params={}) {
- let {id="air-conditioner",
- val='unset',
- type='unset',
- ifOn='unset',
- windSpeed='unset',
- fanPos='unset',
- name='unset',
- fanState='unset'} = params
- //开关
- if (ifOn!='unset') {
- if (ifOn) {
- $('.ac-body').show()
- $('.ac-switch').hide()
- }else{
- $('.ac-body').hide()
- $('.ac-switch').show()
- }
- }
- //名字
- if (name!='unset') {
- $('.ac-title').text(name)
- }
- //风向
- if (fanPos!='unset') {
- $('#fxDom').text('风向' + fanPos)
- }
- //风速
- if (windSpeed!='unset') {
- $('#fsDom').text(windSpeed)
- $(`.ac-left li[data-name='${windSpeed}']`).addClass("active").siblings().removeClass("active");
- }
- //模式
- if (type!='unset') {
- $(`#airmode span[data-name='${type}']`).addClass("activeTxt").siblings().removeClass("activeTxt");
- }
- if (val=='unset') {
- return
- }
- //加载温度计
- var chartDom = document.getElementById(id);
- var myChart = echarts.init(chartDom);
-
- let option = {
- series: [
- {
- name: "Indicator",
- type: "gauge",
- data: [{
- value: val,
- name:type,
- itemStyle:{
- color: "#23EACF",
- fontSize:14
- },
- detail: {
- offsetCenter: ['0%', '0'],
- formatter: "{value}℃",
- color: "#fff",
- fontSize:22
- },
- title: {
- offsetCenter: ['0%', '26%'],
- color: "#fff",
- fontSize:16
- }
- }],
- radius: "100%",
- startAngle: 220,
- endAngle: -40,
- progress: {
- show: true,
- roundCap:true,
- itemStyle:{
- color: "#23EACF"
- }
- },
- axisLine: {
- show: true,
- roundCap:true,
- lineStyle:{
- color: [[1, '#ffffff']]
- }
- },
- axisTick:{
- show: false
- },
- splitLine: {
- show: false
- },
- axisLabel: {
- show: false,
- },
- pointer: {
- show: false,
- }
- }
- ]
- }
- option && myChart.setOption(option, true);
- }
- window.loadMonitor = function (params={}) {
- let {id,url} = params
- console.log(id,url);
- var video = document.getElementById(id);
- if (Hls.isSupported()) {
- var hls = new Hls();
- hls.loadSource(url||'http://14.215.216.123:18080/rtp/00A153DF/hls.m3u8');
- hls.attachMedia(video);
- hls.on(Hls.Events.MEDIA_ATTACHED, function () {
- video.play();
- });
- }
- // hls.js is not supported on platforms that do not have Media Source Extensions (MSE) enabled.
- // When the browser has built-in HLS support (check using `canPlayType`), we can provide an HLS manifest (i.e. .m3u8 URL) directly to the video element throught the `src` property.
- // This is using the built-in support of the plain video element, without using hls.js.
- else if (video.canPlayType('application/vnd.apple.mpegurl')) {
- video.src = url||'http://14.215.216.123:18080/rtp/00A153DF/hls.m3u8';
- video.addEventListener('canplay', function () {
- video.play();
- });
- }
- }
- window.loadCalendar = function(params = {}){
- let { data,cellCb=()=>{},yearSelect=()=>{},monthCb=()=>{} } = params
- //日历方法
- $("#calendar").calendar({
- data: data, //记录数据
- work: [],//上班时间
- mode: "month",
- shwoLunar:false,
- width: 400,
- cellClick: function (data) {
- let item = data[0]
- cellCb(item)
- },
- yearSelect: function (yearText) {
- yearSelect(yearText)
- },
- monthClick: function (e, nextMonth, opts, me) {
- monthCb(nextMonth)
- }
- });
- }
- window.loadCalendar({
- data:[{
- 'startDate': "2021-5-18",//有监控的日期
- id:'传对应的id'
- }],
- //点击日期时间
- cellCb: (item)=> {
- console.log(item);
- },
- yearSelect: (yearText)=> {
- console.log(yearText);
- },
- monthCb: (nextMonth)=> {
- console.log(nextMonth);
- }
-
- })
- /*loadMonitor({
- id:"monitor",
- url:'http://14.215.216.123:18080/rtp/00A153DF/hls.m3u8'
- })
- loadAirConditioner({
- id:"air-conditioner",
- val:50,
- type:'冷风'
- }) */
- // loadAirConditioner({
- // name:'二楼-大会议室-04-空调',
- // val:50,
- // id:"air-conditioner",
- // type:'冷风',
- // ifOn:true,//开关机
- // windSpeed : "低风",//风速
- // fanPos : "上",//摆叶位置
- // fanState: true//摆叶状态
- // })
-
- });
|