This commit is contained in:
kerwincui
2024-03-17 14:59:23 +08:00
parent 3d44f4674c
commit 5539c1b6af
999 changed files with 115642 additions and 10757 deletions

View File

@@ -18,7 +18,9 @@
height: 100%;
padding: 16px 16px 10px 16px;
box-sizing: border-box;
background-image: url("../../assets/bigScreen/img/pageBg.png");
// 深蓝色背景
// background-image: radial-gradient(closest-side,#264194, #12214c);
background-color: #0e2e87;
background-size: cover;
background-position: center center;
}
@@ -112,13 +114,10 @@
.item {
width: 130px;
height: 36px;
border-radius: 18px 0px 0px 18px;
color: #00FBF8;
text-indent: 26px;
text-indent: 5px;
line-height: 36px;
font-size: 16px;
margin-right: 20px;
background: linear-gradient(to right, rgba(76, 245, 255, .5), rgba(76, 245, 255, 0));
}
}
}
@@ -264,4 +263,4 @@
100% {
transform: translate(100%, 0)
}
}
}

View File

@@ -1,95 +1,96 @@
<template>
<div id="index" ref="appRef" class="index_home" :class="{ pageisScale: true }">
<div id="index" ref="appRef" class="index_home" :class="{ pageisScale: true }">
<div class="bg">
<dv-loading v-if="loading">Loading...</dv-loading>
<div v-else class="host-body">
<!-- 头部 s -->
<div class="d-flex jc-center title_wrap">
<div class="zuojuxing"></div>
<div class="youjuxing"></div>
<div class="guang"></div>
<div class="d-flex jc-center">
<div class="title">
<span class="title-text">FastBee物联网平台</span>
<dv-loading v-if="loading">Loading...</dv-loading>
<div v-else class="host-body">
<!-- 头部 s -->
<div class="d-flex jc-center title_wrap">
<div class="zuojuxing"></div>
<div class="youjuxing"></div>
<div class="guang"></div>
<div class="d-flex jc-center">
<div class="title">
<span class="title-text">FastBee物联网平台</span>
</div>
</div>
<div class="timers ">
{{ dateYear }} {{ dateWeek }} {{ dateDay }}
<i class=" blq-icon-shezhi02" style="margin-left:10px" @click="showSetting"></i>
</div>
</div>
</div>
<div class="timers ">
{{ dateYear }} {{ dateWeek }} {{ dateDay }}
<i class=" blq-icon-shezhi02" style="margin-left:10px" @click="showSetting"></i>
</div>
<!-- 头部 e-->
<!-- 内容 s-->
<index></index>
<!-- 内容 e -->
</div>
<!-- 头部 e-->
<!-- 内容 s-->
<index></index>
<!-- 内容 e -->
</div>
</div>
<Setting ref="setting"/>
</div>
<Setting ref="setting" />
</div>
</template>
<script>
import drawMixin from "../../utils/bigScreen/drawMixin";
import { formatTime } from "../../utils/bigScreen/index.js";
import {
formatTime
} from "../../utils/bigScreen/index.js";
import Setting from './setting.vue'
import index from './indexs/index.vue'
export default {
mixins: [drawMixin],
components:{Setting,index},
data() {
return {
timing: null,
loading: true,
dateDay: null,
dateYear: null,
dateWeek: null,
weekday: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
};
},
filters: {
numsFilter(msg) {
return msg || 0;
mixins: [drawMixin],
components: {
Setting,
index
},
},
computed:{
data() {
return {
timing: null,
loading: true,
dateDay: null,
dateYear: null,
dateWeek: null,
weekday: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
};
},
filters: {
numsFilter(msg) {
return msg || 0;
},
},
computed: {
},
created(){
},
created() {
},
mounted() {
this.timeFn();
this.cancelLoading();
},
beforeDestroy() {
clearInterval(this.timing);
},
methods: {
showSetting(){
this.$refs.setting.init()
},
timeFn() {
this.timing = setInterval(() => {
this.dateDay = formatTime(new Date(), "HH: mm: ss");
this.dateYear = formatTime(new Date(), "yyyy-MM-dd");
this.dateWeek = this.weekday[new Date().getDay()];
}, 1000);
mounted() {
this.timeFn();
this.cancelLoading();
},
cancelLoading() {
setTimeout(() => {
this.loading = false;
}, 500);
beforeDestroy() {
clearInterval(this.timing);
},
methods: {
showSetting() {
this.$refs.setting.init()
},
timeFn() {
this.timing = setInterval(() => {
this.dateDay = formatTime(new Date(), "HH: mm: ss");
this.dateYear = formatTime(new Date(), "yyyy-MM-dd");
this.dateWeek = this.weekday[new Date().getDay()];
}, 1000);
},
cancelLoading() {
setTimeout(() => {
this.loading = false;
}, 500);
},
},
},
};
</script>
<style lang="scss" >
<style lang="scss">
@import "./home.scss";
@import '../../assets/bigScreen/css/theme/index.css';
@import "../../assets/bigScreen/css/index.scss";
@import "../../assets/bigScreen/css/index.scss"
</style>

View File

@@ -1,179 +1,176 @@
<template>
<div class="center_bottom">
<Echart :options="options" id="bottomLeftChart" class="echarts_bottom"></Echart>
</div>
<div class="center_bottom">
<div>
<dv-scroll-board :config="config" style="width:360px;height:175px" />
</div>
<div style="display:flex;height:115px;margin-top:30px;">
<div>
<dv-water-level-pond :config="configCpu" style="width:115px;height:100%;" />
<div style="text-align: center;margin-top:10px;color:#23cdd8;font-weight:600;">CPU</div>
</div>
<div style="margin:0 20px;">
<dv-water-level-pond :config="configMemery" style="width:115px;height:100%;" />
<div style="text-align: center;margin-top:10px;color:#23cdd8;font-weight:600;">内存</div>
</div>
<div style="">
<dv-water-level-pond :config="configDisk" style="width:115px;height:100%;" />
<div style="text-align: center;margin-top:10px;color:#23cdd8;font-weight:600;">系统盘</div>
</div>
</div>
</div>
</template>
<script>
import {currentGET} from '@/api/bigScreen/modules'
import {
getServer
} from "@/api/monitor/server";
export default {
data() {
return {
options: {},
};
},
props: {
},
mounted() {
this.getData()
},
methods: {
getData() {
this.pageflag = true
currentGET('big6', { companyName: this.companyName }).then(res => {
console.log('安装计划', res);
if (res.success) {
this.init(res.data)
} else {
this.pageflag = false
this.$Message({
text: res.msg,
type: 'warning'
})
}
})
data() {
return {
timer: null,
config: {},
data: [
['服务器名称', ''],
['服务器IP', ""],
['操作系统', ''],
['系统架构', ""],
['CPU核心数', ''],
['服务器内存', ""],
['Java名称', ''],
['Java版本', ''],
['Java启动时间', ""],
['Java运行时长', ""],
['Java占用内存', ''],
['Java总内存', ""]
],
// 服务器信息
server: {
jvm: {
name: "",
version: "",
startTime: "",
runTime: "",
used: "",
total: 100
},
sys: {
computerName: "",
osName: "",
computerIp: "",
osArch: ""
},
cpu: {
cpuNum: 1
},
mem: {
total: 2
}
},
configCpu: {
data: [50],
shape: 'roundRect',
formatter: '{value}%',
waveHeight: 10
},
configMemery: {
data: [50],
shape: 'roundRect',
formatter: '{value}%',
waveHeight: 10
},
configDisk: {
data: [50],
shape: 'roundRect',
formatter: '{value}%',
waveHeight: 10
}
};
},
init(newData) {
this.options = {
tooltip: {
trigger: "axis",
backgroundColor: "rgba(0,0,0,.6)",
borderColor: "rgba(147, 235, 248, .8)",
textStyle: {
color: "#FFF",
},
formatter: function (params) {
// 添加单位
var result = params[0].name + "<br>";
params.forEach(function (item) {
if (item.value) {
if(item.seriesName=="安装率"){
result += item.marker + " " + item.seriesName + " : " + item.value + "%</br>";
}else{
result += item.marker + " " + item.seriesName + " : " + item.value + "个</br>";
}
} else {
result += item.marker + " " + item.seriesName + " : - </br>";
}
});
return result;
}
props: {},
mounted() {
this.getServer();
},
beforeDestroy() {
this.clearData();
},
methods: {
/** 查询服务器信息 */
getServer() {
getServer().then(response => {
this.server = response.data;
this.config = {
rowNum: 6,
oddRowBGC: '',
evenRowBGC: '',
columnWidth: [105, 230],
data: [
['服务器名:', this.server.sys.computerName],
['服务器IP', this.server.sys.computerIp],
['操作系统:', this.server.sys.osName],
['系统架构:', this.server.sys.osArch],
['CPU核心', this.server.cpu.cpuNum],
['系统内存:', this.server.mem.total],
['Java名称', this.server.jvm.name],
['Java版本', this.server.jvm.version],
['启动时间:', this.server.jvm.startTime],
['运行时长:', this.server.jvm.runTime],
['运行内存:', this.server.jvm.used],
['JVM总内存', this.server.jvm.total],
],
};
// 计算CPU使用
let cpu = (this.server.cpu.used + this.server.cpu.sys) / (this.server.cpu.used + this.server.cpu.sys + this.server.cpu.free) * 100;
this.configCpu = {
data: [cpu.toFixed(1), cpu.toFixed(1) - 10],
shape: 'roundRect',
formatter: '{value}%',
waveHeight: 10
};
// 计算内存
let memery = this.server.mem.used / (this.server.mem.used + this.server.mem.free) * 100;
this.configMemery = {
data: [memery.toFixed(1), memery.toFixed(1) - 10],
shape: 'roundRect',
formatter: '{value}%',
waveHeight: 10
};
// 计算硬盘
let disk = Number(this.server.sysFiles[0].used.replace("GB", "")) / (Number(this.server.sysFiles[0].used.replace("GB", "")) + Number(this.server.sysFiles[0].free.replace("GB", ""))) * 100;
this.configDisk = {
data: [disk.toFixed(1), disk.toFixed(1) - 10],
shape: 'roundRect',
formatter: '{value}%',
waveHeight: 10
};
// 轮询
this.switper()
});
},
legend: {
data: ["已安装", "计划安装", "安装率"],
textStyle: {
color: "#B4B4B4"
},
top: "0"
},
grid: {
left: "50px",
right: "40px",
bottom: "30px",
top: "20px",
},
xAxis: {
data: newData.category,
axisLine: {
lineStyle: {
color: "#B4B4B4"
clearData() {
if (this.timer) {
clearInterval(this.timer)
this.timer = null
}
},
axisTick: {
show: false
}
},
yAxis: [
{
splitLine: { show: false },
axisLine: {
lineStyle: {
color: "#B4B4B4"
}
},
axisLabel: {
formatter: "{value}"
//轮询
switper() {
if (this.timer) {
return
}
},
{
splitLine: { show: false },
axisLine: {
lineStyle: {
color: "#B4B4B4"
}
},
axisLabel: {
formatter: "{value}% "
}
}
],
series: [
{
name: "已安装",
type: "bar",
barWidth: 10,
itemStyle: {
normal: {
barBorderRadius: 5,
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: "#956FD4" },
{ offset: 1, color: "#3EACE5" }
])
}
},
data: newData.barData
},
{
name: "计划安装",
type: "bar",
barGap: "-100%",
barWidth: 10,
itemStyle: {
normal: {
barBorderRadius: 5,
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: "rgba(156,107,211,0.8)" },
{ offset: 0.2, color: "rgba(156,107,211,0.5)" },
{ offset: 1, color: "rgba(156,107,211,0.2)" }
])
}
},
z: -12,
data: newData.lineData
},
{
name: "安装率",
type: "line",
smooth: true,
showAllSymbol: true,
symbol: "emptyCircle",
symbolSize: 8,
yAxisIndex: 1,
itemStyle: {
normal: {
color: "#F02FC2"
}
},
data: newData.rateData
},
]
}
let looper = (a) => {
this.getServer();
};
this.timer = setInterval(looper, 60000);
},
}
},
}
</script>
<style lang="scss" scoped>
.center_bottom {
width: 100%;
height: 100%;
.echarts_bottom {
width: 100%;
height: 100%;
}
padding: 10px;
display: flex;
}
</style>
</style>

View File

@@ -1,398 +1,392 @@
<template>
<div class="centermap">
<div class="centermap">
<div class="maptitle">
<div class="zuo"></div>
<span class="titletext">{{ maptitle }}</span>
<div class="you"></div>
<div class="zuo"></div>
<span class="titletext">设备分布图</span>
<div class="you"></div>
</div>
<div class="mapwrap">
<dv-border-box-13 >
<div class="quanguo" @click="getData(-1)" v-if="code !== 'china' && userCode == -1">
中国
</div>
<Echart id="CenterMap" :options="options" ref="CenterMap" />
</dv-border-box-13>
<div style="height:640px;background-color:#0e2e87;">
<dv-border-box-8>
<div ref="map" style="height:600px;width:760px;padding:10px;"></div>
</dv-border-box-8>
</div>
</div>
</div>
</template>
<script>
import xzqCode from "../../../utils/bigScreen/map/xzqCode";
import { currentGET } from '@/api/bigScreen/modules'
import { GETNOBASE } from '@/api/bigScreen/api'
import {
loadBMap
} from '@/utils/map.js'
//安装的是echarts完整包里面包含百度地图扩展路径为 echarts/extension/bmap/bmap.js将其引入
//ECharts的百度地图扩展可以在百度地图上展现点图线图热力图等可视化
require('echarts/extension/bmap/bmap')
import {
listAllDeviceShort,
} from "@/api/iot/device";
export default {
data() {
return {
maptitle: "设备分布图",
options: {},
code: "china",
userCode: -1,//-1 代表中国 用户权限的行政区code
echartBindClick: false
};
},
created() { },
mounted() {
// console.log(xzqCode);
this.getData()
},
methods: {
getData(code) {
currentGET('big8',{regionCode:code}).then(res => {
console.log('设备分布', res);
if (res.success) {
if (!code) {
this.userCode = res.data.regionCode;
}
this.getGeojson(res.data.regionCode, res.data.dataList);
this.mapclick();
} else {
this.$Message.warning(res.msg)
}
})
data() {
return {
// 设备列表
deviceList: [],
};
},
getGeojson(name, mydata) {
if (name == -1) {
name = 'china'
}
this.code = name;
GETNOBASE("./map-geojson/" + name + ".json").then((res) => {
// console.log('地图行政区划', name, res);
let cityCenter = {};
let arr = res.features;
arr.map((item) => {
cityCenter[item.properties.name] =
item.properties.centroid || item.properties.center;
});
let newData = [];
// console.log('中心点',cityCenter);
mydata.map((item) => {
if (cityCenter[item.name]) {
let color = this.getColor(item.value);
newData.push({
name: item.name,
value: cityCenter[item.name].concat(item.value),
// itemStyle: {
// color: color,
// borderColor: color,
// // borderWidth: 4,
// },
created() {
this.getAllDevice();
},
beforeDestroy() {
this.clearData();
},
methods: {
clearData() {
if (this.timer) {
clearInterval(this.timer)
this.timer = null
}
},
//轮询
switper() {
if (this.timer) {
return
}
let looper = (a) => {
this.getAllDevice();
};
this.timer = setInterval(looper, 120000);
},
/**查询所有设备 */
getAllDevice() {
listAllDeviceShort(this.queryParams).then(response => {
this.deviceList = response.rows;
this.deviceCount = response.total;
this.loadMap();
// 轮询
this.switper()
})
},
/**加载地图*/
loadMap() {
loadBMap().then(() => {
this.getmap();
});
}
});
let mapjson = echarts.getMap(name);
if (!mapjson) {
echarts.registerMap(name, res);
}
this.init(name, mydata, newData);
});
},
getColor(num) {
if (num > 0 && num < 9) {
return "#035cf5";
} else if (num > 10 && num < 49) {
return "#3375e4";
} else if (num > 50 && num < 199) {
return "#6797ef";
} else if (num > 200 && num < 499) {
return "#96b5ef";
} else if (num > 500 && num < 9999) {
return "#bacae8";
} else if (num > 1000) {
return "#3FF4FF";
} else {
return "";
}
},
init(name, data, data2) {
let top = 45;
let zoom = 1.05;
if (name == "china") {
top = 140;
zoom = 1.42;
}
},
let option = {
backgroundColor: "rgba(0,0,0,0)",
tooltip: {
show: false,
},
legend: {
show: false,
},
visualMap: {
left: 20,
bottom: 20,
pieces: [
{ gte: 1000, label: "1000个以上" }, // 不指定 max表示 max 为无限大Infinity
{ gte: 600, lte: 999, label: "600-999个" },
{ gte: 200, lte: 599, label: "200-599个" },
{ gte: 50, lte: 199, label: "49-199个" },
{ gte: 10, lte: 49, label: "10-49个" },
{ lte: 9, label: "1-9个" }, // 不指定 min表示 min 为无限大(-Infinity
],
inRange: {
// 渐变颜色,从小到大
color: [
"#c3d7df",
"#5cb3cc",
"#8abcd1",
"#66a9c9",
"#2f90b9",
"#1781b5",
],
},
textStyle: {
color: "#fff",
},
},
geo: {
map: name,
roam: false,
selectedMode: false, //是否允许选中多个区域
zoom: zoom,
top: top,
aspectScale: 0.78,
tooltip: {
show: false,
},
label: {
show: false,
}, //地图中文字内容及样式控制
itemStyle: {
areaColor: "rgba(0,0,0,0)",
borderColor: "rgba(0,0,0,0)",
},
emphasis: {
disabled: true,
},
},
series: [
{
name: "MAP",
type: "map",
mapType: name,
aspectScale: 0.78,
data: data,
// data: [1,100],
/** 地图 */
getmap() {
var myChart = this.$echarts.init(this.$refs.map);
var option;
selectedMode: false, //是否允许选中多个区域
zoom: zoom,
geoIndex: 1,
top: top,
tooltip: {
show: true,
formatter: function (params) {
if (params.data) {
return params.name + "" + params.data["value"];
} else {
return params.name;
// 单击事件
myChart.on('click', (params) => {
if (params.data.deviceId) {
this.$router.push({
path: '/iot/device-edit',
query: {
t: Date.now(),
deviceId: params.data.deviceId,
}
});
}
},
backgroundColor: "rgba(0,0,0,.6)",
borderColor: "rgba(147, 235, 248, .8)",
textStyle: {
color: "#FFF",
},
},
label: {
show: false,
color: "#000",
// position: [-10, 0],
formatter: function (val) {
// console.log(val)
if (val.data !== undefined) {
return val.name.slice(0, 2);
} else {
return "";
}
},
rich: {},
emphasis: { show: false },
},
itemStyle: {
borderColor: "rgba(147, 235, 248, .8)",
borderWidth: 1,
areaColor: {
type: "radial",
x: 0.5,
y: 0.5,
r: 0.8,
colorStops: [
{
offset: 0,
color: "rgba(147, 235, 248, 0)", // 0% 处的颜色
},
{
offset: 1,
color: "rgba(147, 235, 248, .2)", // 100% 处的颜色
},
],
globalCoord: false, // 缺为 false
},
shadowColor: "rgba(128, 217, 248, .3)",
shadowOffsetX: -2,
shadowOffsetY: 2,
shadowBlur: 10,
emphasis: {
areaColor: "#389BB7",
borderWidth: 1,
},
},
},
{
data: data2,
type: "effectScatter",
coordinateSystem: "geo",
symbolSize: function (val) {
return 4;
// return val[2] / 50;
},
legendHoverLink: true,
showEffectOn: "render",
rippleEffect: {
// period: 4,
scale: 6,
color: "rgba(255,255,255, 1)",
brushType: "fill",
},
tooltip: {
show: true,
formatter: function (params) {
if (params.data) {
return params.name + "" + params.data["value"][2];
} else {
return params.name;
}
},
backgroundColor: "rgba(0,0,0,.6)",
borderColor: "rgba(147, 235, 248, .8)",
textStyle: {
color: "#FFF",
},
},
label: {
formatter: (param) => {
return param.name.slice(0, 2);
},
});
fontSize: 11,
offset: [0, 2],
position: "bottom",
textBorderColor: "#fff",
textShadowColor: "#000",
textShadowBlur: 10,
textBorderWidth: 0,
color: "#FFF",
show: true,
},
// colorBy: "data",
itemStyle: {
color: "rgba(255,255,255,1)",
borderColor: "rgba(2255,255,255,2)",
borderWidth: 4,
shadowColor: "#000",
shadowBlur: 10,
},
},
],
};
this.options = option;
// 格式化数据
let convertData = function (data, status) {
var res = [];
for (var i = 0; i < data.length; i++) {
var geoCoord = [data[i].longitude, data[i].latitude];
if (geoCoord && data[i].status == status) {
res.push({
name: data[i].deviceName,
value: geoCoord,
serialNumber: data[i].serialNumber,
status: data[i].status,
isShadow: data[i].isShadow,
firmwareVersion: data[i].firmwareVersion,
networkAddress: data[i].networkAddress,
productName: data[i].productName,
activeTime: data[i].activeTime == null ? '' : data[i].activeTime,
deviceId: data[i].deviceId,
serialNumber: data[i].serialNumber,
locationWay: data[i].locationWay,
});
}
}
return res;
};
option = {
tooltip: {
trigger: 'item',
backgroundColor: "rgba(58,73,116,0.7)",
textStyle: {
color: "rgba(65,235,246,1)"
},
formatter: function (params) {
var htmlStr = '<div style="padding:5px;line-height:28px;">';
htmlStr += "设备名称: <span style='color:#FFF'>" + params.data.name + "</span><br />";
htmlStr += "设备编号: " + params.data.serialNumber + "<br />";
htmlStr += "设备状态: ";
if (params.data.status == 1) {
htmlStr += "<span style='color:#E6A23C'>未激活</span>" + "<br />";
} else if (params.data.status == 2) {
htmlStr += "<span style='color:#F56C6C'>禁用</span>" + "<br />";
} else if (params.data.status == 3) {
htmlStr += "<span style='color:#67C23A'>在线</span>" + "<br />";
} else if (params.data.status == 4) {
htmlStr += "<span style='color:#909399'>离线</span>" + "<br />";
}
if (params.data.isShadow == 1) {
htmlStr += "设备影子: " + "<span style='color:#67C23A'>启用</span>" + "<br />";
} else {
htmlStr += "设备影子: " + "<span style='color:#909399'>未启用</span>" + "<br />";
}
htmlStr += "产品名称: " + params.data.productName + "<br />";
htmlStr += "固件版本: Version " + params.data.firmwareVersion + "<br />";
htmlStr += "激活时间: " + params.data.activeTime + "<br />";
htmlStr += "定位方式: ";
if (params.data.locationWay == 1) {
htmlStr += "自动定位" + "<br />";
} else if (params.data.locationWay == 2) {
htmlStr += "设备定位" + "<br />";
} else if (params.data.locationWay == 3) {
htmlStr += "自定义位置" + "<br />";
} else {
htmlStr += "未知" + "<br />";
}
htmlStr += "所在地址: " + params.data.networkAddress + "<br />";
htmlStr += '</div>';
return htmlStr;
}
},
bmap: {
center: [106, 37.5],
zoom: 5,
// 大屏用zomm缩放导致地图缩放中心点会偏移
roam: 'move',
mapStyle: {
styleJson: [{
featureType: 'water',
elementType: 'all',
stylers: {
color: '#3863db'
}
},
{
featureType: 'land',
elementType: 'all',
stylers: {
color: '#0e2e87'
}
},
{
featureType: 'railway',
elementType: 'all',
stylers: {
visibility: 'off'
}
},
{
featureType: 'highway',
elementType: 'all',
stylers: {
visibility: 'off',
color: '#fdfdfd'
}
},
{
featureType: 'highway',
elementType: 'labels',
stylers: {
visibility: 'off',
visibility: 'off'
}
},
{
featureType: 'arterial',
elementType: 'geometry',
stylers: {
visibility: 'off',
color: '#fefefe'
}
},
{
featureType: 'arterial',
elementType: 'geometry.fill',
stylers: {
visibility: 'off',
color: '#fefefe'
}
},
{
featureType: 'poi',
elementType: 'all',
stylers: {
visibility: 'off',
visibility: 'off'
}
},
{
featureType: 'green',
elementType: 'all',
stylers: {
visibility: 'off'
}
},
{
featureType: 'subway',
elementType: 'all',
stylers: {
visibility: 'off'
}
},
{
featureType: 'manmade',
elementType: 'all',
stylers: {
visibility: 'off',
color: '#d1d1d1'
}
},
{
featureType: 'local',
elementType: 'all',
stylers: {
visibility: 'off',
color: '#d1d1d1'
}
},
{
featureType: 'arterial',
elementType: 'labels',
stylers: {
visibility: 'off'
}
},
{
featureType: 'boundary',
elementType: 'all',
stylers: {
color: '#23cdd8'
}
},
{
featureType: 'building',
elementType: 'all',
stylers: {
visibility: 'off',
color: '#d1d1d1'
}
},
{
featureType: 'label',
elementType: 'labels.text.fill',
stylers: {
color: '#264194',
visibility: 'off'
}
}
]
}
},
series: [{
type: 'scatter',
coordinateSystem: 'bmap',
data: convertData(this.deviceList, 1),
symbolSize: 10,
itemStyle: {
color: '#e8fc05'
}
},
{
type: 'scatter',
coordinateSystem: 'bmap',
data: convertData(this.deviceList, 2),
symbolSize: 10,
itemStyle: {
color: '#fc3464'
}
}, {
type: 'scatter',
coordinateSystem: 'bmap',
data: convertData(this.deviceList, 4),
symbolSize: 10,
itemStyle: {
color: '#eee'
}
}, {
type: 'effectScatter',
coordinateSystem: 'bmap',
data: convertData(this.deviceList, 3),
symbolSize: 12,
showEffectOn: 'render',
rippleEffect: {
brushType: 'stroke',
scale: 5
},
label: {
formatter: '{b}',
position: 'right',
show: false
},
itemStyle: {
color: '#5de88e',
shadowBlur: 100,
shadowColor: '#333'
},
zlevel: 1
}
]
};
option && myChart.setOption(option, true);
},
},
message(text) {
this.$Message({
text: text,
type: 'warning'
})
},
mapclick() {
if (this.echartBindClick || this.userCode !== -1) return
//单击切换到级地图当mapCode有值,说明可以切换到下级地图
this.$refs.CenterMap.chart.on("click", (params) => {
// console.log(params);
let xzqData = xzqCode[params.name];
if (xzqData) {
this.getData(xzqData.adcode);
} else {
this.message("暂无下级地市!");
}
});
this.echartBindClick = true
},
},
};
</script>
<style lang='scss' scoped>
.centermap {
margin-bottom: 30px;
.maptitle {
height: 60px;
display: flex;
justify-content: center;
padding-top: 10px;
box-sizing: border-box;
.titletext {
font-size: 28px;
font-weight: 900;
letter-spacing: 6px;
background: linear-gradient(92deg,
#0072ff 0%,
#00eaff 48.8525390625%,
#01aaff 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
margin: 0 10px;
}
.zuo,
.you {
background-size: 100% 100%;
width: 29px;
height: 20px;
margin-top: 8px;
}
.zuo {
background: url("../../../assets/bigScreen/img/xiezuo.png") no-repeat;
}
.you {
background: url("../../../assets/bigScreen/img/xieyou.png") no-repeat;
}
}
.mapwrap {
height: 548px;
width: 100%;
// padding: 0 0 10px 0;
box-sizing: border-box;
position: relative;
.quanguo {
position: absolute;
right: 20px;
top: -46px;
width: 80px;
height: 28px;
border: 1px solid #00eded;
border-radius: 10px;
color: #00f7f6;
text-align: center;
line-height: 26px;
letter-spacing: 6px;
cursor: pointer;
box-shadow: 0 2px 4px rgba(0, 237, 237, 0.5),
0 0 6px rgba(0, 237, 237, 0.4);
}
}
<style lang="scss">
/* 清除地图LOGO */
.BMap_cpyCtrl {
display: none !important;
}
</style>
.anchorBL {
display: none !important;
}
.centermap {
.maptitle {
height: 60px;
display: flex;
justify-content: center;
padding-top: 10px;
box-sizing: border-box;
.titletext {
font-size: 28px;
font-weight: 900;
letter-spacing: 6px;
background: linear-gradient(92deg,
#0072ff 0%,
#00eaff 48.8525390625%,
#01aaff 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
margin: 0 10px;
}
.zuo,
.you {
background-size: 100% 100%;
width: 29px;
height: 20px;
margin-top: 8px;
}
.zuo {
background: url("../../../assets/bigScreen/img/xiezuo.png") no-repeat;
}
.you {
background: url("../../../assets/bigScreen/img/xieyou.png") no-repeat;
}
}
}
</style>

View File

@@ -1,53 +1,39 @@
<template>
<div class="contents">
<div class="contents">
<div class="contetn_left">
<div class="pagetab">
<!-- <div class="item">实时监测</div> -->
</div>
<ItemWrap class="contetn_left-top contetn_lr-item" title="设备总览">
<LeftTop/>
</ItemWrap>
<ItemWrap class="contetn_left-center contetn_lr-item" title="用户总览">
<LeftCenter />
</ItemWrap>
<ItemWrap
class="contetn_left-bottom contetn_lr-item"
title="设备提醒"
style="padding: 0 10px 16px 10px"
>
<LeftBottom />
</ItemWrap>
<div class="pagetab">
<dv-decoration-12 style="width:30px;height:30px;" />
<div class="item">实时监测数据</div>
</div>
<ItemWrap class="contetn_left-top contetn_lr-item" title="设备总览">
<LeftTop />
</ItemWrap>
<ItemWrap class="contetn_left-center contetn_lr-item" title="Mqtt统计">
<LeftCenter />
</ItemWrap>
<ItemWrap class="contetn_left-bottom contetn_lr-item" title="监测数据" style="padding: 0 10px 16px 10px">
<LeftBottom />
</ItemWrap>
</div>
<div class="contetn_center">
<CenterMap class="contetn_center_top" />
<ItemWrap class="contetn_center-bottom" title="安装计划">
<CenterBottom />
</ItemWrap>
<CenterMap class="contetn_center_top" />
<ItemWrap class="contetn_center-bottom" title="服务器信息">
<CenterBottom />
</ItemWrap>
</div>
<div class="contetn_right">
<ItemWrap
class="contetn_left-bottom contetn_lr-item"
title="报警次数"
>
<RightTop />
</ItemWrap>
<ItemWrap
class="contetn_left-bottom contetn_lr-item"
title="报警排名(TOP8)"
style="padding: 0 10px 16px 10px"
>
<RightCenter />
</ItemWrap>
<ItemWrap
class="contetn_left-bottom contetn_lr-item"
title="数据统计图 "
>
<RightBottom />
</ItemWrap>
<ItemWrap class="contetn_left-bottom contetn_lr-item" title="Mqtt状态">
<RightTop />
</ItemWrap>
<ItemWrap class="contetn_left-bottom contetn_lr-item" title="Mqtt消息" style="padding: 0 10px 16px 10px">
<RightCenter />
</ItemWrap>
<ItemWrap class="contetn_left-bottom contetn_lr-item" title="设备提醒 ">
<RightBottom />
</ItemWrap>
</div>
</div>
</div>
</template>
<script>
@@ -61,91 +47,92 @@ import RightCenter from "./right-center.vue";
import RightBottom from "./right-bottom.vue";
export default {
components: {
LeftTop,
LeftCenter,
LeftBottom,
CenterMap,
RightTop,
RightCenter,
RightBottom,
CenterBottom,
},
data() {
return {
};
},
filters: {
numsFilter(msg) {
return msg || 0;
components: {
LeftTop,
LeftCenter,
LeftBottom,
CenterMap,
RightTop,
RightCenter,
RightBottom,
CenterBottom,
},
},
created() {
},
data() {
return {
mounted() {},
methods: {
},
};
},
filters: {
numsFilter(msg) {
return msg || 0;
},
},
created() {},
mounted() {},
methods: {
},
};
</script>
<style lang="scss" scoped>
// 内容
.contents {
.contetn_left,
.contetn_right {
width: 540px;
box-sizing: border-box;
// padding: 16px 0;
}
.contetn_center {
width: 720px;
}
.contetn_left,
.contetn_right {
width: 500px;
box-sizing: border-box;
// padding: 16px 0;
}
//左右两侧 三个块
.contetn_lr-item {
height: 310px;
}
.contetn_center {
width: 800px;
}
.contetn_center_top {
width: 100%;
}
//左右两侧 三个块
.contetn_lr-item {
height: 310px;
}
// 中间
.contetn_center {
display: flex;
flex-direction: column;
justify-content: space-around;
}
.contetn_center_top {
width: 100%;
}
.contetn_center-bottom {
height: 315px;
}
// 中间
.contetn_center {
display: flex;
flex-direction: column;
justify-content: space-around;
}
//左边 右边 结构一样
.contetn_left,
.contetn_right {
display: flex;
flex-direction: column;
justify-content: space-around;
position: relative;
.contetn_center-bottom {
height: 255px;
}
}
//左边 右边 结构一样
.contetn_left,
.contetn_right {
display: flex;
flex-direction: column;
justify-content: space-around;
position: relative;
}
}
@keyframes rotating {
0% {
-webkit-transform: rotate(0) scale(1);
transform: rotate(0) scale(1);
}
50% {
-webkit-transform: rotate(180deg) scale(1.1);
transform: rotate(180deg) scale(1.1);
}
100% {
-webkit-transform: rotate(360deg) scale(1);
transform: rotate(360deg) scale(1);

View File

@@ -1,246 +1,100 @@
<template>
<div
v-if="pageflag"
class="left_boottom_wrap beautify-scroll-def"
:class="{ 'overflow-y-auto': !sbtxSwiperFlag }"
>
<component :is="components" :data="list" :class-option="defaultOption">
<ul class="left_boottom">
<li class="left_boottom_item" v-for="(item, i) in list" :key="i">
<span class="orderNum doudong">{{ i + 1 }}</span>
<div class="inner_right">
<div class="dibu"></div>
<div class="flex">
<div class="info">
<span class="labels">设备ID</span>
<span class="contents zhuyao doudong wangguan">
{{ item.gatewayno }}</span
>
</div>
<div class="info">
<span class="labels">时间</span>
<span class="contents " style="font-size: 12px">
{{ item.createTime }}</span
>
</div>
<div v-if="pageflag" style="overflow:hidden;width: 100%;height:250px;font-size:12px;line-height:24px;">
<vue-seamless-scroll :data="deviceLogList" :class-option="defaultOption">
<div style="display:flex;margin-bottom:10px;border-bottom:2px dashed #23cdd8;color:#bbb;" v-for="(item, i) in deviceLogList" :key="i">
<span style="width:50px;color:#23cdd8;font-size:16px;line-height:48px;font-weight:bolder;">{{ i + 1 }}</span>
<div style="display:flex;flex-wrap: wrap;">
<div style="width:200px;">
<span>设备编号</span>
<span style="color:#23cdd8">{{ item.serialNumber }}</span>
</div>
<div style="width:150px;white-space: nowrap;overflow:hidden;text-overflow:ellipsis;">
<span>标识符</span>
<span style="color:#fff;">{{item.identity}}</span>
</div>
<div style="width:60px;align-items: flex-end;text-align: right;">
<span v-if="item.logType==1" style="color:#ffdb5c">属性上报</span>
<span v-else-if="item.logType==2" style="color:#ffdb5c">功能调用</span>
<span v-else-if="item.logType==3" style="color:#fb7293">事件上报</span>
<span v-else-if="item.logType==4" style="color:#ffdb5c">设备升级</span>
<span v-else-if="item.logType==5" style="color:#9fe6b8">设备上线</span>
<span v-else-if="item.logType==6" style="color:#ff9f7f">设备离线</span>
</div>
<div style="width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
<span>上报时间</span>
<span style="color:#fff;">{{ item.createTime }}</span>
</div>
<div style="margin-bottom:10px;width:210px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
<span>上报值</span>
<span style="color:#fff;">{{item.logValue }}</span>
</div>
</div>
</div>
</vue-seamless-scroll>
</div>
<span
class="types doudong"
:class="{
typeRed: item.onlineState == 0,
typeGreen: item.onlineState == 1,
}"
>{{ item.onlineState == 1 ? "上线" : "下线" }}</span
>
<div class="info addresswrap">
<span class="labels">地址</span>
<span class="contents ciyao" style="font-size: 12px">
{{ addressHandle(item) }}</span
>
</div>
</div>
</li>
</ul>
</component>
</div>
<Reacquire v-else @onclick="getData" style="line-height: 200px" />
<Reacquire v-else @onclick="getData" style="line-height:200px;color:#23cdd8;margin-left:210px;">
重新获取
</Reacquire>
</template>
<script>
import { currentGET } from "@/api/bigScreen/modules";
import vueSeamlessScroll from "vue-seamless-scroll"; // vue2引入方式
import Kong from "../components/kong.vue";
import vueSeamlessScroll from "vue-seamless-scroll";
import {
listDeviceLog
} from "@/api/iot/deviceLog";
export default {
components: { vueSeamlessScroll, Kong },
data() {
return {
list: [],
pageflag: true,
components: vueSeamlessScroll,
defaultOption: {
...this.$store.state.settings.defaultOption,
singleHeight: 240,
limitMoveNum: 5,
step: 0,
},
};
},
computed: {
sbtxSwiperFlag() {
let sbtxSwiper = this.$store.state.settings.sbtxSwiper;
if (sbtxSwiper) {
this.components = vueSeamlessScroll;
} else {
this.components = Kong;
}
return sbtxSwiper;
components: {
vueSeamlessScroll,
},
},
created() {
this.getData();
},
mounted() {},
methods: {
addressHandle(item) {
let name = item.provinceName;
if (item.cityName) {
name += "/" + item.cityName;
if (item.countyName) {
name += "/" + item.countyName;
}
}
return name;
data() {
return {
deviceLogList: [],
pageflag: true,
defaultOption: {
step: 2,
limitMoveNum: 4,
hoverStop: true,
singleHeight: 280,
openWatch: true,
waitTime: 3000,
},
queryParams: {
pageNum: 1,
pageSize: 20,
},
};
},
getData() {
this.pageflag = true;
// this.pageflag =false
currentGET("big3", { limitNum: 20 }).then((res) => {
console.log("设备提醒", res);
if (res.success) {
this.countUserNumData = res.data;
this.list = res.data.list;
let timer = setTimeout(() => {
clearTimeout(timer);
this.defaultOption.step =
this.$store.state.settings.defaultOption.step;
}, this.$store.state.settings.defaultOption.waitTime);
} else {
this.pageflag = false;
this.$Message({
text: res.msg,
type: "warning",
});
}
});
created() {
this.getData();
},
beforeDestroy() {
this.clearData()
},
methods: {
getData() {
listDeviceLog(this.queryParams).then(response => {
this.deviceLogList = response.rows;
// 轮询
this.switper()
});
},
clearData() {
if (this.timer) {
clearInterval(this.timer)
this.timer = null
}
},
//轮询
switper() {
if (this.timer) {
return
}
let looper = (a) => {
this.getData()
};
this.timer = setInterval(looper, 60000);
},
},
},
};
</script>
<style lang='scss' scoped>
.left_boottom_wrap {
overflow: hidden;
width: 100%;
height: 100%;
}
.doudong {
// vertical-align:middle;
overflow: hidden;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
backface-visibility: hidden;
}
.overflow-y-auto {
overflow-y: auto;
}
.left_boottom {
width: 100%;
height: 100%;
.left_boottom_item {
display: flex;
align-items: center;
justify-content: center;
padding: 8px;
font-size: 14px;
margin: 10px 0;
.orderNum {
margin: 0 16px 0 -20px;
}
.info {
margin-right: 10px;
display: flex;
align-items: center;
color: #fff;
.labels {
flex-shrink: 0;
font-size: 12px;
color: rgba(255, 255, 255, 0.6);
}
.zhuyao {
// color: $primary-color;
font-size: 15px;
}
.ciyao {
color: rgba(255, 255, 255, 0.8);
}
.warning {
color: #e6a23c;
font-size: 15px;
}
}
.inner_right {
position: relative;
height: 100%;
width: 380px;
flex-shrink: 0;
line-height: 1;
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
.dibu {
position: absolute;
height: 2px;
width: 104%;
background-image: url("../../../assets/bigScreen/img/zuo_xuxian.png");
bottom: -10px;
left: -2%;
background-size: cover;
}
.addresswrap {
width: 100%;
display: flex;
margin-top: 8px;
}
}
.wangguan {
color: #1890ff;
font-weight: 900;
font-size: 15px;
width: 80px;
flex-shrink: 0;
}
.time {
font-size: 12px;
// color: rgba(211, 210, 210,.8);
color: #fff;
}
.address {
font-size: 12px;
cursor: pointer;
// @include text-overflow(1);
}
.types {
width: 30px;
flex-shrink: 0;
}
.typeRed {
color: #fc1a1a;
}
.typeGreen {
color: #29fc29;
}
}
}
</style>

View File

@@ -1,223 +1,152 @@
<template>
<Echart id="leftCenter" :options="options" class="left_center_inner" v-if="pageflag" ref="charts" />
<Reacquire v-else @onclick="getData" style="line-height:200px">
重新获取
</Reacquire>
<div>
<div ref="statsChart" style="height: 240px; margin: 20px 0 40px 0"></div>
</div>
</template>
<script>
import { currentGET } from '@/api/bigScreen/modules'
import { getNettyMqttStats } from '@/api/iot/netty';
export default {
data() {
return {
options: {},
countUserNumData: {
lockNum: 0,
onlineNum: 0,
offlineNum: 0,
totalNum: 0
},
pageflag: true,
timer: null
timer: null,
// emqx状态数据
stats: {},
mqtt: this.$store.state.user.mqtt,
};
},
created() {
this.getData()
},
mounted() {
this.getMqttStats();
},
beforeDestroy() {
this.clearData()
this.clearData();
},
methods: {
clearData() {
if (this.timer) {
clearInterval(this.timer)
this.timer = null
/** 查询mqtt状态数据*/
getMqttStats() {
if (this.mqtt) {
getNettyMqttStats().then((response) => {
this.stats = response.data;
this.drawStats();
// 轮询
this.switper();
});
} else {
this.$nextTick(() => {
// 初始值
this.stats = {
'connections.count': 800,
'connections.max': 8000,
'sessions.count': 700,
'sessions.max': 7000,
'topics.count': 600,
'topics.max': 6000,
'subscribers.count': 500,
'subscribers.max': 5000,
'routes.count': 400,
'routes.max': 4000,
'retained.count': 300,
'retained.max': 3000,
};
this.drawStats();
// 轮询
this.switper();
});
}
},
getData() {
this.pageflag = true
// this.pageflag =false
currentGET('big1').then(res => {
//只打印一次
if (!this.timer) {
console.log("设备总览", res);
}
if (res.success) {
this.countUserNumData = res.data
this.$nextTick(() => {
this.init()
this.switper()
})
} else {
this.pageflag = false
this.$Message({
text: res.msg,
type: 'warning'
})
}
})
/** EMQX状态统计 */
drawStats() {
// 基于准备好的dom初始化echarts实例
let myChart = this.$echarts.init(this.$refs.statsChart);
var option;
option = {
animationDuration: 3000,
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
backgroundColor: 'rgba(58,73,116,0.7)',
textStyle: {
color: 'rgba(65,235,246,1)',
},
},
legend: {
textStyle: {
color: 'rgba(65,235,246,1)',
},
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
},
xAxis: {
type: 'value',
boundaryGap: [0, 0.01],
axisLabel: {
fontSize: 12,
color: '#fff',
},
splitLine: {
//网格线
lineStyle: {
type: 'dashed', //设置网格线类型 dotted虚线 solid:实线
color: 'rgba(65,235,246,1)', //网格线颜色
width: 0.5,
},
},
},
yAxis: {
type: 'category',
axisLabel: {
fontSize: 12,
color: '#fff',
},
data: this.mqtt ? ['连接数量', '会话数量', '订阅数量', '路由数量', '保留消息'] : ['连接数量', '会话数量', '主题数量', '订阅数量', '路由数量', '保留消息'],
},
series: [
{
name: '当前数量',
type: 'bar',
data: this.mqtt
? [this.stats['connection_count'], this.stats['session_count'], this.stats['subscription_count'], this.stats['retain_count'], this.stats['retain_count']]
: [this.stats['connections.count'], this.stats['sessions.count'], this.stats['topics.count'], this.stats['subscribers.count'], this.stats['routes.count'], this.stats['retained.count']],
itemStyle: {
color: '#67e0e3',
},
},
{
name: this.mqtt ? '累计总数' : '历史最大数',
type: 'bar',
data: this.mqtt
? [this.stats['connection_total'], this.stats['session_total'], this.stats['subscription_total'], this.stats['retain_total'], this.stats['retain_total']]
: [this.stats['connections.max'], this.stats['sessions.max'], this.stats['topics.max'], this.stats['subscribers.max'], this.stats['routes.max'], this.stats['retained.max']],
itemStyle: {
color: '#ffdb5c',
},
},
],
};
option && myChart.setOption(option);
},
clearData() {
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
},
//轮询
switper() {
if (this.timer) {
return
return;
}
let looper = (a) => {
this.getData()
};
this.timer = setInterval(looper, this.$store.state.settings.echartsAutoTime);
let myChart = this.$refs.charts.chart
myChart.on('mouseover', params => {
this.clearData()
});
myChart.on('mouseout', params => {
this.timer = setInterval(looper, this.$store.state.settings.echartsAutoTime);
});
},
init() {
let total = this.countUserNumData.totalNum;
let colors = ["#ECA444", "#33A1DB", "#56B557"];
let piedata = {
name: "用户总览",
type: "pie",
radius: ["42%", "65%"],
avoidLabelOverlap: false,
itemStyle: {
borderRadius: 4,
borderColor: "rgba(0,0,0,0)",
borderWidth: 2,
},
color: colors,
data: [
// {
// value: 0,
// name: "告警",
// label: {
// shadowColor: colors[0],
// },
// },
{
value: this.countUserNumData.lockNum,
name: "锁定",
label: {
shadowColor: colors[0],
},
},
{
value: this.countUserNumData.onlineNum,
name: "在线",
label: {
shadowColor: colors[2],
},
},
{
value: this.countUserNumData.offlineNum,
name: "离线",
label: {
shadowColor: colors[1],
},
},
],
};
this.options = {
title: {
// zlevel: 0,
text: ["{value|" + total + "}", "{name|总数}"].join("\n"),
top: "center",
left: "center",
textStyle: {
rich: {
value: {
color: "#ffffff",
fontSize: 24,
fontWeight: "bold",
lineHeight: 20,
},
name: {
color: "#ffffff",
lineHeight: 20,
},
},
},
},
tooltip: {
trigger: "item",
backgroundColor: "rgba(0,0,0,.6)",
borderColor: "rgba(147, 235, 248, .8)",
textStyle: {
color: "#FFF",
},
},
legend: {
show: false,
top: "5%",
left: "center",
},
series: [
//展示圆点
{
...piedata,
tooltip: { show: true },
label: {
formatter: " {b|{b}} \n {c|{c}个} {per|{d}%} ",
// position: "outside",
rich: {
b: {
color: "#fff",
fontSize: 12,
lineHeight: 26,
},
c: {
color: "#31ABE3",
fontSize: 14,
},
per: {
color: "#31ABE3",
fontSize: 14,
},
},
},
labelLine: {
length: 20, // 第一段线 长度
length2: 36, // 第二段线 长度
show: true,
emphasis: {
show: true,
},
},
},
{
...piedata,
tooltip: { show: true },
itemStyle: {},
label: {
backgroundColor: "auto", //圆点颜色auto映射的系列色
height: 0,
width: 0,
lineHeight: 0,
borderRadius: 2.5,
shadowBlur: 8,
shadowColor: "auto",
padding: [2.5, -2.5, 2.5, -2.5],
},
labelLine: {
length: 20, // 第一段线 长度
length2: 36, // 第二段线 长度
show: false,
},
},
],
this.getMqttStats();
};
this.timer = setInterval(looper, 60000);
},
},
};
</script>
<style lang='scss' scoped>
</style>

View File

@@ -1,246 +1,75 @@
<template>
<ul class="user_Overview flex" v-if="pageflag">
<li class="user_Overview-item" style="color: #00fdfa">
<div class="user_Overview_nums allnum ">
<dv-digital-flop :config="config" style="width:100%;height:100%;" />
</div>
<p>总设备数</p>
</li>
<li class="user_Overview-item" style="color: #07f7a8">
<div class="user_Overview_nums online">
<dv-digital-flop :config="onlineconfig" style="width:100%;height:100%;" />
</div>
<p>在线数</p>
</li>
<li class="user_Overview-item" style="color: #e3b337">
<div class="user_Overview_nums offline">
<dv-digital-flop :config="offlineconfig" style="width:100%;height:100%;" />
</div>
<p>掉线数</p>
</li>
<li class="user_Overview-item" style="color: #f5023d">
<div class="user_Overview_nums laramnum">
<dv-digital-flop :config="laramnumconfig" style="width:100%;height:100%;" />
</div>
<p>告警次数</p>
</li>
</ul>
<Reacquire v-else @onclick="getData" line-height="200px">
重新获取
</Reacquire>
<div style="display:flex;margin-top:60px;">
<div style="margin-left:10px;color:#32c5e9;">
<dv-decoration-9 style="width:90px;height:90px;font-weight:600;" :dur="10" :color="['#32c5e9', '#238aa4']">{{deviceStatistic.deviceCount}}</dv-decoration-9>
<div style="text-align: center;margin-top:25px;">设备总数</div>
</div>
<div style="margin:0 30px;color:#9fe6b8">
<dv-decoration-9 style="width:90px;height:90px;font-weight:600;" :dur="10" :color="['#9fe6b8', '#70a181']">{{deviceStatistic.deviceOnlineCount}}</dv-decoration-9>
<div style="text-align: center;margin-top:25px;font-weight:400;">在线设备</div>
</div>
<div style="margin-right:30px;color:#ffdb5c">
<dv-decoration-9 style="width:90px;height:90px;font-weight:600;" :dur="10" :color="['#ffdb5c', '#b39a41']">{{deviceStatistic.deviceCount-deviceStatistic.deviceOnlineCount}}</dv-decoration-9>
<div style="text-align: center;margin-top:25px;font-weight:400;">离线设备</div>
</div>
<div style="color:#fb7293;">
<dv-decoration-9 style="width:90px;height:90px;font-weight:600;" :dur="10" :color="['#fb7293', '#ad4f65']">{{deviceStatistic.alertCount}}</dv-decoration-9>
<div style="text-align: center;margin-top:25px;font-weight:400;">告警数量</div>
</div>
</div>
</template>
<script>
import {
import {
getDeviceStatistic,
} from "@/api/iot/device";
import {
listAllDeviceShort,
} from "@/api/iot/device";
let style = {
fontSize: 24
}
export default {
} from "@/api/iot/device";
export default {
data() {
return {
// 设备列表
deviceList: [],
// 设备统计信息
deviceStatistic: {},
// 设备总数
deviceCount: 0,
options: {},
userOverview: {
alarmNum: 0,
offlineNum: 0,
onlineNum: 0,
totalNum: 0,
},
pageflag: true,
timer: null,
config: {
number: [],
content: '{nt}',
style: {
...style,
// stroke: "#00fdfa",
fill: "#00fdfa",
},
},
onlineconfig: {
number: [0],
content: '{nt}',
style: {
...style,
// stroke: "#07f7a8",
fill: "#07f7a8",
},
},
offlineconfig: {
number: [0],
content: '{nt}',
style: {
...style,
// stroke: "#e3b337",
fill: "#e3b337",
},
},
laramnumconfig: {
number: [0],
content: '{nt}',
style: {
...style,
// stroke: "#f5023d",
fill: "#f5023d",
},
}
};
},
filters: {
numsFilter(msg) {
return msg || 0;
},
return {
// 设备统计信息
deviceStatistic: {
deviceCount: 100,
productCount: 100,
eventCount: 100,
alertCount: 100,
deviceOnlineCount:100
},
timer: null,
};
},
created() {
this.getData()
this.getDeviceStatic()
},
mounted() {},
beforeDestroy() {
this.clearData()
this.clearData()
},
methods: {
clearData() {
if (this.timer) {
clearInterval(this.timer)
this.timer = null
}
},
getData() {
this.pageflag = true;
getDeviceStatistic().then(res => {
// this.deviceStatistic = response.data;
if (!this.timer) {
console.log("设备总览", res);
}
if (res.code == 200) {
this.userOverview = res.data;
this.laramnumconfig = {
...this.laramnumconfig,
number: [res.data.alertCount]
clearData() {
if (this.timer) {
clearInterval(this.timer)
this.timer = null
}
this.getAllDevice();
// 轮询
this.switper()
} else {
this.pageflag = false;
this.$Message.warning(res.msg);
}
});
},
//轮询
switper() {
if (this.timer) {
return
}
let looper = (a) => {
// this.getData()
};
this.timer = setInterval(looper, this.$store.state.settings.echartsAutoTime);
},
/**查询所有设备 */
getAllDevice() {
listAllDeviceShort(this.queryParams).then(response => {
this.deviceList = response.rows;
this.deviceCount = response.total;
let online = this.deviceList.filter(x => x.status == 3).length;
let offline = this.deviceList.length - online;
this.config = {
...this.config,
number: [this.deviceCount]
}
this.onlineconfig = {
...this.onlineconfig,
number: [online]
}
this.offlineconfig = {
...this.offlineconfig,
number: [offline]
}
})
},
},
getDeviceStatic() {
getDeviceStatistic().then(response => {
if (response.code == 200) {
this.deviceStatistic = response.data;
// 轮询
this.switper()
}
});
},
//轮询
switper() {
if (this.timer) {
return
}
let looper = (a) => {
this.getDeviceStatic();
};
this.timer = setInterval(looper, 60000);
},
},
};
};
</script>
<style lang='scss' scoped>
.user_Overview {
li {
flex: 1;
p {
text-align: center;
height: 16px;
font-size: 16px;
}
.user_Overview_nums {
width: 100px;
height: 100px;
text-align: center;
line-height: 100px;
font-size: 22px;
margin: 50px auto 30px;
background-size: cover;
background-position: center center;
position: relative;
&::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
&.bgdonghua::before {
animation: rotating 14s linear infinite;
}
}
.allnum {
// background-image: url("../../assets/img/left_top_lan.png");
&::before {
background-image: url("../../../assets/bigScreen/img/left_top_lan.png");
}
}
.online {
&::before {
background-image: url("../../../assets/bigScreen/img/left_top_lv.png");
}
}
.offline {
&::before {
background-image: url("../../../assets/bigScreen/img/left_top_huang.png");
}
}
.laramnum {
&::before {
background-image: url("../../../assets/bigScreen/img/left_top_hong.png");
}
}
}
}
</style>

View File

@@ -1,187 +1,99 @@
<template>
<div v-if="pageflag" class="right_center_wrap beautify-scroll-def" :class="{ 'overflow-y-auto': !sbtxSwiperFlag }">
<component :is="components" :data="list" :class-option="defaultOption">
<ul class="right_center ">
<li class="right_center_item" v-for="(item, i) in list" :key="i">
<span class="orderNum">{{ i + 1 }}</span>
<div class="inner_right">
<div class="dibu"></div>
<div class="flex">
<div class="info">
<span class="labels ">设备ID</span>
<span class="contents zhuyao"> {{ item.gatewayno }}</span>
</div>
<div class="info">
<span class="labels">型号</span>
<span class="contents "> {{ item.terminalno }}</span>
</div>
<div class="info">
<span class="labels">告警值</span>
<span class="contents warning"> {{ item.alertvalue | montionFilter }}</span>
</div>
<div v-if="pageflag" style="overflow:hidden;width: 100%;height:250px;font-size:12px;line-height:24px;">
<vue-seamless-scroll :data="deviceLogList" :class-option="defaultOption">
<div style="display:flex;margin-bottom:10px;border-bottom:2px dashed #23cdd8;color:#bbb;" v-for="(item, i) in deviceLogList" :key="i">
<span style="width:50px;color:#23cdd8;font-size:16px;line-height:48px;font-weight:bolder;">{{ i + 1 }}</span>
<div style="display:flex;flex-wrap: wrap;">
<div style="width:200px;">
<span>设备编号</span>
<span style="color:#23cdd8">{{ item.serialNumber }}</span>
</div>
<div style="width:150px;white-space: nowrap;overflow:hidden;text-overflow:ellipsis;">
<span>标识符</span>
<span style="color:#fff;">{{item.identify}}</span>
</div>
<div style="width:60px;align-items: flex-end;text-align: right;">
<span style="color:#ffdb5c">编码{{ item.resultCode }}</span>
</div>
<div style="width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
<span>上报时间</span>
<span style="color:#fff;">{{ item.createTime }}</span>
</div>
<div style="margin-bottom:10px;width:210px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
<span>上报值</span>
<span style="color:#fff;">{{item.funValue }}</span>
</div>
</div>
</div>
</vue-seamless-scroll>
</div>
<div class="flex">
<div class="info">
<span class="labels"> 地址</span>
<span class="contents ciyao" style="font-size:12px"> {{ item.provinceName }}/{{ item.cityName }}/{{ item.countyName }}</span>
</div>
<div class="info time">
<span class="labels">时间</span>
<span class="contents" style="font-size:12px"> {{ item.createtime }}</span>
</div>
</div>
<div class="flex">
<div class="info">
<span class="labels">报警内容</span>
<span class="contents ciyao" :class="{ warning: item.alertdetail }"> {{ item.alertdetail || '无'
}}</span>
</div>
</div>
</div>
</li>
</ul>
</component>
</div>
<Reacquire v-else @onclick="getData" style="line-height:200px" />
<Reacquire v-else @onclick="getData" style="line-height:200px;color:#23cdd8;margin-left:210px;">
重新获取
</Reacquire>
</template>
<script>
import { currentGET } from '@/api/bigScreen/modules'
import vueSeamlessScroll from 'vue-seamless-scroll' // vue2引入方式
import Kong from '../components/kong.vue'
import vueSeamlessScroll from "vue-seamless-scroll";
import {
listLog,
getLog,
delLog,
addLog,
updateLog
} from "@/api/iot/functionLog";
export default {
components: { vueSeamlessScroll, Kong },
data() {
return {
list: [],
pageflag: true,
defaultOption: {
...this.$store.state.settings.defaultOption,
limitMoveNum: 3,
singleHeight: 250,
step:0,
}
};
},
computed: {
sbtxSwiperFlag() {
let ssyjSwiper = this.$store.state.settings.ssyjSwiper
if (ssyjSwiper) {
this.components = vueSeamlessScroll
} else {
this.components = Kong
}
return ssyjSwiper
}
},
created() {
this.getData()
},
mounted() { },
methods: {
getData() {
this.pageflag = true
// this.pageflag =false
currentGET('big5', { limitNum: 50 }).then(res => {
console.log('实时预警', res);
if (res.success) {
this.list = res.data.list
let timer = setTimeout(() => {
clearTimeout(timer)
this.defaultOption.step=this.$store.state.settings.defaultOption.step
}, this.$store.state.settings.defaultOption.waitTime);
} else {
this.pageflag = false
this.$Message.warning(res.msg)
}
})
components: {
vueSeamlessScroll,
},
data() {
return {
deviceLogList: [],
pageflag: true,
defaultOption: {
step: 2,
limitMoveNum: 4,
hoverStop: true,
singleHeight: 280,
openWatch: true,
waitTime: 3000,
},
queryParams: {
pageNum: 1,
pageSize: 5,
},
};
},
created() {
this.getData();
},
beforeDestroy() {
this.clearData()
},
methods: {
getData() {
listLog(this.queryParams).then(response => {
this.deviceLogList = response.rows;
// 轮询
this.switper()
});
},
clearData() {
if (this.timer) {
clearInterval(this.timer)
this.timer = null
}
},
//轮询
switper() {
if (this.timer) {
return
}
let looper = (a) => {
this.getData()
};
this.timer = setInterval(looper, 60000);
},
},
},
};
</script>
<style lang='scss' scoped>
.right_center {
width: 100%;
height: 100%;
.right_center_item {
display: flex;
align-items: center;
justify-content: center;
height: auto;
padding: 10px;
font-size: 14px;
color: #fff;
.orderNum {
margin: 0 20px 0 -20px;
}
.inner_right {
position: relative;
height: 100%;
width: 400px;
flex-shrink: 0;
line-height: 1.5;
.dibu {
position: absolute;
height: 2px;
width: 104%;
background-image: url("../../../assets/bigScreen/img/zuo_xuxian.png");
bottom: -12px;
left: -2%;
background-size: cover;
}
}
.info {
margin-right: 10px;
display: flex;
align-items: center;
.labels {
flex-shrink: 0;
font-size: 12px;
color: rgba(255, 255, 255, 0.6);
}
.zhuyao {
// color: $primary-color;
font-size: 15px;
}
.ciyao {
color: rgba(255, 255, 255, 0.8);
}
.warning {
color: #E6A23C;
font-size: 15px;
}
}
}
}
.right_center_wrap {
overflow: hidden;
width: 100%;
height: 250px;
}
.overflow-y-auto {
overflow-y: auto;
}
</style>

View File

@@ -1,157 +1,121 @@
<template>
<div class="right_bottom">
<dv-capsule-chart :config="config" style="width:100%;height:260px" />
<div style="display: flex">
<dv-active-ring-chart :config="config" style="width: 250px; height: 250px" />
<div style="font-size: 14px; margin-top: 80px; line-height: 10px; margin-left: -20px">
<div style="margin-bottom: 20px; color: #23cdd8" v-if="mqtt">
<div style="margin-bottom: 20px; color: #23cdd8">
发送消息总数
<span style="color: #fff">{{ formatter(this.static['send_total']) }}</span>
<dv-decoration-3 style="width: 200px; height: 20px; margin-top: 5px" />
</div>
</div>
<div style="margin-bottom: 20px; color: #23cdd8" v-else>
发送字节
<span style="color: #fff">{{ formatter(this.static['bytes.sent']) }}</span>
<dv-decoration-3 style="width: 200px; height: 20px; margin-top: 5px" />
</div>
<div style="margin-bottom: 20px; color: #23cdd8" v-if="mqtt">
接收消息总数
<span style="color: #fff">{{ formatter(this.static['receive_total']) }}</span>
<dv-decoration-3 style="width: 200px; height: 20px; margin-top: 5px" />
</div>
<div style="margin-bottom: 20px; color: #23cdd8" v-else>
接收字节
<span style="color: #fff">{{ formatter(this.static['bytes.received']) }}</span>
<dv-decoration-3 style="width: 200px; height: 20px; margin-top: 5px" />
</div>
</div>
</div>
</template>
<script>
import { currentGET } from '@/api/bigScreen/modules'
import { statisticNettyMqtt } from '@/api/iot/netty';
export default {
data() {
return {
gatewayno: '',
config: {
showValue: true,
unit: "次",
data: []
},
// emqx统计信息
static: {},
config: {},
timer: null,
mqtt: this.$store.state.user.mqtt,
};
},
created() {
this.getData()
this.statisticMqtt();
},
computed: {
},
mounted() { },
computed: {},
beforeDestroy() {
this.clearData()
this.clearData();
},
methods: {
/** 查询emqx统计*/
statisticMqtt() {
if (this.mqtt) {
statisticNettyMqtt().then((response) => {
this.static = response.data;
// 图标配置
this.config = {
data: [
{
name: '发送',
value: this.static['send_total'],
},
{
name: '接收',
value: this.static['receive_total'],
},
],
color: ['#ffdb5c', '#67e0e3'],
};
// 轮询
this.switper();
});
} else {
// 图标配置
this.config = {
data: [
{
name: '发送',
value: 32761563,
},
{
name: '接收',
value: 31910071,
},
],
color: ['#ffdb5c', '#67e0e3'],
};
// 轮询
this.switper();
}
},
// 数字格式化
formatter(number) {
if (number) {
const numbers = number.toString().split('').reverse();
const segs = [];
while (numbers.length) segs.push(numbers.splice(0, 3).join(''));
return segs.join(',').split('').reverse().join('');
}
return 1024;
},
clearData() {
if (this.timer) {
clearInterval(this.timer)
this.timer = null
clearInterval(this.timer);
this.timer = null;
}
},
//轮询
switper() {
if (this.timer) {
return
return;
}
let looper = (a) => {
this.getData()
this.statisticMqtt();
};
this.timer = setInterval(looper, this.$store.state.settings.echartsAutoTime);
},
getData() {
this.pageflag = true
// this.pageflag =false
currentGET('big7', { gatewayno: this.gatewayno }).then(res => {
if (!this.timer) {
console.log('报警排名', res);
}
if (res.success) {
this.config = {
...this.config,
data: res.data
}
this.switper()
} else {
this.pageflag = false
this.srcList = []
this.$Message({
text: res.msg,
type: 'warning'
})
}
})
this.timer = setInterval(looper, 60000);
},
},
};
</script>
<style lang='scss' scoped>
.list_Wrap {
height: 100%;
overflow: hidden;
::v-deep .kong {
width: auto;
}
}
.sbtxSwiperclass {
.img_wrap {
overflow-x: auto;
}
}
.right_bottom {
box-sizing: border-box;
padding: 0 16px;
.searchform {
height: 80px;
display: flex;
align-items: center;
justify-content: center;
.searchform_item {
display: flex;
justify-content: center;
align-items: center;
label {
margin-right: 10px;
color: rgba(255, 255, 255, 0.8);
}
button {
margin-left: 30px;
}
input {}
}
}
.img_wrap {
display: flex;
// justify-content: space-around;
box-sizing: border-box;
padding: 0 0 20px;
// overflow-x: auto;
li {
width: 105px;
height: 137px;
border-radius: 6px;
overflow: hidden;
cursor: pointer;
// background: #84ccc9;
// border: 1px solid #ffffff;
overflow: hidden;
flex-shrink: 0;
margin: 0 10px;
img {
flex-shrink: 0;
}
}
}
.noData {
width: 100%;
line-height: 100px;
text-align: center;
color: rgb(129, 128, 128);
}
}
</style>

View File

@@ -1,29 +1,23 @@
<template>
<Echart
id="rightTop"
:options="option"
class="right_top_inner"
v-if="pageflag"
ref="charts"
/>
<Reacquire v-else @onclick="getData" style="line-height: 200px">
重新获取
</Reacquire>
<div style="padding-top: 10px">
<dv-capsule-chart :config="config" style="width: 430px; height: 230px" />
</div>
</template>
<script>
import { currentGET } from "@/api/bigScreen/modules";
import { statisticNettyMqtt } from '@/api/iot/netty';
export default {
data() {
return {
option: {},
pageflag: false,
// emqx统计信息
static: {},
config: {},
timer: null,
mqtt: this.$store.state.user.mqtt,
};
},
created() {
this.getData();
this.statisticMqtt();
},
mounted() {},
@@ -31,264 +25,101 @@ export default {
this.clearData();
},
methods: {
/** 查询mqtt统计*/
statisticMqtt() {
if (this.mqtt) {
statisticNettyMqtt().then((response) => {
this.static = response.data;
this.config = {
data: [
{
name: '今日接收',
value: this.static['today_received'],
},
{
name: '今日发送',
value: this.static['today_send'],
},
{
name: '订阅总数',
value: this.static['subscribe_total'],
},
{
name: '发布消息',
value: this.static['send_total'],
},
{
name: '接收消息',
value: this.static['receive_total'],
},
{
name: '认证次数',
value: this.static['auth_total'],
},
{
name: '认证成功',
value: this.static['auth_total'],
},
],
unit: '次数',
showValue: true,
};
this.switper();
});
} else {
this.config = {
data: [
{
name: '今日接收',
value: 6000,
},
{
name: '今日发送',
value: 5000,
},
{
name: '订阅总数',
value: 4000,
},
{
name: '发布消息',
value: 3000,
},
{
name: '接收消息',
value: 2000,
},
{
name: '认证次数',
value: 1000,
},
{
name: '认证成功',
value: 1000,
},
],
unit: '次数',
showValue: true,
};
this.switper();
}
},
clearData() {
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
},
getData() {
this.pageflag = true;
// this.pageflag =false
currentGET("big4").then((res) => {
if (!this.timer) {
console.log("报警次数", res);
}
if (res.success) {
this.countUserNumData = res.data;
this.$nextTick(() => {
this.init(res.data.dateList, res.data.numList, res.data.numList2),
this.switper();
});
} else {
this.pageflag = false;
this.$Message({
text: res.msg,
type: "warning",
});
}
});
},
//轮询
switper() {
if (this.timer) {
return;
}
let looper = (a) => {
this.getData();
};
this.timer = setInterval(
looper,
this.$store.state.settings.echartsAutoTime
);
let myChart = this.$refs.charts.chart;
myChart.on("mouseover", (params) => {
this.clearData();
});
myChart.on("mouseout", (params) => {
this.timer = setInterval(
looper,
this.$store.state.settings.echartsAutoTime
);
});
},
init(xData, yData, yData2) {
this.option = {
xAxis: {
type: "category",
data: xData,
boundaryGap: false, // 不留白,从原点开始
splitLine: {
show: true,
lineStyle: {
color: "rgba(31,99,163,.2)",
},
},
axisLine: {
// show:false,
lineStyle: {
color: "rgba(31,99,163,.1)",
},
},
axisLabel: {
color: "#7EB7FD",
fontWeight: "500",
},
},
yAxis: {
type: "value",
splitLine: {
show: true,
lineStyle: {
color: "rgba(31,99,163,.2)",
},
},
axisLine: {
lineStyle: {
color: "rgba(31,99,163,.1)",
},
},
axisLabel: {
color: "#7EB7FD",
fontWeight: "500",
},
},
tooltip: {
trigger: "axis",
backgroundColor: "rgba(0,0,0,.6)",
borderColor: "rgba(147, 235, 248, .8)",
textStyle: {
color: "#FFF",
},
},
grid: {
//布局
show: true,
left: "10px",
right: "30px",
bottom: "10px",
top: "28px",
containLabel: true,
borderColor: "#1F63A3",
},
series: [
{
data: yData,
type: "line",
smooth: true,
symbol: "none", //去除点
name: "报警1次数",
color: "rgba(252,144,16,.7)",
areaStyle: {
normal: {
//右,下,左,上
color: new echarts.graphic.LinearGradient(
0,
0,
0,
1,
[
{
offset: 0,
color: "rgba(252,144,16,.7)",
},
{
offset: 1,
color: "rgba(252,144,16,.0)",
},
],
false
),
},
},
markPoint: {
data: [
{
name: "最大值",
type: "max",
valueDim: "y",
symbol: "rect",
symbolSize: [60, 26],
symbolOffset: [0, -20],
itemStyle: {
color: "rgba(0,0,0,0)",
},
label: {
color: "#FC9010",
backgroundColor: "rgba(252,144,16,0.1)",
borderRadius: 6,
padding: [7, 14],
borderWidth: 0.5,
borderColor: "rgba(252,144,16,.5)",
formatter: "报警1{c}",
},
},
{
name: "最大值",
type: "max",
valueDim: "y",
symbol: "circle",
symbolSize: 6,
itemStyle: {
color: "#FC9010",
shadowColor: "#FC9010",
shadowBlur: 8,
},
label: {
formatter: "",
},
},
],
},
},
{
data: yData2,
type: "line",
smooth: true,
symbol: "none", //去除点
name: "报警2次数",
color: "rgba(9,202,243,.7)",
areaStyle: {
normal: {
//右,下,左,上
color: new echarts.graphic.LinearGradient(
0,
0,
0,
1,
[
{
offset: 0,
color: "rgba(9,202,243,.7)",
},
{
offset: 1,
color: "rgba(9,202,243,.0)",
},
],
false
),
},
},
markPoint: {
data: [
{
name: "最大值",
type: "max",
valueDim: "y",
symbol: "rect",
symbolSize: [60, 26],
symbolOffset: [0, -20],
itemStyle: {
color: "rgba(0,0,0,0)",
},
label: {
color: "#09CAF3",
backgroundColor: "rgba(9,202,243,0.1)",
borderRadius: 6,
borderColor: "rgba(9,202,243,.5)",
padding: [7, 14],
formatter: "报警2{c}",
borderWidth: 0.5,
},
},
{
name: "最大值",
type: "max",
valueDim: "y",
symbol: "circle",
symbolSize: 6,
itemStyle: {
color: "#09CAF3",
shadowColor: "#09CAF3",
shadowBlur: 8,
},
label: {
formatter: "",
},
},
],
},
},
],
this.statisticMqtt();
};
this.timer = setInterval(looper, 60000);
},
},
};
</script>
<style lang='scss' scoped>
.right_top_inner {
margin-top: -8px;
}
</style>

View File

@@ -3,7 +3,7 @@
</template>
<script>
import echarts from 'echarts'
import * as echarts from 'echarts';
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'

View File

@@ -3,7 +3,7 @@
</template>
<script>
import echarts from 'echarts'
import * as echarts from 'echarts';
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'

View File

@@ -3,7 +3,7 @@
</template>
<script>
import echarts from 'echarts'
import * as echarts from 'echarts';
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'

View File

@@ -3,7 +3,7 @@
</template>
<script>
import echarts from 'echarts'
import * as echarts from 'echarts';
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
<template>
<div style="padding-left:20px;">
<el-row :gutter="10">
<el-col :span="14">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-tag type="danger" style="margin-left:15px;">开源版本不支持该功能,请前往购买商业版本</el-tag>
</el-col>
</el-row>
</el-col>
</el-row>
</div>
</template>
<style scoped lang="scss">
</style>
<script>
</script>

View File

@@ -1,67 +1,78 @@
<template>
<div style="padding:6px;">
<el-card v-show="showSearch" style="margin-bottom:5px;">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom:-20px;">
<el-form-item label="分类名称" prop="categoryName">
<el-input v-model="queryParams.categoryName" placeholder="请输入产品分类名称" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
<el-form-item style="float:right;">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:category:add']">新增</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card style="padding-bottom:100px;">
<el-table v-loading="loading" :data="categoryList" @selection-change="handleSelectionChange" border>
<el-table-column label="产品分类名称" align="center" prop="categoryName" />
<el-table-column label="备注" align="left" prop="remark" min-width="150" />
<el-table-column label="系统定义" align="center" prop="isSys">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isSys" />
</template>
</el-table-column>
<el-table-column label="显示顺序" align="center" prop="orderNum" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
<template slot-scope="scope">
<el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:category:edit']" v-if="scope.row.isSys == '0'? true:!isTenant">修改</el-button>
<el-button size="small" type="danger" style="padding:5px;" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:category:remove']" v-if="scope.row.isSys == '0'? true:!isTenant">删除</el-button>
<span style="font-size:10px;color:#999;" v-if="scope.row.isSys == '1' && isTenant">系统定义不能修改</span>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改产品分类对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<div style="padding:6px;">
<el-card v-show="showSearch" style="margin-bottom:5px;">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom:-20px;">
<el-form-item label="分类名称" prop="categoryName">
<el-input v-model="form.categoryName" placeholder="请输入产品分类名称" />
<el-input v-model="queryParams.categoryName" placeholder="请输入产品分类名称" clearable size="small"
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="显示顺序" prop="orderNum">
<el-input v-model="form.orderNum" type="number" placeholder="请输入显示顺序" />
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
<el-form-item style="float:right;">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['iot:category:add']">新增</el-button>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" > </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</el-card>
</el-card>
</div>
<el-card style="padding-bottom:100px;">
<el-table v-loading="loading" :data="categoryList" @selection-change="handleSelectionChange" border>
<el-table-column label="产品分类名称" align="center" prop="categoryName" />
<el-table-column label="备注" align="left" header-align="center" prop="remark" min-width="150" />
<el-table-column label="系统定义" align="center" prop="isSys">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isSys" />
</template>
</el-table-column>
<el-table-column label="显示顺序" align="center" prop="orderNum" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
<template slot-scope="scope">
<el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit"
@click="handleUpdate(scope.row)" v-hasPermi="['iot:category:query']"
v-if="scope.row.isSys == '0' ? true : !isTenant">修改</el-button>
<el-button size="small" type="danger" style="padding:5px;" icon="el-icon-delete"
@click="handleDelete(scope.row)" v-hasPermi="['iot:category:remove']"
v-if="scope.row.isSys == '0' ? true : !isTenant">删除</el-button>
<span style="font-size:10px;color:#999;" v-if="scope.row.isSys == '1' && isTenant">系统定义不能修改</span>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改产品分类对话框 -->
<el-dialog title="产品分类" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="分类名称" prop="categoryName">
<el-input v-model="form.categoryName" placeholder="请输入产品分类名称" />
</el-form-item>
<el-form-item label="显示顺序" prop="orderNum">
<el-input-number controls-position="right" v-model="form.orderNum"
placeholder="请输入显示顺序" style="width:100%" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" v-hasPermi="['iot:category:edit']"
v-show="form.categoryId"> </el-button>
<el-button type="primary" @click="submitForm" v-hasPermi="['iot:category:add']"
v-show="!form.categoryId"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</el-card>
</div>
</template>
<script>
@@ -113,6 +124,29 @@ export default {
required: true,
message: "产品分类名称不能为空",
trigger: "blur"
}, {
min: 1,
max: 64,
message: '产品分类不能少于1个字符和超过64字符',
},
],
orderNum: [{
required: true,
message: '分类顺序不能为空',
trigger: 'blur',
}, {
type: 'number',
min: -2147483648,
max: 2147483647,
message: '顺序值不能超过int型的取值范围(-2^31——2^31-1)',
trigger: 'blur',
}],
remark: [{
required: false,
min: 0,
max: 500,
message: '备注不能输入超过500个字符',
trigger: 'blur',
}],
isSys: [{
required: true,
@@ -155,7 +189,7 @@ export default {
tenantName: null,
isSys: null,
parentId: null,
orderNum: null,
orderNum: 0,
delFlag: null,
createBy: null,
createTime: null,
@@ -228,7 +262,7 @@ export default {
}).then(() => {
this.getList();
this.$modal.msgSuccess(msg);
}).catch(() => {});
}).catch(() => { });
},
/** 导出按钮操作 */
handleExport() {

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,222 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="请选择设备从机:" label-width="120px" v-if="isSubDev">
<el-select v-model="queryParams.slaveId" placeholder="请选择设备从机" @change="selectSlave">
<el-option v-for="slave in slaveList" :key="slave.slaveId" :label="`${slave.deviceName} (从机地址:${slave.slaveId})`" :value="slave.slaveId"></el-option>
</el-select>
</el-form-item>
<el-form-item label="日志类型" prop="funType">
<el-select v-model="queryParams.funType" placeholder="请选择类型" clearable size="small">
<el-option v-for="dict in dict.type.iot_function_type" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="标识符" prop="identify">
<el-input v-model="queryParams.identify" placeholder="请输入标识符" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="时间范围">
<el-date-picker v-model="daterangeTime" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="logList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column :label="showName" align="center" prop="identify" />
<el-table-column label="指令类型" align="center" prop="funType" width="120px">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_function_type" :value="scope.row.funType" />
</template>
</el-table-column>
<el-table-column label="设置值" align="center" prop="funValue" />
<el-table-column label="设备编号" align="center" prop="serialNumber" />
<el-table-column label="下发时间" align="center" prop="createTime" />
<el-table-column label="下发结果描述" align="center" prop="resultMsg" />
<el-table-column label="操作" align="center" width="80">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:device:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
</div>
</template>
<script>
import { listLog, delLog } from '@/api/iot/functionLog';
export default {
name: 'device-func',
dicts: ['iot_function_type', 'iot_yes_no'],
props: {
device: {
type: Object,
default: null,
},
},
watch: {
// 获取到父组件传递的device后
device: function (newVal) {
this.deviceInfo = newVal;
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
this.isSubDev = this.deviceInfo.subDeviceList && this.deviceInfo.subDeviceList.length > 0;
this.showName = this.isSubDev ? '寄存器地址' : '标识符';
this.queryParams.deviceId = this.deviceInfo.deviceId;
this.queryParams.slaveId = this.deviceInfo.slaveId;
this.queryParams.serialNumber = this.deviceInfo.serialNumber;
this.slaveList = newVal.subDeviceList;
this.getList();
}
},
},
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 设备服务下发日志表格数据
logList: [],
// 弹出层标题
title: '',
// 是否显示弹出层
open: false,
//设备数据
deviceInfo: {},
// 时间范围
daterangeTime: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
identify: null,
funType: null,
funValue: null,
messageId: null,
deviceName: null,
serialNumber: null,
mode: null,
userId: null,
resultMsg: null,
resultCode: null,
slaveId: null,
},
// 表单参数
form: {},
//是否是modbus设备组
isSubDev: false,
showName: null,
slaveList: [],
// 表单校验
rules: {
identify: [{ required: true, message: '标识符不能为空', trigger: 'blur' }],
funType: [{ required: true, message: '功能下发类型不能为空', trigger: 'change' }],
funValue: [{ required: true, message: '日志值不能为空', trigger: 'blur' }],
serialNumber: [{ required: true, message: '设备编号不能为空', trigger: 'blur' }],
},
};
},
created() {
this.queryParams.serialNumber = this.device.serialNumber;
this.getList();
},
methods: {
/** 查询设备服务下发日志列表 */
getList() {
this.loading = true;
if (null != this.daterangeTime && '' != this.daterangeTime) {
this.queryParams.beginTime = this.daterangeTime[0];
this.queryParams.endTime = this.daterangeTime[1];
}
if (this.queryParams.slaveId) {
this.queryParams.serialNumber = this.queryParams.serialNumber + '_' + this.queryParams.slaveId;
}
listLog(this.queryParams).then((response) => {
this.logList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
identify: null,
funType: null,
funValue: null,
messageId: null,
deviceName: null,
serialNumber: null,
mode: null,
userId: null,
resultMsg: null,
resultCode: null,
createBy: null,
createTime: null,
remark: null,
};
this.resetForm('form');
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm('queryForm');
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal
.confirm('是否确认删除设备服务下发日志编号为"' + ids + '"的数据项?')
.then(function () {
return delLog(ids);
})
.then(() => {
this.getList();
this.$modal.msgSuccess('删除成功');
})
.catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download(
'iot/log/export',
{
...this.queryParams,
},
`log_${new Date().getTime()}.xlsx`
);
},
//选择从机
selectSlave() {},
},
};
</script>

View File

@@ -3,22 +3,25 @@
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="日志类型" prop="logType">
<el-select v-model="queryParams.logType" placeholder="请选择类型" clearable size="small">
<el-option v-for="dict in dict.type.iot_device_log_type" :key="dict.value" :label="dict.label" :value="dict.value" />
<el-option v-for="dict in dict.type.iot_event_type" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="标识符" prop="identity">
<el-input v-model="queryParams.identity" placeholder="请输入标识符" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="时间范围">
<el-date-picker v-model="daterangeTime" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="deviceLogList" size="mini">
<el-table v-loading="loading" :data="deviceLogList" size="mini">
<el-table-column label="类型" align="center" prop="logType" width="120">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_device_log_type" :value="scope.row.logType" />
<dict-tag :options="dict.type.iot_event_type" :value="scope.row.logType" />
</template>
</el-table-column>
<el-table-column label="模式" align="center" prop="logType" width="120">
@@ -56,15 +59,12 @@
<script>
import {
listDeviceLog
} from "@/api/iot/deviceLog";
import {
cacheJsonThingsModel
} from "@/api/iot/model";
listEventLog
} from "../../../api/iot/eventLog";
export default {
name: "DeviceLog",
dicts: ['iot_device_log_type', "iot_yes_no"],
dicts: ['iot_event_type', "iot_yes_no"],
props: {
device: {
type: Object,
@@ -76,10 +76,10 @@ export default {
device: function (newVal, oldVal) {
this.deviceInfo = newVal;
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
this.queryParams.deviceId = this.deviceInfo.deviceId;
this.queryParams.serialNumber = this.deviceInfo.serialNumber;
this.getList();
// 获取物模型
this.getCacheThingsModdel(this.deviceInfo.productId);
// 解析缓存物模型
this.thingsModel = this.deviceInfo.cacheThingsModel;
}
}
},
@@ -101,20 +101,24 @@ export default {
logType: null,
logValue: null,
deviceId: null,
serialNumber: null,
deviceName: null,
identity: null,
isMonitor: null,
},
// 时间范围
daterangeTime: [],
};
},
created() {
this.queryParams.serialNumber = this.device.serialNumber;
this.getList();
},
methods: {
/** 查询设备日志列表 */
getList() {
this.loading = true;
listDeviceLog(this.queryParams).then(response => {
listEventLog(this.addDateRange(this.queryParams, this.daterangeTime)).then(response => {
this.deviceLogList = response.rows;
this.total = response.total;
this.loading = false;
@@ -128,20 +132,14 @@ export default {
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.daterangeTime=[];
this.handleQuery();
},
/** 导出按钮操作 */
handleExport() {
this.download('iot/deviceLog/export', {
this.download('iot/event/export', {
...this.queryParams
}, `deviceLog_${new Date().getTime()}.xlsx`)
},
/** 获取物模型*/
getCacheThingsModdel(productId) {
// 获取缓存的Json物模型
cacheJsonThingsModel(productId).then(response => {
this.thingsModel = JSON.parse(response.data);
});
}, `eventLog_${new Date().getTime()}.xlsx`)
},
/** 格式化显示数据定义 */
formatValueDisplay(row) {
@@ -149,17 +147,29 @@ export default {
if (row.logType == 1) {
let propertyItem = this.getThingsModelItem(1, row.identity);
if (propertyItem != "") {
return propertyItem.name + ' <span style="color:#409EFF;">' + this.getThingsModelItemValue(propertyItem, row.logValue) + ' ' + (propertyItem.datatype.unit != undefined ? propertyItem.datatype.unit : '') + '</span>';
return (propertyItem.parentName ? '[' + propertyItem.parentName + (propertyItem.arrayIndex ? propertyItem.arrayIndex : '') + '] ' : '') +
propertyItem.name +
' <span style="color:#409EFF;">' + this.getThingsModelItemValue(propertyItem, row.logValue) + ' ' +
(propertyItem.datatype.unit != undefined ? propertyItem.datatype.unit : '') + '</span>';
}
} else if (row.logType == 2) {
let functionItem = this.getThingsModelItem(2, row.identity);
if (functionItem != "") {
return functionItem.name + ' <span style="color:#409EFF">' + this.getThingsModelItemValue(functionItem, row.logValue) + ' ' + (functionItem.datatype.unit != undefined ? functionItem.datatype.unit : '') + '</span>';
return (functionItem.parentName ? '[' + functionItem.parentName + (functionItem.arrayIndex ? functionItem.arrayIndex : '') + '] ' : '') +
functionItem.name +
' <span style="color:#409EFF">' + this.getThingsModelItemValue(functionItem, row.logValue) + ' ' +
(functionItem.datatype.unit != undefined ? functionItem.datatype.unit : '') + '</span>';
}
} else if (row.logType == 3) {
let eventItem = this.getThingsModelItem(3, row.identity);
if (eventItem != "") {
return eventItem.name + ' <span style="color:#409EFF">' + this.getThingsModelItemValue(eventItem, row.logValue) + ' ' + (eventItem.datatype.unit != undefined ? eventItem.datatype.unit : '') + '</span>';
return (eventItem.parentName ? '[' + eventItem.parentName + (eventItem.arrayIndex ? eventItem.arrayIndex : '') + '] ' : '') +
eventItem.name +
' <span style="color:#409EFF">' + this.getThingsModelItemValue(eventItem, row.logValue) + ' ' +
(eventItem.datatype.unit != undefined ? eventItem.datatype.unit : '') + '</span>';
}
else {
return row.logValue;
}
} else if (row.logType == 4) {
return '<span style="font-weight:bold">设备升级</span>';
@@ -172,6 +182,7 @@ export default {
},
/** 获取物模型项中的值*/
getThingsModelItemValue(item, oldValue) {
// 枚举和布尔转换为文字
if (item.datatype.type == "bool") {
if (oldValue == "0") {
return item.datatype.falseText;
@@ -191,15 +202,95 @@ export default {
getThingsModelItem(type, identity) {
if (type == 1 && this.thingsModel.properties) {
for (let i = 0; i < this.thingsModel.properties.length; i++) {
//普通类型 integer/decimal/string/emum//bool
if (this.thingsModel.properties[i].id == identity) {
return this.thingsModel.properties[i];
}
// 对象 object
if (this.thingsModel.properties[i].datatype.type == "object") {
for (let j = 0; j < this.thingsModel.properties[i].datatype.params.length; j++) {
if (this.thingsModel.properties[i].datatype.params[j].id == identity) {
this.thingsModel.properties[i].datatype.params[j].parentName = this.thingsModel.properties[i].name;
return this.thingsModel.properties[i].datatype.params[j];
}
}
}
// 数组 array
if (this.thingsModel.properties[i].datatype.type == "array" && this.thingsModel.properties[i].datatype.arrayType) {
if (this.thingsModel.properties[i].datatype.arrayType == "object") {
// 数组元素格式array_01_parentId_humidity,array_01_前缀终端上报时加上物模型中没有
let realIdentity = identity;
let arrayIndex = 0;
if (identity.indexOf("array_") > -1) {
arrayIndex = identity.substring(6, 8);
realIdentity = identity.substring(9);
}
for (let j = 0; j < this.thingsModel.properties[i].datatype.params.length; j++) {
if (this.thingsModel.properties[i].datatype.params[j].id == realIdentity) {
// 标注索引和父级名称
this.thingsModel.properties[i].datatype.params[j].arrayIndex = Number(arrayIndex) + 1;
this.thingsModel.properties[i].datatype.params[j].parentName = this.thingsModel.properties[i].name;
return this.thingsModel.properties[i].datatype.params[j];
}
}
} else {
// 普通类型
for (let j = 0; j < this.thingsModel.properties[i].datatype.arrayCount.length; j++) {
if (this.thingsModel.properties[i].id == realIdentity) {
this.thingsModel.properties[i].arrayIndex = Number(arrayIndex) + 1;
this.thingsModel.properties[i].parentName = "元素";
return this.thingsModel.properties[i];
}
}
}
}
}
} else if (type == 2 && this.thingsModel.functions) {
for (let i = 0; i < this.thingsModel.functions.length; i++) {
//普通类型 integer/decimal/string/emum/bool
if (this.thingsModel.functions[i].id == identity) {
return this.thingsModel.functions[i];
}
// 对象 object
if (this.thingsModel.functions[i].datatype.type == "object") {
for (let j = 0; j < this.thingsModel.functions[i].datatype.params.length; j++) {
if (this.thingsModel.functions[i].datatype.params[j].id == identity) {
this.thingsModel.functions[i].datatype.params[j].parentName = this.thingsModel.functions[i].name;
return this.thingsModel.functions[i].datatype.params[j];
}
}
}
// 数组 array
if (this.thingsModel.functions[i].datatype.type == "array" && this.thingsModel.functions[i].datatype.arrayType) {
// 数组元素格式array_01_parentId_humidity,array_01_前缀终端上报时加上物模型中没有
let realIdentity = identity;
let arrayIndex = 0;
if (identity.indexOf("array_") > -1) {
arrayIndex = identity.substring(6, 8);
realIdentity = identity.substring(9);
}
if (this.thingsModel.functions[i].datatype.arrayType == "object") {
for (let j = 0; j < this.thingsModel.functions[i].datatype.params.length; j++) {
if (this.thingsModel.functions[i].datatype.params[j].id == realIdentity) {
// 标注索引和父级名称
this.thingsModel.functions[i].datatype.params[j].arrayIndex = Number(arrayIndex) + 1;
this.thingsModel.functions[i].datatype.params[j].parentName = this.thingsModel.functions[i].name;
return this.thingsModel.functions[i].datatype.params[j];
}
}
} else {
// 普通类型
for (let j = 0; j < this.thingsModel.functions[i].datatype.arrayCount.length; j++) {
if (this.thingsModel.functions[i].id == realIdentity) {
this.thingsModel.functions[i].arrayIndex = Number(arrayIndex) + 1;
this.thingsModel.functions[i].parentName = "元素";
return this.thingsModel.functions[i];
}
}
}
}
}
} else if (type == 3 && this.thingsModel.events) {
for (let i = 0; i < this.thingsModel.events.length; i++) {

View File

@@ -0,0 +1,296 @@
<template>
<div style="padding-left: 20px">
<el-form :inline="true" label-width="100px">
<el-form-item label="监测间隔(ms)">
<el-tooltip class="item" effect="light" content="取值范围500-10000毫秒" placement="top">
<el-input v-model="monitorInterval" placeholder="请输入监测间隔" type="number" clearable size="small" style="width: 180px" />
</el-tooltip>
</el-form-item>
<el-form-item label="监测次数">
<el-tooltip class="item" effect="light" content="取值方位1-300" placement="top">
<el-input v-model="monitorNumber" placeholder="请输入监测次数" type="number" clearable size="small" style="width: 180px" />
</el-tooltip>
</el-form-item>
<el-form-item>
<el-button type="success" icon="el-icon-video-play" size="mini" @click="beginMonitor()" style="margin-left: 30px">开始监测</el-button>
<el-button type="danger" icon="el-icon-video-pause" size="mini" @click="stopMonitor()">停止监测</el-button>
</el-form-item>
</el-form>
<el-row :gutter="20" v-loading="chartLoading" element-loading-text="正在接收设备数据,请耐心等待......" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)">
<el-col :span="12" v-for="(item, index) in monitorThings" :key="index" style="margin-bottom: 20px">
<el-card shadow="hover" :body-style="{ paddingTop: '10px', marginBottom: '-20px' }">
<div ref="monitor" style="height: 210px; padding: 0"></div>
</el-card>
</el-col>
</el-row>
</div>
</template>
<script>
export default {
name: 'DeviceMonitor',
props: {
device: {
type: Object,
default: null,
},
},
watch: {
// 获取到父组件传递的device后刷新列表
device: function (newVal, oldVal) {
this.deviceInfo = newVal;
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
// 监测数据
this.monitorThings = this.deviceInfo.monitorList;
// 监测数据集合初始化
this.dataList = [];
for (let i = 0; i < this.monitorThings.length; i++) {
this.dataList.push({
id: this.monitorThings[i].id,
name: this.monitorThings[i].name,
data: [],
});
// this.dataList[i].data.push(["2022-03-14 23:32:09", "30"]);
}
// 绘制监测图表
this.$nextTick(function () {
this.getMonitorChart();
});
this.mqttCallback();
}
},
},
data() {
return {
// 实时监测间隔
monitorInterval: 1000,
// 实时监测次数
monitorNumber: 60,
// 图表集合
chart: [],
// 图表数据集合
dataList: [],
// 监测物模型
monitorThings: [],
// 图表遮罩层
chartLoading: false,
// 设备信息
deviceInfo: {},
};
},
created() {},
methods: {
/**
* Mqtt发布消息
* @device 设备
* @model 物模型 ,type 类型(1=属性2=功能3=OTA升级(商业版支持)4=实时监测)
* */
mqttPublish(device, model) {
let topic = '';
let message = '';
if (model.type == 4) {
// 实时监测
topic = '/' + device.productId + '/' + device.serialNumber + '/monitor/get';
message = '{"count":' + model.value + ',"interval":' + this.monitorInterval + '}';
} else {
return;
}
if (topic != '') {
// 发布
this.$mqttTool
.publish(topic, message, model.name)
.then((res) => {
this.$modal.notifySuccess(res);
})
.catch((res) => {
this.$modal.notifyError(res);
});
}
},
/* Mqtt回调处理 */
mqttCallback() {
this.$mqttTool.client.on('message', (topic, message, buffer) => {
let topics = topic.split('/');
let productId = topics[1];
let deviceNum = topics[2];
message = JSON.parse(message.toString());
if (!message) {
return;
}
if (topics[3] == 'status') {
console.log('接收到【设备状态】主题:', topic);
console.log('接收到【设备状态】内容:', message);
// 更新列表中设备的状态
if (this.deviceInfo.serialNumber == deviceNum) {
this.deviceInfo.status = message.status;
this.deviceInfo.isShadow = message.isShadow;
this.deviceInfo.rssi = message.rssi;
}
}
if (topics[3] == 'monitor') {
console.log('接收到【实时监测】主题:', topic);
console.log('接收到【实时监测】内容:', message);
// 实时监测
this.chartLoading = false;
for (let k = 0; k < message.length; k++) {
let value = message[k].value;
let id = message[k].id;
let remark = message[k].remark;
// 数据加载到图表
for (let i = 0; i < this.dataList.length; i++) {
if (id == this.dataList[i].id) {
// 普通类型匹配
if (this.dataList[i].length > 50) {
this.dataList[i].shift();
}
this.dataList[i].data.push([this.getTime(), value]);
// 更新图表
this.chart[i].setOption({
series: [
{
data: this.dataList[i].data,
},
],
});
break;
} else if (this.dataList[i].id.indexOf('array_') == 0) {
// 数组类型匹配,例如gateway_temperature,图表id去除前缀后匹配
let index = this.dataList[i].id.substring(6, 8);
let identity = this.dataList[i].id.substring(9);
if (identity == id) {
let values = value.split(',');
if (this.dataList[i].length > 50) {
this.dataList[i].shift();
}
this.dataList[i].data.push([this.getTime(), values[index]]);
// 更新图表
this.chart[i].setOption({
series: [
{
data: this.dataList[i].data,
},
],
});
break;
}
}
}
}
}
});
},
/** 更新实时监测参数*/
beginMonitor() {
if (this.deviceInfo.status != 3) {
this.$modal.alertError('设备不在线,下发指令失败');
return;
}
// 清空图表数据
for (let i = 0; i < this.dataList.length; i++) {
this.dataList[i].data = [];
}
if (this.monitorInterval < 500 || this.monitorInterval > 10000) {
this.$modal.alertError('实时监测的间隔范围500-10000毫秒');
}
if (this.monitorNumber == 0 || this.monitorNumber > 300) {
this.$modal.alertError('实时监测数量范围1-300');
}
// Mqtt发布实时监测消息
let model = {};
model.name = '更新实时监测';
model.value = this.monitorNumber;
model.type = 4;
this.mqttPublish(this.deviceInfo, model);
this.chartLoading = true;
},
/** 停止实时监测 */
stopMonitor() {
if (this.deviceInfo.status != 3) {
this.$modal.alertError('设备不在线,下发指令失败');
return;
}
this.chartLoading = false;
// Mqtt发布实时监测
let model = {};
model.name = '关闭实时监测';
model.value = 0;
model.type = 4;
this.mqttPublish(this.deviceInfo, model);
},
/**监测数据 */
getMonitorChart() {
let color = ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'];
for (let i = 0; i < this.monitorThings.length; i++) {
// 设置宽度
this.$refs.monitor[i].style.width = document.documentElement.clientWidth / 2 - 255 + 'px';
this.chart[i] = this.$echarts.init(this.$refs.monitor[i]);
var option;
option = {
title: {
left: 'center',
text: this.monitorThings[i].name + ' (单位 ' + (this.monitorThings[i].datatype.unit != undefined ? this.monitorThings[i].datatype.unit : '无') + '',
textStyle: {
fontSize: 14,
},
},
grid: {
top: '50px',
left: '20px',
right: '20px',
bottom: '10px',
containLabel: true,
},
tooltip: {
trigger: 'axis',
axisPointer: {
animation: true,
},
},
xAxis: {
type: 'time',
show: false,
splitLine: {
show: false,
},
},
yAxis: {
type: 'value',
boundaryGap: [0, '100%'],
splitLine: {
show: true,
},
},
series: [
{
name: this.monitorThings[i].name,
type: 'line',
symbol: 'none',
sampling: 'lttb',
itemStyle: {
color: i > 9 ? color[0] : color[i],
},
areaStyle: {},
data: [],
},
],
};
option && this.chart[i].setOption(option);
}
},
/* 获取当前时间*/
getTime() {
let date = new Date();
let y = date.getFullYear();
let m = date.getMonth() + 1;
let d = date.getDate();
let H = date.getHours();
let mm = date.getMinutes();
let s = date.getSeconds();
m = m < 10 ? '0' + m : m;
d = d < 10 ? '0' + d : d;
H = H < 10 ? '0' + H : H;
return y + '-' + m + '-' + d + ' ' + H + ':' + mm + ':' + s;
},
},
};
</script>

View File

@@ -1,192 +1,225 @@
<template>
<div style="padding-left:20px;">
<div style="padding-left: 20px">
<el-row>
<el-col :span="24">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="75px" style="">
<el-form-item label="时间范围">
<el-date-picker v-model="daterangeTime" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item label="最大数量">
<el-input v-model="queryParams.total"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="getStatisticData">查询</el-button>
</el-form-item>
</el-form>
</el-col>
<el-col :span="23">
<div v-for="(item,index) in monitorThings" :key="index" style="margin-bottom:30px;">
<el-card shadow="hover" :body-style="{ padding: '10px 0px',overflow:'auto' }" v-loading="loading">
<div ref="statisticMap" style="height:300px;width:1080px;"></div>
</el-card>
</div>
</el-col>
<el-col :span="24">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="75px">
<el-form-item label="请选择设备从机:" label-width="120px" v-if="isSubDev">
<el-select v-model="queryParams.slaveId" placeholder="请选择设备从机" @change="selectSlave">
<el-option v-for="slave in slaveList" :key="slave.slaveId" :label="`${slave.deviceName} (${slave.slaveId})`"
:value="slave.slaveId"></el-option>
</el-select>
</el-form-item>
<el-form-item label="时间范围">
<el-date-picker v-model="daterangeTime" size="small" style="width: 240px" value-format="yyyy-MM-dd"
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="getListHistory">查询</el-button>
</el-form-item>
</el-form>
</el-col>
<el-col :span="23">
<div v-for="(item, index) in staticList" :key="index" style="margin-bottom: 30px">
<el-card shadow="hover" :body-style="{ padding: '10px 0px', overflow: 'auto' }" v-loading="loading">
<div ref="statisticMap" style="height: 300px; width: 1080px"></div>
</el-card>
</div>
</el-col>
</el-row>
</div>
</div>
</template>
<script>
import * as echarts from 'echarts';
import {
cacheJsonThingsModel
} from "@/api/iot/model";
import {
listMonitor
} from "@/api/iot/deviceLog";
import { listHistory } from '@/api/iot/deviceLog';
export default {
name: "device-statistic",
props: {
device: {
type: Object,
default: null
}
name: 'device-statistic',
props: {
device: {
type: Object,
default: null,
},
watch: {
// 获取到父组件传递的device后
device: function (newVal, oldVal) {
this.deviceInfo = newVal;
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
this.getCacheThingsModdel(this.deviceInfo.productId);
},
watch: {
// 获取到父组件传递的device后
device: function (newVal, oldVal) {
this.deviceInfo = newVal;
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
this.isSubDev = this.deviceInfo.subDeviceList && this.deviceInfo.subDeviceList.length > 0;
this.queryParams.slaveId = this.deviceInfo.slaveId;
this.queryParams.serialNumber = this.deviceInfo.serialNumber;
this.slaveList = newVal.subDeviceList;
// 监测数据
if (this.isSubDev) {
this.staticList = this.deviceInfo.cacheThingsModel['properties'].filter((item) => {
return item.tempSlaveId == this.queryParams.slaveId;
});
} else {
this.staticList = this.deviceInfo.staticList;
}
// 加载图表
this.$nextTick(function () {
// 绘制图表
this.getStatistic();
});
}
},
},
data() {
return {
loading: true,
// 设备信息
deviceInfo: {},
// 统计物模型
staticList: [],
// 图表集合
chart: [],
// 激活时间范围
daterangeTime: [this.getTime(), this.getTime()],
// 查询参数
queryParams: {
serialNumber: null,
identity: '',
slaveId: undefined,
},
// 对象数组类型物模型暂存数据
arrayData: [],
// 子设备列表
slaveList: [],
isSubDev: false,
};
},
mounted() {
// 获取统计数据
// this.getListHistory();
},
methods: {
/** 获取当前日期 **/
getTime() {
let date = new Date();
let y = date.getFullYear();
let m = date.getMonth() + 1;
let d = date.getDate();
m = m < 10 ? '0' + m : m;
d = d < 10 ? '0' + d : d;
return y + '-' + m + '-' + d;
},
/* 获取监测历史数据*/
getListHistory() {
this.loading = true;
this.queryParams.serialNumber = this.queryParams.slaveId ? this.deviceInfo.serialNumber + '_' + this.queryParams.slaveId : this.deviceInfo.serialNumber;
if (null != this.daterangeTime && '' != this.daterangeTime) {
this.queryParams.beginTime = this.daterangeTime[0];
this.queryParams.endTime = this.daterangeTime[1] + ' 23:59';
}
listHistory(this.queryParams).then((res) => {
for (let key in res.data) {
for (let i = 0; i < this.staticList.length; i++) {
if (key == this.staticList[i].id) {
// 对象转数组
let dataList = [];
for (let j = 0; j < res.data[key].length; j++) {
let item = [];
item[0] = res.data[key][j].time;
item[1] = res.data[key][j].value;
dataList.push(item);
}
// 图表显示数据
this.chart[i].setOption({
series: [
{
data: dataList,
},
],
});
}
}
}
this.loading = false;
});
},
data() {
return {
loading: false,
// 设备信息
deviceInfo: {},
// 监测物模型
monitorThings: [],
// 图表集合
chart: [],
// 激活时间范围
daterangeTime: [],
// 查询参数
queryParams: {
deviceId: 0,
identity: "",
total: 1000,
/**监测统计数据 */
getStatistic() {
let color = ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'];
for (let i = 0; i < this.staticList.length; i++) {
// 设置宽度
this.$refs.statisticMap[i].style.width = document.documentElement.clientWidth - 510 + 'px';
this.chart[i] = this.$echarts.init(this.$refs.statisticMap[i]);
var option;
option = {
animationDurationUpdate: 3000,
tooltip: {
trigger: 'axis',
},
title: {
left: 'center',
text: this.staticList[i].name + '统计 (单位 ' + (this.staticList[i].datatype && this.staticList[i].datatype.unit != undefined ? this.staticList[i].datatype.unit : '无') + '',
},
grid: {
top: '80px',
left: '50px',
right: '20px',
bottom: '80px',
// containLabel: true,
},
toolbox: {
feature: {
dataZoom: {
yAxisIndex: 'none',
},
restore: {},
saveAsImage: {},
},
},
xAxis: {
type: 'time',
},
yAxis: {
type: 'value',
},
dataZoom: [
{
type: 'inside',
start: 0,
end: 100,
},
{
start: 0,
end: 100,
},
],
series: [
{
name: this.staticList[i].name,
type: 'line',
symbol: 'none',
sampling: 'lttb',
itemStyle: {
color: i > 9 ? color[0] : color[i],
},
areaStyle: {},
data: [],
},
],
};
option && this.chart[i].setOption(option);
}
},
mounted() {
/*选择从机*/
selectSlave() {
this.staticList = this.deviceInfo.cacheThingsModel['properties'].filter((item) => {
return item.tempSlaveId == this.queryParams.slaveId;
});
// 加载图表
this.$nextTick(function () {
// 绘制图表
this.getStatistic();
// 获取统计数据
this.getListHistory();
});
},
methods: {
/** 获取物模型*/
getCacheThingsModdel(productId) {
// 获取缓存的Json物模型
cacheJsonThingsModel(productId).then(response => {
let thingsModel = JSON.parse(response.data);
// 筛选监测数据
this.monitorThings = thingsModel.properties.filter(item => item.isMonitor == 1);
// 加载图表
this.$nextTick(function () {
// 绘制图表
this.getStatistic();
// 获取统计数据
this.getStatisticData(this.monitorThings);
});
});
},
/** 获取统计数据 */
getStatisticData() {
this.loading = true;
for (let i = 0; i < this.monitorThings.length; i++) {
this.queryParams.deviceId = this.deviceInfo.deviceId;
this.queryParams.identity = this.monitorThings[i].id;
if (null != this.daterangeTime && '' != this.daterangeTime) {
this.queryParams.beginTime = this.daterangeTime[0];
this.queryParams.endTime = this.daterangeTime[1]+" 23:59";
}
listMonitor(this.queryParams).then(response => {
let data = response.rows;
// 对象转数组
let dataList = [];
for (let j = 0; j < data.length; j++) {
let item = [];
item[0] = data[j].time;
item[1] = data[j].value;
dataList.push(item);
}
this.chart[i].setOption({
series: [{
data: dataList
}]
});
this.loading = false;
});
}
},
/**监测统计数据 */
getStatistic() {
let color = ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'];
for (let i = 0; i < this.monitorThings.length; i++) {
// 设置宽度
this.$refs.statisticMap[i].style.width = (document.documentElement.clientWidth - 510) + "px";
console.log(this.$refs.statisticMap[i]);
this.chart[i] = echarts.init(this.$refs.statisticMap[i]);
var option;
option = {
animationDurationUpdate: 3000,
tooltip: {
trigger: 'axis',
},
title: {
left: 'center',
text: this.monitorThings[i].name + '统计 (单位 ' + (this.monitorThings[i].datatype.unit != undefined ? this.monitorThings[i].datatype.unit : "无") + "",
},
grid: {
top: '80px',
left: '40px',
right: '20px',
bottom: '60px',
containLabel: true
},
toolbox: {
feature: {
dataZoom: {
yAxisIndex: 'none'
},
restore: {},
saveAsImage: {}
}
},
xAxis: {
type: 'time',
},
yAxis: {
type: 'value',
},
dataZoom: [{
type: 'inside',
start: 0,
end: 100
},
{
start: 0,
end: 100
}
],
series: [{
name: this.monitorThings[i].name,
type: 'line',
symbol: 'none',
sampling: 'lttb',
itemStyle: {
color: i > 9 ? color[0] : color[i]
},
areaStyle: {},
data: []
}]
};
option && this.chart[i].setOption(option);
}
},
}
},
};
</script>

File diff suppressed because it is too large Load Diff

View File

@@ -1,234 +1,348 @@
<template>
<div style="padding-left:20px;">
<div style="padding-left: 20px">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-share" size="mini" @click="selectUser" v-hasPermi="['iot:device:share']">分享设备</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-refresh" size="mini" @click="getList">刷新</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-share" size="mini" @click="shareDevice" v-hasPermi="['iot:device:share']">分享设备</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-refresh" size="mini" @click="getList">刷新</el-button>
</el-col>
</el-row>
<el-table v-loading="loading" :data="deviceUserList" @selection-change="handleSelectionChange" size="mini">
<el-table-column label="用户编号" align="center" prop="userId" width="100" />
<el-table-column label="用户名称" align="center" prop="userName" />
<el-table-column label="手机号码" align="center" prop="phonenumber" width="150" />
<el-table-column label="用户类型" align="center" prop="isOwner" width="150">
<template slot-scope="scope">
<el-tag type="primary" v-if="scope.row.isOwner">主人</el-tag>
<el-tag type="success" v-else>分享</el-tag>
</template>
</el-table-column>
<el-table-column label="分享时间" align="center" prop="createTime" width="150">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="left" prop="remark" header-align="center" min-width="150" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:device:share']" v-if="scope.row.isOwner==0">备注</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:device:share']" v-if="scope.row.isOwner==0">取消分享</el-button>
</template>
</el-table-column>
<el-table-column label="用户编号" align="center" prop="userId" width="100" />
<el-table-column label="用户名称" align="center" prop="userName" />
<el-table-column label="手机号码" align="center" prop="phonenumber" width="150" />
<el-table-column label="用户类型" align="center" prop="isOwner" width="150">
<template slot-scope="scope">
<el-tag type="primary" v-if="scope.row.isOwner">主人</el-tag>
<el-tag type="success" v-else>分享</el-tag>
</template>
</el-table-column>
<el-table-column label="分享时间" align="center" prop="createTime" width="150">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="left" prop="remark" header-align="center" min-width="150" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:device:share']" v-if="scope.row.isOwner == 0">编辑</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:device:share']" v-if="scope.row.isOwner == 0">取消分享</el-button>
</template>
</el-table-column>
</el-table>
<!-- 添加或修改设备用户对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" rows="4" />
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
<!--设备分享对话框-->
<el-dialog title="设备分享" :visible.sync="open" width="800px">
<div style="margin-top: -50px">
<el-divider></el-divider>
</div>
<!--用户查询-->
<el-form :model="permParams" ref="queryForm" :rules="rules" :inline="true" label-width="80px" v-if="type == 1">
<el-form-item label="手机号码" prop="phonenumber">
<el-input type="text" placeholder="请输入用户手机号码" v-model="permParams.phonenumber" minlength="10" clearable size="small" show-word-limit style="width: 240px" @keyup.enter.native="handleQuery"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="userQuery">查询用户</el-button>
</el-form-item>
</el-form>
<!--用户信息和权限设置-->
<div v-loading="permsLoading" style="background-color: #f8f8f9; line-height: 28px">
<div v-if="message" style="padding: 20px">{{ message }}</div>
<div v-if="form.userId" style="padding: 15px">
<div style="font-weight: bold; line-height: 28px">用户信息</div>
<span style="width: 80px; display: inline-block">用户ID</span>
<span>{{ form.userId }}</span>
<br />
<span style="width: 80px; display: inline-block">手机号码</span>
<span>{{ form.phonenumber }}</span>
<br />
<span style="width: 80px; display: inline-block">用户名称</span>
<span>{{ form.userName }}</span>
<br />
<!--选择权限-->
<div style="font-weight: bold; margin: 15px 0 10px">设置用户权限</div>
<el-table :data="sharePermissionList" highlight-current-row size="mini" ref="multipleTable" @select="handleSelectionChange" @select-all="handleSelectionAll">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="权限名称" align="center" key="modelName" prop="modelName" />
<el-table-column label="权限标识" align="center" key="identifier" prop="identifier" />
<el-table-column label="备注信息" align="left" min-width="100" header-align="center" key="remark" prop="remark" />
</el-table>
<!--选择权限-->
<div style="font-weight: bold; margin: 15px 0 10px">备注信息</div>
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" rows="2" />
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" :disabled="!form.userId || !deviceInfo.deviceId">确定</el-button>
<el-button @click="closeSelectUser"> </el-button>
</div>
</el-dialog>
<!-- 选择用户 -->
<user-list ref="userList" :device="devices" />
</div>
</div>
</template>
<script>
import userList from "./user-list"
import {
listDeviceUser,
getDeviceUser,
delDeviceUser,
updateDeviceUser
} from "@/api/iot/deviceuser";
import { addDeviceUser, listDeviceUser, getDeviceUser, delDeviceUser, updateDeviceUser, shareUser } from '@/api/iot/deviceuser';
import { permListModel } from '@/api/iot/model';
export default {
name: "device-user",
dicts: ['iot_yes_no'],
components: {
userList
name: 'device-user',
dicts: ['iot_yes_no'],
props: {
device: {
type: Object,
default: null,
},
props: {
device: {
type: Object,
default: null
}
},
watch: {
// 获取到父组件传递的device后刷新列表
device: function (newVal, oldVal) {
this.deviceInfo = newVal;
this.devices = [newVal];
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
this.queryParams.deviceId = this.deviceInfo.deviceId;
this.getList();
}
}
},
data() {
return {
// 设备列表
devices: [],
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 总条数
total: 0,
// 设备用户表格数据
deviceUserList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
deviceName: null,
userName: null,
userId: null,
tenantName: null,
isOwner: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
deviceName: [{
required: true,
message: "设备名称不能为空",
trigger: "blur"
}],
userName: [{
required: true,
message: "用户昵称不能为空",
trigger: "blur"
}],
}
};
},
created() {
},
watch: {
// 获取到父组件传递的device后刷新列表
device: function (newVal, oldVal) {
this.deviceInfo = newVal;
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
this.queryParams.deviceId = this.deviceInfo.deviceId;
this.getList();
}
},
methods: {
/** 查询设备用户列表 */
getList() {
this.loading = true;
listDeviceUser(this.queryParams).then(response => {
this.deviceUserList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
deviceId: null,
userId: null,
deviceName: null,
userName: null,
tenantId: null,
tenantName: null,
isOwner: null,
limitNum: null,
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.deviceId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加设备用户";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const deviceId = row.deviceId || this.ids
getDeviceUser(deviceId, row.userId).then(response => {
this.form = response.data;
this.open = true;
this.title = "用户备注";
});
},
/** 提交按钮 */
submitForm() {
if (this.form.deviceId != null) {
updateDeviceUser(this.form).then(response => {
this.$modal.msgSuccess("备注成功");
this.open = false;
this.getList();
},
data() {
return {
// 类型,1=新增2=更新
type: 1,
// 消息提示
message: '',
// 权限遮罩层
permsLoading: false,
// 权限列表
sharePermissionList: [],
// 设备信息
deviceInfo: {},
// 是否显示选择用户弹出层
open: false,
// 查询参数
permParams: {
userName: undefined,
phonenumber: undefined,
deviceId: null,
},
// 查询表单验证
rules: {
phonenumber: [
{
required: true,
message: '手机号码不能为空',
trigger: 'blur',
},
{
min: 11,
max: 11,
message: '手机号码长度为11位',
trigger: 'blur',
},
],
},
// 遮罩层
loading: true,
// 总条数
total: 0,
// 设备用户表格数据
deviceUserList: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
deviceName: null,
userName: null,
userId: null,
tenantName: null,
isOwner: null,
},
// 表单参数
form: {},
};
},
created() {
this.queryParams.deviceId = this.device.deviceId;
this.getList();
},
methods: {
/** 查询设备用户列表 */
getList() {
this.loading = true;
listDeviceUser(this.queryParams).then((response) => {
this.deviceUserList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 表单重置
reset() {
this.form = {
deviceId: null,
userId: null,
deviceName: null,
userName: null,
perms: null,
phonenumber: null,
remark: null,
};
this.sharePermissionList = [];
this.message = '';
this.resetForm('form');
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.type = 2; //更新
getDeviceUser(row.deviceId, row.userId).then((response) => {
this.form = response.data;
// 查询物模型权限列表
this.getPermissionList();
this.open = true;
});
},
// 设备分享
shareDevice() {
this.type = 1; // 新增
this.open = true;
},
/** 删除按钮操作 */
handleDelete(row) {
const deviceUser = row;
this.$modal
.confirm('确认取消分享设备?')
.then(function () {
return delDeviceUser(deviceUser);
})
.then(() => {
this.getList();
this.$modal.msgSuccess('取消分享成功');
})
.catch(() => {});
},
/** 用户按钮操作 */
userQuery() {
this.$refs['queryForm'].validate((valid) => {
if (valid) {
this.reset();
this.getShareUser();
}
});
},
/** 查询用户 */
getShareUser() {
this.permsLoading = true;
if (!this.deviceInfo.deviceId) {
this.$modal.alert('查询不到设备信息,请刷新后重试');
return;
}
this.permParams.deviceId = this.deviceInfo.deviceId;
shareUser(this.permParams).then((response) => {
if (response.data) {
this.form = response.data;
// 查询物模型权限列表
this.getPermissionList();
} else {
this.permsLoading = false;
this.message = '查询不到用户信息,或者该用户已经是设备用户';
}
});
},
/** 查询产品物模型设备权限列表 */
async getPermissionList() {
let perms = [];
if (this.form.perms) {
perms = this.form.perms.split(',');
}
console.log('deviceInfo', this.deviceInfo);
permListModel(this.deviceInfo.productId).then((response) => {
// 固定增加设备系统相关权限
this.sharePermissionList = [
{
identifier: 'timer',
modelName: '设备定时',
remark: '定时执行任务',
},
{
identifier: 'log',
modelName: '设备日志',
remark: '包含事件日志和指令日志',
},
{
identifier: 'monitor',
modelName: '实时监测',
remark: '下发实时监测指令后,图表实时显示设备上报数据',
},
{
identifier: 'statistic',
modelName: '监测统计',
remark: '图表显示存储的历史监测数据',
},
];
this.sharePermissionList = this.sharePermissionList.concat(response.data);
// 设置选中
if (perms.length > 0) {
for (let i = 0; i < this.sharePermissionList.length; i++) {
for (let j = 0; j < perms.length; j++) {
if (this.sharePermissionList[i].identifier == perms[j]) {
this.$nextTick(() => {
this.$refs.multipleTable.toggleRowSelection(this.sharePermissionList[i], true);
});
break;
}
}
},
/** 删除按钮操作 */
handleDelete(row) {
const deviceUser = row;
this.$modal.confirm('确认取消分享设备?').then(function () {
return delDeviceUser(deviceUser);
}).then(() => {
this.getList();
this.$modal.msgSuccess("取消分享成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('iot/deviceUser/export', {
...this.queryParams
}, `deviceUser_${new Date().getTime()}.xlsx`)
},
// 选择用户
selectUser() {
this.devices = [this.device]
this.$refs.userList.openSelectUser = true;
},
}
}
}
this.permsLoading = false;
});
},
// 重置查询
resetUserQuery() {
this.resetForm('queryForm');
this.reset();
},
// 关闭选择用户
closeSelectUser() {
this.open = false;
this.resetUserQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.form.perms = selection.map((x) => x.identifier).join(',');
},
// 全选事件处理
handleSelectionAll(selection) {
this.form.perms = selection.map((x) => x.identifier).join(',');
},
/** 提交按钮 */
submitForm() {
if (this.type == 2) {
// 更新设备用户
updateDeviceUser(this.form).then((response) => {
this.$modal.msgSuccess('更新成功');
this.resetUserQuery();
this.open = false;
this.getList();
});
} else if (this.type == 1) {
// 添加设备用户
this.form.deviceId = this.deviceInfo.deviceId;
this.form.deviceName = this.deviceInfo.deviceName;
addDeviceUser(this.form).then((response) => {
this.$modal.msgSuccess('新增成功');
this.resetUserQuery();
this.open = false;
this.getList();
});
}
},
},
};
</script>

File diff suppressed because it is too large Load Diff

View File

@@ -103,6 +103,10 @@ export default {
getList() {
this.loading = true;
listProduct(this.queryParams).then(response => {
//产品列表初始化isSelect值用于单选
for (let i = 0; i < response.rows.length; i++) {
response.rows[i].isSelect = false;
}
this.productList = response.rows;
this.total = response.total;
if (this.productId != 0) {

File diff suppressed because it is too large Load Diff

View File

@@ -1,264 +1,289 @@
<template>
<div style="padding:6px;">
<el-card v-show="showSearch" style="margin-bottom:6px;">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom:-20px;">
<el-form-item label="分组名称" prop="groupName">
<el-input v-model="queryParams.groupName" placeholder="请输入分组名称" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="我的分组" v-if="isAdmin" style="margin:0 20px;">
<el-switch v-model="myGroup" @change="myGroupChange"></el-switch>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
<el-form-item style="float:right;">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:group:add']">新增</el-button>
</el-form-item>
<div style="padding: 6px">
<el-card v-show="showSearch" style="margin-bottom: 6px">
<el-form ref="queryForm" :model="queryParams" :inline="true" label-width="68px" style="margin-bottom: -20px">
<el-form-item label="分组名称" prop="groupName">
<el-input v-model="queryParams.groupName" placeholder="请输入分组名称" clearable size="small"
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item v-if="isAdmin" label="我的分组" style="margin: 0 20px">
<el-switch v-model="myGroup" @change="myGroupChange"></el-switch>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
<el-form-item style="float: right">
<el-button v-hasPermi="['iot:group:add']" type="primary" plain icon="el-icon-plus" size="mini"
@click="handleAdd">新增</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card style="padding-bottom: 100px">
<el-table v-loading="loading" :data="groupList" border @selection-change="handleSelectionChange">
<el-table-column label="分组名称" align="center" prop="groupName" width="200" />
<el-table-column label="分组排序" align="center" prop="groupOrder" width="100" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column v-if="isAdmin" label="所属用户" align="center" prop="userName" width="100" />
<el-table-column label="备注" align="left" header-align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="320">
<template slot-scope="scope">
<el-button v-hasPermi="['iot:device:query']" size="small" type="warning" style="padding: 5px"
icon="el-icon-search" @click="handleViewDevice(scope.row.groupId)">查看设备</el-button>
<el-button v-hasPermi="['iot:group:add']" size="small" type="success" style="padding: 5px" icon="el-icon-edit"
@click="selectDevice(scope.row)">添加设备</el-button>
<el-button v-hasPermi="['iot:group:edit']" size="small" type="primary" style="padding: 5px"
icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
<el-button v-hasPermi="['iot:group:remove']" size="small" type="danger" style="padding: 5px"
icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 分组设备列表 -->
<deviceList ref="groupDeviceList" :group="group"></deviceList>
<!-- 添加或修改设备分组对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="分组名称" prop="groupName">
<el-input v-model="form.groupName" placeholder="请输入分组名称" />
</el-form-item>
<el-form-item label="分组排序" prop="groupOrder">
<el-input v-model="form.groupOrder" type="number" placeholder="请输入分组排序" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</el-card>
<el-card style="padding-bottom:100px;">
<el-table v-loading="loading" :data="groupList" @selection-change="handleSelectionChange" border>
<el-table-column label="分组名称" align="center" prop="groupName" width="200" />
<el-table-column label="分组排序" align="center" prop="groupOrder" width="100" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="left" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="320">
<template slot-scope="scope">
<el-button size="small" type="warning" style="padding:5px;" icon="el-icon-search" @click="handleViewDevice(scope.row.groupId)" v-hasPermi="['iot:device:query']">查看设备</el-button>
<el-button size="small" type="success" style="padding:5px;" icon="el-icon-edit" @click="selectDevice(scope.row)" v-hasPermi="['iot:group:edit']">添加设备</el-button>
<el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:group:edit']">修改</el-button>
<el-button size="small" type="danger" style="padding:5px;" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:group:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 分组设备列表 -->
<deviceList ref="groupDeviceList" :group="group"></deviceList>
<!-- 添加或修改设备分组对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="分组名称" prop="groupName">
<el-input v-model="form.groupName" placeholder="请输入分组名称" />
</el-form-item>
<el-form-item label="分组排序" prop="groupOrder">
<el-input v-model="form.groupOrder" type="number" placeholder="请输入分组排序" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</el-card>
</div>
</div>
</template>
<script>
import deviceList from "./device-list"
import {
listGroup,
getGroup,
delGroup,
addGroup,
updateGroup,
} from "@/api/iot/group";
import deviceList from './device-list'
import { listGroup, getGroup, delGroup, addGroup, updateGroup } from '@/api/iot/group'
import {getUserId} from "@/utils/auth";
export default {
name: "Group",
components: {
deviceList
},
data() {
return {
// 是否管理员
isAdmin: false,
// 我的分组
myGroup: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 设备分组表格数据
groupList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
groupName: null,
userId: null,
},
// 设备分组
group: {},
// 表单参数
form: {},
// 表单校验
rules: {
groupName: [{
required: true,
message: "分组名称不能为空",
trigger: "blur"
}],
groupOrder: [{
required: true,
message: "分组排序不能为空,最大值为99",
trigger: "blur"
}],
}
};
},
created() {
this.getList();
this.init();
},
methods: {
init() {
if (this.$store.state.user.roles.indexOf("tenant") === -1 && this.$store.state.user.roles.indexOf("general") === -1) {
this.isAdmin = true
}
},
// 我的分组改变事件
myGroupChange() {
this.queryParams.userId = this.myGroup ? this.$store.state.user.userId : null;
},
/** 查看设备按钮操作 */
handleViewDevice(groupId) {
this.$router.push({
path: '/iot/device',
query: {
t: Date.now(),
groupId: groupId,
}
});
},
/** 查询设备分组列表 */
getList() {
this.loading = true;
listGroup(this.queryParams).then(response => {
this.groupList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
groupId: null,
groupName: null,
groupOrder: null,
userId: null,
userName: null,
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.groupId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加设备分组";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const groupId = row.groupId || this.ids
getGroup(groupId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改设备分组";
});
},
/** 选择设备 */
selectDevice(row) {
this.group = row;
// 刷新子组件
this.$refs.groupDeviceList.openDeviceList = true;
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.groupId != null) {
updateGroup(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addGroup(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const groupIds = row.groupId || this.ids;
this.$modal.confirm('是否确认删除设备分组编号为"' + groupIds + '"的数据项?').then(function () {
return delGroup(groupIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('iot/group/export', {
...this.queryParams
}, `group_${new Date().getTime()}.xlsx`)
},
name: 'Group',
components: {
deviceList,
},
data() {
return {
// 是否管理员
isAdmin: false,
// 我的分组
myGroup: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 设备分组表格数据
groupList: [],
// 弹出层标题
title: '',
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
groupName: null,
userId: null,
},
// 设备分组
group: {},
// 表单参数
form: {},
// 表单校验
rules: {
groupName: [
{
required: true,
message: '分组名称不能为空',
trigger: 'blur',
},
{
min: 1,
max: 64,
message: '分组名称不能少于1个字符和超过64字符',
},
],
groupOrder: [
{
required: true,
message: '分组排序不能为空,最大值为99',
trigger: 'blur',
},
{
max: 128,
message: '分组排序不能少于1个位和超过10位',
trigger: 'blur',
},
],
},
}
};
},
created() {
this.getList()
this.init()
},
methods: {
init() {
if (this.$store.state.user.roles.indexOf('tenant') === -1 && this.$store.state.user.roles.indexOf('general') === -1) {
this.isAdmin = true
}
},
// 我的分组改变事件
myGroupChange() {
this.queryParams.userId = this.myGroup ? getUserId() : null;
this.handleQuery();
},
/** 查看设备按钮操作 */
handleViewDevice(groupId) {
this.$router.push({
path: '/iot/device',
query: {
t: Date.now(),
groupId: groupId,
},
})
},
/** 查询设备分组列表 */
getList() {
this.loading = true
listGroup(this.queryParams).then((response) => {
this.groupList = response.rows
this.total = response.total
this.loading = false
})
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
groupId: null,
groupName: null,
groupOrder: null,
userId: null,
userName: null,
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null,
}
this.resetForm('form')
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm('queryForm')
this.handleQuery()
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.groupId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.open = true
this.title = '添加设备分组'
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const groupId = row.groupId || this.ids
getGroup(groupId).then((response) => {
this.form = response.data
this.open = true
this.title = '修改设备分组'
})
},
/** 选择设备 */
selectDevice(row) {
this.group = row
// 刷新子组件
this.$refs.groupDeviceList.openDeviceList = true
},
/** 提交按钮 */
submitForm() {
this.$refs['form'].validate((valid) => {
if (valid) {
if (this.form.groupId != null) {
updateGroup(this.form).then((response) => {
this.$modal.msgSuccess('修改成功')
this.open = false
this.getList()
})
} else {
addGroup(this.form).then((response) => {
this.$modal.msgSuccess('新增成功')
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const groupIds = row.groupId || this.ids
this.$modal
.confirm('是否确认删除设备分组编号为"' + groupIds + '"的数据项?')
.then(function () {
return delGroup(groupIds)
})
.then(() => {
this.getList()
this.$modal.msgSuccess('删除成功')
})
.catch(() => { })
},
/** 导出按钮操作 */
handleExport() {
this.download(
'iot/group/export',
{
...this.queryParams,
},
`group_${new Date().getTime()}.xlsx`
)
},
},
}
</script>

View File

@@ -0,0 +1,324 @@
<template>
<div style="padding: 6px">
<el-card v-show="showSearch" style="margin-bottom: 6px">
<el-form @submit.native.prevent :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom: -20px">
<el-form-item label="客户端" prop="clientId">
<el-input v-model="queryParams.clientId" placeholder="请输入客户端ID" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item prop="isClient">
<el-checkbox v-model="queryParams.isClient" true-label="1" false-label="0">只看设备端</el-checkbox>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-tabs type="border-card" v-model="serverType" @tab-click="handleClick" style="flex: 1; height: 800px; margin-bottom: 5px">
<el-tab-pane label="MQTT客户端" name="MQTT">
<el-table v-loading="loading" :data="clientList">
<el-table-column label="客户端ID" align="left" header-align="center" prop="clientId">
<template slot-scope="scope">
<el-link :underline="false" type="primary" @click.native="handleOpen(scope.row)">{{ scope.row.clientId }}</el-link>
</template>
</el-table-column>
<el-table-column label="类型" align="center" prop="type">
<template slot-scope="scope">
<el-tag type="danger" v-if="scope.row.clientId.indexOf('server') == 0">服务端</el-tag>
<el-tag type="success" v-else-if="scope.row.clientId.indexOf('web') == 0">Web端</el-tag>
<el-tag type="warning" v-else-if="scope.row.clientId.indexOf('phone') == 0">移动端</el-tag>
<el-tag type="info" v-else-if="scope.row.clientId.indexOf('test') == 0">测试端</el-tag>
<el-tag type="primary" v-else>设备端</el-tag>
</template>
</el-table-column>
<el-table-column label="连接状态" align="center" prop="connected">
<template slot-scope="scope">
<el-tag type="success" v-if="scope.row.connected">已连接</el-tag>
<el-tag type="info" v-else>已断开</el-tag>
</template>
</el-table-column>
<el-table-column label="心跳(秒)" align="center" prop="keepAlive" width="100" />
<el-table-column label="账号" align="center" prop="username" width="100px" />
<el-table-column label="当前订阅数量" align="center" prop="topicCount" width="100" />
<el-table-column label="连接时间" align="center" prop="connected_at" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="clickClientOut(scope.row)">踢出</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- MQTT客户端详细 -->
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
<el-tabs v-model="activeName" tab-position="top" style="padding: 10px">
<el-tab-pane name="subscribe">
<span slot="label">订阅列表</span>
<el-row :gutter="10" class="mb8"></el-row>
<el-table :data="subscribeList" size="mini">
<el-table-column label="主题" align="center" prop="topicName" />
<el-table-column label="QoS" align="center" prop="qos" />
</el-table>
</el-tab-pane>
</el-tabs>
</el-dialog>
</el-tab-pane>
<el-tab-pane label="TCP客户端" name="TCP">
<el-table v-loading="loading" :data="clientList">
<el-table-column label="客户端ID" align="left" header-align="center" prop="clientId"></el-table-column>
<el-table-column label="类型" align="center" prop="type">
<template slot-scope="scope">
<el-tag type="danger" v-if="scope.row.clientId.indexOf('server') == 0">服务端</el-tag>
<el-tag type="success" v-else-if="scope.row.clientId.indexOf('web') == 0">Web端</el-tag>
<el-tag type="warning" v-else-if="scope.row.clientId.indexOf('phone') == 0">移动端</el-tag>
<el-tag type="info" v-else-if="scope.row.clientId.indexOf('test') == 0">测试端</el-tag>
<el-tag type="primary" v-else>设备端</el-tag>
</template>
</el-table-column>
<el-table-column label="连接状态" align="center" prop="connected">
<template slot-scope="scope">
<el-tag type="success" v-if="scope.row.connected">已连接</el-tag>
<el-tag type="info" v-else>已断开</el-tag>
</template>
</el-table-column>
<el-table-column label="心跳(秒)" align="center" prop="keepAlive" width="100" />
<el-table-column label="连接时间" align="center" prop="connected_at" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="clickClientOut(scope.row)">踢出</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- MQTT客户端详细 -->
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
<el-tabs v-model="activeName" tab-position="top" style="padding: 10px">
<el-tab-pane name="subscribe">
<span slot="label">订阅列表</span>
<el-row :gutter="10" class="mb8"></el-row>
<el-table :data="subscribeList" size="mini">
<el-table-column label="主题" align="center" prop="topicName" />
<el-table-column label="QoS" align="center" prop="qos" />
</el-table>
</el-tab-pane>
</el-tabs>
</el-dialog>
</el-tab-pane>
</el-tabs>
<!-- 添加或修改订阅对话框 -->
<el-dialog title="添加订阅" :visible.sync="subscribeOpen" width="800px" append-to-body>
<el-form ref="subscribeForm" :model="subscribeForm" :rules="rules" label-width="60px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="主题" prop="topic">
<el-input v-model="subscribeForm.topic" placeholder="请输入主题" />
</el-form-item>
<el-form-item label="Qos" prop="qos">
<el-select v-model="subscribeForm.qos" placeholder="请选择消息类型">
<el-option key="0" label="0" value="0"></el-option>
<el-option key="1" label="1" value="1"></el-option>
<el-option key="2" label="2" value="2"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancelSubscribe"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { clientOut, listNettyMqttClient } from '@/api/iot/netty';
export default {
name: 'Category',
data() {
return {
// 非单个禁用
single: true,
// 遮罩层
loading: true,
loadSubscribeing: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 产品分类表格数据
clientList: [],
// 弹出层标题
title: '',
// 是否显示弹出层
open: false,
// 是否显示添加订阅弹出层
subscribeOpen: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
clientId: null,
isClient: 0,
serverCode: 'MQTT',
},
// 表单参数
form: {},
// 选中选项卡
activeName: 'subscribe',
//订阅列表数据
subscribeList: [],
//订阅数据
subscribe: {
topic: '',
clientId: '',
},
//添加订阅表单参数
subscribeForm: {
qos: '0',
},
//客户端ID
clientId: '',
//服务协议类型
serverType: 'MQTT',
// 表单校验
rules: {
topic: [
{
required: true,
message: '主题不能为空',
trigger: 'blur',
},
],
},
};
},
created() {
this.getList();
},
methods: {
/** 查询客户端列表 */
getList() {
this.loading = true;
listNettyMqttClient(this.queryParams).then((response) => {
this.clientList = response.data;
this.total = response.total;
this.loading = false;
});
},
/*将客户端踢出*/
clickClientOut(row) {
const params = { clientId: row.clientId };
clientOut(params).then((res) => {
//刷新列表
this.getList();
});
},
/*tabs切换*/
handleClick() {
this.queryParams.serverCode = this.serverType;
this.getList();
},
/** 查询客户端订阅列表 */
getSubscribeList(clientId) {
this.clientId = clientId;
this.loadSubscribeing = true;
getSubscriptionsByClientId(clientId).then((res) => {
this.subscribeList = res.data.data;
this.loadSubscribeing = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm('queryForm');
this.handleQuery();
},
/** 断开客户端连接 */
handleDelete(row) {
const clientId = row.clientId;
this.$modal
.confirm('是否确认删除MQTT客户端编号为"' + clientId + '"的数据项?')
.then(function () {
return eliminateClient(clientId);
})
.then(() => {
this.getList();
this.$modal.msgSuccess('删除成功');
})
.catch(() => {});
},
//取消主题订阅
handleUnsubscribe(row) {
const clientId = row.clientId;
const topic = row.topic;
this.$modal
.confirm('是否确认取消订阅主题为"' + topic + '"的数据项?')
.then(function () {
const param = {};
param.topic = topic;
param.clientId = clientId;
return unsubscribe(param);
})
.then(() => {
this.getSubscribeList(clientId);
this.$modal.msgSuccess('取消订阅成功');
})
.catch(() => {});
},
//查看客户端详情
handleOpen(row) {
this.open = true;
this.title = '详情';
this.subscribeList = row.topics;
console.log(this.subscribeList);
},
//添加订阅
handleAdd() {
this.subscribeOpen = true;
},
//提交添加订阅表单
submitForm() {
this.subscribeForm.clientId = this.clientId;
console.log(this.subscribeForm);
this.$refs['subscribeForm'].validate((valid) => {
if (valid) {
addSubscribe(this.subscribeForm).then((response) => {
this.$modal.msgSuccess('新增订阅成功');
this.subscribeOpen = false;
this.getSubscribeList(this.clientId);
});
}
});
},
cancelSubscribe() {
this.subscribeOpen = false;
this.resetForm('subscribeForm');
//刷新列表
this.getSubscribeList(this.clientId);
},
},
};
</script>

View File

@@ -0,0 +1,346 @@
<template>
<div style="padding: 6px">
<el-card style="margin-bottom: 6px">
<el-row :gutter="120">
<el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="8">
<h3 style="font-weight: bold">Mqtt 统计指标</h3>
<el-row :gutter="20" class="panel-group">
<el-col :span="24" class="card-panel-col" style="margin-bottom: 17px">
<div class="card-panel">
<div class="card-panel-icon-wrapper icon-orange">
<svg-icon icon-class="guide" class-name="card-panel-icon" />
</div>
<div class="card-panel-description">
<div>
<div class="card-panel-text">发送消息</div>
<count-to :start-val="0" :end-val="this.static['send_total']" :duration="3000" class="card-panel-num" />
</div>
</div>
</div>
</el-col>
<el-col :span="24" class="card-panel-col" style="margin-bottom: 18px">
<div class="card-panel">
<div class="card-panel-icon-wrapper icon-green">
<svg-icon icon-class="receiver" class-name="card-panel-icon" />
</div>
<div class="card-panel-description">
<div>
<div class="card-panel-text">接收消息</div>
<count-to :start-val="0" :end-val="this.static['receive_total']" :duration="3000" class="card-panel-num" />
</div>
</div>
</div>
</el-col>
<el-col :span="24" class="card-panel-col" style="margin-bottom: 17px">
<div class="card-panel">
<div class="card-panel-icon-wrapper icon-orange">
<svg-icon icon-class="authenticate" class-name="card-panel-icon" />
</div>
<div class="card-panel-description">
<div class="card-panel-text">认证次数</div>
<count-to :start-val="0" :end-val="this.static['auth_total']" :duration="1000" class="card-panel-num" />
</div>
</div>
</el-col>
<el-col :span="24" class="card-panel-col" style="margin-bottom: 18px">
<div class="card-panel">
<div class="card-panel-icon-wrapper icon-green">
<svg-icon icon-class="connect" class-name="card-panel-icon" />
</div>
<div class="card-panel-description">
<div class="card-panel-text">连接次数</div>
<count-to :start-val="0" :end-val="this.static['connect_total']" :duration="1000" class="card-panel-num" />
</div>
</div>
</el-col>
<el-col :span="24" class="card-panel-col" style="margin-bottom: 17px">
<div class="card-panel">
<div class="card-panel-icon-wrapper icon-orange">
<svg-icon icon-class="subscribe1" class-name="card-panel-icon" />
</div>
<div class="card-panel-description">
<div class="card-panel-text">订阅次数</div>
<count-to :start-val="0" :end-val="this.static['subscribe_total']" :duration="2000" class="card-panel-num" />
</div>
</div>
</el-col>
<el-col :span="24" class="card-panel-col" style="margin-bottom: 17px">
<div class="card-panel">
<div class="card-panel-icon-wrapper icon-green">
<svg-icon icon-class="message" class-name="card-panel-icon" />
</div>
<div class="card-panel-description">
<div>
<div class="card-panel-text">今日接收</div>
<count-to :start-val="0" :end-val="this.static['today_received']" :duration="3000" class="card-panel-num" />
</div>
</div>
</div>
</el-col>
<el-col :span="24" class="card-panel-col" style="margin-bottom: 17px">
<div class="card-panel">
<div class="card-panel-icon-wrapper icon-orange">
<svg-icon icon-class="subscribe1" class-name="card-panel-icon" />
</div>
<div class="card-panel-description">
<div class="card-panel-text">今日发送</div>
<count-to :start-val="0" :end-val="this.static['today_send']" :duration="2000" class="card-panel-num" />
</div>
</div>
</el-col>
</el-row>
</el-col>
<el-col :xs="24" :sm="24" :md="24" :lg="15" :xl="15">
<div style="padding: 30px 0 85px">
<div ref="pieTotal" style="height: 230px"></div>
</div>
<div ref="statsChart" style="height: 275px; margin: 20px 0 40px 0"></div>
</el-col>
</el-row>
</el-card>
</div>
</template>
<script>
import { getNettyMqttStats, statisticNettyMqtt } from '@/api/iot/netty';
import CountTo from 'vue-count-to';
export default {
name: 'Mqtt',
components: {
CountTo,
},
data() {
return {
// mqtt状态数据
stats: {},
// mqtt统计信息
static: {},
};
},
created() {
this.getMqttStats();
this.statisticMqtt();
},
methods: {
/** 查询mqtt统计*/
statisticMqtt() {
statisticNettyMqtt().then((response) => {
this.static = response.data;
this.totalMqtt();
});
},
/** 查询mqtt状态数据*/
getMqttStats() {
getNettyMqttStats().then((response) => {
this.stats = response.data;
this.drawStats();
});
},
// 绘制mqtt饼图
totalMqtt() {
// 基于准备好的dom初始化echarts实例
let myChart = this.$echarts.init(this.$refs.pieTotal);
var option;
option = {
title: {
text: 'Mqtt消息',
left: 'left',
textStyle: {
fontSize: 16,
},
},
tooltip: {
trigger: 'item',
},
legend: {
orient: 'vertical',
left: 'right',
},
color: ['#E6A23C', '#F56C6C', '#DDD'],
series: [
{
name: 'Mqtt消息 %',
type: 'pie',
radius: '55%',
label: {
show: true,
},
labelLine: {
normal: {
position: 'inner',
show: false,
},
},
data: [
{
value: this.static['send_total'],
name: '发送消息总数',
},
{
value: this.static['receive_total'],
name: '接收消息总数',
},
],
},
],
};
option && myChart.setOption(option);
},
/** 绘制mqtt状态统计 */
drawStats() {
// 基于准备好的dom初始化echarts实例
let myChart = this.$echarts.init(this.$refs.statsChart);
var option;
option = {
title: {
text: 'Mqtt 状态数据',
textStyle: {
fontSize: 18,
color: '#000',
fontWeight: 800,
},
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
},
legend: {},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
},
xAxis: {
type: 'value',
boundaryGap: [0, 0.01],
},
yAxis: {
type: 'category',
axisLabel: {
fontSize: 14,
},
data: ['连接数量', '会话数量', '订阅数量', '路由数量', '保留消息'],
},
series: [
{
name: '当前数量',
type: 'bar',
data: [this.stats['connection_count'], this.stats['session_count'], this.stats['subscription_count'], this.stats['retain_count'], this.stats['retain_count']],
itemStyle: {
color: '#67C23A',
},
},
{
name: '累计总数',
type: 'bar',
data: [this.stats['connection_total'], this.stats['session_total'], this.stats['subscription_total'], this.stats['retain_total'], this.stats['retain_total']],
itemStyle: {
color: '#409EFF',
},
},
],
};
option && myChart.setOption(option);
},
},
};
</script>
<style lang="scss" scoped>
.panel-group {
.card-panel-col {
margin-bottom: 10px;
}
.card-panel {
height: 68px;
cursor: pointer;
position: relative;
overflow: hidden;
color: #666;
border: 1px solid #eee;
border-radius: 5px;
//box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.08);
background-color: #fff;
&:hover {
.card-panel-icon-wrapper {
color: #fff;
}
.icon-blue {
background: #36a3f7;
}
.icon-green {
background: #34bfa3;
}
.icon-red {
background: #f56c6c;
}
.icon-orange {
background: #e6a23c;
}
}
.icon-blue {
color: #36a3f7;
}
.icon-green {
color: #34bfa3;
}
.icon-red {
color: #f56c6c;
}
.icon-orange {
color: #e6a23c;
}
.card-panel-icon-wrapper {
float: left;
margin: 10px;
padding: 10px;
transition: all 0.38s ease-out;
border-radius: 6px;
}
.card-panel-icon {
float: left;
font-size: 30px;
}
.card-panel-description {
float: right;
font-weight: bold;
margin: 15px;
margin-left: 0px;
.card-panel-text {
line-height: 14px;
color: rgba(0, 0, 0, 0.45);
font-size: 14px;
margin-bottom: 12px;
text-align: right;
}
.card-panel-num {
font-size: 18px;
}
}
}
}
</style>

View File

@@ -1,165 +1,185 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="60px" v-if="isAdmin">
<el-form-item label="标题" prop="title">
<el-input v-model="queryParams.title" placeholder="请输入标题" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="分类" prop="categoryName">
<el-input v-model="queryParams.categoryName" placeholder="请输入分类名称" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="置顶" prop="isTop">
<el-select v-model="queryParams.isTop" placeholder="是否置顶" clearable size="small" style="width:100px;">
<el-option v-for="dict in dict.type.iot_yes_no" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="轮播" prop="isBanner">
<el-select v-model="queryParams.isBanner" placeholder="是否轮播" clearable size="small" style="width:100px;">
<el-option v-for="dict in dict.type.iot_yes_no" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="60px" v-if="isAdmin">
<el-form-item label="标题" prop="title">
<el-input v-model="queryParams.title" placeholder="请输入标题" clearable size="small"
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="分类" prop="categoryName">
<el-input v-model="queryParams.categoryName" placeholder="请输入分类名称" clearable size="small"
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="置顶" prop="isTop">
<el-select v-model="queryParams.isTop" placeholder="是否置顶" clearable size="small" style="width:100px;">
<el-option v-for="dict in dict.type.iot_yes_no" :key="dict.value" :label="dict.label"
:value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="轮播" prop="isBanner">
<el-select v-model="queryParams.isBanner" placeholder="是否轮播" clearable size="small" style="width:100px;">
<el-option v-for="dict in dict.type.iot_yes_no" :key="dict.value" :label="dict.label"
:value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="发布" prop="status">
<el-select v-model="queryParams.status" placeholder="选择状态" clearable size="small" style="width:100px;">
<el-option v-for="dict in dict.type.iot_yes_no" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:news:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['iot:news:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['iot:news:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['iot:news:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="newsList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="图片" align="center" prop="imgUrl" width="140px;">
<template slot-scope="scope">
<el-image style="border-radius:5px;height:80px;width:120px;margin-bottom:-5px;" lazy :preview-src-list="[baseUrl+scope.row.imgUrl]" :src="baseUrl+scope.row.imgUrl" fit="cover"></el-image>
</template>
</el-table-column>
<el-table-column label="标题" align="center" prop="title" />
<el-table-column label="分类" align="center" prop="categoryName">
<template slot-scope="scope">
<el-tag type="info">{{scope.row.categoryName}}</el-tag>
</template>
</el-table-column>
<el-table-column label="作者" align="center" prop="author" width="100" />
<el-table-column label="置顶" align="center" prop="isTop" width="80">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isTop" />
</template>
</el-table-column>
<el-table-column label="轮播" align="center" prop="isBanner" width="80">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isBanner" />
</template>
</el-table-column>
<el-table-column label="发布" align="center" prop="status" width="80">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="120">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-view" @click="openDetailDialog(scope.row.newsId)">查看</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:news:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:news:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改新闻资讯对话框 -->
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="60px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="标题" prop="title">
<el-input v-model="form.title" placeholder="请输入标题" />
</el-form-item>
<el-form-item label="作者" prop="author">
<el-input v-model="form.author" placeholder="请输入作者" />
</el-form-item>
<el-form-item label="摘要" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" rows="3" />
</el-form-item>
<el-row>
<el-col :span="8">
<el-form-item label="置顶" prop="isTop">
<el-switch v-model="form.isTop" active-text="" inactive-text="" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="轮播" prop="isBanner">
<el-switch v-model="form.isBanner" active-text="" inactive-text="" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="发布" prop="status">
<el-switch v-model="form.status" active-text="" inactive-text="" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item>
</el-col>
</el-row>
</el-col>
<el-col :span="12">
<el-form-item label="分类" prop="categoryId">
<el-select v-model="form.categoryId" placeholder="请选择分类" @change="selectCategory">
<el-option v-for="category in categoryList" :key="category.id" :label="category.name" :value="category.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="图片">
<imageUpload ref="image-upload" :value="form.imgUrl" :limit="1" :fileSize="1" @input="getImagePath($event)"></imageUpload>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="内容">
<editor v-model="form.content" :min-height="192" />
<el-form-item label="发布" prop="status">
<el-select v-model="queryParams.status" placeholder="选择状态" clearable size="small" style="width:100px;">
<el-option v-for="dict in dict.type.iot_yes_no" :key="dict.value" :label="dict.label"
:value="dict.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!--通知公告详情 -->
<el-dialog :title="form.title" :visible.sync="openDetail" width="800px" append-to-body>
<div style="margin-top:-20px;margin-bottom:10px;">
<el-tag size="mini" effect="dark" type="success">{{form.categoryName}}</el-tag>
<span style="margin-left:20px;">{{form.createTime}}</span>
</div>
<div v-loading="loadingDetail" class="content">
<div v-html="form.content"></div>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="closeDetail"> </el-button>
</div>
</el-dialog>
</div>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['iot:news:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
v-hasPermi="['iot:news:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
v-hasPermi="['iot:news:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
v-hasPermi="['iot:news:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="newsList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="图片" align="center" prop="imgUrl" width="140px;">
<template slot-scope="scope">
<el-image style="border-radius:5px;height:80px;width:120px;margin-bottom:-5px;" lazy
:preview-src-list="[baseUrl + scope.row.imgUrl]" :src="baseUrl + scope.row.imgUrl"
fit="cover"></el-image>
</template>
</el-table-column>
<el-table-column label="标题" align="center" prop="title" />
<el-table-column label="分类" align="center" prop="categoryName">
<template slot-scope="scope">
<el-tag type="info">{{ scope.row.categoryName }}</el-tag>
</template>
</el-table-column>
<el-table-column label="作者" align="center" prop="author" width="100" />
<el-table-column label="置顶" align="center" prop="isTop" width="80">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isTop" />
</template>
</el-table-column>
<el-table-column label="轮播" align="center" prop="isBanner" width="80">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isBanner" />
</template>
</el-table-column>
<el-table-column label="发布" align="center" prop="status" width="80">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="120">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-view"
@click="openDetailDialog(scope.row.newsId)">查看</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['iot:news:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['iot:news:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 添加或修改新闻资讯对话框 -->
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="60px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="标题" prop="title">
<el-input v-model="form.title" placeholder="请输入标题" />
</el-form-item>
<el-form-item label="作者" prop="author">
<el-input v-model="form.author" placeholder="请输入作者" />
</el-form-item>
<el-form-item label="摘要" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" rows="3" />
</el-form-item>
<el-row>
<el-col :span="8">
<el-form-item label="置顶" prop="isTop">
<el-switch v-model="form.isTop" active-text="" inactive-text="" :active-value="1"
:inactive-value="0"></el-switch>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="轮播" prop="isBanner">
<el-switch v-model="form.isBanner" active-text="" inactive-text="" :active-value="1"
:inactive-value="0"></el-switch>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="发布" prop="status">
<el-switch v-model="form.status" active-text="" inactive-text="" :active-value="1"
:inactive-value="0"></el-switch>
</el-form-item>
</el-col>
</el-row>
</el-col>
<el-col :span="12">
<el-form-item label="分类" prop="categoryId">
<el-select v-model="form.categoryId" placeholder="请选择分类" @change="selectCategory">
<el-option v-for="category in categoryList" :key="category.id" :label="category.name"
:value="category.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="图片">
<imageUpload ref="image-upload" :value="form.imgUrl" :limit="1" :fileSize="1"
@input="getImagePath($event)"></imageUpload>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="内容">
<editor v-model="form.content" :min-height="192" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!--通知公告详情 -->
<el-dialog :title="form.title" :visible.sync="openDetail" width="800px" append-to-body>
<div style="margin-top:-20px;margin-bottom:10px;">
<el-tag size="mini" effect="dark" type="success">{{ form.categoryName }}</el-tag>
<span style="margin-left:20px;">{{ form.createTime }}</span>
</div>
<div v-loading="loadingDetail" class="content">
<div v-html="form.content"></div>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="closeDetail"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
@@ -228,7 +248,13 @@ export default {
required: true,
message: "标题不能为空",
trigger: "blur"
}],
},
{
min: 1,
max: 64,
message: '标题不能少于1个字符和超过64字符',
},
],
content: [{
required: true,
message: "内容不能为空",
@@ -243,7 +269,12 @@ export default {
required: true,
message: "作者不能为空",
trigger: "blur"
}],
},
{
min: 1,
max: 50,
message: '作者名称不能少于1个字符和超过50字符',
},],
}
};
},
@@ -367,7 +398,7 @@ export default {
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}).catch(() => { });
},
/** 导出按钮操作 */
handleExport() {
@@ -404,11 +435,9 @@ export default {
};
</script>
<style lang="scss" scoped>
.content {
<style lang="scss" scoped>.content {
line-height: 24px;
padding: 10px;
border: 1px solid #eee;
border-radius: 10px;
}
</style>
}</style>

View File

@@ -1,71 +1,83 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="分类名称" prop="categoryName">
<el-input v-model="queryParams.categoryName" placeholder="请输入分类名称" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:category:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['iot:category:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['iot:category:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['iot:category:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="categoryList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="分类编号" align="center" prop="categoryId" />
<el-table-column label="分类名称" align="center" prop="categoryName" />
<el-table-column label="显示顺序" align="center" prop="orderNum" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" min-width="200" header-align="center" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:category:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:category:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改新闻分类对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="分类名称" prop="categoryName">
<el-input v-model="form.categoryName" placeholder="请输入分类名称" />
<el-input v-model="queryParams.categoryName" placeholder="请输入分类名称" clearable size="small"
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="显示顺序" prop="orderNum">
<el-input v-model="form.orderNum" placeholder="请输入显示顺序" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['iot:newsCategory:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
v-hasPermi="['iot:newsCategory:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
v-hasPermi="['iot:newsCategory:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
v-hasPermi="['iot:newsCategory:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="categoryList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="分类编号" align="center" prop="categoryId" />
<el-table-column label="分类名称" align="center" prop="categoryName" />
<el-table-column label="显示顺序" align="center" prop="orderNum" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" min-width="200" header-align="center" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-view" @click="handleUpdate(scope.row)"
v-hasPermi="['iot:newsCategory:add']">查看</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['iot:newsCategory:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 添加或修改新闻分类对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="分类名称" prop="categoryName">
<el-input v-model="form.categoryName" placeholder="请输入分类名称" />
</el-form-item>
<el-form-item label="显示顺序" prop="orderNum">
<el-input-number v-model="form.orderNum" placeholder="请输入显示顺序" type="number" controls-position="right"
style="width: 100%" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" v-hasPermi="['iot:newsCategory:edit']"
v-show="form.categoryId"> </el-button>
<el-button type="primary" @click="submitForm" v-hasPermi="['iot:newsCategory:add']"
v-show="!form.categoryId"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
@@ -113,12 +125,19 @@ export default {
required: true,
message: "分类名字不能为空",
trigger: "blur"
}],
},
{
min: 1,
max: 64,
message: '分类名字不能少于1个字符和超过64字符',
},
],
orderNum: [{
required: true,
message: "显示顺序不能为空",
trigger: "blur"
}],
}
],
}
};
},
@@ -210,15 +229,15 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const categoryIds = row.categoryId || this.ids;
let msg="";
let msg = "";
this.$modal.confirm('是否确认删除新闻分类编号为"' + categoryIds + '"的数据项?').then(function () {
return delNewsCategory(categoryIds).then(response => {
msg=response.msg;
return delNewsCategory(categoryIds).then(response => {
msg = response.msg;
});
}).then(() => {
this.getList();
this.$modal.msgSuccess(msg);
}).catch(() => {});
}).catch(() => { });
},
/** 导出按钮操作 */
handleExport() {

View File

@@ -23,7 +23,7 @@
</el-form>
</el-card>
<el-card style="padding-bottom:100px;">
<el-row :gutter="30" v-loading="loading" >
<el-row :gutter="30" v-loading="loading">
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="6" v-for="(item,index) in productList" :key="index" style="margin-bottom:30px;text-align:center;">
<el-card :body-style="{ padding: '20px'}" shadow="always" class="card-item">
<el-row type="flex" :gutter="10" justify="space-between">
@@ -35,10 +35,10 @@
</el-col>
<el-col :span="4">
<el-tooltip class="item" effect="dark" content="取消发布" placement="top-start" v-if="item.status==2">
<el-button type="success" size="mini" style="padding:5px;" @click="changeProductStatus(item.productId,1)">已发布</el-button>
<el-button type="success" size="mini" style="padding:5px;" @click="changeProductStatus(item.productId,1,item.deviceType)">已发布</el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="现在发布" placement="top-start" v-if="item.status==1">
<el-button type="info" size="mini" style="padding:5px;" @click="changeProductStatus(item.productId,2)">未发布</el-button>
<el-button type="info" size="mini" style="padding:5px;" @click="changeProductStatus(item.productId,2,item.deviceType)">未发布</el-button>
</el-tooltip>
</el-col>
</el-row>
@@ -63,12 +63,14 @@
<el-col :span="10">
<div style="margin-top:10px;">
<el-image style="width:100%;height:100px;border-radius:10px;" lazy :preview-src-list="[baseUrl+item.imgUrl]" :src="baseUrl+item.imgUrl" fit="cover" v-if="item.imgUrl!=null && item.imgUrl!=''"></el-image>
<el-image style="width:100%;height:100px;border-radius:10px;" :preview-src-list="[require('@/assets/images/product.jpg')]" :src="require('@/assets/images/product.jpg')" fit="cover" v-else></el-image>
<el-image style="width:100%;height:100px;border-radius:10px;" :preview-src-list="[require('@/assets/images/gateway.png')]" :src="require('@/assets/images/gateway.png')" fit="cover" v-else-if="item.deviceType==2"></el-image>
<el-image style="width:100%;height:100px;border-radius:10px;" :preview-src-list="[require('@/assets/images/video.png')]" :src="require('@/assets/images/video.png')" fit="cover" v-else-if="item.deviceType==3"></el-image>
<el-image style="width:100%;height:100px;border-radius:10px;" :preview-src-list="[require('@/assets/images/product.png')]" :src="require('@/assets/images/product.png')" fit="cover" v-else></el-image>
</div>
</el-col>
</el-row>
<el-button-group style="margin-top:15px;height:28px;">
<el-button size="mini" type="primary" icon="el-icon-edit" @click="handleEditProduct(item)" v-hasPermi="['iot:product:edit']">详情</el-button>
<el-button size="mini" type="primary" icon="el-icon-view" @click="handleEditProduct(item)" v-hasPermi="['iot:product:query']">详情</el-button>
<el-button size="mini" type="danger" icon="el-icon-delete" @click="handleDelete(item)" v-hasPermi="['iot:product:remove']" v-if="item.status==1">删除</el-button>
<el-button size="mini" type="success" icon="el-icon-s-check" @click="handleDeviceAuthorize(item)" v-hasPermi="['iot:product:edit']" v-if="item.status==2" :disabled="item.isAuthorize!=1">设备授权</el-button>
<el-button size="mini" type="warning" icon="el-icon-search" @click="handleViewDevice(item.productId)" v-hasPermi="['iot:device:query']">查看设备</el-button>
@@ -104,9 +106,14 @@
import {
listProduct,
delProduct,
changeProductStatus
changeProductStatus,
deviceCount,
} from "@/api/iot/product";
import {
checkPermi
} from "@/utils/permission"
export default {
name: "Product",
dicts: ['iot_yes_no', 'iot_product_status', 'iot_device_type', 'iot_network_method', 'iot_vertificate_method', 'iot_device_chip'],
@@ -162,13 +169,38 @@ export default {
this.loading = false;
});
},
/**同步获取产品下的设备数量**/
getDeviceCountByProductId(productId) {
return new Promise((resolve, reject) => {
deviceCount(productId).then(res => {
resolve(res);
}).catch(error => {
reject(error);
})
})
},
/** 更新产品状态 */
changeProductStatus(productId,status) {
let message="发生错误了";
if(status==2){
message="产品发布后不能再更改产品内容和对应物模型 ";
}else if(status==1){
message="产品下不能有已经创建的设备,才能取消发布哦 "
async changeProductStatus(productId, status, deviceType) {
let message = "确定取消发布?";
if (status == 2) {
// 发布
let hasPermission = checkPermi(['iot:product:add']);
if (!hasPermission) {
this.$modal.alertError("没有操作权限");
return;
}
message = "产品发布后,可以创建对应的设备";
} else if (status == 1) {
// 取消发布
let hasPermission = checkPermi(['iot:product:edit']);
if (!hasPermission) {
this.$modal.alertError("没有操作权限");
return;
}
let result = await this.getDeviceCountByProductId(productId);
if (result.data > 0) {
message = "重要提示:产品下已有 " + result.data + " 个设备,取消发布可以修改产品信息和模型,重新发布后对应设备状态将会被重置!"
}
}
this.$confirm(message, '提示', {
confirmButtonText: '确定',
@@ -178,6 +210,7 @@ export default {
let data = {};
data.productId = productId;
data.status = status;
data.deviceType = deviceType;
changeProductStatus(data).then(response => {
this.getList();
this.$modal.alertSuccess(response.msg);
@@ -217,16 +250,16 @@ export default {
},
/** 下载SDK */
downloadSdk() {
this.$download.zip("/iot/tool/genSdk?deviceChip=" + 1, "wumeismart-sdk");
this.$download.zip("/iot/tool/genSdk?deviceChip=" + 1, "fastbee-sdk");
},
/** 删除按钮操作 */
handleDelete(row) {
const productIds = row.productId || this.ids;
let msg = "";
this.$modal.confirm('是否确认删除产品编号为"' + productIds + '"的数据项?').then(function () {
return delProduct(productIds).then(response => {
msg = response.msg;
});
// // 删除SIP配置
// delSipconfigByProductId(productIds).then(response => {});
return delProduct(productIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess(msg);
@@ -246,14 +279,14 @@ export default {
}
});
},
/** 设备授权操作 */
/** 设备授权操作 */
handleDeviceAuthorize(row) {
let productId = row.productId
this.$router.push({
path: '/iot/product-edit',
query: {
productId: productId,
tabPanelName:'productAuthorize',
tabPanelName: 'productAuthorize',
pageNum: this.queryParams.pageNum
}
});
@@ -264,6 +297,6 @@ export default {
<style scoped>
.card-item {
border-radius:15px;
border-radius: 15px;
}
</style>

View File

@@ -108,7 +108,7 @@
<!-- 设备详情对话框 -->
<el-dialog title="设备详情" :visible.sync="openDevice" width="600px" append-to-body>
<div v-if="device==null" style="text-align:center;"><i class="el-icon-warning" style="color:#E6A23C;"></i> 提示查找不到设备可能已经被删除</div>
<div v-if="device==null" style="text-align:center;"><i class="el-icon-warning" style="color:#E6A23C;"></i> 提示查找不到设备可能已经被删除</div>
<el-descriptions border :column="2" size="medium" v-if="device!=null">
<el-descriptions-item label="设备ID">{{device.deviceId}}</el-descriptions-item>
<el-descriptions-item label="设备名称">{{device.deviceName}}</el-descriptions-item>
@@ -277,7 +277,7 @@ export default {
},
/** 修改按钮操作 */
goToEditDevice(deviceId) {
this.openDevice=false;
this.openDevice = false;
this.$router.push({
path: '/iot/device-edit',
query: {
@@ -290,6 +290,10 @@ export default {
this.deviceLoading = true;
this.deviceParams.params = {};
listUnAuthDevice(this.deviceParams).then(response => {
//设备列表初始化isSelect值用于单选
for (let i = 0; i < response.rows.length; i++) {
response.rows[i].isSelect = false;
}
this.deviceList = response.rows;
this.deviceTotal = response.total;
this.deviceLoading = false;

View File

@@ -1,136 +1,188 @@
<template>
<el-card style="margin:6px;padding-bottom:100px;">
<el-tabs v-model="activeName" tab-position="left" style="padding:10px;">
<el-tab-pane name="basic">
<span slot="label"><span style="color:red;">* </span>基本信息</span>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-row :gutter="100">
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
<el-form-item label="产品名称" prop="productName">
<el-input v-model="form.productName" placeholder="请输入产品名称" :readonly="form.status==2" />
</el-form-item>
<el-form-item label="产品分类" prop="categoryId">
<el-select v-model="form.categoryId" placeholder="请选择分类" @change="selectCategory" style="width:100%" :disabled="form.status==2">
<el-option v-for="category in categoryShortList" :key="category.id" :label="category.name" :value="category.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="联网方式" prop="networkMethod">
<el-select v-model="form.networkMethod" placeholder="请选择联网方式" style="width:100%;" :disabled="form.status==2">
<el-option v-for="dict in dict.type.iot_network_method" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"></el-option>
</el-select>
</el-form-item>
<el-form-item label="启用授权" prop="networkMethod">
<el-switch v-model="form.isAuthorize" @change="changeIsAuthorize(form.isAuthorize)" :active-value="1" :inactive-value="0" :disabled="form.status==2" />
</el-form-item>
<el-form-item label="备注信息" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" rows="3" :readonly="form.status==2" />
<el-card style="margin:6px;padding-bottom:100px;">
<el-tabs v-model="activeName" tab-position="left" style="padding:10px;min-height:400px;" @tab-click="tabChange">
<el-tab-pane name="basic">
<span slot="label"><span style="color:red;">* </span>基本信息</span>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-row :gutter="100">
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
<el-form-item label="产品名称" prop="productName">
<el-input v-model="form.productName" placeholder="请输入产品名称" :readonly="form.status == 2" />
</el-form-item>
<el-form-item label="产品分类" prop="categoryId">
<el-select v-model="form.categoryId" placeholder="请选择分类" @change="selectCategory"
style="width:100%" :disabled="form.status == 2">
<el-option v-for="category in categoryShortList" :key="category.id"
:label="category.name" :value="category.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备类型" prop="deviceType">
<el-select v-model="form.deviceType" placeholder="请选择设备类型" :disabled="form.status == 2"
style="width:100%">
<el-option v-for="dict in dict.type.iot_device_type" :key="dict.value"
:label="dict.label" :value="parseInt(dict.value)"></el-option>
</el-select>
</el-form-item>
<el-form-item label="传输协议" prop="transport">
<el-select v-model="form.transport" placeholder="请选择传输协议" style="width: 100%"
:disabled="form.status == 2">
<el-option v-for="dict in dict.type.iot_transport_type" :key="dict.value"
:label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item v-if="form.deviceType !== 3" label="编码协议" prop="protocolCode">
<el-select v-model="form.protocolCode" placeholder="请选择编码协议" style="width: 100%"
:disabled="form.status == 2" @change="changeProductCode">
<el-option v-for="p in protocolList" :key="p.protocolCode" :label="p.protocolName"
:value="p.protocolCode" />
</el-select>
</el-form-item>
<el-form-item label="联网方式" prop="networkMethod">
<el-select v-model="form.networkMethod" placeholder="请选择联网方式" style="width:100%;"
:disabled="form.status == 2">
<el-option v-for="dict in dict.type.iot_network_method" :key="dict.value"
:label="dict.label" :value="parseInt(dict.value)"></el-option>
</el-select>
</el-form-item>
<el-form-item label="备注信息" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" rows="3"
:readonly="form.status == 2" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
<el-form-item label="启用授权" prop="networkMethod">
<el-switch v-model="form.isAuthorize" @change="changeIsAuthorize(form.isAuthorize)"
:active-value="1" :inactive-value="0"
:disabled="form.status == 2 || form.deviceType == 3" />
</el-form-item>
<el-form-item label="认证方式" prop="vertificateMethod">
<el-select v-model="form.vertificateMethod" placeholder="请选择认证方式" style="width:100%"
:disabled="form.status == 2 || form.deviceType == 3">
<el-option v-for="dict in dict.type.iot_vertificate_method" :key="dict.value"
:label="dict.label" :value="parseInt(dict.value)"></el-option>
</el-select>
</el-form-item>
<el-form-item label="产品编号" prop="productId">
<el-input v-model="form.productId" placeholder="自动生成"
:disabled="!form.mqttAccount || form.deviceType == 3" readonly />
</el-form-item>
<el-form-item label="Mqtt账号" prop="mqttAccount">
<el-input v-model="form.mqttAccount" placeholder="不填自动生成" :disabled="form.deviceType == 3"
:readonly="accountInputType == 'password'" :type="accountInputType">
<el-button slot="append" icon="el-icon-view" style="font-size:18px;"
@click="changeInputType('account')"></el-button>
</el-input>
</el-form-item>
<el-form-item label="Mqtt密码" prop="mqttPassword">
<el-input v-model="form.mqttPassword" placeholder="不填则自动生成" :disabled="form.deviceType == 3"
:readonly="passwordInputType == 'password'" :type="passwordInputType">
<el-button slot="append" icon="el-icon-view" style="font-size:18px;"
@click="changeInputType('password')"></el-button>
</el-input>
</el-form-item>
<el-form-item label="产品秘钥" prop="mqttSecret">
<el-input v-model="form.mqttSecret" placeholder="自动生成"
:disabled="!form.mqttAccount || form.deviceType == 3" readonly :type="keyInputType">
<el-button slot="append" icon="el-icon-view" style="font-size:18px;"
@click="changeInputType('key')"></el-button>
</el-input>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
<el-form-item label="产品图片">
<div v-if="form.status == 2 && form.imgUrl == null">
<el-image style="height:145px;height:145px;border-radius:10px;"
:preview-src-list="[require('@/assets/images/gateway.png')]"
:src="require('@/assets/images/gateway.png')" fit="cover"
v-if="form.deviceType == 2"></el-image>
<el-image style="height:145px;height:145px;border-radius:10px;"
:preview-src-list="[require('@/assets/images/video.png')]"
:src="require('@/assets/images/video.png')" fit="cover"
v-else-if="form.deviceType == 3"></el-image>
<el-image style="height:145px;height:145px;border-radius:10px;"
:preview-src-list="[require('@/assets/images/product.png')]"
:src="require('@/assets/images/product.png')" fit="cover" v-else></el-image>
</div>
<div v-else>
<imageUpload ref="image-upload" :disabled="true" :value="form.imgUrl"
:limit="form.status == 2 ? 0 : 1" :fileSize="1" @input="getImagePath($event)">
</imageUpload>
</div>
<div class="el-upload__tip" style="color:#f56c6c"
v-if="form.productId == null || form.productId == 0">提示上传后需要提交保存</div>
</el-form-item>
</el-col>
</el-row>
<el-col :span="20">
<el-form-item style="text-align: center;margin:40px 0px;">
<el-button type="primary" @click="submitForm" v-hasPermi="['iot:product:edit']"
v-show="form.productId != 0 && form.status != 2"> </el-button>
<el-button type="primary" @click="submitForm" v-hasPermi="['iot:product:add']"
v-show="form.productId == 0 && form.status != 2"> </el-button>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
<el-form-item label="设备类型" prop="deviceType">
<el-select v-model="form.deviceType" placeholder="请选择设备类型" :disabled="form.status==2" style="width:100%">
<el-option v-for="dict in dict.type.iot_device_type" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"></el-option>
</el-select>
</el-form-item>
<el-form-item label="认证方式" prop="vertificateMethod">
<el-select v-model="form.vertificateMethod" placeholder="请选择认证方式" style="width:100%" :disabled="form.status==2">
<el-option v-for="dict in dict.type.iot_vertificate_method" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"></el-option>
</el-select>
</el-form-item>
<el-form-item label="产品编号" prop="productId">
<el-input v-model="form.productId" placeholder="自动生成" :disabled="!form.mqttAccount" readonly />
</el-form-item>
<el-form-item label="Mqtt账号" prop="mqttAccount">
<el-input v-model="form.mqttAccount" placeholder="自动生成" :disabled="!form.mqttAccount" readonly :type="accountInputType">
<el-button slot="append" icon="el-icon-view" style="font-size:18px;" @click="changeInputType('account')"></el-button>
</el-input>
</el-form-item>
<el-form-item label="Mqtt密码" prop="mqttPassword">
<el-input v-model="form.mqttPassword" placeholder="自动生成" :disabled="!form.mqttAccount" readonly :type="passwordInputType">
<el-button slot="append" icon="el-icon-view" style="font-size:18px;" @click="changeInputType('password')"></el-button>
</el-input>
</el-form-item>
<el-form-item label="产品秘钥" prop="mqttSecret">
<el-input v-model="form.mqttSecret" placeholder="自动生成" :disabled="!form.mqttAccount" readonly :type="keyInputType">
<el-button slot="append" icon="el-icon-view" style="font-size:18px;" @click="changeInputType('key')"></el-button>
</el-input>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
<el-form-item label="产品图片">
<div v-if="form.status==2 && form.imgUrl==null">
<el-image style="height:145px;height:145px;border-radius:10px;" :preview-src-list="[require('@/assets/images/product.jpg')]" :src="require('@/assets/images/product.jpg')" fit="cover"></el-image>
</div>
<div v-else>
<imageUpload ref="image-upload" :disabled="true" :value="form.imgUrl" :limit="form.status==2 ? 0 : 1" :fileSize="1" @input="getImagePath($event)"></imageUpload>
</div>
<div class="el-upload__tip" style="color:#f56c6c" v-if="form.productId==null || form.productId==0">提示上传后需要提交保存</div>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-tab-pane>
<el-col :span="20">
<el-form-item style="text-align: center;margin:40px 0px;">
<el-button type="primary" @click="submitForm()" v-if="form.status!=2">提交</el-button>
</el-form-item>
</el-col>
</el-form>
</el-tab-pane>
<el-tab-pane label="" name="things" :disabled="form.productId == 0">
<span slot="label"><span style="color:red;">* </span>产品模型</span>
<product-things-model ref="productThingsModel" :product="form" />
</el-tab-pane>
<el-tab-pane label="" name="things" :disabled="form.productId==0">
<span slot="label"><span style="color:red;">* </span>产品模型</span>
<product-things-model ref="productThingsModel" :product="form" />
</el-tab-pane>
<el-tab-pane label="" name="productFirmware" :disabled="form.productId==0">
<span slot="label">固件管理</span>
<product-firmware ref="productFirmware" :product="form" />
</el-tab-pane>
<el-tab-pane label="" name="productAuthorize" :disabled="form.productId == 0" v-if="form.deviceType !== 3">
<span slot="label">设备授权</span>
<product-authorize ref="productAuthorize" :product="form" />
</el-tab-pane>
<el-tab-pane label="" name="productAuthorize" :disabled="form.productId==0 || form.isAuthorize==0">
<span slot="label">设备授权</span>
<product-authorize ref="productAuthorize" :product="form" />
</el-tab-pane>
<el-tab-pane label="" name="alert" :disabled="form.productId == 0" v-if="form.deviceType !== 3">
<span slot="label"><span style="color:red;"> </span>告警配置</span>
<business ref="business"/>
</el-tab-pane>
<el-tab-pane label="" name="alert" :disabled="form.productId==0">
<span slot="label"> 告警配置</span>
<product-alert ref="productAlert" :product="form"></product-alert>
</el-tab-pane>
<el-tab-pane label="" name="productApp" :disabled="form.productId==0">
<span slot="label">控制界面</span>
<product-app ref="productApp" :product="form" />
</el-tab-pane>
<div style="margin-top:200px;"></div>
<el-tab-pane label="" disabled name="product01" />
<el-tab-pane label="" disabled name="product02" />
<el-tab-pane label="" disabled name="product03" />
<el-tab-pane v-if="form.status==1" name="product04">
<span slot="label">
<el-button type="success" size="mini" @click="changeProductStatus(2)">发布产品</el-button>
</span>
</el-tab-pane>
<el-tab-pane v-if="form.status==2" name="product05">
<span slot="label">
<el-button type="danger" size="mini" @click="changeProductStatus(1)">取消发布</el-button>
</span>
</el-tab-pane>
<el-tab-pane name="product06">
<span slot="label">
<el-button type="info" size="mini" @click="goBack()">返回列表</el-button>
</span>
</el-tab-pane>
</el-tabs>
<!-- 用于设置间距 -->
<el-tab-pane>
<span slot="label">
<div style="margin-top:200px;"></div>
</span>
</el-tab-pane>
</el-card>
<el-tab-pane v-if="form.status == 1" name="product04" disabled>
<span slot="label">
<el-button type="success" size="mini" @click="changeProductStatus(2)"
v-hasPermi="['iot:product:add']">发布产品</el-button>
</span>
</el-tab-pane>
<el-tab-pane v-if="form.status == 2" name="product05" disabled>
<span slot="label">
<el-button type="danger" size="mini" @click="changeProductStatus(1)"
v-hasPermi="['iot:product:edit']">取消发布</el-button>
</span>
</el-tab-pane>
<el-tab-pane name="product06" disabled>
<span slot="label">
<el-button type="info" size="mini" @click="goBack()">返回列表</el-button>
</span>
</el-tab-pane>
</el-tabs>
</el-card>
</template>
<script>
import productThingsModel from "./product-things-model";
import productFirmware from "./product-firmware";
import productApp from "./product-app"
import productAlert from "./product-alert"
import productAuthorize from "./product-authorize"
import imageUpload from "../../../components/ImageUpload/index"
import business from "../business/index"
import {
listProtocol
} from "@/api/iot/protocol";
import {
listShortCategory,
} from "@/api/iot/category";
@@ -138,53 +190,106 @@ import {
getProduct,
addProduct,
updateProduct,
changeProductStatus
changeProductStatus,
deviceCount,
} from "@/api/iot/product";
import {
getAllPoints
} from "@/api/iot/template";
export default {
name: "ProductEdit",
dicts: ['iot_device_type', 'iot_network_method', 'iot_vertificate_method'],
dicts: ['iot_device_type', 'iot_network_method', 'iot_vertificate_method', 'iot_transport_type', 'data_collect_type'],
components: {
productThingsModel,
productApp,
productAlert,
productAuthorize,
productFirmware,
imageUpload,
business,
},
data() {
return {
// 输入框类型
keyInputType: "password",
accountInputType: "text",
accountInputType: "password",
passwordInputType: "password",
// 选中选项卡
activeName: 'basic',
// 分类短列表
categoryShortList: [],
//协议列表
protocolList: [],
// 表单参数
form: {
networkMethod: 1,
deviceType: 1,
vertificateMethod: 3,
transport: 'MQTT',
imgUrl: "",
},
// 表单校验
rules: {
productName: [{
required: true,
message: "产品名称不能为空",
trigger: "blur"
}],
trigger: "blur",
},
{
min: 1,
max: 64,
message: '产品名称不能少于1个字符和超过64字符',
trigger: 'blur',
},
],
categoryId: [{
required: true,
message: "产品分类ID不能为空",
trigger: "blur"
}],
deviceType: [{
required: true,
message: "请选择设备类型",
trigger: "blur"
}],
protocolCode: [{
required: true,
message: "设备协议不能为空",
trigger: "blur"
}],
transport: [{
required: true,
message: "传输协议不能为空",
trigger: 'blur'
}]
},
// 查询参数
queryParams: {
tenantName: null,
},
pointList: [],
open: false,
// 弹出层标题
title: "",
loading: true,
tempList: [],
// 总条数
total: 0,
tempTotal: 0,
// 查询参数
pointsParams: {
pageNum: 1,
pageSize: 8,
templateId: 0,
},
tempParams: {
pageNum: 1,
pageSize: 10,
},
currentRow: {},
selectRowData: {},
isModbus: false,
};
},
@@ -202,24 +307,31 @@ export default {
}
// 获取分类信息
this.getShortCategory();
// 设置账号密码输入框类型,新增时为text查看时为password
if (!this.form.productId || this.form.productId == 0) {
this.accountInputType = "text";
this.passwordInputType = "text";
}
this.getProtocol();
},
activated() {
const time = this.$route.query.t;
if (time != null && time != this.uniqueId) {
this.uniqueId = time;
// 获取产品信息
let productId = this.$route.query.productId
if (productId != null && productId != 0) {
this.form.productId = Number(productId);
this.getProduct();
this.getShortCategory();
}
// 切换选项卡
const tabPanelName = this.$route.query && this.$route.query.tabPanelName;
if (tabPanelName != null && tabPanelName != '') {
this.activeName = tabPanelName;
}
this.uniqueId = time;
}
// 获取产品信息
let productId = this.$route.query.productId
if (productId != null && productId != 0) {
this.form.productId = Number(productId);
this.getProduct();
this.getShortCategory();
}
// 切换选项卡
const tabPanelName = this.$route.query && this.$route.query.tabPanelName;
if (tabPanelName != null && tabPanelName != '') {
this.activeName = tabPanelName;
}
},
methods: {
// 获取简短分类列表
@@ -244,6 +356,7 @@ export default {
getProduct() {
getProduct(this.form.productId).then(response => {
this.form = response.data;
this.changeProductCode(this.form.protocolCode);
});
},
// 表单重置
@@ -262,7 +375,8 @@ export default {
mqttAccount: null,
mqttPassword: null,
mqttSecret: null,
remark: null
remark: null,
imgUrl: "",
};
this.resetForm("form");
},
@@ -272,25 +386,43 @@ export default {
if (valid) {
if (this.form.productId != null && this.form.productId != 0) {
updateProduct(this.form).then(response => {
this.changeProductCode(this.form.protocolCode);
this.$modal.alertSuccess("修改成功");
});
} else {
addProduct(this.form).then(response => {
this.$modal.alertSuccess("添加成功,可以开始定义物模型了");
if (!this.form.isModbus) {
this.$modal.alertSuccess("添加成功,可以开始定义物模型或配置");
} else {
this.$modal.alertSuccess("物模型已经从采集点模板同步至产品")
}
this.form = response.data;
this.activeName = "things";
this.changeProductCode(this.form.protocolCode);
});
}
}
});
},
/**同步获取产品下的设备数量**/
getDeviceCountByProductId(productId) {
return new Promise((resolve, reject) => {
deviceCount(productId).then(res => {
resolve(res);
}).catch(error => {
reject(error);
})
})
},
/** 更新产品状态 */
changeProductStatus(status) {
let message = "发生错误了";
async changeProductStatus(status) {
let message = "确定取消发布?";
if (status == 2) {
message = "产品发布后不能再更改产品内容和对应物模型";
message = "产品发布后,可以创建对应的设备";
} else if (status == 1) {
message = "产品下不能有已经创建的设备,才能取消发布哦"
let result = await this.getDeviceCountByProductId(this.form.productId);
if (result.data > 0) {
message = "重要提示:产品下已有 " + result.data + " 个设备,取消发布可以修改产品信息和模型,重新发布后对应设备状态将会被重置!"
}
}
this.$confirm(message, '提示', {
confirmButtonText: '确定',
@@ -300,12 +432,14 @@ export default {
let data = {};
data.productId = this.form.productId;
data.status = status;
data.deviceType = this.form.deviceType;
changeProductStatus(data).then(response => {
this.$modal.alertSuccess(response.msg);
this.goBack();
this.activeName = "basic";
this.getProduct();
}).catch(() => {
if (status == 2) {
this.activeName = "things";
this.activeName = "basic";
} else {
this.goBack();
}
@@ -349,7 +483,78 @@ export default {
}).catch(() => {
this.form.isAuthorize = 0;
});
}
},
//获取设备协议
getProtocol() {
const data = {
protocolStatus: 1
};
listProtocol(data).then(res => {
this.protocolList = res.rows;
})
},
// 取消按钮
cancel() {
this.open = false;
// this.reset();
},
getList() {
getAllPoints(this.pointsParams).then(response => {
this.pointList = response.rows;
this.total = response.total;
});
},
changeProductCode(val) {
if (val && val.startsWith("MODBUS")) {
this.form.deviceType = 2;
this.form.isModbus = true;
if (this.form.productId != 0 && this.form.productId != null) {
//this.getTempDetail()
}
} else {
this.form.isModbus = false;
}
},
/**选项卡切换事件**/
tabChange(tabItem) {
// 切换到告警配置,获取物模型
if (tabItem.paneName == "alert") {
//this.$refs.productAlert.getCacheThingsModel(this.form.productId);
}
},
/*按照模板名查询*/
queryTemp() {
this.getTempList();
},
/** 搜索按钮操作 */
handleQuery() {
this.tempParams.pageNum = 1
this.getTempList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm('tempParams')
this.handleQuery()
},
}
};
</script>
<style>
.el-aside {
margin: 0;
padding: 0;
background-color: #fff;
color: #333;
}
.el-main {
margin: 0;
padding: 0 10px;
background-color: #fff;
color: #333;
}
</style>

View File

@@ -1,49 +1,63 @@
<template>
<div style="margin-top:-50px;">
<el-divider></el-divider>
<el-form :model="queryParams" ref="product-select-template" :inline="true" label-width="48px">
<el-form-item label="名称" prop="templateName">
<el-input v-model="queryParams.templateName" placeholder="请输入物模型名称" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="类别" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择模型类别" clearable size="small">
<el-option v-for="dict in dict.type.iot_things_type" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<div style="margin-top:-50px;">
<el-divider></el-divider>
<el-form :model="queryParams" ref="product-select-template" :inline="true" label-width="48px">
<el-form-item label="名称" prop="templateName">
<el-input v-model="queryParams.templateName" placeholder="请输入物模型名称" clearable size="small"
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="类别" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择模型类别" clearable size="small">
<el-option v-for="dict in dict.type.iot_things_type" :key="dict.value" :label="dict.label"
:value="dict.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="templateList" @selection-change="handleSelectionChange" ref="selectTemplateTable" size="small">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="名称" align="center" prop="templateName" />
<el-table-column label="标识符" align="center" prop="identifier" />
<el-table-column label="物模型类别" align="center" prop="type">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_things_type" :value="scope.row.type" />
</template>
</el-table-column>
<el-table-column label="首页显示" align="center" prop="isTop">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isTop" />
</template>
</el-table-column>
<el-table-column label="监测值" align="center" prop="isMonitor">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isMonitor" />
</template>
</el-table-column>
<el-table-column label="数据类型" align="center" prop="datatype">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_data_type" :value="scope.row.datatype" />
</template>
</el-table-column>
</el-table>
<el-table v-loading="loading" :data="templateList" @selection-change="handleSelectionChange"
ref="selectTemplateTable" size="small">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="名称" align="center" prop="templateName" />
<el-table-column label="标识符" align="center" prop="identifier" />
<el-table-column label="物模型类别" align="center" prop="type">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_things_type" :value="scope.row.type" />
</template>
</el-table-column>
<el-table-column label="图表展示" align="center" prop="isChart" width="75">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isChart" />
</template>
</el-table-column>
<el-table-column label="实时监测" align="center" prop="isMonitor" width="75">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isMonitor" />
</template>
</el-table-column>
<el-table-column label="只读" align="center" prop="isReadonly" width="75">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isReadonly" />
</template>
</el-table-column>
<el-table-column label="历史存储" align="center" prop="isHistory" width="75">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isHistory" />
</template>
</el-table-column>
<el-table-column label="数据类型" align="center" prop="datatype">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_data_type" :value="scope.row.datatype" />
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
</div>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="getList" />
</div>
</template>
<script>
@@ -95,7 +109,7 @@ export default {
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.resetForm("product-select-template");
this.handleQuery();
},
// 多选框选中数据
@@ -104,9 +118,8 @@ export default {
this.single = selection.length !== 1;
this.multiple = !selection.length;
// Id数组传递到父组件
this.$emit('idsToParentEvent', this.ids)
this.$emit('idsToParentEvent', this.ids);
},
},
};
</script>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,234 @@
<template>
<div style="padding:6px;">
<el-card v-show="showSearch" style="margin-bottom:6px;">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom:-20px;">
<el-form-item label="协议名称" prop="protocolName">
<el-input v-model="queryParams.protocolName" placeholder="请输入协议名称" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="协议编码" prop="protocolCode">
<el-input v-model="queryParams.protocolCode" placeholder="请输入协议编码" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card style="padding-bottom:100px;">
<el-table v-loading="loading" :data="protocolList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="协议名称" align="center" prop="protocolName" />
<el-table-column label="协议编码" align="center" prop="protocolCode" />
<el-table-column label="上传地址" align="center" prop="protocolFileUrl" />
<el-table-column label="协议类型" align="center" prop="protocolType" />
<el-table-column label="协议摘要" align="center" prop="jarSign" />
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改协议对话框 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="协议名称" prop="protocolName">
<el-input v-model="form.protocolName" placeholder="请输入协议名称" />
</el-form-item>
<el-form-item label="协议编码" prop="protocolCode">
<el-input v-model="form.protocolCode" placeholder="请输入协议编码" />
</el-form-item>
<el-form-item label="上传地址" prop="protocolFileUrl">
<el-input v-model="form.protocolFileUrl" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="协议摘要" prop="jarSign">
<el-input v-model="form.jarSign" placeholder="请输入协议文件摘要(文件的md5)" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</el-card>
</div>
</template>
<script>
import {
listProtocol,
getProtocol,
delProtocol,
addProtocol,
updateProtocol
} from "@/api/iot/protocol";
export default {
name: "Protocol",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 协议表格数据
protocolList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
protocolCode: null,
protocolName: null,
protocolFileUrl: null,
protocolType: null,
jarSign: null,
protocolStatus: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
protocolCode: [{
required: true,
message: "协议编码不能为空",
trigger: "blur"
}],
protocolName: [{
required: true,
message: "协议名称不能为空",
trigger: "blur"
}],
protocolFileUrl: [{
required: true,
message: "协议上传地址不能为空",
trigger: "blur"
}],
protocolType: [{
required: true,
message: "协议类型不能为空",
trigger: "change"
}],
jarSign: [{
required: true,
message: "协议摘要不能为空",
trigger: "blur"
}]
}
};
},
created() {
this.getList();
},
methods: {
/** 查询协议列表 */
getList() {
this.loading = true;
listProtocol(this.queryParams).then(response => {
this.protocolList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
protocolCode: null,
protocolName: null,
protocolFileUrl: null,
protocolType: null,
jarSign: null,
createTime: null,
updateTime: null,
protocolStatus: 0,
delFlag: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加协议";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getProtocol(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改协议";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateProtocol(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addProtocol(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除协议编号为"' + ids + '"的数据项?').then(function () {
return delProtocol(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('iot/protocol/export', {
...this.queryParams
}, `protocol_${new Date().getTime()}.xlsx`)
}
}
};
</script>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,440 @@
<template>
<div style="padding: 6px">
<!-- 添加或修改通用物模型对话框 -->
<el-dialog title="编辑参数" :visible.sync="openEdit" width="900px" append-to-body>
<div style="margin: -30px 0 30px; background-color: #ddd; height: 1px"></div>
<el-row>
<el-col :span="12" style="border: 1px solid #ddd; border-radius: 5px; padding: 10px; background-color: #eee">
<el-form :model="queryParams" :inline="true" label-width="48px" size="small">
<el-form-item label="" prop="templateName">
<el-input v-model="queryParams.templateName" placeholder="请输入物模型名称" style="width: 160px" clearable size="mini" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="info" icon="el-icon-search" size="mini" @click="handleQuery" style="padding: 5px">搜索</el-button>
</el-form-item>
<el-form-item>
<el-link :underline="false" icon="el-icon-info" type="primary" style="margin-left: 20px">单击应用模板</el-link>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="templateList" size="mini" @row-click="rowClick" highlight-current-row :border="false" :show-header="false" :row-style="{ backgroundColor: '#eee' }">
<el-table-column label="选择" width="30" align="center">
<template slot-scope="scope">
<input type="radio" :checked="scope.row.isSelect" :disabled="scope.row.datatype == 'array' || scope.row.datatype == 'object'" name="template" />
</template>
</el-table-column>
<el-table-column label="名称" align="left" prop="templateName" />
<el-table-column label="标识符" align="left" prop="identifier" />
<el-table-column label="数据类型" align="center" prop="datatype" width="60">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_data_type" :value="scope.row.datatype" />
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
small
style="margin: 0 0 10px; background-color: #eee"
layout="prev, pager, next"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-col>
<el-col :span="11" :offset="1">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="参数名称" prop="name">
<el-input v-model="form.name" placeholder="例如:温度" style="width: 270px" size="small" />
</el-form-item>
<el-form-item label="参数标识" prop="id">
<el-input v-model="form.id" placeholder="例如temperature" style="width: 270px" size="small"></el-input>
</el-form-item>
<el-form-item label="参数排序" prop="order">
<el-input-number controls-position="right" v-model="form.order" placeholder="请输入排序" type="number" style="width: 270px" size="small" />
</el-form-item>
<el-form-item label="参数特性" prop="property">
<el-checkbox name="isChart" label="图表展示" @change="isChartChange" v-model="form.isChart" :true-label="1" :false-label="0"></el-checkbox>
<el-checkbox name="isMonitor" label="实时监测" @change="isMonitorChange" v-model="form.isMonitor" :true-label="1" :false-label="0"></el-checkbox>
<el-checkbox name="isReadonly" label="只读数据" @change="isReadonlyChange" v-model="form.isReadonly" :true-label="1" :false-label="0"></el-checkbox>
<el-checkbox name="isHistory" label="历史存储" v-model="form.isHistory" :true-label="1" :false-label="0"></el-checkbox>
<el-checkbox name="isSharePerm" label="分享权限" v-model="form.isSharePerm" :true-label="1" :false-label="0"></el-checkbox>
</el-form-item>
<div style="margin-bottom: 20px; background-color: #ddd; height: 1px"></div>
<el-form-item label="数据类型" prop="datatype">
<el-select v-model="form.datatype" placeholder="请选择数据类型" style="width: 125px" size="small">
<el-option key="integer" label="整数" value="integer"></el-option>
<el-option key="decimal" label="小数" value="decimal"></el-option>
<el-option key="bool" label="布尔" value="bool" :disabled="form.isChart == 1"></el-option>
<el-option key="enum" label="枚举" value="enum" :disabled="form.isChart == 1"></el-option>
<el-option key="string" label="字符串" value="string" :disabled="form.isChart == 1"></el-option>
</el-select>
</el-form-item>
<div v-if="form.datatype == 'integer' || form.datatype == 'decimal'">
<el-form-item label="取值范围">
<el-row>
<el-col :span="10">
<el-input v-model="form.specs.min" placeholder="最小值" type="number" size="small" />
</el-col>
<el-col :span="4" align="center"></el-col>
<el-col :span="10">
<el-input v-model="form.specs.max" placeholder="最大值" type="number" size="small" />
</el-col>
</el-row>
</el-form-item>
<el-form-item label="单位">
<el-input v-model="form.specs.unit" placeholder="例如:℃" style="width: 308px" size="small" />
</el-form-item>
<el-form-item label="步长">
<el-input-number controls-position="right" v-model="form.specs.step" placeholder="例如1" type="number" style="width: 308px" size="small" />
</el-form-item>
</div>
<div v-if="form.datatype == 'bool'">
<el-form-item label="布尔值" prop="">
<el-row style="margin-bottom: 10px">
<el-col :span="10">
<el-input v-model="form.specs.falseText" placeholder="例如:关闭" size="small" />
</el-col>
<el-col :span="10" :offset="1">0 值对应文本</el-col>
</el-row>
<el-row>
<el-col :span="10">
<el-input v-model="form.specs.trueText" placeholder="例如:打开" size="small" />
</el-col>
<el-col :span="10" :offset="1">1 值对应文本</el-col>
</el-row>
</el-form-item>
</div>
<div v-if="form.datatype == 'enum'">
<el-form-item label="展示方式">
<el-select v-model="form.specs.showWay" placeholder="请选择展示方式" style="width: 175px">
<el-option key="select" label="下拉框" value="select"></el-option>
<el-option key="button" label="按钮" value="button"></el-option>
</el-select>
</el-form-item>
<el-form-item label="枚举项" prop="">
<el-row v-for="(item, index) in form.specs.enumList" :key="'enum' + index" style="margin-bottom: 10px">
<el-col :span="8">
<el-input v-model="item.value" placeholder="例如0" size="small" />
</el-col>
<el-col :span="11" :offset="1">
<el-input v-model="item.text" placeholder="例如:中速挡位" size="small" />
</el-col>
<el-col :span="3" :offset="1" v-if="index != 0"><a style="color: #f56c6c" @click="removeEnumItem(index)">删除</a></el-col>
</el-row>
<div>
+
<a style="color: #409eff" @click="addEnumItem()">添加枚举项</a>
</div>
</el-form-item>
</div>
<div v-if="form.datatype == 'string'">
<el-form-item label="最大长度" prop="">
<el-row>
<el-col :span="10">
<el-input v-model="form.specs.maxLength" placeholder="例如1024" type="number" size="small" />
</el-col>
</el-row>
</el-form-item>
</div>
</el-form>
</el-col>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<style>
.specsColor {
background-color: #fcfcfc;
}
</style>
<script>
import { listTemplate } from '@/api/iot/template';
export default {
name: 'things_parameter',
dicts: ['iot_things_type', 'iot_data_type', 'iot_yes_no'],
props: {
data: {
type: Object,
default: null,
},
},
watch: {
data: function (newVal, oldVal) {
this.index = newVal.index;
if (newVal && newVal.parameter.name && newVal.parameter.name != '') {
this.form.name = newVal.parameter.name;
this.form.id = newVal.parameter.id;
this.form.order = newVal.parameter.order;
this.form.isChart = newVal.parameter.isChart ? newVal.parameter.isChart : 0;
this.form.isHistory = newVal.parameter.isHistory ? newVal.parameter.isHistory : 1;
this.form.isSharePerm = newVal.parameter.isSharePerm ? newVal.parameter.isSharePerm : 0;
this.form.isMonitor = newVal.parameter.isMonitor ? newVal.parameter.isMonitor : 0;
this.form.isReadonly = newVal.parameter.isReadonly ? newVal.parameter.isReadonly : 0;
this.form.specs = newVal.parameter.datatype;
this.form.datatype = this.form.specs.type;
if (!this.form.specs.enumList) {
this.form.specs.enumList = [
{
value: '',
text: '',
},
];
}
if (!this.form.specs.arrayType) {
this.form.specs.arrayType = 'int';
}
}
this.openEdit = true;
this.getList();
},
},
data() {
return {
// 遮罩层
loading: true,
// 总条数
total: 0,
// 通用物模型表格数据
templateList: [],
// 是否显示弹出层
openEdit: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
name: null,
type: null,
},
// 参数索引
index: -1,
// 表单参数
form: {},
// 表单校验
rules: {
name: [
{
required: true,
message: '参数名称不能为空',
trigger: 'blur',
},
],
id: [
{
required: true,
message: '参数标识符不能为空',
trigger: 'blur',
},
],
order: [
{
required: true,
message: '模型排序不能为空',
trigger: 'blur',
},
],
datatype: [
{
required: true,
message: '数据类型不能为空',
trigger: 'change',
},
],
},
};
},
created() {
this.getList();
this.reset();
},
methods: {
/** 查询通用物模型列表 */
getList() {
this.loading = true;
listTemplate(this.queryParams).then((response) => {
//模板列表初始化isSelect值用于单选
for (let i = 0; i < response.rows.length; i++) {
response.rows[i].isSelect = false;
}
this.templateList = response.rows;
this.total = response.total;
this.setRadioSelected(this.productId);
this.loading = false;
});
},
/** 单选数据 */
rowClick(item) {
if (item != null && item.datatype != 'array' && item.datatype != 'object') {
this.form.name = item.templateName;
this.form.id = item.identifier;
this.form.order = item.modelOrder;
this.form.isChart = item.isChart ? item.isChart : 0;
this.form.isHistory = item.isHistory ? item.isHistory : 1;
this.form.isSharePerm = item.isSharePerm ? item.isSharePerm : 0;
this.form.isReadonly = item.isReadonly ? item.isReadonly : 0;
this.form.isMonitor = item.isMonitor ? item.isMonitor : 0;
this.form.datatype = item.datatype;
// Json转对象
this.form.specs = JSON.parse(item.specs);
if (!this.form.specs.enumList) {
this.form.specs.enumList = [
{
value: '',
text: '',
},
];
}
if (!this.form.specs.arrayType) {
this.form.specs.arrayType = 'int';
}
this.setRadioSelected(item.templateId);
}
},
/** 设置单选按钮选中 */
setRadioSelected(templateId) {
for (let i = 0; i < this.templateList.length; i++) {
if (this.templateList[i].templateId == templateId) {
this.templateList[i].isSelect = true;
} else {
this.templateList[i].isSelect = false;
}
}
},
// 取消按钮
cancel() {
this.openEdit = false;
this.reset();
},
// 表单重置
reset() {
this.index = -1;
this.form = {
name: null,
id: null,
order: 0,
datatype: 'integer',
isChart: 0,
isHistory: 1,
isSharePerm: 0,
isMonitor: 0,
isReadonly: 0,
specs: {
enumList: [
{
value: '',
text: '',
},
],
showWay: 'select', // 显示方式select=下拉选择框button=按钮
},
};
this.resetForm('form');
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 提交按钮 */
submitForm() {
this.$refs['form'].validate((valid) => {
if (valid) {
// 格式化datatype
this.form.datatype = this.formatThingsSpecs();
// 清空不需要存储数据
delete this.form.specs;
this.openEdit = false;
// 返回参数对象
let data = {
parameter: JSON.parse(JSON.stringify(this.form)),
index: this.index,
};
console.log('data', data);
this.$emit('dataEvent', data);
this.reset();
}
});
},
// 是否图表展示改变
isChartChange() {
if (this.form.isChart == 1) {
this.form.isReadonly = 1;
} else {
this.form.isMonitor = 0;
}
},
// 是否实时监测改变
isMonitorChange() {
if (this.form.isMonitor == 1) {
this.form.isReadonly = 1;
this.form.isChart = 1;
}
},
// 是否只读数据改变
isReadonlyChange() {
if (this.form.isReadonly == 0) {
this.form.isMonitor = 0;
this.form.isChart = 0;
}
},
// 格式化物模型
formatThingsSpecs() {
var data = {};
data.type = this.form.datatype;
if (this.form.datatype == 'integer' || this.form.datatype == 'decimal') {
data.min = Number(this.form.specs.min ? this.form.specs.min : 0);
data.max = Number(this.form.specs.max ? this.form.specs.max : 100);
data.unit = this.form.specs.unit ? this.form.specs.unit : '';
data.step = Number(this.form.specs.step ? this.form.specs.step : 1);
} else if (this.form.datatype == 'string') {
data.maxLength = Number(this.form.specs.maxLength ? this.form.specs.maxLength : 1024);
} else if (this.form.datatype == 'bool') {
data.falseText = this.form.specs.falseText ? this.form.specs.falseText : '关闭';
data.trueText = this.form.specs.trueText ? this.form.specs.trueText : '打开';
} else if (this.form.datatype == 'array') {
data.arrayType = this.form.specs.arrayType;
} else if (this.form.datatype == 'enum') {
data.showWay = this.form.specs.showWay;
if (this.form.specs.enumList && this.form.specs.enumList[0].text != '') {
data.enumList = this.form.specs.enumList;
} else {
data.showWay = 'select';
data.enumList = [
{
value: '0',
text: '低',
},
{
value: '1',
text: '高',
},
];
}
}
return data;
},
/** 添加枚举项 */
addEnumItem() {
this.form.specs.enumList.push({
value: '',
text: '',
});
},
/** 删除枚举项 */
removeEnumItem(index) {
this.form.specs.enumList.splice(index, 1);
},
},
};
</script>

View File

@@ -1,435 +1,438 @@
<template>
<div class="login">
<div class="login">
<el-row>
<el-col :xs="24">
<div
style="color: #fff; background-color: #0f73ee; width: 100%; height: 200px; text-align: center; padding: 15px; font-family: '微软雅黑'">
<div style="font-size: 42px; padding-top: 40px; width: 300px; margin: 0 auto">
<img :src="logo" alt="logo" style="width: 100px; height: 100px; float: left" />
<div style="float: left; margin-top: 13px; width: 200px; text-align: left">
<div>FastBee</div>
<div style="letter-spacing: 1.5px; font-size: 20px; font-weight: 600; margin-top: -8px; margin-left: 3px">
开源物联网平台</div>
</div>
</div>
</div>
<div style="padding:20px;">
<el-row :gutter="10">
<el-col :xs="24" :sm="24" :md="14" :lg="14" :xl="14">
<div class="login-top hidden-sm-and-down">
<h1>
<a href="https://wumei.live/" target="_blank">FastBee物联网平台</a>
</h1>
<h2><a href="https://wumei.live/" target="_blank">FastBee</a> open source living iot platform</h2>
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
<el-form-item>
<div class="alert-box-wrap" v-if="loginForm.bindId != null">
<div v-if="loginForm.bindId != null" class="alert-message-wrap">
<i class="el-icon-warning" />
如果你已经有账号,请直接输入账号进行绑定
</div>
<el-row>
<el-col :span="10.5">
<div v-if="loginForm.bindId != null" class="alert-message-wrap">
如果还没有账号请先去</div>
</el-col>
<!-- <el-col :span="4"> -->
<router-link v-if="loginForm.bindId != null" :to="{ path: '/register', query: this.$route.query }"
style="margin-left: 10px; font-size: 14px; font-family: '微软雅黑'; color: rgba(41, 96, 197, 0.856);">
注册
</router-link>
<!-- </el-col> -->
</el-row>
</div>
</el-form-item>
<div style="margin-bottom: 10px; font-size: 14px; font-family: '微软雅黑'; color: #f78e21">演示账号fastbee 123456</div>
<el-form-item prop="username">
<el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号">
<svg-icon slot="prefix" icon-class="user" class="input-icon" />
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input v-model="loginForm.password" type="password" auto-complete="off" placeholder="密码"
@keyup.enter.native="handleLogin">
<svg-icon slot="prefix" icon-class="password" class="input-icon" />
</el-input>
</el-form-item>
<el-form-item v-if="captchaOnOff" prop="code">
<el-input v-model="loginForm.code" auto-complete="off" placeholder="验证码" style="width: 63%"
@keyup.enter.native="handleLogin">
<svg-icon slot="prefix" icon-class="validCode" class="input-icon" />
</el-input>
<div style="max-width:330px;text-align:left;margin:0 auto;">
<div v-if="!bindAccount" style="padding:25px 0;">
<span style="margin-right:10px;">登录方式</span>
<el-button type="success" title="微信登录" size="mini" @click="authLogin" style="border:1px solid #fff;" disabled>
<svg-icon icon-class="wechat" /> 微信
</el-button>
<el-button type="danger" title="QQ登录" size="mini" @click="qqLogin" style="border:1px solid #fff;" disabled>
<svg-icon icon-class="qq" /> QQ
</el-button>
<el-button type="primary" title="支付宝登录" size="mini" @click="authLogin" style="border:1px solid #fff;" disabled>
<svg-icon icon-class="zhifubao" /> 支付宝
</el-button>
</div>
<div v-if="register">
<el-button type="warning" style="padding:0px;">
<el-link href="https://wumei.live/" :underline="false" target="_blank" style="color:#fff;padding:12px 18px;">返回官网</el-link>
</el-button>
<el-button type="success" style="padding:0px;">
<el-link href="https://wumei.live/doc" :underline="false" target="_blank" style="color:#fff;padding:12px 18px;">查看文档</el-link>
</el-button>
<el-button style="padding:0px;">
<router-link :to='{path:"/register",query: this.$route.query }' style="color:#666;padding:11px 18px;display:flex;padding-bottom:12px;">注册账号
</router-link>
</el-button>
</div>
<div style="line-height:20px;border:1px solid #fff;color:#eee;margin-top:30px;width:316px;">
<table>
<tr>
<td rowspan="3" style="width:60px;font-weight:bold;color:#fff;line-height:28px;background-color:#F56C6C;text-align:center;font-size:18px;"> <br /> </td>
<td style="padding:10px 15px 0 10px;">受限管理</td>
<td style="padding:10px 30px 0 0;">wumei</td>
<td style="padding-top:10px;">123456</td>
</tr>
<tr>
<td style="padding:0 15px 0 10px;">租户账号</td>
<td>wumei-t1</td>
<td>123456</td>
</tr>
<tr>
<td style="padding:0 15px 10px 10px;">普通用户</td>
<td style="padding-bottom:10px;">wumei-u1</td>
<td style="padding-bottom:10px;">123456</td>
</tr>
</table>
</div>
</div>
</div>
</el-col>
<el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
<h3 class="title" v-if="!bindAccount">账号登录</h3>
<h3 class="bindAccountTitle" v-else>绑定蜂信科技账户</h3>
<el-form-item prop="username">
<el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号">
<svg-icon slot="prefix" icon-class="user" class="input-icon" />
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input v-model="loginForm.password" type="password" auto-complete="off" placeholder="密码" @keyup.enter.native="handleLogin">
<svg-icon slot="prefix" icon-class="password" class="input-icon" />
</el-input>
</el-form-item>
<el-form-item prop="code" v-if="captchaOnOff">
<el-input v-model="loginForm.code" auto-complete="off" placeholder="验证码" style="width: 63%" @keyup.enter.native="handleLogin">
<svg-icon slot="prefix" icon-class="validCode" class="input-icon" />
</el-input>
<div class="login-code">
<img :src="codeUrl" @click="getCode" />
</div>
</el-form-item>
<el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;color:#000;">记住密码</el-checkbox>
<el-form-item style="width:100%;">
<el-button v-if="!bindAccount" :loading="loading" type="primary" style="width:100%;" @click.native.prevent="handleLogin">
<span v-if="!loading"> </span>
<span v-else> 中...</span>
</el-button>
<el-button v-else :loading="loading" type="primary" style="width:100%;" @click.native.prevent="handleLogin">
<span v-if="!loading">绑定</span>
<span v-else> 中...</span>
</el-button>
<div class="login-code">
<img :src="codeUrl" @click="getCode" />
</div>
</el-form-item>
<el-checkbox v-model="loginForm.rememberMe" style="margin: 0px 0px 25px 0px; color: #000">记住密码</el-checkbox>
</el-form-item>
</el-form>
</el-col>
</el-row>
</div>
<el-form-item style="width: 100%">
<div style="margin-bottom: 10px">
<el-button v-if="!bindAccount" :loading="loading" type="primary" style="width: 100%"
@click.native.prevent="handleLogin">
<span v-if="!loading"> </span>
<span v-else> 中...</span>
</el-button>
<el-button v-else :loading="loading" type="primary" style="width: 100%" @click.native.prevent="handleBind">
<span v-if="!loading"> </span>
<span v-else> 中...</span>
</el-button>
</div>
<el-row>
<div>
<el-button v-if="loginForm.bindId == null" type="text" :wxloading="loading"
@click.native.prevent="weChatLogin">
<svg-icon icon-class="wechat" style="color: #13ce66" />
微信登录
</el-button>
<el-button type="text" disabled>
<i class="el-icon-mobile-phone"></i>
短信登录
</el-button>
<router-link v-if="!bindAccount" :to="{ path: '/register', query: this.$route.query }"
style="float: right">注册账号</router-link>
<router-link v-else :to="{ path: '/register', query: this.$route.query }"
style="float: right">注册绑定账号</router-link>
</div>
</el-row>
</el-form-item>
</el-form>
</el-col>
</el-row>
<!-- 底部 -->
<div class="el-login-footer">
<span>Copyright © 2021-2024 <a target="_blank" href="https://fastbee.cn/">蜂信物联</a> All Rights Reserved.</span>
<span>
Copyright © 2023
<a target="_blank" href="http://fastbee.cn">FastBee</a>
All Rights Reserved.
</span>
</div>
</div>
</div>
</template>
<script>
import 'element-ui/lib/theme-chalk/display.css';
import {
getCodeImg,
checkBindId,
getErrorMsg
} from "@/api/login";
import Cookies from "js-cookie";
import {
encrypt,
decrypt
} from '@/utils/jsencrypt'
import logo from '@/assets/logo/logo.gif';
import { getCodeImg, checkBindId, getErrorMsg, socialLogin, bindLogin } from '@/api/login';
import Cookies from 'js-cookie';
import { encrypt, decrypt } from '@/utils/jsencrypt';
import { setToken } from '@/utils/auth';
export default {
name: "Login",
data() {
return {
codeUrl: "",
loginForm: {
username: "",
password: "",
rememberMe: false,
code: "",
uuid: "",
bindId: ""
},
loginRules: {
username: [{
required: true,
trigger: "blur",
message: "请输入您的账号"
}],
password: [{
required: true,
trigger: "blur",
message: "请输入您的密码"
}],
code: [{
required: true,
trigger: "change",
message: "请输入验证码"
}]
},
loading: false,
// 验证码开关
captchaOnOff: true,
bindAccount: false,
// 注册开关
register: true,
redirect: undefined
};
name: 'Login',
data() {
return {
logo,
codeUrl: '',
loginForm: {
username: '',
password: '',
rememberMe: false,
code: '',
uuid: '',
bindId: '',
// loginId: '',
},
loginRules: {
username: [
{
required: true,
trigger: 'blur',
message: '请输入您的账号',
},
],
password: [
{
required: true,
trigger: 'blur',
message: '请输入您的密码',
},
],
code: [
{
required: true,
trigger: 'change',
message: '请输入验证码',
},
],
},
loading: false,
// 验证码开关
captchaOnOff: true,
bindAccount: false,
// 注册开关
register: true,
redirect: undefined,
};
},
watch: {
$route: {
handler: function (route) {
this.redirect = route.query && route.query.redirect;
},
immediate: true,
},
watch: {
$route: {
handler: function (route) {
this.redirect = route.query && route.query.redirect;
},
immediate: true
}
},
created() {
let loginId = this.$route.query.loginId;
if (loginId === undefined || loginId === null) {
this.checkBind();
this.checkErrorMsg();
this.getCode();
this.getCookie();
} else {
this.redirectLogin(loginId);
}
},
methods: {
redirectLogin(loginId) {
this.loading = true;
this.$store.dispatch("RedirectLogin", loginId).then(() => {
this.$router.push({
path: this.redirect || "/"
}).catch(() => {});
}).catch(() => {
this.loading = false;
if (this.captchaOnOff) {
this.getCode();
}
this.$router.push({
query: {}
})
});
},
checkBind() {
let query = this.$route.query;
let bindId = query.bindId;
if (bindId === undefined || bindId === null) {
this.bindAccount = false;
} else {
this.bindAccount = true;
checkBindId(bindId).then(res => {
this.bindAccount = res.bindAccount === undefined ? true : res.bindAccount
if (this.bindAccount) {
this.loginForm.bindId = bindId;
} else {
this.loginForm.bindId = "";
this.$router.push({
query: {}
})
}
})
}
},
checkErrorMsg() {
let errorId = this.$route.query.errorId;
if (errorId !== undefined && errorId !== null) {
getErrorMsg(errorId).then(res => {}).catch(err => {
this.$router.push({
query: {}
})
})
}
},
getCode() {
getCodeImg().then(res => {
this.captchaOnOff = res.captchaOnOff === undefined ? true : res.captchaOnOff;
if (this.captchaOnOff) {
this.codeUrl = "data:image/gif;base64," + res.img;
this.loginForm.uuid = res.uuid;
}
});
},
getCookie() {
const username = Cookies.get("username");
const password = Cookies.get("password");
const rememberMe = Cookies.get('rememberMe')
this.loginForm = {
username: username === undefined ? this.loginForm.username : username,
password: password === undefined ? this.loginForm.password : decrypt(password),
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
};
},
qqLogin() {
window.location.href = "http://localhost:8080/auth/render/qq";
},
authLogin() {
this.$alert('第三方登录正在集成中...', '提示消息', {
confirmButtonText: '确定',
callback: action => {
this.$message({
type: 'info',
message: `action: ${action}`
});
}
});
},
handleLogin() {
this.$refs.loginForm.validate(valid => {
if (valid) {
this.loading = true;
if (this.loginForm.rememberMe) {
Cookies.set("username", this.loginForm.username, {
expires: 30
});
Cookies.set("password", encrypt(this.loginForm.password), {
expires: 30
});
Cookies.set('rememberMe', this.loginForm.rememberMe, {
expires: 30
});
} else {
Cookies.remove("username");
Cookies.remove("password");
Cookies.remove('rememberMe');
}
console.log(this.loginForm)
this.$store.dispatch("Login", this.loginForm).then(() => {
this.$router.push({
path: this.redirect || "/"
}).catch(() => {});
}).catch(() => {
this.loading = false;
if (this.captchaOnOff) {
this.getCode();
}
});
}
});
},
},
created() {
const loginId = this.$route.query.loginId;
if (loginId === undefined || loginId === null) {
this.checkBind();
this.getCode();
this.checkErrorMsg();
this.getCookie();
} else {
this.redirectSocialLogin(loginId);
}
},
methods: {
redirectLogin(loginId) {
this.loading = true;
this.$store
.dispatch('RedirectLogin', loginId)
.then(() => {
this.$router
.push({
path: this.redirect || '/',
})
.catch(() => { });
})
.catch(() => {
this.loading = false;
if (this.captchaOnOff) {
this.getCode();
}
this.$router.push({
query: {},
});
});
},
redirectSocialLogin() {
const query = this.$route.query;
const loginId = query.loginId;
socialLogin(loginId).then((res) => {
// 保存token
this.loading = true;
setToken(res.token);
this.$router
.push({
path: this.redirect || '/',
})
.catch(() => { });
if (this.captchaOnOff) {
this.getCode();
this.loading = false;
}
});
},
checkBind() {
const query = this.$route.query;
const bindId = query.bindId;
if (bindId === undefined || bindId === null) {
this.bindAccount = false;
} else {
this.bindAccount = true;
checkBindId(bindId).then((res) => {
this.bindAccount = res.bindAccount === undefined ? true : res.bindAccount;
if (this.bindAccount) {
this.loginForm.bindId = bindId;
} else {
this.loginForm.bindId = '';
this.$router.push({
query: {},
});
}
});
}
},
checkErrorMsg() {
const errorId = this.$route.query.errorId;
if (errorId !== undefined && errorId !== null) {
getErrorMsg(errorId)
.then((res) => { })
.catch((err) => {
this.$router.push({ query: {} });
console.log(err);
});
}
},
getCode() {
getCodeImg().then((res) => {
this.captchaOnOff = res.captchaOnOff === undefined ? true : res.captchaOnOff;
if (this.captchaOnOff) {
this.codeUrl = 'data:image/gif;base64,' + res.img;
this.loginForm.uuid = res.uuid;
}
});
},
getCookie() {
const username = Cookies.get('username');
const password = Cookies.get('password');
const rememberMe = Cookies.get('rememberMe');
const loginId = Cookies.get('loginId');
this.loginForm = {
username: username === undefined ? this.loginForm.username : username,
password: password === undefined ? this.loginForm.password : decrypt(password),
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
loginId: loginId === undefined ? this.loginForm.loginId : loginId,
};
},
qqLogin() {
window.location.href = 'http://localhost:8080/auth/render/qq';
},
weChatLogin() {
const baseURL = process.env.VUE_APP_BASE_API;
window.location.href = baseURL + '/auth/render/wechat_open_web';
},
authLogin() {
this.$alert('第三方登录正在集成中...', '提示消息', {
confirmButtonText: '确定',
callback: (action) => {
this.$message({
type: 'info',
message: `action: ${action}`,
});
},
});
},
handleBind() {
this.$refs.loginForm.validate((valid) => {
if (valid) {
this.loading = true;
if (this.loginForm.rememberMe) {
Cookies.set('username', this.loginForm.username, {
expires: 30,
});
Cookies.set('password', encrypt(this.loginForm.password), {
expires: 30,
});
Cookies.set('rememberMe', this.loginForm.rememberMe, {
expires: 30,
});
} else {
Cookies.remove('username');
Cookies.remove('password');
Cookies.remove('rememberMe');
}
this.loginForm.bindId = this.$route.query.bindId;
bindLogin(this.loginForm)
.then((res) => {
// 保存token
setToken(res.token);
this.$router
.push({
path: '/',
})
.catch(() => { });
})
.catch(() => {
this.loading = false;
if (this.captchaOnOff) {
this.loading = false;
this.getCode();
}
});
}
});
},
handleLogin() {
this.$refs.loginForm.validate((valid) => {
if (valid) {
this.loading = true;
if (this.loginForm.rememberMe) {
Cookies.set('username', this.loginForm.username, {
expires: 30,
});
Cookies.set('password', encrypt(this.loginForm.password), {
expires: 30,
});
Cookies.set('rememberMe', this.loginForm.rememberMe, {
expires: 30,
});
} else {
Cookies.remove('username');
Cookies.remove('password');
Cookies.remove('rememberMe');
}
this.$store
.dispatch('Login', this.loginForm)
.then(() => {
this.$router
.push({
path: this.redirect || '/',
})
.catch(() => { });
})
.catch(() => {
this.loading = false;
if (this.captchaOnOff) {
this.getCode();
}
});
}
});
},
},
};
</script>
<style lang="scss">
.login {
background: linear-gradient(303deg, #48c6ef 10%, #6f86d6 80%);
height: 100%;
overflow: auto;
padding-top: 150px;
}
.title {
margin: 0px auto 20px auto;
text-align: center;
color: #333;
font-size: 28px;
height: 100%;
overflow: auto;
}
.bindAccountTitle {
margin: 0px auto 30px auto;
text-align: center;
color: #333;
font-size: 24px;
}
.login-top {
color: #fff;
text-align: center;
@media screen and (min-width:992px) {
h1 {
font-size: 36px;
}
h2 {
font-size: 20px;
margin-top: -20px;
}
}
@media screen and (min-width:1200px) {
h1 {
font-size: 46px;
}
h2 {
font-size: 26px;
margin-top: -25px;
}
}
@media screen and (min-width:1920px) {
padding: 0px;
h1 {
font-size: 62px;
}
h2 {
font-size: 35px;
margin-top: -30px;
}
}
margin: 0px auto 30px auto;
text-align: center;
color: #333;
font-size: 24px;
}
.login-form {
box-shadow: 0 20px 30px 0 rgba(0, 0, 0, 0.1);
border-radius: 10px;
background-color: rgba(250, 250, 250, 0.8);
border: 1px solid #fff;
padding: 25px 25px 5px 25px;
margin: 0 auto;
z-index: 1000;
max-width: 370px;
margin-bottom: 100px;
margin: 30px auto 0 auto;
padding: 15px;
z-index: 1000;
max-width: 350px;
.el-input {
height: 38px;
input {
height: 38px;
background-color: #f1f1f1;
color: #666;
}
input {
height: 38px;
background-color: rgba(0, 0, 0, 0.1);
color: #333;
}
// 谷歌
input::-webkit-input-placeholder {
color: #666;
}
// 火狐19+版本
input::-moz-placeholder {
/* Mozilla Firefox 19+ */
color: #666;
}
// 火狐4-18版本
input:-moz-placeholder {
/* Mozilla Firefox 4 to 18 */
color: #666;
}
// IE10-11版本
input:-ms-input-placeholder {
/* Internet Explorer 10-11 */
color: #666;
}
}
.input-icon {
height: 39px;
width: 14px;
margin-left: 2px;
color: #fff;
}
.input-icon {
height: 39px;
width: 14px;
margin-left: 2px;
}
}
.login-code {
width: 33%;
height: 38px;
float: right;
width: 33%;
float: right;
img {
cursor: pointer;
vertical-align: middle;
border-radius: 5px;
height: 38px;
}
img {
cursor: pointer;
vertical-align: middle;
border-radius: 3px;
height: 38px;
}
}
.el-login-footer {
height: 40px;
line-height: 40px;
position: fixed;
bottom: 0;
width: 100%;
text-align: center;
color: #fff;
font-family: Arial;
font-size: 12px;
letter-spacing: 1px;
height: 40px;
line-height: 40px;
position: fixed;
bottom: 0;
width: 100%;
text-align: center;
color: #333;
font-family: Arial;
font-size: 12px;
letter-spacing: 1px;
}
.alert-box-wrap {
border: 1px solid #f78e21;
.alert-message-wrap {
font-size: 14px;
font-family: '微软雅黑';
color: rgba(197, 41, 41, 0.856);
margin-left: 10px;
}
}
</style>

View File

@@ -68,10 +68,10 @@
<script>
import { getCache } from "@/api/monitor/cache";
import * as echarts from 'echarts';
import * as echarts from "echarts";
export default {
name: "Server",
name: "Cache",
data() {
return {
// 统计命令信息
@@ -79,8 +79,8 @@ export default {
// 使用内存
usedmemory: null,
// cache信息
cache: [],
};
cache: []
}
},
created() {
this.getList();
@@ -109,8 +109,8 @@ export default {
data: response.data.commandStats,
animationEasing: "cubicInOut",
animationDuration: 1000,
},
],
}
]
});
this.usedmemory = echarts.init(this.$refs.usedmemory, "macarons");
this.usedmemory.setOption({
@@ -130,17 +130,17 @@ export default {
{
value: parseFloat(this.cache.info.used_memory_human),
name: "内存消耗",
},
],
},
],
}
]
}
]
});
});
},
// 打开加载层
openLoading() {
this.$modal.loading("正在加载缓存监控数据,请稍候!");
},
},
}
}
};
</script>

241
vue/src/views/monitor/cache/list.vue vendored Normal file
View File

@@ -0,0 +1,241 @@
<template>
<div class="app-container">
<el-row :gutter="10">
<el-col :span="8">
<el-card style="height: calc(100vh - 125px)">
<div slot="header">
<span>缓存列表</span>
<el-button
style="float: right; padding: 3px 0"
type="text"
icon="el-icon-refresh-right"
@click="refreshCacheNames()"
></el-button>
</div>
<el-table
v-loading="loading"
:data="cacheNames"
:height="tableHeight"
highlight-current-row
@row-click="getCacheKeys"
style="width: 100%"
>
<el-table-column
label="序号"
width="60"
type="index"
></el-table-column>
<el-table-column
label="缓存名称"
align="center"
prop="cacheName"
:show-overflow-tooltip="true"
:formatter="nameFormatter"
></el-table-column>
<el-table-column
label="备注"
align="center"
prop="remark"
:show-overflow-tooltip="true"
/>
<el-table-column
label="操作"
width="60"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleClearCacheName(scope.row)"
></el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
<el-col :span="8">
<el-card style="height: calc(100vh - 125px)">
<div slot="header">
<span>键名列表</span>
<el-button
style="float: right; padding: 3px 0"
type="text"
icon="el-icon-refresh-right"
@click="refreshCacheKeys()"
></el-button>
</div>
<el-table
v-loading="subLoading"
:data="cacheKeys"
:height="tableHeight"
highlight-current-row
@row-click="handleCacheValue"
style="width: 100%"
>
<el-table-column
label="序号"
width="60"
type="index"
></el-table-column>
<el-table-column
label="缓存键名"
align="center"
:show-overflow-tooltip="true"
:formatter="keyFormatter"
>
</el-table-column>
<el-table-column
label="操作"
width="60"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleClearCacheKey(scope.row)"
></el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
<el-col :span="8">
<el-card :bordered="false" style="height: calc(100vh - 125px)">
<div slot="header">
<span>缓存内容</span>
<el-button
style="float: right; padding: 3px 0"
type="text"
icon="el-icon-refresh-right"
@click="handleClearCacheAll()"
>清理全部</el-button
>
</div>
<el-form :model="cacheForm">
<el-row :gutter="32">
<el-col :offset="1" :span="22">
<el-form-item label="缓存名称:" prop="cacheName">
<el-input v-model="cacheForm.cacheName" :readOnly="true" />
</el-form-item>
</el-col>
<el-col :offset="1" :span="22">
<el-form-item label="缓存键名:" prop="cacheKey">
<el-input v-model="cacheForm.cacheKey" :readOnly="true" />
</el-form-item>
</el-col>
<el-col :offset="1" :span="22">
<el-form-item label="缓存内容:" prop="cacheValue">
<el-input
v-model="cacheForm.cacheValue"
type="textarea"
:rows="8"
:readOnly="true"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
</el-col>
</el-row>
</div>
</template>
<script>
import { listCacheName, listCacheKey, getCacheValue, clearCacheName, clearCacheKey, clearCacheAll } from "@/api/monitor/cache";
export default {
name: "CacheList",
data() {
return {
cacheNames: [],
cacheKeys: [],
cacheForm: {},
loading: true,
subLoading: false,
nowCacheName: "",
tableHeight: window.innerHeight - 200
};
},
created() {
this.getCacheNames();
},
methods: {
/** 查询缓存名称列表 */
getCacheNames() {
this.loading = true;
listCacheName().then(response => {
this.cacheNames = response.data;
this.loading = false;
});
},
/** 刷新缓存名称列表 */
refreshCacheNames() {
this.getCacheNames();
this.$modal.msgSuccess("刷新缓存列表成功");
},
/** 清理指定名称缓存 */
handleClearCacheName(row) {
clearCacheName(row.cacheName).then(response => {
this.$modal.msgSuccess("清理缓存名称[" + this.nowCacheName + "]成功");
this.getCacheKeys();
});
},
/** 查询缓存键名列表 */
getCacheKeys(row) {
const cacheName = row !== undefined ? row.cacheName : this.nowCacheName;
if (cacheName === "") {
return;
}
this.subLoading = true;
listCacheKey(cacheName).then(response => {
this.cacheKeys = response.data;
this.subLoading = false;
this.nowCacheName = cacheName;
});
},
/** 刷新缓存键名列表 */
refreshCacheKeys() {
this.getCacheKeys();
this.$modal.msgSuccess("刷新键名列表成功");
},
/** 清理指定键名缓存 */
handleClearCacheKey(cacheKey) {
clearCacheKey(cacheKey).then(response => {
this.$modal.msgSuccess("清理缓存键名[" + cacheKey + "]成功");
this.getCacheKeys();
});
},
/** 列表前缀去除 */
nameFormatter(row) {
return row.cacheName.replace(":", "");
},
/** 键名前缀去除 */
keyFormatter(cacheKey) {
return cacheKey.replace(this.nowCacheName, "");
},
/** 查询缓存内容详细 */
handleCacheValue(cacheKey) {
getCacheValue(this.nowCacheName, cacheKey).then(response => {
this.cacheForm = response.data;
});
},
/** 清理全部缓存 */
handleClearCacheAll() {
clearCacheAll().then(response => {
this.$modal.msgSuccess("清理全部缓存成功");
});
}
},
};
</script>

View File

@@ -1,17 +1,16 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="任务名称" prop="jobName">
<el-input
v-model="queryParams.jobName"
placeholder="请输入任务名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="任务组名" prop="jobGroup">
<el-select v-model="queryParams.jobGroup" placeholder="请选择任务组名" clearable size="small">
<el-select v-model="queryParams.jobGroup" placeholder="请选择任务组名" clearable>
<el-option
v-for="dict in dict.type.sys_job_group"
:key="dict.value"
@@ -21,7 +20,7 @@
</el-select>
</el-form-item>
<el-form-item label="任务状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择任务状态" clearable size="small">
<el-select v-model="queryParams.status" placeholder="请选择任务状态" clearable>
<el-option
v-for="dict in dict.type.sys_job_status"
:key="dict.value"
@@ -130,9 +129,7 @@
v-hasPermi="['monitor:job:remove']"
>删除</el-button>
<el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['monitor:job:changeStatus', 'monitor:job:query']">
<span class="el-dropdown-link">
<i class="el-icon-d-arrow-right el-icon--right"></i>更多
</span>
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="handleRun" icon="el-icon-caret-right"
v-hasPermi="['monitor:job:changeStatus']">执行一次</el-dropdown-item>
@@ -165,7 +162,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="任务分组" prop="jobGroup">
<el-select v-model="form.jobGroup" placeholder="请选择">
<el-select v-model="form.jobGroup" placeholder="请选择任务分组">
<el-option
v-for="dict in dict.type.sys_job_group"
:key="dict.value"
@@ -204,7 +201,7 @@
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="错误策略" prop="misfirePolicy">
<el-form-item label="执行策略" prop="misfirePolicy">
<el-radio-group v-model="form.misfirePolicy" size="small">
<el-radio-button label="1">立即执行</el-radio-button>
<el-radio-button label="2">执行一次</el-radio-button>
@@ -457,7 +454,7 @@ export default {
/** 任务日志列表查询 */
handleJobLog(row) {
const jobId = row.jobId || 0;
this.$router.push({ path: '/monitor/job-log/index', query: { jobId: jobId } })
this.$router.push('/monitor/job-log/index/' + jobId)
},
/** 新增按钮操作 */
handleAdd() {

View File

@@ -1,12 +1,11 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="任务名称" prop="jobName">
<el-input
v-model="queryParams.jobName"
placeholder="请输入任务名称"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
@@ -14,9 +13,8 @@
<el-form-item label="任务组名" prop="jobGroup">
<el-select
v-model="queryParams.jobGroup"
placeholder="请任务组名"
placeholder="请选择任务组名"
clearable
size="small"
style="width: 240px"
>
<el-option
@@ -32,7 +30,6 @@
v-model="queryParams.status"
placeholder="请选择执行状态"
clearable
size="small"
style="width: 240px"
>
<el-option
@@ -46,7 +43,6 @@
<el-form-item label="执行时间">
<el-date-picker
v-model="dateRange"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
@@ -221,7 +217,7 @@ export default {
};
},
created() {
const jobId = this.$route.query.jobId;
const jobId = this.$route.params && this.$route.params.jobId;
if (jobId !== undefined && jobId != 0) {
getJob(jobId).then(response => {
this.queryParams.jobName = response.data.jobName;

View File

@@ -1,12 +1,11 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="登录地址" prop="ipaddr">
<el-input
v-model="queryParams.ipaddr"
placeholder="请输入登录地址"
clearable
size="small"
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
@@ -16,7 +15,6 @@
v-model="queryParams.userName"
placeholder="请输入用户名称"
clearable
size="small"
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
@@ -26,7 +24,6 @@
v-model="queryParams.status"
placeholder="登录状态"
clearable
size="small"
style="width: 240px"
>
<el-option
@@ -40,7 +37,6 @@
<el-form-item label="登录时间">
<el-date-picker
v-model="dateRange"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
@@ -77,6 +73,17 @@
v-hasPermi="['monitor:logininfor:remove']"
>清空</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-unlock"
size="mini"
:disabled="single"
@click="handleUnlock"
v-hasPermi="['monitor:logininfor:unlock']"
>解锁</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
@@ -122,7 +129,7 @@
</template>
<script>
import { list, delLogininfor, cleanLogininfor } from "@/api/monitor/logininfor";
import { list, delLogininfor, cleanLogininfor, unlockLogininfor } from "@/api/monitor/logininfor";
export default {
name: "Logininfor",
@@ -133,8 +140,12 @@ export default {
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 选择用户名
selectName: "",
// 显示搜索条件
showSearch: true,
// 总条数
@@ -178,13 +189,15 @@ export default {
resetQuery() {
this.dateRange = [];
this.resetForm("queryForm");
this.queryParams.pageNum = 1;
this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
this.handleQuery();
},
/** 多选框选中数据 */
handleSelectionChange(selection) {
this.ids = selection.map(item => item.infoId)
this.single = selection.length!=1
this.multiple = !selection.length
this.selectName = selection.map(item => item.userName);
},
/** 排序触发事件 */
handleSortChange(column, prop, order) {
@@ -211,6 +224,15 @@ export default {
this.$modal.msgSuccess("清空成功");
}).catch(() => {});
},
/** 解锁按钮操作 */
handleUnlock() {
const username = this.selectName;
this.$modal.confirm('是否确认解锁用户"' + username + '"数据项?').then(function() {
return unlockLogininfor(username);
}).then(() => {
this.$modal.msgSuccess("用户" + username + "解锁成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('monitor/logininfor/export', {

View File

@@ -1,12 +1,11 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="登录地址" prop="ipaddr">
<el-input
v-model="queryParams.ipaddr"
placeholder="请输入登录地址"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
@@ -15,7 +14,6 @@
v-model="queryParams.userName"
placeholder="请输入用户名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>

View File

@@ -1,12 +1,11 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="系统模块" prop="title">
<el-input
v-model="queryParams.title"
placeholder="请输入系统模块"
clearable
size="small"
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
@@ -16,7 +15,6 @@
v-model="queryParams.operName"
placeholder="请输入操作人员"
clearable
size="small"
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
@@ -26,7 +24,6 @@
v-model="queryParams.businessType"
placeholder="操作类型"
clearable
size="small"
style="width: 240px"
>
<el-option
@@ -42,7 +39,6 @@
v-model="queryParams.status"
placeholder="操作状态"
clearable
size="small"
style="width: 240px"
>
<el-option
@@ -56,7 +52,6 @@
<el-form-item label="操作时间">
<el-date-picker
v-model="dateRange"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
@@ -260,8 +255,8 @@ export default {
resetQuery() {
this.dateRange = [];
this.resetForm("queryForm");
this.queryParams.pageNum = 1;
this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
this.handleQuery();
},
/** 多选框选中数据 */
handleSelectionChange(selection) {

View File

@@ -106,7 +106,7 @@
<span>Java虚拟机信息</span>
</div>
<div class="el-table el-table--enable-row-hover el-table--medium">
<table cellspacing="0" style="width: 100%;">
<table cellspacing="0" style="width: 100%;table-layout:fixed;">
<tbody>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">Java名称</div></td>
@@ -128,6 +128,10 @@
<td colspan="1" class="el-table__cell is-leaf"><div class="cell">项目路径</div></td>
<td colspan="3" class="el-table__cell is-leaf"><div class="cell" v-if="server.sys">{{ server.sys.userDir }}</div></td>
</tr>
<tr>
<td colspan="1" class="el-table__cell is-leaf"><div class="cell">运行参数</div></td>
<td colspan="3" class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.inputArgs }}</div></td>
</tr>
</tbody>
</table>
</div>

View File

@@ -1,401 +1,329 @@
<template>
<div class="register">
<div style="padding:20px;">
<el-row :gutter="10">
<el-col :xs="24" :sm="24" :md="14" :lg="14" :xl="14">
<div class="login-top hidden-sm-and-down">
<h1>
<a href="https://wumei.live/" target="_blank" style="color:#FFF;">FastBee物联网平台</a>
</h1>
<h2><a href="https://wumei.live/" target="_blank" style="color:#FFF;">FastBee</a> open source living iot platform</h2>
<div style="max-width:330px;text-align:left;margin:0 auto;">
<div v-if="!bindAccount" style="padding:25px 0;">
<span style="color:#fff;margin-right:10px;">登录方式</span>
<el-button type="success" title="微信登录" size="mini" @click="authLogin" style="border:1px solid #fff;" disabled>
<svg-icon icon-class="wechat" /> 微信
</el-button>
<el-button type="danger" title="QQ登录" size="mini" @click="qqLogin" style="border:1px solid #fff;" disabled>
<svg-icon icon-class="qq" /> QQ
</el-button>
<el-button type="primary" title="支付宝登录" size="mini" @click="authLogin" style="border:1px solid #fff;" disabled>
<svg-icon icon-class="zhifubao" /> 支付宝
</el-button>
</div>
<div>
<el-button type="warning" style="padding:0px;">
<el-link href="https://wumei.live/" :underline="false" target="_blank" style="color:#fff;padding:12px 18px;">返回官网</el-link>
</el-button>
<el-button type="danger" style="padding:0px;">
<el-link href="https://wumei.live/doc" :underline="false" target="_blank" style="color:#fff;padding:12px 18px;">查看文档</el-link>
</el-button>
<el-button style="padding:0px;">
<router-link :to='{path:"/login",query: this.$route.query }' style="color:#666;padding:11px 18px;display:flex;padding-bottom:12px;">账号登录
</router-link>
</el-button>
</div>
</div>
</div>
</el-col>
<el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
<el-form ref="registerForm" :model="registerForm" :rules="registerRules" class="register-form" style="z-index:1000">
<h3 class="title" v-if="!bindAccount">注册账号</h3>
<h3 class="title" v-else>注册绑定蜂信科技账户</h3>
<el-form-item prop="username">
<el-input v-model="registerForm.username" type="text" auto-complete="off" placeholder="账号">
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
</el-input>
</el-form-item>
<el-form-item prop="phonenumber">
<el-input v-model="registerForm.phonenumber" type="text" auto-complete="off" placeholder="手机号码">
<svg-icon slot="prefix" icon-class="phone" class="el-input__icon input-icon" />
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input v-model="registerForm.password" type="password" auto-complete="off" placeholder="密码" @keyup.enter.native="handleRegister">
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
</el-input>
</el-form-item>
<el-form-item prop="confirmPassword">
<el-input v-model="registerForm.confirmPassword" type="password" auto-complete="off" placeholder="确认密码" @keyup.enter.native="handleRegister">
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
</el-input>
</el-form-item>
<el-form-item prop="code" v-if="captchaOnOff">
<el-input v-model="registerForm.code" auto-complete="off" placeholder="验证码" style="width: 63%" @keyup.enter.native="handleRegister">
<svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" />
</el-input>
<div class="register-code">
<img :src="codeUrl" @click="getCode" />
</div>
</el-form-item>
<el-form-item style="width:100%;">
<el-button v-if="!bindAccount" :loading="loading" type="primary" style="width:100%;" @click.native.prevent="handleRegister">
<span v-if="!loading"> </span>
<span v-else> 中...</span>
</el-button>
<el-button v-else :loading="loading" type="primary" style="width:100%;" @click.native.prevent="handleRegister">
<span v-if="!loading"> </span>
<span v-else> 中...</span>
</el-button>
</el-form-item>
</el-form>
</el-col>
</el-row>
</div>
<div class="register">
<el-row>
<el-col :xs="24">
<div
style="color: #fff; background-color: #0f73ee; width: 100%; height: 200px; text-align: center; padding: 15px; font-family: '微软雅黑'">
<div style="font-size: 42px; padding-top: 40px; width: 300px; margin: 0 auto">
<img :src="logo" alt="logo" style="width: 100px; height: 100px; float: left" />
<div style="float: left; margin-top: 13px; width: 200px; text-align: left">
<div>FastBee</div>
<div style="letter-spacing: 1.5px; font-size: 20px; font-weight: 600; margin-top: -8px; margin-left: 3px">
开源物联网平台</div>
</div>
</div>
</div>
<el-form ref="registerForm" :model="registerForm" :rules="registerRules" class="register-form"
style="z-index: 1000;">
<el-form-item prop="username">
<el-input v-model="registerForm.username" type="text" auto-complete="off" placeholder="账号">
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
</el-input>
</el-form-item>
<el-form-item prop="phonenumber">
<el-input v-model="registerForm.phonenumber" type="text" auto-complete="off" placeholder="手机号码">
<svg-icon slot="prefix" icon-class="phone" class="el-input__icon input-icon" />
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input v-model="registerForm.password" type="password" auto-complete="off" placeholder="密码"
@keyup.enter.native="handleRegister">
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
</el-input>
</el-form-item>
<el-form-item prop="confirmPassword">
<el-input v-model="registerForm.confirmPassword" type="password" auto-complete="off" placeholder="确认密码"
@keyup.enter.native="handleRegister">
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
</el-input>
</el-form-item>
<el-form-item v-if="captchaOnOff" prop="code">
<el-input v-model="registerForm.code" auto-complete="off" placeholder="验证码" style="width: 63%"
@keyup.enter.native="handleRegister">
<svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" />
</el-input>
<div class="register-code">
<img :src="codeUrl" @click="getCode" />
</div>
</el-form-item>
<el-form-item style="width: 100%">
<el-button v-if="!bindAccount" :loading="loading" type="primary" style="width: 100%"
@click.native.prevent="handleRegister">
<span v-if="!loading"> </span>
<span v-else> 中...</span>
</el-button>
<el-button v-else :loading="loading" type="primary" style="width: 100%"
@click.native.prevent="handleRegister">
<span v-if="!loading"> </span>
<span v-else> 中...</span>
</el-button>
</el-form-item>
<el-form-item>
<el-link href="https://fastbee.cn/" :underline="false" target="_blank" style="float: left">返回官网</el-link>
<el-link href="https://fastbee.cn/doc" :underline="false" target="_blank"
style="float: left; margin-left: 20px">查看文档</el-link>
<router-link :to="{ path: '/login', query: this.$route.query }"
style="float: left; margin-left: 20px">账号登录</router-link>
</el-form-item>
</el-form>
</el-col>
</el-row>
<!-- 底部 -->
<div class="el-register-footer">
<span>Copyright © 2021-2024 <a target="_blank" href="https://fastbee.cn/">蜂信物联</a> All Rights Reserved.</span>
<span>
Copyright © 2023
<a target="_blank" href="http://fastbee.cn">FastBee</a>
All Rights Reserved.
</span>
</div>
</div>
</div>
</template>
<script>
import 'element-ui/lib/theme-chalk/display.css';
import {
getCodeImg,
checkBindId,
bindRegister
} from "@/api/login";
import {
register
} from '@/api/iot/tool';
import logo from '@/assets/logo/logo.gif';
import { getCodeImg, checkBindId, bindRegister } from '@/api/login';
import { register } from '@/api/iot/tool';
export default {
name: "Register",
data() {
const equalToPassword = (rule, value, callback) => {
if (this.registerForm.password !== value) {
callback(new Error("两次输入的密码不一致"));
} else {
callback();
name: 'Register',
data() {
const equalToPassword = (rule, value, callback) => {
if (this.registerForm.password !== value) {
callback(new Error('两次输入的密码不一致'));
} else {
callback();
}
};
return {
logo,
codeUrl: '',
registerForm: {
username: '',
phonenumber: '',
password: '',
confirmPassword: '',
code: '',
uuid: '',
bindId: '',
},
registerRules: {
username: [
{
required: true,
trigger: 'blur',
message: '请输入您的账号',
},
{
min: 2,
max: 20,
message: '用户账号长度必须介于 2 和 20 之间',
trigger: 'blur',
},
],
phonenumber: [
{
required: true,
trigger: 'blur',
message: '请输入您的手机号码',
},
{
min: 11,
max: 11,
message: '手机号码长度为11',
trigger: 'blur',
},
],
password: [
{
required: true,
trigger: 'blur',
message: '请输入您的密码',
},
{
min: 5,
max: 20,
message: '用户密码长度必须介于 5 和 20 之间',
trigger: 'blur',
},
{
trigger: 'blur',
validator: (rule, value, callback) => {
var passwordreg = /(?![A-Z]*$)(?![a-z]*$)(?![0-9]*$)(?![^a-zA-Z0-9]*$)/
if (!passwordreg.test(value)) {
callback(new Error('密码须由大写,小写字母,数字,特殊符中的2种及以上类型组成'))
}
else {
callback()
}
}
};
return {
codeUrl: "",
registerForm: {
username: "",
phonenumber: "",
password: "",
confirmPassword: "",
code: "",
uuid: "",
bindId: ""
},
registerRules: {
username: [{
required: true,
trigger: "blur",
message: "请输入您的账号"
},
{
min: 2,
max: 20,
message: '用户账号长度必须介于 2 和 20 之间',
trigger: 'blur'
}
],
phonenumber: [{
required: true,
trigger: "blur",
message: "请输入您的手机号码"
},
{
min: 11,
max: 11,
message: '手机号码长度为11',
trigger: 'blur'
}
],
password: [{
required: true,
trigger: "blur",
message: "请输入您的密码"
},
{
min: 5,
max: 20,
message: '用户密码长度必须介于 5 和 20 之间',
trigger: 'blur'
}
],
confirmPassword: [{
required: true,
trigger: "blur",
message: "请再次输入您的密码"
},
{
required: true,
validator: equalToPassword,
trigger: "blur"
}
],
code: [{
required: true,
trigger: "change",
message: "请输入验证码"
}]
},
loading: false,
captchaOnOff: true,
bindAccount: false
};
},
],
confirmPassword: [
{
required: true,
trigger: 'blur',
message: '请再次输入您的密码',
},
{
required: true,
validator: equalToPassword,
trigger: 'blur',
},
],
code: [
{
required: true,
trigger: 'change',
message: '请输入验证码',
},
],
},
loading: false,
captchaOnOff: true,
bindAccount: false,
};
},
created() {
this.checkBind();
this.getCode();
},
methods: {
checkBind() {
const query = this.$route.query;
const bindId = query.bindId;
if (bindId === undefined || bindId === null) {
this.bindAccount = false;
} else {
this.bindAccount = true;
checkBindId(bindId).then((res) => {
this.bindAccount = res.bindAccount === undefined ? true : res.bindAccount;
if (this.bindAccount) {
this.registerForm.bindId = bindId;
} else {
this.registerForm.bindId = '';
this.$router.push({
query: {},
});
}
});
}
},
created() {
this.checkBind();
this.getCode();
},
methods: {
checkBind() {
let query = this.$route.query;
let bindId = query.bindId;
if (bindId === undefined || bindId === null) {
this.bindAccount = false;
} else {
this.bindAccount = true;
checkBindId(bindId).then(res => {
this.bindAccount = res.bindAccount === undefined ? true : res.bindAccount
if (this.bindAccount) {
this.registerForm.bindId = bindId;
} else {
this.registerForm.bindId = "";
this.$router.push({
query: {}
})
}
})
}
},
getCode() {
getCodeImg().then(res => {
this.captchaOnOff = res.captchaOnOff === undefined ? true : res.captchaOnOff;
if (this.captchaOnOff) {
this.codeUrl = "data:image/gif;base64," + res.img;
this.registerForm.uuid = res.uuid;
}
});
},
qqLogin() {
window.location.href = "http://localhost:8080/auth/render/qq";
},
authLogin() {
this.$alert('第三方登录正在集成中...', '提示消息', {
confirmButtonText: '确定',
callback: action => {
this.$message({
type: 'info',
message: `action: ${action}`
});
}
});
},
handleRegister() {
this.$refs.registerForm.validate(valid => {
if (valid) {
this.loading = true;
if (this.bindAccount) {
bindRegister(this.registerForm).then(res => {
this.innerRegister(res)
}).catch(() => {
this.loading = false;
if (this.captchaOnOff) {
this.getCode();
}
});
} else {
register(this.registerForm).then(res => {
this.innerRegister(res)
}).catch(() => {
this.loading = false;
if (this.captchaOnOff) {
this.getCode();
}
})
}
}
});
},
innerRegister(res) {
const username = this.registerForm.username;
this.$alert("<font color='red'>恭喜你,您的账号 " + username + " 注册成功!</font>", '系统提示', {
dangerouslyUseHTMLString: true,
type: 'success'
}).then(() => {
this.$router.push("/login");
}).catch(() => {});
getCode() {
getCodeImg().then((res) => {
this.captchaOnOff = res.captchaOnOff === undefined ? true : res.captchaOnOff;
if (this.captchaOnOff) {
this.codeUrl = 'data:image/gif;base64,' + res.img;
this.registerForm.uuid = res.uuid;
}
}
});
},
qqLogin() {
window.location.href = 'http://localhost:8080/auth/render/qq';
},
authLogin() {
this.$alert('第三方登录正在集成中...', '提示消息', {
confirmButtonText: '确定',
callback: (action) => {
this.$message({
type: 'info',
message: `action: ${action}`,
});
},
});
},
handleRegister() {
this.$refs.registerForm.validate((valid) => {
if (valid) {
this.loading = true;
if (this.bindAccount) {
bindRegister(this.registerForm)
.then((res) => {
this.innerRegister(res);
})
.catch(() => {
this.loading = false;
if (this.captchaOnOff) {
this.getCode();
}
});
} else {
register(this.registerForm)
.then((res) => {
this.innerRegister(res);
})
.catch(() => {
this.loading = false;
if (this.captchaOnOff) {
this.getCode();
}
});
}
}
});
},
innerRegister(res) {
const username = this.registerForm.username;
this.$alert("<font color='red'>恭喜你,您的账号 " + username + ' 注册成功!</font>', '系统提示', {
dangerouslyUseHTMLString: true,
type: 'success',
})
.then(() => {
this.$router.push('/login');
})
.catch(() => { });
},
},
};
</script>
<style lang="scss">
.register {
background: linear-gradient(303deg, #48c6ef 10%, #6f86d6 80%);
height: 100%;
overflow: auto;
padding-top: 150px;
}
.title {
margin: 0px auto 20px auto;
text-align: center;
color: #333;
font-size: 28px;
}
.login-top {
color: #fff;
text-align: center;
padding-top: 30px;
@media screen and (min-width:992px) {
h1 {
font-size: 36px;
}
h2 {
font-size: 20px;
margin-top: -20px;
}
}
@media screen and (min-width:1200px) {
h1 {
font-size: 46px;
}
h2 {
font-size: 26px;
margin-top: -25px;
}
}
@media screen and (min-width:1920px) {
padding:0px;
h1 {
font-size: 62px;
}
h2 {
font-size: 35px;
margin-top: -30px;
}
}
height: 100%;
overflow: auto;
}
.register-form {
box-shadow: 0 20px 20px 0 rgba(0, 0, 0, 0.1);
border-radius: 10px;
background: #ffffff;
background-color: rgba(250, 250, 250, 0.8);
border: 1px solid #fff;
padding: 25px 25px 5px 25px;
margin:0 auto;
z-index: 1000;
max-width: 370px;
margin-bottom: 100px;
margin: 30px auto 0 auto;
padding: 15px;
z-index: 1000;
max-width: 350px;
.el-input {
height: 38px;
input {
height: 38px;
background-color: rgba(0, 0, 0, 0.1);
color:#333;
}
// 谷歌
input::-webkit-input-placeholder{
color:#666;
}
// 火狐19+版本
input::-moz-placeholder{ /* Mozilla Firefox 19+ */
color:#666;
}
// 火狐4-18版本
input:-moz-placeholder{ /* Mozilla Firefox 4 to 18 */
color:#666;
}
// IE10-11版本
input:-ms-input-placeholder{ /* Internet Explorer 10-11 */
color:#666;
}
}
input {
height: 38px;
background-color: #f1f1f1;
color: #666;
}
.input-icon {
height: 39px;
width: 14px;
margin-left: 2px;
color:#fff;
}
.input-icon {
height: 39px;
width: 14px;
margin-left: 2px;
}
}
.register-code {
width: 33%;
height: 38px;
float: right;
width: 33%;
float: right;
img {
cursor: pointer;
vertical-align: middle;
border-radius:5px;
height: 38px;
}
img {
cursor: pointer;
vertical-align: middle;
border-radius: 3px;
height: 38px;
}
}
.el-register-footer {
height: 40px;
line-height: 40px;
position: fixed;
bottom: 0;
width: 100%;
text-align: center;
color: #fff;
font-family: Arial;
font-size: 12px;
letter-spacing: 1px;
}
</style>
height: 40px;
line-height: 40px;
position: fixed;
bottom: 0;
width: 100%;
text-align: center;
color: #333;
font-family: Arial;
font-size: 12px;
letter-spacing: 1px;
}</style>

View File

@@ -1,12 +1,11 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="参数名称" prop="configName">
<el-input
v-model="queryParams.configName"
placeholder="请输入参数名称"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
@@ -16,13 +15,12 @@
v-model="queryParams.configKey"
placeholder="请输入参数键名"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="系统内置" prop="configType">
<el-select v-model="queryParams.configType" placeholder="系统内置" clearable size="small">
<el-select v-model="queryParams.configType" placeholder="系统内置" clearable>
<el-option
v-for="dict in dict.type.sys_yes_no"
:key="dict.value"
@@ -34,7 +32,6 @@
<el-form-item label="创建时间">
<el-date-picker
v-model="dateRange"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"

View File

@@ -1,17 +1,16 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
<el-form-item label="部门名称" prop="deptName">
<el-input
v-model="queryParams.deptName"
placeholder="请输入部门名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="部门状态" clearable size="small">
<el-select v-model="queryParams.status" placeholder="部门状态" clearable>
<el-option
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
@@ -106,6 +105,8 @@
<treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级部门" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="部门名称" prop="deptName">
<el-input v-model="form.deptName" placeholder="请输入部门名称" />
@@ -116,6 +117,8 @@
<el-input-number v-model="form.orderNum" controls-position="right" :min="0" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="负责人" prop="leader">
<el-input v-model="form.leader" placeholder="请输入负责人" maxlength="20" />
@@ -126,6 +129,8 @@
<el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="邮箱" prop="email">
<el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
@@ -200,7 +205,7 @@ export default {
email: [
{
type: "email",
message: "'请输入正确的邮箱地址",
message: "请输入正确的邮箱地址",
trigger: ["blur", "change"]
}
],
@@ -292,9 +297,13 @@ export default {
this.form = response.data;
this.open = true;
this.title = "修改部门";
});
listDeptExcludeChild(row.deptId).then(response => {
this.deptOptions = this.handleTree(response.data, "deptId");
listDeptExcludeChild(row.deptId).then(response => {
this.deptOptions = this.handleTree(response.data, "deptId");
if (this.deptOptions.length == 0) {
const noResultsOptions = { deptId: this.form.parentId, deptName: this.form.parentName, children: [] };
this.deptOptions.push(noResultsOptions);
}
});
});
},
/** 提交按钮 */

View File

@@ -1,8 +1,8 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="字典名称" prop="dictType">
<el-select v-model="queryParams.dictType" size="small">
<el-select v-model="queryParams.dictType">
<el-option
v-for="item in typeOptions"
:key="item.dictId"
@@ -16,12 +16,11 @@
v-model="queryParams.dictLabel"
placeholder="请输入字典标签"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="数据状态" clearable size="small">
<el-select v-model="queryParams.status" placeholder="数据状态" clearable>
<el-option
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
@@ -164,7 +163,7 @@
<el-option
v-for="item in listClassOptions"
:key="item.value"
:label="item.label"
:label="item.label + '(' + item.value + ')'"
:value="item.value"
></el-option>
</el-select>
@@ -192,7 +191,7 @@
<script>
import { listData, getData, delData, addData, updateData } from "@/api/system/dict/data";
import { listType, getType } from "@/api/system/dict/type";
import { optionselect as getDictOptionselect, getType } from "@/api/system/dict/type";
export default {
name: "Data",
@@ -288,8 +287,8 @@ export default {
},
/** 查询字典类型列表 */
getTypeList() {
listType().then(response => {
this.typeOptions = response.rows;
getDictOptionselect().then(response => {
this.typeOptions = response.data;
});
},
/** 查询字典数据列表 */
@@ -365,12 +364,14 @@ export default {
if (valid) {
if (this.form.dictCode != undefined) {
updateData(this.form).then(response => {
this.$store.dispatch('dict/removeDict', this.queryParams.dictType);
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addData(this.form).then(response => {
this.$store.dispatch('dict/removeDict', this.queryParams.dictType);
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
@@ -387,6 +388,7 @@ export default {
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
this.$store.dispatch('dict/removeDict', this.queryParams.dictType);
}).catch(() => {});
},
/** 导出按钮操作 */

View File

@@ -1,12 +1,11 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="字典名称" prop="dictName">
<el-input
v-model="queryParams.dictName"
placeholder="请输入字典名称"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
@@ -16,7 +15,6 @@
v-model="queryParams.dictType"
placeholder="请输入字典类型"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
@@ -26,7 +24,6 @@
v-model="queryParams.status"
placeholder="字典状态"
clearable
size="small"
style="width: 240px"
>
<el-option
@@ -40,7 +37,6 @@
<el-form-item label="创建时间">
<el-date-picker
v-model="dateRange"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
@@ -343,6 +339,7 @@ export default {
handleRefreshCache() {
refreshCache().then(() => {
this.$modal.msgSuccess("刷新成功");
this.$store.dispatch('dict/cleanDict');
});
}
}

View File

@@ -1,17 +1,16 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
<el-form-item label="菜单名称" prop="menuName">
<el-input
v-model="queryParams.menuName"
placeholder="请输入菜单名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="菜单状态" clearable size="small">
<el-select v-model="queryParams.status" placeholder="菜单状态" clearable>
<el-option
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
@@ -108,7 +107,7 @@
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-row>
<el-col :span="24">
<el-form-item label="上级菜单">
<el-form-item label="上级菜单" prop="parentId">
<treeselect
v-model="form.parentId"
:options="menuOptions"
@@ -128,7 +127,7 @@
</el-form-item>
</el-col>
<el-col :span="24" v-if="form.menuType != 'F'">
<el-form-item label="菜单图标">
<el-form-item label="菜单图标" prop="icon">
<el-popover
placement="bottom-start"
width="460"
@@ -160,7 +159,7 @@
</el-form-item>
</el-col>
<el-col :span="12" v-if="form.menuType != 'F'">
<el-form-item>
<el-form-item prop="isFrame">
<span slot="label">
<el-tooltip content="选择是外链则路由地址需要以`http(s)://`开头" placement="top">
<i class="el-icon-question"></i>
@@ -196,7 +195,7 @@
</el-form-item>
</el-col>
<el-col :span="12" v-if="form.menuType != 'M'">
<el-form-item>
<el-form-item prop="perms">
<el-input v-model="form.perms" placeholder="请输入权限标识" maxlength="100" />
<span slot="label">
<el-tooltip content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasPermi('system:user:list')`)" placement="top">
@@ -207,7 +206,7 @@
</el-form-item>
</el-col>
<el-col :span="12" v-if="form.menuType == 'C'">
<el-form-item>
<el-form-item prop="query">
<el-input v-model="form.query" placeholder="请输入路由参数" maxlength="255" />
<span slot="label">
<el-tooltip content='访问路由的默认传递参数,如:`{"id": 1, "name": "ry"}`' placement="top">
@@ -218,7 +217,7 @@
</el-form-item>
</el-col>
<el-col :span="12" v-if="form.menuType == 'C'">
<el-form-item>
<el-form-item prop="isCache">
<span slot="label">
<el-tooltip content="选择是则会被`keep-alive`缓存,需要匹配组件的`name`和地址保持一致" placement="top">
<i class="el-icon-question"></i>
@@ -232,7 +231,7 @@
</el-form-item>
</el-col>
<el-col :span="12" v-if="form.menuType != 'F'">
<el-form-item>
<el-form-item prop="visible">
<span slot="label">
<el-tooltip content="选择隐藏则路由将不会出现在侧边栏,但仍然可以访问" placement="top">
<i class="el-icon-question"></i>
@@ -249,7 +248,7 @@
</el-form-item>
</el-col>
<el-col :span="12" v-if="form.menuType != 'F'">
<el-form-item>
<el-form-item prop="status">
<span slot="label">
<el-tooltip content="选择停用则路由将不会出现在侧边栏,也不能被访问" placement="top">
<i class="el-icon-question"></i>

View File

@@ -1,305 +1,312 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px" v-if="isAdmin">
<el-form-item label="公告标题" prop="noticeTitle">
<el-input v-model="queryParams.noticeTitle" placeholder="请输入公告标题" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="操作人员" prop="createBy">
<el-input v-model="queryParams.createBy" placeholder="请输入操作人员" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="类型" prop="noticeType">
<el-select v-model="queryParams.noticeType" placeholder="公告类型" clearable>
<el-option v-for="dict in dict.type.sys_notice_type" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="公告标题" prop="noticeTitle">
<el-input
v-model="queryParams.noticeTitle"
placeholder="请输入公告标题"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="操作人员" prop="createBy">
<el-input
v-model="queryParams.createBy"
placeholder="请输入操作人员"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="类型" prop="noticeType">
<el-select v-model="queryParams.noticeType" placeholder="公告类型" clearable>
<el-option
v-for="dict in dict.type.sys_notice_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:notice:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['system:notice:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['system:notice:remove']">删除</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:notice:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:notice:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:notice:remove']"
>删除</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="noticeList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" prop="noticeId" width="100" />
<el-table-column label="公告标题" align="center" prop="noticeTitle" :show-overflow-tooltip="true" />
<el-table-column label="公告类型" align="center" prop="noticeType" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_notice_type" :value="scope.row.noticeType" />
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="status" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_notice_status" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="创建者" align="center" prop="createBy" width="100" />
<el-table-column label="创建时间" align="center" prop="createTime" width="100">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-view" @click="openDetailDialog(scope.row.noticeId)">查看</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:notice:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:notice:remove']">删除</el-button>
</template>
</el-table-column>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" prop="noticeId" width="100" />
<el-table-column
label="公告标题"
align="center"
prop="noticeTitle"
:show-overflow-tooltip="true"
/>
<el-table-column label="公告类型" align="center" prop="noticeType" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_notice_type" :value="scope.row.noticeType"/>
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="status" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_notice_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="创建者" align="center" prop="createBy" width="100" />
<el-table-column label="创建时间" align="center" prop="createTime" width="100">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:notice:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:notice:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改公告对话框 -->
<el-dialog :title="title" :visible.sync="open" width="780px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<el-col :span="12">
<el-form-item label="公告标题" prop="noticeTitle">
<el-input v-model="form.noticeTitle" placeholder="请输入公告标题" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="公告类型" prop="noticeType">
<el-select v-model="form.noticeType" placeholder="请选择公告类型">
<el-option v-for="dict in dict.type.sys_notice_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="状态">
<el-radio-group v-model="form.status">
<el-radio v-for="dict in dict.type.sys_notice_status" :key="dict.value" :label="dict.value">{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="内容">
<editor v-model="form.noticeContent" :min-height="192" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<el-col :span="12">
<el-form-item label="公告标题" prop="noticeTitle">
<el-input v-model="form.noticeTitle" placeholder="请输入公告标题" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="公告类型" prop="noticeType">
<el-select v-model="form.noticeType" placeholder="请选择公告类型">
<el-option
v-for="dict in dict.type.sys_notice_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="状态">
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in dict.type.sys_notice_status"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="内容">
<editor v-model="form.noticeContent" :min-height="192"/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!--通知公告详情 -->
<el-dialog :title="form.noticeTitle" :visible.sync="openDetail" width="800px" append-to-body>
<div style="margin-top:-20px;margin-bottom:10px;">
<el-tag size="mini" effect="dark" type="warning" v-if="form.noticeType==2">公告</el-tag>
<el-tag size="mini" effect="dark" v-else>信息</el-tag>
<span style="margin-left:20px;">{{form.createTime}}</span>
</div>
<div v-loading="loadingDetail" class="content">
<div v-html="form.noticeContent"></div>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="closeDetail"> </el-button>
</div>
</el-dialog>
</div>
</div>
</template>
<script>
import {
listNotice,
getNotice,
delNotice,
addNotice,
updateNotice
} from "@/api/system/notice";
import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice";
export default {
name: "Notice",
dicts: ['sys_notice_status', 'sys_notice_type'],
data() {
return {
// 是否为管理员
isAdmin: false,
// 详情加载
loadingDetail: false,
// 打开详情
openDetail: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 公告表格数据
noticeList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
noticeTitle: undefined,
createBy: undefined,
status: undefined
},
// 表单参数
form: {},
// 表单校验
rules: {
noticeTitle: [{
required: true,
message: "公告标题不能为空",
trigger: "blur"
}],
noticeType: [{
required: true,
message: "公告类型不能为空",
trigger: "change"
}]
}
};
name: "Notice",
dicts: ['sys_notice_status', 'sys_notice_type'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 公告表格数据
noticeList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
noticeTitle: undefined,
createBy: undefined,
status: undefined
},
// 表单参数
form: {},
// 表单校验
rules: {
noticeTitle: [
{ required: true, message: "公告标题不能为空", trigger: "blur" }
],
noticeType: [
{ required: true, message: "公告类型不能为空", trigger: "change" }
]
}
};
},
created() {
this.getList();
},
methods: {
/** 查询公告列表 */
getList() {
this.loading = true;
listNotice(this.queryParams).then(response => {
this.noticeList = response.rows;
this.total = response.total;
this.loading = false;
});
},
created() {
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
noticeId: undefined,
noticeTitle: undefined,
noticeType: undefined,
noticeContent: undefined,
status: "0"
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.noticeId)
this.single = selection.length!=1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加公告";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const noticeId = row.noticeId || this.ids
getNotice(noticeId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改公告";
});
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.noticeId != undefined) {
updateNotice(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addNotice(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const noticeIds = row.noticeId || this.ids
this.$modal.confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?').then(function() {
return delNotice(noticeIds);
}).then(() => {
this.getList();
this.init();
},
methods: {
init() {
if (this.$store.state.user.roles.indexOf("tenant") === -1 && this.$store.state.user.roles.indexOf("general") === -1) {
this.isAdmin = true
}
},
/** 查询公告列表 */
getList() {
this.loading = true;
listNotice(this.queryParams).then(response => {
this.noticeList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
noticeId: undefined,
noticeTitle: undefined,
noticeType: undefined,
noticeContent: undefined,
status: "0"
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.noticeId)
this.single = selection.length != 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加公告";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const noticeId = row.noticeId || this.ids
getNotice(noticeId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改公告";
});
},
/** 提交按钮 */
submitForm: function () {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.noticeId != undefined) {
updateNotice(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addNotice(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const noticeIds = row.noticeId || this.ids
this.$modal.confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?').then(function () {
return delNotice(noticeIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
// 打开信息详情
openDetailDialog(id) {
this.openDetail = true;
this.loadingDetail = true;
getNotice(id).then(response => {
this.form = response.data;
this.openDetail = true;
this.loadingDetail = false;
});
},
// 取消按钮
closeDetail() {
this.titleDetail = "详情";
this.openDetail = false;
this.reset();
},
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
}
};
</script>
<style lang="scss" scoped>
.content {
line-height: 24px;
padding: 10px;
border: 1px solid #eee;
border-radius: 10px;
}
</style>

View File

@@ -1,12 +1,11 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="岗位编码" prop="postCode">
<el-input
v-model="queryParams.postCode"
placeholder="请输入岗位编码"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
@@ -15,12 +14,11 @@
v-model="queryParams.postName"
placeholder="请输入岗位名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="岗位状态" clearable size="small">
<el-select v-model="queryParams.status" placeholder="岗位状态" clearable>
<el-option
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"

View File

@@ -1,12 +1,11 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
<el-form-item label="用户名称" prop="userName">
<el-input
v-model="queryParams.userName"
placeholder="请输入用户名称"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
@@ -16,7 +15,6 @@
v-model="queryParams.phonenumber"
placeholder="请输入手机号码"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>

View File

@@ -1,12 +1,11 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
<el-form-item label="角色名称" prop="roleName">
<el-input
v-model="queryParams.roleName"
placeholder="请输入角色名称"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
@@ -16,7 +15,6 @@
v-model="queryParams.roleKey"
placeholder="请输入权限字符"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
@@ -26,7 +24,6 @@
v-model="queryParams.status"
placeholder="角色状态"
clearable
size="small"
style="width: 240px"
>
<el-option
@@ -40,7 +37,6 @@
<el-form-item label="创建时间">
<el-date-picker
v-model="dateRange"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
@@ -123,7 +119,8 @@
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope" v-if="scope.row.roleId !== 1 && scope.row.roleId !== 2 && scope.row.roleId !== 3">
<!-- v-if="scope.row.roleId !== 1 && scope.row.roleId !== 2 && scope.row.roleId !== 3" -->
<template slot-scope="scope" v-if="scope.row.roleId !== 1">
<el-button
size="mini"
type="text"
@@ -139,9 +136,7 @@
v-hasPermi="['system:role:remove']"
>删除</el-button>
<el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['system:role:edit']">
<span class="el-dropdown-link">
<i class="el-icon-d-arrow-right el-icon--right"></i>更多
</span>
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="handleDataScope" icon="el-icon-circle-check"
v-hasPermi="['system:role:edit']">数据权限</el-dropdown-item>
@@ -258,9 +253,8 @@
</template>
<script>
import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus } from "@/api/system/role";
import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect } from "@/api/system/role";
import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu";
import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/dept";
export default {
name: "Role",
@@ -368,12 +362,6 @@ export default {
this.menuOptions = response.data;
});
},
/** 查询部门树结构 */
getDeptTreeselect() {
deptTreeselect().then(response => {
this.deptOptions = response.data;
});
},
// 所有菜单节点数据
getMenuAllCheckedKeys() {
// 目前被选中的菜单节点
@@ -400,8 +388,8 @@ export default {
});
},
/** 根据角色ID查询部门树结构 */
getRoleDeptTreeselect(roleId) {
return roleDeptTreeselect(roleId).then(response => {
getDeptTree(roleId) {
return deptTreeSelect(roleId).then(response => {
this.deptOptions = response.depts;
return response;
});
@@ -547,12 +535,12 @@ export default {
/** 分配数据权限操作 */
handleDataScope(row) {
this.reset();
const roleDeptTreeselect = this.getRoleDeptTreeselect(row.roleId);
const deptTreeSelect = this.getDeptTree(row.roleId);
getRole(row.roleId).then(response => {
this.form = response.data;
this.openDataScope = true;
this.$nextTick(() => {
roleDeptTreeselect.then(res => {
deptTreeSelect.then(res => {
this.$refs.dept.setCheckedKeys(res.checkedKeys);
});
});

View File

@@ -1,13 +1,12 @@
<template>
<!-- 授权用户 -->
<el-dialog title="选择用户" :visible.sync="visible" width="800px" top="5vh" append-to-body>
<el-form :model="queryParams" ref="queryForm" :inline="true">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
<el-form-item label="用户名称" prop="userName">
<el-input
v-model="queryParams.userName"
placeholder="请输入用户名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
@@ -16,7 +15,6 @@
v-model="queryParams.phonenumber"
placeholder="请输入手机号码"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>

View File

@@ -9,7 +9,7 @@
</el-form-item>
</el-col>
<el-col :span="8" :offset="2">
<el-form-item label="登录账号" prop="phonenumber">
<el-form-item label="登录账号" prop="userName">
<el-input v-model="form.userName" disabled />
</el-form-item>
</el-col>

View File

@@ -20,20 +20,21 @@
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
node-key="id"
default-expand-all
highlight-current
@node-click="handleNodeClick"
/>
</div>
</el-col>
<!--用户数据-->
<el-col :span="20" :xs="24">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="用户名称" prop="userName">
<el-input
v-model="queryParams.userName"
placeholder="请输入用户名称"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
@@ -43,7 +44,6 @@
v-model="queryParams.phonenumber"
placeholder="请输入手机号码"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
@@ -53,7 +53,6 @@
v-model="queryParams.status"
placeholder="用户状态"
clearable
size="small"
style="width: 240px"
>
<el-option
@@ -67,7 +66,6 @@
<el-form-item label="创建时间">
<el-date-picker
v-model="dateRange"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
@@ -182,9 +180,7 @@
v-hasPermi="['system:user:remove']"
>删除</el-button>
<el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['system:user:resetPwd', 'system:user:edit']">
<span class="el-dropdown-link">
<i class="el-icon-d-arrow-right el-icon--right"></i>更多
</span>
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="handleResetPwd" icon="el-icon-key"
v-hasPermi="['system:user:resetPwd']">重置密码</el-dropdown-item>
@@ -248,7 +244,7 @@
<el-row>
<el-col :span="12">
<el-form-item label="用户性别">
<el-select v-model="form.sex" placeholder="请选择">
<el-select v-model="form.sex" placeholder="请选择性别">
<el-option
v-for="dict in dict.type.sys_user_sex"
:key="dict.value"
@@ -273,7 +269,7 @@
<el-row>
<el-col :span="12">
<el-form-item label="岗位">
<el-select v-model="form.postIds" multiple placeholder="请选择">
<el-select v-model="form.postIds" multiple placeholder="请选择岗位">
<el-option
v-for="item in postOptions"
:key="item.postId"
@@ -286,7 +282,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="角色">
<el-select v-model="form.roleIds" multiple placeholder="请选择">
<el-select v-model="form.roleIds" multiple placeholder="请选择角色">
<el-option
v-for="item in roleOptions"
:key="item.roleId"
@@ -345,9 +341,8 @@
</template>
<script>
import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus } from "@/api/system/user";
import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/system/user";
import { getToken } from "@/utils/auth";
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
@@ -443,7 +438,7 @@ export default {
email: [
{
type: "email",
message: "'请输入正确的邮箱地址",
message: "请输入正确的邮箱地址",
trigger: ["blur", "change"]
}
],
@@ -465,7 +460,7 @@ export default {
},
created() {
this.getList();
this.getTreeselect();
this.getDeptTree();
this.getConfigKey("sys.user.initPassword").then(response => {
this.initPassword = response.msg;
});
@@ -482,8 +477,8 @@ export default {
);
},
/** 查询部门下拉树结构 */
getTreeselect() {
treeselect().then(response => {
getDeptTree() {
deptTreeSelect().then(response => {
this.deptOptions = response.data;
});
},
@@ -495,7 +490,7 @@ export default {
// 节点单击事件
handleNodeClick(data) {
this.queryParams.deptId = data.id;
this.getList();
this.handleQuery();
},
// 用户状态修改
handleStatusChange(row) {
@@ -540,6 +535,8 @@ export default {
resetQuery() {
this.dateRange = [];
this.resetForm("queryForm");
this.queryParams.deptId = undefined;
this.$refs.tree.setCurrentKey(null);
this.handleQuery();
},
// 多选框选中数据
@@ -564,7 +561,6 @@ export default {
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.getTreeselect();
getUser().then(response => {
this.postOptions = response.posts;
this.roleOptions = response.roles;
@@ -576,14 +572,13 @@ export default {
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.getTreeselect();
const userId = row.userId || this.ids;
getUser(userId).then(response => {
this.form = response.data;
this.postOptions = response.posts;
this.roleOptions = response.roles;
this.form.postIds = response.postIds;
this.form.roleIds = response.roleIds;
this.$set(this.form, "postIds", response.postIds);
this.$set(this.form, "roleIds", response.roleIds);
this.open = true;
this.title = "修改用户";
this.form.password = "";
@@ -663,7 +658,7 @@ export default {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
this.getList();
},
// 提交上传文件

View File

@@ -1,197 +1,212 @@
<template>
<div class="app-container">
<div class="app-container">
<el-row :gutter="20">
<el-col :span="6" :xs="24">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>个人信息</span>
</div>
<div>
<div class="text-center">
<userAvatar :user="user" />
</div>
<ul class="list-group list-group-striped">
<li class="list-group-item">
<svg-icon icon-class="user" />
用户名称
<div class="pull-right">{{ user.userName }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="number" />
用户编号
<div class="pull-right">{{ user.userId }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="phone" />
手机号码
<div class="pull-right">{{ user.phonenumber }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="email" />
用户邮箱
<div class="pull-right">{{ user.email }}</div>
</li>
<li class="list-group-item" style="padding-top:40px;">
<svg-icon icon-class="tree" />
所属部门
<div class="pull-right" v-if="user.dept">{{ user.dept.deptName }} / {{ postGroup }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="peoples" />
所属角色
<div class="pull-right">{{ roleGroup }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="date" />
创建日期
<div class="pull-right">{{ user.createTime }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="qq" />
QQ
<div class="pull-right" v-if="!this.qqBind">
<el-button size="mini" style="margin-top: -7px" @click="bind(socialAccount.QQ.name)" disabled>未绑定</el-button>
</div>
<div style="float:right;display: flex;" v-else>
<span>{{ this.socialAccount.QQ.value.nickname }}</span>
<el-image style="width: 25px; height: 25px; margin-top: -7px;margin-left: 5px;margin-right: 5px" :src="this.socialAccount.QQ.value.avatar" />
<el-button style="margin-top: -5px" size="mini" @click="unbind(socialAccount.QQ.name)" disabled>解除绑定
</el-button>
</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="wechat" />
微信
<div class="pull-right">
<el-button style="margin-top: -7px" size="mini" disabled>未绑定</el-button>
</div>
</li>
</ul>
</div>
</el-card>
</el-col>
<el-col :span="18" :xs="24">
<el-card>
<div slot="header" class="clearfix">
<span>基本资料</span>
</div>
<el-tabs v-model="activeTab">
<el-tab-pane label="基本资料" name="userinfo">
<userInfo :user="user" />
</el-tab-pane>
<el-tab-pane label="修改密码" name="resetPwd">
<resetPwd :user="user" />
</el-tab-pane>
</el-tabs>
</el-card>
</el-col>
<el-col :span="6" :xs="24">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>个人信息</span>
</div>
<div>
<div class="text-center">
<userAvatar :user="user" />
</div>
<ul class="list-group list-group-striped">
<li class="list-group-item">
<svg-icon icon-class="user" />用户名称
<div class="pull-right">{{ user.userName }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="phone" />手机号码
<div class="pull-right">{{ user.phonenumber }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="email" />用户邮箱
<div class="pull-right">{{ user.email }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="tree" />所属部门
<div v-if="user.dept" class="pull-right">{{ user.dept.deptName }} / {{ postGroup }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="peoples" />所属角色
<div class="pull-right">{{ roleGroup }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="date" />创建日期
<div class="pull-right">{{ user.createTime }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="wechat" />微信绑定
<div v-if="wxbind" style="color:#007AFf" class="pull-right" @click="secureBind">已绑定,点击解绑</div>
<div v-else class="pull-right" @click="loginWxCode">未绑定,点击绑定</div>
</li>
<div id="weixinLogin" style="width: 150px;height: 200px;"></div>
</ul>
</div>
</el-card>
</el-col>
<el-col :span="18" :xs="24">
<el-card>
<div slot="header" class="clearfix">
<span>基本资料</span>
</div>
<el-tabs v-model="activeTab">
<el-tab-pane label="基本资料" name="userinfo">
<userInfo :user="user" />
</el-tab-pane>
<el-tab-pane label="修改密码" name="resetPwd">
<resetPwd />
</el-tab-pane>
</el-tabs>
</el-card>
</el-col>
</el-row>
</div>
<el-dialog title="请输入您的密码" :visible.sync="secureBindDialog" width="600px" append-to-body>
<el-form label-width="150px">
<el-form-item label="密码" prop="pasaward">
<el-input v-model="password" style="width: 80%" type="password" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="closeSummaryDialog"> </el-button>
<el-button class="btns" type="primary" @click="handleSecureBind">确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import userAvatar from "./userAvatar";
import userInfo from "./userInfo";
import resetPwd from "./resetPwd";
import {
getUserProfile
} from "@/api/system/user";
import {
unbind,
bind
} from "@/api/iot/platform";
<script >
import userAvatar from './userAvatar';
import userInfo from './userInfo';
import resetPwd from './resetPwd';
import { getWxBindMsg} from '@/api/login';
import { getUserProfile, getLoginParam, secureBind } from '@/api/system/user';
export default {
name: "Profile",
components: {
userAvatar,
userInfo,
resetPwd
},
data() {
return {
user: {},
roleGroup: {},
postGroup: {},
activeTab: "userinfo",
socialGroup: [],
qqBind: false,
wechatBind: false,
socialAccount: {
QQ: {
name: "QQ",
value: null
},
Wechat: {
name: "Wechat",
value: null
},
Status: {
bind: "0",
unbind: "1"
}
},
};
},
created() {
this.getUser();
},
methods: {
getUser() {
getUserProfile().then(response => {
this.user = response.data;
this.roleGroup = response.roleGroup;
this.postGroup = response.postGroup;
this.socialGroup = response.socialGroup;
if (!(this.socialGroup === undefined || this.socialGroup === null)) {
this.socialGroup.forEach(social => {
if (social.status === this.socialAccount.Status.bind) {
switch (social.source) {
case this.socialAccount.QQ.name: {
this.qqBind = true;
this.socialAccount.QQ.value = social;
break
}
case this.socialAccount.Wechat.name: {
this.wechatBind = true;
this.socialAccount.Wechat.value = social;
break
}
}
}
})
}
});
},
bind(type) {
switch (type) {
case this.socialAccount.QQ.name: {
if (!this.qqBind) {
bind(type).then((res) => {
window.location.href = "http://localhost:8080/auth/render/qq";
});
}
break;
}
}
name: 'Profile',
components: { userAvatar, userInfo, resetPwd },
data() {
return {
user: {},
roleGroup: {},
postGroup: {},
activeTab: 'userinfo',
qrText: 'fastbee',
wxbind: '',
secureBindDialog: false,
password: '',
verifyType: 1,
userPhone: '',
smsCode: '',
};
},
},
unbind(type) {
switch (type) {
case this.socialAccount.QQ.name: {
if (this.qqBind) {
unbind(this.socialAccount.QQ.value.socialUserId).then((res) => {
this.$modal.msgSuccess(res.msg);
this.qqBind = false;
this.socialAccount.QQ.value = null;
})
}
break;
}
}
}
created() {
this.getUser();
const wxBindMsgId = this.$route.query.wxBindMsgId;
if (wxBindMsgId != null && wxBindMsgId !== undefined) {
this.getWxBindMsg();
} else {
console.log('此时没有进行绑定操作!');
}
},
mounted() {
const script = document.createElement('script');
script.type = 'text/javascript',
script.src = 'http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js',
document.body.appendChild(script);
},
methods: {
getUser() {
getUserProfile().then(response => {
console.log(response.data);
this.user = response.data;
this.wxbind = response.wxBind;
this.roleGroup = response.roleGroup;
this.postGroup = response.postGroup;
});
},
secureBind() {
this.secureBindDialog = true;
},
handleSecureBind() {
const params = {
password: this.password,
verifyType: this.verifyType,
userPhone: this.userPhone,
smsCode: this.smsCode,
};
secureBind(params).then(response => {
this.loading = true;
this.$modal.msgSuccess(response.msg);
this.secureBindDialog = false;
if (response.code === 200) {
this.getUser();
}
})
.catch(() => {
// eslint-disable-next-line no-undef
this.$modal.msgError(response.msg);
this.loading = false;
});
},
closeSummaryDialog() {
this.secureBindDialog = false;
},
// 微信绑定二维码
loginWxCode() {
getLoginParam().then(response => {
// 实例微信js对象
// eslint-disable-next-line no-undef
const s = document.createElement('script');
s.type = 'text/javascript';
s.src = 'https://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js';
const wxElement = document.body.appendChild(s);
wxElement.onload = function () {
var obj = new WxLogin({
self_redirect: false,
id: 'weixinLogin',
appid: response.data.appid,
scope: response.data.scope,
redirect_uri: response.data.redirectUri,
state: response.data.state,
style: 'black',
href: 'data:text/css;base64,LmltcG93ZXJCb3ggLnRpdGxlIHsKIGRpc3BsYXk6IG5vbmU7Cn0KLmltcG93ZXJCb3ggLnN0YXR1cy5zdGF0dXNfYnJvd3NlciB7CiBkaXNwbGF5OiBub25lOwp9Ci5pbXBvd2VyQm94IC5xcmNvZGUgewogYm9yZGVyOm5vbmU7CiB3aWR0aDogMjAwcHg7CiBoZWlnaHQ6IDIwMHB4OwogbWFyZ2luOjAgYXV0bzsKfQouaW1wb3dlckJveCAuc3RhdHVzewogZGlzcGxheTogbm9uZQp9',
});
};
});
},
// 获取微信绑定返回结果信息
getWxBindMsg() {
const query = this.$route.query;
const wxBindMsgId = query.wxBindMsgId;
getWxBindMsg(wxBindMsgId).then((res) => {
this.$modal.msgSuccess(res.msg)
.catch(() => {
setTimeout(function() {
this.$modal.msgError(res.msg);
}, 1000);
});
});
},
},
};
</script>
<styule lang="scss">
// 自定义二维码样式
.impowerBox .title {
display: none;
}
.impowerBox .status.status_browser {
display: none;
}
.impowerBox .qrcode {
border:none;
width: 200px;
height: 200px;
margin:0 auto;
}
.impowerBox .status{
display: none
}
</styule>

View File

@@ -1,13 +1,13 @@
<template>
<el-form ref="form" :model="user" :rules="rules" label-width="80px">
<el-form-item label="旧密码" prop="oldPassword">
<el-input v-model="user.oldPassword" placeholder="请输入旧密码" type="password" show-password/>
<el-input v-model="user.oldPassword" placeholder="请输入旧密码" type="password" show-password />
</el-form-item>
<el-form-item label="新密码" prop="newPassword">
<el-input v-model="user.newPassword" placeholder="请输入新密码" type="password" show-password/>
<el-input v-model="user.newPassword" placeholder="请输入新密码" type="password" show-password />
</el-form-item>
<el-form-item label="确认密码" prop="confirmPassword">
<el-input v-model="user.confirmPassword" placeholder="请确认密码" type="password" show-password/>
<el-input v-model="user.confirmPassword" placeholder="请确认密码" type="password" show-password />
</el-form-item>
<el-form-item>
<el-button type="primary" size="mini" @click="submit">保存</el-button>
@@ -41,11 +41,23 @@ export default {
],
newPassword: [
{ required: true, message: "新密码不能为空", trigger: "blur" },
{ min: 6, max: 20, message: "长度在 6 到 20 个字符", trigger: "blur" }
{ min: 6, max: 20, message: "长度在 6 到 20 个字符", trigger: "blur" },
{
trigger: 'blur',
validator: (rule, value, callback) => {
var passwordreg = /(?![A-Z]*$)(?![a-z]*$)(?![0-9]*$)(?![^a-zA-Z0-9]*$)/
if (!passwordreg.test(value)) {
callback(new Error('密码必须由大写字母、小写字母、数字、特殊符号中的2种及以上类型组成!'))
}
else {
callback()
}
}
},
],
confirmPassword: [
{ required: true, message: "确认密码不能为空", trigger: "blur" },
{ required: true, validator: equalToPassword, trigger: "blur" }
{ required: true, validator: equalToPassword, trigger: "blur" },
]
}
};
@@ -55,7 +67,14 @@ export default {
this.$refs["form"].validate(valid => {
if (valid) {
updateUserPwd(this.user.oldPassword, this.user.newPassword).then(response => {
this.$modal.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功,请重新登录!");
if (response.code == 200) {
//清除登录缓存
localStorage.removeItem('token');
this.$store.dispatch('LogOut').then(() => {
location.href = '/index';
})
}
});
}
});

View File

@@ -12,6 +12,7 @@
:autoCropWidth="options.autoCropWidth"
:autoCropHeight="options.autoCropHeight"
:fixedBox="options.fixedBox"
:outputType="options.outputType"
@realTime="realTime"
v-if="visible"
/>
@@ -24,7 +25,7 @@
</el-row>
<br />
<el-row>
<el-col :lg="2" :md="2">
<el-col :lg="2" :sm="3" :xs="3">
<el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload">
<el-button size="small">
选择
@@ -32,19 +33,19 @@
</el-button>
</el-upload>
</el-col>
<el-col :lg="{span: 1, offset: 2}" :md="2">
<el-col :lg="{span: 1, offset: 2}" :sm="2" :xs="2">
<el-button icon="el-icon-plus" size="small" @click="changeScale(1)"></el-button>
</el-col>
<el-col :lg="{span: 1, offset: 1}" :md="2">
<el-col :lg="{span: 1, offset: 1}" :sm="2" :xs="2">
<el-button icon="el-icon-minus" size="small" @click="changeScale(-1)"></el-button>
</el-col>
<el-col :lg="{span: 1, offset: 1}" :md="2">
<el-col :lg="{span: 1, offset: 1}" :sm="2" :xs="2">
<el-button icon="el-icon-refresh-left" size="small" @click="rotateLeft()"></el-button>
</el-col>
<el-col :lg="{span: 1, offset: 1}" :md="2">
<el-col :lg="{span: 1, offset: 1}" :sm="2" :xs="2">
<el-button icon="el-icon-refresh-right" size="small" @click="rotateRight()"></el-button>
</el-col>
<el-col :lg="{span: 2, offset: 6}" :md="2">
<el-col :lg="{span: 2, offset: 6}" :sm="2" :xs="2">
<el-button type="primary" size="small" @click="uploadImg()"> </el-button>
</el-col>
</el-row>
@@ -56,6 +57,7 @@
import store from "@/store";
import { VueCropper } from "vue-cropper";
import { uploadAvatar } from "@/api/system/user";
import { debounce } from '@/utils'
export default {
components: { VueCropper },
@@ -77,9 +79,11 @@ export default {
autoCrop: true, // 是否默认生成截图框
autoCropWidth: 200, // 默认生成截图框宽度
autoCropHeight: 200, // 默认生成截图框高度
fixedBox: true // 固定截图框大小 不允许改变
fixedBox: true, // 固定截图框大小 不允许改变
outputType:"png" // 默认生成截图为PNG格式
},
previews: {}
previews: {},
resizeHandler: null
};
},
methods: {
@@ -90,6 +94,16 @@ export default {
// 打开弹出层结束时的回调
modalOpened() {
this.visible = true;
if (!this.resizeHandler) {
this.resizeHandler = debounce(() => {
this.refresh()
}, 100)
}
window.addEventListener("resize", this.resizeHandler)
},
// 刷新组件
refresh() {
this.$refs.cropper.refresh();
},
// 覆盖默认的上传行为
requestUpload() {
@@ -141,6 +155,7 @@ export default {
closeDialog() {
this.options.img = store.getters.avatar
this.visible = false;
window.removeEventListener("resize", this.resizeHandler)
}
}
};
@@ -169,4 +184,4 @@ export default {
line-height: 110px;
border-radius: 50%;
}
</style>
</style>

View File

@@ -42,7 +42,7 @@ export default {
{ required: true, message: "邮箱地址不能为空", trigger: "blur" },
{
type: "email",
message: "'请输入正确的邮箱地址",
message: "请输入正确的邮箱地址",
trigger: ["blur", "change"]
}
],

View File

@@ -41,7 +41,7 @@
<el-button @click="close">
取消
</el-button>
<el-button type="primary" @click="handelConfirm">
<el-button type="primary" @click="handleConfirm">
确定
</el-button>
</div>
@@ -94,7 +94,7 @@ export default {
close(e) {
this.$emit('update:visible', false)
},
handelConfirm() {
handleConfirm() {
this.$refs.elForm.validate(valid => {
if (!valid) return
this.$emit('confirm', { ...this.formData })

View File

@@ -486,7 +486,7 @@
</el-tree>
</template>
<template v-if="activeData.layout === 'colFormItem'">
<template v-if="activeData.layout === 'colFormItem' && activeData.tag !== 'el-button'">
<el-divider>正则校验</el-divider>
<div
v-for="(item, index) in activeData.regList"

View File

@@ -59,7 +59,7 @@
<div slot="footer">
<el-button
type="primary"
@click="handelConfirm"
@click="handleConfirm"
>
确定
</el-button>
@@ -133,7 +133,7 @@ export default {
close() {
this.$emit('update:visible', false)
},
handelConfirm() {
handleConfirm() {
this.$refs.elForm.validate(valid => {
if (!valid) return
if (this.dataType === 'number') {

View File

@@ -146,7 +146,7 @@ import { beautifierConf, titleCase } from '@/utils/index'
import { makeUpHtml, vueTemplate, vueScript, cssStyle } from '@/utils/generator/html'
import { makeUpJs } from '@/utils/generator/js'
import { makeUpCss } from '@/utils/generator/css'
import drawingDefalut from '@/utils/generator/drawingDefalut'
import drawingDefault from '@/utils/generator/drawingDefault'
import logo from '@/assets/logo/logo.gif'
import CodeTypeDialog from './CodeTypeDialog'
import DraggableItem from './DraggableItem'
@@ -171,15 +171,15 @@ export default {
selectComponents,
layoutComponents,
labelWidth: 100,
drawingList: drawingDefalut,
drawingList: drawingDefault,
drawingData: {},
activeId: drawingDefalut[0].formId,
activeId: drawingDefault[0].formId,
drawerVisible: false,
formData: {},
dialogVisible: false,
generateConf: null,
showFileName: false,
activeData: drawingDefalut[0]
activeData: drawingDefault[0]
}
},
created() {

View File

@@ -33,6 +33,7 @@
<el-option label="Double" value="Double" />
<el-option label="BigDecimal" value="BigDecimal" />
<el-option label="Date" value="Date" />
<el-option label="Boolean" value="Boolean" />
</el-select>
</template>
</el-table-column>
@@ -44,22 +45,22 @@
<el-table-column label="插入" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" v-model="scope.row.isInsert"></el-checkbox>
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isInsert"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="编辑" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" v-model="scope.row.isEdit"></el-checkbox>
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isEdit"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="列表" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" v-model="scope.row.isList"></el-checkbox>
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isList"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="查询" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" v-model="scope.row.isQuery"></el-checkbox>
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isQuery"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="查询方式" min-width="10%">
@@ -78,7 +79,7 @@
</el-table-column>
<el-table-column label="必填" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" v-model="scope.row.isRequired"></el-checkbox>
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isRequired"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="显示类型" min-width="12%">
@@ -158,7 +159,7 @@ export default {
};
},
created() {
const tableId = this.$route.query && this.$route.query.tableId;
const tableId = this.$route.params && this.$route.params.tableId;
if (tableId) {
// 获取表详细信息
getGenTable(tableId).then(res => {

View File

@@ -1,13 +1,12 @@
<template>
<!-- 导入表 -->
<el-dialog title="导入表" :visible.sync="visible" width="800px" top="5vh" append-to-body>
<el-form :model="queryParams" ref="queryForm" :inline="true">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
<el-form-item label="表名称" prop="tableName">
<el-input
v-model="queryParams.tableName"
placeholder="请输入表名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
@@ -16,7 +15,6 @@
v-model="queryParams.tableComment"
placeholder="请输入表描述"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>

View File

@@ -1,12 +1,11 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="表名称" prop="tableName">
<el-input
v-model="queryParams.tableName"
placeholder="请输入表名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
@@ -15,14 +14,12 @@
v-model="queryParams.tableComment"
placeholder="请输入表描述"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="dateRange"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
@@ -169,7 +166,8 @@
:name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
:key="key"
>
<pre><code class="hljs" v-html="highlightedCode(value, key)"></code></pre>
<el-link :underline="false" icon="el-icon-document-copy" v-clipboard:copy="value" v-clipboard:success="clipboardSuccess" style="float:right">复制</el-link>
<pre><code class="hljs" v-html="highlightedCode(value, key)"></code></pre>
</el-tab-pane>
</el-tabs>
</el-dialog>
@@ -269,7 +267,7 @@ export default {
this.$modal.msgSuccess("成功生成到自定义路径:" + row.genPath);
});
} else {
this.$download.zip("/tool/gen/batchGenCode?tables=" + tableNames, "wumei");
this.$download.zip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi.zip");
}
},
/** 同步数据库操作 */
@@ -306,6 +304,10 @@ export default {
const result = hljs.highlight(language, code || "", true);
return result.value || '&nbsp;';
},
/** 复制代码成功 */
clipboardSuccess() {
this.$modal.msgSuccess("复制成功");
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.tableId);
@@ -316,7 +318,9 @@ export default {
/** 修改按钮操作 */
handleEditTable(row) {
const tableId = row.tableId || this.ids[0];
this.$router.push({ path: '/tool/gen-edit/index', query: { tableId: tableId, pageNum: this.queryParams.pageNum } });
const tableName = row.tableName || this.tableNames[0];
const params = { pageNum: this.queryParams.pageNum };
this.$tab.openPage("修改[" + tableName + "]生成配置", '/tool/gen-edit/index/' + tableId, params);
},
/** 删除按钮操作 */
handleDelete(row) {