equip-set.vue 13 KB

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