equip-set.vue 12 KB

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