pull/72/head
孙萌 2023-12-12 11:45:54 +08:00
parent f65303a215
commit 1603a9652f
8 changed files with 381 additions and 16 deletions

View File

@ -56,6 +56,36 @@ function sendPostRequest(url, data) {
});
}
function sendDelRequest(url, data) {
// 一个状态为resolve包裹的是数据
// 或者状态为reject (包裹的是错误信息)
// 的promise对象
return new Promise(function (resolve, reject) {
axios.delete(url, {
headers: { //头部参数
// 'Content-Type': 'application/json; charset=utf-8',
// "Access-Control-Allow-Origin": "*",
// "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept",
'token': (localStorage.getItem('token') ? localStorage.getItem('token') : '')
},
params: data
}).then(
(res) => {
if (res.data.code == 401) {
localStorage.removeItem('token')
router.push({
name: 'login'
})
}
resolve(res);
},
(err) => {
reject(err);
}
);
});
}
//总接口域名
axios.defaults.baseURL = "/api";
axios.defaults.timeout = 30000; // 设置全局默认请求超时时间为10秒
@ -237,6 +267,20 @@ export default {
return sendPostRequest(`/getcontrol/addStatepermission?deviceId=${id1}&Permissionid=${id2}`, '')
},
//添加短信报警
addWarnMessage(data){
return sendPostRequest(`/shortMessage/setMessage`, data)
},
//根据设备id查看短信报警
messageList(data){
return sendGetRequest(`/shortMessage/selMesById`, data)
},
//根据id删除短信报警
delMessage(data){
return sendDelRequest(`/shortMessage/delmesbyid`,data)
},
//二维码溯源

View File

