thxyset.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view>
  3. <view class="buttonbox" v-if="myuser_type">
  4. <button type="warn" @click="equipBtnControl('reboot')" size="mini">重启</button>
  5. <button type="warn" @click="equipBtnControl('update')" size="mini">升级</button>
  6. <button type="warn" @click="equipBtnControl('clearworm')" size="mini">清网</button>
  7. <button type="warn" @click="equipBtnControl('mqttconf')" size="mini">查询服务器配置</button>
  8. </view>
  9. <view class="setitem">
  10. 设备编号:{{option.device_id}}
  11. </view>
  12. <view class="setitem">
  13. 设备名称:{{option.device_name}}
  14. </view>
  15. <view class="setitem">
  16. 设备版本:{{option.dtype}}
  17. </view>
  18. <view class="setitem">
  19. 设备开关:
  20. <view class="uni-list-cell" style="margin-top: 30rpx;">
  21. <picker @change="turnChange($event,'ds')" value="equipContrlForm.ds" :range="dsArr">
  22. <text class="uni-input">{{dsArr[equipContrlForm.ds]}}</text>
  23. <view class="arrow"></view>
  24. </picker>
  25. </view>
  26. </view>
  27. <view class="setitem">
  28. 时控时长:
  29. <view class="selectTime">
  30. <view class="uni-list-cell time" @click="selectTime('st')">
  31. <text>{{stLabel}}</text>
  32. <u-icon name="clock"></u-icon>
  33. </view>
  34. <text class="line">-</text>
  35. <view class="uni-list-cell time" @click="selectTime('et')">
  36. <text>{{etLabel}}</text>
  37. <u-icon name="clock"></u-icon>
  38. </view>
  39. </view>
  40. <u-select v-model="stShow" mode="single-column" :list="list" @confirm="stConfirm"></u-select>
  41. <u-select v-model="etShow" mode="single-column" :list="list" @confirm="etConfirm"></u-select>
  42. </view>
  43. <view class="setitem">
  44. 数据频率(min):
  45. <slider :value="equipContrlForm.dat_f" show-value="true" :min="10" :max="60"
  46. @change="sliderChange($event,'dat_f')" block-color="#57C878" activeColor="#57C878" step="1" />
  47. </view>
  48. <view class="setitem">
  49. 自清虫定时(min):
  50. <slider :value="equipContrlForm.clt_t" show-value="true" :min="10" :max="60"
  51. @change="sliderChange($event,'clt_t')" block-color="#57C878" activeColor="#57C878" step="1" />
  52. </view>
  53. <view class="submit-box">
  54. <u-button @click="submit" type="success">确定</u-button>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. myuser_type:false,
  63. option: {},
  64. dsArr: ['关机', '开机'],
  65. equipContrlForm: {
  66. ds: 0,
  67. dat_f: 0,
  68. clt_t: 0,
  69. st: "",
  70. et: "",
  71. timctrl: ""
  72. },
  73. stLabel: "",
  74. etLabel: "",
  75. stShow: false,
  76. etShow: false,
  77. list: [{
  78. value: 0,
  79. label: '00:00'
  80. },
  81. {
  82. value: 1,
  83. label: '01:00'
  84. },
  85. {
  86. value: 2,
  87. label: '02:00'
  88. },
  89. {
  90. value: 3,
  91. label: '03:00'
  92. },
  93. {
  94. value: 4,
  95. label: '04:00'
  96. },
  97. {
  98. value: 5,
  99. label: '05:00'
  100. },
  101. {
  102. value: 6,
  103. label: '06:00'
  104. },
  105. {
  106. value: 7,
  107. label: '04:00'
  108. }, {
  109. value: 8,
  110. label: '08:00'
  111. },
  112. {
  113. value: 9,
  114. label: '09:00'
  115. },
  116. {
  117. value: 10,
  118. label: '10:00'
  119. },
  120. {
  121. value: 11,
  122. label: '11:00'
  123. },
  124. {
  125. value: 12,
  126. label: '12:00'
  127. },
  128. {
  129. value: 13,
  130. label: '13:00'
  131. },
  132. {
  133. value: 14,
  134. label: '14:00'
  135. }, {
  136. value: 15,
  137. label: '15:00'
  138. },
  139. {
  140. value: 16,
  141. label: '16:00'
  142. },
  143. {
  144. value: 17,
  145. label: '17:00'
  146. },
  147. {
  148. value: 18,
  149. label: '18:00'
  150. },
  151. {
  152. value: 19,
  153. label: '19:00'
  154. },
  155. {
  156. value: 20,
  157. label: '20:00'
  158. },
  159. {
  160. value: 21,
  161. label: '21:00'
  162. }, {
  163. value: 22,
  164. label: '22:00'
  165. },
  166. {
  167. value: 23,
  168. label: '23:00'
  169. },
  170. ],
  171. }
  172. },
  173. methods: {
  174. turnChange(e) {
  175. this.equipContrlForm.ds = e.target.value
  176. },
  177. selectTime(a) {
  178. if (a == 'st') {
  179. this.stShow = true;
  180. } else {
  181. this.etShow = true;
  182. }
  183. },
  184. stConfirm(e) {
  185. this.stLabel = e[0].label
  186. this.equipContrlForm.st = e[0].value
  187. },
  188. etConfirm(e) {
  189. this.etLabel = e[0].label
  190. this.equipContrlForm.et = e[0].value
  191. },
  192. async getconf() {
  193. const res = await this.$myRequest({
  194. url: '/api/api_gateway?method=forecast.send_control.device_control_info',
  195. data: {
  196. cmd: "paramconf",
  197. d_id: this.option.d_id
  198. }
  199. })
  200. console.log(res)
  201. this.equipContrlForm.et = res.work_tim.et
  202. this.equipContrlForm.st = res.work_tim.st
  203. this.equipContrlForm.timctrl = res.work_tim.timctrl
  204. this.etLabel = this.list[res.work_tim.et].label
  205. this.stLabel = this.list[res.work_tim.st].label
  206. this.equipContrlForm.dat_f = res.data_tim.dat_f
  207. this.equipContrlForm.clt_t = res.clt_tim.clt_t
  208. this.equipContrlForm.ds = res.power.ds
  209. },
  210. sliderChange(e, a) {
  211. console.log(e)
  212. if (a == "dat_f") {
  213. this.equipContrlForm.dat_f = e.detail.value
  214. } else {
  215. this.equipContrlForm.clt_t = e.detail.value
  216. }
  217. },
  218. async submit() {
  219. var obj = {
  220. work_tim: {
  221. timctrl: this.equipContrlForm.timctrl,
  222. st: this.equipContrlForm.st,
  223. et: this.equipContrlForm.et
  224. },
  225. data_tim: {
  226. dat_f: this.equipContrlForm.dat_f
  227. },
  228. power: {
  229. ds: this.equipContrlForm.ds
  230. },
  231. clt_tim: {
  232. clt_t: this.equipContrlForm.clt_t
  233. },
  234. }
  235. console.log(obj)
  236. const res = await this.$myRequest({
  237. url: '/api/api_gateway?method=forecast.send_control.device_control',
  238. data: {
  239. device_type_id: 8,
  240. d_id: this.option.d_id,
  241. config: JSON.stringify(obj),
  242. }
  243. })
  244. console.log(res)
  245. if (res == true) {
  246. uni.showToast({
  247. title: '指令下发成功!',
  248. duration: 2000
  249. });
  250. } else {
  251. uni.showToast({
  252. title: '指令下发失败!',
  253. duration: 2000,
  254. icon: "none"
  255. });
  256. }
  257. },
  258. async equipBtnControl(cmd) {
  259. const res = await this.$myRequest({
  260. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  261. data: {
  262. cmd,
  263. device_type_id: 8,
  264. d_id: this.option.d_id,
  265. }
  266. })
  267. console.log(res)
  268. if (res == true) {
  269. uni.showToast({
  270. title: '指令下发成功!',
  271. duration: 2000
  272. });
  273. } else {
  274. uni.showToast({
  275. title: '指令下发失败!',
  276. duration: 2000,
  277. icon: "none"
  278. });
  279. }
  280. }
  281. },
  282. onLoad(option) {
  283. uni.getStorage({
  284. key:"myuser_type",
  285. success:(res)=>{
  286. console.log(res.data)
  287. if(Number(res.data) == 1){
  288. this.myuser_type = true
  289. }
  290. }
  291. })
  292. this.option = option
  293. this.getconf()
  294. }
  295. }
  296. </script>
  297. <style lang='less'>
  298. page {
  299. padding: 20rpx;
  300. box-sizing: border-box;
  301. .buttonbox {
  302. display: flex;
  303. justify-content: space-between;
  304. }
  305. .setitem {
  306. margin-top: 30rpx;
  307. .selectTime {
  308. margin-top: 30rpx;
  309. display: flex;
  310. .time {
  311. width: 350rpx;
  312. display: flex;
  313. justify-content: space-between;
  314. }
  315. .line {
  316. width: 50rpx;
  317. text-align: center;
  318. }
  319. }
  320. }
  321. .uni-list-cell {
  322. background: #F7F8FA;
  323. padding: 10rpx 40rpx;
  324. font-size: 28rpx;
  325. box-sizing: border-box;
  326. /* margin-top: 30rpx; */
  327. .arrow {
  328. display: inline-block;
  329. border-width: 12rpx 8rpx;
  330. border-style: solid;
  331. float: right;
  332. margin-top: 10rpx;
  333. border-color: #888 transparent transparent transparent;
  334. }
  335. }
  336. .submit-box {
  337. margin-top: 60rpx
  338. }
  339. }
  340. </style>