| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- <template>
- <view>
- <view class="" v-if="myuser_type">
- <view class="tit adminTit">
- 操作
- </view>
- <view class="btns">
- <button type="warn" @click="equipBtnControl('update')" size="mini">升级</button>
- <button type="warn" @click="equipBtnControl('reboot')" size="mini">重启</button>
- <button type="warn" @click="equipBtnControl('clearworm')" size="mini">清网</button>
- </view>
- <view class="tit adminTit">
- 设备开关
- </view>
- <view class="uni-list-cell" @click="cell">
- <text class="uni-input">{{equipContrlForm1.ds=="0"?'关机':'开机'}}</text>
- <view class="arrow"></view>
- <u-select v-model="ds_show" mode="single-column" :list="ds_list" @confirm="confirm($event,'ds')"></u-select>
- </view>
- <view class="tit adminTit">
- 时控开关
- </view>
- <view class="uni-list-cell" @click="shicell">
- <text class="uni-input">{{equipContrlForm1.timctrl=="0"?'关':'开'}}</text>
- <view class="arrow"></view>
- <u-select v-model="timctrl_show" mode="single-column" :list="timctrl_list" @confirm="confirm($event,'timctrl')"></u-select>
- </view>
- </view>
- <view class="" v-if="Number(equipContrlForm1.timctrl)">
- <view class="tit">
- 时控时长
- </view>
- <view class="selectTime">
- <view class="uni-list-cell time" @click="selectTime('st')">
- <text>{{time.time1||'开始时间'}}</text>
- <u-icon name="clock"></u-icon>
- </view>
- <text class="line">-</text>
- <view class="uni-list-cell time" @click="selectTime('et')">
- <text>{{time.time2||'结束时间'}}</text>
- <u-icon name="clock"></u-icon>
- </view>
- <u-select v-model="timeShow" mode="single-column" :list="timeList" @confirm="timeConfirm($event,timeType)"></u-select>
- </view>
- </view>
- <view class="tit">
- 数据频率(min)
- </view>
- <view class="">
- <slider :value="equipContrlForm1.dat_f" show-value="true" :min="10" :max="40" @change="sliderChange" block-color="#57C878" activeColor="#57C878" step="1" />
- </view>
- <view class="submit-box">
- <u-button @click="submit" type="success">确定</u-button>
- </view>
- <u-toast ref="toast" />
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- d_id:'',
- equipContrlForm1: {
- st: '', //时控开始时间
- et: '', //时控结束时间
- dat_f: 10 ,//数据上传时间间隔
- ds:'',//开关,1开机,0关机
- timctrl:''//时控开关 1开,0关
- },
- time:{
- time1:'',
- time2:''
- },
- ds_list:[{
- value:0,
- label:'关机'
- },{
- value:1,
- label:'开机'
- }
- ],
- ds_show:false,
- timctrl_list:[
- {
- value:0,
- label:'关'
- },{
- value:1,
- label:'开'
- }
- ],
- timctrl_show:false,
- timeList:[],
- timeShow:false,
- timeType:'',
- myuser_type:false
- }
- },
- onLoad(option){
- this.d_id=option.d_id
- this.equipSet()
- uni.getStorage({
- key: "myuser_type",
- success: (res) => {
- if (Number(res.data) == 1) {
- this.myuser_type = true
- }
- }
- })
- },
- methods: {
- //回显设备控制参数
- async equipSet(){
- let res=await this.$myRequest({
- url:'/api/api_gateway?method=forecast.send_control.device_control_info',
- data:{
- d_id:this.d_id,
- cmd: "paramconf"
- }
- })
- console.log(res)
- let obj = {
- st: res.work_tim.st,
- et: res.work_tim.et,
- timctrl: res.work_tim.timctrl,
- ds: res.power.ds,
- dat_f: res.data_tim.dat_f,
- };
- this.equipContrlForm1=obj
- this.time.time1= obj.st && obj.st < 10 ? "0" + obj.st + ":00" : obj.st + ":00";
- this.time.time2= obj.et && obj.et < 10 ? "0" + obj.et + ":00" : obj.et + ":00";
- },
- async equipBtnControl(cmd){
- let res=await this.$myRequest({
- url:'/api/api_gateway?method=forecast.send_control.admin_device_control',
- data:{
- cmd,
- device_type_id: 4,
- d_id: this.d_id
- }
- })
- if(res){
- this.$refs.toast.show({
- title: '指令下发成功!',
- type: 'success',
- })
- }
- },
- sliderChange(e){
- this.equipContrlForm1.dat_f=e.detail.value
- },
- selectTime(a){
- this.timeType=a
- if(this.timeList.length==0){
- let arr=[]
- for(let i=0;i<24;i++){
- let label=i<10?`0${i}:00`:`${i}:00`
- arr.push({
- value:i,
- label
- })
- }
- arr.unshift({
- value:'',
- label:'重置'
- })
- this.timeList=arr
- }
- this.timeShow=true
- },
- confirm(e,a){
- if(a=='ds'){
- this.equipContrlForm1.ds=e[0].value
- }else if(a=='timctrl'){
- this.equipContrlForm1.timctrl=e[0].value
- }
- },
- timeConfirm(e,a){
- if(a=='st'){
- this.time.time1=e[0].label
- this.equipContrlForm1.st=e[0].value
- }else{
- this.time.time2=e[0].label
- this.equipContrlForm1.et=e[0].value
- }
- },
- cell(){//设备开关
- this.ds_show=true
- },
- shicell(){
- this.timctrl_show=true
- },
- async submit(){
- console.log(this.equipContrlForm1)
- let obj = {
- work_tim: {
- timctrl: this.equipContrlForm1.timctrl,
- st: this.equipContrlForm1.st,
- et: this.equipContrlForm1.et ,
- },
- data_tim: { dat_f: this.equipContrlForm1.dat_f },
- power: { ds: this.equipContrlForm1.ds },
- };
- let res=await this.$myRequest({
- url:'/api/api_gateway?method=forecast.send_control.device_control',
- data:{
- device_type_id: 4,
- d_id: this.d_id,
- config: JSON.stringify(obj),
- }
- })
- if(res){
- this.$refs.toast.show({
- title: '修改成功!',
- type: 'success',
- callback:function(){
- uni.navigateBack({
- delta: 1
- });
- }
- })
-
- }
- }
- }
- }
- </script>
- <style lang="scss">
- page{
- padding:20rpx;
- box-sizing: border-box;
- .tit{
- line-height:30rpx;
- font-size:30rpx;
- padding-left:20rpx;
- border-left-width:2px;
- border-left-style: solid;
- border-left-color:$uni-color-success;
- margin:30rpx 0;
- }
- .adminTit{border-left-color:#e64340;}
- .btns{
- display:flex;
- justify-content: flex-start;
- flex-wrap:no-wrap;
- button{margin:0;margin-right:10rpx;padding:0 25rpx;}
- }
- .uni-list-cell{
- background:#F7F8FA;
- padding:10rpx 40rpx;
- font-size:28rpx;
- .arrow{
- display:inline-block;
- border-width:12rpx 8rpx ;
- border-style: solid;
- float:right;
- margin-top:10rpx;
- border-color:#888 transparent transparent transparent;
- }
- }
- .selectTime{
- display:flex;
- margin-bottom:20rpx;
- .time{
- width:350rpx;
- display:flex;
- justify-content: space-between;
- }
- .line{width:50rpx;text-align: center;}
- }
- .submit-box{
- margin-top:60rpx
- }
- }
- </style>
|