@ -225,6 +225,46 @@
left: 20px;
}
.warning-btn {
justify-content: flex-end;
}
.warning-btn .btn.green {
opacity: 1;
}
.warning-model {
padding: 0 30px 25px;
}
.warning-model .input-main {
margin: 0;
}
.warning-model .input-main input {
width: 300px;
}
.warning-model .input-sel {
margin-right: 30px;
}
.warning-model .input-sel > span {
margin-right: 10px;
}
.warning-model .input-sel .el-dropdown-link {
width: 200px;
}
.warning-model .vrcode-btn.red-btn {
margin: 0 !important;
}
.warning-sel {
width: 200px !important;
}
.table-title {
display: flex;
align-items: center;
@ -2636,6 +2676,11 @@
text-align: left;
}
.vrcode-model .vrcode-model-title.vrcode-model-title-282 {
background: url(../img/vrcode-title-282.png) no-repeat;
background-size: 282px 43px;
}
.vrcode-model .vrcode-model-title::after {
content: ' ';
width: 32px;
@ -3315,6 +3360,10 @@
color: #606266;
}
.el-button--primary.el-button span {
color: #fff;
}
.return-btn {
margin: 0 8px;
min-width: 120px;

File diff suppressed because one or more lines are too long

View File

@ -252,7 +252,36 @@
}
}
}
.warning-btn{
justify-content: flex-end;
.btn.green{
opacity: 1;
}
}
.warning-model{
padding:0 30px 25px;
.input-main{
margin: 0;
input{
width: 300px;
}
}
.input-sel{
margin-right: 30px;
>span{
margin-right: 10px;
}
}
.input-sel .el-dropdown-link{
width: 200px;
}
.vrcode-btn.red-btn{
margin: 0!important;
}
}
.warning-sel{
width: 200px!important;
}
.table-title {
display: flex;
align-items: center;
@ -2804,6 +2833,7 @@
}
.vrcode-model {
.vrcode-model-title {
width: 100%;
height: 43px;
@ -2817,7 +2847,10 @@
position: relative;
font-weight: bold;
text-align: left;
&.vrcode-model-title-282{
background: url(../img/vrcode-title-282.png) no-repeat;
background-size: 282px 43px;
}
&::after {
content: ' ';
width: 32px;
@ -3507,6 +3540,12 @@
color: #606266;
}
.el-button--primary{
&.el-button span{
color: #fff;
}
}
.return-btn {
// width: 120px;
margin: 0 8px;

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -28,15 +28,15 @@
}}</span> -->
{{ list[0].updateTime ? list[0].updateTime : '' }}
</div>
<div class="flex-view border-none">
<!-- <div class="input-btn">
<div class="btn blue">
<div class="flex-view border-none warning-btn">
<div class="input-btn ">
<!-- <div class="btn blue">
<img src="../../assets/image/real-time-icon1.png" alt="" />3D动态水肥监控
</div>
<div class="btn green">
</div> -->
<div class="btn green" @click="openWarn">
<img src="../../assets/image/real-time-icon2.png" alt="" />短信报警
</div>
</div> -->
</div>
</div>
<div class="realTime-list" v-if="list.length">
<vue-seamless class="seamless-warp" :data="list" :class-option="defaultOption">
@ -186,6 +186,107 @@
<el-button type="primary" @click="addModel = false"> </el-button>
</span>
</el-dialog>
<el-dialog title="控制器短信报警规则" class="vrcode-model" top="5vh" :append-to-body="true" :visible.sync="warnModel"
width="1200px">
<div class="vrcode-model-title vrcode-model-title-282">控制器短信报警规则</div>
<div class="warning-model ">
<div class="title-tips">新建报警规则</div>
<div class="flex-view border-none">
<div class="input-main">
<div>设备code码</div>
<input disabled type="text" v-model="warnForm.deviceId">
</div>
</div>
<div class="flex-view">
<div class="input-main">
<div>用户1手机号</div>
<input type="text" v-model="warnForm.phonenumber">
<span></span>
</div>
<div class="input-main">
<div>用户2手机号</div>
<input type="text" v-model="warnForm.phonenumber2">
</div>
</div>
<div class="flex-view">
<div class="input-sel">
<span>判断条件</span>
<el-dropdown @command="handleCommand">
<div class="el-dropdown-link">
<input v-model="warnModelSel1" type="text" class="input-input" placeholder="请选择">
<div class="arrow"><img src="../../assets/image/arrow.png" alt=""></div>
</div>
<el-dropdown-menu class="warning-sel" slot="dropdown">
<el-dropdown-item v-for="item, index in typeSelList" :key="index" :command="index">{{
item.name
}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<div class="input-sel">
<el-dropdown @command="handleCommand1">
<div class="el-dropdown-link">
<input v-model="warnModelSel2" type="text" class="input-input" placeholder="请选择">
<div class="arrow"><img src="../../assets/image/arrow.png" alt=""></div>
</div>
<el-dropdown-menu class="warning-sel" slot="dropdown">
<el-dropdown-item v-for="item, index in typeSelList1" :key="index" :command="index">{{
item.name
}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<div class="input-main">
<input type="text" v-model="warnForm.environmentData" style="width: 200px;" placeholder="请输入设定值">
<span></span>
</div>
<div class="input-btn ">
<div class="btn blue" @click="addMessage">
<img src="../../assets/img/add.png" alt="" />添加
</div>
</div>
</div>
<div class="title-tips">原有报警规则</div>
<div class="vrcode-table">
<div class="vrcode-table-view table-view">
<el-table :data="tableData" :row-class-name="tableRowClassName" height="520" style="width: 100%">
<el-table-column prop="environmentId" label="报警名称">
<template slot-scope="scope">
<div>
{{ typeSelList[scope.row.environmentId-1].name }}
</div>
</template>
</el-table-column>
<el-table-column prop="environmentId" label="判断条件">
<template slot-scope="scope">
<div>
{{ typeSelList1[scope.row.unit-1].name }}
</div>
</template>
</el-table-column>
<el-table-column prop="environmentData" label="数值"></el-table-column>
<el-table-column prop="phonenumber" label="手机号1"></el-table-column>
<el-table-column prop="phonenumber2" label="手机号2"></el-table-column>
<el-table-column label="操作" width="100">
<template slot-scope="scope">
<div class="vrcode-table-btn">
<div class="vrcode-btn red-btn" @click="delMessage(scope.row)">
删除
</div>
</div>
</template>
</el-table-column>
</el-table>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="returnWarn"> </el-button>
</span>
</div>
</el-dialog>
</div>
</template>
<script>
@ -244,6 +345,32 @@ export default {
nowDevicestatus: [],//
selDevicestatus: [],//
addModel: false,//
warnModelSel1: '',
warnModelSel2: '',
warnModel: false,//
deviceId: '',//id
warnForm: {
"deviceId": '',
"userId": '',
"environmentData": '',
"environmentId": '',
"unit": '',
"phonenumber": '',
"phonenumber2": ''
},
tableData: [],
//
typeSelList: [{ name: '1#平均空气温度', value: 1, },
{ name: '2#平均空气温度', value: 2, },
{ name: '1#光亮度', value: 3, },
{ name: '1#二氧化碳', value: 4, },
{ name: '1#平均土壤温度', value: 5, },
{ name: '1#平均土壤湿度', value: 6, },],
typeSelList1: [{ name: '大于(>)', value: 1, },
{ name: '小于(<)', value: 2, },
{ name: '大于等于(>=)', value: 3, },
{ name: '小于等于(<=)', value: 4, },],
}
},
watch: {
@ -296,6 +423,111 @@ export default {
this.$bus.$off('refreshTime')
},
methods: {
tableRowClassName({ row, rowIndex }) {
if (rowIndex % 2 == 1) {
return 'warning-row';
} else if (rowIndex % 2 == 0) {
return 'success-row';
}
return '';
},
delMessage(item){
var data={
messageId:item.id
}
this.api.delMessage(data).then(res=>{
if (res.data.code == 200) {
this.$message({
message: '删除成功',
type: "success",
});
this.getMessageList()
} else {
this.$message.error(res.data.msg);
}
})
},
getMessageList() {
var data = {
deviceId: this.warnForm.deviceId
}
this.api.messageList(data).then(res => {
if (res.data.code == 200) {
this.tableData=res.data.data
} else {
this.$message.error(res.data.msg);
}
})
},
addMessage() {
console.log(this.warnForm);
this.api.addWarnMessage(this.warnForm).then(res => {
if (res.data.code == 200) {
this.$message({
message: '添加成功',
type: "success",
});
this.warnForm = {
"userId": '',
"environmentData": '',
"environmentId": '',
"unit": '',
"phonenumber": '',
"phonenumber2": ''
}
this.getMessageList()
} else {
this.$message.error(res.data.msg);
}
})
},
returnWarn() {
this.warnForm = {
"userId": '',
"environmentData": '',
"environmentId": '',
"unit": '',
"phonenumber": '',
"phonenumber2": ''
}
this.warnModel = false
},
//
openWarn() {
this.warnForm = {
"deviceId": '',
"userId": '',
"environmentData": '',
"environmentId": '',
"unit": '',
"phonenumber": '',
"phonenumber2": ''
}
var store = this.$store.state
var userid = JSON.parse(localStorage.getItem('userInfo')).userid
this.warnForm.userId = userid
this.warnForm.deviceId = store.equipmentList[this.indexs - 1].deviceId
this.getMessageList()
this.warnModel = true
},
//
handleCommand(index) {
this.warnModelSel1 = this.typeSelList[index].name
this.warnForm.environmentId = this.typeSelList[index].value
// this.TypeSel = this.typeSelList[index].name
// this.TypeSelIndex = this.typeSelList[index].value
// var dataNum = {
// target: {
// value: this.TypeSelIndex,
// },
// };
// this.changeBtn(21657 + (this.indexs - 1), dataNum);
},
//1
handleCommand1(index) {
this.warnModelSel2 = this.typeSelList1[index].name
this.warnForm.unit = this.typeSelList1[index].value
},
padString(str, length) {
return str.padStart(length, '0');
},

View File

@ -260,6 +260,7 @@ export default {
this.get21531()
this.inputData['21532'] = this.countData(this.inputData['21532'])
this.inputData['21533'] = this.countData10(this.inputData['21533'])
this.inputData['21562'] = this.countData10(this.inputData['21562'])
}
})