历史温度暂时提交

feasure-livedata
lld 2026-03-21 00:46:48 +08:00
parent 72a71589b4
commit 620d031eb7
19 changed files with 69 additions and 253 deletions

View File

@ -2,7 +2,7 @@
<template>
<view class="refresher-container">
<!-- 这里的图片请换成自己项目的图片 -->
<image class="refresher-image" mode="aspectFit" src="@/static/refresher_loading.gif"></image>
<image class="refresher-image" mode="aspectFit" src="https://img.xiaoces.com/photos/refresher_loading.gif"></image>
<text class="refresher-text">{{statusText}}</text>
</view>
</template>

View File

@ -9,7 +9,7 @@ module.exports = {
// 应用版本
version: "1.2.0",
// 应用logo
logo: "/static/logo200.png",
logo: "https://img.xiaoces.com/photos/logo200.png",
// 官方网站
site_url: "http://ruoyi.vip",
// 政策协议

View File

@ -8,6 +8,8 @@ import { getDicts } from "@/api/system/dict/data"
import "./utils/uni.css";
// 引入全局TuniaoUI
import TuniaoUI from 'tuniao-ui'
import VueCompositionAPI from '@vue/composition-api'
Vue.use(VueCompositionAPI)
// 引入TuniaoUI提供的vuex简写方法
let vuexStore = require('@/store/$tn.mixin.js')
Vue.use(plugins)

View File

@ -1,6 +1,7 @@
{
"dependencies": {
"crypto-js": "^4.2.0",
"echarts": "^5.3.0",
"mqtt": "^2.18.8"
}
}

View File

@ -27,6 +27,12 @@
"navigationBarTitleText": "数据中心"
}
},
// {
// "path": "pages/data/indexDemo",
// "style": {
// "navigationBarTitleText": "数据中心11"
// }
// },
{
"path": "pages/news/index",
"style": {
@ -181,6 +187,12 @@
"selectedIconPath": "static/images/tabbar/data_.png",
"text": "历史数据"
},
// {
// "pagePath": "pages/data/indexDemo",
// "iconPath": "static/images/tabbar/data.png",
// "selectedIconPath": "static/images/tabbar/data_.png",
// "text": "历史数据"
// },
{
"pagePath": "pages/news/index",
"iconPath": "static/images/tabbar/news.png",

View File

@ -8,14 +8,12 @@
</uni-col>
<uni-col :span="16">
<uni-datetime-picker v-model="dateRange" type="datetimerange" @change="changeDate"/>
<uni-datetime-picker v-model="dateRange" type="datetimerange" :end="end" @change="changeDate"/>
</uni-col>
</uni-row>
</view>
<qiun-data-charts
type="line"
:opts="opts"
@ -36,7 +34,7 @@
import { getHistoryData} from "../../api/system/data";
import {listAgri} from "../../api/system/assets/agri";
import store from "../../store";
import {parseTime} from "../../utils/agri";
import {parseTime,isIntervalMoreThanNDays} from "../../utils/agri";
export default {
data: function () {
@ -167,7 +165,10 @@ export default {
},
changeDate(date) {
// date[0]-date[1]
console.info("日期选择器:",date)
if (isIntervalMoreThanNDays(date[0],date[1],7)) {
this.$modal.alert('时间范围暂不支持查询超过7天以上的数据');
return;
}
if (date[0] === date[1]) {
this.dateRange[0] = parseTime(date[0], '{y}-{m}-{d} 00:00:00')
}

View File

@ -137,7 +137,7 @@ export default {
"value": 1,
"text": "设备编号",
}],
imageSrc:'/static/agri.png',
imageSrc:'https://img.xiaoces.com/photos/agri.png',
scrollHeight: 0,
// horizontal: 'right',
// vertical: 'bottom',

View File

@ -1,7 +1,7 @@
<template>
<view class="about-container">
<view class="header-section text-center">
<image style="width: 160rpx;height: 160rpx;" src="/static/logo200.png" mode="widthFix">
<image style="width: 160rpx;height: 160rpx;" src="https://img.xiaoces.com/photos/logo200.png" mode="widthFix">
</image>
<uni-title type="h2" title="智能农业移动端"></uni-title>
</view>

View File

@ -62,7 +62,7 @@ export default {
{
id: 1,
sender: '系统通知',
avatar: '/static/news.png',
avatar: 'https://img.xiaoces.com/photos/news.png',
preview: '您有一条新的系统通知,请查看',
time: '10:30',
unread: true,
@ -71,7 +71,7 @@ export default {
{
id: 2,
sender: '告警中心',
avatar: '/static/alarm.png',
avatar: 'https://img.xiaoces.com/photos/alarm.png',
preview: '您有一条新告警->',
time: '昨天',
unread: false,
@ -80,7 +80,7 @@ export default {
{
id: 3,
sender: '客服小美',
avatar: '/static/cs.png',
avatar: 'https://img.xiaoces.com/photos/cs.png',
preview: '您好,请问有什么可以帮到您的吗?',
time: '昨天',
unread: false,

View File

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="renderer" content="webkit">
<title><%= htmlWebpackPlugin.options.title %></title>
<link rel="shortcut icon" type="image/x-icon" href="<%= BASE_URL %>static/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="https://img.xiaoces.com/photos/favicon.ico">
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')
@ -17,4 +17,5 @@
<strong>本站点必须要开启JavaScript才能运行.</strong>
</noscript>
<div id="app"></div>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -64,13 +64,12 @@ const cfu = {
"xAxisDemo2":function(val, index, opts){return formatDateTime(val,'h:m')},
"seriesDemo1":function(val, index, series, opts){return val+'元'},
"tooltipDemo":function(item, category, index, opts){
if(index!==0) {
var unit = "%RH";
if (item.name.includes("温度")) {
unit = "℃";
}
return `${item.name}: ${item.data} ${unit}`
}
},
"tooltipDemo1":function(item, category, index, opts){
if(index==0){

View File

@ -284,6 +284,39 @@ export function checkTimeConflict(list) {
return { isConflict: false };
}
/**
* 判断两个时间的间隔是否大于 N
* @param {Date|String} time1 第一个时间
* @param {Date|String} time2 第二个时间
* @param {Number} days 天数
* @returns {Boolean} true=间隔大于N天false=不大于
*/
export function isIntervalMoreThanNDays(time1, time2, days) {
// 转换并校验时间
const d1 = new Date(time1);
const d2 = new Date(time2);
if (isNaN(d1.getTime()) || isNaN(d2.getTime())) {
throw new Error("时间格式不合法!");
}
// 计算两个时间的毫秒差(取绝对值,避免顺序问题)
const timeDiff = Math.abs(d1.getTime() - d2.getTime());
const oneDayMs = 24 * 60 * 60 * 1000;
// 转换为天数并比较
const dayDiff = timeDiff / oneDayMs;
return dayDiff > days;
}
// // 测试示例
// const start = "2026-03-01";
// const end = "2026-03-12";
// console.log(isIntervalMoreThanNDays(start, end, 10)); // true间隔11天大于10天
// console.log(isIntervalMoreThanNDays(start, end, 11)); // false刚好11天不大于
// ===================== 测试用例 =====================
/*
const rollerList = [

View File

@ -1,82 +0,0 @@
import Vue from 'vue'
import { mergeRecursive } from "@/utils/agri"
import DictMeta from './DictMeta'
import DictData from './DictData'
const DEFAULT_DICT_OPTIONS = {
types: [],
}
/**
* @classdesc 字典
* @property {Object} label 标签对象内部属性名为字典类型名称
* @property {Object} dict 字段数组内部属性名为字典类型名称
* @property {Array.<DictMeta>} _dictMetas 字典元数据数组
*/
export default class Dict {
constructor() {
this.owner = null
this.label = {}
this.type = {}
}
init(options) {
if (options instanceof Array) {
options = { types: options }
}
const opts = mergeRecursive(DEFAULT_DICT_OPTIONS, options)
if (opts.types === undefined) {
throw new Error('need dict types')
}
const ps = []
this._dictMetas = opts.types.map(t => DictMeta.parse(t))
this._dictMetas.forEach(dictMeta => {
const type = dictMeta.type
Vue.set(this.label, type, {})
Vue.set(this.type, type, [])
if (dictMeta.lazy) {
return
}
ps.push(loadDict(this, dictMeta))
})
return Promise.all(ps)
}
/**
* 重新加载字典
* @param {String} type 字典类型
*/
reloadDict(type) {
const dictMeta = this._dictMetas.find(e => e.type === type)
if (dictMeta === undefined) {
return Promise.reject(`the dict meta of ${type} was not found`)
}
return loadDict(this, dictMeta)
}
}
/**
* 加载字典
* @param {Dict} dict 字典
* @param {DictMeta} dictMeta 字典元数据
* @returns {Promise}
*/
function loadDict(dict, dictMeta) {
return dictMeta.request(dictMeta)
.then(response => {
const type = dictMeta.type
let dicts = dictMeta.responseConverter(response, dictMeta)
if (!(dicts instanceof Array)) {
console.error('the return of responseConverter must be Array.<DictData>')
dicts = []
} else if (dicts.filter(d => d instanceof DictData).length !== dicts.length) {
console.error('the type of elements in dicts must be DictData')
dicts = []
}
dict.type[type].splice(0, Number.MAX_SAFE_INTEGER, ...dicts)
dicts.forEach(d => {
Vue.set(dict.label[type], d.value, d.label)
})
return dicts
})
}

View File

@ -1,17 +0,0 @@
import DictOptions from './DictOptions'
import DictData from './DictData'
export default function(dict, dictMeta) {
const label = determineDictField(dict, dictMeta.labelField, ...DictOptions.DEFAULT_LABEL_FIELDS)
const value = determineDictField(dict, dictMeta.valueField, ...DictOptions.DEFAULT_VALUE_FIELDS)
return new DictData(dict[label], dict[value], dict)
}
/**
* 确定字典字段
* @param {DictData} dict
* @param {...String} fields
*/
function determineDictField(dict, ...fields) {
return fields.find(f => Object.prototype.hasOwnProperty.call(dict, f))
}

View File

@ -1,13 +0,0 @@
/**
* @classdesc 字典数据
* @property {String} label 标签
* @property {*} value 标签
* @property {Object} raw 原始数据
*/
export default class DictData {
constructor(label, value, raw) {
this.label = label
this.value = value
this.raw = raw
}
}

View File

@ -1,38 +0,0 @@
import { mergeRecursive } from "@/utils/agri"
import DictOptions from './DictOptions'
/**
* @classdesc 字典元数据
* @property {String} type 类型
* @property {Function} request 请求
* @property {String} label 标签字段
* @property {String} value 值字段
*/
export default class DictMeta {
constructor(options) {
this.type = options.type
this.request = options.request
this.responseConverter = options.responseConverter
this.labelField = options.labelField
this.valueField = options.valueField
this.lazy = options.lazy === true
}
}
/**
* 解析字典元数据
* @param {Object} options
* @returns {DictMeta}
*/
DictMeta.parse= function(options) {
let opts = null
if (typeof options === 'string') {
opts = DictOptions.metas[options] || {}
opts.type = options
} else if (typeof options === 'object') {
opts = options
}
opts = mergeRecursive(DictOptions.metas['*'], opts)
return new DictMeta(opts)
}

View File

@ -1,51 +0,0 @@
import { mergeRecursive } from "@/utils/agri"
import dictConverter from './DictConverter'
export const options = {
metas: {
'*': {
/**
* 字典请求方法签名为function(dictMeta: DictMeta): Promise
*/
request: (dictMeta) => {
console.log(`load dict ${dictMeta.type}`)
return Promise.resolve([])
},
/**
* 字典响应数据转换器方法签名为function(response: Object, dictMeta: DictMeta): DictData
*/
responseConverter,
labelField: 'label',
valueField: 'value',
},
},
/**
* 默认标签字段
*/
DEFAULT_LABEL_FIELDS: ['label', 'name', 'title'],
/**
* 默认值字段
*/
DEFAULT_VALUE_FIELDS: ['value', 'id', 'uid', 'key'],
}
/**
* 映射字典
* @param {Object} response 字典数据
* @param {DictMeta} dictMeta 字典元数据
* @returns {DictData}
*/
function responseConverter(response, dictMeta) {
const dicts = response.content instanceof Array ? response.content : response
if (dicts === undefined) {
console.warn(`no dict data of "${dictMeta.type}" found in the response`)
return []
}
return dicts.map(d => dictConverter(d, dictMeta))
}
export function mergeOptions(src) {
mergeRecursive(options, src)
}
export default options

View File

@ -1,33 +0,0 @@
import Dict from './Dict'
import { mergeOptions } from './DictOptions'
export default function(Vue, options) {
mergeOptions(options)
Vue.mixin({
data() {
if (this.$options === undefined || this.$options.dicts === undefined || this.$options.dicts === null) {
return {}
}
const dict = new Dict()
dict.owner = this
return {
dict
}
},
created() {
if (!(this.dict instanceof Dict)) {
return
}
options.onCreated && options.onCreated(this.dict)
this.dict.init(this.$options.dicts).then(() => {
options.onReady && options.onReady(this.dict)
this.$nextTick(() => {
this.$emit('dictReady', this.dict)
if (this.$options.methods && this.$options.methods.onDictReady instanceof Function) {
this.$options.methods.onDictReady.call(this, this.dict)
}
})
})
},
})
}