equip-set-new.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. <template>
  2. <view style="padding: 0 24rpx;">
  3. <view class="" v-if="myuser_type">
  4. <view class="tit adminTit">
  5. 联网模块
  6. </view>
  7. <view class="btns">
  8. <button v-for="(item,index) in controlInfo.netControl" type="warn" @click="equipBtnControl(item.cmd)" size="mini">{{item.name}}</button>
  9. </view>
  10. <view class="tit adminTit">
  11. 强制操作
  12. </view>
  13. <view class="btns">
  14. <button v-for="(item,index) in controlInfo.forceControl" type="warn" @click="equipBtnControl(item.cmd)" size="mini">{{item.name}}</button>
  15. </view>
  16. <view class="tit adminTit">
  17. 设备操作
  18. </view>
  19. <view class="btns">
  20. <button v-for="(item,index) in controlInfo.equipControl" type="warn" @click="equipBtnControl(item.cmd)" size="mini">{{item.name}}</button>
  21. </view>
  22. </view>
  23. <view style="margin:40rpx 0 20rpx 0;">
  24. <u-line color="#E5EBE9" />
  25. </view>
  26. <!-- <view class="">
  27. <view class="tit">
  28. IMEI:{{equipContrlForm.imei}}
  29. </view>
  30. <view class="tit">
  31. 设备ID:{{device_id}}
  32. </view>
  33. <view class="tit">
  34. 设备版本:{{equipContrlForm.version}}
  35. </view>
  36. </view> -->
  37. <view class="uni-list-cell" v-if="device_type==32" @click="modeShow = true">
  38. <span class="tit">定时模式</span>
  39. <view class="right-data" style="float: right;">
  40. <span>{{tsArrLabel}}</span>
  41. <u-icon class="arrow" name="arrow-right"></u-icon>
  42. </view>
  43. </view>
  44. <!-- <view class="uni-list-cell" v-if="device_type==33||device_type==34" @click="syModeShow = true">
  45. <span class="tit">控制模式</span>
  46. <view class="right-data" style="float: right;">
  47. <span>{{tsArrLabel}}</span>
  48. <u-icon class="arrow" name="arrow-right"></u-icon>
  49. </view>
  50. </view> -->
  51. <!-- <view class="uni-list-cell" @click="shikongshow = true" v-if="equipContrlForm.CONTROL==0">
  52. <span class="tit">
  53. 时控时长
  54. </span>
  55. <view class="right-data" style="float: right;">
  56. <span>{{shikongLabel}}</span>
  57. <u-icon class="arrow" name="arrow-right"></u-icon>
  58. </view>
  59. </view> -->
  60. <!-- <view class="uni-list-cell" @click="gkongShow = true" v-if="equipContrlForm.CONTROL==1">
  61. <span class="tit">
  62. 光控时长
  63. </span>
  64. <view class="right-data" style="float: right;">
  65. <span>{{gkongLabel}}</span>
  66. <u-icon class="arrow" name="arrow-right"></u-icon>
  67. </view>
  68. </view> -->
  69. <view class="uni-list-cell" @click="shikongshow = true" v-if="device_type==33||device_type==34">
  70. <span class="tit">
  71. 拍照时间
  72. </span>
  73. <view class="right-data" style="float: right;">
  74. <span>{{shikongLabel}}</span>
  75. <u-icon class="arrow" name="arrow-right"></u-icon>
  76. </view>
  77. </view>
  78. <view class="uni-list-cell" v-if="device_type==33||device_type==34" @click="selectOperate(5,1440,'PHO_T')">
  79. <span class="tit">
  80. 拍照频率(min)
  81. </span>
  82. <view class="right-data" style="float: right;">
  83. <span>{{equipContrlForm.PHO_T}}</span>
  84. <u-icon class="arrow" name="arrow-right"></u-icon>
  85. </view>
  86. </view>
  87. <view class="uni-list-cell" @click="selectOperate(5,device_type==32?60:1440,'DATT')">
  88. <span class="tit">
  89. 数据上传频率(min)
  90. </span>
  91. <view class="right-data" style="float: right;">
  92. <span>{{equipContrlForm.DATT}}</span>
  93. <u-icon class="arrow" name="arrow-right"></u-icon>
  94. </view>
  95. </view>
  96. <view v-if="device_type==32" class="uni-list-cell" @click="selectOperate(5,180,'PHO_T')">
  97. <span class="tit">
  98. 照片上传频率(min)
  99. </span>
  100. <view class="right-data" style="float: right;">
  101. <span>{{equipContrlForm.PHO_T}}</span>
  102. <u-icon class="arrow" name="arrow-right"></u-icon>
  103. </view>
  104. </view>
  105. <view class="uni-list-cell" v-if="device_type==34" >
  106. <span class="tit">
  107. 是否温控
  108. </span>
  109. <view class="right-data" style="width:50px;height: 100%; float: right;display: flex;align-items: center;">
  110. <u-switch style="margin-top: 5px;" color="#57C878" v-model="equipContrlForm.TEMP_LIMIT" size="40"></u-switch>
  111. <!-- <u-icon class="arrow" name="arrow-right"></u-icon> -->
  112. </view>
  113. </view>
  114. <view class="uni-list-cell" v-if="device_type==34 && equipContrlForm.TEMP_LIMIT" >
  115. <span class="tit">
  116. 低温设置
  117. </span>
  118. <view class="right-data" style="float: right;width: 70%;">
  119. <slider style="margin: 0;" :block-size='20' :value="equipContrlForm.TEMP_DOWN" show-value="true" :min="0" :max="20" @change="sliderChange($event,'down')" block-color="#57C878" activeColor="#57C878" step="1" />
  120. </view>
  121. </view>
  122. <view class="uni-list-cell" v-if="device_type==34 && equipContrlForm.TEMP_LIMIT" >
  123. <span class="tit">
  124. 高温设置
  125. </span>
  126. <view class="right-data" style="float: right;width: 70%;">
  127. <slider style="margin: 0;" :block-size='20' :value="equipContrlForm.TEMP_UP" show-value="true" :min="50" :max="80" @change="sliderChange($event,'up')" block-color="#57C878" activeColor="#57C878" step="1" />
  128. <!-- <u-icon class="arrow" name="arrow-right"></u-icon> -->
  129. </view>
  130. </view>
  131. <view >
  132. <u-select v-model="modeShow" :list="tsArr" @confirm="tsArrConfirm"></u-select>
  133. <u-select v-model="syModeShow" :list="syArr" @confirm="tsArrConfirm"></u-select>
  134. <u-select v-model="shikongshow" mode="mutil-column" :list="shikonglist" @confirm="shikongconfirm"></u-select>
  135. <u-select v-model="photoShow" mode="mutil-column" :list="shikonglist" @confirm="photoConfirm"></u-select>
  136. <u-select v-model="gkongShow" :list="gkongArr" @confirm="gkArrConfirm"></u-select>
  137. <u-select v-model="dataSelectShow" :list="singleSelectList" @confirm="dataconfirm"></u-select>
  138. </view>
  139. <view class="submit-box">
  140. <u-button :custom-style="customStyle" @click="submit" :disabled="submitBtnDisabled" >确定</u-button>
  141. </view>
  142. <u-toast ref="toast" />
  143. <u-popup v-model="mqttShow">
  144. <view class="mqtt-popup">
  145. <u-field required v-model="mqttConfig.muid" label="MQTT用户名" label-width="180">
  146. </u-field>
  147. <u-field required v-model="mqttConfig.mpwd" label="MQTT密码" label-width="180">
  148. </u-field>
  149. <u-field required v-model="mqttConfig.mpi" label="MQTT地址" label-width="180">
  150. </u-field>
  151. <u-field required v-model="mqttConfig.mport" label="MQTT端口" label-width="180">
  152. </u-field>
  153. <u-field required v-model="mqttConfig.mpub" label="上传地址" label-width="180">
  154. </u-field>
  155. <u-field required v-model="mqttConfig.msub" label="下发地址" label-width="180">
  156. </u-field>
  157. <u-field v-model="mqttConfig.fuid" label="FTP用户名" label-width="180">
  158. </u-field>
  159. <u-field v-model="mqttConfig.fpwd" label="FTP密码" label-width="180">
  160. </u-field>
  161. <u-field required v-model="mqttConfig.fip" label="图片上传地址" label-width="180">
  162. </u-field>
  163. <u-field required v-model="mqttConfig.fport" label="图片上传接口" label-width="180">
  164. </u-field>
  165. </view>
  166. <view class="mqtt-btn-box">
  167. <u-button @click="" size="medium" type="success">确定</u-button>
  168. </view>
  169. </u-popup>
  170. </view>
  171. </template>
  172. <script>
  173. export default {
  174. data() {
  175. return {
  176. d_id: '',
  177. device_id:'',
  178. device_type:'',
  179. dsArr: ['关机', '开机'],
  180. dsIndex: 0,
  181. wsArr: ['待机', '工作'],
  182. wsIndex: 0,
  183. tsArr: [
  184. { value: 1, label: '时控触发' },
  185. { value: 0, label: '时控模式' },
  186. ],
  187. syArr:[
  188. { value: 1, label: '光控模式' },
  189. { value: 0, label: '时控模式' }
  190. ],
  191. tsIndex: 0,
  192. imgresArr: ['高', '中', '低'],
  193. imgresIndex: "",
  194. wsModelShow: false,
  195. equipContrlForm: {
  196. END_TIME: '',
  197. // CONTROL: 0,
  198. DATT: 5,
  199. START_TIME: '',
  200. PHO_T: 5,
  201. P_DATT:1,
  202. TT: '',
  203. P_START:'',
  204. P_END:'',
  205. TEMP_LIMIT:false,
  206. TEMP_UP: 50,
  207. TEMP_DOWN: 0
  208. },
  209. shikongLabel:'00:00-00:00',
  210. list: [{
  211. value: '00:00',
  212. label: '00:00'
  213. },
  214. {
  215. value: '01:00',
  216. label: '01:00'
  217. },
  218. {
  219. value: '02:00',
  220. label: '02:00'
  221. },
  222. {
  223. value: '03:00',
  224. label: '03:00'
  225. },
  226. {
  227. value: '04:00',
  228. label: '04:00'
  229. },
  230. {
  231. value: '05:00',
  232. label: '05:00'
  233. },
  234. {
  235. value: '06:00',
  236. label: '06:00'
  237. },
  238. {
  239. value: '07:00',
  240. label: '07:00'
  241. }, {
  242. value: '08:00',
  243. label: '08:00'
  244. },
  245. {
  246. value: '09:00',
  247. label: '09:00'
  248. },
  249. {
  250. value: '10:00',
  251. label: '10:00'
  252. },
  253. {
  254. value: '11:00',
  255. label: '11:00'
  256. },
  257. {
  258. value:'12:00',
  259. label: '12:00'
  260. },
  261. {
  262. value: '13:00',
  263. label: '13:00'
  264. },
  265. {
  266. value: '14:00',
  267. label: '14:00'
  268. }, {
  269. value: '15:00',
  270. label: '15:00'
  271. },
  272. {
  273. value: '16:00',
  274. label: '16:00'
  275. },
  276. {
  277. value: '17:00',
  278. label: '17:00'
  279. },
  280. {
  281. value: '18:00',
  282. label: '18:00'
  283. },
  284. {
  285. value: '19:00',
  286. label: '19:00'
  287. },
  288. {
  289. value: '20:00',
  290. label: '20:00'
  291. },
  292. {
  293. value: '21:00',
  294. label: '21:00'
  295. }, {
  296. value: '22:00',
  297. label: '22:00'
  298. },
  299. {
  300. value: '23:00',
  301. label: '23:00'
  302. },
  303. ],
  304. mqttShow: false,
  305. shikongshow:false,
  306. gkongLabel:'0h',
  307. gkongShow:false,
  308. mqttConfig: {
  309. muid: '',
  310. mpwd: '',
  311. mip: '',
  312. mport: '',
  313. mpub: '',
  314. msub: '',
  315. fuid: '',
  316. fpwd: '',
  317. fip: '',
  318. fport: ''
  319. },
  320. myuser_type: false,
  321. singleSelectList:[],
  322. dataSelectShow:false,
  323. currentFormKey:'',
  324. tsArrLabel:'时控模式',
  325. modeShow:false,
  326. syModeShow:false,
  327. submitBtnDisabled:false,
  328. photoShow:false,
  329. photoLabel:'00:00-00:00'
  330. }
  331. },
  332. computed:{
  333. gkongArr(){
  334. const list = []
  335. const count = 24
  336. for (let i = 0; i < count; i++) {
  337. list.push({
  338. value: i + 1 + '',
  339. label: i + 1 + 'h'
  340. })
  341. }
  342. return list
  343. },
  344. customStyle(){
  345. return {
  346. background: '#14A478',
  347. borderRadius:'90rpx',
  348. border:'none',
  349. color:'#fff'
  350. }
  351. },
  352. shikonglist(){
  353. return[
  354. [...this.list],
  355. [...this.list]
  356. ]
  357. },
  358. controlInfo(){
  359. const netControl = [{
  360. name: '数据单元重启',
  361. cmd: 'dtu_reboot'
  362. },
  363. {
  364. name: '数据单元升级',
  365. cmd: 'dtu_update'
  366. }]
  367. const forceControl = [
  368. {
  369. name: '控制单元重启',
  370. cmd: 'reboot'
  371. },
  372. {
  373. name: '控制单元升级',
  374. cmd: 'update'
  375. }
  376. ]
  377. const equipControl = [
  378. {
  379. name: '开启补光灯',
  380. cmd: 'led_on'
  381. },
  382. {
  383. name: '关闭补光灯',
  384. cmd: 'led_off'
  385. },
  386. {
  387. name: '测试拍照',
  388. cmd: 'takephoto'
  389. },
  390. {
  391. name: '翻版测试',
  392. cmd: 'FB_Test'
  393. }
  394. ]
  395. switch (this.device_type){
  396. case 32://天牛
  397. break;
  398. case 33:
  399. break;
  400. case 34:
  401. break;
  402. case 35:
  403. break;
  404. default:
  405. break;
  406. }
  407. return {
  408. netControl,forceControl,equipControl
  409. }
  410. }
  411. },
  412. onLoad(option) {
  413. this.d_id = option.d_id
  414. this.device_id = option.device_id
  415. this.device_type = option.device_type
  416. this.getInfo()
  417. uni.getStorage({
  418. key: "myuser_type",
  419. success: (res) => {
  420. if (Number(res.data) == 1) {
  421. this.myuser_type = true
  422. }
  423. }
  424. })
  425. },
  426. methods: {
  427. sliderChange(e,a){
  428. let val=e.detail.value
  429. switch(a){
  430. case 'up':
  431. this.equipContrlForm.TEMP_UP=val;
  432. break;
  433. case 'down':
  434. this.equipContrlForm.TEMP_DOWN=val;
  435. break;
  436. }
  437. },
  438. selectOperate(min,max,formKey){
  439. this.dataSelectShow = true
  440. this.singleSelectList = []
  441. for (let i = min; i < max; i+=5) {
  442. this.singleSelectList.push({
  443. value:i,
  444. label:i.toString()
  445. })
  446. }
  447. console.log(this.singleSelectList,'--')
  448. this.currentFormKey = formKey
  449. },
  450. tsArrConfirm(e){
  451. this.tsArrLabel = e[0].label
  452. // this.equipContrlForm.CONTROL = e[0].value
  453. },
  454. gkArrConfirm(e){
  455. this.gkongLabel = e[0].label
  456. this.equipContrlForm.TT = e[0].value
  457. },
  458. dataconfirm(e){
  459. this.equipContrlForm[this.currentFormKey] = e[0].value
  460. },
  461. shikongconfirm(e){
  462. console.log(e)
  463. this.shikongLabel = e[0].label+'-'+e[1].label
  464. this.equipContrlForm.START_TIME = e[0].value
  465. this.equipContrlForm.END_TIME = e[1].value
  466. },
  467. photoConfirm(e){
  468. this.photoLabel = e[0].label+'-'+e[1].label
  469. this.equipContrlForm.P_START = e[0].value
  470. this.equipContrlForm.P_END = e[1].value
  471. },
  472. turnChange(e, a) {
  473. this.equipContrlForm.ts = e.target.value
  474. },
  475. async getInfo() {
  476. let res = await this.$myRequest({
  477. url: '/api/api_gateway?method=new_gateway.device_info.get_device_config',
  478. data: {
  479. device_type_id:this.device_type,
  480. id: this.d_id
  481. }
  482. })
  483. if(res.code==4000){
  484. this.submitBtnDisabled = true
  485. this.$refs.toast.show({
  486. title: res.msg,
  487. type: 'warning'
  488. })
  489. return
  490. }
  491. this.equipContrlForm = res
  492. this.equipContrlForm.TEMP_LIMIT = res.TEMP_LIMIT=='1'
  493. this.equipContrlForm.TEMP_UP = (res.TEMP_UP||50)-0
  494. this.equipContrlForm.TEMP_DOWN = (res.TEMP_DOWN||0)-0
  495. this.photoLabel = (res.P_START||'00:00')+' - '+ (res.P_END||'00:00')
  496. this.shikongLabel = res.START_TIME + ':00' + ' - '+res.END_TIME + ':00'
  497. console.log(this.equipContrlForm,'0000')
  498. },
  499. async submit() {
  500. console.log(this.equipContrlForm)
  501. this.equipContrlForm.TEMP_LIMIT = this.equipContrlForm.TEMP_LIMIT ? '1':'0'
  502. let res = await this.$myRequest({
  503. url: '/api/api_gateway?method=new_gateway.device_info.update_device_config',
  504. data: {
  505. device_type_id: this.device_type,
  506. id: this.d_id,
  507. ...this.equipContrlForm
  508. }
  509. })
  510. if(res){
  511. this.$refs.toast.show({
  512. title: '修改成功!',
  513. type: 'success',
  514. })
  515. }
  516. if(res.code==4000){
  517. this.$refs.toast.show({
  518. title: res.msg+'无法修改',
  519. type: 'warning'
  520. })
  521. }
  522. },
  523. async equipBtnControl(cmd) {
  524. let res = await this.$myRequest({
  525. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  526. data: {
  527. cmd,
  528. device_type_id: this.device_type,
  529. d_id: this.d_id
  530. }
  531. })
  532. if (res) {
  533. this.$refs.toast.show({
  534. title: '指令下发成功!',
  535. type: 'success',
  536. })
  537. }
  538. },
  539. async mqttInfo() {
  540. let res = await this.$myRequest({
  541. url: '/api/api_gateway?method=forecast.send_control.device_control_info',
  542. data: {
  543. cmd: 'netconf',
  544. d_id: this.d_id
  545. }
  546. })
  547. if (res) {
  548. let {
  549. ftp,
  550. mqtt
  551. } = res
  552. this.mqttConfig = {
  553. muid: mqtt.uid,
  554. mpwd: mqtt.pwd,
  555. mip: mqtt.ip,
  556. mport: mqtt.port,
  557. mpub: mqtt.pub,
  558. msub: mqtt.sub,
  559. fuid: ftp.uid,
  560. fpwd: ftp.pwd,
  561. fip: ftp.ip,
  562. fport: ftp.port
  563. }
  564. }
  565. this.mqttShow = true
  566. },
  567. async mqttSubm() {
  568. let obj = {
  569. mqtt: {
  570. uid: this.mqttConfig.muid,
  571. pwd: this.mqttConfig.mpwd,
  572. ip: this.mqttConfig.mip,
  573. port: this.mqttConfig.mport,
  574. pub: this.mqttConfig.mpub,
  575. sub: this.mqttConfig.msub,
  576. keepalive: 60,
  577. lastwill: '/yfkj/cbd/offline/'
  578. },
  579. ftp: {
  580. uid: this.mqttConfig.fuid,
  581. pwd: this.mqttConfig.fpwd,
  582. ip: this.mqttConfig.fip,
  583. port: this.mqttConfig.fport
  584. }
  585. }
  586. let res = await this.$myRequest({
  587. url: '/api/api_gateway?method=forecast.send_control.device_control',
  588. data: {
  589. device_type_id: 3,
  590. d_id: this.d_id,
  591. cmd: 'setnet',
  592. config: JSON.stringify(obj)
  593. }
  594. })
  595. }
  596. }
  597. }
  598. </script>
  599. <style lang="scss" scoped>
  600. page {
  601. padding: 20rpx;
  602. box-sizing: border-box;
  603. .tit {
  604. line-height: 30rpx;
  605. font-size: 28rpx;
  606. margin: 30rpx 0;
  607. color: #666666;
  608. }
  609. .adminTit {
  610. border-left-color: #e64340;
  611. }
  612. .btns {
  613. display: flex;
  614. justify-content: flex-start;
  615. flex-wrap: wrap;
  616. gap: 16rpx;
  617. button {
  618. margin: 0;
  619. margin-right: 10rpx;
  620. padding: 0 25rpx;
  621. }
  622. }
  623. .uni-list-cell {
  624. // background: #F7F8FA;
  625. // padding: 10rpx 40rpx;
  626. height: 80rpx;
  627. line-height: 80rpx;
  628. font-size: 28rpx;
  629. box-sizing: border-box;
  630. .arrow{
  631. margin-left: 30rpx;
  632. }
  633. .right-data{
  634. color: #CCCCCC;
  635. }
  636. }
  637. .selectTime {
  638. display: flex;
  639. float: right;
  640. width: 30%;
  641. color: #CCCCCC;
  642. justify-content: space-between;
  643. .time {
  644. // width: 350rpx;
  645. // display: flex;
  646. // justify-content: space-between;
  647. }
  648. .line {
  649. width: 50rpx;
  650. text-align: center;
  651. }
  652. }
  653. .submit-box {
  654. margin-top: 60rpx
  655. }
  656. .mqtt-popup {
  657. width: 580rpx;
  658. }
  659. .mqtt-btn-box {
  660. margin-top: 50rpx;
  661. text-align: center;
  662. }
  663. }
  664. </style>