<script setup>
|
import { onLoad } from '@dcloudio/uni-app'
|
import { getFacilityApi,getParameterApi } from '../../api/index.js'
|
import { ref,onMounted } from 'vue';
|
|
let facilityId
|
let onLineState
|
let facilityCode
|
onLoad(async(option) =>{
|
console.log(14,option)
|
facilityId = option.id
|
await getFacilityById()
|
})
|
onMounted(async() =>{
|
await handleSetting()
|
})
|
async function getFacilityById(){
|
await getFacilityApi(facilityId).then((res) =>{
|
onLineState = res.data.onLineState
|
facilityCode = res.data.facilityCode
|
})
|
}
|
//表单相关
|
const formRef = ref()
|
const formData = ref({})
|
function initData(){
|
formData.value = {
|
sn: '',
|
swipingCardAmount: 100,
|
pulse: 450,
|
swipingCardTime: 45,
|
|
insertCoinsCount: 5,
|
insertCoinsTime: 22,
|
swipingCardCount: 7500,
|
recycleAmountTime: 60,
|
lightFetchWaterTime: 60,
|
|
lockFetchWaterTime: 60,
|
produceWaterTime: 1,
|
wasteWaterTime: 10,
|
wasteWaterIntervalTime: 10,
|
ozoneTime: 10,
|
|
ozoneIntervalTime: 60,
|
temperatureLower: 10,
|
temperatureUpper: 15,
|
openAdvertTime: '19:10',
|
closeAdvertTime: '23:30',
|
|
recycleWashing: 10,
|
recycleWashingInterval: 4,
|
runningMode: 1,
|
isReport: 1,
|
wxFetchWaterAmount: 100,
|
|
wxFetchWaterTime: 45,
|
wxFetchWaterCount: 7500,
|
coinsFetchWater: 3750,
|
type:'',
|
}
|
}
|
//表单校验
|
|
const rulesData = ref({
|
swipingCardAmount: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^(1|[1-9]\d{0,2}|[1-5]\d{3}|6000)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
pulse: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^([1-9]\d{0,2}|1\d{3}|2000)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
swipingCardTime:{
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^([1-9]\d{0,2}|1000)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
|
insertCoinsCount: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^([1-9]|10)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
insertCoinsTime: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^([1-9]\d{0,2}|1000)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
swipingCardCount: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^(1|([1-9]\d{0,4}|[1-5]\d{4}|6[0-4]\d{3}|65000))$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
recycleAmountTime: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^(1[0-9]{1,2}|2[0-3][0-9]|240)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
lightFetchWaterTime: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^([5-9]|[1-9]\d|1\d{2}|2[0-3]\d|240)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
|
lockFetchWaterTime:{
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^([5-9]|[1-9]\d|1\d{2}|2[0-3]\d|240)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
produceWaterTime:{
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^([1-5]\d{0,1}|60)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
wasteWaterTime: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^(1[0-9]{1,2}|2[0-3][0-9]|240)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
wasteWaterIntervalTime: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^([5-9]|[1-9]\d|1\d{2}|2[0-3]\d|240)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
ozoneTime: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^([5-9]|[1-9]\d|1\d{2}|2[0-3]\d|240)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
|
ozoneIntervalTime: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^([3-9]\d|1\d{2}|2[0-3]\d|240)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
temperatureLower: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^([1-9]|[1-2]\d|3[0-5])$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
temperatureUpper:{
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^[3-9]|[1-4]\d|50$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
openAdvertTime: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
],
|
},
|
closeAdvertTime: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
],
|
},
|
|
recycleWashing: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^([1-9]\d{0,1}|0)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
recycleWashingInterval:{
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^([1-9]|10)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
runningMode: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^1|2$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
isReport: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^1|2$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
wxFetchWaterAmount:{
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^(1|[1-9]\d{0,2}|[1-5]\d{3}|6000)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
|
wxFetchWaterTime: {
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^([1-9]\d{0,3}|10000)$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
wxFetchWaterCount:{
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^(1|([1-9]\d{0,4}|[1-5]\d{4}|6[0-4]\d{3}|65000))$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
coinsFetchWater:{
|
rules:[
|
{required: true,errorMessage: '请输入参数'},
|
{pattern:/^(1|([1-9]\d{0,4}|[1-5]\d{4}|6[0-4]\d{3}|65000))$/,errorMessage: '超出范围,请输入范围内参数'},
|
],
|
},
|
});
|
|
//参数设置按钮,请求设备参数
|
async function handleSetting(){
|
await getParameterApi(facilityCode).then((res) =>{
|
//参数不为空
|
if(res.data != null){
|
formData.value = res.data
|
}else{
|
//参数为空置为默认
|
initData()
|
formData.value.sn = facilityCode
|
}
|
})
|
}
|
//type:1:修改参数,0:恢复出厂设置
|
//恢复出厂设置
|
async function restore(){
|
if(onLineState == 1){
|
|
let sn = formData.value.sn
|
initData()
|
formData.value.type = 0
|
formData.value.sn = sn
|
await setParams(formData.value)
|
}else{
|
uni.showToast({
|
title:'离线,无法操作',
|
icon:'none'
|
})
|
}
|
}
|
//修改参数
|
async function save(){
|
if(onLineState.value == 1){
|
|
formData.value.type = 1
|
formRef.value.validate.then(async() =>{
|
await setParams(formData.value)
|
}).catch(() =>{})
|
}else{
|
uni.showToast({
|
title:'离线,无法操作',
|
icon:'none'
|
})
|
}
|
}
|
|
async function setParams(formParams){
|
await facilityList().editParameter(formParams).then((res) =>{
|
if(res.code == 200){
|
uni.showToast({
|
title:'成功!三秒刷新'
|
})
|
setTimeout(async() =>{
|
await handleSetting()
|
},4000)
|
}else{
|
uni.showToast({
|
title:'网络错误',
|
icon:'none'
|
})
|
}
|
})
|
}
|
</script>
|
<template>
|
<view>
|
<view class="container">
|
<navbar title = '参数设置'></navbar>
|
<view class="content">
|
<view class="head">
|
<text>设备参数设置</text>
|
</view>
|
<view class="main">
|
<view class="form-box">
|
<uni-forms ref="formRef" :modelValue="formData" :rules="rulesData">
|
<view class="devide-name">水价设置:</view>
|
<uni-group>
|
<uni-forms-item class="form-item" name="swipingCardAmount">
|
<text style="color:#4784c7">刷卡扣费金额:(范围:10-6000分)</text>
|
<uni-easyinput type="text" v-model="formData.swipingCardAmount" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="swipingCardTime">
|
<text style="color:#4784c7">刷卡打水时间:(范围:1-1000秒)</text>
|
<uni-easyinput type="text" v-model="formData.swipingCardTime" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="swipingCardCount">
|
<text style="color:#4784c7">刷卡打水水量:(范围:1-65000毫升)</text>
|
<uni-easyinput type="text" v-model="formData.swipingCardCount" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="insertCoinsCount">
|
<text style="color:#4784c7">投币数量设置:(范围:1-10个)</text>
|
<uni-easyinput type="text" v-model="formData.insertCoinsCount" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="insertCoinsTime">
|
<text style="color:#4784c7">5角投币打水时间:(范围:1-1000秒)</text>
|
<uni-easyinput type="text" v-model="formData.insertCoinsTime" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="coinsFetchWater">
|
<text style="color:#4784c7">5角投币打水水量:(范围:1-65000毫升)</text>
|
<uni-easyinput type="text" v-model="formData.coinsFetchWater" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="wxFetchWaterAmount">
|
<text style="color:#4784c7">微信打水金额:(范围:1-6000分)</text>
|
<uni-easyinput type="text" v-model="formData.wxFetchWaterAmount" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="wxFetchWaterTime">
|
<text style="color:#4784c7">微信打水时间:(范围:1-1000秒)</text>
|
<uni-easyinput type="text" v-model="formData.wxFetchWaterTime" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="wxFetchWaterCount">
|
<text style="color:#4784c7">微信打水量:(范围:1-65000毫升)</text>
|
<uni-easyinput type="text" v-model="formData.wxFetchWaterCount" placeholder="请输入姓名" />
|
</uni-forms-item>
|
</uni-group>
|
|
<view class="devide-name">系统参数:</view>
|
<uni-group>
|
<uni-forms-item class="form-item" name="runningMode">
|
<text style="color:#4784c7">计费模式:(范围:1时间,2流量)</text>
|
<uni-easyinput type="text" v-model="formData.runningMode" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="pulse">
|
<text style="color:#4784c7">流量计脉冲数:(范围:1-2000个)</text>
|
<uni-easyinput type="text" v-model="formData.pulse" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="recycleAmountTime">
|
<text style="color:#4784c7">钱数回收时间:(范围:10-240秒)</text>
|
<uni-easyinput type="text" v-model="formData.recycleAmountTime" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="lightFetchWaterTime">
|
<text style="color:#4784c7">打水灯延时:(范围:5-240秒)</text>
|
<uni-easyinput type="text" v-model="formData.lightFetchWaterTime" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="lockFetchWaterTime">
|
<text style="color:#4784c7">打水锁延时:(范围:5-240秒)</text>
|
<uni-easyinput type="text" v-model="formData.lockFetchWaterTime" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="isReport">
|
<text style="color:#4784c7">是否语音播报金额:(范围:1开启,2关闭)</text>
|
<uni-easyinput type="text" v-model="formData.isReport" placeholder="请输入姓名" />
|
</uni-forms-item>
|
</uni-group>
|
|
<view class="devide-name">制水设置:</view>
|
<uni-group>
|
<uni-forms-item class="form-item" name="produceWaterTime">
|
<text style="color:#4784c7">制水延时:(范围:1-60分)</text>
|
<uni-easyinput type="text" v-model="formData.produceWaterTime" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="wasteWaterTime">
|
<text style="color:#4784c7">废水重洗时间:(范围:5-240秒)</text>
|
<uni-easyinput type="text" v-model="formData.wasteWaterTime" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="wasteWaterIntervalTime">
|
<text style="color:#4784c7">废水重洗间隔:(范围:30-240秒)</text>
|
<uni-easyinput type="text" v-model="formData.wasteWaterIntervalTime" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="ozoneTime">
|
<text style="color:#4784c7">臭氧杀菌时间:(范围:1-240秒)</text>
|
<uni-easyinput type="text" v-model="formData.ozoneTime" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="ozoneIntervalTime">
|
<text style="color:#4784c7">臭氧杀菌间隔:(范围:1-240秒)</text>
|
<uni-easyinput type="text" v-model="formData.ozoneIntervalTime" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="temperatureLower">
|
<text style="color:#4784c7">加热温度下限:(范围:1-35℃)</text>
|
<uni-easyinput type="text" v-model="formData.temperatureLower" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="temperatureUpper">
|
<text style="color:#4784c7">加热温度上限:(范围:3-50℃)</text>
|
<uni-easyinput type="text" v-model="formData.temperatureUpper" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="openAdvertTime">
|
<text style="color:#4784c7;font-size: 26rpx">广告灯开启时间:(范围:00:00~23:59时分)</text>
|
<uni-easyinput type="text" v-model="formData.openAdvertTime" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="closeAdvertTime">
|
<text style="color:#4784c7;font-size: 26rpx">广告灯关闭时间:(范围:00:00~23:59时分)</text>
|
<uni-easyinput type="text" v-model="formData.closeAdvertTime" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="recycleWashing">
|
<text style="color:#4784c7">循环重洗时间:(范围:0-99秒)</text>
|
<uni-easyinput type="text" v-model="formData.recycleWashing" placeholder="请输入姓名" />
|
</uni-forms-item>
|
<uni-forms-item class="form-item" name="recycleWashingInterval">
|
<text style="color:#4784c7">循环重洗间隔:(范围:1-10小时)</text>
|
<uni-easyinput type="text" v-model="formData.recycleWashingInterval" placeholder="请输入姓名" />
|
</uni-forms-item>
|
</uni-group>
|
</uni-forms>
|
</view>
|
<view class="handle-btn">
|
<view class="left" @click="restore">恢复出厂设置</view>
|
<view class="right" @click="save">保存设置</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
<style lang="scss" scoped>
|
.container{
|
width:100%;
|
box-sizing: border-box;
|
.content{
|
height:calc(100vh - 176rpx);
|
background: linear-gradient(to bottom,#8BC1FC 0%,#D2F2FE 30%,#D2F2FE 100%);
|
padding:30rpx 40rpx 100rpx;
|
box-sizing: border-box;
|
.head{
|
width:100%;
|
height: 100rpx;
|
background-color: rgba(255,255,255,0.6);
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
font-size: 38rpx;
|
color: #4784c7;
|
letter-spacing: 2rpx;
|
box-shadow: 0 4rpx 4rpx 1rpx rgba(71,132,199,0.6);
|
}
|
.main{
|
width:100%;
|
height:calc(100% - 100rpx);
|
background-color: rgba(255,255,255,0.6);
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
justify-content: center;
|
margin-top:30rpx;
|
padding:30rpx 40rpx;
|
box-sizing:border-box;
|
.handle-btn{
|
height:60rpx;
|
width:100%;
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
text-align: center;
|
margin-top:50rpx;
|
.left{
|
border: 1rpx solid #5694f0;
|
color: #409EFF;
|
background-color:#fff;
|
border-radius:15rpx;
|
line-height:60rpx;
|
margin-right:60rpx;
|
width: 215rpx;
|
font-size: 30rpx;
|
}
|
.left:hover{
|
opacity: 0.8;
|
}
|
.right{
|
background-color:#409EFF;
|
color: #fff;
|
border-radius:15rpx;
|
line-height:60rpx;
|
width: 215rpx;
|
font-size: 30rpx;
|
}
|
.right:hover{
|
opacity:0.8;
|
}
|
}
|
.form-box{
|
width: 580rpx;
|
height:90%;
|
overflow: scroll;
|
.devide-name{
|
width:100%;
|
color: #30b351;
|
margin:20rpx 0;
|
}
|
.form-item{
|
width:100%;
|
}
|
}
|
}
|
}
|
}
|
|
</style>
|