equip-set.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view>
  3. <view class="tit adminTit">
  4. 操作
  5. </view>
  6. <view class="btns">
  7. <button type="warn" @click="equipBtnControl('update')" size="mini">升级</button>
  8. <button type="warn" @click="equipBtnControl('reboot')" size="mini">重启</button>
  9. <button type="warn" @click="equipBtnControl('clearworm')" size="mini">清网</button>
  10. <button type="warn" @click="" size="mini">查询服务器配置</button>
  11. </view>
  12. <view class="tit adminTit">
  13. 设备开关
  14. </view>
  15. <view class="uni-list-cell" @click="ds_show=true">
  16. <text class="uni-input">{{equipContrlForm1.ds=="0"?'关机':'开机'}}</text>
  17. <view class="arrow"></view>
  18. <u-select v-model="ds_show" mode="single-column" :list="ds_list" @confirm="confirm($event,'ds')"></u-select>
  19. </view>
  20. <view class="tit adminTit">
  21. 时控开关
  22. </view>
  23. <view class="uni-list-cell" @click="timctrl_show=true">
  24. <text class="uni-input">{{equipContrlForm1.timctrl=="0"?'关':'开'}}</text>
  25. <view class="arrow"></view>
  26. <u-select v-model="timctrl_show" mode="single-column" :list="timctrl_list" @confirm="confirm($event,'timctrl')"></u-select>
  27. </view>
  28. <view class="tit">
  29. 时控时长
  30. </view>
  31. <view class="selectTime">
  32. <view class="uni-list-cell time" @click="selectTime('st')">
  33. <text>{{time.time1||'开始时间'}}</text>
  34. <u-icon name="clock"></u-icon>
  35. </view>
  36. <text class="line">-</text>
  37. <view class="uni-list-cell time" @click="selectTime('et')">
  38. <text>{{time.time2||'结束时间'}}</text>
  39. <u-icon name="clock"></u-icon>
  40. </view>
  41. <u-select v-model="timeShow" mode="single-column" :list="timeList" @confirm="timeConfirm($event,timeType)"></u-select>
  42. </view>
  43. <view class="tit">
  44. 数据频率(min)
  45. </view>
  46. <view class="">
  47. <slider :value="equipContrlForm1.dat_f" show-value="true" :min="10" :max="40" @change="sliderChange" block-color="#57C878" activeColor="#57C878" step="1" />
  48. </view>
  49. <view class="submit-box">
  50. <u-button @click="submit" type="success">确定</u-button>
  51. </view>
  52. <u-toast ref="toast" />
  53. </view>
  54. </template>
  55. <script>
  56. export default {
  57. data() {
  58. return {
  59. d_id:'',
  60. equipContrlForm1: {
  61. st: '', //时控开始时间
  62. et: '', //时控结束时间
  63. dat_f: 10 ,//数据上传时间间隔
  64. ds:'',//开关,1开机,0关机
  65. timctrl:''//时控开关 1开,0关
  66. },
  67. time:{
  68. time1:'',
  69. time2:''
  70. },
  71. ds_list:[{
  72. value:0,
  73. label:'关机'
  74. },{
  75. value:1,
  76. label:'开机'
  77. }
  78. ],
  79. ds_show:false,
  80. timctrl_list:[
  81. {
  82. value:0,
  83. label:'关'
  84. },{
  85. value:1,
  86. label:'开'
  87. }
  88. ],
  89. timctrl_show:false,
  90. timeList:[],
  91. timeShow:false,
  92. timeType:''
  93. }
  94. },
  95. onLoad(option){
  96. this.d_id=option.d_id
  97. this.equipSet()
  98. },
  99. methods: {
  100. //回显设备控制参数
  101. async equipSet(){
  102. let res=await this.$myRequest({
  103. url:'/api/api_gateway?method=forecast.send_control.device_control_info',
  104. data:{
  105. d_id:this.d_id,
  106. cmd: "paramconf"
  107. }
  108. })
  109. console.log(res)
  110. let obj = {
  111. st: res.work_tim.st,
  112. et: res.work_tim.et,
  113. timctrl: res.work_tim.timctrl,
  114. ds: res.power.ds,
  115. dat_f: res.data_tim.dat_f,
  116. };
  117. this.equipContrlForm1=obj
  118. this.time.time1= obj.st && obj.st < 10 ? "0" + obj.st + ":00" : obj.st + ":00";
  119. this.time.time2= obj.et && obj.et < 10 ? "0" + obj.et + ":00" : obj.et + ":00";
  120. },
  121. async equipBtnControl(cmd){
  122. let res=await this.$myRequest({
  123. url:'/api/api_gateway?method=forecast.send_control.admin_device_control',
  124. data:{
  125. cmd,
  126. device_type_id: 4,
  127. d_id: this.d_id
  128. }
  129. })
  130. if(res){
  131. this.$refs.toast.show({
  132. title: '指令下发成功!',
  133. type: 'success',
  134. })
  135. }
  136. },
  137. sliderChange(e){
  138. this.equipContrlForm1.dat_f=e.detail.value
  139. },
  140. selectTime(a){
  141. this.timeType=a
  142. if(this.timeList.length==0){
  143. let arr=[]
  144. for(let i=0;i<24;i++){
  145. let label=i<10?`0${i}:00`:`${i}:00`
  146. arr.push({
  147. value:i,
  148. label
  149. })
  150. }
  151. arr.unshift({
  152. value:'',
  153. label:'重置'
  154. })
  155. this.timeList=arr
  156. }
  157. this.timeShow=true
  158. },
  159. confirm(e,a){
  160. if(a=='ds'){
  161. this.equipContrlForm1.ds=e[0].value
  162. }else if(a=='timctrl'){
  163. this.equipContrlForm1.timctrl=e[0].value
  164. }
  165. },
  166. timeConfirm(e,a){
  167. if(a=='st'){
  168. this.time.time1=e[0].label
  169. this.equipContrlForm1.st=e[0].value
  170. }else{
  171. this.time.time2=e[0].label
  172. this.equipContrlForm1.et=e[0].value
  173. }
  174. },
  175. async submit(){
  176. console.log(this.equipContrlForm1)
  177. let obj = {
  178. work_tim: {
  179. timctrl: this.equipContrlForm1.timctrl,
  180. st: this.equipContrlForm1.st,
  181. et: this.equipContrlForm1.et ,
  182. },
  183. data_tim: { dat_f: this.equipContrlForm1.dat_f },
  184. power: { ds: this.equipContrlForm1.ds },
  185. };
  186. let res=await this.$myRequest({
  187. url:'/api/api_gateway?method=forecast.send_control.device_control',
  188. data:{
  189. device_type_id: 4,
  190. d_id: this.d_id,
  191. config: JSON.stringify(obj),
  192. }
  193. })
  194. if(res){
  195. this.$refs.toast.show({
  196. title: '修改成功!',
  197. type: 'success',
  198. callback:function(){
  199. uni.navigateBack({
  200. delta: 1
  201. });
  202. }
  203. })
  204. }
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss">
  210. page{
  211. padding:20rpx;
  212. .tit{
  213. line-height:30rpx;
  214. font-size:30rpx;
  215. padding-left:20rpx;
  216. border-left-width:2px;
  217. border-left-style: solid;
  218. border-left-color:$uni-color-success;
  219. margin:30rpx 0;
  220. }
  221. .adminTit{border-left-color:#e64340;}
  222. .btns{
  223. display:flex;
  224. justify-content: flex-start;
  225. flex-wrap:no-wrap;
  226. button{margin:0;margin-right:10rpx;padding:0 25rpx;}
  227. }
  228. .uni-list-cell{
  229. background:#F7F8FA;
  230. padding:10rpx 40rpx;
  231. font-size:28rpx;
  232. .arrow{
  233. display:inline-block;
  234. border-width:12rpx 8rpx ;
  235. border-style: solid;
  236. float:right;
  237. margin-top:10rpx;
  238. border-color:#888 transparent transparent transparent;
  239. }
  240. }
  241. .selectTime{
  242. display:flex;
  243. margin-bottom:20rpx;
  244. .time{
  245. width:350rpx;
  246. display:flex;
  247. justify-content: space-between;
  248. }
  249. .line{width:50rpx;text-align: center;}
  250. }
  251. .submit-box{
  252. margin-top:60rpx
  253. }
  254. }
  255. </style>