equip-set.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <view>
  3. <view class="tit adminTit">
  4. 操作
  5. </view>
  6. <view class="btns">
  7. <button type="warn" @click="equipBtnControl('dtu_update')" size="mini">升级</button>
  8. <button type="warn" @click="equipBtnControl('dtu_reboot')" size="mini">重启</button>
  9. <button type="warn" @click="equipBtnControl('dtu_reboot')" size="mini">立即拍照</button>
  10. <button type="warn" @click="equipBtnControl('dtu_reboot')" size="mini">对焦拍照</button>
  11. <button type="warn" @click="equipBtnControl('dtu_reboot')" size="mini">转仓</button>
  12. </view>
  13. <view class="tit adminTit">
  14. 设备开关
  15. </view>
  16. <view class="uni-list-cell" @click="on_off_show=true">
  17. <text class="uni-input">{{on_off=="0"?'关闭':'开机'}}</text>
  18. <view class="arrow"></view>
  19. <u-select v-model="on_off_show" mode="single-column" :list="on_off_list" @confirm="confirm($event,'on_off')"></u-select>
  20. </view>
  21. <view class="tit">
  22. 载玻片滴液时间
  23. </view>
  24. <view class="uni-list-cell" @click="selectFun('drop_time')">
  25. <text class="uni-input">{{setFrom.drop_time}}</text>
  26. <view class="arrow"></view>
  27. <u-select v-model="drop_time_show" mode="single-column" :list="drop_time_List" @confirm="confirm($event,'drop')"></u-select>
  28. </view>
  29. <view class="tit">
  30. 孢子培养时间(h)
  31. </view>
  32. <view class="">
  33. <slider :value="setFrom.cul_time" show-value="true" :min="1" :max="24" @change="sliderChange($event,'cul_time')" block-color="#57C878" activeColor="#57C878" step="1" />
  34. </view>
  35. <view class="tit">
  36. 保温仓设定温度(℃)
  37. </view>
  38. <view class="">
  39. <slider :value="setFrom.set_temp" show-value="true" :min="10" :max="40" @change="sliderChange($event,'set_temp')" block-color="#57C878" activeColor="#57C878" step="1" />
  40. </view>
  41. <view class="tit">
  42. 数据上传时间间隔(min)
  43. </view>
  44. <view class="">
  45. <slider :value="setFrom.datt" show-value="true" :min="10" :max="60" @change="sliderChange($event,'datt')" block-color="#57C878" activeColor="#57C878" step="1" />
  46. </view>
  47. <view class="tit">
  48. 采集开启和关闭时间
  49. </view>
  50. <view class="selectTime">
  51. <view class="uni-list-cell time" @click="selectTime('st1')">
  52. <text>{{coll_time.time01||'开始时间'}}</text>
  53. <u-icon name="clock"></u-icon>
  54. </view>
  55. <text class="line">-</text>
  56. <view class="uni-list-cell time" @click="selectTime('et1')">
  57. <text>{{coll_time.time02||'结束时间'}}</text>
  58. <u-icon name="clock"></u-icon>
  59. </view>
  60. </view>
  61. <view class="selectTime">
  62. <view class="uni-list-cell time" @click="selectTime('st2')">
  63. <text>{{coll_time.time03||'开始时间'}}</text>
  64. <u-icon name="clock"></u-icon>
  65. </view>
  66. <text class="line">-</text>
  67. <view class="uni-list-cell time" @click="selectTime('et2')">
  68. <text>{{coll_time.time04||'开始时间'}}</text>
  69. <u-icon name="clock"></u-icon>
  70. </view>
  71. </view>
  72. <view class="selectTime">
  73. <view class="uni-list-cell time" @click="selectTime('st3')">
  74. <text>{{coll_time.time05||'开始时间'}}</text>
  75. <u-icon name="clock"></u-icon>
  76. </view>
  77. <text class="line">-</text>
  78. <view class="uni-list-cell time" @click="selectTime('et3')">
  79. <text>{{coll_time.time06||'开始时间'}}</text>
  80. <u-icon name="clock"></u-icon>
  81. </view>
  82. </view>
  83. <view class="submit-box">
  84. <u-button @click="submit" type="success">确定</u-button>
  85. </view>
  86. <u-select v-model="collShow" mode="single-column" :list="timeList" @confirm="collConfirm($event,timeType)"></u-select>
  87. <u-toast ref="toast" />
  88. </view>
  89. </template>
  90. <script>
  91. export default {
  92. data() {
  93. return {
  94. d_id:'',
  95. on_off_show:false,
  96. on_off:null,//设备开关
  97. on_off_list:[{
  98. value:0,
  99. label:'关闭'
  100. },{
  101. value:1,
  102. label:'开机'
  103. }],
  104. drop_time_show:false,
  105. drop_time_List:[],
  106. setFrom: {
  107. drop_time: "1", //载玻片滴液时间
  108. cul_time: 1, //孢子培养时间
  109. set_temp: 10, //保温仓设定温度
  110. datt: 10, //数据上传时间间隔(h)-m
  111. coll_time: [], //采集开启和关闭时间
  112. },
  113. coll_time: {
  114. time01: "",
  115. time02: "",
  116. time03: "",
  117. time04: "",
  118. time05: "",
  119. time06: "",
  120. value01: "",
  121. value02: "",
  122. value03: "",
  123. value04: "",
  124. value05: "",
  125. value06: "",
  126. },
  127. timeList:[] ,
  128. collShow:false,
  129. timeType:''
  130. }
  131. },
  132. onLoad(option){
  133. this.d_id=option.d_id
  134. this.equipOperation()
  135. this.equipSet()
  136. },
  137. methods: {
  138. //回显设备控制参数
  139. async equipSet(){
  140. let res=await this.$myRequest({
  141. url:'/api/api_gateway?method=forecast.send_control.device_control_info',
  142. data:{
  143. d_id:this.d_id,
  144. cmd: "paramconf"
  145. }
  146. })
  147. this.setFrom.drop_time=res.drop_time
  148. this.setFrom.cul_time=res.cul_time
  149. this.setFrom.set_temp=res.set_temp
  150. this.setFrom.datt=res.datt
  151. let coll_time=res.coll_time
  152. for (let i in coll_time) {
  153. if (i == 0) {
  154. let arr = coll_time[i].split("-");
  155. this.coll_time.time01 =
  156. Number(arr[0]) < 10 ? "0" + arr[0] + ":00" : arr[0] + ":00";
  157. this.coll_time.time02 =
  158. Number(arr[1]) < 10 ? "0" + arr[1] + ":00" : arr[1] + ":00";
  159. this.coll_time.value01=Number(arr[0])
  160. this.coll_time.value02=Number(arr[1])
  161. } else if (i == 1) {
  162. let arr = coll_time[i].split("-");
  163. this.coll_time.time03 =
  164. Number(arr[0]) < 10 ? "0" + arr[0] + ":00" : arr[0] + ":00";
  165. this.coll_time.time04 =
  166. Number(arr[1]) < 10 ? "0" + arr[1] + ":00" : arr[1] + ":00";
  167. this.coll_time.value03=Number(arr[0])
  168. this.coll_time.value04=Number(arr[1])
  169. } else if (i == 2) {
  170. let arr = coll_time[i].split("-");
  171. this.coll_time.time05 =
  172. Number(arr[0]) < 10 ? "0" + arr[0] + ":00" : arr[0] + ":00";
  173. this.coll_time.time06 =
  174. Number(arr[1]) < 10 ? "0" + arr[1] + ":00" : arr[1] + ":00";
  175. this.coll_time.value05=Number(arr[0])
  176. this.coll_time.value06=Number(arr[1])
  177. }
  178. }
  179. console.log(this.setFrom)
  180. },
  181. //回显设备开关状态
  182. async equipOperation(){
  183. let res=await this.$myRequest({
  184. url:'/api/api_gateway?method=forecast.worm_lamp.bzy_device',
  185. data:{
  186. d_id: this.d_id
  187. }
  188. })
  189. this.on_off=res.on_off
  190. },
  191. //管理员操作
  192. async equipBtnControl(cmd){
  193. let res=await this.$myRequest({
  194. url:'/api/api_gateway?method=forecast.send_control.admin_device_control',
  195. data:{
  196. cmd,
  197. device_type_id: 7,
  198. d_id: this.d_id
  199. }
  200. })
  201. if(res){
  202. this.$refs.toast.show({
  203. title: '指令下发成功!',
  204. type: 'success',
  205. })
  206. }
  207. },
  208. confirm(e,a){
  209. switch(a){
  210. case "on_off":
  211. if(e[0].value){
  212. this.equipControl("poweron",e[0].value);
  213. }else{
  214. this.equipControl("poweroff",e[0].value);
  215. }
  216. break;
  217. case "drop":
  218. this.setFrom.drop_time=e[0].value;
  219. break;
  220. }
  221. },
  222. async equipControl(cmd,val){
  223. let res=await this.$myRequest({
  224. url:'/api/api_gateway?method=forecast.send_control.admin_device_control',
  225. data:{
  226. cmd,
  227. device_type_id: 7,
  228. d_id: this.d_id
  229. }
  230. })
  231. this.on_off=val;
  232. },
  233. selectFun(a){
  234. switch(a){
  235. case 'drop_time':
  236. for(let i=1;i<31;i++){
  237. this.drop_time_List.push({
  238. value:i,
  239. label:i
  240. })
  241. }
  242. this.drop_time_show=true;
  243. }
  244. },
  245. sliderChange(e,a){
  246. switch(a){
  247. case 'cul_time':
  248. this.setFrom.cul_time=e.detail.value;
  249. break;
  250. case 'set_temp':
  251. this.setFrom.set_temp=e.detail.value;
  252. break;
  253. case 'datt':
  254. this.setFrom.datt=e.detail.value;
  255. break;
  256. }
  257. },
  258. selectTime(a){
  259. this.timeType=a
  260. let arr=[]
  261. if(a=='st1'){
  262. for(let i=1;i<25;i++){
  263. let label=i<10?`0${i}:00`:`${i}:00`
  264. arr.push({
  265. value:i,
  266. label
  267. })
  268. }
  269. this.timeList=arr
  270. }else if(a=='et1'){
  271. for(let i=this.coll_time.value01+1;i<25;i++){
  272. let label=i<10?`0${i}:00`:`${i}:00`
  273. arr.push({
  274. value:i,
  275. label
  276. })
  277. }
  278. this.timeList=arr
  279. }else if(a=='st2'){
  280. for(let i=this.coll_time.value02+1;i<25;i++){
  281. let label=i<10?`0${i}:00`:`${i}:00`
  282. arr.push({
  283. value:i,
  284. label
  285. })
  286. }
  287. this.timeList=arr
  288. }else if(a=='et2'){
  289. for(let i=this.coll_time.value03+1;i<25;i++){
  290. let label=i<10?`0${i}:00`:`${i}:00`
  291. arr.push({
  292. value:i,
  293. label
  294. })
  295. }
  296. this.timeList=arr
  297. }else if(a=='st3'){
  298. for(let i=this.coll_time.value04+1;i<25;i++){
  299. let label=i<10?`0${i}:00`:`${i}:00`
  300. arr.push({
  301. value:i,
  302. label
  303. })
  304. }
  305. this.timeList=arr
  306. }else if(a=='et3'){
  307. for(let i=this.coll_time.value05+1;i<25;i++){
  308. let label=i<10?`0${i}:00`:`${i}:00`
  309. arr.push({
  310. value:i,
  311. label
  312. })
  313. }
  314. this.timeList=arr
  315. }
  316. this.collShow=true
  317. },
  318. collConfirm(e,a){
  319. if(a=='st1'){
  320. this.coll_time.time01=e[0].label
  321. this.coll_time.value01=e[0].value
  322. }else if(a=='et1'){
  323. this.coll_time.time02=e[0].label
  324. this.coll_time.value02=e[0].value
  325. }else if(a=='st2'){
  326. this.coll_time.time03=e[0].label
  327. this.coll_time.value03=e[0].value
  328. }else if(a=='et2'){
  329. this.coll_time.time04=e[0].label
  330. this.coll_time.value04=e[0].value
  331. }else if(a=='st3'){
  332. this.coll_time.time05=e[0].label
  333. this.coll_time.value05=e[0].value
  334. }else if(a=='et3'){
  335. this.coll_time.time06=e[0].label
  336. this.coll_time.value06=e[0].value
  337. }
  338. },
  339. async submit(){
  340. let arr=[]
  341. if(this.coll_time.value01&&this.coll_time.value02){
  342. arr.push(`${this.coll_time.value01}-${this.coll_time.value02}`)
  343. }
  344. if(this.coll_time.value03&&this.coll_time.value04){
  345. arr.push(`${this.coll_time.value03}-${this.coll_time.value04}`)
  346. }
  347. if(this.coll_time.value05&&this.coll_time.value06){
  348. arr.push(`${this.coll_time.value05}-${this.coll_time.value06}`)
  349. }
  350. this.setFrom.coll_time=arr
  351. console.log(this.setFrom)
  352. let res=await this.$myRequest({
  353. url:'/api/api_gateway?method=forecast.send_control.device_control',
  354. data:{
  355. device_type_id: 7,
  356. d_id: this.d_id,
  357. config: JSON.stringify(this.setFrom),
  358. }
  359. })
  360. if(res){
  361. this.$refs.toast.show({
  362. title: '修改成功!',
  363. type: 'success',
  364. callback:function(){
  365. uni.navigateBack({
  366. delta: 1
  367. });
  368. }
  369. })
  370. }
  371. }
  372. }
  373. }
  374. </script>
  375. <style lang="scss">
  376. page{padding:20rpx;
  377. .tit{
  378. line-height:30rpx;
  379. font-size:30rpx;
  380. padding-left:20rpx;
  381. border-left-width:2px;
  382. border-left-style: solid;
  383. border-left-color:$uni-color-success;
  384. margin:30rpx 0;
  385. }
  386. .adminTit{border-left-color:#e64340;}
  387. .btns{
  388. display:flex;
  389. justify-content: flex-start;
  390. flex-wrap:no-wrap;
  391. button{margin:0;margin-right:10rpx;padding:0 25rpx;}
  392. }
  393. .uni-list-cell{
  394. background:#F7F8FA;
  395. padding:10rpx 40rpx;
  396. font-size:28rpx;
  397. .arrow{
  398. display:inline-block;
  399. border-width:12rpx 8rpx ;
  400. border-style: solid;
  401. float:right;
  402. margin-top:10rpx;
  403. border-color:#888 transparent transparent transparent;
  404. }
  405. }
  406. .selectTime{
  407. display:flex;
  408. margin-bottom:20rpx;
  409. .time{
  410. width:350rpx;
  411. display:flex;
  412. justify-content: space-between;
  413. }
  414. .line{width:50rpx;text-align: center;}
  415. }
  416. .submit-box{
  417. margin-top:60rpx
  418. }
  419. }
  420. </style>